akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int N = sc.nextInt();
			int K = sc.nextInt();
			int[] score = new int[N];
			for(int i=0;i<N;i++) {
				score[i] = sc.nextInt();
			}
			
			for(int i=K;i<N;i++) {
				if(score[i-K] < score[i]) {
					System.out.println("Yes");
				}else {
					System.out.println("No");
				}
			}
		}	
	}
}


Measured memory_bytes: 59808
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat64() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func contain(i int, as []int) bool {
	for _, a := range as {
		if a == i {
			return true
		}
	}
	return false
}

type UnionFind struct {
	Par map[int]int
}

func NewUnionFind(n int) *UnionFind {
	par := make(map[int]int)
	for i := 0; i < n; i++ {
		par[i] = -1
	}
	return &UnionFind{
		Par: par,
	}
}

func (u *UnionFind) Root(x int) int {
	c := u.Par[x]
	if c < 0 {
		return x
	}
	u.Par[x] = u.Root(u.Par[x])
	return u.Par[x]
}

func (u *UnionFind) Unite(x, y int) bool {
	x = u.Root(x) //xの根をrx
	y = u.Root(y) //yの根をry
	if x == y {
		return false
	} //xとyの根が同じ(=同じ木にある)時はそのまま
	if u.Par[x] > u.Par[y] {
		tmp := x
		x = y
		y = tmp
	}
	u.Par[x] += u.Par[y]
	u.Par[y] = x
	return true
}

func (u *UnionFind) Same(x, y int) bool { // 2つのデータx, yが属する木が同じならtrueを返す
	rx := u.Root(x)
	ry := u.Root(y)
	return rx == ry
}

func (u *UnionFind) Size(x int) int {
	n := u.Root(x)
	return -u.Par[n]
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(nil, 100000000)

	n, m := nextInt(), nextInt()

	uf := NewUnionFind(n)

	for i := 0; i < m; i++ {
		k, v := nextInt()-1, nextInt()-1
		uf.Unite(k, v)
	}

	ans := 0
	for i := 0; i < n; i++ {
		ans = max(ans, uf.Size(i))
	}
	fmt.Println(ans)
}


Measured memory_bytes: 13428
#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,l=0,j;
    cin>>n;
    int a[n];
    REP(i,0,n-1) cin>>a[i];
    vi last(20,-1);
    ll ans=0;
    REP(i,0,n-1){
    	REP(j,0,19){
    		if(a[i]>>j&1) l=max(l,last[j]+1),last[j]=i;
    	}
    	ans+=i-l+1;
    	dbg(l,ans,i);
    }
    cout<<ans;
   	return 0;   
} 

Measured memory_bytes: 4436
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }
 
int main(){
    int A, B;
    cin >> A >> B;
    if(A >= 10 || B >= 10){
        cout << -1 << endl;
        return 0;
    }
    cout << A * B << endl;
}


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

int main() {
    string S,T;
    int cnt = 0;
    cin>>S>>T;
    for(int i=0; i<S.length(); i++) {
        if(S[i] != T[i]) {
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3916
/// Code by Leonardo16
///   “It is not the strength of the body, but the strength of the spirit.”   —  J.R.R. Tolkien
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
//#pragma GCC option("arch=native","tune=native","no-zero-upper")
//#pragma GCC target("avx2")

#define int long long
#define ll long long
#define sz size
#define ull unsigned long long
#define ld long double
#define ii pair<int,int>
#define fst first
#define scd second
#define vi vector<int>
#define vii vector<ii>
#define vs vector<string>
#define pb push_back
#define pf push_front
#define fl '\n'
#define el endl
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
/// Functions
#define db(x) cerr << #x << ": " << (x) << '\n';
#define random() __builtin_ia32_rdtsc()
#define lg2(x) 31-__builtin_clz(x)
#define lg2ll(x) 63-__builtin_clzll(x)
#define pi acos(-1)
#define YN(x) cout<<((x)?("YES"):("NO"))<<fl;
#define yn(x) cout<<((x)?("Yes"):("No"))<<fl;
#define des(x,s1,s2,end1,end2) cout<<((x)?(s1):(s2))<<fl;if(x){end1;}else{end2;}
#define precision(x) cout.setf(ios::fixed);cout.precision(x);
/// Red-Black Tree Template
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
//#define less_than(n) order_of_key(n)
//#define en_pos(n) find_by_order(n)
/// Prime numbers  173,179,311,331,737,1009,2011,2027,3079,4001,100003
///=====================================================================
int n,m,k;
string arr[10];

main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n>>m>>k;
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }

    int ans=0;

    for(int m1=0;m1<(1<<n);m1++){
        for(int m2=0;m2<(1<<m);m2++){

            string na[n];
            for(int i=0;i<n;i++){
                na[i]=arr[i];
            }
            int cnt=0;

            for(int i=0;i<n;i++){
                for(int j=0;j<m;j++){
                    if( (m1&(1<<i)) || (m2&(1<<j)) ){
                        na[i][j]='_';
                    }
                }
            }
            for(int i=0;i<n;i++){
                for(int j=0;j<m;j++){
                    if(na[i][j]=='#')cnt++;
                }
            }

            if(cnt==k){
                ans++;
            }


        }
    }

    cout<<ans;
return 0;}




Measured memory_bytes: 3628
///RAIYAN_MAHIN
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m; cin >> n >> m; 
    vector<int >rm;
    for(int i = 1; i <= m; i++)
    {
        int x; cin >> x;
        rm.push_back(x);
    }
    int s  = accumulate(rm.begin(),rm.end(),0);
    if(s >= n) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    
    
}


Measured memory_bytes: 892
#include <stdio.h>

int main(void){
    char S[100000];
    scanf("%s",S);
    int chn=0;
    int i;
    for (i=0; S[i]!='\0'; i++) {
        if(i%2==0){
            if(S[i]=='1'){
                chn++;
            }
        }
        else{
            if (S[i]=='0') {
                chn++;
            }
        }
    }
    if((i-chn)>chn){
        printf("%d\n",chn);
    }
    else{
        printf("%d\n",i-chn);
    }
    return 0;
}


Measured memory_bytes: 256
N = input()
l = len(N)

if l == 1:
    s = int(N[0])
    if s == 2 or s == 4 or s == 5 or s == 7 or s == 9:
        print("hon")
    elif s == 0 or s == 1 or s == 6 or s == 8:
        print("pon")
    elif s == 3:
        print("bon")
elif l == 2:
    s = int(N[1])
    if s == 2 or s == 4 or s == 5 or s == 7 or s == 9:
        print("hon")
    elif s == 0 or s == 1 or s == 6 or s == 8:
        print("pon")
    elif s == 3:
        print("bon")
elif l == 3:
    s = int(N[2])
    if s == 2 or s == 4 or s == 5 or s == 7 or s == 9:
        print("hon")
    elif s == 0 or s == 1 or s == 6 or s == 8:
        print("pon")
    elif s == 3:
        print("bon")

Measured memory_bytes: 62016
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int H, N;
  cin >> H >> N;
  ll div = 0;
  REP(i, N) {
    ll a;
    cin >> a;
    div += a;
  }
  if (H <= div) {
    puts("Yes");
  } else {
    puts("No");
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
        

fast();
//ll t;cin>>t;while(t--)
{
    ll n,weight;
    cin>>n>>weight;
    ll w[n],v[n];
    for(int i=0;i<n;i++)
    {
        cin>>w[i]>>v[i];
    }
    ll dp[n+1][weight+1];
    for(int i=0;i<=n;i++)
    {
        dp[i][0]=0;
    }
    for(int i=0;i<=weight;i++)
    {
        dp[0][i]=0;
    }
    for(int i=1;i<=n;i++) 
    {
        for(int j=1;j<=weight;j++)
        {
            if(w[i-1]<=j)
            {
                 dp[i][j]=max(v[i-1]+dp[i-1][j-w[i-1]],dp[i-1][j]);
            }
            else
            {
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    cout<<dp[n][weight]<<endl;
}
return 0;
}

Measured memory_bytes: 82492
#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(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



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


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

ll calc(ll x){
		if(x <= 0) return 0;
		ll res = 0;
		rep(i,40){
			ll hoge = (1LL << (i+1));
			ll foo = x / hoge;
			ll bar = x % hoge;
			ll cnt = foo * hoge / 2;
			cnt += max(bar - hoge / 2 + 1, 0LL);
			if(cnt%2 == 1) res |= (1LL << i);
		}
		return res;
	}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;
    ll ans = calc(b) ^ calc(a-1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
#from fractions import gcd
from math import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)
inf = float("inf")

def input():
    return sys.stdin.readline()[:-1]

def main():
    a, b, c, d = map(int, input().split())
    while True:
        c -= b
        if c <= 0:
            print("Yes")
            break
        a -= d
        if a <= 0:
            print("No")
            break

if __name__ == '__main__':
    main()



Measured memory_bytes: 9372
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int h,n;
	cin>>h>>n;
	long long int sum=0;
	for(int i=0;i<n;i++)
	{ 
	  int a;
		cin>>a;
		sum+=a;
	}
	sum>=h?cout<<"Yes\n":cout<<"No\n";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
   long a,b,c,d,ans;

   scanf("%ld %ld %ld %ld",&a,&b,&c,&d);
   ans=a*c;
   if (ans<a*d) ans=a*d;
   if (ans<b*c) ans=b*c;
   if (ans<b*d) ans=b*d;
   printf("%ld\n",ans);
   return 0;
}


Measured memory_bytes: 1736
#include <iostream>
#include <string>
#include <algorithm>

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

	int A, B, r;
	std::cin >> A >> B;

	r = A < B ? B-- : A--;
	r += A < B ? B-- : A--;

	std::cout << r;
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    private static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }
        Arrays.sort(a);
        long g = a[0];
        for (int i = 1; i < n; i++) {
            g = gcd(g, a[i]);
        }
        if (k <= a[a.length - 1] && k % g == 0) {
            System.out.println("POSSIBLE");
        } else {
            System.out.println("IMPOSSIBLE");
        }
    }

}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  if ( A-B < C ) {
  cout << C - (A - B) << endl;
  }
  
  if ( A-B >= C) {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,m;
  cin>>n>>m;
  int t[m],s[n];
  for(int i=0;i<m;i++) cin>>t[i];
  memset(s,0,sizeof(s));
  for(int i=0;i<m;i++){
    int tmp=0;
    for(int j=0,k;j<n;j++){
      cin>>k;
      if(t[i]==k) s[j]++,tmp++;
    }
    s[t[i]-1]+=n-tmp;
  }
  for(int j=0;j<n;j++) cout<<s[j]<<endl;
  return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
typedef long long ll;
typedef pair<int,int> pii;

int main(){
    int x, a; cin>>x>>a;
    if(x<a)cout<<0<<endl;
    else cout<<10<<endl;
    return 0;
}


Measured memory_bytes: 3560
#include<stdio.h>
int main(void)
{
	int N,i,j,k,count=0;
	scanf("%d",&N);
	int L[N];
	for(i=0;i<N;i++){
		scanf("%d",&L[i]);
	}
	for(i=0;i<N-2;i++){
		for(j=i;j<N-1;j++){
			for(k=j;k<N;k++){
				if(L[i]==L[j] || L[j]==L[k] || L[k]==L[i])
					continue;
				else if(L[i]<L[j]+L[k] && L[j]<L[i]+L[k] && L[k]<L[i]+L[j])
				count++;
			}
		}
	}
	printf("%d",count);
	return 0;	
		
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int N;
    cin >> N;
    int P[N];
    REP(i,N) cin >> P[i];
    int mi = N+1;
    int ans = 0;
    REP(i,N){
        if(P[i] <= mi){
            ans++;
            mi = P[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4408
n, m = map(int, input().split())
a = [int(x) for x in input().split()]

aa = [0]*(10**5+1)
aa_sum = [0]*(10**5+1)

for x in a:
    aa[x] += 1
    aa_sum[x] += x

for i in range(10**5)[::-1]:
    aa[i] = aa[i] + aa[i+1]
    aa_sum[i] = aa_sum[i] + aa_sum[i+1]


def count(x):
    cnt = 0
    sm = 0
    for i in range(n):
        if x-a[i] < 0:
            cnt += n
            sm += aa_sum[0]+n*a[i]
        elif x-a[i] > 10**5:
            continue
        else:
            cnt += aa[x-a[i]]
            sm += aa_sum[x-a[i]]+aa[x-a[i]]*a[i]

    return cnt, sm


bottom = 0
top = 10**6

while top - bottom > 1:
    mid = (top+bottom) // 2
    cnt, sm = count(mid)
    if cnt < m:
        top = mid
    else:
        bottom = mid

cnt, sm = count(bottom)
ans = sm - (cnt-m)*bottom

print(ans)


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

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto P = RD;
	auto A = RDR.ARR;

	long o, e;
	foreach (i; 0..N)
	{
		if (A[i] % 2 == 0)
			++e;
		else
			++o;
	}

	long ans = (2^^e);
	if (!(P == 0 && o == 0))
		ans *= ((2^^o)/2);

	writeln(ans);
	stdout.flush();
	debug readln();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-8;
typedef long long ll;
#define equ(a,b) ((fabs((a)-(b)))<(eps))
#define more(a,b) (((a)-(b))>(eps))
#define less(a,b) (((a)-(b))<(-eps))
#define inf 0x3f3f3f3f

int main(){
    int a,b;
    cin>>a>>b;
    cout<<a*b;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

int a[86401];

int toSeconds(int h, int m, int s){
    return h*3600 + m*60 + s;
}

int main(){
    int N;
    while(std::cin >> N, N){
        std::fill(a, a+86401, 0);
        REP(i, N){
            int h1, m1, s1, h2, m2, s2;
            scanf("%2d%*c%2d%*c%2d %2d%*c%2d%*c%2d", &h1, &m1, &s1, &h2, &m2, &s2);

            int t1 = toSeconds(h1, m1, s1),
                t2 = toSeconds(h2, m2, s2);

            a[t1]++;
            a[t2]--;
        }

        int res = a[0];
        FOR(i, 1, 86401){
            a[i] += a[i-1];
            res = std::max(res, a[i]);
        }

        std::cout << res << std::endl;
    }
}

Measured memory_bytes: 1580
// これWA出してしまったのはさすがに無能 問題把握しろ
// わからなかったので手動だけど通るんだろうか 通ったら草なんだが
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define ll long long
using namespace std;

int main() {
  int a[39] = {1, 4, 8, 9, 16, 25, 27, 32, 49, 64, 81, 100, 121, 125, 128, 144, 169, 225, 243, 256, 289, 324, 343, 361, 400, 441, 484, 512, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1000, 1001};
  int x;
  cin >> x;
  rep(i,39) {
    if (a[i] > x) {
      cout << a[i - 1] << endl;
      break;
    }
  }
}

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

int main(){
    int N, M, C;

    cin >> N >> M >> C;

    int bs[20];
    int as[20][20];

    int sum = 0;
    int counter = 0;

    for(int i=0; i<M; i++){
        cin >> bs[i];
    }

    for(int i=0; i<N; i++){
        for(int j=0; j<M; j++){
            cin >> as[i][j];
        }
    }

    for(int i=0; i<N; i++){
        sum = 0;
        for(int j=0; j<M; j++){
            sum += bs[j] * as[i][j];
        }
        sum += C;
        if(sum > 0) counter++;
    }
    
    cout << counter << endl;

    return 0;
}


Measured memory_bytes: 256
import itertools
n = input()
dp = [[[[[0] * 2 for i in range(2)] for j in range(2)] for k in range(2)]for l in range(len(n))]
#dp[i桁目][nより小さいかどうか][3がある][5がある][7がある]

for i in range(len(n)):
    dp[i][0][0][0][0] = 1

for j in range(10):
    if int(n[0]) >= j and j in [3, 5, 7]:
        dp[0][int(n[0]) == j][j == 3][j == 5][j == 7] = 1

for i, j, k, l, m in itertools.product(range(len(n)-1), range(2), range(2), range(2), range(10)):
    if m in [3, 5, 7]:
        dp[i + 1][0][j or m == 3][k or m == 5][l or m == 7] += dp[i][0][j][k][l]
        if m <= int(n[i+1]):
            dp[i + 1][m == int(n[i+1])][j or m == 3][k or m == 5][l or m == 7] += dp[i][1][j][k][l]

print(dp[-1][0][1][1][1] + dp[-1][1][1][1][1])

Measured memory_bytes: 3188
N = int(input())

lst = [0] * 10001

for x in range(1, 101):
  for y in range(1, 101):
    for z in range(1, 101):
      i  = x*x + y*y + z*z + x*y + y*z + z*x
      if i < 10001:
      	lst[i] += 1
      
for k in range(N):
  print(lst[k+1])

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

#define int long long 

bool calc(int a);

string s;

signed main()
{
    cin >> s;
    for (int i = 2001; i >= 1; i--) {
        if (calc(i)) {
            cout << "(x-" << i << ")";
        }
    }
    for (int i = -1; i >= -2000; i--) {
        if (calc(i)) {
            cout << "(x+" << -i << ")";
        }
    }
    cout << endl;
    return 0;
}

bool calc(int a)
{
    //cout << a << endl;;
    int ptr = 0, sum = 0, num = 1;
    while (s.size() > ptr) {
        //cout << s[ptr] << endl;
        if (s[ptr] == 'x') {
            if (ptr+1 < s.size() && s[ptr+1] == '^') {
                sum += num * (int)pow(a, s[ptr+2] - '0');
                ptr += 3;
            } else {
                sum += num * a;
                ptr++;
            }
        } else if (s[ptr] == '+') {
            num = 1;
            ptr++;
        } else if (s[ptr] == '-') {
            num = -1;
            ptr++;
        } else if ('0' <= s[ptr] && s[ptr] <= '9') {
            int minus = (num < 0) ? -1 : 1;
            num = s[ptr++] - '0';
            while (ptr < s.size() && '0' <= s[ptr] && s[ptr] <= '9') {
                num *= 10;
                num += s[ptr++] - '0';
            }
            num *= minus;
        } else {
            //cout << "error " <<  ptr << endl;
            //return false;
        }
        //cout << num << " " << sum << endl;
    }
    //cout << sum << endl;
    sum += num;
    //cout << sum << endl;
    if (sum) return false; 
    else return true;
}

Measured memory_bytes: 3364
#include<stdio.h>
#define MAX 100000
#define LIM 1000000000

int solve(int A[], int n, int k, int p) {
  int i = 0, c = 0, cp = p;
  while (i < n && c < k) {
    if ( A[i] > p ) return 0;
    else if ( A[i] <= cp ) cp -= A[i++];
    else {
      cp = p;
      c++;
      cp -= A[i++];
    }
  }
  if ( i == n && c < k) return 1;
  else return 0;
}

int binarySearch(int A[], int n, int k, int left, int right) {
  int mid = (left + right) / 2;
  if (mid == right) return mid;
  if (solve(A, n, k, mid)) return binarySearch(A, n, k, left, mid);
  else return binarySearch(A, n, k, mid + 1, right);
}

int main() {
  int n, k, A[MAX];

  scanf("%d %d", &n, &k);
  for ( int i = 0; i < n; i++ ) scanf("%d", &A[i]);
  int ans = binarySearch(A, n, k, 0, LIM);

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


Measured memory_bytes: 3152
using System;
using System.Linq;
using System.Collections.Generic;

class MainClass {
  public static void Main (string[] args) {
    var list = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    var N = list[0];
    var A = list[1];
    var B = list[2];
    var orbit = N / (A + B);
    
    if(N % (A + B) < A){
      Console.WriteLine(orbit * A + N % (A + B));
    }else if(N % (A + B) >= A){
      Console.WriteLine(orbit * A + A);
    }

  }
}

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

int main() {
    int n;
    while(cin >> n, n) {
        vector<int> a(n), b(n);
        for(auto& i: a) cin >> i;
        for(auto& i: b) cin >> i;
        sort(a.begin(), a.end());
        sort(b.begin(), b.end());

        int answer = -1;
        for(int i = 1; i < n; ++i) {
            int lowest = a[n - i];
            auto it = upper_bound(b.end() - i, b.end(), lowest - 1);
            int d = it - b.begin() - (n - i);
            if(it - (b.end() - i) > i / 2) {
                answer = i;
                break;
            }
        }
        if(answer == -1) cout << "NA" << endl;
        else cout << answer << endl;
    }
}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

const int MAX_N = 100005;
ll fact[MAX_N];
ll factinv[MAX_N];
long long mod_pow(long long x, long long n, long long mod){
	long long res = 1;
	while(n > 0){
		if(n & 1) res = res * x % mod;
		x = x*x % mod;
		n >>= 1;
	}
	return res;
}

//階乗のリストを作る
void make_fact_tbl(long long n, long long mod){
	fact[0] = 1;
	for(long long i=1; i<=n; i++){
		fact[i] = fact[i-1] * i;
		fact[i] %= mod;
	}
}

//階乗の逆元のリストを作る
void make_factinv_tbl(long long n, long long mod){
	factinv[0] = 1; //0の逆元は存在しない
	for(long long i=1; i<=n; i++){
		factinv[i] = mod_pow(fact[i], mod-2, mod);
	}
}

//組み合わせの計算に必要な情報の作成
void comb_init(long long n, long long mod){
	make_fact_tbl(n, mod);
	make_factinv_tbl(n, mod);
}

//組み合わせの計算
long long comb(long long n, long long k, long long mod){
	if(n < k) return 0;
	if(k == 0 || n-k == 0) return 1;
	//printf("n:%lld k:%lld n-k:%lld\n", fact[n], factinv[k], factinv[n-k]);
	return ((fact[n] * factinv[k]) % mod) * factinv[n-k] % mod;
}

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	int n;
	cin >> n;
	comb_init(n+1, MOD);

	map<int, int> a;
	ll l = -1;
	ll r = -1;
	for(int i=0; i<n+1; i++){
		int t;
		cin >> t;
		if(a.find(t) == a.end()){
			a[t] = i;
		}else{
			l = a[t];
			r = i;
		}
	}

	for(int k=1; k<=n+1; k++){
		ll ans = comb(n+1, k, MOD);
		ans = (ans + MOD - comb(l+n-r, k-1, MOD)) % MOD;
		cout << ans << endl;
	}

	
	return 0;
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int
 
#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>
 
#define str string
 
#define pb(a) push_back(a)
#define mp make_pair

int main(){
  SCIN(a,b,c);
  cout<<a[0]<<b[1]<<c[2]<<endl;




  return 0;
}


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

int main() {
  int N, T;
  cin >> N >> T;
  vector<int> c(N), t(N);
  for (int i = 0; i < N; i++) {
    cin >> c.at(i) >> t.at(i);
  }
  int mc = 1100;
  for (int i = 0; i < N; i++) {
    if (t.at(i) <= T) {
      mc = min(mc, c.at(i));
    }
  }
  if (mc == 1100) {
    cout << "TLE" << endl;
  }
  else {
    cout << mc << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string.h>
#include <deque>
#define REP(i,j,n) for(int i=j;i<n;i++)
#define SORT(x) sort(x.begin(),x.end())

using namespace std;

bool isPrime(int x) {
	if (x < 2) return false;
	if (x == 2 || x == 3) return true;
	if (x % 2 == 0) return false;

	for (int j = 3; j*j <= x; j += 2) {
		if (x%j == 0)return false;
	}
	return true;

}

int main() {
	int n, m, count = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> m;
		if (isPrime(m)) count++;
	}

	cout << count << endl;
	return 0;
}

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int a, b, c, d, n, x, y;
    string s, t;


    auto Yes = [&](bool t){
        cout << (t ? "Yes" : "No") << endl;
    };
    auto YES = [&](bool t){
        cout << (t ? "YES" : "NO") << endl;
    };
    auto tri = [&](bool t, string a, string b){
        cout << (t ? a : b) << endl;
    };

    vector<int> v(3);
    for(auto& x : v)
        cin >> x;
    sort(v.begin(), v.end());
    cout << v[2] * 10 + v[1] + v[0] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define li long long int

using namespace std;

void FAST()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}

li n,w;
vector<li> aw;
vector<li> av;

li calc()
{
	li i,j;
	li dp[n+1][w+1];
	for(i=0;i<=n;i++)	dp[i][0]=0;
	for(i=0;i<=w;i++)	dp[0][i]=0;
	
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=w;j++)
		{
			if(aw[i-1]<=j)
				dp[i][j]=max(dp[i-1][j],(dp[i-1][j-aw[i-1]]+av[i-1]));
			else
				dp[i][j]=dp[i-1][j];
		}
	}
	return(dp[n][w]);
}

int main()
{
    FAST();
    li nn,i,ww;
    cin>>nn>>ww;	n=nn;w=ww;
    aw = vector< li > (n);
    av = vector< li > (n);
    
    for(i=0;i<n;i++)
    	cin>>aw[i]>>av[i];
    cout<<calc();
    
}

Measured memory_bytes: 82420
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int N=gi();
	    int A=gi();
	    int B=gi();
	    long[] V=new long[N];

        for (int i=0; i< N;i++) {
        	V[i]=gl();
        }
        Arrays.sort(V);

        double avg=0;
        for(int i=N-1; i>=N-A; i--) {
        	avg+=V[i];
        }
        avg=avg/(double)A;

        long ans=0;
        long m=V[N-A];
        int p=0;
        int q=0;
        for(int i=0; i<N;i++) {
        	if(V[i]==m) {
        		p++;
        		if(i>=N-A)q++;
        	}
        }

        if(avg==m) {
            for (int i=q; i<=Math.min(p, B); i++) {
            	ans+=combi(p, i);
            }
        } else {
        	ans=combi(p, q);
        }

        System.out.println(avg);
        System.out.println(ans);
	}

	// ｎ個の中からm個選ぶ組み合わせの数
		public static long combi(int n, int m) {
			int ind=Math.max(n, m)+1;
			long[][] C=new long[ind][ind];
			for(int i=0; i<ind;i++) {
				C[i][0]=1;
			}

			for (int i=2; i<=n+m;i++) {
				for (int j=1; j<i;j++) {
					if(j<ind && i-j<ind) {
				        C[j][i-j]=C[j-1][i-j-1]+C[j-1][i-j];
					}
				}
			}
			return C[n][m];
		}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

int SCF(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}
int main(){
    int N, X[210000], XX[210000];
    int cnt, cntl, cntr;

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

    qsort(X, N, sizeof(int), SCF);
    cntl = X[N/2-1];
    cntr = X[N/2];

    for(int i=0; i<N; i++){
        if(XX[i]<=cntl){
            printf("%d\n", cntr);
        }else{
            printf("%d\n", cntl);
        }
    }

    return 0;
}

Measured memory_bytes: 3704
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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 int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;



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

    int n;
    cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    int ans=0;
    for(int i=0;i<n;i++){//始点
        int j=i;
        while(i+1<n&&v[i]>=v[i+1]){
            i++;
        }
        // cout<<i<<" "<<j<<endl;
        ans=max(ans,i-j);
    }
    fin(ans);

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Main cubic = new Main();
		cubic.start();
		
	}

	private void start() {
		Scanner scanner =new Scanner(System.in); 
		int x =scanner.nextInt();
		System.out.println(x * x * x);
		
		
	}

}

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


int dfs(int h){

  if (h == 0){
    
    return 0;
  }
 
  
  return h + dfs(h - 1);
}

int main() {
    int a;
 
   cin >> a;
  
   int b = dfs(a);
  
   cout << b << endl;
  
  
  return 0;
}

Measured memory_bytes: 256
# F - Bracket Sequencing

from itertools import chain

n = int(input())
ss = [input() for i in range(n)]

def parse(s):
    "バランスしていない閉じ括弧数, 開き括弧数"
    cl, op = 0, 0
    for c in s:
        if c == '(':
            op += 1
        elif op > 0:
            op -= 1
        else:
            cl += 1
    return (cl, op)

open  = []  # 開き括弧のみ
close = []  # 閉じ括弧のみ
inc   = []  # 開き括弧が多い
dec   = []  # 閉じ括弧が多い
for s in ss:
    cl, op = parse(s)
    if cl == 0:
        open.append((cl, op))
    elif cl < op:
        inc.append((cl, op))
    elif op == 0:
        close.append((cl, op))
    else:
        dec.append((cl, op))
peak = 0
inc.sort()
dec.sort(reverse=True)
for cl, op in chain(open, inc, dec, close):
    if peak < cl:
        print('No')
        exit()
    peak += op - cl
print('Yes' if peak == 0 else 'No')


Measured memory_bytes: 87988
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<String>().to_uppercase().as_bytes().iter().map(|c|*c as char).collect::<Vec<char>>()[0];
    let b=read::<String>().to_uppercase().as_bytes().iter().map(|c|*c as char).collect::<Vec<char>>()[0];
    let c=read::<String>().to_uppercase().as_bytes().iter().map(|c|*c as char).collect::<Vec<char>>()[0];
    println!("{}{}{}",a,b,c);
}

Measured memory_bytes: 4352
#include <cstdint>
#include <iostream>

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;

} // namespace null_null

#include <string>

namespace null_null {

void main_() {
  std::string S,T;
  std::cin>>S>>T;

  i32 ans=0;
  for(usize i=0;i<3;i++){
    if(S[i]==T[i]){
      ans++;
    }
  }

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

} // namespace null_null

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  null_null::main_();
  return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
    vector<int> t(2);
    vector<ll> tak(2);
    vector<ll> aok(2);
    cin >> t[0] >> t[1] >> tak[0] >> tak[1] >> aok[0] >> aok[1];

    ll fir = (tak[0] - aok[0]) * t[0];
    ll sec = (tak[1] - aok[1]) * t[1];
    if (fir + sec == 0)cout << "infinity" << endl;
    else if ((fir >= 0 && fir + sec <= 0) || (fir <= 0 && fir + sec >= 0)) {
        ll x = abs(fir) / abs(fir + sec);
        ll ret = x * 2;
        if (abs(fir) % abs(fir + sec) != 0)ret++;
        cout << ret << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

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


ll n, q;
vector<vector<ll>> g;
vector<ll> counter;

void dfs(ll from, ll now, ll cnt) {
	cnt += counter[now];
	counter[now] = cnt;
	for (ll next : g[now]) {
		if (next != from)dfs(now, next, cnt);
	}
}

int main() {
	cin >> n >> q;
	g.resize(n);
	counter.resize(n, 0);
	for (ll i = 0; i < n - 1; ++i) {
		ll a, b;
		cin >> a >> b;
		--a; --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for (ll i = 0; i < q; ++i) {
		ll p, x;
		cin >> p >> x;
		--p;
		counter[p] += x;
	}
	dfs(-1, 0, 0);
	for (ll ans : counter)cout << ans << " ";
	cout << endl;
}


Measured memory_bytes: 24320
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


int main(int argc, char const *argv[])
{
    std::vector<int> nums;
    int a,b,c;
    std::cin >> a >> b >> c;
    nums.push_back(a);
    nums.push_back(b);
    nums.push_back(c);
    
    std::vector<int>::iterator iter = std::min_element(nums.begin(), nums.end());
    int min = *iter;
    
    iter = std::max_element(nums.begin(), nums.end());
    int max = *iter;

    cout << max-min << endl;
    
    return 0;
}



Measured memory_bytes: 256
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

eat = [p[i] for i in range(X)] + [q[i] for i in range(Y)]
eat.sort()
for i in range(len(r)):
    if eat[i] < r[i]:
        eat[i] = r[i]
    else:
        break

print(sum(eat))


Measured memory_bytes: 109292
#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>;
//#########################################
const int INF = 1e18;
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};
signed main(){
	int h,w;cin >>h >> w;
	int sx,sy,gx,gy;cin >> sx >> sy >> gx >> gy;
	sx--;sy--;gx--;gy--;
	vector<string> f(h);
	rep(i,h)cin >> f[i];
	auto toID = [&](int x,int y){
		return x*w + y;
	};
	priority_queue<P,vector<P>,greater<P>> pq;
	vector<int> dist(h*w,INF);
	auto push = [&](int x,int y,int cost){
		if(x < 0 || y <0 || x > h-1 || y > w-1)return;
		if(dist[toID(x,y)] <= cost)return;
		if(f[x][y] == '#')return;
		pq.emplace(cost,toID(x,y));
		dist[toID(x,y)] = cost;
	};
	push(sx,sy,0);
	while(pq.size()){
		auto now = pq.top();pq.pop();
		// trace(now);
		//(dist,vertex)
		if(dist[now.second] != now.first)continue;
		int x = now.second/w,y = now.second%w;
		rep(i,4){
			int nx = x+ dx[i],ny = y + dy[i];
			push(nx,ny,now.first);
		}
		for(int nx = x - 2;nx <= x+2;nx++)for(int ny = y-2;ny <= y+2;ny++){
			if(nx < 0 || ny < 0 || nx > h-1 || ny > w-1)continue;
			// trace(x,y,nx,ny);
			// if(nx == x && ny == y)continue;
			push(nx,ny,now.first+1);
		}

	}
	int ret = dist[(toID(gx,gy))];
	if(ret == INF)ret = -1;
	cout << ret << endl;
	
	// rep(i,h){
	// 	rep(j,w){
	// 		cout << dist[toID(i,j)] << " ";
	// 	}
	// 	cout << endl;
	// }
	return 0;
}

Measured memory_bytes: 13144
N, X, Y = [int(x) for x in input().split()]

counter = [0] * N
for i in range(1, N + 1):
    for j in range(i + 1, N + 1):
        d = min(abs(i - j), abs(i - X) + abs(j - Y) + 1, abs(i - Y) + abs(j - X) + 1)
        counter[d] += 1

for i in range(1, N):
    print(counter[i])

Measured memory_bytes: 9228
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,X,ans=0,tall;
  cin>>N>>X;
  tall=X;
  for(int i=1;i<N;i++){
    cin>>X;
    if(X>=tall)
      ans++;
    tall=max(tall,X);
    }
  cout<<ans+1;
  }

Measured memory_bytes: 256