akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;

int main(int argc, char* argv[])
{
    long sx, sy, tx, ty;
    scanf("%ld%ld%ld%ld", &sx, &sy, &tx, &ty);

    long x = tx-sx;
    long y = ty-sy;
    long i;
    for(i=0; i<x; i++) {
        printf("R");
    }
    for(i=0; i<y; i++) {
        printf("U");
    }
    for(i=0; i<x; i++) {
        printf("L");
    }
    for(i=0; i<y; i++) {
        printf("D");
    }
    printf("D");
    for(i=0; i<x+1; i++) {
        printf("R");
    }
    for(i=0; i<y+1; i++) {
        printf("U");
    }
    printf("L");
    printf("U");
    for(i=0; i<x+1; i++) {
        printf("L");
    }
    for(i=0; i<y+1; i++) {
        printf("D");
    }
    printf("R\n");

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
vector<int> InputLine(int N);

int main() {
    int N;
    cin >> N;
    vector<int> A = InputLine(N-1);
    vector<int> ans(N);

    for(int i = 0; i < A.size() ; i++){
        ans.at(A.at(i)-1)++;
    }

    for(int i = 0 ; i < ans.size() ; i++){
        cout << ans.at(i) << endl;
    }

}

vector<int> InputLine(int N) {
    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }
    return vec;
}

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

using namespace std;

void setIO() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef DEBUG
    //freopen("solution.out", "w", stdout);
    freopen("1.in", "r", stdin);
#endif
}

const int inf = 1e9;

int main() {
    setIO();

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


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

int qtmp(const void *a,const void *b){
    return *(int*)a - *(int*)b;
}

int main(void){
    int i,n;

    int ascore[20] = {};
    int count=0;

    while(1){
    scanf("%d",&n);
    if(n == 0) break;

    int score[n];

    for(i=0;i<n;i++){
        scanf("%d",&score[i]);
    }

    for(i=0;i<n;i++){
        qsort(score,n,sizeof(int),qtmp);
    }

    double dave=0;
    int iave=0;

    for(i=1;i<n-1;i++){
        dave += score[i];
    }

    iave = (int)((dave / (n-2)));

    ascore[count] = iave;
    count++;

    }

    for(i=0;i<20;i++){
        if(ascore[i] == 0) break;
        printf("%d\n",ascore[i]);
    }

    return 0;
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

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

    ll N,M,X;
    string S;
    cin >> N>>M>>X;
    vector<ll> C(N);
    vector<vector<ll>> A(N, vector<ll>(M));

    REP(i,N){
        cin >> C.at(i);
        REP(j,M){
            cin >> A.at(i).at(j);
        }
    }

    ll flag = 0;
    ll sum = 0;

    REP(i,M){
        REP(j,N){
            sum += A.at(j).at(i);
        }
        if(sum<X){
            flag = 1;
            sum = 0;
        }
        else{
            sum = 0;
        }
    }
    vector<ll> sumA(M);
    ll flag1 = 0;
    ll sumC = MOD, ans = MOD;
    ll tmp = 0;

    if(flag==1){
        cout << -1 << endl;
    }


    else{
        for (int bit = 0; bit < (1 << N);++bit){
            bitset<12> s(bit);

            for (int i = 0; i < N;i++){
                if(s.test(i)){
                    REP(j,M){
                        sumA.at(j) += A.at(i).at(j);
                    }
                    tmp += C.at(i);
                }
            }
            //cout << tmp << endl;
            sumC = tmp;
            REP(i, M)
            {
                if(sumA.at(i)<X){
                    flag1 = 1;
                }
            }
            //cout << flag1 << " " << sumC << endl;
            if (flag1 == 0)
            {
                ans = min(ans, sumC);
                tmp = 0;
                sumC = MOD;

            }
            else{
                flag1 = 0;
                sumC = MOD;
                tmp = 0;
            }
            REP(i, M)
            {
                sumA.at(i) = 0;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3664
N = int(input())
A = list(map(int,input().split()))

sum = 0

for i in range(len(A)-1):
  if A[i+1] < A[i]:
    sum += A[i] - A[i+1]    
    A[i+1] = A[i]

  else:
    pass
print(sum)

Measured memory_bytes: 32408
#!/usr/bin python3
# -*- coding: utf-8 -*-

N, M = map(int, input().split())
vals = [[] for _ in range(8)]
for _ in range(N):
    a, b, c = map(int,input().split())
    vals[0].append( a+b+c)
    vals[1].append( a+b-c)
    vals[2].append( a-b+c)
    vals[3].append( a-b-c)
    vals[4].append(-a+b+c)
    vals[5].append(-a+b-c)
    vals[6].append(-a-b+c)
    vals[7].append(-a-b-c)
ret = 0
for val in vals:
    val.sort(reverse = True)
    ret = max(ret, sum(val[:M]))
print(ret)


Measured memory_bytes: 9448
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void){
	int N, K;
	int ans=0;
	cin >> N >> K;
	int l[N];
	for(int i=0; i<N; i++){
		cin >> l[i];
	}
	sort(l, l+N);
	for(int i=0; i<K; i++){
		ans += l[N-i-1];
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

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

    vector<double> vec(n);
    for (auto &num : vec) {
        cin >> num;
    }
    sort(vec.begin(), vec.end());

    double mid = vec[n - 1] / 2.0;
    double best_match = vec[0];
    double best_dist = abs(mid - best_match);

    for (const auto &num : vec) {
        if (abs(mid - num) < best_dist) {
            best_dist = abs(mid - num);
            best_match = num;
        }
    }

    cout << (int)vec[n - 1] << " " << (int)best_match << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll)(a.size())
#define pll pair<ll,ll>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for(i=a;i<b;i++)

set<ll>::iterator it;
ll mod = 1000000007;
ll power(ll a,ll b)
{
	ll p = 1;
	a = a%mod;
	while(b>0)
	{
		if(b%2==1)
			p=((p%mod)*(a%mod))%mod;
		b=b>>1;
		a=((a%mod)*(a%mod))%mod;
	}
	return p;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	if(n>=30)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

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

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

int main() {
    int N, result = 0;
    cin >> N;
    vector<int> a(N);
    vector<bool> can(N);
    REP(i, N) {
        cin >> a[i];
        can[i] = false;
    }
    REP(i, N) {
        if (a[a[i]-1] == i+1) {
            if (can[a[i]-1] == false && can[i] == false) {
                result++;
                can[a[i]-1] = true;
                can[i] = true;
            }
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
    char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
    vector<char*> v({token});
    while(token = strtok(NULL,", ")) v.push_back(token);
    return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
    debug() << " [" << args.back() << ": " << H << "] ";
    args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=1e9+7;
const int MX=0x3f3f3f3f;

int main(){
    IOS;
    int n,i;
    cin>>n;
    int a[n],b[n],flag=0;
    ll ans=0;
    REP(i,0,n-1){
        cin>>a[i]>>b[i];
        ans+=a[i];
        if(b[i]>a[i]) flag=1;
    }
    if(!flag){
        cout<<0;
        return 0;
    }
    vi v;
    REP(i,0,n-1){
        if(a[i]>b[i]) v.EB(b[i]);
    }
    sort(all(v));
    cout<<ans-v[0];
    return 0;
}

Measured memory_bytes: 3872
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;

int main(){
    string s,t;
    cin >> s >> t;
    int s_size=s.size();
    int t_size=t.size();
    vector<vi>dp(s_size+1,vi(t_size+1,0));
    for(int i=0;i<s_size;i++){
        for(int j=0;j<t_size;j++){
            if(s[i]==t[j]){
                dp[i+1][j+1]=dp[i][j]+1;
            }
            else dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
        }
    }
    /*
    for(int i=0;i<=s_size;i++){
        for(int j=0;j<=t_size;j++){
            cout << dp[i][j] <<" ";
        }
        cout << endl;
    }
    */
    int len=dp[s_size][t_size];
    int i=s_size,j=t_size;
    string ans="";
    while(len>0){
        if(dp[i][j]==dp[i-1][j]) i--;
        else if(dp[i][j]==dp[i][j-1]) j--;
        else{
            ans=s[i-1]+ans;
            i--; j--; len--;
        }
    }
    //cout << dp[s_size][t_size] << endl;
    cout << ans << endl;
}

Measured memory_bytes: 38844
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
int main(void){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  int min,max;
  if(A<=C) min=C; else min=A;
  if(B<=D) max=B; else max=D;
  if(max-min<=0) cout<<0;
  else cout<<max-min;
  return 0;
}


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

int main() {
  int N;
 
  cin >> N;
  
  int a = N % 1000;
  int b = N / 10;
  
  cin >> a, b;
  
  if ( a % 111 == 0 || b % 111 == 0 ) {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
int n,k;
int ans=0;
int tot=0;
int h[100005],a[100005];
struct Edge
{
    int x,next;
}e[200005];
void add_edge(int x,int y)
{
    e[++tot].x=y;
    e[tot].next=h[x],h[x]=tot;
}
int dfs(int x,int deep)
{
    int ret=deep;
    for(int i=h[x];i;i=e[i].next)
    ret=max(ret,dfs(e[i].x,deep+1));
    if(a[x]!=1 && ret-deep==k-1)
	return ans++,0;
    else 
	return ret;
}

int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
    if(a[1]!=1)
	ans=a[1]=1;
    for(int i=2;i<=n;i++)
	add_edge(a[i],i);
    dfs(1,0);
	printf("%d\n",ans);
}

Measured memory_bytes: 6528
def mc():
    k,a,b=map(int,input().split())
    if b-a<=2:
        print(k+1)
        exit()

    kanekai=(k-(a+1))//2

    ans=kanekai*(b-a)+b
    if (k-(a+1))%2!=0:
        ans+=1
    return ans



print(mc())


Measured memory_bytes: 3060
X[500][500],Y[500][500];
d[4]={1,0,-1};
N;
dfs(x,y)
{
	int c=X[x][y]+1-Y[x][y];
	for(int r=0;r<4;r++)
	{
		int z=x+d[r],w=y+d[r^1];
		if(0<=z&&0<=w&&z<N&&w<N&&X[z][w]>c)
		{
			X[z][w]=c;
			dfs(z,w);
		}
	}
}
ans;
main(P)
{
	scanf("%d",&N);
	for(int i=0;i<N;i++)for(int j=0;j<N;j++)X[i][j]=i<j?fmin(i,N-j-1):fmin(j,N-i-1);
	for(;~scanf("%d",&P);)
	{
		int x=~-P/N,y=~-P%N;
		ans+=X[x][y];
		Y[x][y]=1;
		dfs(x,y);
	}
	printf("%d",ans);
}

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

int main() 
{
	//int a,b; cin>>a>>b;
	set<int>s;
	for(int i=1;i<=9;i++)
	{
		for(int j=1;j<=9;j++)
		{
			s.insert(i*j);
		}
	}
	int n; cin>>n;
	if(s.count(n))
	{
		cout<<"Yes\n";
	}else{cout<<"No\n";}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rlcfpoj(x) scanf("%I64d",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define plcfpoj(x) printf("%I64d",x)
#define lfd() printf("\n")
#define sp() printf(" ")
#define inrep(x) int x;scanf("%d",&x);while(x--)
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
int n;
long double a[120];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=2;i<=n;i++){
		a[i]=(a[i]+a[i-1])/(long double)(2.0000);
	}
	cout<<a[n]<<endl;
	return 0;
}


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

int n, k;
int main()
{
	std::cin >> n >> k;

	if (k == 0) {
		std::cout << static_cast<long long>(n) * static_cast<long long>(n) << std::endl;
		return  0;
	}

	long long ans = 0;
	for (int i = 1; i <= n; ++i) {
		if (i > k) {
			auto p = n / i;
			auto r = n % i;
			ans += p * std::max(0, i - k) + std::max(0, r - k + 1);
		}
	}

	std::cout << ans << std::endl;
	return 0;
}


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

using namespace std;

#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define F first
#define S second
#define pb push_back

typedef long long ll;
typedef pair <int, int> pii;
typedef long double ld;
typedef vector <ll> vi;

const int N = 2e6 + 1;
const int INF = 1e9 + 9;
const int B = 1e9 + 7;

int n;
pii a[N];

int main() {
    #ifdef black
    freopen("in", "r", stdin);
    #endif // black
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    cin >> n;
    forn(i, 1, n)
        cin >> a[i].F >> a[i].S;

    a[++n] = {0, 0};
    forn(i, 1, n)
        a[i].S *= -1;
    set <pii> sl, sr;
    forn(i, 1, n)
        sl.insert({a[i].F, i}), sr.insert({a[i].S, i});

    ll ans = 0;
    forn(k, 1, n / 2) {
        int i = sl.rbegin() -> S;
        sr.erase({a[i].S, i});
        int j = sr.rbegin() -> S;
        sr.insert({a[i].S, i});
        ll x = a[i].F + a[j].S;

        i = sr.rbegin() -> S;
        sl.erase({a[i].F, i});
        j = sl.rbegin() -> S;
        sl.insert({a[i].F, i});
        if (x >= a[i].S + a[j].F) {
            i = sl.rbegin() -> S;
            sl.erase({a[i].F, i});
            sr.erase({a[i].S, i});
            j = sr.rbegin() -> S;
            sl.erase({a[j].F, j});
            sr.erase({a[j].S, j});
        }
        else {
            x = a[i].S + a[j].F;
            sl.erase({a[i].F, i});
            sr.erase({a[i].S, i});
            sl.erase({a[j].F, j});
            sr.erase({a[j].S, j});
        }
        if (x < 0) break;
        ans += x;
    }

    cout << 2 * ans << "\n";

    return 0;
}


Measured memory_bytes: 10368
import sys
N = raw_input()
items = raw_input().split()
res = dict()
for i in items[:int(N)]:
    i = int(i)
    if res.get(i) is None:
        res[i] = 1
    else:
        res[i] = res[i] + 1
long2 = [0,0]
for i, num in res.iteritems():
    if num < 2:
        continue
    if i > long2[0]:
        if num >= 4:
            long2 = [i, i]
        else:
            long2 = [i, long2[0]]
    elif i > long2[1]:
        long2[1] = i
print long2[0] * long2[1]

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

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

  vector<int> H(N);
  for (int i = 0; i < N; i++){
    cin >> H[i];
  }

  if (N <= K){
    cout << 0 << endl;
    return 0;
  }
  
  sort(H.begin(), H.end());

  int rest = N - K;
  ll sum = 0;
  for(int i = 0; i < rest; i++){
    sum += H[i];
  }
  cout << sum << endl;
}

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

int main(){

    ll n;
    cin >> n;
    int cnt=0;
    while(n>1){
        int ab=n/3;
        int c=ab;
        if(n%3!=0){
            c++;
        }
        n=c;
        cnt++;
    }
    cout << cnt <<endl;

    return 0;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
// -----------------<fast IO>------------------
#define IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FLSH             fflush(stdout)
#define fileIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);
#define PRECISION(x)     cout << fixed << setprecision(x);
#define endl             "\n"
// -----------------<Container manipulation / traversal macros>------------------
#define mp                 make_pair
#define pb                 push_back
#define ff                 first
#define ss                 second
#define sz(x)             ((int)((x).size()))
#define all(x)             (x).begin(),(x).end()
#define rep(i,n)         for(ll (i)=0;(i)<(n);(i)++)
#define forn(i,a,b)     for(ll (i)=(a);(i)<=(b);(i)++)
#define fill(l,a)        memset((l) , (a) , sizeof(l))
// -----------------<Some common useful functions>------------------
#define maX(a,b)        ( (a) > (b) ? (a) : (b))
#define miN(a,b)        ( (a) < (b) ? (a) : (b))
#define checkbit(n,b)   ( (n >> b) & 1)
#define INDEX(arr,i)      ( lower_bound(all(arr),i)-arr.begin())
#define in(b,a)         ( (b).find(a) != (b).end())
// -----------------<TypeDef Start>------------------
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector< std::vector<ll> > matrix;
typedef map<ll,ll> mii;
typedef vector<pii> vpii;
// -----------------<Constants>------------------
const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI=acos(-1);

const int INF=1e9;

int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}
ll lcm(ll a,ll b)
{
    return(a/gcd(a,b)*b);
}
/*ll power(ll a,ll b,ll p)
{
    ll res=1;
    a%=p;
    while(b>0)
    {
        if(b&1)
        res=res*a%p;
        a=a*a%p;
        b>>=1;
    }
    return(res);
}
ll modInverse(ll a, ll m)
{
    ll g = gcd(a, m);
    return(power(a,m-2,m));
}*/
/*ll b_search(ll arr[],ll n,ll s)
{
    ll l=0,r=n-1;
    while(l<=r)
    {
        ll mid=l+(r-l)/2;
        if(arr[mid]==s)
        return(mid);
        if(arr[mid]<s)
        l=mid+1;
        else
        r=mid-1;
    }
    return(-1);
}*/
bool isprime(ll x)
{
    if(x==1)
        return(false);
    for(ll i=2;i*i<=x;i++)
    {
        if(x%i==0)
            return(false);
    }
    return(true);
}
//vector<ll> v[100005];
void solve()
{
    ll n;
    cin>>n;
    ll c=n%10;
    if(c==2 || c==4 || c==5 || c==7 || c==9)
        cout<<"hon";
    else if(c==0 || c==1 || c==6 || c==8)
        cout<<"pon";
    else if(c==3)
    cout<<"bon"<<endl;
}

int main()
{
    IOS
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return(0);
}


Measured memory_bytes: 3652
K = int(input())
p = 7 % K
ans = 1
for i in range(K):
    if p == 0:
        print(ans)
        break
    p2 = (p * 10) % K
    p = 7 % K + p2
    p %= K
    ans += 1
if p != 0:
    print(-1)

Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, a, b; cin >> n >> a >> b;
	vector<int> v(n);
	for(int i = 0; i < n; i++) cin >> v[i];
	long long ans = 0;
	for(int i = 0; i < n - 1; i++) ans += min(1ll * (v[i + 1] - v[i]) * a, 1ll * b);
	cout << ans << endl;
	return 0;
}


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

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

const long long INF = 1LL << 60;

int main(){
  string s; cin >> s;

  int cnt = 0;
  rep(i, s.size()){
    if(s[i] == 'o') cnt++;
  }

  cout << 700 + 100 * cnt << endl;

  return 0;
}


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

int main(){
  int N;
  cin >> N;
  int ans = 1;
  for(int i = 1; i < N; i++){
    if(i * i > N){
      break;
    } else {
      ans = i * i;
    }
  }
  cout << ans << endl;
}

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

using namespace std;
int main(){
	int w, h, n;
	int x1, y1, x2, y2;
	cin >> w >> h >> n;

	x1 = 0;
	x2 = w;
	y1 = 0;
	y2 = h;
	for(int i=0; i<n; i++){
		int x, y, a;
		cin >> x >> y >> a;

		if(a == 1) x1 = max(x1, x);
		if(a == 2) x2 = min(x2, x);
		if(a == 3) y1 = max(y1, y);
		if(a == 4) y2 = min(y2, y);

	}

	if((x2 < x1) || (y2 < y1)){
		cout << 0 << endl;
		return 0;
	}

	cout << (x2 - x1) * (y2 - y1) << endl;

	return 0;
}

Measured memory_bytes: 256
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define CLR(x) memset(x,0,sizeof x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
int n,m,a[200005],b[200005],res1[200005],res2[200005];
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);;
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>a[i]>>b[i];
	}
	for(int i=1;i<=m;i++){
		if(a[i]==1){
			res1[b[i]]=1;
		}
		if(b[i]==n){
			res2[a[i]]=2;
		}
	}
	for(int i=1;i<=m;i++){
		if(res1[i]==1 && res2[i]==2){
			cout<<"POSSIBLE";
			return 0;
		}
	}
	cout<<"IMPOSSIBLE";
	//system("pause");
	return 0;
}

Measured memory_bytes: 3328
#      
import collections, atexit, math, sys, bisect 

sys.setrecursionlimit(1000000)
def getIntList():
    return list(map(int, input().split()))    

try :
    #raise ModuleNotFoundError
    import numpy
    def dprint(*args, **kwargs):
        #print(*args, **kwargs, file=sys.stderr)
        # in python 3.4 **kwargs is invalid???
        print(*args,  file=sys.stderr)
    dprint('debug mode')
except Exception:
    def dprint(*args, **kwargs):
        pass



inId = 0
outId = 0
if inId>0:
    dprint('use input', inId)
    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #标准输出重定向至文件
if outId>0:
    dprint('use output', outId)
    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #标准输出重定向至文件
    atexit.register(lambda :sys.stdout.close())     #idle 中不会执行 atexit
    
N, = getIntList()
H, = getIntList()
W, = getIntList()
#print(N)
r =0

r +=  (N-H+1) * (N-W+1)

print(r)







Measured memory_bytes: 21636
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
    int time=0;
    if(a==0||b==0||c==0){
        cout<<0<<endl;
        return 0;
    }
while(a>0){
    if(a>b){
        time+=c;
        a=a-b;
    }else {
        time=time +c;
        break;
    }
}
    cout<<time<<endl;
return 0;
}

Measured memory_bytes: 3596
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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=1e18;

int main(){
    string s;
    cin >> s;
    ll n=s.length();
    ll ans=0;
    for(ll i=1;i<n/2;i++){
        bool ok=true;
        for(ll j=0;j<i;j++){
            if(s[j]!=s[j+i]){
                ok=false;
                break;
            }
        }
        if(ok) ans=i*2;
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;
typedef long long LL;

int main(){
    LL N;
    cin >> N;
    map<LL, LL> m;
    for(int i = 0; i < N; ++i){
        LL a;
        cin >> a;
        m[a] += 1;
    }
    LL rest = 0;
    for(auto p : m){
        rest += p.second - 1;
    }
    rest %= 2;
    LL ans = m.size();
    if(rest == 1){
        ans -= 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <iostream>
using namespace std;
int main(){
    int a,b;
    int t;
    char op;
    cin>>a>>op>>b;
    while( op != '?'){
        switch (op) {
            case '+':
              cout<<a+b<<endl;
              break;
            case '-':
              cout<<a-b<<endl;
              break;
            case '*':
              t = a*b;
              cout<<t<<endl;
              break;
            case '/':
              t = a/b;
              cout<<t<<endl;
              break;
            case '?':
              break;
            default :
              break;
        }
        cin>>a>>op>>b;
    }
    return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS

int main(){
	fastread;
	string s;
	cin>>s;
	vector<vector<int> > a(26);
	for(int i=0;i<s.size();i++){
		a[s[i]-'a'].pb(i);
	}

	for(int c=0;c<26;c++){
		if(a[c].size() < 2) continue;
		int l = 0;
		int r = (int)a[c].size()-1;
		while(l<r){
			int tot = a[c][r]-a[c][l]+1;
			int my = r-l+1;
			if(my > (tot)/2){
				cout<<a[c][l]+1<<" "<<a[c][r]+1<<endl;
				return 0;
			}
			int tot1 = a[c][r]-a[c][l+1]+1;
			int tot2 = a[c][r-1]-a[c][l]+1;
			if(tot1 < tot2) l++;
			else r--;
		}
	}
	cout<<-1<<" "<<-1<<endl;
	return 0;
}


Measured memory_bytes: 1104
#include <cstdio>
#define rr register
using namespace std;
const int mod=1000000007,N=2001;
int n,k,inv[N*N],fac[N*N],dp[N][N];
inline signed mo(int x,int y){return x+y>=mod?x+y-mod:x+y;}
inline signed c(int n,int m){return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;}
signed main(){
	inv[0]=inv[1]=fac[0]=fac[1]=1,scanf("%d%d",&n,&k);
	if (k==1) return !putchar(49);
	for (rr int i=2;i<=n*k;++i) inv[i]=1ll*inv[mod%i]*(mod-mod/i)%mod;
	for (rr int i=2;i<=n*k;++i) fac[i]=1ll*fac[i-1]*i%mod,inv[i]=1ll*inv[i-1]*inv[i]%mod;
	for (rr int i=0;i<=n;++i) dp[i][0]=1;
	for (rr int i=1;i<=n;++i) for (rr int j=1;j<=i;++j)
	    dp[i][j]=mo(dp[i-1][j],1ll*dp[i][j-1]*(n-j+1)%mod*c(n*k-i-1-(j-1)*(k-1),k-2)%mod);
	return !printf("%d\n",dp[n][n]);
}

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

int main(){
  string S;
  cin >> S;
  
  int ans = 0;
  for (int i=0 ; i<3 ; i++){
    if (S.at(i)=='R')
      ans++;
  }
  
  if (S=="RSR")
    ans = 1;
  
  cout << ans << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>

int a[100001];

int main(){
    int n, tmp;
    std::cin >> n;
    for(int i = 0; i < n; i++){
        std::cin >> tmp;
        a[tmp+2]++;
        a[tmp+1]++;
        a[tmp]++;
    }
    std::cout << *std::max_element(a, a+100001) << std::endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
typedef long long ll;

using ipair = pair<int, int>;

ll INF = 1e16+7;

bool operator>(const ipair a,const ipair b){return a.first > b.first;}

int N;
string S;

int main(){
  // Input
  cin >> N;
  cin >> S;

  char c = '1';
  int cnt = 0;
  rep(i, N){
    if(S[i] != c){
      c = S[i];
      cnt++;
    }
  }

  cout << cnt << endl;


  return 0;
}


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

int main() {
    int n,m;
    long long ans = 0;
    cin >> n >> m;
    int to_buy = m;
    vector<pair<int,int>>a(n);
    for(int i = 0;i<n;i++){
        cin >> a[i].first >> a[i].second;
    }
    sort(a.begin(),a.end());
    for(auto now : a){
        if(to_buy == 0)break;
        ans += (long long)now.first * min(now.second,to_buy);
        to_buy -= min(now.second,to_buy);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
using namespace std;
typedef long long LL;
const int maxn = 200007;
struct thing
{
    int t;
    int e;
}a[maxn];

bool cmp(thing x, thing y){
    if(x.e > y.e){
        return false;
    }
    else if(x.e == y.e){
        return x.t < y.t;
    }
    else return true;
}

int main()
{
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i].t >> a[i].e;
    }
    sort(a, a + N, cmp);
    long long res = 0;
    int flag = 0;
    for(int i = 0; i < N; i++){
        res += a[i].t;
        if(res > a[i].e){
            flag = 1;
            break;
        }
    }
    if(flag){
        cout << "No" << endl;
    }
    else cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;


int main(){
  int n;
  cin >> n;
  vector<int> a(n+1);
  vector<int> ans(n+1);
  rep(i, n) cin >> a[i+1];
  for(int i = n; i > 0; --i){
    int s = 0;
    for(int j = i + i; j <= n; j += i){
      s += ans[j];
    }
    if(a[i] != s % 2) ans[i] = 1;
  }
  int s = 0;
  for(int i = 1; i <= n; ++i){
    s += ans[i];
  }
  cout << s << endl;
  if(s == 0) return 0;
  for(int i = 1; i <= n; ++i){
    if(ans[i])  cout << i << ' ';
  }
  cout << endl;

}


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

typedef long long LL;

const LL inf = (LL)1e18;

LL n, a, b, c, d, now;

unordered_map<LL, LL> ma;
priority_queue<LL> que;

void update(LL x, LL y)
{
	if (x >= now) return;
	if (!ma[x]) ma[x] = inf / (n - x) >= d ? (n - x) * d : inf, que.push(x);
	ma[x] = min(ma[x], y);
}

int main()
{
	int T; scanf("%d", &T);
	while (T--)
	{
		scanf("%lld%lld%lld%lld%lld", &n, &a, &b, &c, &d);
		ma.clear();
		ma[n] = 0;
		que.push(n);
		while (!que.empty())
		{
			LL x = que.top(); que.pop();
			now = x;
			if (inf / d >= x) update(0, ma[x] + d * x);
			if (x % 2 != 0)
			{
				update((x + 1) / 2, ma[x] + d + a);
				update((x - 1) / 2, ma[x] + d + a);
			}
			else update(x / 2, ma[x] + a);
			if (x % 3 != 0)
			{
				update(x / 3 + 1, ma[x] + d * (3 - x % 3) + b);
				update(x / 3, ma[x] + d * (x % 3) + b);
			}
			else update(x / 3, ma[x] + b);
			if (x % 5 != 0)
			{
				update(x / 5 + 1, ma[x] + d * (5 - x % 5) + c);
				update(x / 5, ma[x] + d * (x % 5) + c);
			}
			else update(x / 5, ma[x] + c);
		}
		printf("%lld\n", ma[0]);
	}
	return 0;
}

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

#define int long long
#define double long double

const int INF=2147483647;
const int MOD=1000000007;
const int mod=998244353;
const double eps=1e-18;

using namespace std;

int n,m;
int p[200001];
int sz[200001];

int findp(int v){
    if( p[v]==v ){
        return v;
    }
    return p[v]=findp(p[v]);
}

void Union(int v1,int v2){

    int p1=findp(v1);
    int p2=findp(v2);

    if(p1==p2){
        return;
    }

    if( sz[p1]>sz[p2] ){
        p[p2]=p1;
        sz[p1]+=sz[p2];
    }
    else{
        p[p1]=p2;
        sz[p2]+=sz[p1];
    }

}

signed main(){

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

    int v1,v2;

    cin>>n>>m;

    for(int i=0;i<n;i++){
        p[i]=i;
        sz[i]=1;
    }

    for(int i=0;i<m;i++){
        cin>>v1>>v2;
        v1--;
        v2--;
        Union(v1,v2);
    }

    int Max=-INF;
    for(int i=0;i<n;i++){
        Max=max(Max,sz[i]);
    }

    cout<<Max<<endl;


    return 0;
}


Measured memory_bytes: 6776
n = gets.chomp.to_i
f = []
p = []
n.times do
  f.push gets.chomp.split.join.to_i(2)
end
n.times do
  p.push gets.split.map(&:to_i)
end
$bithash = {}
def bitcount(n)
  return $bithash[n] if $bithash[n]
  count = 0
  10.times do
    count += 1 & n
    n >>= 1
  end
  count
end
max = -10000000000
1.upto(2**10-1) do |s|
  profit = 0
  0.upto(n-1) do |i|
    profit += p[i][bitcount(s & f[i])]
  end
  if max < profit
    max = profit
  end
end
puts max


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

int main(){
  string s;
  cin >> s;
  char S[100000];
  int count = 0;
  for(int i;i<s.size();i++){
    if(i%2==0){
      count++;
    }
  }
  for(int i;i<count;i++){
    S[i]=s[2*i];
  }
  cout << S << endl;
}

Measured memory_bytes: 512
# input
S = [list(input()) for _ in range(3)]

P_curr = 0

while S[P_curr] != []:
    if S[P_curr][0] == 'a':
        del S[P_curr][0]
        P_curr = 0
    elif S[P_curr][0] == 'b':
        del S[P_curr][0]
        P_curr = 1
    elif S[P_curr][0] == 'c':
        del S[P_curr][0]
        P_curr = 2

if P_curr == 0:
    print('A')
if P_curr == 1:
    print('B')
if P_curr == 2:
    print('C')



Measured memory_bytes: 3064
W, H, N = map(int, input().split())
menseki = W*H
left_x = 0
right_x = W
top_y = H
bottom_y = 0
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        if x > left_x:
            left_x = x
    elif a == 2:
        if x < right_x:
            right_x = x
    elif a == 3:
        if y > bottom_y:
            bottom_y = y
    else:
        if y < top_y:
            top_y = y
ans = (right_x - left_x) * (top_y - bottom_y)
if right_x <= left_x or top_y <= bottom_y:
    ans = 0
print(ans)    


Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL long long
#define MOD 100000
#define inf 1999999999


int main() {
	int a[10];
	cin >> a[0];
	cout << a[0] * (a[0] + 1) / 2 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
/* テンプレートここまで */

int main() {
  ll H, W; cin >> H >> W;

  if( H%3 == 0 || W%3 == 0){
    cout << 0 << endl;
    return 0;
  }

  ll ans = INF;

  if( H >= 3) ans = min(ans, W);
  if( W >= 3) ans = min(ans, H);

  vector<ll> s(3,0);
  FOR(i, 1, H){
    s[0] = W*i;
    s[1] = (H-i)*(W-W/2);
    s[2] = (H-i)*(W/2);
    sort(ALL(s)); 
    ll tmp = s[2]-s[0];
    ans = min(ans, tmp);
  } 
  FOR(i, 1, W){
    s[0] = H*i;
    s[1] = (W-i)*(H-H/2);
    s[2] = (W-i)*(H/2);
    sort(ALL(s)); 
    ll tmp = s[2]-s[0];
    ans = min(ans, tmp);
  } 
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    ll x, y;
    for(ll i = 1; i*i <= n; i++) {
        if(n%i == 0) {
            x = i;
            y = n/i;
        }
    }

    out(x+y-2);
    re0;
}

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

using namespace std;
using namespace boost;
using namespace boost::adaptors;

struct Mod {
    static constexpr auto kMod = 1000000007L;

    Mod() : n(0) {}
    // can be implicitly converted
    Mod(int64_t n) : n(n) {}

    Mod operator*(Mod m) const { return (n * (m.n % kMod)) % kMod; }

    Mod& operator*=(Mod m) {
        *this = *this * m;
        return *this;
    }

    Mod pow(int64_t p) {
        if (p == 0) {
            return 1;
        }
        if (p == 1) {
            return n;
        }

        int64_t r = this->pow(p / 2).n;
        if (p % 2 == 0) {
            return r * r % kMod;
        } else {
            return (r * r % kMod) * n % kMod;
        }
    }

    Mod operator/(Mod m) const {
        if (n == 0) {
            return 0;
        }

        return *this * m.pow(kMod - 2);
    }

    Mod& operator/=(Mod m) {
        *this = *this / m;
        return *this;
    }

    Mod operator+(Mod m) const { return (n + m.n) % kMod; }

    Mod& operator+=(Mod m) {
        *this = *this + m;
        return *this;
    }

    Mod operator-(Mod m) const { return (kMod + n - m.n) % kMod; }

    Mod& operator-=(Mod m) {
        *this = *this - m;
        return *this;
    }

    int64_t n;
};

int main() {
    int64_t r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;

    vector<Mod> fact(2000002L, 1);
    for (auto i : irange(1L, 2000002L)) {
        fact[i] = fact[i - 1] * i;
    }

    Mod ans = 0;
    for (auto r : irange(r1, r2 + 1)) {
        // C(r + c + 1, r + 1)
        ans += fact[r + c2 + 1] / fact[r + 1] / fact[c2];
        ans -= fact[r + (c1 - 1) + 1] / fact[r + 1] / fact[c1 - 1];
    }

    cout << ans.n << endl;
}

Measured memory_bytes: 15872
#include <cstddef>
#include <cstdint>
#include <vector>

namespace null_null {

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

template <typename T>
std::vector<T> make_v(usize a) { return std::vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(usize a, Ts... ts) {
  return std::vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template <typename T, typename V>
typename std::enable_if<std::is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename std ::enable_if<std::is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
  for (auto &e : t) fill_v(e, v);
}

template <typename T, typename V>
inline void chmin(T &a, V b) {
  if (a > b) a = b;
}
template <typename T, typename V>
inline void chmax(T &a, V b) {
  if (a < b) a = b;
}

} // namespace null_null

#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <utility>

namespace null_null {

void main_() {
  usize N;
  std::cin >> N;
  std::map<std::map<char, i32>, i32> sum;
  i32 ans = 0;
  for (usize i = 0; i < N; i++) {
    std::map<char, i32> mp;
    std::string s;
    std::cin >> s;
    for (usize j = 0; j < 10; j++) {
      mp[s[j]]++;
    }
    sum[mp]++;
    ans += sum[mp] - 1;
  }
  std::cout << ans << std::endl;
}

} // namespace null_null

int main() {
  null_null::main_();
  return 0;
}


Measured memory_bytes: 62336
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    int n;
    cin >> n;
    int *a = new int[n + 10];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll sum = 0;
    int max = a[0];
    for (int i = 1; i < n; i++) {
        if (max > a[i]) {
            sum += max - a[i];
        } else {
            max = a[i];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 4416
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
    int A, B, C;
    cin >> A >> B >> C;
    for(int i = max({A, B, C});i != -1;i++){
        if((i-A+i-B+i-C) % 2 == 0){cout << (i-A+i-B+i-C)/2;return 0;}
    }
}




Measured memory_bytes: 256
import collections
from collections import deque
n,m = map(int,input().split())
ko = deque([])
for i in range(n):
  a= deque(map(int,input().split()))
  ko.append(a)
dai = float("inf")
for j in range(m):
  san = []
  for i in range(n):
    san.append(ko[i][0])
  c = collections.Counter(san)
  to = c.most_common()[0]
  dai = min(to[1],dai)
  ira = to[0]
  for i in range(n):
    ko[i].remove(ira)
print(dai)

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

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

    vector<vector<int>> dp (n+1, vector<int>(3));
    rep(k,3) dp[0][k] = 0;
    rep(i,n){
        
        dp[i+1][0] = max(dp[i][1] + a[i+1], dp[i][2] + a[i+1]);
        dp[i+1][1] = max(dp[i][0] + b[i+1], dp[i][2] + b[i+1]);
        dp[i+1][2] = max(dp[i][0] + c[i+1], dp[i][1] + c[i+1]);
    }
    
    cout << max(max(dp[n][0],dp[n][1]), max(dp[n][1], dp[n][2])) << endl;
    return 0;
}

Measured memory_bytes: 6912
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int n,h,m,s,time,ans,cnt;
  char q;
  vector<pair<int,int> > ti;
  while(1){
    cin>>n;
    ans=0,cnt=0;
    if(n==0) break;
    for(int i=0;i<n;i++){
      cin>>h>>q>>m>>q>>s;
      time=h*3600+m*60+s;
      ti.push_back(make_pair(time,1));
      cin>>h>>q>>m>>q>>s;
      time=h*3600+m*60+s;
      ti.push_back(make_pair(time,-1));
    }
    sort(ti.begin(),ti.end());
    for(int i=0;i<ti.size();i++)cnt+=ti[i].second,ans=max(cnt,ans);
    cout<<ans<<endl;
    ti.clear();
  }
  return 0;
}

Measured memory_bytes: 1528
#include <stdio.h>

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

    int h[n];
    for (int i = 0; i < n; i++) {
        scanf("%d", &h[i]);
    }

    int count = 0;
    int max = 0;

    for (int i = 0; i < n - 1; i++) {
        if (h[i] >= h[i + 1]) {
            count++;
        } else {
            max = (max < count) ? count : max;
            count = 0;
        }
    }
    max = (max < count) ? count : max;

    printf("%d\n", max);
    return 0;
}


Measured memory_bytes: 512
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val a = sc.nextInt()
  val b = sc.nextInt()
  val s = sc.next()

  var ans = true
  if (s.length != a + b + 1) ans = false

  for (i in 0 until a) {
    if ('0' <= s.get(i) && s.get(i) <= '9') {
    } else {
      ans = false 
    }
  }
  if (s.get(a) != '-') ans = false
  for (i in a + 1 until a + b + 1) {
    if ('0' <= s.get(i) && s.get(i) <= '9') {
    } else {
      ans = false
    }
  }

  var str = "No"
  if (ans) str = "Yes"

  println(str)
}


Measured memory_bytes: 31400