akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>

int main() {
	int a;
	std::string s;
	std::cin >> a;
	std::cin >> s;
	if (a >= 3200) {
		std::cout << s << std::endl;
		return 0;
	}
	std::cout << "red" << std::endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
using namespace std;
int gcd(int a, int b) {
	int c = a%b;
	if (c == 0) return b;
	return gcd(b, c);
}
int main() {
	int x, y;
	scanf("%d%d", &x, &y);
	printf("%d\n", gcd(x, y));
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <iomanip>
  
using namespace std;

int main()
{
	int  n, w;
	while(1){
		cin >> n >> w;
		if(n == 0 && w == 0) break;
		double height[100] = {0};
		int howmanyranges = 0;
		for(int i = 0; i < n; i++){
			int v;
			cin >> v;
			int j = 0;
			while(1){
				if(v >= j * w && v < (j + 1) * w){
					height[j]++;
					break;
				}
				else j++;
			}
			howmanyranges = max(howmanyranges, (v / w + 1));
		}
		double maxheight = 0;
		for(int i = 0; i < 100; i++){
			maxheight = max(maxheight, height[i]);
		}
		double ans = 0;
		if(howmanyranges == 1) ans = 0;
		for(int i = 0; i < 100; i++){
				ans += ((howmanyranges - 1 - i) * height[i]) / ((howmanyranges - 1) * maxheight);
				
		}
		ans += 0.01;
		cout << setprecision( 6 ) << ans << endl;
	}
}

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

int64_t f(int64_t &n){
    return n*(n-1)/2;
}

int main(){
    int n;
    cin>>n;
    
    int64_t a[n];
    rep(i,n)cin>>a[i], a[i]--;
    
    vector<int64_t> m(n,0);
    rep(i,n)m[a[i]]++;
    
    int64_t ans = 0;
    rep(i,n)ans += f(m[i]);
    
    for(int i=0; i<n; i++){
        cout << ans -( m[a[i]] - 1 ) << endl;
    }
    
    return 0;
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if (a+b==c || a+c==b || b+c==a) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
def how_many_times_divisible(n):
	ans = 0
	while n % 2 == 0:
		n /= 2
		ans += 1
	return ans
 
n = int(input())
a = map(int, input().split())
ans = min(map(how_many_times_divisible, a))
 
print(ans)

Measured memory_bytes: 2940
inp = [input() for _ in range(2)]
s = inp[0]
t = inp[1]
 
s = list(s)
t = list(t)

for i in t:
    t.append(t[0])
    t.pop(0)
    if s == t:
        print("Yes")
        break
if s != t:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double a(0), b(0); 
  cin >> a; 
  cin >> b;
  const double x = (a + b) * 0.5;
  const int xCast = static_cast<int>(x);
  
  if( x == xCast )
  {
      cout << xCast << endl;
  }
  else 
  {
      cout << xCast + 1 << endl;
  }
}

Measured memory_bytes: 256
from sys import stdin

A, B, C, K = map(int, stdin.readline().rstrip().split())
res = int(0)

def f(p, n, k, res):
    if (k - n) >= 0:
        return k - n, p * n + res
    else:
        return 0, p * k + res


K, res = f(1, A, K, res)
K, res = f(0, B, K, res)
_, res = f(-1, C, K, res)
print(res)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
#include <iostream>
typedef long long ll;
#define rep(i,a,b) for(ll i =a ;i <= b;i++)
#define per(i,a,b) for(ll i =a ;i >= b;i--)
using namespace std;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;

int main()
{
	//ifstream cin("input.txt");
	ll n;
	cin>>n;
	int c = 1;
	while(n > 4 || n == 3)
	{
		c++;
		if(n%2 == 0)
			n = n/2;
		else
			n = 3*n + 1;
	}
	cout<<c + 3;
	
}


Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include <string>
#include <utility>
#define EPS (1e-7)
using namespace std;




int main() {

	int N, K;
	vector<int> h;

	cin >> N >> K;
	h.resize(N);
	for (int i = 0; i < N; i++) {
		cin >> h[i];
	}

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

	int min_h = 1000000001;
	int ans;
	for (int i = 0; i <= N - K; i++) {
		int test = abs(h[i] - h[i + K - 1]);
		min_h = min(min_h, abs(h[i] - h[i + K - 1]));
	}

	cout << min_h << endl;

	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#define Max 1000


int main(){
	int n,i,x;
	double sum = 0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&x);
		sum += ((double)1/x);
	}

	printf("%lf\n",1/sum);


	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int a[maxn];
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        int x;
        cin >> x;
        a[x]++;
    }
    for (int i = 1; i <= n; i++)
        cout << a[i] << '\n';
}

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

#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 ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N,A,B; cin >> N >> A >> B;
    cout << min(N*A,B) << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<queue>
#include<algorithm>

using namespace std;

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

int calc(int from, int add, int t) {
  add *= t % 2 + 1;
  if (add > 9) add = add / 10 + add % 10;
  return (from + add) % 10;
}

int main() {
  int n, m;
  string str;
  cin >> n >> str >> m;
  vector<int> a(m);
  rep (i, m) cin >> a[i];
  int dp[10] ={};
  dp[0] = 1;
  reverse(str.begin(), str.end());
  rep (i, n) {
    int next[10] = {};
    rep (j, 10) {
      if (str[i] == '*') rep (k, m) next[calc(j, a[k], i)] += dp[j];
      else next[calc(j, str[i] - '0', i)] += dp[j];
    }
    rep (j, 10) dp[j] = next[j];
  }
  cout << dp[0] << endl;
  return 0;
}

Measured memory_bytes: 1336
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

mat G(200010, vec(0));
vector<bool> used(200010, false);
mat lfs(200010, vec(0));
ll dfs(ll v){
    used[v] = true;
    ll sum = 0;
    for(ll to : G[v]){
        if(!used[to]){
            ll num = dfs(to);
            lfs[v].push_back(num);
            sum += num;
        }
    }
    if(v != 0) lfs[v].push_back(N - 1 - sum);
    //else cout<<sum<<endl;
    return sum + 1;
}

ll fastpow(ll a, ll pw) {
	ll res = 1;
	while (pw) {
		if (pw & 1) res = res * a % MOD;
		a = a * a % MOD;
		pw >>= 1;
	}
	return res;
}
int main(){
    cin>>N;
    rep(i, N - 1){
        cin>>A>>B;
        --A, --B;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    dfs(0);
    vec bits(200010);
    bits[0] = 1;
    reps(i,1,200010) (bits[i] = bits[i-1] * 2)%=MOD;
    ll ans = 0;
    rep(i,N){
        ll temp = 1;
        for(ll n : lfs[i]){
            (temp += bits[n] - 1)%=MOD;
        }
        (ans += MOD + bits[N - 1] - temp)%=MOD;
    }
    (ans *= fastpow(2, MOD - 1 - N))%=MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll A, B;
    cin >> A >> B;
    ll ans = INF;
    rep(i, 10) {
        ll num = 10 * B + i;
        if (num * 8 / 100 == A) chmin(ans, num);
    }
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}


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

int main (){
    int count=0;
    string s,t;
    getline(cin,s);
    getline(cin,t);
    char a,b;
    rep(i,3){
        a=s.at(i); b=t.at(i);
        if(a==b) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
z = True
y = 0
s = ''
while a >= 50:
	x = 100
	s += '#.' * 50 + '\n'
	s += '#' * 99 + '.\n'
	y += 2
	a -= 49
s += '.#' * (a - 1) + '##' * (50 - a) + '#.\n'
s += '#' * 99 + '.\n'
s += '.' * 100 + '\n'
y += 3
b -= 1
while b >= 50:
	x = 100
	s += '#.' * 50 + '\n'
	s += '.' * 100 + '\n'
	y += 2
	b -= 50
s += '#.' * b + '..' * (50 - b)
y += 1
print(y, 100)
print(s)


Measured memory_bytes: 3064
A, B, C = map(int, input().split())
K = int(input())
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i + j + k <= K:
                A1 = A * 2 ** i
                B1 = B * 2 ** j
                C1 = C * 2 ** k
                if A1 < B1 < C1:
                    print('Yes')
                    exit()
print('No')


Measured memory_bytes: 9176
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <ctime>
using namespace std;

int dp[30][30][30][30];
int memoa[30][30], memob[30][30];
int ori_rule[15], ori_s, orilen, ori_rulelen;
int n, m, stra[30], strb[30];
int rules[50000][3], rulelen, newvar;

void transform(int rule[], int start, int len){
  if(len == 2){
    rules[rulelen][0] = rule[0];
    rules[rulelen][1] = rule[1];
    rules[rulelen][2] = start;
    rulelen++;
  }
  else{
    rules[rulelen][0] = newvar++;
    rules[rulelen][1] = rule[len - 1];
    rules[rulelen][2] = start;
    rulelen++;
    transform(rule, newvar - 1, len - 1);
  }
}

void CYK(int str[], int len, int memo[30][30]){
  bool mark[30][30][700] = {0};
  for(int i = 0; i < len; i++) mark[i][1][str[i]] = true;
  
  for(int i = 2; i <= len; i++)
  for(int idx = 0; idx < len; idx++)
  for(int k = 1; k < i; k++)
  for(int r = 0; r < rulelen; r++)
    if(mark[idx][k][rules[r][0]] && mark[(idx + k) % len][i - k][rules[r][1]]) mark[idx][i][rules[r][2]] = true;
  
  for(int i = 0; i < len; i++)
  for(int j = 1; j <= len; j++){
    for(int k = 1; k <= 30; k++)
      if(mark[i][j][k]) memo[i][j] |= 1 << k;
  }
}

int main(){
  while(scanf("%d%d%d", &n, &m, &ori_rulelen) == 3 && (n || m || ori_rulelen)){
    newvar = 31;
    rulelen = 0;
    memset(memoa, 0, sizeof(memoa));
    memset(memob, 0, sizeof(memob));
    memset(dp, -1, sizeof(dp));
    
    for(int i = 0; i < n; i++) scanf("%d", stra + i);
    for(int i = 0; i < m; i++) scanf("%d", strb + i);
    for(int i = 0; i < ori_rulelen; i++){
      scanf("%d", &orilen);
      for(int i = 0; i < orilen; i++) scanf("%d", ori_rule + i);
      scanf("%d", &ori_s); 
      transform(ori_rule, ori_s, orilen);
    }
    
    CYK(stra, n, memoa);
    CYK(strb, m, memob);
    
    for(int i = 0; i < n; i++)
    for(int j = 0; j < m; j++) dp[i][0][j][0] = 0;
    
    for(int i = 0; i < n; i++)
    for(int j = 0; j < m; j++)
    for(int a = 1; a <= n; a++)
    for(int b = 1; b <= m; b++)
    for(int aa = 0; aa < a; aa++)
    for(int bb = 0; bb < b; bb++)
      if((memoa[(i + aa) % n][a - aa] & memob[(j + bb) % m][b - bb]) && dp[i][aa][j][bb] != -1)
        dp[i][a][j][b] = max(dp[i][a][j][b], dp[i][aa][j][bb] + 1);
    
    int ans = -1;
    for(int i = 0; i < n; i++)
    for(int j = 0; j < m; j++) ans = max(ans, dp[i][n][j][m]);
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 4824
#include <bits/stdc++.h>
#define ll long long

using namespace std;
const int inf=0x3f3f3f3f;
int main()
{

    char ss[150];
    scanf("%s",ss);
    int len=strlen(ss);
    cout<<ss[0]<<len-2<<ss[len-1]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF (1LL << 60)
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl

using namespace std;

template<typename S,typename T>auto&operator<<(ostream&o,pair<S,T>p){return o<<"{"<<p.fi<<","<<p.se<<"}";}
template<typename T>auto&operator<<(ostream&o,set<T>s){for(auto&e:s)o<<e<<" ";return o;}
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,priority_queue<S,T,U>q){while(!q.empty())o<<q.top()<<" ",q.pop();return o;}
template<typename K,typename T>auto&operator<<(ostream&o,map<K,T>m){for(auto&e:m)o<<e<<" ";return o;}
template<typename T>auto&operator<<(ostream&o,vector<T>v){for(auto&e:v)o<<e<<" ";return o;}
void ashow(){cout<<endl;}template<typename T,typename...A>void ashow(T t,A...a){cout<<t<<" ";ashow(a...);}

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<string> vs;

const int MAX_N = 100005;

double dp[155][305];
double h[155];

double solve(double h, double l, double r)
{
    if(l <= h){
        if(r > h){
            return ((r-h)*(r-h)+(h-l)*(h-l))/(2.0*(r-l));
        }else{
            return (2*h-r-l)/2.0;
        }
    }else{
        if(r > h){
            return (r+l-2*h)/2.0;
        }else{
            return ((l-h)*(l-h)+(h-r)*(h-r))/(2.0*(l-r));
        }
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n){
        cin >> h[i];
    }
    rep(i,n+1){
        rep(j,305){
            dp[i][j] = INF;
        }
    }
    dp[0][1] = 0;
    rep(i,n){
        srep(j,1,305){
            srep(k,1,305){
                cmn(dp[i+1][k], dp[i][j]+solve(h[i],j,k));
            }
        }
    }
    printf("%.12lf\n", *min_element(dp[n]+1, dp[n]+305));
    return 0;
}



Measured memory_bytes: 3624
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn = 100000 + 100;
int T, A, B; ll pro;

bool check(ll k)
{
	ll a = k, b = k; bool fa = 0, fb = 0;
	if(k >= A) a++, fa = 1; if(k >= B) b++, fb = 1;
	ll c = a >> 1, d = b >> 1;
	if(k & 1)
	{
		if(c>=A || !fa) c++; if(d>=B || !fb) d++;
		return c*d < pro;
	}
	ll e = c + 1, f = d + 1;
	if(c >= A) c++, e++; if(d >= B) d++, f++;
	if(e == A) e++; if(f == B) f++;
	return c*f<pro && d*e<pro;
}

void Solve()
{
	scanf("%d", &T);
	while(T--)
	{
		scanf("%d%d", &A, &B);
		pro = 1ll * A * B;
		ll l = 0, r = 3ll * max(A, B);
		while(l <= r)
		{
			ll mid = (l + r) >> 1;
			if(check(mid)) l = mid + 1;
			else r = mid - 1;
		}
		printf("%I64d\n", l-1);
	}
}

int main()
{
	Solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int r, g, b, k;
    cin>>r>>g>>b>>k;
    while(g <= r)
    {
        --k;
        if(k < 0)
        {
            cout<<"No";
            return 0;
        }
        g*=2;
    }
    while(b <= g)
    {
        --k;
        if(k < 0)
        {
            cout<<"No";
            return 0;
        }
        b*=2;
    }
    //cout<<r<<g<<b;
    if(r<g && g<b)
        cout<<"Yes";
    return 0;
}

Measured memory_bytes: 3644
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := NewScanner()
	N, K, S := sc.NextInt(), sc.NextInt(), sc.NextInt()

	list := make([]int, N)
	for i := 0; i < K; i++ {
		list[i] = S
	}
	for i := K; i < N; i++ {
		if S == int(1e9) {
			list[i] = 1
		} else {
			list[i] = S + 1
		}
	}
	PrintI(list...)
}

func mapToString(arr []int) []string {
	ret := make([]string, len(arr))
	for i := 0; i < len(arr); i++ {
		ret[i] = strconv.Itoa(arr[i])
	}
	return ret
}

func PrintI(args ...int) {
	fmt.Println(strings.Join(mapToString(args), " "))
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 9088
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

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;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n;
P a[100010];
int ans[100010];
int mi = INF;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i].first;
		a[i].second = i;
	}
	sort(a, a + n);
	reverse(a, a + n);
	for (int i = 0; i < n; i++) {
		mi = min(mi, a[i].second);
		ans[mi] += (i + 1)*(a[i].first - a[i + 1].first);
	}
	for (int i = 0; i < n; i++)cout << ans[i] << endl;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 998244353
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	char c; cin >> c;
	if ('a' <= c && c <= 'z')cout << 'a' << endl;
	else cout << 'A' << endl;

}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;

#define pll pair<ll,ll>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define rep(i,n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << endl
#define sz(a) int((a).size())
#define endl '\n' // remove for interactive

const int INF = 1e9;
const ll mod = 1e9 + 7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}


const int N = 1e6 + 50;
int spf[N];







void solve()
{
    for(int i=2;i<=1e6;i++)if(!spf[i])
		for(int j=i;j<=1e6;j+=i)if(!spf[j])spf[j]=i;
    int n; cin>>n;
    vi v;
    int gdc;
    set<int> s;
    int flag = 1;
    rep(i, n)
    {
        int x; cin>>x;
        if(i == 0) gdc = x;
        if(i >= 1) {
            gdc = __gcd(gdc, x);
        }
        while(x != 1)
        {
            int divd = spf[x];
            if(s.count(divd)) flag = 0;
            s.insert(divd);
            while(x % divd == 0) x /=divd;
        }
    }
    if(flag) cout<<"pairwise coprime"<<endl;
    else {
        if(gdc == 1) cout<<"setwise coprime"<<endl;
        else cout<<"not coprime";
    }
    
}

int main()
{
    // clock_t start, end;
    // start = clock();
    ios_base::sync_with_stdio(0); //cant use scanf, printf
    cin.tie(0);cout.tie(0); // no longer auto flush cout before each cin, remove for interactive
    int t = 1;
    // cin>>t;
    REP(i, 1, t)
    {
        solve();
        
    }
    // end = clock();
    // double time_taken = double(end - start) / double(CLOCKS_PER_SEC); 
    // watch(time_taken);
    ll x = INF; x++;
    return 0;
    
}



/*before sub
TEST: 0(1 by 1 too), 1, equal, -ve, bounds(random and ez)
ERR/WA: loop vars, out of bounds, endl, finish taking inputs, large doubles, larger INF, corr mod, t, early/late mod
RE: double dec, integer overflow(ll or 1LL mult)
*/





Measured memory_bytes: 11204
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))
D = defaultdict(int)
for a in A:
    D[a] += 1

memo = defaultdict(lambda: -1)
conv_D = defaultdict(int)
SUM = 0
for d in D:
    conv_D[d] = D[d] * (D[d] - 1) // 2
    SUM += conv_D[d]

for i in range(N):
    if memo[A[i]] == -1:
        tmp = SUM - conv_D[A[i]] + (D[A[i]] - 1)*(D[A[i]] - 2)//2
        print(tmp)
        memo[A[i]] = tmp
    else:
        print(memo[A[i]])

Measured memory_bytes: 109720
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=100000000000000000;

int main() {
    int n;
    cin >> n;
    ll s=0,ans=INF;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
        s+=a[i];
    }
    ll su=0;
    rep(i,n){
        su+=a[i];
        ans=min(abs(s-2*su),ans);
    }
    cout << ans << endl;
}


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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		int pa = 0, pb = 0;
		StringTokenizer sta, stb;
		while ((line = br.readLine()) != null) {
			sta = new StringTokenizer(line);
			stb = new StringTokenizer(br.readLine());
			for (int i = 0; i < 4; i++) {
				pa += Integer.parseInt(sta.nextToken());
				pb += Integer.parseInt(stb.nextToken());
			}
			System.out.println(pa > pb ? pa : pb);
		}
	}
}

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

int main(){
    int N; cin >> N;
    vector<ll> V(N);
    rep(i, N) cin >> V[i];

    int ans = 0;
    
    for(int i = 0; i<N-2; i++)
        for(int j = i+1; j<N-1; j++)
            for(int k = j+1; k<N; k++){
                if(V[i] == V[j] || V[j] == V[k] || V[k] == V[i]) continue;
                if(V[i]+V[j]>V[k] && V[j]+V[k]>V[i] && V[k]+V[i]>V[j]) ans++;
                
            }
   
    cout << ans << endl;
}



Measured memory_bytes: 3628
#include <iostream>

int main() {
    unsigned long long n, a, b; std::cin >> n >> a >> b;
    if (a > b) {
        std::cout << 0 << std::endl;
        return 0;
    }
    if (n == 1) {
        std::cout << ((a==b)?1:0) << std::endl;
        return 0;
    }

    std::cout << (b * (n-1) + a) - (b + a * (n-1)) + 1 << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define DBG(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define EN cout<<"\n"
#define fi first
#define se second
#define PI (acos(-1))
#define fastread ios::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 200005
template<class T> ostream& operator<<(ostream &s,pair<T,ll> a)
{
    s<<a.fi<<' '<<a.se;
    return s;
}
int main()
{
    fastread;
    ll T=1;
//    cin>>T;
    for(ll qq=1;qq<=T; qq++)
    {
        ll n;
        cin>>n;
        vi ara(n);
        vii a(n);
        for(int i=0;i<n;i++)
        {
            cin>>a[i].fi;
            ara[i]=a[i].fi;
            a[i].se=i;
        }
        sort(a.begin(),a.end());
        ll ans=0;
        for(int i=0;i<n;i++)
        {
            if(abs(a[i].se-i)%2)
            {
                while(1){
                    ll x=lower_bound(a.begin(),a.end(),ii(ara[i],0))-a.begin();
                    a[x].se=i;
                    if(abs(i-x)%2==0)
                    {
                        a[x].se=x;
                        swap(ara[i],ara[x]);
                    }
                    else break;
                }
                ll x=lower_bound(a.begin(),a.end(),ii(ara[i],0))-a.begin();
                a[x].se=a[i].se;
                swap(ara[i],ara[a[i].se]);
                a[i].se=i;
                ans++;
            }
            else
            {
                ll x=lower_bound(a.begin(),a.end(),ii(ara[i],0))-a.begin();
                a[x].se=a[i].se;
                swap(ara[i],ara[a[i].se]);
                a[i].se=i;
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 2560
import java.awt.*;
import java.util.*;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        sc.next();
        int m = sc.nextInt();
        List<Point> list = new ArrayList<>();
        for (int i = 0; i < m; i++) list.add(new Point(sc.nextInt(), sc.nextInt()));
        Collections.sort(list, Comparator.comparingInt(o -> o.y));

        int ans = 0, lastIndex = -1;
        for (int i = 0; i < m; i++)
            if (list.get(i).x > lastIndex) {
                ans++;
                lastIndex = list.get(i).y - 1;
            }
        System.out.println(ans);
    }
}

Measured memory_bytes: 92556
import fractions
a,b,c,d=map(int,input().split())
nc=b//c-(a+c-1)//c+1
nd=b//d-(a+d-1)//d+1
cd=c*d//fractions.gcd(c,d)
ncd=b//cd-(a+cd-1)//cd+1
print(b-a+1-(nc+nd-ncd))

# math.ceil(a/b)->(a+b-1)//b

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

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define vi vector< int > 
#define pii pair< int, int >
#define mii map< int , int > 
#define F(start,stop) for(int i=start; i<stop; i++)
#define FRev(start,stop) for(int i=start; i>=stop; i--)
#define MOD1 1000000007
#define MOD2 998244353

int main()
{

	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	IOS

	ll n;
	cin >> n;
	ll a[n];
	ll b[n];

	F(0,n) cin >> a[i] >> b[i];

	sort(a, a+n);
	sort(b, b+n);
	ll med_a , med_b;
	if(n%2 != 0){
		med_a = a[n/2];
		med_b =  b[n/2];
	}else{
		med_a = a[n/2] + a[(n-1)/2];
		med_b = b[n/2] + b[(n-1)/2];
	}
	cout << med_b - med_a + 1 << endl;
}

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

using namespace std;

typedef long long llint;

int main() {
  llint n;
  cin >> n;
  llint ans = 0;
  for (llint i = 1; i <= n; i++) {
    llint j = n / i;
    ans += j * (j + 1) * i / 2;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3636
n,m = map(int, input().split())
l = []
for i in range(n):
    l.append(list(map(int,input().split())))
fav=[0]*m
for tmp in l:
    for food in tmp[1:]:
        fav[food-1]+=1
ans=0
for f in fav:
    if f == n:
        ans+=1
print(ans)

Measured memory_bytes: 38384
# 不幸な人の最少人数は1人
# 同じ向きを向いている人を1人に圧縮すると、[L,R,L,...,L], [L,R,L,...,R],[R,L,R,...,R],[R,L,R,...,L]のいずれかの配列が得られる
# 不幸な人が2人以上いれば、1回操作を行うごとに不幸な人を2人減らせる。不幸な人が1人になったら終了

N, K = map(int, input().split())
S = list(input())

# 同じ方向を向いている人の圧縮処理
S_pack = [S[0]]
for direction in S:
    if S_pack[-1] != direction:
        S_pack.append(direction)

n_unhappy = len(S_pack)
n_unhappy = max(n_unhappy - K*2, 1)

print(N - n_unhappy)

Measured memory_bytes: 4652
#include <iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
    int n;
    int a[200000];
    int copy[200000];
    int max,nmax;
    cin >> n;
    rep(i,n){
        cin >> a[i];
        copy[i]=a[i];
    }
    sort(a,a+n);
    max = a[n-1];
    nmax = a[n-2];
    for(int i=0;i<n;i++){
       if(copy[i]==max) cout << nmax << endl;
       else cout << max << endl;
    }
    //cout << nmax << ' ' << max << endl;
    //rep(i,n) { 
    //  cout << 'a' << i << ' ' << a[i] << endl;
    //    cout << "copy" << i << ' ' << copy[i] << endl;
    //}
    return 0;
}

Measured memory_bytes: 3200
from sys import stdin

sentence = stdin.read().rstrip()
lis = [0] * 26
for char in sentence:
    if char.isalpha():
        codenum = ord(char)
        if codenum >= 97:
            codenum -= 97
        else:
            codenum -= 65
        lis[codenum] += 1

for i in range(len(lis)):
    print('%s : %d'%(chr(i+97), lis[i]))


Measured memory_bytes: 5560
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
const long long INF = 1<<29;

const int MOD = 1000000007;
long long ruizyou(long long m,long long n){
  if(m == 0)return 0;
  if(m == 1)return 1;
  long long ans = 1;
  long long tmp = m;
  for(int i=0;i<=30;i++){
    if(n & (1<<i)){
      ans *= tmp;
      ans %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
  }
  return ans;
}
long long kaizyou(long long x){
  if(x == 0)return 1;
  return x * kaizyou(x-1) % MOD;
}
long long comb(long long x,long long y){
  long long bunsi = kaizyou(x);
  long long bunbo = kaizyou(x-y) * kaizyou(y) % MOD;
  return bunsi * ruizyou((int)bunbo,MOD-2) % MOD;
}
struct unionfind{
  vector<int> par;
  vector<int> hukasa;
  unionfind(int n){
    par = vector<int>(n);
    hukasa = vector<int>(n,0);
    for(int i=0;i<n;i++){
      par.at(i) = i;
    }
  }
  int root(int x){
    if(par.at(x) == x)return x;
    return root(par.at(x));
  }
  void unite(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry)return;
    if(hukasa.at(rx) >= hukasa.at(ry)){
      par.at(ry) = rx;
      hukasa.at(rx) = max(hukasa.at(ry) + 1,hukasa.at(rx));
    }
    else{
      par.at(rx) = ry;
    }
  }
  bool same(int x,int y){
    return root(x) == root(y);
  }
};
int ctoi(char a){
  return a - '0';
}
long long gcd(long long a,long long b){
  long long c = max(a,b);
  long long d = min(a,b);
  if(d % c == 0)return c;
  return gcd(c,d%c);
}
long long lcm(long long a,long long b){
  return a * b / gcd(a,b);
}
int main(){
  int n;
  cin >> n;
  vector<long long> a(n);
  for(int i=0;i<n;i++)cin >> a.at(i);
  long long ans = 0;
  int t = a.at(0);
  for(int i=1;i<n;i++){
    if(t < a.at(i))t = a.at(i);
    else ans += t-a.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4844
n = int(input())
a = list(map(int, input().split()))
ans = 0
s = 0
for i in range(n):
  if a[i] == i + 1:
    s += 1
  else:
    ans += (s + 1) // 2
    s = 0
ans += (s + 1) // 2
print(ans)


Measured memory_bytes: 14008
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main() {
    ll n,a,b;
    cin>>n>>a>>b;
    vll v(n);
    rep(i,n)cin>>v[i];
    ll ans=0;
    rep(i,n-1){
        ans+=min((v[i+1]-v[i])*a,b);
    }
    fin(ans);
}


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

long long MOD = 1e9 + 7;

void Main() {
  int N, K;
  cin >> N >> K;

  long long ans = 0;
  for (int i = K; K <= N + 1; K++) {
    long long minimum, maximum;
    minimum = (0 + K - 1) * (long long)K / 2;
    maximum = (N - K + 1 + N) * (long long)K / 2;
    //cout << minimum << " " << maximum << endl;
    ans += (maximum - minimum + 1);
    ans %= MOD;
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int N, A;
int MIN = 1001;
int MAX = -1;

int main(){
  cin >> N;
  for(int i =1; i<= N; i++){
    cin >> A;
    if(MIN > A) MIN = A;
    if(MAX < A) MAX = A;
  }
  cout << MAX - MIN << endl;
  return 0;
}


Measured memory_bytes: 3536
# Contest No.: ABC170
# Problem No.: D
# Solver:      JEMINI
# Date:        20200614

import sys
import heapq

def main():
    n = int(input())
    nums = list(map(int, sys.stdin.readline().split()))
    nums.sort()

    check = [False] * (10 ** 6 + 1)
    for i in range(1, n):
        if nums[i] == nums[i - 1]:
            check[nums[i]] = True
    #print(nums)
    ans = 0
    for i in range(n):
        if check[nums[i]] == False:
            ans += 1
        if i == 0 or (i > 0 and nums[i] != nums[i - 1]):
            cnt = nums[i] * 2
            while cnt < 10 ** 6 + 1:
                #print(cnt)
                check[cnt] = True
                cnt += nums[i]
        #print(ans)
    print(ans)

    
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 98124
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
 
using namespace std;
#define rep(i,a,b) for (ll i = a; i < b; i++)
#define rrep(i,a,b) for (ll i = a; i >= b; i--)
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
 
using namespace std;
#define rep(i,a,b) for (ll i = a; i < b; i++)
#define rrep(i,a,b) for (ll i = a; i >= b; i--)
#define l(s) s.length()
#define sort(v) sort(v.begin(), v.end());
#define scan(v,n) rep(i,0,n) {ll k; cin >> k; v.pb(k);}
#define print(v,n) {rep(i,0,n) cout << v[i] << " "; cout << endl;}
#define printstr(s,n) {rep(i,0,n) cout << s[i]; cout << endl;}
#define rev(a) reverse(a.begin(), a.end());
#define pb push_back
typedef long long ll;
typedef long double lld;
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
 
const ll mxN=1e5;
const ll N=1e9+7;
 
int dp[mxN+1];

//dp[i][j][2] is the score of each player when the remaining array is from index i to j
// dp[0][n-1]=0
//rep(i,1,n+1) cout max of dp[i][i-1][1]



  int main() {
      int T=1;// cin >> T;
      while(T--){
          ll n,W,sum=0; cin >> n >> W;
          rep(i,1,mxN+1) dp[i]=N;
          rep(i,0,n) {
              ll w,v;
              cin >> w >> v;
              sum+=v;
              rrep(x,sum,0) {
                  if(x>=v&&dp[x]>dp[x-v]+w) dp[x]=dp[x-v]+w;
              }
          }
          ll ans=0;
          rrep(i,sum,0){
              if(dp[i]<=W) {
                  cout << i; 
                  break;
              }
          }
          //cout << ans;
          
      } 
	 return 0;
}


Measured memory_bytes: 3992
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>

using namespace std;

typedef long long ll;

struct High {
    ll x, y, h;
    High(ll x, ll y, ll h) : x(x), y(y), h(h) {}
};

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    ll n;
    
    cin >> n;
    
    vector<High> p;
    
    ll x, y, h;
    for (int i = 0; i < n; ++i) {
        cin >> x >> y >> h;
        
        p.push_back(High(x, y, h));
    }
    
    set<ll> m;
    for (ll cx = 0; cx <= 100; cx++) {
        for (ll cy = 0; cy <= 100; cy++) {
            m.clear();
            for (int i = 0; i < n; ++i) {
                m.insert(p[i].h + abs(cx - p[i].x) + abs(p[i].y - cy));
            }
            
            if (*m.begin() >= 1) {
                bool flag = true;
                for (int i = 0; i < n; ++i) {
                    if (max((*m.begin() - abs(cx - p[i].x) - abs(p[i].y - cy)), 0LL) != p[i].h) {
                        flag = false;
                    }
                }
                if (flag) {
                    cout << cx << " " << cy << " " << *m.begin() << endl;
                    return 0;
                }
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int l,i,cnt=0;
  scanf("%d",&l);
  int num[l];
  for(i=0;i<l;i++){
    scanf("%d",&num[i]);
    if(num[i]!=i+1){
      cnt++;
    }
  }
  if(cnt<=2){
    printf("YES");
  }else{
    printf("NO");
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int> a;
  for(int i = 0; 3*n > i; i++){
    int tmp;cin>>tmp;
    a.push_back(tmp);
  }
  sort(a.begin(),a.end(),greater<int>());
  long long sm = 0;
  for(int i = 0; n > i; i++){
    sm += a[i*2+1];
  }
  cout << sm << endl;
}

Measured memory_bytes: 2420
import java.util.LinkedList;
import java.util.Scanner;

class Main {

	/*
	 * 着席位置：ホワイトボード向かって右側の前から３番目
	 * 問題：コッホ曲線
	 */

	private static LinkedList<double[]> points;
	private static final int X=0, Y=1;//0と1だと混乱するため

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		scanner.close();

		points = new LinkedList<>();
		double[] a = {0, 0};
		points.add(a);
		double[] b = {100, 0};
		points.add(b);

		koch(a, b, N);

		for(double[] p : points) {
			print(p[X], p[Y]);
		}

	}

	private static void koch(double[] a, double[] b, int N) {
	    if(N==0) return;
		double newp1[] = {(a[X]*2+b[X])/3, (a[Y]*2+b[Y])/3};//１つ目の点寄り
		double newp2[] = {(b[X]*2+a[X])/3, (b[Y]*2+a[Y])/3};//２つ目の点寄り
		double dx = newp2[X]-newp1[X], dy = newp2[Y]-newp1[Y];
		double newp3[] = {newp1[X] +(dx -Math.sqrt(3)*dy)/2, newp1[Y] +(Math.sqrt(3)*dx +dy)/2};//とがるところ・１つ目の点を軸に60°回す
		//配列に順番通りに格納
		int index = points.indexOf(a);
		points.add(index+1, newp1);
		points.add(index+2, newp3);
		points.add(index+3, newp2);
		if(N>=2) {//再帰する
			N--;
			koch(a, newp1, N);
			koch(newp1, newp3, N);
			koch(newp3, newp2, N);
			koch(newp2, b, N);
		}

	}

	private static void print(double x, double y) {
		System.out.printf("%f %f", x, y);
		System.out.println();
	}

}



Measured memory_bytes: 38440
use std::cmp::max;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s:Vec<char> = read::<String>().chars().collect();
    let mut ans = 0;
    for i in 1..s.len()/2-1 {
        if s[0..=i] == s[i+1..=2*i+1] {
            ans = max(ans, i);
        }
    }
    println!("{}", (ans+1)*2);
}


Measured memory_bytes: 2104
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
}

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

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int x,y;
  x=0;
  y=0;
  for(int i=0;i<n;i++){
    if(a[i]%2==1){
      x++;
    }
    else if(a[i]%4==0){
      y++;
    }
  }
  if(x<=y){
    cout << "Yes" << endl;
  }
  else if(x==y+1&&x+y==n){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 640
begin
  input_line = []
  while line = $stdin.gets.chomp
    break if line == ""
    input_line.push(line.split(" "))
  end
rescue
end

i = input_line.first.map{|i| i.to_i }

if i[0] < i[1] && i[1] < i[2]
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 8568
from collections import Counter
s = input()[::-1]
T = [0]*(len(s)+1)
digit = 1

for i in range(1,len(s)+1):
    T[i] = (T[i-1]+digit*int(s[i-1]))
    T[i] = T[i] % 2019
    digit = digit * 10
    digit = digit % 2019

S = Counter(T)
ans = 0
for i in S.values():
    ans+=(i*(i-1))//2

print(ans)

Measured memory_bytes: 16616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
typedef pair<int, int> ii; 
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000


int main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  int n; cin >> n;
  vi a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  vi dp(n);
  dp[0] = 0;
  dp[1] = dp[0] + abs(a[0] - a[1]);
  for (int i = 2; i < n; i++){
    dp[i] = min(dp[i-1] + abs(a[i]-a[i-1]), dp[i-2] + abs(a[i]-a[i-2]));
  }
  cout << dp[n-1] << '\n';
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define LL long long
using namespace std;
typedef pair<LL, LL> pii;
LL n, ans, a[1 << 18 + 5];
vector <pii> v[1<<18+5];
int main() {
	scanf ("%d", &n);
	for (int i = 0; i < (1 << n); i ++)
		scanf ("%lld", &a[i]);
	for (int i = 0; i < (1 << n); i ++)
		v[i].push_back(make_pair(a[i], i));
	for (int S = 0; S < (1 << n); S ++) {
		for (int i = 0; i < n; i ++) {
			if (!((S >> i) & 1))
				continue;
			for (int j = 0; j < v[S ^ (1 << i)].size(); j ++)
				v[S].push_back(v[S ^ (1 << i)][j]);
		}
		sort (v[S].begin(), v[S].end(), greater<pii>());
		v[S].erase(unique(v[S].begin(), v[S].end()), v[S].end());
		if (v[S].size() > 2)
			v[S].resize(2);
	}
	for (int S = 1; S < (1 << n); S ++) {
		ans = max(ans, v[S][0].first + v[S][1].first);
		printf ("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 323200
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cstdlib>
#include <cmath>
int main() {
  int D;
cin>>D;
if(D==25){
cout<<"Christmas"<<endl;
}
if(D==24){
cout<<"Christmas Eve"<<endl;
}
if(D==23){
cout<<"Christmas Eve Eve"<<endl;
}
if(D==22){
cout<<"Christmas Eve Eve Eve"<<endl;
}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,x,y;
    cin>>n>>x>>y;
    for(int i=1;i<n;i++){
        if(i==1){
            cout<<n<<endl;
            continue;
        }
        int a=0;//経路数
        //近道を通らない
        for(int j=1;j<=n-i;j++){
            if(i<=abs(x-j)+abs(y-(j+i))+1)a++;
        }
        //近道を通り、x,yから合計i-1の長さの道を生やす
        for(int j=0;j<i;j++){//xからの距離
            int k=i-j-1;//yからの距離
            if(j && k){
                if(y+k-(x+j)>i && y+k<=n && x+j<=n)a++;
                if(y+k-(x-j)>i && y+k<=n && x-j>=1)a++;
                if(y-k-(x+j)>i && y-k>=1 && x+j<=n)a++;
                if(y-k-(x-j)>i && y-k>=1 && x-j>=1)a++;
            }
            if(j==0){
                if(y+k-x>i && y+k<=n)a++;
                if(y-k-x>i && y-k>=1)a++;
            }
            if(k==0){
                if(y-(x+j)>i && x+j<=n)a++;
                if(y-(x-j)>i && x-j>=1)a++;
            }
        }
        cout<<a<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string A;
  cin>>A;
  int ans=0;
  int kouho=0;
  for(int i=0; i<A.size(); i++){
    if(A.at(i)=='R'){
      kouho++;
    }
    else{
      ans=max(ans, kouho);
      kouho=0;
    }
  }
  ans=max(ans, kouho);
  cout<<ans<<endl;
}


Measured memory_bytes: 3512
#include <stdio.h>
#include <math.h>


int main(void)
{
    int a;
    int b;
    int C;
    double S;
    double L;
    double h;
    double pi;

    scanf("%d %d %d", &a, &b, &C);

    pi = acos(-1);
    
    S = 0.5 * a * b * sin(C * (pi / 180.0));
    L = a + b + sqrt(pow(a, 2.0) + pow(b, 2.0) - 2.0 * a * b * cos(C * (pi / 180.0)));
    h = b * sin(C * (pi / 180.0));
    
    printf("%lf\n", S);
    printf("%lf\n", L);
    printf("%lf\n", h);

    return 0;
}


Measured memory_bytes: 2112
# 再帰の深さが1000を超えそうなときはこれをやっておく
import sys
sys.setrecursionlimit(10**7)
#隣接リスト表現
n,q=list(map(int,input().split()))
es=[[] for i in range(n)]
for i in range(n-1):
  a,b=list(map(int,input().split()))
  es[a-1].append(b)
  es[b-1].append(a)
#頂点に値をたす
cnt=[0 for i in range(n)]
for i in range(q):
  p,x=list(map(int,input().split()))
  cnt[p-1]=cnt[p-1]+x
  
#頂点vから始めるdfsで累積和をを求める
#check=訪れたことがあるかどうかを探索
check=[0 for i in range(n)]
def dfs(v):
  check[v-1]=1
  for l in es[v-1]:
    if check[l-1]==0:
      cnt[l-1]=cnt[l-1]+cnt[v-1]
      dfs(l)
  return cnt
#出力
dfs(1)
for i in cnt:
  print(i,end=" ")
  



Measured memory_bytes: 221784