akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  // cin>>n>>m;
  string s;
  cin>>s;
  s[0] = '2';
  s[1] = '0';
  s[2] = '1';
  s[3] = '8';
  cout<<s<<endl;
}

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


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define Yes(condition) if(condition){ cout << "Yes" << '\n'; }else{ cout << "No" << '\n'; }
#define YES(condition) if(condition){ cout << "YES" << '\n'; }else{ cout << "NO" << '\n'; }
#define yes(condition) if(condition){ cout << "yes" << '\n'; }else{ cout << "no" << '\n'; }




int main() {
    ll n;
    double t, a;
    cin >> n >> t >> a;
    double b = -1000000;
    ll ans = 0;
    REP(i, n){
        ll h;
        cin >> h;
        if(abs(a - (t - b * 0.006)) > abs(a - (t - h * 0.006))){
            b = h;
            ans = i + 1;
        }
    }
    cout << ans << endl;
}


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


#define fs first
#define sc second
#define endl "\n"

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<int, int> P;


int main(){
    int n, m;   cin >> n >> m;
    string s;   cin >> s;

    vector<P> seList;
    seList.emplace_back(P(n, n));
    while(true){
        int nextEnd = seList[seList.size()-1].fs-1;
        int nextStart = max(0, seList[seList.size()-1].fs - m);
        while(s[nextEnd] == '1'){
            nextEnd--;
        }
        while(s[nextStart] == '1'){
            nextStart++;
        }

        if(nextStart > nextEnd){
            cout << -1 << endl;
            return 0;
        }

        seList.emplace_back(P(nextStart, nextEnd));

        if(nextStart == 0){
            break;
        }
    }

    reverse(seList.begin(), seList.end());
    int now = 0;
    for(auto range: seList){
        if(range.fs == 0){
            continue;
        }
        cout << range.fs - now << " ";
        now = range.fs;
    }

    cout << endl;


    return 0;
}


Measured memory_bytes: 1528
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>
#include <stack>
#include <map>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
//static const long double pi = 3.1415926535897932;

using namespace std;
using ll = long long int;
using ull = unsigned long long;

char toSmall(char c) { // 大文字を小文字へ
	return (c + 0x20);
}

char toLarge(char c) { // 小文字を大文字へ
	return (c - 0x20);
}

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

ll combination(ll n, ll r) { // nCr の計算
	if (n < 0 || r < 0 || r > n) return -1;

	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> num(r);
	vector<ll> den(r);

	for (ll i = 0; i < r; i++) {
		num[i] = n - r + i + 1;
		den[i] = i + 1;
	}

	for (ll p = 2; p <= r; p++) {
		ll pivot = den[p - 1];
		if (pivot > 1) {
			ll offset = (n - r) % p;
			for (ll k = p - 1; k < r; k += p) {
				num[k - offset] /= pivot;
				den[k] /= pivot;
			}
		}
	}
	ll result = 1;
	for (ll k = 0; k < r; k++) {
		if (num[k] > 1) result *= num[k];
	}
	return result;
}

vector<string> split(const string& src, const char* delim = ",") { //カンマ区切り
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

bool check_int(string str)
{
	if (all_of(str.cbegin(), str.cend(), [](char ch) { return isdigit(ch);}))
	{
		return true;
	}
	return false;
}

map<string, int> input;

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		input[s] += 1;
	}
	int max = 0;
	for (const auto& x : input) {
		int v = x.second;
		if (v > max) {
			max = v;
		}
	}
	for (auto it = input.begin(); it != input.end(); it++) {
		if (it->second == max) {
			cout << it->first << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 19228
#include<iostream>
using namespace std;
#define MAX 100000

int parent(int i) { return i / 2; }
int left(int i) { return 2*i; }
int right(int i ) { return 2*i +1;}

int main() {
  int H, i, A[MAX + 1];
  //1-origin
  cin >> H;
  for ( i = 1; i <= H; i++) cin >> A[i];

  for(i = 1; i <= H; i++) {
    cout << "node " << i << ": key = " << A[i] << ", ";
    if(parent(i) >= 1)cout << "parent key = " << A[parent(i)] << ", ";
    if(left(i) <= H)cout << "left key = " << A[left(i)] << ", ";
    if(right(i) <= H)cout << "right key = " << A[right(i)] << ", ";
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1168
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int N;
int X[50];
int Y[50];

int GetCost(int p, int q)
{
	bool flg[50] = {};
	int cnt = 0;
	int cost = 0;

	while (true)
	{
		int best_x = p > 0 ? INT_MIN : INT_MAX;
		int best_y = q > 0 ? INT_MIN : INT_MAX;
		int best = -1;
		for (int i = 0; i < N; i++)
		{
			if (!flg[i])
			{
				if (p > 0)
				{
					if (best_x < X[i])
					{
						best_x = X[i];
						best_y = Y[i];
						best = i;
					}
					else if (best_x == X[i])
					{
						if (q > 0)
						{
							if (best_y < Y[i])
							{
								best_y = Y[i];
								best = i;
							}
						}
						else
						{
							if (best_y > Y[i])
							{
								best_y = Y[i];
								best = i;
							}
						}
					}
				}
				else
				{
					if (best_x > X[i])
					{
						best_x = X[i];
						best_y = Y[i];
						best = i;
					}
					else if (best_x == X[i])
					{
						if (q > 0)
						{
							if (best_y < Y[i])
							{
								best_y = Y[i];
								best = i;
							}
						}
						else
						{
							if (best_y > Y[i])
							{
								best_y = Y[i];
								best = i;
							}
						}
					}
				}
			}
		}

		cost++;
		cnt++;
		flg[best] = true;

		int cx = X[best];
		int cy = Y[best];

		while (true)
		{
			bool is_found = false;
			for (int i = 0; i < N; i++)
			{
				int nx = cx - p;
				int ny = cy - q;
				if (!flg[i])
				{
					if (X[i] == nx && Y[i] == ny)
					{
						cx = nx;
						cy = ny;
						cnt++;
						flg[i] = true;
						is_found = true;
					}
				}
			}
			if (!is_found) break;
		}

		if (cnt == N)
		{
			break;
		}
	}

	return cost;
}


signed main()
{
	cin >> N;
	REP(i, N) cin >> X[i] >> Y[i];

	int min = N;

	for (int i = 0; i < N; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			int cost1 = GetCost(X[i] - X[j], Y[i] - Y[j]);
			int cost2 = GetCost(X[j] - X[i], Y[j] - Y[i]);

			min = MIN(min, cost1);
			min = MIN(min, cost2);
		}
	}

	cout << min << endl;
}









Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
int N,a,t;
int i,j,miyaki;
long long dp[100][21]={0};
scanf("%d",&N);
scanf("%d",&a);
dp[0][a]++;
for(i=1;i<N-1;i++){
scanf("%d",&a);
for(j=0;j<21;j++){
if(dp[i-1][j]!=0){
t=a+j;
if(t>=0&&t<21){
dp[i][t]=dp[i][t]+dp[i-1][j];
}
t=j-a;
if(t>=0&&t<21){
dp[i][t]=dp[i][t]+dp[i-1][j];
}
}
}
}
scanf("%d",&a);
printf("%lld\n",dp[N-2][a]);
return 0;
}

Measured memory_bytes: 624
#include <iostream>
int main(int argc, char* argv[]){
  int a, b, c;
  std::cin >> a >> b >> c;
  int r = b + c - a;
  if (r > 0){
    std::cout
        << (b + c - a) << std::endl;
  } else {
    std::cout
        << 0 << std::endl;
  }
  return 0;
}


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

int main() {
  long long a, b;
  cin >> a >> b;
  long long x;
  cin >> x;

  long long s, t;
  s = b / x + 1;
  if (a == 0) t = 0;
  else t = (a - 1) / x + 1;
  
  cout << s - t << endl;

  return 0;
}


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

namespace ProconTemplate
{
    class Doing
    {
        public static void Main(string[] args)
        {
            var inList = new List<int>();
            for (int iLoop = 0; iLoop < 5; iLoop++)
            {
                inList.Add(int.Parse(Console.ReadLine()));
            }

            var limit = int.Parse(Console.ReadLine());

            for (int xIndex=0;xIndex < 4; xIndex++)
            {
                for(int yIndex = xIndex+1;yIndex < 5; yIndex++)
                {
                    if (Math.Abs(inList[xIndex] - inList[yIndex]) > limit)
                    {
                        Console.WriteLine(":(");
                        return;
                    }
                }
            }

            Console.WriteLine("Yay!");
        }
    }
}


Measured memory_bytes: 11092
def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end
n = inp[0]
load = (0...n).to_a

ans = 0
x = []
y = []
n.times do |i|
  x[i],y[i] = inp
end
c = 0
load.permutation(n).each do |t|
  c += 1
  (t.size-1).times do |i|
    ans += ((x[t[i]]-x[t[i+1]])**2 + (y[t[i]]-y[t[i+1]])**2)**0.5
  end
end
p ans / c

Measured memory_bytes: 2300
from heapq import heappush, heappop, heapify

n = int(input())
lst = list(map(int, input().split()))
preQue = sorted(lst[:n])
mid = lst[n:2*n]
sufQue = sorted([-i for i in lst[2*n:]])

preScore = sum(preQue)
preScores = [preScore]
heapify(preQue)
for i in mid:
    v = heappop(preQue)
    if v < i:
        preScore += (i - v)
        heappush(preQue, i)
    else:
        heappush(preQue, v)
    preScores.append(preScore)

sufScore = sum(sufQue)
sufScores = [sufScore]
heapify(sufQue)
for i in mid[::-1]:
    v = heappop(sufQue)
    if -v > i:
        sufScore += (-v - i)
        heappush(sufQue, -i)
    else:
        heappush(sufQue, v)

    sufScores.append(sufScore)

sufScores.reverse()
ans = max([p + s for p, s in zip(preScores, sufScores)])
print(ans)


Measured memory_bytes: 37212
//In The Name of Allah
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 10;

int h[N], dp[N];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i ++)
        cin >> h[i];
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < n; i ++)
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    cout << dp[n - 1];
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
char s[11][1111];
int main(){
    int n, w, K, h;
    while(cin>>h>>w>>K){
        int ans=h*w;
        for(int i=0; i<h; ++i){
            scanf("%s",s[i]);
        }
        for(int i=0; i<(1<<(h-1)); ++i){
        	bool fl=1;
        	int tmp=0;
        	bool l[11]={0};
        	vector<int> v;
        	for(int j=0; j<h-1; ++j){
        		if((1<<j)&i){
        			l[j]=1;
        			v.push_back(0);
        		}
        	}
        	v.push_back(0);
        	int cnt=0;
        	for(int j=0; j<w; ++j){
        		int mx=0;
        		cnt=0;
        		fill(v.begin(), v.end(), 0);
        		for(int k=0; k<h; ++k){
        			v[cnt]+=s[k][j]-'0';
        			mx=max(mx, v[cnt]);
        			if(l[k]){
        				++cnt;
        			}
        		}
        		if(mx>K){
        			fl=0;
        			break;
        		}
        		for(int jj=j+1; jj<w; ++jj){
        			cnt=0;
        			for(int k=0; k<h; ++k){
	        			v[cnt]+=s[k][jj]-'0';
	        			mx=max(mx, v[cnt]);
	        			if(l[k]){
	        				++cnt;
	        			}
	        		}
	        		j=jj-1;
	        		if(mx>K){
	        			++tmp;
	        			break;
	        		}
        		}
        	}
        	if(fl)	
	        	ans=min(ans, (int)v.size()-1+tmp);
        }
        cout<<ans<<endl;
    }
  return 0;
}




Measured memory_bytes: 256
N,K=map(int,input().split())
H=list(map(int,input().split()))+[0]
h=[0]*(N+1)
h[0]=H[0]
for i in range(1,N):
    h[i]=max(H[i]-H[i-1],h[i])
for i in range(1,N+1):
    h[i]+=h[i-1]
data=[[0]*N for i in range(N)]
for L in range(N):
    for R in range(L,N):
        if L==0:
            data[L][R]=h[-1]-h[R+1]+H[R+1]
        else:
            data[L][R]=h[L-1]+h[-1]-h[R+1]+max(0,H[R+1]-H[L-1])
for L in range(N):
    for R in range(L,N):
        data[L][R]=h[-1]-data[L][R]
dp=[[0]*(K+1) for i in range(N+1)]
for i in range(1,N+1):
    for j in range(min(i+1,K+1)):
        dp[i][j]=dp[i-1][j]
        for k in range(j-1,-1,-1):
            if dp[i][j]<dp[i-1-j+k][k]+data[i-j+k][i-1]:
                dp[i][j]=dp[i-1-j+k][k]+data[i-j+k][i-1]
print(h[-1]-max(dp[N]))

Measured memory_bytes: 44396
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

using pii = pair<int, int>;
vector<vector<int> > g;
vector< int > cost;

int solve(){
  queue<int> q;
  int k;
  q.push(0);
  while(!q.empty()){
    k= q.front();
    q.pop();
    for(auto v:g[k]){
      cost[v] += cost[k];
      q.push(v);
    }
  }
  return 0;
}

int main(int argc, char* argv[]){
  int n, q; cin >> n >> q;
  g = vector< vector<int> >(n, vector<int>());
  for(int i = 0; i < n-1 ; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
  }
  cost = vector< int>(n, 0);
  for(int i = 0; i < q; i++){
    int p, x;
    cin >> p >> x;
    p--;
    cost[p] += x;
  }
  solve();
  for(int i = 0; i < n; i++){
    cout << cost[i] << ' ';
  }
  cout << endl;
}


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

typedef long long int ll;

int main(){
    string s;
    cin>>s;
    map<char,int>check;
    for(int i=0;i<s.size();i++) check[s[i]]++;
    bool flag=true;
    for(auto x:check){
        if(x.second%2!=0) {
            flag=false;
            break;
        }
    } 
    if(flag) printf("Yes\n");
    else printf("No\n");
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int main() {
  const ULL m = 1e9 + 7;
  int n;
  ULL p = 1;
  cin >> n;

  REP(i, n) {
    p *= i+1;
    p %= m;
  }

  cout << p << endl;

  return 0;
}


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

int main() {
  int x, a, b;
  scanf("%d %d %d", &x, &a, &b);
  if(b - a <= 0)
    printf("delicious\n");
  else if(b - a <= x)
    printf("safe\n");
  else
    printf("dangerous\n");
}

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

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

const long long INF = 1LL << 60;

int main(){
  int a, b;
  cin >> a >> b;

  cout << (a+b) % 24 << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    S = list(input())
    N = len(S)

    val = [0] * (2019)
    tenfactor = 1
    cur = 0
    val[cur] += 1
    for i in range(N):
        cur = (cur + int(S[N - i - 1]) * tenfactor) % 2019
        tenfactor = (tenfactor * 10) % 2019
        val[cur] += 1

    ans = 0
    for p in range(2019):
        ans += val[p] * (val[p] - 1) // 2
    print(ans)


if __name__ == "__main__":
    main()


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

namespace atcorder_GrandContest_031
{
    class Program
    {

        public const int MOD = 1000000000 + 7;

        static void Main(string[] args)
        {

            int cnt = int.Parse(Console.ReadLine());
            var data = Console.ReadLine().ToArray();

            List<int> charList = new List<int>();
            int[] cntArr = new int[128];

            int charCnt = 0;

            for (int i = 0; i < cnt; i++)
            {
                int aVal = (int)data[i];
                if (0 == cntArr[aVal])
                {
                    charList.Add(aVal);
                    charCnt++;
                }
                cntArr[aVal]++;
            }

            long ret = 1;
            for (int i = 0; i < charCnt; i++)
            {
                ret *= cntArr[charList[i]] + 1;
                ret %= MOD;
            }

            ret--;

            Console.WriteLine(ret);

        }

    }
}



Measured memory_bytes: 13268
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    int n = 0;
    cin >> n;
    vector<int> b(n-1);
    for (int i=0; i<n-1; i++) {
        cin >> b.at(i);
    }
    int ans = b.at(0) + b.at(n-2);
    for (int i=0; i<n-2; i++) {
        ans += min(b.at(i), b.at(i+1));
    }
    cout << ans << endl;
    return 0;
}


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

namespace ConsoleApp2
{
    class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
 
            var n = int.Parse(Console.ReadLine());
            int[] cc = new int[10000+1];
            cnt(cc);
            for (int i = 1; i <= n; i++)
            {
                Console.WriteLine(cc[i]);
            }
 
            // 10000 1+1+z*z+1+z+z
            Console.Out.Flush();
        }
 
        public static int calc(int x, int y, int z)
        {
            return (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (x * z);
        }
 
        public static void cnt(int[] cc)
        {
            int m = 100;
            for (int x = 1; x < m; x++)
            {
                for (int y = 1; y < m; y++)
                {
                    for (int z = 1; z < m; z++)
                    {
                        var d = calc(x, y, z);
                        if (d<=10000)
                        {
                            cc[d]++;
                        }
                    }
                }
            }
        }
        //static void Main(string[] args)
        //{
        //    //var N = GetLongNum();
        //    var x = 1;
        //    var y = 1;
        //    var z = 1;
        //    double n = 0;

        //    while (n <= 1000)
        //    {
        //        n = Math.Pow(x, 2) + Math.Pow(y, 2) + Math.Pow(z, 2) + x * y + y * z + x * z;
        //        Console.WriteLine(n + " " + x + " " + y + " " + z);
        //        if (x == y && x == z)
        //        {
        //            x++;
        //        }
        //        else if (x > y)
        //        {
        //            y++;
        //        }
        //        else if (y > z)
        //        {
        //            z++;
        //        }
        //    }

        //    //n = Math.Pow(x, 2) + Math.Pow(y, 2) + Math.Pow(z, 2) + x * y + y * z + x * z;
        //    //Console.WriteLine(n);
        //}

        //private static long[] GetLongNumArray()
        //{
        //    var input = Console.ReadLine().Split(' ');
        //    return input.Select(x => long.Parse(x)).ToArray();
        //}

        //private static long GetLongNum()
        //{
        //    return long.Parse(Console.ReadLine());
        //}

        //private static string[] GetStringArray()
        //{
        //    return Console.ReadLine().Split(' ');
        //}

        //private static string GetString()
        //{
        //    return Console.ReadLine();
        //}
    }
}


Measured memory_bytes: 27340
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <random>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr ll INF = 1LL << 60;

ll n, k, c, l[200010], r[200010];
string s;

int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> n >> k >> c >> s;

  for(int i = 0; i < n; ++i) {
    if (s[i] == 'o') {
      l[i + 1]++;
      i += c;
    }
  }
  for(int i = n - 1; i >= 0; --i) {
    if (s[i] == 'o') {
      r[i]++;
      i -= c;
    }
  }
  REP(i, n) l[i + 1] += l[i];
  for(int i = n; i >= 1; --i) r[i - 1] += r[i];
  
  // check: 
  for(int i = 0; i < n; ++i) {
    if(l[i] + r[i + 1] < k) {
      cout << i + 1 << '\n';
    }
  }
  return 0;
}



Measured memory_bytes: 5012
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int h, w;
    cin >> h >> w;
    auto A = make_v(h, w, 0);
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> A[i][j];
        }
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            int x;
            cin >> x;
            A[i][j] -= x;
        }
    }
    auto v = make_v(h, w, vector<int>{});
    v[0][0].resize((h+w)*82);
    v[0][0][abs(A[0][0])]++;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            for (int k = 0; k < v[i][j].size(); ++k) {
                if(!v[i][j][k]) continue;
                if(i != h-1){
                    v[i+1][j].resize((h+w)*82);
                    v[i+1][j][abs(k-A[i+1][j])]++;
                    v[i+1][j][abs(k+A[i+1][j])]++;
                }
                if(j != w-1){
                    v[i][j+1].resize((h+w)*82);
                    v[i][j+1][abs(k-A[i][j+1])]++;
                    v[i][j+1][abs(k+A[i][j+1])]++;
                }
            }
            if(i != h-1 || j != w-1) v[i][j].clear();
        }
    }
    for (int i = 0; i < v.back().back().size(); ++i) {
        if(v.back().back()[i]){
            cout << i << "\n";
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 328576
#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()

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

    long long cur = A[n-2]; 
    long long sum = A[n-1];
    long long ans = 0;
    long long mod = 1000000007;
    
    for(int i=n-2; i>=0; i--){
        ans += (sum * A[i]) % mod;
        sum += A[i];
        sum %= mod;
    }

    cout << ans % mod << endl;
}

Measured memory_bytes: 4832
#include<bits/stdc++.h>
using namespace std;
#define mx 1000000000000000000
#define ll long long int
ll a[40001000];
//ll number[20],used[20];
int main()
{
  ll i,j,count =0,n;
  cin>> n;
  for(i=0;i<n;i++)
    cin>> a[i];
  sort(a,a+n);
  for(i=0;i<n-1;i++)
  {
      if(a[i]!=a[i+1])
        count=0;
      else
      {
          count=1;
          break;
      }
  }
  if(count==0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 5216
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;



int main(){
    int a, b;
    cin >> a >> b;
    int s = max(0, 4 - a), t = max(0, 4 - b);
    ll res = s * 100000 + t * 100000;
    if(a == 1 && b == 1)res += 400000;
    cout << res;
}

Measured memory_bytes: 256
#include <stdio.h>
#define max(p,q)((p)>(q)?(p):(q))

int h[100010];
int tate[100010],yoko[100010],cnt;

int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",h+i);
	cnt=1;
	long ans=0;
	for(int i=0;i<=n;i++){
		if(h[i]>tate[cnt-1]){
			tate[cnt]=h[i];
			yoko[cnt]=i;
			cnt++;
		}
		if(h[i]<tate[cnt-1]){
			while(tate[cnt-1]>h[i]){
				ans=max(ans,1LL*tate[cnt-1]*(i-yoko[cnt-1]));
				cnt--;
			}
			tate[cnt]=h[i];
			cnt++;
		}
	}
	printf("%ld\n",ans);
}


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  
  int x = max(a*c, b*c), y=max(a*d, b*d);
  
  cout<<max(x, y);
  return 0;
}

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

using namespace std;

int main() {
	string s[101];
	int n, L;
	scanf("%d %d", &n, &L);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	sort(s, s + n);
	for (int i = 0; i < n; i++) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <limits>
#include <cassert>
#include <fstream>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <ciso646>
#include <array>
#include <cmath>
 
using namespace std;
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
 
#define inf 0x3f3f3f3f
#define uinf 0x3f3f3f3f3f3f3f3f
#define CLEAR(a) a = decltype(a)()
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define pii pair<int ,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define VVI vector<vector<int>>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define pi 2*acos(0.0)
#define INFILE() freopen("in.txt","r",stdin)
#define OUTFILE() freopen("out.txt","w",stdout)
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define FIN std::ifstream cin("D:\input.txt")
const int MOD = 1e9 + 7;
 
signed int main(void) {
	int N, M; cin >> N >> M;
	vector<int> count(N, 1);
	bitset<100001> isRed;
	isRed[0] = true;
	REP(i, M) {
		int x, y; cin >> x >> y;
		--x; --y;
		count[x]--;
		count[y]++;
 
		if (isRed[x]) isRed[y] = true;
		if (count[x] == 0) isRed[x] = false;
	}
	cout << isRed.count() << endl;
	return 0;
}

Measured memory_bytes: 888
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int 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;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}

class BIT {
private:
	vector<int>bit;
	int n;
public:
	BIT(int _n) {
		rep(i, _n + 1) bit.push_back(0);
		n = _n;
	}

	int get() {
		return bit.size();
	}

	int sum(int i) {
		int s = 0;
		while (i > 0) {
			s += bit[i];
			i -= (i & -i);
		}
		return s;
	}

	int sum(int i, int j) {
		int be = sum(i - 1);
		int af = sum(j);
		return af - be;
	}

	void add(int i, int x) {
		while (i <= n) {
			bit[i] += x;
			i += (i & -i);
		}
	}
};

signed main() {
	int n;
	int k;
	cin >> n >> k;
	int a[100005], sum[100005], x[100005];
	sum[0] = 0;
	rep(i, n) {
		cin >> a[i];
		a[i] -= k;
		sum[i + 1] = sum[i] + a[i];
	}
	rep(i, n + 1) {
		x[i] = sum[i];
	}
	sort(x, x + n + 1);
	map<int, int>mp;
	int now = 1;
	mp[x[0]] = 1;
	for (int i = 1; i < n + 1; i++) {
		if (x[i] > x[i - 1]) {
			now++;
		}
		mp[x[i]] = now;
	}
	rep(i, n + 1) {
		sum[i] = mp[sum[i]];
	}
	int ans = 0;
	BIT bit(n);
	for (int i = n - 1; i >= 0; i--) {
		bit.add(sum[i + 1], 1);
		ans += (n - i) - bit.sum(sum[i] - 1);
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 12520
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int N, M; cin >> N >> M;
    int mi = 0, ma = N;
    int L=0, R=0;
    for(int i=0; i < M; i++) {
        cin >> L >> R;

        if(R < mi) {
            cout << 0 << endl;
            return 0;
        }

        if(L > ma) {
            cout << 0 << endl;
            return 0;
        }

        if(L > mi && L <= ma) {
            mi = L;
        }
        if(R < ma && R >= mi) {
            ma = R;
        }

    }

    cout << ma - mi + 1 << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin>>n;
  int arr[n];
  double total=0;
  for(int i=0;i<n;i++){
    cin>>arr[i];
    total+=1/(double)arr[i];
  }
  total=1/(double)total;
  cout<<total<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <cmath>

using namespace std;

int main(int argc, const char * argv[]) {
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int m = max({a,b,c});
    if (m == a) {
        cout << a*pow(2,k) + b + c << "\n";
    } else if (m == b) {
        cout << a + b*pow(2,k) + c << "\n";
    } else {
        cout << a + b + c*pow(2,k) << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	static long inverse=0;
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int[] sorts=new int[N];
		for(int i=0; i<N; i++) {
			sorts[i]=sc.nextInt();
		}
		sort(sorts);
		pl(inverse);
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void mergesort(int[] splits) {
		if(splits.length>1) {
			int len=splits.length;
			int left=len/2;
			int right=len-left;
			int[] leftarray=new int[left];
			int[] rightarray=new int[right];
			for(int i=0; i<len; i++) {
				if(i<left) {
					leftarray[i]=splits[i];
				}
				else {
					rightarray[i-left]=splits[i];
				}
			}
			mergesort(leftarray);
			mergesort(rightarray);
			merge(leftarray,rightarray,splits);
		}
	}
	public static void merge(int[] a,int[] b,int[] source) {
		int left=0;
		int right=0;
		while(left<a.length || right<b.length) {
			if(right>=b.length || (left<a.length && a[left]<=b[right])) {
				source[left+right]=a[left];
				left++;
			}
			else {
				source[left+right]=b[right];
				inverse+=((long)a.length)-((long)left);
				right++;
			}
		}
	}
	public static void sort(int[] sortarray) {
		mergesort(sortarray);
	}
}


Measured memory_bytes: 100928
//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int n,k;
vector<int>v[100005];
int vis[100005];
int mod=1e9+7;
int dfs(int pos,int par)
{
    vis[pos]=1;
    int sz=1;
    for(auto i:v[pos])
        sz+=vis[i];
    int ans=1;
    for(auto i:v[pos])
        if(i!=par)
        {
            ans=(ans*(((k-sz)*dfs(i,pos))%mod))%mod;
            sz++;
        }
    return ans;
}
int32_t main()
{
    IOS;
    cin>>n>>k;
    for(int i=0;i<n-1;i++)
    {
        int a,b;
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    if(n==1)
        return cout<<k,0;
    if(n==2)
        return cout<<(k*(k-1))%mod,0;
    int st=-1;
    for(int i=1;i<=n;i++)
    {
        if(st==-1 && v[i].size()==1)
            st=i;
        if(v[i].size()+1>k)
            return cout<<0,0;
    }
    int ans=(k*(k-1))%mod;
    vis[st]=1;
    ans=(ans*dfs(v[st][0],st))%mod;
    print(ans);
}


Measured memory_bytes: 17640
//Zory-2018
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
#include<stack>
using namespace std;

namespace mine
{
	const int MAX_N=5100;
	typedef long long ll;

	int hou[MAX_N],siz[MAX_N];
	struct Edge{int y,g;}e[MAX_N*2];
	int ln=0;void ins(int x,int y) {e[++ln]=(Edge){y,hou[x]};hou[x]=ln;}

	const ll MOD=1e9+7;
	void addup(ll &x,ll y) {x=(x+y)%MOD;}

	ll g[MAX_N],f[MAX_N][MAX_N],tmp[MAX_N];
	void dfs(int x,int fa)
	{
		siz[x]=1;f[x][1]=1;
		for(int k=hou[x];k>0;k=e[k].g)
		{
			int y=e[k].y;if(y==fa) continue;
			dfs(y,x);
			for(int i=0;i<=siz[x]+siz[y];i++) tmp[i]=0;
			for(int sz1=0;sz1<=siz[x];sz1++)
				for(int sz2=0;sz2<=siz[y];sz2++)
				{
					addup(tmp[sz1+sz2],f[x][sz1]*f[y][sz2]%MOD);
					if(sz2%2==0) addup(tmp[sz1],-f[x][sz1]*f[y][sz2]%MOD*g[sz2]%MOD);
				}
			siz[x]+=siz[y];
			for(int i=0;i<=siz[x];i++) f[x][i]=tmp[i];
		}
	}

	void main()
	{
		int n;scanf("%d",&n);
		for(int i=1;i<=n-1;i++)
		{
			int x,y;scanf("%d%d",&x,&y);
			ins(x,y);ins(y,x);
		}
		g[0]=1;for(int i=2;i<=n;i+=2) g[i]=g[i-2]*(i-1)%MOD;

		dfs(1,0);
		ll ans=0;
		for(int sz=2;sz<=n;sz+=2) addup(ans,f[1][sz]*g[sz]%MOD);
		addup(ans,MOD);
		printf("%lld",ans);
	}
};

int main()
{
	mine::main();
}


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

int main(){
	int x,y,z;
	cin >> x ;
	y=x % 3600;
	z=y % 60;
	y=y / 60;
	x=x / 3600;
    cout << x << ':' << y << ':' << z << endl;

    return 0;
}

Measured memory_bytes: 1160
import Control.Applicative
import Control.Monad
import Data.List (foldl')

doOrder :: [String] -> String -> IO String
doOrder (order:args) s =
    case order of
        "print" -> do
            let [a,b] = map read args
            putStrLn . take (b-a+1) . drop a $ s
            return s
        "reverse" -> do
            let
                [a,b] = map read args
                (pre,m) = splitAt a s
                (mid,rest) = splitAt (b-a+1) m
            return $ pre ++ reverse mid ++ rest
        "replace" -> do
            let
                [a,b] = map read . take 2 $ args
                (pre,m) = splitAt a s
                rest = drop (b-a+1) m
            return $ pre ++ last args ++ rest

main = do
    source <- getLine
    n <- readLn
    replicateM n getLine >>=
        flip (foldl' (>=>) return) source . map (doOrder . words)
    return ()

Measured memory_bytes: 5632
n,k,q = map(int,input().split())
li = [k-q for i in range(n)]
a = 0
for i in range(q):
    a = int(input())
    li[a-1]+=1
for i in range(n):
    if li[i] <= 0:
        print("No")
    else:
        print("Yes")

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

using namespace std;

typedef unsigned long long ll;

int main(){
        int N;
        vector<ll> T;
        cin>>N;
        for(int i=0;i<N;i++){
                ll t;
                cin>>t;
                T.push_back(t);
                //cout<<"success"<<endl;
        }
        sort(T.begin(), T.end());
        while(T.size()>1){
                ll a=T[1], b=T[0];
                ll t=a%b;
                while(t!=0){
                        a=b;
                        b=t;
                        t=a%b;
                }
                //cout<<T[1]/b*T[0]<<endl;
                T.push_back(T[1]/b*T[0]);
                T.erase(T.begin());
                T.erase(T.begin());
                if(T.size()==1)
                        break;
                sort(T.begin(), T.end());
                /*for(unsigned int i=0;i<T.size();i++){
                        cout<<T[i]<<":";
                }
                cout<<endl;*/
        }
        cout<<T[0]<<endl;
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int A, B;
    std::cin>>A>>B;

    int max = std::max({A + B, A - B, A * B});
    std::cout<<max<<std::endl;
    return 0;
}

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

map<int64_t, int64_t> fact;

void factor(int64_t x){

  for (int64_t divs = 2; divs <= 1000010; divs++){
    if (x % divs == 0){
      fact[divs] = 0;
      while (x % divs == 0){
	fact[divs]++;
	x /= divs;
      }
      //cout << divs << " " << x << endl;
      continue;
    }
    if (x == 1){
      break;
    }
  }
  if (x != 1){
    fact[x] = 1;
  }
}

int main(){
  int64_t N;

  cin >> N;
  factor(N);

  int count = 0;
  int64_t p, e, z, m;
  for (auto p : fact){
    //cout << p.first << ":" << p.second << endl;
    m = p.second;
    e = 1;
    while((m = m - e) >= 0){
      //cout << "div" << endl;
      e++;
      count++;
    }
  }
  cout << count << endl;
}


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

int main() {
  // string text;
  // cin >> text;
  // if(text[text.size()-1] == 's'){
  //   text = text + "es";
  // }else{
  //   text = text + "s";
  // }
  // cout << text << endl;



  // int n;
  // int a,b;
  // int ans = 0;

  // cin >> n;

  // for(int i=0; i<n; i++){
  //   cin >> a >> b;
  //   if(a == b)ans++;
  //   else ans = 0;

  //   if(ans == 3)break;
  // }

  // if(ans == 3)cout << "Yes" << endl;
  // else cout << "No" << endl;




  int n;
  int ans =0;

  cin >> n;

  // for(int i=1; i<=n; i++){
  //   for(int j=1; 1; j++){
  //     if(i*j >= n)break;
  //     ans++;
  //     cout << "(" << i << "," << j << ")" << endl;
  //   }
  // }

  for(int i=1; i<=n; i++){
    ans += (n-1)/i;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3628
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
#include<array>
#include<iomanip>
#include<iostream>
#include<limits>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
#include<functional>

using namespace std;

typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define rep(i, n) for( int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
#define vint vector<int> 

int main(){
    int a, b;
    cin >> a >> b;
    if ((1 <= a && a <= 9) && (1 <= b && b <= 9)) cout << a * b << endl;
    else cout << -1 << endl;
    return 0;
}

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

using namespace std;
using namespace boost;

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

    vector<int> a(n);
    for (auto&& aa : a) {
        cin >> aa;
        // zero-based index
        --aa;
    }

    int ans = 0;
    for (auto i : irange(0, n)) {
        if (a[a[i]] == i) {
            ++ans;
        }
    }
    ans /= 2;

    cout << ans << endl;
}

Measured memory_bytes: 640
//
//AtCoder Beginner Contest 135
//A - Harmony
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    ll a, b;
    cin >> a >> b;

    ll k = abs(a-b);

    if (k%2 == 1) cout << "IMPOSSIBLE" << endl;
    else cout << abs(max(a,b)-k/2) << endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int x,y,z,k;
ll a[1010],b[1010],c[1010];
ll ans;
bool is_used[1010][1010][1010];
int s[3];

int main() {
    cin >> x >> y >> z >> k;

    for (int i=0;i<x;i++) cin >> a[i];
    for (int i=0;i<y;i++) cin >> b[i];
    for (int i=0;i<z;i++) cin >> c[i];
    
    sort(a,a+x,greater<ll>());
    sort(b,b+y,greater<ll>());
    sort(c,c+z,greater<ll>());

    vector<ll> v{a[0]+b[0]+c[0],0,0,0};
    is_used[0][0][0] = true;
    
    priority_queue<vector<ll>> pq;

    pq.push(v);
    for (int i=0;i<k;i++) {
        ans = pq.top()[0];
        cout << ans << endl;

        int d,e,f;
        d = pq.top()[1];
        e = pq.top()[2];
        f = pq.top()[3];

        pq.pop();   // ここにないとダメ？　同じ大きさの物で死んでそう

        if(!is_used[d+1][e][f] && d+1 < x) {
            pq.push({a[d+1]+b[e]+c[f],d+1,e,f});
            is_used[d+1][e][f] = true;
        }
        if(!is_used[d][e+1][f] && e+1 < y) {
            pq.push({a[d]+b[e+1]+c[f],d,e+1,f});
            is_used[d][e+1][f] = true;
        }
        if(!is_used[d][e][f+1] && f+1 < z) {
            pq.push({a[d]+b[e]+c[f+1],d,e,f+1});
            is_used[d][e][f+1] = true;
        }
    }
}


Measured memory_bytes: 993920