akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rd3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define rl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back


#define L_B lower_bound
#define U_B upper_bound

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf (1000*1000*1000+5)
#define mod 1000000007
#define maxn 100009
#define maxr 100009
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	ll n;
	rl(n);
	map<string,ll> mp;
	ll mx=0;
	fr(i,0,n)
	{
		string str;
		cin>>str;
		mp[str]+=1;
		mx=max(mx,mp[str]);
	}
	for(auto i: mp)
	{
		if(i.S==mx)
			cout<<i.F<<endl;
	}
	return 0;
}

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

int main() {
	// your code goes here
	int n; cin>>n;
	int f=0;
	int arr[n][2];
	for(int i=0;i<n;i++){
	    cin>>arr[i][0];
	    cin>>arr[i][1];
	}
	for(int i=1;i<n-1;i++){
	    //cout<<arr[i][0]<<arr[i][1]<<endl;
	    if(arr[i][0]==arr[i][1] && arr[i-1][0]==arr[i-1][1] && arr[i+1][0]==arr[i+1][1]){
	        cout<<"Yes"<<endl;
	        f++;
	        break;
	    }
	}
	if(f==0) cout<<"No"<<endl;
	return 0;
}


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

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

	vector<int> vec(3);

	vec.at(0)=a+b;
	vec.at(1)=a-b;
	vec.at(2)=a*b;

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

	cout << vec.at(2) << endl;
}

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

long long moduloMultiplication(long long a, long long b, long long mod) 
{ 
    long long res = 0;
    a %= mod; 
  
    while (b) 
    {  if (b & 1) 
          res = (res + a) % mod; 
          a = (2 * a) % mod;  
        b >>= 1;
    }   
    return res; 
} 

int main()
{
  long long mod=pow(10,9)+7,n;
  cin>>n;
  long long arr[n],sum=0,ans=0,pro;
  
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
    sum+=arr[i];
  }
  for(int i=0;i<n-1;i++)
  {
    sum-=arr[i];
    pro=moduloMultiplication(sum,arr[i],mod)%mod;
    ans=(pro%mod+ans%mod)%mod;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 5148
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#include<limits.h>
#define MAX 200002
int min(int a,int b){
    if(a<b) return a;
    else return b;
}
int main(){
    int N;
    char c[MAX];
    scanf("%d",&N);
    scanf("%s",c);
    int r=0,w=0;
    for(int i=0;i<N;i++){
        if(c[i]=='W')
            w++;
        else
            r++;
    }
    int left_w=0;
    for(int i=0;i<r;i++){
        if(c[i]=='W')
            left_w++;
    }
    int ans = min(w, min(r,left_w));
    printf("%d",ans);
    
}


Measured memory_bytes: 1924
def f(a):
    for x in 'bw':
        if a[0::4].count(x)==3 or a[2:7:2].count(x)==3:return x
        for i in range(3):
            if a[i*3:i*3+3].count(x)==3 or a[i::3].count(x)==3:return x
    return 'NA'

while 1:
    a=input()
    if a =='0':break
    print(f(a+input()+input()))

Measured memory_bytes: 7496
var
s,s1,s2,s3:string;
x:array[1..1000] of longint;
a:array['a'..'z'] of longint;
i,c,d,e:longint;
j,min:char;
begin
min:='z';
read(s);
for i:=1 to length(s) do
inc(a[s[i]]);
for j:='a' to 'z' do
if a[j]=0 then begin e:=1; if ord(j)<ord(min) then min:=j;end;
if e=0 then writeln('None')
else
writeln(min);
end.


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N; cin >> N;
    vector<ll> A(N), B(N), C(N);
    rep(i, N){cin >> A.at(i);}
    rep(i, N){cin >> B.at(i);}
    rep(i, N){cin >> C.at(i);}
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    ll ans = 0;
    for (auto b: B){
        auto a_iter = lower_bound(A.begin(), A.end(), b);
        auto c_iter = upper_bound(C.begin(), C.end(), b);
        // cout << b << " " << distance(A.begin(), a_iter) << " " << distance(c_iter, C.end()) << endl;
        ans += distance(A.begin(), a_iter) * distance(c_iter, C.end());
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 2560
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
typedef long long ll;
typedef priority_queue<int> PQI;
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);

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

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    vector<int> a(3);
    rep(i,3){
        cin>>a[i];
    }
    sort(all(a));
    rep(i,3){
        cout<<a[i];
        if(i!=2){
            cout<<" ";
        }
    }
    cout<<endl;
}


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

int main()
{
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i <= n; ++i)
  {
    for (int j = 0; j <= m; ++j)
      if ((m - j) * i + (n - i) * j == k)
      {
        printf("Yes\n");
        return 0;
      }
  }
  printf("No\n");

  return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        v: [usize; n]
    }
    let total: usize = v.iter().sum();
    let mut even = 0;
    for i in 0..(n + 1) / 2 {
        even += v[2 * i];
    }
    let mut ans = vec![0; n];
    ans[0] = even * 2 - total;
    print!("{}", ans[0]);
    for i in 1..n {
        ans[i] = (v[i - 1] - ans[i - 1] / 2) * 2;
        print!(" {}", ans[i]);
    }
    println!("");
}


Measured memory_bytes: 7420
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int h,n;
    cin >> h >> n;
    vector<int> a(n);
    long long int sum = 0;
    for(int i = 0 ; i < n ; i++){
        cin >> a[i];
        sum += a[i];
    }
    if(h <= sum)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
  
    return 0;
}

Measured memory_bytes: 640
N, K, S = map(int, input().split())

if S == 10**9:
  ans_list = [str(S)] * K  +  [str(S-1)] * (N-K)
else:
  ans_list = [str(S)] * K + [str(S+1)] * (N-K)
  
print(" ".join(ans_list))

Measured memory_bytes: 7012
S=input()
ans=0
tmp=0
for i in range(len(S)):
	if S[i]=="A" or S[i]=="C" or S[i]=="G" or S[i]=="T":
		tmp+=1
	else:
		ans=max(ans,tmp)
		tmp=0
ans=max(ans,tmp)
print(ans)


Measured memory_bytes: 2940
#!/usr/bin/env python3

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(1)
	n, m = map(int, sys.stdin.readline().split())
	a = list(map(int, sys.stdin.readline().split()))
	if n - sum(a) >= 0:
		print(n-sum(a))
	else:
		print(-1)
	


main()

Measured memory_bytes: 10608
n,w=map(int,input().split())
a=[]
dp=[]
for i in range(n):
   a.append(list(map(int,input().split())))
for k in range(n+1):
  dp.append([])
  for l in range(w+1):
      dp[k].append(0)
for i in range(n-1,-1,-1):
   for j in range(w+1):
       if j<a[i][0]:
           dp[i][j]=dp[i+1][j]
       else:
           dp[i][j]=max(dp[i+1][j],dp[i+1][j-a[i][0]]+a[i][1])
print(dp[0][w])

Measured memory_bytes: 142668
main = input => {
  input = input.split('\n');
  var v = input[1].split(' ').map(parseFloat);
  
  var result = v.sort((a,b) => a - b).reduce((acc,cur) =>(acc + cur)/2);
  console.log(result);
}
main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7628
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
  
int main() {
	// 入力
	ll A, B, C;cin>>A>>B>>C;
    
	// 解法
	bool ans = false;
	if (A==B & B!=C) ans = true;
	if (B==C & C!=A) ans = true;
	if (C==A & A!=B) ans = true;

	//出力
	if (ans) printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
long long MOD = 1e9 + 7;
typedef long long ll;
typedef pair<ll, ll> pll;
//typedef boost::multiprecision::cpp_int bigint;

ll N, P;
vector<ll> A;
vector<vector<ll>> DP;

int main() {
	cin >> N >> P;
	A.resize(N + 1);
	for (ll n = 1; n <= N; n++)cin >> A[n];
	DP.resize(N + 1, vector<ll>(2, 0));
	DP[0][0] = 1;
	for (ll n = 1; n <= N; n++) {
		for (ll d = 0; d < 2; d++) {
			DP[n][d] += DP[n - 1][d];
			DP[n][d] += DP[n - 1][(d + A[n])&1];
		}
	}
	cout << DP[N][P & 1] << endl;
	return 0;
}

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



int dp[1<<17][26];

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  string s, t; cin >> s >> t;
  {
    auto S = set<char>(s.begin(), s.end());
    for (auto c : t) {
      if (not S.count(c)) return cout << -1 << '\n', 0;
    }
  }
  for (int i = 0; i < s.size(); ++i) fill(dp[i], dp[i] + 26, int(1e9));
  int cur[26];
  fill(cur, cur + 26, int(1e9));
  for (int _ = 0; _ < 10; ++_) {
    for (int i = s.size() - 1; i >= 0; --i) {
      for (int j = 0; j < 26; ++j) cur[j] += 1, dp[i][j] = min(dp[i][j], cur[j]);
      cur[s[i] - 'a'] = 0;
    }
  }
  long long ans = -1;
  for (auto c : t) {
    ans += dp[(ans + s.size()) % s.size()][c - 'a'];
  }
  cout << ans + 1 << '\n';
}


Measured memory_bytes: 10832
#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl


namespace atcoder {
	template<typename T>
	T ncr(T left, T right) {
		right = min(left - right, right);
		T ans = 1;
		for (T i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int MOD = 1000000007;
	const lli LIMIT = 10'000'000'000'000'000 * 5;
	const int tenfive = 100000;
}

using namespace atcoder;

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


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

#define INF 9000000000000;
#define int long long
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;

class SegmentTree {
private:
	int n;
	vector<int> node;
public:
	SegmentTree (vector<int> v) {
		int sz = v.size();
		n = 1;while(n < sz) n *= 2;
		node.resize(2*n-1, -1);
		for (int i = 0;i < sz;i++) {node[i+n-1] = v[i];}
		for (int i = n-2;i >= 0;i--) node[i] = max(node[2*i+1], node[2*i+2]);
	}

	int getmax(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		//要求区間と対象区間が交わらない
		if (r <= a || b <= l) return -1;
		//要求区間と対象区間を完全に被覆
		if (a <= l && r <= b) return node[k];
		int vl = getmax(a,b,2*k+1,l,(l+r)/2);
		int vr = getmax(a,b,2*k+2,(l+r)/2,r);
		return max(vl,vr);
	}
};

signed main() {
	int a[5];
	REP (i,5) cin >> a[i];
	int ans = INF;
	int now = 0;
	do {
		REP (i,4) {
			now += a[i];
			if (now%10!=0) now = now - now%10+10;
		}
		now += a[4];
		ans = min(now,ans);
		now = 0;
	}while(next_permutation(a,a+5));
	cout << ans << endl;
}

Measured memory_bytes: 256
import math


# 素数の判定
def is_prime(n):
    if n == 1:
        return 0

    for k in range(2, int(math.sqrt(n)) + 1):
        chk = False
        while (n % k == 0):
            chk = True
            n /= k
            if k not in check:
                check[k] = 1
            else:
                check[k] += 1
        if chk:
            return n
    if n in check:
        return 0
    else:
        check[n] = 1
        return 1


check = {}
n = int(input())
if n == 1:
    print(0)
else:
    while (1):
        n = is_prime(n)
        if n == 0:
            break
    ans = 0
    for k, v in check.items():
        for i in range(1, 50):
            v -= i
            if v < 0:
                break
            else:
                ans += 1
    # print(check)
    print(ans)


Measured memory_bytes: 9284
n = int(input())
words = ['a', 'b', 'c', 'd', 'e', 'f','g','h', 'i', 'j']
ans = [[] for _ in range(n)]
ans[0].append(["a", 1])
for i in range(n - 1):
    for ai in ans[i]:
        for j in range(ai[1]):
            ans[i + 1].append([ai[0] + words[j], ai[1]])
        ans[i + 1].append([ai[0] + words[ai[1]], ai[1] + 1])

for a in ans[n - 1]:
    print(a[0])


Measured memory_bytes: 27996
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int main(){
	int n,m;
	while(cin>>n>>m,n){
		vvi in(n,vi(n));
		vvi pic(m,vi(m));
		rep(i,n)rep(j,n)cin>>in[i][j];
		rep(i,m)rep(j,m)cin>>pic[i][j];
		pii out(inf,inf);
		rep(e,4){
			rep(i,n-m+1)rep(j,n-m+1){
				bool h=true;
				pii t(inf,inf);
				rep(k,m)rep(l,m)
					if(pic[k][l]!=-1&&in[i+k][j+l]!=pic[k][l])h=false;				
					else if(pic[k][l]!=-1)t=min(t,pii(i+k,j+l));
				if(h){
					out=min(out,t);
				}
			}
			vvi tmp=pic;
			rep(i,m)rep(j,m)pic[i][j]=tmp[j][m-i-1];
		}
		if(out.first==inf)cout<<"NA"<<endl;
		else cout<<out.second+1<<" "<<out.first+1<<endl;
	}
}

Measured memory_bytes: 1288
#include<stdio.h>
#define MAX 26
 
typedef struct{
  int l;
  int r;
  int parent;
  int sibling;
  int deg;
  int depth;
  int height;
}Node;
  
Node node[MAX];
  
int Height(int i){
  int l=0,r=0; 
  if( node[i].l != -1 ) l = Height(node[i].l) + 1;
  if( node[i].r != -1 ) r = Height(node[i].r) + 1;
  if( r <= l ) return l;
  else if( r > l ) return r;
}
  
int main(){
   
  int n,id,r,l,i;
  
  scanf("%d",&n);
  
  for( i = 0 ; i < n ; i++ )
    {
      node[i].l = node[i].r = node[i].parent = node[i].sibling = -1;
      node[i].deg = node[i].depth = node[i].height = 0;
    }
    
  for( i = 0 ; i < n ; i++ )
    {
      scanf("%d%d%d",&id,&r,&l);
      if(r != -1 && l != -1){
    node[r].sibling = l;
    node[l].sibling = r;
    node[id].r = r;
    node[id].l = l;
    node[r].parent = node[l].parent = id;
    node[id].deg = 2;
      }
      else if( r == -1 && l != -1 ){
    node[id].l = l;
    node[l].parent = id;
    node[id].deg++;
      }
      else if( l == -1 && r != -1 ) {
    node[id].r = r;
    node[r].parent = id;
    node[id].deg++;
      }
    }
  int x;
  
  for( i = 0 ; i < n ; i++ )
    {
      x = i;
      while( node[x].parent != -1 )
    {
      x = node[x].parent;
          node[i].depth++;
    }
      node[i].height =  Height(i);
    }
  
  for( i = 0 ; i < n ; i++ )
    {
      printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,node[i].parent,node[i].sibling,node[i].deg,node[i].depth,node[i].height);
      if(node[i].parent == -1 ) printf("root\n");
      else if(node[i].deg == 0 ) printf("leaf\n");
      else printf("internal node\n");
    }
  return 0;
}

Measured memory_bytes: 612
//Humra Baski naahi...
 
#include<bits/stdc++.h>
using namespace std;

//-----------------------------------------------------------------------------------
typedef long long int ll;
typedef long double ld;
#define endl "\n"
#define int long long
#define float long double
#define u_s unordered_set
#define mm multimap
#define pb push_back
#define ff first
#define ss second
#define go_flash ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
const int mod = 1000000007;
//-----------------------------------------------------------------------------------
void primeFactors(int n){while(!(n%2)){n/=2;}for(int i=3;i<=sqrt(n);i+=2){
while(!(n%i)){n/=i;}}if(n>2){;}}
int cd(int n){return floor(log10(n) + 1);} 
unsigned int cb(int number) {unsigned int l=log2(number)+1;return l;}
bool at_position(int num,int pos){unsigned int go=(1ULL<<pos);bool bit = num & go;return bit;} 
//-----------------------------------------------------------------------------------
template<typename...T>void input(T &...args) {((cin >> args), ...);}
template<typename...T>void print(T &&...args) {((cout << args <<" "),...);}
template<typename...T>void deb(T &&...args) {((cerr<<args<<" "),...);cerr<<endl;}
//#define debug(x) cerr<<#x<<" => "<<x<<" ";
//-----------------------------------------------------------------------------------
void forv(vector<int> &v, int n) {int x;for(int i=0;i<n;i++){cin>>x;v.pb(x);}}
void printv(vector<int> v) {for(auto i: v){cout<<i<<" ";}}
void fora(int a[], int n) {for(int i=0;i<n;i++)cin>>a[i];}
void printa(int a[], int n) {for(int i=0;i<n;i++)cout<<a[i]<<" ";}
void dmap(map<int,int> mp){for(auto i: mp)cout<<i.ff<<" "<<i.ss<<endl;}
void dmmap(mm<int,int> mp){for(auto i: mp)cout<<i.ff<<" "<<i.ss<<endl;}
//-----------------------------------------------------------------------------------

signed main(){
    go_flash;

        int t=1;
        while(t--){
            //Your Code Blows HERE
            int n;cin>>n;
            if(n%10==2||n%10==7||n%10==5||n%10==4||n%10==9){
                cout<<"hon";
            }
            else if(n%10==0||n%10==1||n%10==6||n%10==8)
                cout<<"pon";
            else
            cout<<"bon";
            cout<<endl;
        }
    return 0;
}


Measured memory_bytes: 3700
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

bool hoge(int x,int y,int z) {
  return x&&x%3==0&&y%3==2&&z%3==2; 
}

int main() {
  int a,b,c,d,e,f;
  while(cin>>a>>b>>c>>d>>e>>f,a||b||c||d||e||f) {
    int x=a+d,y=b+e,z=c+f;
    int res = x/3+y/3+z/3;
    res += min(x%3, min(y%3, z%3));
    if (hoge(x,y,z)||hoge(y,z,x)||hoge(z,x,y))
      res++;
    cout << res<< endl;
  }
}

Measured memory_bytes: 868
#include "bits/stdc++.h"
#define _ ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;

int main() { _
    long long x, y;
    cin >> x >> y;
    if (x%y==0) return cout << -1 << endl, 0;
    cout << x << endl;
    return 0;
}



Measured memory_bytes: 256
data = {
        'S': [int(x) for x in range(1, 14)],
        'H': [int(x) for x in range(1, 14)],
        'C': [int(x) for x in range(1, 14)],
        'D': [int(x) for x in range(1, 14)]
        }

count = int(input())

for c in range(count):
    (s,r) = input().split()
    r = int(r)
    del data[s][data[s].index(r)]
        
for i in ('S', 'H', 'C', 'D'):
    for v in data[i]:
        print(i, v)

Measured memory_bytes: 6724
#include<stdio.h>
int main()
{
    char str[10000];
    int i,j,count=0,f,x,a[26]={0},c=0;
    scanf("%s",str);
    for(i=0;str[i]!='\0';i++)
    {
        if(str[i]>='a'&&str[i]<='z')
        {
            x=str[i]-'a';
            a[x]++;
        }
    }
    for(i=0;i<26;i++)
    {
        if(a[i]%2==0)
        {
            c++;
        }
    }
    if(c==26)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
typedef unsigned long long ULL;
using namespace std;

const LL INF = 99999999999999;
const int inf = 999999999;
int A, B, C;

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	while(scanf("%d%d%d", &A, &B, &C) == 3) {
		printf("%d\n", C / A * B);
	}

	return 0;
}
/*
    input:
    output:
    modeling:
    methods:
    complexity:
    summary:
*/

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

int main (int argc, char *argv[]) {
    int a, b, c, d, p;
    cin>>a;
    cin>>b;
    cin>>c;
    cin>>d;
    cin>>p;
    int t1 = p * a;
    int t2 = b + max((p - c), 0) * d;
    cout<<min(t1, t2)<<endl;
    return 0;
}


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

int main() {
    string stra[110];
    int x,y,z;
    cin >> x >> y;
    for(int i=1;i<=x;i++){
        cin >> stra[i];
    }
    z=y+2;
    for(int i=1;i<=z;i++){
        cout << "#";
    }
    cout << endl;
    for(int i=1;i<=x;i++){
        cout << "#" << stra[i] << "#" << endl;
    }
    for(int i=1;i<=z;i++){
        cout << "#";
    }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	if(b>a)return 0;
	if(a==b)return 1;
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n,k,q,cnt[100010];
signed main(){
	cin>>n>>k>>q;
	rep(i,q){
		int a;
		cin>>a;
		cnt[a]++;
	}
	for(int i=1;i<=n;i++){
		int x=k-(q-cnt[i]);
		if(x>0)puts("Yes");
		else puts("No");
	}
	return 0;
}


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

int main() {
	int n,h,w;
	cin>>n>>h>>w;
	if (h > n || w > n) {
		cout<<0<<endl;
		return 0;
	}
	cout<<(n-h+1)*(n-w+1)<<endl;
	return 0;
}

Measured memory_bytes: 256
import math
n=int(input())
x=[]
y=[]
for i in range(n):
    xn,yn=map(int,input().split())
    x.append(xn)
    y.append(yn)
sum=0
for i in range(n):
    for j in range(n):
        if i!=j:
            sum+=math.sqrt((x[i]-x[j])**2+(y[i]-y[j])**2)
mul=1
for i in reversed(range(1,n)):#(n-1)!
    mul*=i
sum*=mul
for i in range(n):
    sum/=i+1
print(sum)


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector <int> v(n);
    for (int i=0; i<n; i++) cin >> v[i];
    int mx = 0, smx = 0;
    vector <int> gcd_fwd(n), gcd_bck(n);
    gcd_fwd[0] = v[0];
    for (int i=1; i<n; i++) gcd_fwd[i] = __gcd(gcd_fwd[i-1], v[i]);
    gcd_bck[n-1] = v[n-1];
    for (int i=n-2; i>=0; i--) gcd_bck[i] = __gcd(gcd_bck[i+1], v[i]);
    int gcd = v[0];
    for (int i=1; i<n; i++) gcd = __gcd(gcd, v[i]);
    gcd = max(gcd, gcd_bck[1]);
    gcd = max(gcd, gcd_fwd[n-2]);
    for (int i=1; i<n-1; i++) gcd = max(gcd, __gcd(gcd_fwd[i-1], gcd_bck[i+1]));
    cout << gcd;
    return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <stdlib.h>
using namespace std;
int main()
{
	int a,b,k;
	scanf("%d %d %d", &a, &b, &k);
	int i;
	if(k * 2 >= b - a + 1)
	{
		for(i = a ; i <= b ; i++)
		{
			printf("%d\n",i);
		}
	}
	else
	{
		for(i = 1 ; i <= k ; i++)
		{
			printf("%d\n",i + a - 1);
		}
		for(i = 1 ; i <= k ; i++)
		{
			printf("%d\n",b - k + i);
		}
	}
	return 0;
}

Measured memory_bytes: 128
N,L = map(int,input().split())

taste = []

for i in range(0,N):
	taste.append(L + i)
		
if 0 in taste:
	print(sum(taste))
	
else:
	if L > 0:
		print(sum(taste) - taste[0])
	elif L < 0:
		print(sum(taste) - taste[N-1])

Measured memory_bytes: 3060
#include <iostream>
#include <string>

using namespace std;

//文字列の標準化
string standardize(string s)
{
    
    char c = 'a';       //最初に置き換えるのは'a'
    char temp;
    for (auto& i: s)    //先頭から見ていく
    {
        //今見ているアルファベットが既知のアルファベット群と隣り合っていなかったら問題の操作を行う
        if (i > c)
        {
            temp = i;   //置き換える文字を保存（保存しないと置き換える文字自体が置き換えられて条件が狂う）
            for (auto& j: s)
            {
                if (j == temp) j = c;
                else if (j == c) j = temp;
            }
            c++;        //既知の文字が1増える（cが既知となり、cの次以降が未知となる）
            if (c > 'z') break; //全部のアルファベットが既知なら完成
        }
        //今見ているアルファベットが既知のアルファベット群と隣り合っていたら置き換えの必要はないが
        else if (i == c)
        {
            c++;        //既知の文字が1増える（cが既知となり、cの次以降が未知となる）
            if (c > 'z') break; //全部のアルファベットが既知なら完成
        }
    }
    return s;
}

int main(void)
{
    string S, T;
    //SとTを入力
    cin >> S >> T;
    //SとTの標準形が一致すれば"Yes"を、異なれば"No"を出力
    cout << ( (standardize(S) == standardize(T)) ? "Yes" : "No") << endl;
    return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s,t; cin>>s>>t;
  vsort(s);
  sort(t.rbegin(),t.rend());
  if(s<t){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

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

using namespace std;

template <typename M>
struct PersistentSegmentTree {
    using Op = function<M(const M&, const M&)>;
    using Ptr = int;
    using Index = int;
    M ID;
    Op op;
    Index SL, SR;
    struct Node {
        Ptr ch[2] = {};
        M x;
        Node(M _x) : x(_x) {}
    };
    vector<Node> tr;
    Ptr vc = 0; // version count
    // create node
    inline Ptr cn(const M& val) {
        tr.emplace_back(val);
        return vc++;
    }
    inline Ptr cp(const Ptr& i) {
        tr.push_back(tr[i]); // not safe
        return vc++;
    }
    PersistentSegmentTree(M _ID, Op _op, Index _SL, Index _SR)
        : ID(_ID), op(_op), SL(_SL), SR(_SR)
    {
        // TODO
        tr.reserve(1e7); // WARNING: there's an intrinsic bug, if don't reserve enough space, might RE
        cn(ID);
    }
    inline void pull(Ptr i) { tr[i].x = op(tr[ tr[i].ch[0] ].x, tr[ tr[i].ch[1] ].x); }
    Ptr update(Ptr pv, Index p, const M& val, Index sl, Index sr) {
        if (sr - sl == 1) return cn(op(tr[pv].x, val));
        Index sm = sl + (sr-sl)/2;
        Ptr ptr = cp(pv);
        if (p < sm) tr[ptr].ch[0] = update(tr[ptr].ch[0], p, val, sl, sm);
        else        tr[ptr].ch[1] = update(tr[ptr].ch[1], p, val, sm, sr);
        pull(ptr);
        return ptr;
    }
    M query(Ptr v, Index l, Index r, Index sl, Index sr) {
        if (r <= sl || sr <= l) return ID;
        if (l <= sl && sr <= r) return tr[v].x;
        Index sm = sl + (sr-sl)/2;
        return op(query(tr[v].ch[0], l, r, sl, sm),
                  query(tr[v].ch[1], l, r, sm, sr));
    }

    Ptr update(Ptr pv, Index p, const M& val) {
        return update(pv, p, val, SL, SR);
    }
    M query(Ptr v, Index l, Index r) {
        return query(v, l, r, SL, SR);
    }
    M query_all(Ptr v) const { return tr[v].x; }
};

void solve() {
    int n,q;
    cin >> n >> q;
    PersistentSegmentTree<int> pst(0, [](int u, int v){ return u+v; }, 0, n+1);
    vector<int> roots(n+1);
    vector<int> pre(n+1);
    for (int i = 1; i <= n; i++) {
        int x; cin >> x;
        int ver = roots[i-1];
        ver = pst.update(ver, pre[x], 1);
        pre[x] = i;
        roots[i] = ver;
    }
    while (q--) {
        int l,r;
        cin >> l >> r;
        int res = pst.query(roots[r], 0, l) - pst.query(roots[l-1], 0, l);
        cout << res << '\n';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 124056
#include<iostream>
#include<bits/stdc++.h>
#include<math.h>
#include<vector>
#include<string>
#include<cstring>
#include<ctype.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
			tree_order_statistics_node_update>
	new_data_set;
//   <<implemented_sorted_vector>>  new_data_set p;
//   <<insert_like_set>>           insert(key):log(n)
//<<accessing_iterator_by_index>> find_by_order(idx):log(n)
//	    <<accessing_by_value>>   order_of_key(key):log(n)
// << replace less<int> by greater<int> for descending order>>
// find(key), erase(find(key)) works the same!
typedef long long ll;
typedef long l;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ERR(x) cout<<"#x:"<<x<<endl
#define ERR2(x,y) cout<<"#x:"<<x<<" "<<"#y:"<<y<<endl;
#define ERR3(x,y,z) cout<<"#x:"<<x<<" "<<"#y:"<<y<<" "<<"#z:"<<z<<endl;
#define show(v) for(auto e: v) cout<<e<<" ";
#define showArr(A,n) for(int i=0;i<n;i++) cout<<A[i]<<" ";
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define mp make_pair
#define ff first
#define ss second
#define umpit unordered_map<ll,ll>::iterator
#define mpit map<ll,ll>::iterator
#define setit set<ll>::iterator
#define all(v) v.begin(),v.end()

bool check(ll mid, vector<ll>&v, ll k){
	ll n = v.size();
	bool x = true;
	FOR(i,0,v.size()){
		
		if(v[i] <= mid) continue;
		// else
		ll ans = -1;
		ll lb = 1;
		ll ub = MOD;
		// find minimum 
		while(lb < ub){
			ll mx = (lb+ub)/2;
			if((v[i]+mx-1)/mx <= mid){
				ub = mx;
			} else {
				lb = mx+1;
			}
		}
		
		
		//cout<<v[i]<<"->"<<ub-1<<endl;
		k -= ub-1;
		if( k < 0  ){
			x = false;
			break;
		}
		
	}

	return x;
}

int main()
{
	ll n,k;
	cin>>n>>k;
	vector<ll>v(n);
	FOR(i,0,n){
		cin>>v[i];
	}
	// o logn logk n
	ll low = 0;
	ll high = MOD;
	while(low < high){
		ll mid = (low+high)/2;
		bool z = check(mid,v,k);
		//cout<<mid<<" "<<endl;
		if(z){
			// ok check for lower
			high = mid;
		}
		else{
			low = mid + 1;
		}
	}
	cout<<high;
	return 0;
}


Measured memory_bytes: 4688
import bisect

n = int(input())
a = list(map(int,input().split()))
a.sort()

# 確定
last = a[-1]
a = a[:-1]

first = 10**10
now = 10**10

for i in a:
    m = min(abs(i-last//2),abs(i-(last+1)//2))
    if now > m:
        now = m
        first = i

print(last,first)

Measured memory_bytes: 14428
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    string a = string({s1.at(0)}) + string({s2.at(0)}) + string({s3.at(0)});
    for(int i=0; i<a.size(); i++) a.at(i) -= 32;
    cout << a << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define debug(x) cerr<<#x<<" = "<<x<<endl
#define debug2(a, b) cerr<<#a<<" = "<<a<<" | "<<#b<<" = "<<b<<endl
#define debug3(a, b, c) cerr<<#a<<" = "<<a<<" | "<<#b<<" = "<<b<<" | "<<#c<<" = "<<c<<endl
#define debug4(a, b, c, d) cerr<<#a<<" = "<<a<<" | "<<#b<<" = "<<b<<" | "<<#c<<" = "<<c<<" | "<<#d<<" = "<<d<<endl
#define debug5(a, b, c, d, e) cerr<<#a<<" = "<<a<<" | "<<#b<<" = "<<b<<" | "<<#c<<" = "<<c<<" | "<<#d<<" = "<<d<<" | "<<#e<<" = "<<e<<endl
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
const ll N = 100000 + 5;
const ll MOD = 1e9 + 7;
const ll INF = 2e9;
unordered_set<string> occured;
int main() {
	ll n;
	cin>>n;
	string s[n];
	cin>>s[0];
	occured.insert(s[0]);
	bool ok = 1;
	for(int i=1; i<n; ++i) {
		cin>>s[i];
		if(occured.find(s[i])!=occured.end() || s[i][0] != s[i-1][s[i-1].size()-1]) {
			ok = 0;
		}
		occured.insert(s[i]);
	}
	if(ok) printf("Yes\n");
	else	printf("No\n");
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    ll ans=0;
    for(int b=k+1;b<=n;++b){//ｂを固定して考える
        ans+=n+1;//0-n
        ans-=k*(n/b);//bの剰余がk未満のものの数
        ans-=min(k,n%b+1);//最後の端数だけ別で考える
    }
    if(!k)ans-=n;//a=0の場合を取り除く
    cout<<ans<<endl;
    return 0;
}

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

int main() {
	int i , j , k=0 , n ;
	cin >> n ;
	for(i=1;i<=n;i++)
	{
		cin >> j ;
		if(i!=j)
		k++;
	}
	if(k<=2)
	cout << "YES";
	else
	cout << "NO";
	return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
int main()
{
	int n,a[100],i,s=0,p,m=0,f;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		m+=a[i];
	}
	p=m/n;
	f=m%n;
	if(f>=(n+1)/2)
	p++;
	for(i=0;i<n;i++)
	{
		s+=(a[i]-p)*(a[i]-p);
	}
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
int a[50],b[50],c[50];
const int INF = 1001001001;
int dp[50][440][440];
int dfs(int x,int sa,int sb){
	//trace(x,sa,sb);
	if(x == 0 && sa == 0 && sb == 0)return 0;
	else if(x == 0)return INF;
	if(dp[x][sa][sb] != -1)return dp[x][sa][sb];
	int ret = INF;
	//tukawanai
	ret = min(ret,dfs(x-1,sa,sb));
	if(sa - a[x] >= 0 && sb - b[x] >= 0)ret = min(ret,dfs(x-1,sa-a[x],sb-b[x]) + c[x]);
	return dp[x][sa][sb] = ret;

}
signed main(){
	int n,ma,mb;cin >> n >> ma >> mb;
	rep(i,n)cin >> a[i+1] >> b[i+1] >> c[i+1];
	int ret = INF;
	rep(i,50)rep(j,440)rep(k,440)dp[i][j][k] = -1;
	
	for(int i = 1;i <= 400;i++){
		int A = ma*i;
		int B = mb*i;
		if(A > 440 || B > 440)break;
		ret = min(ret,dfs(n,A,B));
	}
	if(ret == INF)ret = -1;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 79220
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
    double a, b, c, C;
    cin >> a >> b >> C;
    const double pi = 3.14159265359;
    c = sqrt(a * a + b * b - 2 * a * b * cos(pi * C / 180));
    double S, L, h;
    h = b * sin(pi * C / 180);
    S = 0.5 * a * h;
    L = a + b + c;
    cout << fixed << setprecision(4) << S << '\n' << L << '\n' << h << endl;
    return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
ll M = 1000000007;

int main(){
  ll n , k; cin >> n >> k;
  ll ans = 0;
  ll t = (n+1)*n/2;
  // cout<<t<<endl;
  for (ll i = k; i <= n+1; i++){
    ll t2 = (n - i)*(n - i + 1)/2;
    ll d = (i-1)*i/2;
    ans += t-t2-d+1;
    // cout<<i<<" "<<t2<<" "<<d<<endl;
    ans %= M;
  }
  cout << ans << endl;
  return 0;
}


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

 
int main(){
  
 int k,x;
 cin >> k >> x;
 int req = k-1;
 int ini = x-req;
 int fin = x+req;
 for(int i=ini; i<=fin; i++){
  cout << i << " ";
 }
return 0;



}

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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/f.in", "r", stdin);
//  freopen("../IO/f.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}


void solve(std::istream &in, std::ostream &out) {
  int n;
  in >> n;
  vector<int> a(n + 1), b(n + 1);
  for (int i = 0, x; i < n; ++i) {
    in >> x;
    a[x]++;
  }
  for (int i = 1; i <= n; ++i) {
    b[a[i]]++;
  }
  int sum2 = 0, sum1 = 0;
  for (int i = 1; i <= n; ++i) {
    sum2 += b[i];
  }
  vector<int> f(n + 1);
  for (int i = 1; i <= n; ++i) {
    sum1 += i * b[i];
    sum2 -= b[i];
    f[i] = (sum1 + i * sum2) / i;
  }
  f[0] = n;
  for (int i = 1; i <= n; ++i) {
    int l = upper_bound(f.begin(), f.end(), i, greater<>()) - f.begin() - 1;
    l = max(0, l);
    out << l << '\n';
  }
}


Measured memory_bytes: 4352
from collections import defaultdict
d = defaultdict(int)
n = int(input())
for _ in range(n): d[input()] += 1
s = sorted(d.items(), key=lambda x: (-x[1], x[0]))
nmax = s[0][1]
for i in s:
  if i[1] != nmax: break
  print(i[0])

Measured memory_bytes: 62308
#coding:utf-8
s = list(input())
n = len(s)
ans = 0
if n % 2 == 0:
    sf = s[0:int(n/2)]
    sb = s[int(n/2):]
    sb_r = sb[::-1]
    #print(sf, sb_r)
    for i in range(0, int(n/2)):
        if sf[i] != sb_r[i]:
            ans += 1
else:
    sf = s[0:int(((n-1)/2))]
    sb = s[int(((n-1)/2)+1):]
    sb_r = sb[::-1]
    #print(sf, sb_r)
    for i in range(0, int((n-1)/2)):
        if sf[i] != sb_r[i]:
            ans += 1
print(ans)




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

int main() {
  int K,N;
  cin>>K>>N;
  vector<int> vec(N);
   rep(i,N){
     cin>>vec.at(i);
  }
  sort(vec.begin(), vec.end());
  
  int MAX=K-vec.at(N-1)+vec.at(0);
  
  rep(i,N-1){
    MAX=max(MAX,vec.at(i+1)-vec.at(i));
    }
  
  cout<<K-MAX<<endl;
  
}

Measured memory_bytes: 1024
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

#define rep(i,n) for(int i=0; i < n; i++)
using ll =  long long;
using namespace std;

int main()
{
    int n, _n;
    cin >> n;
    _n = n%10;
    if (_n == 3) cout << "bon" << endl;
    else if (_n == 2 || _n == 4 || _n == 5 || _n == 7 || _n == 9) cout << "hon" << endl;
    else cout << "pon" << endl;

    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
using namespace std;
 
  int main(){
int a,b,c,d;
cin>>a >>b>>c>>d;
if(a+b>c+d)cout<<"Left"<< endl;
if(a+b==c+d)cout<<"Balanced"<< endl;
if(a+b<c+d)cout<<"Right"<<endl;
return 0;}

Measured memory_bytes: 256
#include<stdio.h>
void swap(int *a,int *b);

int main(){
	int a[5];
	int i,j;

	for(i=0;i<5;i++){
		scanf("%d",&a[i]);
	}
	for(i=4;i>=0;i--){
		for(j=0;j<i;j++){
			if(a[j]<a[j+1])swap(&a[j],&a[j+1]);
		}
	}

	printf("%d %d %d %d %d\n",a[0],a[1],a[2],a[3],a[4]);

	return 0;

}

void swap(int *a,int *b){
	int temp;
	temp = *a;
	*a = *b;
	*b =temp;

}

Measured memory_bytes: 596
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		string[] str = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			Console.Write(str[0].Substring(i,1));
			Console.Write(str[1].Substring(i,1));
		}
	}
}

Measured memory_bytes: 11092