akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <tr1/unordered_map>
#define mo 1000000007
#define num(x) (x>='0' && x<='9')
typedef unsigned long long ull;
typedef long long ll;
using namespace std::tr1;
using namespace std;
int read(){
    int p=0, q=1;
    char ch=getchar();
    while (!num(ch))
        (ch=='-'?q=-1:0),
        ch=getchar();
    while (num(ch)) p=p*10+ch-'0', ch=getchar();
    return p*q;
}
int power(ll a, int b){
	ll c=1;
	while (b){
		if (b&1) c=c*a%mo;
		a=a*a%mo;
		b>>=1;
	}
	return c;
}
int main(){
	int n=read(), x=read(), t=read();
	cout<<((n-1)/x+1)*t<<endl;
    return 0;
}

Measured memory_bytes: 3616
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (h, w) = listOfInt()

    (1..h).forEach {
        val line = next()
        println(line)
        println(line)
    }
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 37996
#include<stdio.h>

int main() {
	int costP[3], costJ[2];
	int min = 2001, sum = 0;

	for (int i = 0; i < 3; i++) {
		scanf("%d", &costP[i]);
	}
	for (int i = 0; i < 2; i++) {
		scanf("%d", &costJ[i]);
	}
	for (int i = 0; i < 3; i++) {
		if (min > costP[i]) min = costP[i];
	}
	sum += min;
	min = 2001;
	for (int i = 0; i < 2; i++) {
		if (min > costJ[i]) min = costJ[i];
	}
	sum += min;
	printf("%d\n", sum - 50);
	return 0;
}


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

using namespace std;

int main() {
  long long n;
  cin >> n;
  long long res = n;
  for (long long i = 1; i <= n / i; i++) {
    if (n % i) continue;
    res = min(res, i + n / i - 2);
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main(){
	int n,m;
	int cot = 0;
	scanf("%d %d",&n,&m);
	m /= 1000;
	if(n > m || n * 10 < m) printf("-1 -1 -1");
	else {
		if(n * 10 == m) printf("%d 0 0\n",n);
		else if(n * 5 == m) printf("0 %d 0\n",n);
		else if(n == m) printf("0 0 %d\n",n);
		else {
			for(int x = 0; x <= n; x++){
				for(int y = 0; y <= n; y++){
					if((10 * x + 5 * y + (n - x - y) == m) && ((n - x - y) >= 0)) {printf("%d %d %d\n",x,y,n-x-y); return 0;}
					else cot++;
				}
			}
			if(cot == (n + 1) * (n + 1)) printf("-1 -1 -1");
		}
	}
}


Measured memory_bytes: 128
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
c.sort()
import bisect as bi
ans=0
for i in b:
    k=1
    k*=bi.bisect_left(a,i)
    k*=n-bi.bisect_right(c,i)
    ans+=k
print(ans)


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

using namespace std;

#define all(x) (x).begin(),(x).end()
#define sz(x) (int)x.size()
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define debug(x) cerr << "  - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << "  - " << #x << ": " << x << "\t\t" << #y << ": " << y << endl;
#define debugv(v, n) cerr << #v << " : " << " "; for(int i = 0; i < n; i++) cerr << "\t" << #v << "[" <<  i <<  "]" <<  " : " << v[i] << "\n"; cerr << endl;
#define sep() cerr << "--------------------" << endl;

typedef long long ll;
const ll mod = 1e9 + 7;
const int N = 2234;

int a[N];

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	
	ll sum = 0;
	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n - 1; j++) {
			int c = a[i] + a[j];
			int idx = lower_bound(a + j + 1, a + n, c) - a;
			idx--;
			sum += idx - j;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const long long MOD=1000000007;
int main(){
  long long N,K;
  cin >> N >> K;
  long long A[N+1];
  for(long long i=1;i<=N+1;i++)
    A[i]=(i*N%MOD-(i-1)*i%MOD+1)%MOD;
  long long count=0;
  for(long long j=K;j<=N+1;j++)
    count=(A[j]+count)%MOD;
  cout << count%MOD << endl;
}

Measured memory_bytes: 5128
// Copyright 2020 yaito3014
#include <iostream>
#include <vector>
#pragma GCC optimize("Ofast")
int main() {
  using namespace std;
  int K;
  cin >> K;
  string S;
  cin >> S;
  const int N = K + S.length();
  constexpr long long kMod = 1000000007;
  auto modpow = [&](long long a, int b) {
  	long long r = 1;
  	for (; b > 0; b /= 2) {
  		if (b % 2) r = r * a % kMod;
  		a = a * a % kMod;
  	}
  	return r;
  };
  auto inv = [&](int a) { return modpow(a, kMod - 2); };
  vector<long long> fact(N + 1, 1);
  for (int i = 0; i < N; ++i) fact[i + 1] = fact[i] * (i + 1) % kMod;
  vector<long long> inv_fact(N + 1);
  inv_fact[N] = inv(fact[N]);
  for (int i = N; i > 0; --i) inv_fact[i-1] = inv_fact[i] * i % kMod;
  auto c = [&](int n, int r){
  	return fact[n] * inv_fact[n-r] % kMod * inv_fact[r] % kMod;
  };
  long long m25 = 1;
  long long ans = 1;
  for (int i = 1; i <= K; ++i) {
  	m25 = m25 * 25 % kMod;
  	ans += c(N, i) % kMod * m25 % kMod;
  	if (ans > kMod) ans -= kMod;
  }
  cout << ans << '\n';
}


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

#define INF 1e9
int dp[1000009][2];
int main(){
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    S += '0';
    int N = S.size();
    REP(i, N+2){
        REP(j, 2){
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    REP(i, N){
        REP(j, 2){
            int x = S[i] - '0';
            x += j;
            REP(d, 10){
              int b = d - x;
              int nj = 0;
              if(b < 0){
                nj = 1;
                b += 10;
              }
              dp[i+1][nj] = min(dp[i+1][nj], dp[i][j]+d+b);
            }
        }
    }
    cout << dp[N][0] << endl;
    return 0;
}


Measured memory_bytes: 9220
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n,k;
  cin >> n >> k;
  vl a(n);
  rep(i,n){
    cin >> a[i];
  }
  ll ans = 1LL<<60;
  rep(d,1<<(n-1)){
    bitset<14> b(d);
    if(b.count() < k-1)continue;
    ll tmp = 0,now = a[0];
    rep(i,n-1){
      bool c = false;
      if(b[i]){
        if(now >= a[i+1]){
          tmp+=now-a[i+1]+1;
          c = true;
        }
      }
      if(c)now = now+1;
      else now = max(now,a[i+1]);
      
    }
    mins(ans,tmp);
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
//problem - S(indu)

#include <bits/stdc++.h>

#define rate_of_minute 6
#define rate_of_hour 30
#define hour_effected_by_minute 0.5
#define pi 3.1415926535897932384626433

int main()
{
    int a{0},b{0};
    int hour{0},minute{0};
    
    double gap{0.0000},angle_of_hour{0.0000},angle_of_minute{0.0000},C{0.000};
    
    scanf("%d %d %d %d",&a,&b,&hour,&minute);
    
    if(hour == 0 && minute == 0){
        gap = (double) a - b;
        if(gap < 0){
            gap *= (-1);
        }
        printf("%.20lf\n",gap);
        return 0;
    }
    
    angle_of_minute =(double) minute * rate_of_minute;
    angle_of_hour =(double) (hour * rate_of_hour) + (minute * hour_effected_by_minute);
    
    C = (double) angle_of_hour - angle_of_minute;
    if(C < 0){
        C *= (-1);
    }
    
    gap = (a * a) + (b * b) - (2 * a * b) * (cos(C * pi / 180.000));
    gap = sqrt(gap);
    
    printf("%.20lf\n",gap);
    
    return 0;
}

Measured memory_bytes: 4260
#include <iostream>

using namespace std;

void func_A() {

    int n;
    cin >> n;

    while (n > 0) {
        if (n % 10 == 7) {
            cout << "Yes";
            return;
        }

        n /= 10;
    }

    cout << "No";
}

void func_B() {

    unsigned long long n;
    cin >> n;

    unsigned long long sum = 0;
    for (unsigned long long i = 1; i <= n; ++i) {
        if (i % 3 != 0 && i % 5 != 0) sum += i; 
    }

    cout << sum;
}

void func_C() {



}

int main()
{
    func_A();
    //func_B();
    //func_C();

    return 0;

}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;


int h,g[11][11];

bool fall(int x,int y){

  if(g[y][x]==0)return false;

  bool fg=false;
  int tmp=g[y][x];
  g[y][x]=0;
  while(y>0 && g[y-1][x]==0)y--,fg=true;
  g[y][x]=tmp;
  return fg;
}

int remove(int x,int y){

  if(g[y][x]==0)return 0;
  
  int res=g[y][x],cnt=0;
  while(g[y][x]==g[y][x+cnt])cnt++;

  if(cnt<3)return 0;
    
  for(int i=0;i<cnt;i++)g[y][x+i]=0;
  
  return res*cnt;
}

int solve(){

  bool fg;
  int res=0;

  while(true){
    fg=false;
    
    for(int i=0;i<h;i++){
      for(int j=0;j<5;j++){
	res+=remove(j,i);
      }
    }

    for(int i=0;i<h;i++){
      for(int j=0;j<5;j++){
	fg|=fall(j,i);
      }
    }

    if(!fg)return res;
  }
}

int main(void){
  
  while(cin >> h,h){

    for(int i=0;i<11;i++)
      for(int j=0;j<11;j++)g[i][j]=0;

    for(int i=h-1;i>=0;i--){
      for(int j=0;j<5;j++)cin >> g[i][j];
    }

    cout << solve() << endl;
  }

  return 0;
}

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


#define ll long long
#define int long long
#define pb push_back

#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, a, b) for(int i = (a); i > (b); --i)

typedef pair <int,int> ii;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <ll> vl;

const int mod = 1e9+7;
const ll inf = 2e18+5;
const ll inf2 = 2e18;
const int MAXN = 1e5+2;



signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin>>n;
    vector <double> p(n); 
    loop(i,0,n) cin>>p[i];        
    vector <double> dp(n+1);  //dp[x] = prob of finding x heads so far;
    dp[0]=1;
    loop(i,0,n){

        for(int j=i+1;j>=0;j--)
            if(j==0)
                dp[j] = dp[j]*(1-p[i]);
            else    
                dp[j] =  dp[j-1]*p[i] + dp[j]*(1-p[i]);
    }
    double ans=0;
    loop(i,0,n+1){
        int heads=i;
        int tails=n-i;
        if(heads>tails)
            ans+=dp[i];
    }
    cout<<fixed<<setprecision(9)<<ans<<endl;
    return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
 
#define mod(cans) cans%10**9+7
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define cin_pl(n,x) rep(i,n){cin>>x[i];}
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define prians(Answer) cout<<Answer<<"\n"
#define TF(X) X==1?cout<<"Yes\n":cout<<"No\n"
#define elcon else{continue;}
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int> > matrix;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef greater<int> gi;
typedef vector<unsigned> vu;


ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
bool is_prime(const unsigned n){
    switch(n){
        case 0:
        case 1: return false;
        case 2: return true;
    }
 
 
    for(unsigned i=2;i<n;++i){
        if(n%i == 0) return false;
    }
 
    return true;
}

int main()
{
    int n,k,r,s,p;
    cin>>n>>k>>r>>s>>p;
    string t;
    cin>>t;
    int sum=0;
    rep(i,n-k)
    {
        if(t[i]==t[i+k])t[i+k]='x';
    }
    rep(i,n)
    {
        switch (t[i])
        {
        case 's':sum+=r;break;
        case 'r':sum+=p;break;
        case 'p':sum+=s;break;
        default:
            break;
        }
    }


    cout<<sum;
} 

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;

	vector<int> A(N);
	vector<long long> B(N);
	for (auto i = 0; i < N; ++i)
	{
		cin >> A[i] >> B[i];
	}

	auto result = 0ll;
	auto mask = 0x7FFFFFFF;
	for (auto i = 32; i >= 0; --i)
	{
		auto bit = 0;
		if (i > 0)
		{
			bit = (1 << (i - 1));
			if ((K & bit) == 0)
			{
				mask = mask >> 1;
				continue;
			}
		}

		auto temp = K & (~bit);
		temp = ~(temp | mask);
		auto sum = 0ll;
		for (auto j = 0; j < N; ++j)
		{
			if ((A[j] & temp) == 0)
			{
				sum += B[j];
			}
		}
		result = max(result, sum);
		mask = mask >> 1;
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 1408
from collections import defaultdict

N, M, K = map(int, input().split())
friends = defaultdict(list)
blocked = defaultdict(list)

for i in range(M):
    a, b = map(int, input().split())
    friends[a - 1].append(b - 1)
    friends[b - 1].append(a - 1)
for j in range(K):
    c, d = map(int, input().split())
    blocked[c - 1].append(d - 1)
    blocked[d - 1].append(c - 1)

groups = {}
for i in range(N):
    if i in groups:
        continue
    group = {i}
    stack = [(i, None)]
    while stack:
        j, parent_id = stack.pop()
        group.add(j)
        groups[j] = group
        for k in friends[j]:
            if k != parent_id and k not in groups:
                stack.append((k, j))

ans = []
for i in range(N):
    g = groups[i]
    res = len(g) - len(friends[i]) - 1
    for b in blocked[i]:
        if groups[b] is g:
            res -= 1
    ans.append(res)
print(*ans)


Measured memory_bytes: 124504
# -*- coding: utf-8 -*-
import math

def main():
    n_max, d_max = map(int, input().split())
    n_xy = 0
    for i in range(n_max):
        x, y = map(int, input().split())
        d_xy = math.sqrt(float(x * x + y * y))
        if d_xy <= float(d_max):
            n_xy += 1
    print(n_xy)

if __name__ == '__main__':
    main()


Measured memory_bytes: 69980
#include <stdio.h>
#include <string.h>
int main(){
long long int arr[10];
long long int value = 0;
int flag = 0;
scanf("%lld %lld %lld %lld", &arr[0], &arr[1], &arr[2], &arr[3]);
for(int i = 0; i < 2;i++){
	for(int j = 2;j < 4;j++){
		if(arr[i] * arr[j] > value || flag == 0){
			value = arr[i] * arr[j];
			flag = 1;
		}
	}
}



printf("%lld", value);
return 0;
}


Measured memory_bytes: 1716
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int cnt = 0;
	for(int i = a; i <= b; i++) if(c % i == 0) cnt++;
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1160
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    A,B,M=map(int,input().split())
    A=list(map(int,input().split()))
    B=list(map(int,input().split()))
    L=[list(map(int,input().split())) for i in range(M)]

    ans=min(A)+min(B)

    for l in L:
        ans=min(ans,A[l[0]-1]+B[l[1]-1]-l[2])
    print(ans)


resolve()

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

int main() {

    // input from txt （提出時にこの箇所は削除すること）
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    
    double R;
    cin >> R;
    cout << setprecision(20) << R*2*M_PI << endl;
    
}


Measured memory_bytes: 3788
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { x.modm(y.modpow(mod - 2)); }

void main()
{
	auto arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];
	auto K = RD;

	writeln(arr[K-1]);
	stdout.flush;
	debug readln;
}

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

using namespace std;

typedef long long ll;

const int N = 110, M = 1e5 + 10;

int v[N], w[N];
ll dp[N][M];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, W;
    cin >> n >> W;
    for (int i = 1; i <= n; i ++)
        cin >> w[i] >> v[i];
    for (int i = 1; i <= n; i ++)
    {
        for (int j = 0; j <= W; j ++)
        {
            dp[i][j] = dp[i - 1][j];
            if (w[i] <= j)
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
        }
    }
    ll ans = 0;
    for (int i = 1; i <= n; i ++)
        for (int j = 0; j <= W; j ++)
            ans = max(ans, dp[i][j]);
    cout << ans;
    return 0;
}


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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};       ///first 4 for adjacent
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};
ll dx8[]= {+1, +1, -1, -1, +2, +2, -2, -2};    ///knights move
ll dy8[]= {+2, -2, +2, -2, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
ll modinverse(ll a){return powmod(a,MOD-2);}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///


void _case()
{
    ll n,i;
    cin>>n;
    cout<<(n*(n-1))/2 el;

}

main()
{
    fastio();
    _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		if (t.substring(0, s.length()).equals(s)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 35660
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, m, vis[N], ans[N];
vector<int> adj[N];
stack<int> s;
void dfs(int u)
{
	vis[u] = 1;
	for (int v: adj[u])
	{
		if (vis[v] == 0)
			dfs(v);
	}
	s.push(u);
}
int main(int argc, char const *argv[])
{
	cin >> n >> m;
	for (int i = 0; i < m; ++i)
	{
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
	}
	for (int i = 1; i <= n; ++i)
	{
		if (vis[i] == 1)
			continue;
		dfs(i);
		vector<int> nodes;
		while (!s.empty())
		{
			nodes.push_back(s.top());
			s.pop();
		}
		reverse(nodes.begin(), nodes.end());
		for (int u: nodes)
		{
			
			ans[u] = max(ans[u], 1);
			for (int v: adj[u])
				ans[u] = max(ans[u], 1 + ans[v]);
		}
	}
	cout << *max_element(ans + 1, ans + 1 + n) - 1;
	return 0;
}

Measured memory_bytes: 9004
#include "cstdio"

int main (){
    int h,w;

    for(;;){
        scanf("%d%d",&h,&w);
        if(h==0&&w==0) break;
        for(int k=0;k<w;k++){
            printf("#");
        }
        printf("\n");
        for(int i=0;i<h-2;i++){
            printf("#");
            for(int j=0;j<w-2;j++){
                printf(".");
            }
            printf("#\n");
        }
        for(int s=0;s<w;s++){
            printf("#");
        }
        printf("\n\n");
    }
}

Measured memory_bytes: 2556
/*
  AUTHOR:SOURABH
  CREATED:12:02:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<ll , null_type, less< ll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

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

    //freopen("in.txt","r",stdin);
    //freopen(2 "out.txt","w",stdout);

    ll t,a,b,c;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>a>>b>>c;
        if((a==b && b!=c) || (b==c && b!=a)  || (c==a && b!=a))
            cout<<"Yes";
        else
            cout<<"No";
    }
    return 0;
}











Measured memory_bytes: 256
//Lucky PIN
//全探索
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<(x)<<endl
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll inf=1e18;
const int N=2e5+10;
ll factorial(ll x){//階乗の計算
    if(x==0||x==1) return 1;
    return x*factorial(x-1);
}
ll gcd(ll a ,ll b){return b ? gcd(b,a%b) : a;}//最大公約数
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}//最小公倍数
int num_digit(ll a){//桁数を求める
    int num_dig = 0;
    while(a!=0){
        a /= 10;
        ++num_dig;
    }
    return num_dig;
}
vector<ll> digit(ll a){//桁の数字を求める
    vector<ll> dig(num_digit(a));
    for(int i=num_digit(a)-1; i>=0; --i){
        dig[i] = a%10;
        a /= 10; 
    }
    return dig;
}



int main(){

    int n;
    string s;
    cin >> n >> s;

    int ans = 0;
    for(int i=0;i<1000;++i){
        //000~999までの文字列
        string v = to_string(i);
        if((int)v.size()==1) v.insert(0,"00");//insertで任意の位置に文字列を追加
        if((int)v.size()==2) v.insert(0,"0");
        // cout(v);

        int p = 0;
        int cnt = 0;
        for(int j=0;j<3;++j){
            for(int k=p;k<n;++k){
                if(s[k]==v[j]){
                    p = k+1;
                    ++cnt;
                    break;
                }
            }
        }
        if(cnt==3) ans += 1;
    }
    cout(ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<ii> vii;

#define deb(x) cout << #x": " << (x) << endl;


// ---- コーディングはここから！ ('-')7

void solve(){
	int n; cin>>n;
	vii v(n); fore(i,0,n)cin>>v[i].f>>v[i].s;
	bool can = 0;
	fore(i,0,n){
		int x = 0;
		fore(j,0,3)if(v[i+j].f==v[i+j].s)x++;
		if(x==3)can=1;
	}
	cout<<(can?"Yes":"No")<<ENDL;

}
int main(){_
	//int t; cin>>t; while(t--)
	solve();
}


Measured memory_bytes: 3636
#include<stdio.h>

int main(void){
    int i = 0;
    char s[2000] = "",ss[2000] = "";
    scanf("%s",s);
    while(s[i] != '\n' && s[i] != '\0'){
        if (s[i] > 67){
            ss[i] = s[i] - 3;
        }
        else{
            ss[i] = s[i] + 23;
        }
        i = i + 1;
    }
    printf("%s\n",ss);
    return 0;
}

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

using namespace std;
using ll = long long int;
using lc = complex<double>;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for(ll i=0; i<n; i++)
        cin >> a[i];
    for(ll i=k; i<n; i++)
        cout << (a[i-k] < a[i] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 4732
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 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;
}
signed main(){
    int N;cin>>N;
    vector<int>V(N,0);
    int X;cin>>X;
    rep(i,X){
        int j;cin>>j;
        V[j-1]+=1;
    }
    int Y;cin>>Y;
    rep(i,Y){
        int j;cin>>j;
        V[j-1]+=2;
    }
    int Z;cin>>Z;
    rep(i,Z){
        int j;cin>>j;
        V[j-1]+=4;
    }
    int ans=0;
    rep(i,N){
        if(V[i]==7||V[i]==6||V[i]==4)ans++;
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 3084
n=int(input())

t = list(map(int,input().split()))

memo = [0]*9

for i in t:
    if 1<= i and i<400:
        memo[0] += 1
    elif 400<= i and i<800:
        memo[1] += 1
    elif 800<= i and i<1200:
        memo[2] += 1
    elif 1200<= i and i<1600:
        memo[3] += 1
    elif 1600<= i and i<2000:
        memo[4] += 1
    elif 2000<= i and i<2400:
        memo[5] += 1
    elif 2400<= i and i<2800:
        memo[6] += 1
    elif 2800<= i and i<3200:
        memo[7] += 1
    else:
        memo[8] += 1

ans = 0

for i in range(len(memo)):
    if i == 8:
        ex = memo[-1]
    elif memo[i] != 0:
        ans += 1

if ans == 0:
    print(1, ex)
else:
    print(ans, ans+ex)

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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define INFTY 999999


int main(void){
    int N,K;
    scanf("%d %d",&N,&K);

    if(N>=2*K-1){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }

    

    return 0;
}

Measured memory_bytes: 128
<?php

fscanf(STDIN,"%d %d %d",$a,$b,$x);
$a_mod_x = $a % $x;
$left = $a;

if($a_mod_x != 0) {
	$left = $a - $a_mod_x + $x;
}

$right = $b - $b % $x;
$answer = ($right - $left) / $x + 1;

echo $answer, "\n";

?>


Measured memory_bytes: 4856
#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;
#define ll long long
#define For(a, b, c) for(int a = b; a < c; ++a)
#define Ford(a, b, c) for(int a = b; a > c; --a)

#define int long long
#define ii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(),a.end()
#define reset(a, b) memset(a, b, sizeof(a))
#define bit(x, i) (x >> (i - 1) & 1ll)
#define onbit(x, i) (x | (1ll << (i - 1)))
#define offbit(x, i) (x & ~(1ll << (i - 1)))
#define bitone(i) __builtin_popcountll(i)
#define bitl(i) __builtin_clz(i)
#define bitr(i) __builtin_ctz(i)
#define INF 1000000000000
#define vll vector<ll>
#define vi vector<int>
#define fio ifstream cin("a1.in"); ofstream cout("a1.out")
/********************************************************

Digvijay Bahadur Singh
MNNIT

*********************************************************/


const int MOD=998244353;
const int N = 1e6+100;

/********************************************************************/
                 /* GRAPH*/
//vector<vector<ll>> g;
//vector<bool> vis1,vis2;
/*******************************************************************/
ll power(ll a,ll b)
{
   ll ans =1;
   while(b>0){
   if(b&1) ans = (ans%MOD * a%MOD)%MOD;
   a = (a%MOD * a%MOD)%MOD;
   b=b>>1;
   }
   return ans%MOD;
}
int dp[6200][6200];
int lps(string s)
{
   int n=s.length();
   
   for(int i=0;i<n;i++)
   {
      dp[i][i]=1;
   }
   for(int l=2;l<=n;l++)
   {
      for(int j=0;j<n;j++)
      {
        int i=j+l-1;
         if(s[j]==s[i]&&l==2)
         {
            dp[j][i]=2;

         }
         else if(s[j]==s[i])
         {
            dp[j][i]=dp[j+1][i-1]+2;
         }
         else
         {
            dp[j][i]=max(dp[j+1][i],dp[j][i-1]);
         }
         
      }
   }
   return dp[0][n-1];
}

signed main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
   // fio;
  
    	ll T=1;
   //  cin>>T;
  
   
    
    while(T--)
  {
     long double a,b,c;
     cin>>a>>b>>c;
    long double val = 1.0*(c-a-b)/2;
    long double val2=sqrt(a*b);
     if(val2<val)
     {
        cout<<"Yes\n";
     }
     else
     {
        cout<<"No\n";
     }
     
     
     

    

     

     

  }

  
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	
	int n,w[100],i,j,s,count,min;
	count=0;
	min=100;
	
	scanf("%d",&n);
	
	for(i=0; i<n; i++){
		scanf("%d",&w[i]);
	}
	
	for(j=0; j<n-1; j++){
		for(i=j; i<n; i++){
			if(w[i] < min){
				min = w[i];
				s=i;
			}
		}
		
		if(s != j){
			w[s]=w[j];
			w[j]=min;
			count++;
		}
		min = 100;
	}
	
	for(i=0; i<n; i++){
		printf("%d",w[i]);
		if(i != n-1){
			printf(" ");
		}
	}
	printf("\n");
	printf("%d\n",count);
	
	return 0;
}
	


Measured memory_bytes: 2092
//raja1999

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define int ll

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

//std::ios::sync_with_stdio(false);

vi vec,wt;
string s;
vi lol;
int main(){
	std::ios::sync_with_stdio(false); cin.tie(NULL);
	int n,k,c,i,ans= 0,res=0,j;
	cin>>n>>k;
	if(k==0){
		assert(0);
	}
	cin>>s;
	vec.pb(s[0]-'0');
	c=1;
	f(i,1,s.length()){
		if(s[i]!=s[i-1]){
			wt.pb(c);
			c=1;
			vec.pb(s[i]-'0');
		}
		else{
			c++  ;
		}
	}	
	wt.pb(c);
	int fl=0;
	if(vec[0]==0){
		fl=1;
		lol.pb(0);
		rep(i,wt.size() ){
			lol.pb(wt[i]);
		}
		wt=lol;
	}	
	if((vec.size()+fl)/2<=k){
		cout<<n<<endl;
	}
	else{
		rep(i,2*k){
			ans+=wt[i]+wt[i+1];
			i++;
		}
		if(i<vec.size()+fl){
			ans+=wt[i];
		}
		res=ans;
		j=0;
		i++;
		while(i<vec.size()+fl){
			ans+=wt[i];
			if(i+1<vec.size()+fl){
				ans+=wt[i+1];
			}
			ans-=(wt[j]+wt[j+1]);
			j+=2;
			i+=2;
			res=max(res,ans);
		}
		cout<<res<<endl;

	}
	return 0;
} 
	

Measured memory_bytes: 1876
import java.util.*;
import java.io.*;


public class Main {

    static int roundUp(int N){
        return (N+9)/10*10;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = 5;
        int[] dish = new int[N];
        for(int n=0; n<N; n++) dish[n] = sc.nextInt();

        int ans = 0;
        int last = 0;
        for(int d:dish){
            ans += roundUp(d);
            last = Math.max(last, roundUp(d)-d);
        }
        System.out.println(ans-last);



    }
}


Measured memory_bytes: 21844
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
//DEBUG 
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define all(v) (v).begin(), (v).end()
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define pb push_back
#define fi first
#define se second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 998244353;
int t,n,m,k,x,y;
 
 
int32_t main()
{
    IOS;
    cin>>n>>k;
    v32 vis(n+1,0);
    forn(i,k){
      cin>>m;
      forn(j,m){
        cin>>x;
        vis[x]=1;
      }
    }
    int ans=0;
    forsn(i,1,n+1) ans+=!vis[i];
    cout<<ans<<ln;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}

typedef struct{
	int top;
	int *data;
}Stack;
void init(Stack *s,int size){
	s->data=(int*)calloc(size,sizeof(int));
	s->top=0;
	return;
}
void push(Stack *t,int a){
	t->data[t->top++]=a;
	return;
}
int pop(Stack *t){
	return t->data[--t->top];
}
int a[200000];
int l[200000],r[200000];
int main(void)
{
	int n,i;
	ll ans=0;
	Stack s;
	scanf("%d",&n);
	FOR(i,0,n) scanf("%d",&a[i]);
	init(&s,n);
	FOR(i,0,n){
		while(s.top&&a[s.data[s.top-1]]>a[i]) s.top--;
		if(!s.top) l[i]=-1;
		else l[i]=s.data[s.top-1];
		push(&s,i);
	}
	s.top=0;
	for(i=n-1;i>=0;i--){
		while(s.top&&a[s.data[s.top-1]]>a[i]) s.top--;
		if(!s.top) r[i]=n;
		else r[i]=s.data[s.top-1];
		push(&s,i);
	}
	FOR(i,0,n) ans+=(ll)a[i]*(i-l[i])*(r[i]-i);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int j = n%10;
  if (j ==2 || j == 4 || j == 5 || j == 7 || j == 9){
    cout << "hon" << endl;
  }else if (j == 0 || j == 1 || j == 6 || j == 8){
    cout << "pon" << endl;
  }else{
    cout << "bon" << endl;
  }
}


Measured memory_bytes: 3632
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(m)]
ab.sort()
m = 0
ans = 0
for a, b in ab:
  if m <= a:
    ans += 1
    m = n
  m = min(b, m)
print(ans)

Measured memory_bytes: 27880
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    int cnt = 1;
    rep(i,n){
        int add = (a[i] - 1) / cnt;
        ans += add;
        a[i] -= add * cnt;
        if(add > 0) a[i] = 1;
        if(a[i] == cnt) ++cnt;
    }
    cout << ans << endl;
    return 0;
}


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

#define N 100000
#define INF 1000000

typedef struct{
    int go,back,cost;
}Date;

int n,d[N];
Date a[500000];
void root(int);

int main(void){
    int i,j,u,k,count=0;
    scanf("%d",&n);
    for(i=0;i<n;i++) {
        scanf("%d%d",&u,&k);
        for(j=0;j<k;j++){
            a[count].back=u;
            scanf("%d%d",&a[count].go,&a[count].cost);
            count++;
        }
    }
    root(count);
    for(i=0;i<n;i++) printf("%d %d\n",i,d[i]);
    return 0;
}

void root(int b){
    int i,flag=1;
    
    for(i=0;i<n;i++) d[i]=INF;
    d[0]=0;
    
    while(flag!=0){
        flag=0;
        for(i=0;i<b;i++){
            if(a[i].cost+d[a[i].back]<d[a[i].go]){
                d[a[i].go]=a[i].cost+d[a[i].back];
                flag=1;
            }
        }
    }
}

Measured memory_bytes: 6460
from itertools import combinations as cmbs
import sys
c = {"M":0,"A":0,"R":0,"C":0,"H":0}
for si in map(lambda s:s[0],sys.stdin):
    if si in c:
        c[si] += 1
ans = sum(i*j*k for i,j,k in cmbs(c.values(),r=3))
print(ans)


Measured memory_bytes: 8968
/*in the name of Allah the most beneficent the most merciful.*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 1000000007
//#define mod2 20071027
//#define MOD 998244353
// #define base 100001
//#define mod 1000074259
#define base2 31
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case %lld:\n", ++c)
#define out(x) cout << #x << " -> " << x << endl;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FILE   freopen("input.txt", "r", stdin);  freopen("out.txt", "w", stdout);
using namespace std;
const int N = 300010;
ll n, a[N], res,sum;

int solve() {
	in1(n);
	for(int i=0;i<n;i++){
		in1(a[i]);
		sum=(sum+a[i])%MOD;
	}
	for(int i=0;i<n;i++){
		sum=(sum-a[i])%MOD;
		res=(res+(a[i]*sum)%MOD)%MOD;
	}
	if(res<0) res+=MOD;
	printf("%lld\n", res);
	return 0;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	return solve();
}

Measured memory_bytes: 5392
import sys

input = sys.stdin.readline
n, m = map(int, input().split())
ab = {}

for _ in range(m):
    a, b = map(int, input().split())
    if a not in ab:
        ab[a] = [b]
    else:
        ab[a].append(b)
ans = 0
for i in ab[1]:
    if i in ab:
        if n in ab[i]:
            ans = 1
        else:
            continue
    else:
        continue

if ans == 1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 30624
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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

Measured memory_bytes: 256
package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	primeFactorization := func(n int) (factors [][2]int) {
		for i := 2; i*i <= n; i++ {
			e := 0
			for ; n%i == 0; n /= i {
				e++
			}
			if e > 0 {
				factors = append(factors, [2]int{i, e})
			}
		}
		if n > 1 { // n 是质数
			factors = append(factors, [2]int{n, 1})
		}
		return
	}

	var n int
	Fscan(in, &n)
	if n == 1 {
		Fprintln(out, 0)
		return
	}
	ans := 0
	f := primeFactorization(n)
	for _, pp := range f {
		_,e := pp[0],pp[1]
		for i:=1;i<=e;i++ {
			ans++
			e-=i
		}
	}
	Fprintln(out, ans)
}

func main() { run(os.Stdin, os.Stdout) }


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

ll n,m;
bool reached[50];
bool graph[50][50];

void dfs(ll v){
  reached[v]=true;
  rep(i,n){
    if(!(graph[v][i])) continue;
    if(reached[i]) continue;
    reached[i]=true;
    dfs(i);
  }
}

int main(){
  cin>>n>>m;
  vector<ll> a(m),b(m);
  rep(i,m){
    cin>>a[i]>>b[i];
    a[i]--;
    b[i]--;
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
  }
  ll ans=0;
  rep(i,m){
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=false;
    rep(j,n) reached[j]=false;
    dfs(0);
    bool flag=false;
    rep(j,n) if(!(reached[j])) flag=true;
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
    if(flag) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace _066
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToArray();
            var a = line[0];
            var b = line[1];
            var c = line[2];
            var max = line.Max();
            
            Console.WriteLine(a+b+c-max);

        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define N 100020
#define ll long long
using namespace std;
inline int read(){
  int x=0,f=1;char ch=getchar();
  while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
  while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
  return f?x:-x;
}
int main(int argc, char const *argv[]) {
  ll I = read(), O = read(), T = read(),
    J = read(), L = read(), S = read(), Z = read();
  ll ans = O;
  if (!I || !J || !L) {
    ans += I >> 1 << 1;
    ans += L >> 1 << 1;
    ans += J >> 1 << 1;
  } else if ((J & 1) == (L & 1) && (L & 1) == (I & 1)) {
    ans += I + J + L;
  } else {
    ans += I + J + L - 1;
  }
  printf("%lld\n", ans);
  return 0;
}
/*

OO | J IIII L | iiii | J jjj | LLL l
OO | JJJ  LLL | IIII | JJJ j | L lll


*/

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<fstream>
#include <set>
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
const int  MAXN =3e5+10;
const int mod = 1e9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf= 0x3f3f3f3f;
#define eps 1e-8
#define PI 3.1415926535898
#define lowbit(x) (x&(-x))
using namespace std ;
//getline(cin,s);
//set<ll>::iterator it;
//map<int,int>::iterator it;
typedef long long ll;
int hang[MAXN],lie[MAXN];
map<pair<int,int>,int >mp;
vector<int>v1,v2;
int main()
{
	int n,m,t;
	int flag=0;
	scanf("%d %d %d",&n,&m,&t);
	for(int i=1;i<=t;i++)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		mp[{x,y}]=1;
		hang[x]++;
		lie[y]++;
	}
	int max1=0,max2=0;
	for(int i=1;i<=n;i++)
	{
		max1=max(max1,hang[i]);
	}
	for(int i=1;i<=n;i++)
	{
		if(hang[i]==max1) v1.push_back(i);
	}
	for(int i=1;i<=m;i++)
	{
		max2=max(max2,lie[i]);
	}
	for(int i=1;i<=m;i++)
	{
		if(lie[i]==max2) v2.push_back(i);
	}
	int size1=v1.size(),size2=v2.size();
	for(int i=0;i<size1;i++)
	{
		for(int j=0;j<size2;j++)
		{
			int x=v1[i],y=v2[j];
			if(!mp[{x,y}])
			{
				flag=1;
				break;
			}
		}
		if(flag) break;
	}
	if(flag) printf("%d\n",max1+max2);
	else printf("%d\n",max1+max2-1);
	return 0;
}

Measured memory_bytes: 28464