akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<bits/stdc++.h>
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector>
#define rep0(i,n)  for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e18
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
  int m1,d1,m2,d2;  cin >> m1 >> d1 >> m2 >> d2;
  if(m2==m1+1 and d2==1){
    cout << 1;
  }else{
    cout << 0;
  }
}


Measured memory_bytes: 256
import collections
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
def main():
    dd = collections.defaultdict(int)
    n = int(input())
    MOD = 10**9 + 7

    for i in range(1,n+1):
        k=factorization(i)
        for j in k:
            dd[j[0]]+=j[1]
    res = 1
    for j in dd.keys():
        if(j!=1):
            res *= (dd[j]+1)%MOD
            res%=MOD
    print(res)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9668
#include <bits/stdc++.h>
#include <cstdio>
 
using namespace std;
using ll = long long;
 
#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);
template<typename T>
inline T GET() {
	T val;
	cin >> val;
	return val;
}


 
#define MOD 1000000007
void init();
void solve();

signed main()
{
    init();
    solve();
}

struct uni_find
{
	vector<int> par;
	vector<int> cnt;
	int sz;
	uni_find(){} 
	uni_find(int n) {init(n);}
	void init(int n) {
		par.resize(n);
		cnt.resize(n);
		rep(i, n) par[i] = i, cnt[i] = 1;
		sz = n;
	}
	int root(int x) {return par[x] == x ? x : par[x] = root(par[x]);}
	bool same(int x, int y) {return root(x) == root(y);}
	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return;
		if (cnt[x] < cnt[y]) {
			par[x] = y;
			cnt[y] += cnt[x];
		}
		else {
			par[y] = x;
			cnt[x] += cnt[y];
		}
	}
	int size(int x) {
		return cnt[root(x)];
	}
};

uni_find a, b;
int N;

void init()
{
	int K, L;
	cin >> N >> K >> L;
	a.init(N);
	b.init(N);
	rep(i, K) {
		a.unite(GET<int>()-1, GET<int>()-1);
	}
	rep(i, L) {
		b.unite(GET<int>()-1, GET<int>()-1);
	}
}


void solve()
{
	map<pair<int,int> , int> m;
	rep(i, N) {
		m[MP(a.root(i), b.root(i))]++;
	}
	rep(i, N) {
		cout << m[MP(a.root(i), b.root(i))] << " \n"[i==N-1];
	}
}



Measured memory_bytes: 15104
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using Graph = vector<vector<int>>;
using ll = long long;
using p = pair<int, int>;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> s(m, vector<int>(m));
    vector<int> k(m);
    rep(i, m)
    {
        cin >> k[i];
        rep(j, k[i])
        {
            int val;
            cin >> val;
            s[i][j] = val;
        }
    }

    vector<int> p(m);
    rep(i, m)
    {
        cin >> p[i];
    }

    int ans = 0;
    rep(i, (1 << n))
    {
        map<int, int> mp; // 電球につながってるスイッチの中でONになってる数
        // 電球ループ
        rep(j, m)
        {
            if (!mp[j])
                mp[j] = 0;
            int switch_num = k[j];
            rep(k, switch_num)
            {
                if (i & (1 << (s[j][k] - 1)))
                {
                    mp[j]++;
                }
            }
        }

        int light_num = 0;
        for (auto itr = mp.begin(); itr != mp.end(); ++itr)
        {
            if (itr->second % 2 == p[itr->first])
            {
                light_num++;
            }
        }
        if (light_num == m)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3564
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
#include<cstdio>
#include<ctime>
#include<utility>
#include<cstdlib>
#include<iterator>
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;
typedef unsigned int uint;

bool arithmetic(vector<llong> vect) {
	llong ngo = vect[1] - vect[0];
	for (llong i = 1; i < vect.size(); ++i) {
		if ((vect[i] - vect[i - 1]) != ngo) {
			return false;
		}
		ngo = vect[i] - vect[i - 1];
	}
	return true;
}

int main() {
	llong n;
	cin >> n;
	while (n != 0)
	{
		vector<llong> vect(n + 1);
		//cout << "?????????" << vect.size() << endl;
		for (llong i = 0; i < vect.size(); ++i) {
			cin >> vect[i];
		}
		for (llong i = 0; i < vect.size(); ++i) {
			vector<llong> ngo;
			copy(vect.begin(), vect.end(), back_inserter(ngo));
			ngo.erase(ngo.begin() + i);
			if (arithmetic(ngo)) {
				cout << vect[i] << endl;
				break;
			}
		}
		cin >> n;
	}
	return 0;
}


Measured memory_bytes: 3160
unittest
{
	assert( [ "gpg" ].parse.expand.solve == 0 );
	assert( [ "ggppgggpgg" ].parse.expand.solve == 2 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	return tuple( s );
}

auto solve( dchar[] s )
{
	auto wc = 0L;
	auto lc = 0L;
	auto gc = 0L;
	auto pc = 0L;
	foreach( h; s )
	{
		if( pc + 1 <= gc )
		{
			// パーを出せる
			wc += ( h == 'g' );
			pc++;
		}
		else
		{
			// グーしか出せない
			lc += ( h == 'p' );
			gc++;
		}
	}
	return wc - lc;
}


Measured memory_bytes: 2840
# -*- coding: utf-8 -*-
#ARC64C
import sys

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
n=hoge[0]
x=hoge[1]

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
ans=0
for i in range(0,n-1):
	sum=hoge[i]+hoge[i+1]
	if(sum>x):
		ans+=sum-x
		if(sum-x<=hoge[i+1]):
			hoge[i+1]-=sum-x
		else:
			hoge[i+1]=0
print(ans)

Measured memory_bytes: 14432
N = int(input())
S = input()

left = {}
right = {}

for c in S[1:]:
    if c not in right:
        right[c] = 1
    else:
        right[c] += 1

left[S[0]] = 1

ans = len(left.keys() & right.keys())
for i in range(1, N-1):
    c = S[i]
    if c not in left:
        left[c] = 1
    
    if right[c] == 1:
        del(right[c])
    else:
        right[c] -= 1

    ans = max(ans, len(left.keys() & right.keys()))
    

print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string.h>
using namespace std;
int n, m, i, j, k, l, t, len=0, s=0, appeared[26]={0};
vector<int> cutoff;
char a[200010], temp;
int main(){
	cin>>a;
	n=strlen(a);
	for(i=n-1;i>=0;i--){
		if(appeared[a[i]-'a']==0){
			appeared[a[i]-'a']=1;
			s++;
		}
		if(s==26){
			cutoff.push_back(i);
			for(j=0;j<=25;j++) appeared[j]=0;
			s=0;
			len++;
		} 
	}
	for(i=0;i<=25;i++) appeared[i]=0;
	j=0;
	for(i=len-1;i>=0;i--){
		for(;j<=cutoff[i]-1&&j<=n-1;j++) appeared[a[j]-'a']=1;
		for(k=0;k<=25;k++){
			if(appeared[k]==0){
				temp='a'+k;
				cout<<temp;
				for(l=0;l<=25;l++) appeared[l]=0;
				break;
			}
		}
		for(;;j++) if(a[j]==temp) break;
		j++;
	}
	for(;j<=n-1;j++) appeared[a[j]-'a']=1;
	for(k=0;k<=25;k++){
			if(appeared[k]==0){
				temp='a'+k;
				cout<<temp;
				for(l=0;l<=25;l++) appeared[l]=0;
				break;
			}
		}
	return 0;
}

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

const ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

int n, a, b, in[1009][1009], d[1009][1009];
vector<pair<int, int>> e[1009][1009];

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

    cin >> n;
    rep(i, n) rep(j, n - 1) {
        cin >> a;
        if(j) {
            e[min(i + 1, (ll)b)][max(i + 1, (ll)b)].push_back(
                {min(i + 1, (ll)a), max(i + 1, ll(a))});
            in[min(i + 1, (ll)a)][max(i + 1, ll(a))]++;
        }
        b = a;
    }

    queue<pair<int, int>> que;
    FOR(i, 1, n + 1) FOR(j, i + 1, n + 1) if(!in[i][j]) { que.push({i, j}); }

    int ans, cnt = 0;

    while(!que.empty()) {
        pair<int, int> now = que.front();
        que.pop();
        cnt++;
        int x = now.first, y = now.second;
        rep(i, e[x][y].size()) {
            int nx = e[x][y][i].first, ny = e[x][y][i].second;
            if(--in[nx][ny] == 0) {
                ans = d[nx][ny] = d[x][y] + 1;
                que.push({nx, ny});
            }
        }
    }

    cout << (cnt == n * (n - 1) / 2 ? ans + 1 : -1) << endl;
}

Measured memory_bytes: 47616
#include<stdio.h>
int main()
{
    int A, B, C;
    scanf("%d %d %d", &A, &B, &C);
    if(A,B,C>=-100 && A,B,C<=100)
    {
        if(C>=A && C<=B)
        {
            printf("Yes");
        }
        else
        {
            printf("No");
        }
    }
    return 0;
}


Measured memory_bytes: 128
/*
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
*/
#include <bits/stdc++.h>

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

int main()
{
    int x,y,z;
    cin >> x >> y >> z;
    cout << z <<" "<< x <<" "<< y;
    return 0;
}


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

int main(){
    while(true){
        int main;
        int n;
        cin>>n;
        if(n==0)break;
        char c[100];
        for(int i=0;i<n;i++){
            cin>>c[i];
        }
        int cnt[26]={0};
        for(int i=0;i<n;i++){
            cnt[(int)(c[i]-'A')]++;
            int max1 = -1;
            int max2 = -1;
            for(int j=0;j<26;j++){
                if(cnt[j]>max1){
                    max2=max1;
                    max1=cnt[j];
                }else if(cnt[j]>max2){
                    max2=cnt[j];
                }
            }
            if(max1-max2>n-(i+1)){
                for(int j=0;j<26;j++){
                    if(cnt[j]==max1){
                        cout<<(char)(j+'A')<<' ';
                        break;
                    }
                }
                cout<<(i+1)<<endl;
                break;
            }
            if(i==n-1){
                cout<<"TIE"<<endl;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3084
//k_tourist
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define mx 500005
#define non __builtin_popcount
#define ml map<ll, ll> 
#define uml unordered_map<ll, ll>
#define ms map<string , ll> 
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define pl pair<ll, ll>
#define vl vector<ll>
#define vll vector<pl>
#define tpl pair<ll, pl>
#define vlll vector<tpl>
#define vs vector<string>
#define pb push_back
#define mk make_pair
#define M_PI 3.14159265358979323846
#define endl '\n'
#define fst ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%I64d",&x)
#define inf ((ll)1e18 + 1)
#define bs binary_search
#define pq priority_queue
#define ub upper_bound
#define lb lower_bound
#define pow powr
#define sp(a) setprecision(a)
#define rep(i,a,b)  for (i=(a);i<(b);i++)
#define nrep(i,a,b) for (i=(a);i>(b);i--)
using namespace std;
using namespace __gnu_pbds;  

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>  ordered_set;
 
ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

void flag(ll fl){

	if(fl)
	cout<<"NO";
	else
	cout<<"YES";
}

ll a[mx], n, dp[mx];

ll frog1(ll i){

	if(i == n-1)
	return 0;

	if(dp[i] != -1)
	return dp[i];

	if(i == n-2)
	return (dp[i] =  abs(a[i+1] - a[i]) );

	return (dp[i]=  min(abs(a[i+1] - a[i]) + frog1(i+1), abs(a[i+2] - a[i]) + frog1(i+2)));
}

void bta_de_yarr(){

	ll i, j, fl=0, ans, m;
	// ll a[mx];
	cin>>n;

	rep(i, 0, n)
	{
		cin>>a[i];
		dp[i] = -1;
	}

	ans= frog1(0);
	// cin>>m;

	
	cout<<ans;
	// flag(fl);
	cout<<endl;
}

int main(){
    fst

	// freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
	ll t;
    t= 1;
	//cin>>t;
    while(t--){
        bta_de_yarr();
    }
    return 0;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
const int N=1e5+5;
vector<int>lk[N];
int ans[N];
bool vis[N][11];
pair<int,int>q[N*11];int tail;
void push(int x,int d)
{
	if(!vis[x][d])
	{
		q[++tail]=make_pair(x,d);
		vis[x][d]=1;
	}
}

struct Query
{
	int v,d,c;
};
Query query[N];

void bfs(int v,int d,int c)
{
	tail=0;
	push(v,d);
	rep(head,1,tail)
	{
		int x=q[head].first,d=q[head].second;
		if(!ans[x])ans[x]=c;
		if(!d)continue;
		for(auto y:lk[x])push(y,d-1);
	}
}

int main()
{
	//freopen("1.in","r",stdin);
	int n,m;
	cin>>n>>m;
	rep(i,1,m)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		lk[x].push_back(y);lk[y].push_back(x);
	}
	int q;
	cin>>q;
	rep(i,1,q)scanf("%d%d%d",&query[i].v,&query[i].d,&query[i].c);
	per(i,q,1)bfs(query[i].v,query[i].d,query[i].c);
	rep(i,1,n)printf("%d\n",ans[i]);
}

Measured memory_bytes: 15480
H, W = map(int, input().split())
G = [[1 if s == '#' else 0 for s in input().strip()] for _ in range(H)]
T = [[0]*W for _ in range(H)]
for j, g in enumerate(G):
    S = [0]*W
    pre = 0
    for ig, g in enumerate(g):
        if g:
            pre = 0
            continue
        pre += 1
        S[ig] = pre
    pre = 0
    for k, s in enumerate(S[::-1]):
        k = W - 1 - k
        if not s:
            pre = 0
            continue
        pre = max(pre, s)
        T[j][k] = pre

G = list(map(list, zip(*G)))
T2 = [[0]*H for _ in range(W)]

for j, g in enumerate(G):
    S = [0]*H
    pre = 0
    for ig, g in enumerate(g):
        if g:
            pre = 0
            continue
        pre += 1
        S[ig] = pre
    pre = 0
    for k, s in enumerate(S[::-1]):
        k = H - 1 - k
        if not s:
            pre = 0
            continue
        pre = max(pre, s)
        T2[j][k] = pre
T2 = list(map(list, zip(*T2)))
ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, T[i][j] + T2[i][j])
print(ans - 1)

Measured memory_bytes: 190472
// 2012/11/19 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

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

	int A, B;
	cin >> A >> B;

	int C;
	cin >> C;

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

	sort(D, D+N, greater<int>());

	int c_sum = C;
	int p_sum = A;

	for(int i=0; i<N; i++){
		if(c_sum/p_sum>(c_sum+D[i])/(p_sum+B)){
			break;
		}
		else{
			c_sum += D[i];
			p_sum += B;
		}
	}

	cout << c_sum/p_sum << '\n';

	return 0;
}

Measured memory_bytes: 1176
#include <iostream>




using namespace std;

int A;
int B;
int C;
int start;
int remain;

int main () {

    cin >> A;
    cin >> B;
    cin >> C;  
    
    while((B != A)&&(C > 0)){
        B += 1;
        C -= 1;
    }
    cout << C;



     

    

    



}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int N;
  int n[4];
  scanf("%d",&N);

  if (N / 1000 == (N % 1000) / 100 && (N % 100) / 10 == (N % 1000) / 100) {
    puts("Yes");
  }
  else if ((N % 100) / 10  == (N % 1000) / 100 && N % 10 == (N % 100) / 10 ) {
    puts("Yes");
  }
  else
    puts("No");

  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	int a[31]={0};
	int i=0,j=0;
	int num=0;
	int b[2]={0};

	a[0]=0;
	for (i=0;i<=27;i++)
	{
		scanf("%d",&num);
		a[num]=1;
	}
	j=0;
	for (i=1;i<=30;i++)
	{
		if (a[i]==0)
		{
			b[j]=i;
			j++;
		}
	}
	if (b[0]>b[1])
	{
		j=a[0];
		a[0]=a[1];
		a[1]=j;
	}
	for (i=0;i<=1;i++)
	{
		printf("%d\n",b[i]);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7

int main(){
    ll n, k;
    cin >> n >> k;
    if(k == 0){
        ll ans = n * n;
        print(ans);
        return 0;
    }

    ll ans = 0;
    rep(b, k + 1, n + 1){
        ll N = (n + 1) / b;
        ll d = 0;
        d += 1LL * (b - k) * N;
        ll R = n;
        ll L = k + N * b;
        if(L <= R){
            d += R - L + 1;
        }
        ans += d;
    }
    print(ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
#define int long long

signed main(){
        //int a;
        //while( scanf("%lld", &a) != EOF ){}

        char str[21]={0};
        scanf("%s",str);
        for(int i=20;i>=0;i--){
                if(str[i]!=0) printf("%c",str[i]);
        }
        printf("\n");

        return 0;
}

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

count = 0
for i in range(N):
    if (A[i] % 2 == 0):
        if not (A[i] % 3 == 0 or A[i] % 5 == 0):
            count += 1
if count == 0:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
const int maxN = 1000001;
int isSubstring(string s1, string s2) { 
    int M = len(s1); 
    int N = len(s2); 
    for (int i = 0; i <= N - M; i++) { 
        int j; 
        for (j = 0; j < M; j++){
            if (s2[i + j] != s1[j]){
                break; 
            }
        }
        if (j == M){
            return 1; 
        }
    } 
    return 0; 
} 
int32_t main(){
    SPEED;
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a * c , max(a * d, max(b * c, b * d)));
}

Measured memory_bytes: 3636
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
l = len(str(n))
arr = []
for i in range(1, 10):
    for j in range(1, 10):
        arr.append([i, j])
arr3 = [0 for _ in range(len(arr))]
for i in range(1, n + 1):
    head = int(str(i)[0])
    foot = int(str(i)[-1])
    if head != 0 and foot != 0:
        idx = arr.index([head, foot])
        arr3[idx] += 1
ans = 0
for i in range(len(arr3)):
    idx = arr.index(list(reversed(arr[i])))
    ans += arr3[i] * arr3[idx]
print(ans)

Measured memory_bytes: 5200
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	const inputLines = input.split("\n");
	const line0 = inputLines[0];
	const line0vars = line0.split(" ");
	const line1 = inputLines[1];
	const line1vars = line1.split(" ");

	const n = parseInt(line0vars[0], 10);

	var result = 0;
	var current = 0;

	for (var i = 0; i < n; i++) {
		const a = parseInt(line1vars[i], 10);
		if (i === 0) {
			current = a;
			continue;
		}
		if (current < a) {
			current = a;
		} {
			result += current - a;
		}
	}

	console.log(result);

	
	// tmp = input[1].split(" ");
	// //文字列から10進数に変換するときはparseIntを使います
	// var a = parseInt(input[0], 10);
	// var b = parseInt(tmp[0], 10);
	// var c = parseInt(tmp[1], 10);
	// var s = input[2];

	//出力
	// console.log('%d %s',a+b+c,s);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

// node index.js
// 1
// 2 3
// test
// (Ctrl + D)


Measured memory_bytes: 49164
from collections import defaultdict as dd
dicPar = dd(lambda: -1)
dicChild = dd(lambda: [])

n = int(input())
for i in range(n):
  i = list(map(int, input().split()))
  id, k, C = i[0], i[1], i[2:]
  dicChild[id] = C
  for j in range(k):
    dicPar[C[j]] = id
#print(dicPar)
#print(dicChild)

def depth(dicPar, id):
  if dicPar[id] == -1:
    return 0
  else:
    return depth(dicPar, dicPar[id]) + 1

def nodeType(dicPar, dicChild, id):
  if dicPar[id] == -1:
    return "root"
  elif len(dicChild[id]) == 0:
    return "leaf"
  else:
    return "internal node"

#print(depth(dicPar, 1))
for id in range(n):
  print("node {}: parent = {}, depth = {}, {}, {}".format(id, dicPar[id], depth(dicPar, id), nodeType(dicPar, dicChild, id), dicChild[id]))


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

using namespace std;

double r, pi = 3.1415926, c;

int read()
{
  int x = 0, w = 1;
  char ch = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + (ch - '0');
    ch = getchar();
  }
  return x * w;
}

inline void write(int x)
{
  static int sta[35];
  int top = 0;
  do {
    sta[top++] = x % 10, x /= 10;
  } while (x);
  while (top) putchar(sta[-- top] + 48);
}

int main()
{
	r = read();
	c = 2 * r * pi;
	printf("%.3f", c);
	return 0;
}

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

#define scd second
#define fst first
#define mkp make_pair
#define pb push_back

using namespace std;

typedef long long int ll;
typedef vector<int> vint;
typedef vector<ll> vlong;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

int const N=1e5+10;

int main(){
	int n;
	cin>>n;
	vector<int> cnt(N,0);
	int n1=0;
	for(int i=0; i<n; i++){
		int a;
		cin>>a;
		cnt[a]++;
		cnt[a+1]++;
		if(a==0){
			n1++;
		}else{
			cnt[a-1]++;
		}
	}

	int ans=n1;
	for(int i=0; i<N; i++){
		ans=max(ans,cnt[i]);
	}

	cout<<ans<<endl;
}

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

int main(){
    ll n, l;
    cin >> n >> l;
    ll s = 0;
    rep(i, 1, n+1){
        s += l + i - 1;
    }
    ll mx = 1e9;
    ll ans = 0;
    rep(i, 1, n+1){
        if(abs(l+i-1) < mx){
            mx = abs(l+i-1);
            ans = s - (l+i-1);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 1<<29
#define linf 1e18
#define eps (1e-8)
#define mod 1000000007
#define pi M_PI
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

int main()
{
  int n,count=0;
  string s,ans="YES";

  cin>>n;
  FOR(i,0,n){
    cin>>s;
    if(s=="A")count++;
    else {
      count--;
      if(count<0)ans="NO";
    }
  }
  if(count!=0)ans="NO";
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3176
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <utility>
#include <functional>
#include <map>
#include <string>
#include <set>
#include <math.h>

using namespace std;

// 自分で考えてた解法
void solve1() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, q;
  cin >> n >> q;

  string s;
  cin >> s;

  int l[q], r[q];
  for (int i = 0; i < q; i++) {
    cin >> l[i] >> r[i];
  }

  // count[i]:=i番目までの文字列に含まれている"AC"の個数(0-index)
  int count[n];
  for (int i = 0; i < n; i++) {
    count[i] = 0;
  }

  for (int i = 1; i < n; i ++) {
   if (s.substr(i - 1, 2) == "AC") {
     count[i] = 1;
   }

    count[i] += count[i - 1];
  }

  for (int i = 0; i < q; i++) {
    // 0-indexのため
    int left = l[i] - 1;
    int right = r[i] - 1;

    if (left == 0) {
      cout << count[right] << endl;
    }
    else if (count[left] == count[left - 1]) {
      cout << count[right] - count[left - 1] << endl;
    }
    else {
      cout << count[right] - count[left - 1] - 1 << endl;
    }
  }
}

// 解答例
void solve2() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, q;
  cin >> n >> q;

  string s;
  cin >> s;

  int l[q], r[q];
  for (int i = 0; i < q; i++) {
    cin >> l[i] >> r[i];
  }

  // count[i]:=i+1番目までの文字列で、
  // i番目の文字が"A"で、その右隣が"C"である個数
  int count[n];
  for (int i = 0; i < n; i++) {
    count[i] = 0;
  }

  if (s.substr(0, 2) == "AC") {
    count[0] = 1;
  }
  for (int i = 1; i < n; i ++) {
   if (s.substr(i, 2) == "AC") {
     count[i] += (count[i - 1] + 1);
   }
   else {
     count[i] += count[i - 1];
   }
  }

  for (int i = 0; i < q; i++) {
    int left = l[i] - 1;
    int right = r[i] - 1;

    if (left == 0) {
      cout << count[right - 1] << endl;
    }
    else {
      cout << count[right - 1] - count[left - 1] << endl;
    }
  }
}

int main() {
  solve1();
  // solve2();
}

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

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

using namespace std;

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

    if(a*c <= b) {
        cout << c << endl;
    } else {
        cout << b / a << endl;
    }
    return 0;

}




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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long I = A[0];
		long O = A[1];
		long J = A[3];
		long L = A[4];
		
		long ans = 0;
		
		ans += O;
		long x = (I/2) * 2 + (L/2) * 2 + (J/2) * 2;
		long y = (L > 0 & J > 0 & I > 0) ? (3 + (L-1)/2 * 2 + (I-1)/2 * 2 + (J-1)/2 * 2) : 0;
		ans += Math.Max(x, y);
		Console.WriteLine(ans);
		
	}
	long[] A;
	public Sol(){
		A = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13140
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#define ll long long

using namespace std;


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

	printf("%d %d %.8lf", a / b, a%b, (double)a / (double)b);


}




Measured memory_bytes: 3224
#include <algorithm>
#include <iostream>
#include <iterator>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

void Bubble(vector<string> &v) {
  string tmp;
  int n = v.size();
  bool flag = true;
  while (flag) {
    flag = false;
    for (int i = n - 1; i > 0; i--) {
      if (v[i][1] < v[i - 1][1]) {
        tmp = v[i];
        v[i] = v[i - 1];
        v[i - 1] = tmp;
        flag = true;
      }
    }
  }
}

void Select(vector<string> &v) {
  int n = v.size();
  int minj;
  string tmp;
  bool flag = false;
  for (int i = 0; i < n; i++) {
    minj = i;
    for (int j = i; j < n; j++) {
      if (v[j][1] < v[minj][1]) {
        minj = j;
        flag = true;
      }
    }
    if (flag) {
      tmp = v[i];
      v[i] = v[minj];
      v[minj] = tmp;
      flag = false;
    }
  }
}

void print(vector<string> &v) {
  int n = v.size();
  for (int i = 0; i < n; i++) {
    if (i == n - 1)
      cout << v[i] << endl;
    else
      cout << v[i] << ' ';
  }
}

bool isStable(vector<string> &v1, vector<string> &v2) {
  int n = v1.size();
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = 0; k < n; k++) {
        for (int l = k + 1; l < n; l++) {
          if (v1[i][1] == v1[j][1] && v1[i] == v2[l] && v1[j] == v2[k])
            return false;
        }
      }
    }
  }
  return true;
}

int main() {
  int n;
  bool flag = true;
  string s, tmp;
  vector<string> v1, v2, v3;
  cin >> n;
  cin.ignore();
  getline(cin, s);
  stringstream ss(s);
  while (ss >> tmp)
    v1.push_back(tmp);

  copy(v1.begin(), v1.end(), back_inserter(v2));
  copy(v1.begin(), v1.end(), back_inserter(v3));

  Bubble(v2);
  print(v2);
  if (isStable(v1, v2)) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }

  Select(v3);
  print(v3);
  if (isStable(v1, v3)) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }

  return 0;
}



Measured memory_bytes: 3236
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO.Pipes;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder {
    class Triangles {
        static int gcd(int a, int b) {
            while (a>0 && b>0) {
                if (a>b) {
                    a %= b;
                } else {
                    b %= a;
                }
            }
            return a + b;
        }

        static long solve(int W, int H, int K) {
            int[] gcdMemo = new int[H + 1];
            for (int h = 0; h <= H; h++) {
                gcdMemo[h] = gcd(W, h);
            }

            int lim = 2 * K - 2;

            long ans = 0;
            for (int x = 1; x < W; x++) {
                for (int y1 = 1; y1 < H; y1++) {
                    if (W * y1 - 2 * W > lim) {
                        break;
                    }

                    // (W - x) * y1 + x * y2 <= lim
                    // y2 <= (lim - (W - x) * y1) / x

                    int maxTrivial = 0;
                    if ((long)(W - x) * y1 <= lim) {
                        maxTrivial = (lim - (W - x) * y1) / x;
                    }

                    maxTrivial = Math.Min(maxTrivial, H - 1);

                    if (maxTrivial >= y1) {
                        ans += 2 * (maxTrivial - y1) + 1;
                    }

                    for (int y2 = Math.Max(maxTrivial + 1, y1); y2 < H; y2++) {
                        if ((long)(W - x) * y1 + (long)x * y2 - 2 * W > lim) {
                            break;
                        }

                        if ((W - x) * y1 + x * y2 - gcd(x, y1) - gcd(W - x, y2) - gcdMemo[Math.Abs(y1 - y2)] <= lim) {
                            ans += (y2 == y1 ? 1 : 2);
                        }
                    }
                }
            }
            return 2 * ans;
        }

        public static void Main(string[] args) {
            var parts = Console.ReadLine().Split(' ');
            int W = int.Parse(parts[0]);
            int H = int.Parse(parts[1]);
            int K = int.Parse(parts[2]);

            //Stopwatch tm = new Stopwatch();
            //tm.Start();
            long ans = solve(W, H, K) + solve(H, W, K);
            //tm.Stop();

            //Console.WriteLine(tm.ElapsedMilliseconds + " ms");
            Console.WriteLine(ans);
        }
    }
}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<int,int> p;

int a,b,c,d,e,f;
int water, sugar;

int main(){
  cin >> a >> b >> c >> d >> e >> f;
  int a100 = 100*a;
  int b100 = 100*b;
  double temp_dense = 0.0;
  double temp_sugar = 0;
  double temp_water = 100;
  double max_dense = (double)100*e/(100+e);
  // cout << "MAX_DENSE: " << max_dense << endl;
  rep(i,0,50){
    rep(j,0,50){
      if(i==0 && j==0)continue;
      rep(k,0,200){
        rep(l,0,200){
          double water = a100*i+b100*j;
          double sugar = k*c+l*d;
          if(water+sugar <= f){
            double dense = (double)100*sugar/(water+sugar);
            if(dense >= temp_dense && dense <= max_dense){
              temp_dense = dense;
              temp_sugar = sugar;
              temp_water = water;
              // cout << dense << ' ' << sugar <<' '<< water << endl;
            }
          }
        }
      }
    }
  }
  std::cout << temp_water+temp_sugar <<' '<<temp_sugar << '\n';
}


Measured memory_bytes: 256
N = int(input())
a_list = list(map(int,input().split()))

total_sum = sum(a_list)
a_list = sorted(a_list,reverse=True)

a_sum = 0
for i in range(0,len(a_list),2):
    a_sum += a_list[i]

print(a_sum - total_sum + a_sum)


Measured memory_bytes: 2940
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<int,int> P;
ll longinf=1ll<<60;
int inf=1<<29;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
int dh[4]={0,1,0,-1};
int dw[4]={1,0,-1,0};

ll comb[52][52];

void calc(){
      rep0(i,51){
            comb[i][0]=1;
            comb[i][i]=1;
      }
      rep1(i,51){
            REP(j,1,i){
                  comb[i][j]=comb[i-1][j-1]+comb[i-1][j];
            }
      }
}

ll n;
ll a,b;
ll v[50];
int main (){
      calc();
      cin>>n>>a>>b;
      rep0(i,n) cin>>v[i];
      sort(v,v+n);
      reverse(v,v+n);
      ll wa=0;
      rep0(i,a){
            wa+=v[i];
      }
      cout<<shosu<<((double)wa)/((double)a)<<endl;
      bool ok=true;
      ll ans=0;
      ll hoge=v[a-1];
      ll cnt=0;
      ll usemin=0;
      if(v[0]!=hoge) ok=false;
      rep0(i,n){
            if(v[i]==hoge){
                  if(i<a) usemin++;
                  cnt++;
            }
      }
      ans+=comb[cnt][usemin];
      if(ok){
            for(int i=usemin;i<min(b,cnt);i++){
                  ans+=comb[cnt][i+1];
            }
      }
      cout<<ans<<endl;

      return 0;
}


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

const int MAXN = 302;

double dp[MAXN][MAXN][MAXN];
int N,vis[MAXN][MAXN][MAXN];

double solve(int x,int y,int z)
{
	if(vis[x][y][z]) return dp[x][y][z];
	vis[x][y][z] = 1;
	if(x == 0 && y == 0 && z == 0) return dp[x][y][z] = 0;
	int soma = x + y + z;
	double convertido = (double)soma;
	double tot = (N - soma)/convertido;

	if(x != 0) tot += x*((solve(x-1,y,z) + 1)/convertido);
	if(y != 0) tot += y*((solve(x+1,y-1,z) + 1)/convertido);
	if(z != 0) tot += z*((solve(x,y+1,z-1) + 1)/convertido);
  
	return dp[x][y][z] = tot;
}

int main()
{

	int a[4] = {0,0,0,0};
	cin >> N;
	for(int i = 1;i<=N;i++){
		int x;
		cin >> x;
		a[x]++;
	}
	printf("%.9lf\n",solve(a[1],a[2],a[3]));
}

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

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define mod 1000000007
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.1415926535897932384626
#define bits(n) __builtin_popcount(n)

void solve()
{
    ll n, k;
    cin >> n >> k;
    ll a[n];
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (ll i = k; i < n; i++)
    {
        if (a[i] > a[i - k])
        {
            cout << "Yes\n";
        }
        else
        {
            cout << "No\n";
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; i++)
    {
        solve();
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<ll,ll> pll;
typedef pair<int, int> pii;

#define REP(i, a, n) for(ll i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lwb lower_bound
#define N 100010
#define M 200010
#define endl "\n"

ll gcd(ll a_,ll b_){if(b_>a_)swap(b_,a_);return (b_==0?a_:gcd(b_,a_%b_));}		

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	int n, arr[N], curr;
	
	cin >> n;
	REP(i, 0, n){
		cin >> arr[i];
	}
	
	bool ans = true;
	
	arr[0] -= 1;
	curr = arr[0];
	
	REP(i, 1, n){
		if(arr[i] > curr){
			arr[i] -= 1;
		}
		curr = arr[i];
	}
	
	REP(i, 1, n){
		if(arr[i] < arr[i - 1]){
			ans = false;
			break;
		}
	}
	
	if(ans){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <algorithm>
#define INF (1 << 24)
#define NMAX 100
#define TSIZE (NMAX + 1)
using namespace std;

int main() {
  int cost[TSIZE][TSIZE];
  int n, m, s, g1, g2;
  int b1, b2, c;
  while (cin >> n >> m >> s >> g1 >> g2, n | m | s | g1 | g2) {
    fill_n((int*)cost, TSIZE * TSIZE, INF);
    for (int i = 1; i < TSIZE; i++) {
      cost[i][i] = 0;
    }

    for (int i = 0; i < m; i++) {
      cin >> b1 >> b2 >> c;
      cost[b1][b2] = c;
    }

    for (int k = 1; k < TSIZE; k++) {
      for (int i = 1; i < TSIZE; i++) {
        for (int j = 1; j < TSIZE; j++) {
          cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
        }
      }
    }

    int res = INF;
    for (int k = 1; k < TSIZE; k++) {
      res = min(res, cost[s][k] + cost[k][g1] + cost[k][g2]);
    }
    cout << res << endl;
  }
  return 0;
}

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

using namespace std;

int main()
{
    int n,a,b,i,j;
    cin >> n >> a >> b;
    vector<int> ans(n,0);
    for(i=0;i<n; i++){
        for(j=i+1; j<n; j++) {
            ans[min(j-i, abs(i-a+1)+1+abs(j-b+1))]++;
        }
    }
    for(i=1 ;i<n ;i++)
    cout << ans[i] << endl;
    return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = null;

		if((str = br.readLine()) != null){

			str = str.toUpperCase();
		}

		System.out.println(str);

	}
}

Measured memory_bytes: 24004
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#define int long long
//template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
//template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }

long long POW(long long x, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 1) return (x * POW(x, n - 1));
    long long t = POW(x, n / 2);
    return (t * t);
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<long long> A(N);
    vector<long long> sum(N+1, 0);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum[i+1] = sum[i] + A[i];
    }
    
    vector<long long> B;
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j <= N; j++) {
            B.emplace_back(sum[j] - sum[i]);
        }
    }
    
    
    int M = B.size();
    long long ans = 0;
    vector<bool> ok(M, true);
    
    
    for (int s = 63; s >= 0; s--) {
        long long bit = (1LL<<s);
        int cnt = 0;
        for (int i = 0; i < M; i++) if (ok[i]) {
            if (bit&B[i]) cnt++;
        }
        if (K <= cnt) {
            for (int i = 0; i < M; i++) if (ok[i]) {
                if (!(bit&B[i])) ok[i] = false;
            }
            ans += bit;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6260
//Dividing a String

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define nxvarep(n,x,a) ll n,x;cin>>n>>x;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<ll,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    string s;cin>>s;
    string rec=s.substr(0,1);
    ll ans = 1;
    rep(i,1,s.size()){
        if(i==s.size()-2&&s.substr(s.size()-2,1)==s.substr(s.size()-1,1)){
            ans++;
            break;
        }
        if(rec==s.substr(i,1)){
            rec=s.substr(i,2);
            i++;
            ans++;
        }else{
            rec=s.substr(i,1);
            ans++;
        }
    }
    cout<<ans<<nnn;    
    return 0;
}

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

#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

using namespace std;

template<class T>
class fenwick_tree {
private:
    const size_t size;
    const std::function<T(T, T)> f;
    const T unit;
    std::vector<T> a;
public:
    fenwick_tree(size_t size, std::function<T(T, T)> f, T unit) : size(size), f(f), unit(unit), a(size, unit) { }

    void update(size_t i, T x) {
        for (size_t j = i; j < size; j |= j + 1) {
            a[j] = f(a[j], x);
        }
    }

    T query(size_t i) const {
        T result = unit;
        for (size_t j = i; j > 0; j = (j & (j + 1))) {
            result = f(result, a[--j]);
        }
        return result;
    }
};

template <class T>
class range_add_sum_query {
private:
    fenwick_tree<T> fenwick_1;
    fenwick_tree<T> fenwick_2;
public:
    range_add_sum_query(size_t n) : fenwick_1(n + 1, [](T x, T y) { return x + y; }, 0),
                                    fenwick_2(n + 1, [](T x, T y) { return x + y; }, 0) { }

    void update(size_t first, size_t last, T x) {
        fenwick_1.update(first, x);
        fenwick_1.update(last, -x);
        fenwick_2.update(first, first * x);
        fenwick_2.update(last, -last * x);
    }

    T query(size_t last) const {
        return fenwick_1.query(last) * last - fenwick_2.query(last);
    }

    T query(size_t first, size_t last) const {
        return query(last) - query(first);
    }
};

int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, Q;
    cin >> N >> Q;
    vector<int> c(N);
    REP(i, N) {
        cin >> c[i];
        --c[i];
    }
    vector<int> l(Q), r(Q);
    vector<vector<int>> li(N);
    REP(i, Q) {
        cin >> l[i] >> r[i];
        --l[i];
        li[l[i]].push_back(i);
    }

    vector<int> result(Q);
    range_add_sum_query<int> rasq(N);
    vector<int> last(N, N);

    RREP(L, N) {
        rasq.update(L, last[c[L]], 1);
        last[c[L]] = L;
        for (int i: li[L]) {
            result[i] = rasq.query(r[i] - 1, r[i]);
        }
    }

    REP(i, Q) {
        cout << result[i] << '\n';
    }
    cout << flush;

    return 0;
}


Measured memory_bytes: 38128
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(ll int i=a;i<=b;++i)
#define rep(i,n) for(ll int i=0;i<n;i++)
#define pii pair<int,int>
#define ti3 tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
ll int MOD=998244353;
#define N 3000000
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");
int n;
ll int a[51];

bool check(ll int m){
    ll int b=n-1-m;
    ll int res=0;
    rep(i,n){
        res+=max((ll)0,(a[i]-b+n)/(n+1));
    }
    return (res<=m);
}
main(){
    cin>>n;
    rep(i,n){
        cin>>a[i];
    }
    ll int sum=0;
    rep(i,n){
        sum+=a[i]-n+1;
    }
  	sum=max(sum,(ll)0);
    rep2(i,sum,sum+n*n){
        if(check(i)){
            cout<<i; return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <math.h>
using namespace std;

int main(void){
    double r;
    cin>>r;
    
    //cout<<r*r*M_PI<<" "<<r*2*M_PI<<endl;
    printf("%f %f\n",r*r*M_PI,r*2*M_PI);
    
    return 0;
}


Measured memory_bytes: 3128
#include <iostream>
using namespace std;
int a[100010];
long long num[100010],t[100010],sum[100010];
int main(){
    int n,k;
    long long ans=0;
    cin>>n>>k;
    int i;
    for(i=1;i<=n;i++)cin>>a[i];
    for(i=1;i<=n;i++)sum[i]=sum[i-1]+a[i];
    for(i=1;i<=n;i++)num[i]=num[i-1]+max(a[i],0);
    for(i=n;i>=1;i--)t[i]=t[i+1]+max(a[i],0);
    for(i=0;i<=n-k;i++)
    ans=max(ans,num[i]+t[i+k+1]+max(sum[i+k]-sum[i],0LL));
    cout<<ans<<endl;
    return 0;
}


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

A = sorted(A, reverse = True)

B = [A[0]] + [A[i] for i in range(1,N)] * 2

B = sorted(B, reverse = True)

ans = 0

for i in range(N - 1):
   ans +=  B[i]
print(ans)

Measured memory_bytes: 31628