akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
template<typename T>
bool all_same(vector<T> v1,vector<T> v2)
{
    sort(ALL(v1));
    sort(ALL(v2),greater<T>());
    return v1 == v2;
}
   
// g++ -std=c++11 prac.cpp
ll Max=-1e9,Min=1e9+1;

int main(){
    ll a,b,d,x=0,y=0,z,n,m,k,lank=1,w,sum=0,sum2=0,ans=0;
    string s,t;
    bool ok=true;
    cin >> s;   
    a = s[0]-'0';
    n = s.size();
    rep(i,n){
        if(i!=0 && s[i]!='9'){
            break;
        }
        else if (i==s.size()-1){
            cout << a+9*(n-1) << endl;
            return 0;
        }
    }
    cout << (a-1)+9*(n-1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
#define rep(i,n) for(int i=0;i<(n);++i)
#define ll long long
using namespace std;
int main(){
int n,a,b;
cin>>n>>a>>b;
string s;
cin>>s;
int san=0,kaig=0;
rep(i,s.size()){
    if(s[i]=='a'&&san+1<=a+b){cout<<"Yes"<<endl;san++;continue;}
    if(s[i]=='b'&&kaig+1<=b&&san+1<=a+b){cout<<"Yes"<<endl;kaig++;san++;continue;}
     cout<<"No"<<endl;
}
return 0;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  ll B;
  cin>>B;
  
  cout<<power(B,3)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
main(){
    ll n,sum=0,ans=0;
    cin>>n;
    ll a[n],b[n],c[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=0;i<n;i++){
        c[i]=a[i]-b[i];
    }
    sort(c,c+n);
    for(int i=0;i<n;i++){
        if(c[i]<0){
            sum+=c[i];
            ans++;
        }
        else break;
    }
    for(int i=n-1;i>-1;i--){
       if(sum>=0)break;
        if(c[i]>0){
            sum+=c[i];
            ans++;
        }
    }

    //cout<<sum<<endl;

    if(sum<0)cout<<-1<<endl;
    else{cout<<ans<<endl;}
}

Measured memory_bytes: 2560
// Forbidden List.cpp
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>
using namespace std;
const int INF = 1 << 29;
int main ()
{
    int X,N;
    int p[102];

    cin >> X >> N;

    for (int i = 0; i < 102; i++) {
        p[i] = 0;
    }
    for (int i = 0; i < N; i++) {
        int index;
        cin >> index;
        p[index] = 1;
    }

    int ans = INF;
    for (int i = 0; i <= 101; i++) {
        if (p[X-i] == 0) {
            ans = X-i;
            break;
        }
        if (p[X+i] == 0) {
            ans = X+i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

constexpr ll mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    
    friend ostream &operator<<(ostream& os,const mint& a){
        return os << a.x;
    }

    friend istream &operator>>(istream& is,mint& a){
        ll t;
        is >> t;
        a = mint(t);
        return (is);
    }

    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

mint dp[70][2][2] = {};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll n = 0;
    for(int i=0;i<61;i++) if(N>>i&1) n = i;
    dp[0][0][0] = 1;
    for(int i=0;i<=n;i++){
        int b = (N>>(n-i))&1;
        for(int j=0;j<2;j++) for(int num=0;num<2;num++){
            int nj = (j || num<b);
            if(!nj && num>b) continue;
            if(!num){
                dp[i+1][nj][0] += dp[i][j][0];
                dp[i+1][nj][0] += dp[i][j][1];
                dp[i+1][nj][1] += dp[i][j][1];
            }else{
                dp[i+1][nj][0] += dp[i][j][0];
                dp[i+1][nj][1] += dp[i][j][0];
                dp[i+1][nj][1] += dp[i][j][1];
            }
        }
    }
    mint ans = 0;
    for(int j=0;j<2;j++) ans += dp[n+1][j][0];
    cout << ans << "\n";
}

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

int	main() {
	int	N;
  	cin >> N;
  
  	int NG;
 	NG = 0;
  	for (int i=0;i<N;i++) {
 		int	n;
      	cin >> n;
      	//cout << "debug n%3 " << n%3 << " n%5 " << n%5 << endl;
      	if (n%2!=0) continue;
      	else if (n%3==0 || n%5==0) continue;
      	else NG = 1;
    }
  	if (NG == 0) cout << "APPROVED" << endl;
  	else cout << "DENIED" << endl;
}


Measured memory_bytes: 256
/* ****AWARE**** */
#include<bits/stdc++.h>
#include <limits.h> 
#define cut ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll          long long
#define pb          push_back
#define endl        '\n'
#define pii         pair< ll, ll>
#define vi          vector< ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(  ll i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp13       make_pair
using namespace std; 
#define MAX  3000
#define MODULO 2
using namespace std;   
#define hell 1000000007 
#define hell1 30000000000000000
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
#define mysizeof(i) (char*)(&i+1)-(char *)(&i);
ll T;
//double dp[MAX][MAX];
vector<ll>v;
void solve()
{    ll i,j,n,a;
     cin>>n;
     for(i=0;i<n;i++)
     {
     	cin>>a;
     	v.pb(a);
     }
     ll dp[n][n];
      for(i=n;i>=0;i--)
      {
      	for(j=i;j<n;j++)
      	{
      		if(i==j)
      		{
      			dp[i][j]=v[i];
      			continue;
      		}
      		dp[i][j]=max(v[i]-dp[i+1][j],v[j]-dp[i][j-1]);
      	}
      }
   cout<<dp[0][n-1]<<"\n";
}
           
int main(){ 
cut; 
ll t; 
//cin>>t;
//T=t;
 t=1;
while(t--)
solve();
return 0;
}
     


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

using namespace std;

const int N = 1010;

int n, k;
int p[N];

int main()
{
	ios::sync_with_stdio(false);
	
	cin >> n >> k;
	for (int i = 0; i < n; ++i) cin >> p[i];
	
	sort(p, p + n);
	
	int ans = 0;
	for (int i = 0; i < k; ++i) ans += p[i];
	
	cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, R;
vector<int> r;
int V[201][201] = {};
void input() {
  int x, y, z;
  cin >> N >> M >> R;
  r.resize(R);
  rep(i, 0, R - 1) {
    cin >> x;
    r[i] = x - 1;
  }
  rep(i, 0, M - 1) {
    cin >> x >> y >> z;
    V[x - 1][y - 1] = z;
    V[y - 1][x - 1] = z;
  }
}
int ans = INF;
void dfs(int now, set<int> visited, int distance) {
  // debug(now), debug(distance);
  visited.insert(now);
  if (visited.size() == R) {
    ans = min(ans, distance);
    return;
  }
  // bool ex = false;
  for (auto x : r) {
    if ((visited.find(x) == visited.end())) {
      dfs(x, visited, distance + V[now][x]);
      //   ex = true;
    }
  }
  // if (ex = false) return;
}
void solve() {
  rep(i, 0, 200) {
    rep(j, 0, 200) {
      if (V[i][j] == 0) V[i][j] = INF;
    }
  }
  rep(i, 0, 200) { V[i][i] = 0; }
  rep(k, 0, 200) {
    rep(i, 0, 200) {
      rep(j, 0, 200) {
        if ((V[i][j] != 0) && (V[i][k] != 0) && (V[k][j] != 0))
          V[i][j] = min(V[i][j], V[i][k] + V[k][j]);
      }
    }
  }
  // 8!
  for (auto x : r) {
    dfs(x, set<int>(), 0);
  }
  cout << ans << endl;

  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 512
fun main(args: Array<String>){
    
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val xy = Array(m) {
        readLine()!!.split(" ").map { it.toInt() }
    }

    var box = Array(n) { 1 }
    var red = Array(n) { false }
    red[0] = true
    
    for ( (x,y) in xy ){
        
        box[x-1] -= 1
        box[y-1] += 1

        if ( red[x-1] == true ) { red[y-1] = true }
        if ( box[x-1] == 0 ) { red[x-1] = false }
    }

    var ans = 0
    for (r in red) { if ( r == true ) { ans++ } }
    println(ans)
}

Measured memory_bytes: 65104
package main

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

func main() {
	n, k := 0, 0
	fmt.Scanf("%d %d", &n, &k)
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	ins := strings.Split(sc.Text(), " ")

	var in []int
	for _, j := range ins {
		i, _ := strconv.Atoi(j)
		in = append(in, i)
	}

	sort.Slice(in, func(i, j int) bool { return in[i] < in[j] })
	an := 0
	//fmt.Println(in)
	for i := 0; i < k; i++ {
     // fmt.Println(in[i])
		an += in[i]
	}
	fmt.Println(an)

}

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

using namespace std;

//#define FILE_IO

bool cmp(int a, int b)
{
    return ( (a & 1) > (b & 1) );
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    int N, M;
    int v[100005];
    scanf("%d%d", &N, &M);
    for(int i = 1; i <= M; i++)
        scanf("%d", &v[i]);

    if(M == 1)
    {
        if(N == 1)
        {
            printf("1\n1\n1\n");
            return 0;
        }
        printf("%d\n", v[1]);
        printf("%d\n", 2);
        printf("%d %d\n", 1, N - 1);
        return 0;
    }

    for(int i = 1; i <= M; i++)
        if(v[i] % 2 == 1)
        {
            swap(v[i], v[1]);
            break;
        }
    for(int i = 2; i <= M; i++)
        if(v[i] % 2 == 1)
        {
            swap(v[i], v[M]);
            break;
        }
    for(int i = 2; i < M; i++)
        if(v[i] % 2 == 1)
        {
            printf("Impossible\n");
            return 0;
        }

    for(int i = 1; i <= M; i++)
        printf("%d ", v[i]);
    printf("\n");

    vector <int> r;
    r.push_back(v[1] - 1);
    for(int i = 2; i < M; i++)
        r.push_back(v[i]);
    r.push_back(v[M] + 1);
    for(int i = 0; i < (int)r.size(); i++)
        if(!r[i])
        {
            r.erase(r.begin() + i);
            i--;
        }

    printf("%d\n", (int)r.size());
    for(auto x: r)
        printf("%d ", x);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void)
{
        char x[2],y[2];

        scanf("%s%s",x,y);

        if (strcmp(x,y)==0)
                printf("=\n");
        else if (strcmp(x,y)>0)
                printf(">\n");
        else
                printf("<\n");

        return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL; 

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N;
    cin >> N;
    VI a(N);
    REP(i,N)
    {
        cin >> a[i];
    }
    int res = 0;
    REP(i,N)
    {
        res += a[i] - 1;
    }
    cout << res << endl;

}


Measured memory_bytes: 256
n = gets.to_i
w = []
n.times do
  w << gets.chomp
end

h = {}
w.each_with_index do |wi, i|
  if h.has_key?(wi)
    puts 'No'
    exit
  end
  if i > 0 && wi[0] != w[i - 1][-1]
    puts 'No'
    exit
  end
  h[wi] = 0
end

puts 'Yes'


Measured memory_bytes: 3836
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int N;
int main(){
	cin>>N;
	cout<<N*800-N/15*200<<endl;


	return 0;
}


Measured memory_bytes: 256
K,N = map(int,input().split())
A = list(map(int,input().split()))
B = []
for i in range(N-1):
  temp = A[i+1]-A[i]
  B.append(temp)
B.append(K-A[-1]+A[0])
B.sort()
#print(B)
ans = K-B[-1]
print(ans)


Measured memory_bytes: 32204
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define print(x) cout<<x<<endl;

int main() {
	int w, a, b;
	cin >> w >> a >> b;
	int aw = a + w;
	int bw = b + w;
	if (aw < b) {
		print(b - aw);
	}
	else if (bw < a) {
		print(a - bw);
	}
	else if (a < b < aw || a < bw < aw) {
		print(0);
	}
}

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

#undef int
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
#define int long long int
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int t = 1;
	//cin >> t;
	while (t--) {
		int n, m, x;
		cin >> n >> m >> x;
		int crr[n];
		int arr[n][m];
		for (int i = 0; i < n; i++) {
			cin >> crr[i];
			for (int j = 0; j < m; j++) {
				cin >> arr[i][j];
			}
		}
		int p = 1, cnt = 0;
		while (cnt < n) {
			p = p * 2;
			cnt++;
		}
		int ans = 9999999999999;
		for (int i = 0; i < p; i++) {
			int z = i, sum = 0;
			int brr[m];
			for (int j = 0; j < m; j++) brr[j] = 0;
			for (int j = 0; j < n; j++) {
				if (z % 2 == 0) {
					z = z / 2;
					continue;
				}
				sum += crr[j];
				for (int k = 0; k < m; k++)
					brr[k] += arr[j][k];
				z = z / 2;
			}
			int flag = 0;
			for (int k = 0; k < m; k++) {
				if (brr[k] < x)
					flag = 1;
			}
			if (flag == 0)
				ans = min(ans, sum);
		}
		if (ans == 9999999999999)
			cout << -1 << endl;
		else
			cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3652
# -*- coding: utf-8 -*-
# モジュールのインポート
import sys


def get_input() -> tuple:
    """
    標準入力を取得.

    Returns:\n
        tuple: 標準入力
    """
    # 標準入力を取得
    N, M = list(map(int, input().split()))
    cakes = []
    for n in range(N):
        cake_n = list(map(int, input().split()))
        cakes.append(cake_n)

    return N, M, cakes


def main(N: int, M: int, cakes: list) -> None:
    """
    メイン処理.

    Args:\n
        N (int): ケーキの種類(1 <= N <= 1000)
        M (int): 食べる数(0 <= M <= N)
        cakes (list): ケーキの要素(-10000000000 <= x_i, y_i, z_i <= 10000000000)
    """
    # 求解処理
    ans = -sys.maxsize
    element = 3
    for bit in range(1 << element):
        sign = [1 for i in range(element)]
        for i in range(element):
            if bit & (1 << i):
                sign[i] *= -1
        cakes = sorted(cakes, key=lambda x: sum(
            [sign[i] * x[i] for i in range(element)]), reverse=True)

        indicator = [0 for i in range(element)]
        for cake in cakes[:M]:
            for i in range(element):
                indicator[i] += cake[i]

        ans = max(ans, sum(map(abs, indicator)))

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    N, M, cakes = get_input()

    # メイン処理
    main(N, M, cakes)


Measured memory_bytes: 9328
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int R = sc.nextInt();
		int G = sc.nextInt();
		int B = sc.nextInt();
    int N = sc.nextInt();

    int ans = 0;
    
    for (int i=0; i<=N; i++){
      for (int j=0; j<=N; j++){
        int rest = N-(i*R + j*G);
        if ((rest%B == 0) && (rest >= 0)){
          ans++;
        }
      }
    }

		System.out.println(ans);
	}
}

Measured memory_bytes: 23764
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;

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

        while( ((line = br.readLine()) != null) && !(line.equals("0 0"))){
            String[] input = line.split(" " , 2);
            int a = Integer.valueOf(input[0]);
            int b = Integer.valueOf(input[1]);
            if(a > b)   System.out.println(b + " " + a);
            else        System.out.println(a + " " + b);
        }
    }
}

Measured memory_bytes: 27088
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

// rep(i, 100) { cout << i << endl; } => 0 1 2 ... 99
#define rep(i, n) for(int i = 0, i##_len = (n); i < (int)n; i++)

// std::sort(all(v));
#define all(x) (x).begin(), (x).end()

// long long int
using ll = long long;

// utility to cast return value of size function to int
#define SZ(x) ((int)(x).size())

// VS defines "_DEBUG" macro when debug configuration.
#if _DEBUG
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define dump(x)
#define debug(x)
#endif

// update max
template<class T>bool chmax(T & prov, const T & cur)
{
	if (cur > prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

// update min
template<class T>bool chmin(T & prov, const T & cur)
{
	if (cur < prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

int main()
{
	int N, L;
	cin >> N >> L;
	int sum = 0;
	int eat = 1000;
	int ans = 0;
	rep(i, N)
	{
		if (abs(eat) > abs(L + i))
		{
			eat = L + i;
		}
		sum += L + i;
	}
	ans = sum - eat;
	cout << ans << endl;
	return 0;
}


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

long long n;

int gen(long long x) {
	vector<bool> d(11, false);
	if (n >= x)
		d[10] = true;
	while (x > 0) {
		d[(long long)x % 10] = true;
		x /= 10;
	}
	if (d[3] && d[5] && d[7]&&d[10])
		return 1;
	else
		return 0;
}

int check(int x) {
	int ans = 0;
	ans += gen(x);
	if (x < n/10+1) {
		ans+=check((long long)x * 10 + 3);
		ans+=check((long long)x * 10 + 5);
		ans+=check((long long)x * 10 + 7);
	}
	return ans;
}
int main() {
	cin >> n;
	cout << check(0) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define N 10000000

int cnt;
void Merge( int[], int, int, int );
void MergeSort( int[], int, int );

int main( void ){
	int i, L;
	int a[N];
	
	cnt = 0;
	
	scanf("%d", &L );
	for( i = 0; i < L; i++ ){
		scanf("%d", &a[i] );
	}
	
	MergeSort( a, 0, L );
	
	for( i = 0; i < L; i++ ){
		printf("%d", a[i] );
		if( i < L-1 ){
			printf(" ");
		}
	}
	printf("\n");
	printf("%d\n", cnt );
	
	return 0;
}

void Merge( int a[], int left, int mid, int right ){
	int i, j, k;
	int n_1 = mid-left;
	int n_2 = right-mid;
	
	int L[n_1+1], R[n_2+1];
	
	for( i = 0; i < n_1; i++ ){
		L[i] = a[left+i];
	}
	for( i = 0; i < n_2; i++ ){
		R[i] = a[mid+i];
	}
	
	L[n_1] = (int)INFINITY;
	R[n_2] = (int)INFINITY;
	
	i = 0; j = 0;
	for( k = left; k < right; k++ ){
		cnt++;
		if( L[i] <= R[j] ){
			a[k] = L[i];
			i++;
		}
		else{
			a[k] = R[j];
			j++;
		}
	}
}

void MergeSort( int a[], int left, int right ){
	int mid;
	if( left+1 < right ){
		mid = (left+right)/2;
		MergeSort( a, left, mid );
		MergeSort( a, mid, right );
		Merge( a, left, mid, right );
	}
}


Measured memory_bytes: 5632
#include<iostream>
#include<deque>
#include<list>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stack>
#include<queue>
#include<iterator>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

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

	cout << (a - 1)*(b - 1) << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  int a;
  cin >> a;
  int b = a / 10; int c = a % 1000;
  if((b / 100 == b % 10) && (b % 10== (b%100)/10)) cout<<"Yes"<<endl;
  else if ((c / 100 == c % 10) && (c % 10== (c%100)/10)) cout<<"Yes"<<endl;
  else cout <<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << endl; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;

VV G;
V c;
Vll ans;

pair<int, map<int, int>> dfs(int u, int p=-1) {
  map<int, int> res;
  int sz = 1;
  for (auto v : G[u]) {
    if (v == p) continue;
    auto [sz_v, res_v] = dfs(v, u);
    ll x = sz_v - res_v[c[u]];
    ans[c[u]] -= x*(x+1)/2;
    if (res.size() < res_v.size()) swap(res, res_v);
    for (auto &[a, b] : res_v) res[a] += b;
    sz += sz_v;
  }
  res[c[u]] = sz;
  return {sz, move(res)};
}

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

  G.assign(n, V());
  c.assign(n, 0);
  ans.assign(n, n*(n+1)/2);

  rep(i, n) {
    cin >> c[i];
    --c[i];
  }
  rep(i, n-1) {
    int a, b; cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  auto [sz, res] = dfs(0);
  rep(i, n) {
    ll x = sz - res[i];
    ans[i] -= x*(x+1)/2;
  }

  cout << ans;
  return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++) {
        cin >> d.at(i);
    }

    int count, i = 0;
    sort(d.begin(), d.end());
    
    cout << d.at(N / 2) - d.at(N / 2 - 1) << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	string s, t;

	cin >> s >> t;

	int ans = 0;

	REP(i, 3) {
		if (s[i] == t[i])ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    ans = 0
    A = [list(reversed(a)) for a in A]

    s1 = set()
    s2 = set()

    def update(i):
        if not A[i-1]:
            return

        d = A[i-1][-1]
        n = (min(i, d), max(i, d))
        if n not in s1:
            s1.add(n)
        else:
            s2.add(n)
            s1.remove(n)

    for i in range(1, N+1):
        update(i)

    while s2:
        ans += 1
        for k in list(s2):
            a, b = k
            A[a-1].pop()
            A[b-1].pop()
            update(a)
            update(b)
            s2.remove(k)


    for a in A:
        if a:
            return -1
    return ans


def main():
    N = read_int()
    A = [read_int_n() for _ in range(N)]
    print(slv(N, A))

    # N = 1000
    # A = []

    # while True:
    #     for i in range(1, N+1):
    #         t = list(range(1, N+1))
    #         t.remove(i)
    #         random.shuffle(t)
    #         A.append(t)
    #     print(slv(N, A))


if __name__ == '__main__':
    main()


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=2019;

int main(){
    int N, K; cin >> N >> K;
    vector<ll> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    for(int i=K+1; i<=N; i++){
        if(A[i-1] > A[i-1-K]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

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

int main(){
    vector<int> a(5);
    for(int i = 0;i < 5;i++){
        cin >> a[i];
        if(a[i] == 0){
            cout << i + 1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N,M;
	cin >> N >> M;
	ll S = 0,ans=0;
	map<ll,ll> ma;
	ma[S]++;
	FOR(i,0,N){
		ll k;
		cin >> k;
		S += k;
		S %= M;
		ans += ma[S];
		ma[S]++;
	}
	cout << ans << endl;
}


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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

vector<int> z_algorithm(string s){

    int size = s.size();
    vector<int> A(size);

    A[0] = size;
    int i = 1;
    int j = 0;
    
    while(i < size){
        while(i + j < size && s[j] == s[i + j]) j++;

        A[i] = j;
        if(j == 0){
            i++;
            continue;
        }

        int k = 1;
        while(i + k < size && k + A[k] < j){
            A[i + k] = A[k];
            k++;
        }

        i += k;
        j -= k;
    }

    return A;
}

int main(){

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

    int ans = 0;

    for(int i = 0; i < n - 1; i++){
        vector<int> tmpa = z_algorithm(s.substr(i));

        

        for(int j = 1; j < tmpa.size(); j++){
            int match = tmpa[j];

            if(j >= match){
                ans = max(ans, match);
            }
        }
    }

    cout << ans << endl;

}


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

int main(){
  int n, d;
  cin >> n >> d;
  int x[n][d];
  for ( int i = 0; i < n; i++){
    for ( int j = 0; j < d; j++){
      cin >> x[i][j];
    }
  }


  int sum, cnt = 0;
  for ( int i = 0; i < n-1; i++){
    for ( int j = i + 1; j < n; j++ ){
      sum = 0;
      for ( int k = 0; k < d; k++){
        sum = sum + (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      }
      if ( ceil(sqrt(sum)) == floor(sqrt(sum))){ cnt++; }
    }
  }


  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
H,W = map(int,input().split())

S = []

for i in range(H):

    s = input()
    S.append(list(s))

yoko = []

for i in range(H):

    num = 0
    now = []

    for j in range(W):

        if S[i][j] == ".":
            num += 1

        else:
            now += ([num] * num)
            num = 0
            now.append(0)

    now += [num] * num
    yoko.append(now)

#print (yoko)

tate = []

for j in range(W):

    num = 0
    now = []

    for i in range(H):

        if S[i][j] == ".":
            num += 1

        else:
            now += ([num]*num)
            num = 0
            now.append(0)

    now += [num] * num
    tate.append(now)

ans = 0

for i in range(H):

    for j in range(W):

        ans = max(ans , yoko[i][j] + tate[j][i] - 1)

print (ans)


Measured memory_bytes: 248584
N, M = map(int, input().split())
p = [None]*M
S = [None]*M
for i in range(M):
  p[i], S[i] = input().split()

ac = [0]*N
penalty = [0]*N
for i in range(M):
  if S[i] == 'AC':
    ac[int(p[i])-1] = 1
  else:
    if ac[int(p[i])-1] == 0:
      penalty[int(p[i])-1] += 1
for j in range(N):
  if ac[j] == 0:
    penalty[j] = 0
print(*[sum(ac), sum(penalty)])

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

#define F first
#define S second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define in(x) insert(x)
#define forr(i, a, b) for(int i = a;i <= b;i++)
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define did_you_calis_enough ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define int long long

using namespace std;

const int INF =  4294967295;
const int  N = 2e6 + 667;
const int mod = 1e9 + 7;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double PI = acos(-1.0);


main() {
	did_you_calis_enough
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(max(b * d, a * d) , max(a * c,b * c));
}

//Coded by LoliThief

Measured memory_bytes: 3628
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#define N (1000000000+7)
typedef long long ll;
using namespace std;
struct edge {
	ll to;
};
ll kaijo[100010];
void init() {
	kaijo[0] = 1;
	for (ll i = 1;i <= 100000;i++)kaijo[i] = (kaijo[i - 1] * i) % N;
}

ll inv(ll x) {
	ll res = 1;
	ll k = N - 2;
	ll y = x;
	while (k) {
		if (k & 1)res = (res*y) % N;
		y = ((y%N)*(y%N)) % N;
		k /= 2;
	}
	return res;
}

ll Comb(ll n, ll k) {
	//if (n < 0 || k < 0 || (n - k) < 0)return 0;
	ll b = kaijo[n];
	ll c = kaijo[n - k];
	ll d = kaijo[k];
	ll cd = (c*d) % N;
	return ((b%N)*(inv(cd)) % N) % N;
}
int main(void){
    ll n,k;
    cin>>n>>k;
    init();
    for(int i=1;i<=k;i++){
        if(i==1){
            cout<<n-k+1<<endl;
        }
        else{
            if(i==k){
                if(n-k+1>=k)cout<<Comb(n-k+1,k)<<endl;
                else cout<<0<<endl;
            }
            else {
                if(n-k+1>=i)cout<<(Comb(n-k-1+2,i)*Comb((k-1),i-1))%N<<endl;
                else cout<<0<<endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1024
from collections import deque
s = deque(list(input()))
n = int(input())
normal = 0
for i in range(n):
  li = input().split()
  if int(li[0]) == 1:
    normal ^= 1
  else:
    k = int(li[1]) - 1
    k ^= normal
    if k == 1:
      s.append(li[2])
    else:
      s.appendleft(li[2])
print(''.join(s) if normal == 0 else ''.join(list(s)[::-1]))      

Measured memory_bytes: 15860
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,m,d;
    cin>>n>>m>>d;
    
    ld ans;
    if(d==0) ans=1./n;
    else ans=2*(n-d)/(ld)(n*n);
    printf("%.12llf\n",ans*(m-1));
}

Measured memory_bytes: 256
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
import copy
#x = int(input())
n, k = map(int, sys.stdin.readline().split())
#s = input()
a = list(map(int, sys.stdin.readline().split()))

for i in range(n-k):
    if a[i] < a[i+k]:
        print("Yes")
    else:
        print("No")


        


Measured memory_bytes: 32660
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split(" ");
	//文字列から10進数に変換するときはparseIntを使います
  	var a = parseInt(input[0]);
  	var b = parseInt(input[1]);
    var coinCount = 0;
  	
  	for (var i=0; i<2; i++) {
      coinCount += (a > b) ? a-- : b--;
    }
	//出力
	console.log(coinCount);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <iostream>
#include <string>
#include <vector>

#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)

using lint = long int;
using llint = long long int;
using namespace std;

int main() {
    fastIO;

    int n;
    cin >> n;
    while (n--) {
        int input;
        cin >> input;
        if (input % 2 == 0) {
            if (input % 3 != 0 && input % 5 != 0) {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

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



int main(){
    int N,K;
    string S;
    cin >> N >> K >> S;
    std::map<char, char> lower;
    lower['A'] = 'a';
    lower['B'] = 'b';
    lower['C'] = 'c';
    S.at(K-1) = lower[S.at(K-1)];
    cout << S << endl;
    return 0;


}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int n;
    int d=100000;
    int tmp;
    scanf("%d",&n);
    while(n>0){
        d*=1.05;
        tmp=d%1000;
        if(tmp!=0){
             d+=1000;
             d-=tmp;
        }
        n--;
    } 
    printf("%d\n",d);
    return 0;
}

Measured memory_bytes: 588
n=int(input())
a=list(map(int,input().split()))
a.sort()
l=[]
i=0
while i<n-1:
  if a[i]==a[i+1]:
    l.append(a[i])
    i+=2
  else:
    i+=1
l.reverse()
if len(l)<2:
  print(0)
else:
  print(l[0]*l[1])

Measured memory_bytes: 14252
n = gets.to_i
vec = Array.new(4) { Array.new(3) { Array.new(10, 0) } }

n.times do
  b, f, r, v = gets.split.map(&:to_i)
  vec[b - 1][f - 1][r - 1] += v
end

vec.each_with_index do |v, i|
  v.each do |w|
    puts ' ' + w.join(' ')
  end
  puts '#' * 20 if i != vec.size - 1
end



Measured memory_bytes: 6892
#include <iostream>
#include <queue>
#include <string>

using namespace std;

int main() {
  int N, A;
  queue<int> q;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A;
    q.push(A);
  }
  int ret[N];
  for (int i = 0; i < N; i++) {
    ret[q.front()-1] = i + 1;
    q.pop();
  }
  for (int i; i < N; i++) {
    cout << ret[i] << " ";
  }
  cout << endl;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define int long long
#define mod 1000000007
#define maxN 1000005
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pip pair<int,pii>
#define vi vector<int>
#define vpi vector<pii >
#define endl "\n"
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define FOR(a,b,c) for(int(a) = b;a<=c;a++)
#define repr(a,b,c) for(int(a) = b;a>=c;a--)
#define rep(i,n) for(int(i) = 0;i<n;i++)
#define fir first
#define sec second
#define beg begin()
#define e end()
#define len length()
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;


int32_t main()
{
   fastIO;
   int a,b;
   cin>>a>>b;
   cout<<max(a+b,max(a-b,a*b));

   return 0;
}

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

int main(){
	int n;
	long long s=0;
	cin>>n;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		s+=a;
	}
	cout<<s/n<<endl;
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int S[14] = {0,0,0,0,0,0,0,0,0,0,0,0,0},
    H[14] = {0,0,0,0,0,0,0,0,0,0,0,0,0},
    C[14] = {0,0,0,0,0,0,0,0,0,0,0,0,0},
    D[14] = {0,0,0,0,0,0,0,0,0,0,0,0,0};
    
    int num;
    char suit;
    
    for (int i = 0; i < n; i++) {
        cin >> suit >> num;
        if (suit == 'S')
            S[num] = num;
        else if (suit == 'H')
            H[num] = num;
        else if (suit == 'C')
            C[num] = num;
        else
            D[num] = num;
    }
    for (int i = 1; i < 14; i++)
        if (S[i] == 0) cout << "S " << i << endl;
    for (int i = 1; i < 14; i++)
        if (H[i] == 0) cout << "H " << i << endl;
    for (int i = 1; i < 14; i++)
        if (C[i] == 0) cout << "C " << i << endl;
    for (int i = 1; i < 14; i++)
        if (D[i] == 0) cout << "D " << i << endl;
    
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#include <boost/math/constants/constants.hpp>
using namespace std;
typedef long long ll;
long double e = boost::math::constants::e<long double>();
long double pi = boost::math::constants::pi<long double>();
// 条件を見落としていませんか？
int main () {
    int N, M;
    cin >> N >> M;
    cout << N*(N-1)/2 + M*(M-1)/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#define maxn 1005
using namespace std;
string G[maxn];
long long f[maxn][maxn];
int main() {
	ios::sync_with_stdio(false);
	//   sync_with_YinHsuan(true);
	cin.tie(0);
	int h, w, mod = 1e9+7;
	long long ans = 0;
	cin >> h >> w;
	for ( int i=0; i<h; ++i )
		cin >> G[i];
	f[0][0] = 1;
	for ( int i=1; i<w; ++i ) {
		if ( G[0][i] == '#' )	break;
		f[0][i] = f[0][i-1];
	}
	for ( int i=1; i<h; ++i ) {
		if ( G[i][0] == '#' )	break;
		f[i][0] = f[i-1][0];
	}
	for ( int i=1; i<h; ++i )
		for ( int j=1; j<w; ++j ) {
			if ( G[i-1][j] != '#' )	f[i][j] += f[i-1][j];
			if ( G[i][j-1] != '#' )	f[i][j] += f[i][j-1];
			f[i][j] %= mod;
		}
	cout << f[h-1][w-1] << '\n';
	return 0;
}


Measured memory_bytes: 9216
// luogu-judger-enable-o2
#include <bits/stdc++.h>
#define rep(i, j, k) for(int i = j; i <= k; ++i)
#define dep(i, j, k) for(int i = j; i >= k; --i)
#define SIZE(x) (int)(x.size())
#define to(x) (x > n ? x - n : x)

typedef long long ll;

using namespace std;

const int maxn = 2e5 + 5;

int n, a[maxn], b[maxn], L, R, vis[maxn];
set<int> Q[maxn], S, now;
ll ans = 0, rnt = 0;

inline int read() {
	char ch = getchar(); int u = 0, f = 1;
	while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getchar(); }
	while(isdigit(ch))  { u = u * 10 + ch - 48; ch = getchar(); } return u * f;
}

int main() {
	n = read();
	rep(i, 1, n) S.insert(i);
	rep(i, 2, 2 * n) if(i * (i - 1) == 2 * n) {
		puts("Yes");
		printf("%d\n", i);
		rep(j, 1, i) {
			int P = j;
			if(Q[j].size() < i - 1) {
				for(int v : S) if(!Q[j].count(v)) {
					Q[j].insert(v);
					rep(k, P + 1, i) 
						if(Q[k].size() < i - 1 && !Q[k].count(v)) { 
							Q[k].insert(v); P = k; break;
						}
					S.erase(v);
					if(Q[j].size() >= i - 1) break;
				}
			}
			printf("%d ", i - 1);
			for(int v : Q[j]) printf("%d ", v);
			putchar('\n');
		} return 0;
	} puts("No");
	return 0;
}

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

sum = 0.5 * N * (N + 1)

num_3 = int(N / 3)
sum_3 = 3 * 0.5 * num_3 * (num_3 + 1)
num_5 = int(N / 5)
sum_5 = 5 * 0.5 * num_5 * (num_5 + 1)
num_15 = int(N / 15)
sum_15 = 15 * 0.5 * num_15 * (num_15 + 1)

print(int(sum - sum_3 - sum_5 + sum_15))

Measured memory_bytes: 61756
package main

import (
	"fmt"
)

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func div2(x int) (ans int) {
	for x%2 == 0 {
		x /= 2
		ans++
	}
	return
}

func main() {
	var n int
	fmt.Scan(&n)
	arr := make([]int, n)
	for i := range arr {
		fmt.Scan(&arr[i])
	}
	var ans int
	ans = 1e9
	for _, e := range arr {
		ans = min(ans, div2(e))
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1780
#include <iostream>

using namespace std;

int main(void)
{
    int N, A, B, value, j[3] = {};
    cin >> N >> A >> B;

    for (int i = 0; i < N; ++i){
        cin >> value;
        if(value <= A)j[0]++;
        else if(value <= B)j[1]++;
        else if(value > B)j[2]++;
    }
    j[0] = j[0] < j[1] ? j[0] < j[2] ? j[0] : j[2] : j[1] < j[2] ? j[1]:j[2];
    cout << j[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int ans = 0;
    int now = 0;
    for(int i = 0; i < S.size(); i++) {
        if(S[i] == 'R') now++;
        else now = 0;
        chmax(ans, now);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3616
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
const int inf = 0x3f3f3f3f;
const ll linf = 123456789012345678;
const ll mod = 1000000007;
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " = " << x << endl
#define sz(x) ((int)(x).size())


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

    int a, b;
    cin >> a >> b;
    if(a > b) swap(a, b);
    if(a == 1 && b == 2) cout << "3\n";
    if(a == 1 && b == 3) cout << "2\n";
    if(a == 2 && b == 3) cout << "1\n";
}

Measured memory_bytes: 892
#include<iostream>
using namespace std;
int main(int argc, char const *argv[])
{
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	int cnt=0;int cnt1=0;
	for (int i = 0; i < 3; ++i)
	{
		if(a[i]==5){
			cnt++;
		}
		if(a[i]==7){
			cnt1++;
		}

	}

	if(cnt>=2 and cnt!=0){
		cout<<"YES\n";
	}
	else{
		cout<<"NO\n";
	}
	return 0;
}

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

namespace AtCoder.Abc171
{
    class C
    {
        public static void Main()
        {
            var n = long.Parse(Console.ReadLine());
            var ans = new List<char>();
            while (n > 0)
            {
                int a = (int)((n - 1) % 26);
                ans.Add((char)(a + 'a'));
                n = (n-1) / 26;
            }
            ans.Reverse();
            Console.WriteLine(new string(ans.ToArray()));
        }
    }
}


Measured memory_bytes: 27824