akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define len(n) (int)n.length()
#define pb push_back
#define ll long long
#define make_pair mkp
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n-1;i >= 0;i--)
#define ALL(v) (v).begin(), (v).end()
#ifdef DBGPRT
#define dbg(n) cerr << "//" << #n << ":" << n <<endl
#else
#define dbg(n) ;
#endif
typedef pair<ll, ll> LLARR;
#define INF 999999999
const double PI = 3.1415926535897932384626433832795;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
	ios::sync_with_stdio(false);

	set<ll> st;
	int N;
	cin >> N;
	REP(i,N)
	{
		ll a; cin >> a;
		auto r = st.insert(a);
		if (!r.second)
		{
			st.erase(a);
		}
	}
	cout << st.size() << endl;
	return 0;
}

Measured memory_bytes: 4992
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};

int n, d, a;
// int *x, *h;

class monster {
public:
	LL x, h;
	monster(LL _x, LL _h): x(_x), h(_h) {}
};

bool cmp(const monster &a, const monster &b) {
	return a.x < b.x;
}



int main() {
	scanf("%d%d%d", &n, &d, &a);
	vector<monster> ms;
	// x = new int[n + 10];
	// h = new int[n + 10];
	int x, h;
	for (int i = 0; i < n; ++i) {
		scanf("%d%d", &x, &h);
		ms.push_back(monster((LL)(x), (LL)(h)));
		// scanf("%d%d", &x[i], &h[i]);
	}
	sort(ms.begin(), ms.end(), cmp);
	LL res = 0;

	int cur = 0;

	vector<int> cuts;
	vector<int> cutn;

	cuts.clear();
	cutn.clear();
	int cc = 0;
	LL total = 0;

	for (int i = 0; i < ms.size(); ++i) {
		while (cc < cuts.size() && cuts[cc] <= i) {
			total -= cutn[cc];
			++cc;
		}
		ms[i].h -= (total * a);
		if (ms[i].h <= 0) {
			continue;
		}
		// cout << ms[i].h << endl;
		LL ks = (ms[i].h + a - 1) / a;
		res += ks;
		LL cx = ms[i].x + (LL)(2 * d);
		// cout << (ms[i].x + d) << ' ' << ks << endl;
		while (cur < ms.size() && ms[cur].x <= cx) {
			++cur;
		}
		// printf("i = %d, cur = %d\n", i, cur);
		/*for (int j = i; j < cur; ++j) {
			ms[j].h -= (ks * a);
		}*/
		total += ks;
		cuts.push_back(cur);
		cutn.push_back(ks);
	}

	cout << res << endl;
	return 0;
}

Measured memory_bytes: 6636
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

long long int mod=1000000007;


long long int n,k,q,a[2300],b[5000],res,sum[2300]={},key=0;
queue<pair<long long ,long long > >que;
int main() {
    const long long int INF=99999999999999;
	map<long long int, long long int>mp;
    string str[550],red[550],blue[550];
    priority_queue<long long int,vector<long long int>,greater<long long int> >pq,tmp;

	cout << fixed << setprecision(10);
    cin>>n>>k>>q;
    
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    for(int i=n;i<=4500;i++){
        b[i]=INF;
    }
    res=INF;
    long long int now=-1,need=0;
    for(int i=0;i<n;i++){
        need=0;
        now=-1;
        
        key=0;
        for(int j=0;j<n;j++){
            if(a[j]<b[i]){
                for(int i=now+1;i<j;i++){
                    tmp.push(a[i]);
                    
                
                }
                for(int i=1;i<=j-now-1-k+1;i++){
                    pq.push(tmp.top());
                    tmp.pop();
                
                }
                while(!tmp.empty()){
                    tmp.pop();
                }
                now=j;
                
            }
            
        }
        for(int i=now+1;i<n;i++){
            tmp.push(a[i]);
            
        
        }
        for(int i=1;i<=n-now-1-k+1;i++){
            pq.push(tmp.top());
            tmp.pop();
        
        }
        while(!tmp.empty()){
            tmp.pop();
        }

        if(pq.size()<q){break;}
        for(int i=0;i<q-1;i++){
            pq.pop();
        }
        res=min(res,pq.top()-b[i]);
        
        while(!pq.empty()){
            pq.pop();
        }
        //cout<<i<<" "<<res<<" "<<need<<endl;
        

    }
    
    cout<<res<<endl;
    
} 


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

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

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

    ll N;
    cin >> N;
    Rep (i, N) {
        for (ll j = i+1; j < N; j++) {
            for (ll k = 10; k >= 0; k--) {
                if ((i >> k) != (j >> k)) {
                    cout << k+1 << " \n"[j==N-1];
                    break;
                }
            }
        }
    }
}

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

const int N = 18;
const int V = 50;
const int inf = 1e15;
int dp[(1 << N)][V + 1];
int a[N];
int b[N];
int off[N][N];

void solve()
{
	int n; cin >> 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++)
	{
		for(int j=0; j<n; j++)
		{
			off[i][j] = (i%2 == j%2) ? a[j] : b[j]; 	// (shifting from index j to index i)
		}
	}
	int h = (1 << n); 
	for(int m=0; m<h; m++)
	{
		for(int j=0; j<=V; j++)
		{
			dp[m][j] = inf;
		}
	}
	dp[0][0] = 0;
	for(int m=0; m<h; m++)
	{
		int i = __builtin_popcount(m); // i -> first i positions have been filled elements p_j where j_th bit = 1 in M
		for(int v=0; v<=V; v++) // Last value being v (i.e. value of (i - 1)th index)
		{
			int d = 0;				// how much j_th index is to be shifted after I set indices have been positioned at the begining
			for(int j=0; j<n; j++)
			{
				if(m & (1<<j)) continue;  // if used already, move on
				if(off[i][j] >= v)
				{
					dp[m | (1 << j)][off[i][j]] = min(dp[m | (1 << j)][off[i][j]], dp[m][v] + d);
				}
				d++;
			}
		}
	}
	int ans = inf;
	for(int i=0; i<=V; i++) ans = min(ans, dp[h-1][i]);
	if(ans == inf) { cout << -1 << endl; return; }
	cout << ans << endl;
}

signed main()
{	
	int T = 1; 
	// cin >> T;
	while(T--)
		solve();
	return 0;
}

// mango_lassi

Measured memory_bytes: 104704
import numpy as np

def main():

    test = input()
    if test[0] != "A":
        print("WA")
        return

    if test[:-1][2:].count("C") != 1:
        print("WA")
        return

    for i in range(len(test)):
        if i == 0 and test[i] == "A": continue
        if 2 <= i <= len(test) - 2 and test[i] == "C": continue

        if test[i].lower() != test[i]:
            print("WA")
            return

    print("AC")







if __name__ == "__main__":
    main()

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

def main():
    D, G = map(int, input().split())
    p = [None] * D
    c = [None] * D
    for i in range(D):
        p[i], c[i] = map(int, input().split())
    
    ans = 10**18
    for i in range(2**D):
        tmp = 0
        score = 0
        k = 0
        for j in range(D):
            if (i >> j) & 1:
                score += p[j]*100*(j+1) + c[j]
                tmp += p[j]
            else:
                k = j
        tmp2 = 0
        while score < G and tmp2 < p[k]:
            score += 100 * (k+1)
            tmp2 += 1
        if score >= G:
            ans = min(ans,tmp+tmp2)
            # print(i,tmp,score)
    print(ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>                                                   //---------------------------------------------------------------
                                                                    
# define ll long long   
# define ld long double                                               
# define mod 1000000007                                                   
# define MAX 100005
# define pi 3.141592653589793238                                                                                  //shortcut keys
                                                                                
# define pb push_back                                                                     
# define mp make_pair                                                     
                                                                  
# define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);        //---------------------------------------------------------------                                       
using namespace std;
int main()
{
    ll k,n;
    cin>>k>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    {
    	cin>>a[i];
	}
	ll sum=0;ll b[n];
	for(ll i=1;i<n;i++)
	{
		b[i-1]=a[i]-a[i-1];
		sum+=b[i-1];
	}
	b[n-1]=k-a[n-1]+a[0]-0;
	sum+=b[n-1];
	ll ans=sum;
	for(ll i=0;i<n;i++)
	{
		ans=min(ans,sum-b[i]);
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 3328
import sys
input = sys.stdin.readline

def dfs_numbering(st, M, V, ANS, cnt, v):
    ST = [st]
    while len(ST) > 0:
        i = ST[-1]
        if ANS[i] == -1:
            V[i] = v
            end = 1
            for x in M[i]:
                if V[x] == -1:
                    ST.append(x)
                    end = 0
            if end == 1:
                ST.pop()
                ANS[i] = cnt
                cnt += 1
        else:
            ST.pop()
    return cnt

class scc():
    def __init__(self, n):
        self.n = n
        self.M = [[] for i in range(n)]
        self.IM = [[] for i in range(n)]

    def add_edge(self, frm, to):
        self.M[frm].append(to)
        self.IM[to].append(frm)

    def scc_list(self):
        n = self.n
        V = [-1] * n
        ANS = [-1] * n

        cnt = 0
        for i in range(n):
            if V[i] == -1:
                cnt = dfs_numbering(i, self.M, V, ANS, cnt, 0)

        ANS1 = [[ANS[i], i] for i in range(n)]
        ANS1.sort(reverse=True)

        V = [-1] * n
        ANS = [-1] * n
        v = 0
        for i in range(n):
            if V[ANS1[i][1]] == -1:
                dfs_numbering(ANS1[i][1], self.IM, V, ANS, 0, v)
                v += 1

        FANS = [[] for i in range(v)]
        for i in range(n):
            FANS[V[i]].append(i)

        return FANS

n, m = map(int,input().split())

S = scc(n)
for i in range(m):
    frm, to = map(int,input().split())
    S.add_edge(frm, to)
ANS = S.scc_list()

print(len(ANS))
for i in range(len(ANS)):
    print(len(ANS[i]), end=" ")
    print(*ANS[i])

Measured memory_bytes: 270144
#include<bits/stdc++.h>
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define int long long
// #define mod 998244353 
#define pb push_back
#define mb make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod = 1e9+7;
int mat[51][51],mat2[51][51],mat3[51][51];
void matmul(int flag ,int n){
	if(flag){
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++){
				int f = 0;
				mat3[i][j] = 0;
				for(int k=0;k<n;k++){
					mat3[i][j]+=(mat2[i][k]*mat[k][j]);
					mat3[i][j]%=mod;
				}
				// mat2[i][j] = f;
			}
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				mat2[i][j] = mat3[i][j];
	}
	else{
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				int f = 0;
				mat3[i][j]=0;
				for(int k=0;k<n;k++){
					mat3[i][j]+=(mat[i][k]*mat[k][j]);
					mat3[i][j]%=mod;
				}
				
			}
		}
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				mat[i][j] = mat3[i][j];
	}
}
void mul(int n,int k){
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			mat2[i][j] = (i==j);
	int p = k;
	while(p){
		if(p%2)
			matmul(1,n);
		matmul(0,n);
		p/=2;
	}
}
signed main(){
	IOS;
	int n,k; cin >> n >> k;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			cin >> mat[i][j];

	mul(n,k);
	int ans = 0;
	for(int i = 0 ; i < n ; i++)
		for(int j  =0 ;j < n ; j ++){
			ans += mat2[i][j];
			ans%=mod;
		}

	cout << ans << endl;





	return 0;
}




Measured memory_bytes: 384
import math
a,b,x = map(int,input().split())
if x > b*(a**2)/2:
  print(math.atan((2*b*a**2 - 2*x)/a**3) * (180/math.pi))
else:
  print((180/math.pi)*math.atan((a*b**2)/(2*x)))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;

const int N = 1e5+6;
int n, dist, x[N], right[N], st[20][N];

int jump(int pos, int x){
	for (int i=19; i>=0; i--){
		if ((x>>i)&1) pos = st[i][pos];
	}
	return pos;
}

signed main(){
	cin >> n;
	for (int i=1; i<=n; i++) cin >> x[i];
	cin >> dist;
	for (int i=1; i<=n; i++){
		int l = upper_bound(x+1, x+n+1, x[i]+dist)-x-1;
		st[0][i] = l;
	}
	for (int i=1; i<20; i++){
		for (int j=1; j<=n; j++){
			st[i][j] = st[i-1][st[i-1][j]];
		}
	}
	int q; cin >> q;
	while (q--){
		int u, v; cin >> u >> v;
		if (u>v) swap(u, v);
		int l = 0, r = n;
		while (l!=r){
			int mid = (l+r)>>1;
			if (jump(u, mid)>=v) r = mid;
			else l = mid+1;
		}
		cout << l << endl;
	}
}

Measured memory_bytes: 20044
X,Y,A,B,C=gets.split.map(&:to_i)
ps=gets.split.map(&:to_i)
qs=gets.split.map(&:to_i)
rs=gets.split.map(&:to_i).sort_by { |a | -a  }

ps = ps.sort_by { |a | -a }[0..X-1]
qs = qs.sort_by { |a | -a }[0..Y-1]
arr = (ps + qs).sort

i = 0
while i < arr.length && rs[i]
  if arr[i] < rs[i]
    arr[i] = rs[i]
  else
    break
  end
  i += 1
end

ret = arr.inject(&:+)
p ret


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

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define pb push_back
#define ff first
#define ss second
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

using ll = long long int;
using ld = long double;
using vi = vector<int>;
using mii = map<int, int>;
using pii = pair<int, int>;

const int inf = 1e9;
const int N = 100005;
const ll mod = (ll) 1e9 + 7;

ll power(ll a, ll n){
	ll res = 1;
	a %= mod;

	while(n){
		if(n & 1)
			res = res * a % mod;

		n >>= 1;
		a = a * a % mod;
	}
	return res;
}

ll dp[2005];

ll solve(int n){
	ll &res = dp[n];
	if(res != -1)
		return res;

	if(n == 0)
		return 1;

	ll ans = 0;
	for(int i = 3; ; i++){
		if(n - i < 0)
			break;

		ans += solve(n - i);
		ans %= mod;
	}

	return res = ans;
}
int32_t main(){
	fio;

	int n;
	cin >> n;
	memset(dp, -1, sizeof dp);
	if(n < 3){
		cout << 0 << '\n';
		return 0;
	}
	ll ans = solve(n);
	cout << ans << '\n';
	return 0;
}

/*

 */


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N;
  cin>>N;
  vector<vector<pair<int,int>>> A(N);
  for(int i=0;i<N-1;i++){
    int a,b,c;
    cin>>a>>b>>c;
    A[a-1].push_back(make_pair(b-1,c));
    A[b-1].push_back(make_pair(a-1,c));
  }
  int Q,K;
  cin>>Q>>K;
  vector<int> B(N,-1);
  B[K-1]=0;
  queue<int> C;
  C.push(K-1);
  while(!C.empty()){
    int I=C.front();
    C.pop();
    for(pair<int,int> p:A[I])
      if(B[p.first]==-1){
        B[p.first]=B[I]+p.second;
        C.push(p.first);
      }
  }
  while(Q--){
    int x,y;
    cin>>x>>y;
    cout<<B[x-1]+B[y-1]<<endl;
  }
}

Measured memory_bytes: 11800
#include <bits/stdc++.h>
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define deb(x) cout<<#x<<" "<<endl;

 
using namespace std;

 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
//-------------------------------------------------------------------------------





int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	
		int n; cin>>n;
		int k;cin>>k;
		vi h(n+1);
		vi dp(n+1,INT_MAX);
		for(int i=1;i<=n;++i){
			cin>>h[i];
		}
		dp[1]=0;
		dp[2]=abs(h[2]-h[1]);
		for(int i=3;i<=n;++i){
			for(int j=1;j<=k;++j){
				if(i-j>0){
					dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
				}

			}
		}
		cout<<dp[n]<<endl;
	

}
 

Measured memory_bytes: 1024
N, A, B, C, D = [int(_) for _ in input().split()]
S = input()

if "##" in S[A-1:C] or "##" in S[B-1:D]:
    print("No")
elif C < D:
    print("Yes")
elif "..." in S[B-2:D+1]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9404
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    std::vector<ll> a(n);
    for ( int i = 0; i < n; i++ ) {
        cin >> a[i];
    }
    int pre = -999;
    for ( int i = 0; i < n; i++ ) {
        if ( pre <= a[i] - 1 ) {
            pre = a[i] - 1;
        }
        else if ( pre <= a[i] ) {
            pre = a[i];
        }
        else  {
            puts("No");
            return 0;
        }
    }

    puts("Yes");
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 200200;
typedef long long ll;
const int mod = 998244353;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
int a[maxn];
int b[maxn];
int cnt[maxn];
std::vector<int> v;
int n;
ll ans;
inline void dfs(int x) {
	if(x + x + x > n) {
		ll s = 0;
		rep(i, 1, n) s += b[i];
		for(int i = x;i + i <= n;++i) if(b[i] + b[i + i] < 0) s -= b[i] + b[i + i];
		if(s > ans) ans = s;
		return ;
	}
	for(int i : v) if(x % i == 0) {
		return dfs(x + 1);
	}
	for(int i = x;i <= n;i += x) ++ cnt[i], b[i] = 0;
	v.push_back(x);
	dfs(x + 1);
	for(int i = x;i <= n;i += x) if(!--cnt[i]) b[i] = a[i];
	v.pop_back();
	dfs(x + 1);
}
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	rep(i, 1, n) {
		cin >> a[i];
		if(i + i > n && a[i] < 0) a[i] = 0;
		b[i] = a[i];
	}
	ans = -1e18;
	dfs(1);
	cout << ans << '\n';
}


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

using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);



 int main(){

    IOS;
  
   #ifndef ONLINE_JUDGE
     freopen("input1.txt","r",stdin);
     freopen("output1.txt","w",stdout);
   #endif


    //int t;
    //cin>>t;
    //while(t--)
    {
      int n,count=0,max=0,j;
      long ans=0;
    
      
      string s;
        cin>>s;

      n=s.length();  

      for (int i = 0; i < n; ++i)
      {
        count=0;
        if(s[i]=='R')
        {
          for (j = i; j < n; ++j)
          {
            count++;
            if(s[j]=='S'){
              
              count--;
              break;
            }

          }
          
          if(count>max)
          max=count;
        i=j;
          
        }
      }
  cout<<max;    


    }
   

   return 0;
 }   


Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	int tmp = 0;
	deque<int>A;
	while (cin >> tmp) {
		if (tmp == 0) {
			cout << A.front() << endl;
			A.pop_front();
		}
		else {
			A.push_front(tmp);
		}
	}
}


Measured memory_bytes: 2996
#![allow(unused_imports)]
#![allow(dead_code)]

use std::thread;
use std::io::{ self, Read };
use std::fmt;
use std::iter::Iterator;
use std::cmp::*;
use std::collections::*;
use std::str::*;

#[derive(Default)]
struct Input {
    buf: Vec<String>
}

impl Input {
    fn new() -> Input {
        Input { buf: Vec::new() }
    }

    fn read<T: FromStr>(&mut self) -> T 
    where <T as FromStr>::Err: fmt::Debug {
        self.next().unwrap().parse::<T>().unwrap()
    }

    fn read_bytes(&mut self) -> Vec<u8> {
        self.next().unwrap().into_bytes()
    }

    fn read_n<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where <T as FromStr>::Err: fmt::Debug {
        let mut v = Vec::new();
        for _ in 0..n { v.push(self.read::<T>()); }
        v
    }
}

impl Iterator for Input {
    type Item = String;
    fn next(&mut self) -> Option<String> {
        while self.buf.is_empty() {
            let mut s = String::new();
            let _res = io::stdin().read_line(&mut s);
            self.buf = s.split_whitespace().map(|s| s.to_owned()).collect::<Vec<_>>();
            self.buf.reverse();
        }
        self.buf.pop()
    }
}

struct UnionFind {
    c: Vec<(usize, usize)>
}

impl UnionFind {
    fn new(n: usize) -> UnionFind {
        UnionFind { c: (0..n).map(|u| (u, 1)).collect::<Vec<_>>() }
    }

    fn root(&self, u: usize) -> usize {
        let v = self.c[u].0;
        if u == v { u } else { self.root(v) }
    }

    fn is_same(&self, u: usize, v: usize) -> bool {
        self.root(u) == self.root(v)
    }

    fn size(&self, u: usize) -> usize {
        self.c[u].1
    }

    fn unite(&mut self, u: usize, v: usize) {
        let ru = self.root(u);
        let rv = self.root(v);
        let su = self.size(u);
        let sv = self.size(v);
        if su > sv {
            self.c[rv] = (ru, su + sv);
        } else {
            self.c[ru] = (rv, su + sv);
        }
    }
}

fn run() {
    let mut ip = Input::new();
    let n = ip.read::<usize>();
    let m = ip.read::<usize>();
    let mut p = ip.read_n::<usize>(n);
    p.insert(0, 0);
    let mut uf = UnionFind::new(n + 1);
    for _ in 0..m {
        let u = ip.read::<usize>();
        let v = ip.read::<usize>();
        uf.unite(u, v);
    }
    let mut s = 0;
    for u in 1..n + 1 {
        if uf.is_same(u, p[u]) {
            s += 1;
        }
    }
    println!("{}", s);
}

fn main() {
    let _ = thread::Builder::new()
        .stack_size(10 * 1024 * 1024)
        .spawn(run).unwrap()
        .join();
}

Measured memory_bytes: 14588
import java.util.*;

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

        int N = sc.nextInt();
        int max = 0;
        int ans = 0;

        for(int i=1; i<=N; i++){
            int x = i;
            int y = 0;
            for(int j=1; j<=100; j++){
                if(x%2!=0){
                    break;
                }
                else{
                    x = x / 2;
                    y += 1;
                }
            }
            max = Math.max(max, y);
            if(max==y){
                ans = i;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
 
#define sec second
#define fir first
#define mo  998244353
#define inf 1e18
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rrep(i,s,n) for(ll i=s;i>=n;i--)
#define adiii\                               
  ios_base::sync_with_stdio(false);\                                      
  cin.tie(NULL);\
  cout.tie(NULL);									
 
ll mod(ll n) { return (n % (ll)mo + (ll)mo)%(ll)mo;}
ll gcd(ll a,ll b) {if (b == 0) return a;return gcd(b, a % b);}

int main(){
	adiii
	ll n;cin>>n;
	using p = pair<ll,ll>;
	vector <p> a;
	rep(i,1,n+1) {ll x;cin>>x;a.pb({x,i});}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	ll dp[n+5][n+5];
	memset(dp,0,sizeof(dp));
	ll ans = 0;
	rep(x,0,n+1){
		rep(y,0,n-x+1){
			
			//if(x+y+1<=n){
				ll nxt_val = a[x+y].first;
				ll nxt_idx = a[x+y].second;
				dp[x+1][y] = max(dp[x+1][y],dp[x][y] + nxt_val*(nxt_idx) - nxt_val*(x+1));
				dp[x][y+1] = max(dp[x][y+1],dp[x][y] - nxt_val*(nxt_idx) + nxt_val*(n - (y)));
				//cout<<x<<" "<<y<<" "<<dp[x+1][y]<<" "<<dp[x][y+1]<<endl;
				ans = max(ans,dp[x+1][y]);
				ans = max(ans,dp[x][y+1]);
				
			//} 
			//ans = max(ans,dp[x][y]);
		
		}
	}
	
	
    cout<<ans<<endl;
    
}


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

int main() {
  long long a,b,k,l;
  cin>>a>>b;
  k=a;
  l=b;
  while(k!=l){
    if(k>l)k-=l;
    else if(k<l) l-=k;
  }
  cout<<a*b/k<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
const int MAXN = 2005;
const int MOD = 1e9+7;
int bc[MAXN][MAXN];
int K, N;
int N1;

void init() {
  int end = N + 1;
  bc[0][0] = 1;
  for (int i = 1; i <= end; ++i) {
    bc[i][0] = 1;
    for (int j = 1; j <= i; ++j) {
      bc[i][j] = (1LL * bc[i-1][j-1] + bc[i-1][j]) % MOD;
    }
  }
}

// Stars and Bars:
// Split K balls into i non-empty piles [K-1 choose i-1]
// Intersperse i piles between the N-K balls [N-K+1 choose i]

int main() {
  scanf(" %d%d", &N, &K);
  init();
  for (int i = 1; i <= K; ++i) {
    int res = 1LL * bc[K-1][i-1] * bc[N-K+1][i] % MOD;
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 14976
function main(input) {
  input=input.trim();
  const a = input.split(" ")[0];
  const b = input.split(" ")[1];
  if((a=="H"&&b=="H") || (a=="D"&&b=="D")){
    console.log("H");
  }else{
    console.log("D");
  }
}



main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>


using namespace std;

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

const ll mod = 1000000007;


//逆元
// b / a ≡ b * invers(a,n) % n (mod n)
ll modinv(ll a, ll m) {
   	ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}


ll modpow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) { 
            res *= x;
            res %= mod;
        }
        x *= x;
        x %= mod;
        n >>= 1;
    }
    return res;
}


ll nCr(ll n, ll r) {
	ll ans = 1;

	for (int i = 0; i < r; i++) {
		ans = (ans * (n - i)) % mod;
		//cout << "ans:" << ans << " n-r:"<< n - r << endl;
		ans = ans * modinv(r - i, mod) % mod;
		//cout << "ans:" << ans << " n-i:"<< n - i << endl;
	}
	return ans;
}


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

	ll whole = modpow(2, n, mod) - 1;

	ll ac =  nCr(n, a);
	ll bc = nCr(n, b);
	cout << (whole + mod * 2 - ac- bc) % mod << endl; 

	return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() 
{
	ll n,m,k; cin>>n>>m>>k;
	vector<ll>pref(n);

	ll ar[n];
	for(int i=0;i<n;i++)
	{
		cin>>ar[i];
	}
	ll mx=0;
	pref[0]=ar[0];
	if(ar[0]<=k)
	{
		mx=1;
	}
	for(int i=1;i<n;i++)
	{
		pref[i]=pref[i-1]+ar[i];
		if(pref[i]<=k)
		{
			mx=max(mx,(ll)i+1);
		}
	}
	ll sm=0;
	
	for(int i=0;i<m;i++)
	{
	
		ll x; cin>>x;
		if(sm<=k){mx=max(mx,(ll)i);}
		sm+=x;
		if(sm<=k){
		ll it=upper_bound(pref.begin(),pref.end(),k-sm)-pref.begin();
        if(it<=n){
        ll value=i+it+1;
		mx=max(mx,value);
        }
		}
		
		
		
	}
	cout<<mx;
	
	
	
	
	
	
	
}


Measured memory_bytes: 6376
#include<bits/stdc++.h>
using namespace std;
#define ar array
#define endl '\n'
#define ll long long
#define in insert
#define pb push_back
#define vt vector
#define P_Q(x) priority_queue<x>
#define p_q(x) priority_queue<x, vector<x>, greater<x>>
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(ll i=a;i>=b;i--)
#define FOR(m) Rep(i,1,m)
#define For(m) Rep(i,0,m-1)
#define Rbl(x,a) for(auto &x : a)
#define FIO ios::sync_with_stdio(0);   cin.tie(0);
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define vpii vector<pii>
#define vpll vector<pll>
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
const ll INF = 0x3f3f3f3f3f3f3f3fll;
#define mod 1000000007
 
const int mxN = 100 + 1;
ll x, k, d;
 
 
int main()
{
FIO
    cin >> x >> k >> d;
    ll diff = abs(x);
    ll take = min(diff/d, k);
    k -= take;
    if(x > 0)
        x -= d * take;
    else
        x += d * take;
    // cout << x << " " << k << endl;
    if(k % 2)
        if(x > 0)
            cout << d-x;
        else
            cout << x+d;
    else
        cout << abs(x);
    
}

Measured memory_bytes: 3624
n, q = gets.split.map(&:to_i)
s = gets.chomp
array = Array.new(n, 0)
(0..n-2).each do |i|
  array[i+1] = array[i]
  if s[i..i+1] == 'AC'
    array[i+1] += 1
  end
end

q.times do
  l, r = gets.split.map(&:to_i)
  puts array[r-1] - array[l-1]
end

Measured memory_bytes: 3324
#include <stdio.h>
const int N = 15;
int main() {
    int a[N] = {0};
    int i, j, tmp;
    for(i = 0; i < 10; i++)
    {
        scanf("%d", &a[i]);
    }
    for(i = 0; i < 10; i++)
    {
        for(j = i; j < 10; j++)
        {
            if(a[i] < a[j])
            {
                tmp = a[i];
                a[i] = a[j];
                a[j] = tmp;
            }
        }
    }
    printf("%d\n%d\n%d\n", a[0], a[1], a[2]);
    return 0;
}



Measured memory_bytes: 2712
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC124C3
{
    class Program
    {
        static void Main(string[] args)
        {
            // 文字列の入力
            string S = Console.ReadLine();
            int counter_0 = 0;
            int counter_1 = 0;
            for (int i = 0; i < S.Length; i++)
            {
                if (i % 2 == 0)
                {
                    if (S.Substring(i, 1) != "0")
                    {
                        counter_0++;
                    }
                }
                else
                {
                    if (S.Substring(i, 1) != "1")
                    {
                        counter_0++;
                    }
                }
            }
            for (int i = 0; i < S.Length; i++)
            {
                if (i % 2 == 0)
                {
                    if (S.Substring(i, 1) != "1")
                    {
                        counter_1++;
                    }
                }
                else
                {
                    if (S.Substring(i, 1) != "0")
                    {
                        counter_1++;
                    }
                }
            }
            Console.WriteLine(Math.Min(counter_0,counter_1));
        }
    }
}


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

using namespace std;
using ll=long long;
int main(){
   int n;cin >>n;
   int s[n];
   int sum=0;
   for(int i=0;i<n;i++){
    cin >>s[i];
    sum+=s[i];
   }
   sort(s,s+n);
   int ans;
   if(sum%10!=0){
        cout << sum << endl;
        return 0;
   }
   bool flg=true;
   for(int i=0;i<n;i++){
     if(s[i]%10!=0&&flg){
        ans=sum-s[i];
        flg=false;
     }
   }
   if(flg)ans=0;
   cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
while True:
    n,k=map(int,input().split())
    if n==0 and k==0:
        break
    else:
        a=[int(input())for _ in range(n)]
        s=sum(a[0:k])
        ss=[s]
        for i in range(k,n):
            s=s+a[i]-a[i-k]
            ss.append(s)
        print(max(ss))


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

int main() {
  string S;
  string T;
  cin >> S;
  cin >> T;
  int ans = 0;
  
  for(int i = 0; i < 200010; i++) {
    if(i > S.size() - 1) break;
    if(S.at(i) != T.at(i)) {
      ans ++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3912
#include <bits/stdc++.h>
using namespace std;
int main(){
    int k,s,cnt=0;
    cin >> k >> s;
    int x,y,z;
    for(int i=0;i<=k;i++)
        for(int j=0;j<=k;j++)
            if(s-(i+j)>=0&&s-(i+j)<=k)
                cnt++;
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;

template <class T>
string to_binary(T a){
	if(a == 0){
		return "0";
	}
	string res = "";
	while(a > 0){
		res += '0'+(a & 1);
		a >>= 1;
	}
	return res;
}

int main(){
	int n;
	cin >> n;
	vector<string> a(n);
	for(int i = 0;i < n;i++){
		int num;
		cin >> num;
		a[i] = to_binary(num);
	}


	bool flag[20] = {};

	ll ans = 0;
	int r = 0;
	for(int l = 0;l < n;l++){
		while(r < n){
			bool ok = true;
			int m = a[r].size();
			for(int j = 0;j < m;j++){
				if(a[r][j] == '1' && flag[j]){
					ok = false;
				}
			}
			if(!ok)break;
			for(int j = 0;j < m;j++){
				if(a[r][j] == '1')flag[j] = true;
			}
			r++;
		}
		ans += r - l;
		if(l == r)r++;
		for(int j = 0;j < a[l].size();j++){
			if(a[l][j] == '1')flag[j] = false;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 17280
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin >> N;
	int A, B, C = 0;
	cin >> A >> B;
	int c;
	rep(i, 2, N)
	{
		cin >> c;
		C ^= c;
	}
	int OA = A;

	int DP[51][2][2];
	rep(i, 0, 51)rep(j, 0, 2)rep(k, 0, 2)DP[i][j][k] = INF;
	DP[0][0][0] = 0;

	rep(i, 0, 50)rep(j, 0, 2)rep(k, 0, 2)
	{
		int ai = min(1LL, (A&(1LL << i)));
		int bi = min(1LL, (B&(1LL << i)));
		int ci = min(1LL, (C&(1LL << i)));
		int d = 1LL << i;

		int ni = i + 1, nj = 0, nk = 0;
		if (j == 1)
		{
			ai--;
			if (ai == -1)
			{
				ai = 1;
				nj = 1;
			}
		}
		if (k == 1)
		{
			bi++;
			if (bi == 2)
			{
				bi = 0;
				nk = 1;
			}
		}

		if ((ai^bi) == ci)
		{
			chmin(DP[ni][nj][nk], DP[i][j][k]);
		}

		ai--;
		if (ai == -1)
		{
			ai = 1;
			nj = 1;
		}
		bi++;
		if (bi == 2)
		{
			bi = 0;
			nk = 1;
		}

		if ((ai^bi) == ci)
		{
			chmin(DP[ni][nj][nk], DP[i][j][k] + d);
		}
	}

	if (DP[50][0][0] >= OA)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << DP[50][0][0] << endl;
	}

	return 0;
}

Measured memory_bytes: 3668
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
ll a[200001];
ll s[200001];
int main(){
    int n;
    cin >> n;
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        s[i] += a[i];
        s[i] += s[i-1];
    }
    ll mi = (1LL<<60);
    rep(i,n-1){
        mi = min(mi,abs(2*s[i]-s[n-1]));
    }
    cout << mi << endl;
    return 0;
}


Measured memory_bytes: 3328
eval"N,S,*A="+`dd`.split*?,
d=[k=0]*-~S
A.map{|a|S.downto(a){|i|d[i]=(d[i]+(i-a<1?k+1:d[i-a])*((i<S)?1:N-k))%998244353};k+=1}
p d[S]

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

#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define INF 2000000000000000000
#define endl "\n"
#define _time_ 1.0 * clock() / CLOCKS_PER_SEC
#define popcount(x) __builtin_popcountll(x)
#define pll pair<ll,ll> 
#define ld long double

const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);

ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T, U> &p)
{ 
    return os<<'('<<p.F<< ","<<p.S<<')'; 
}

int _runtimeTerror_()
{
    ll n,k;
    cin>>n>>k;
    vector<ll> v(n);
    for(int i=0;i<n;++i)
        cin>>v[i];
    sort(all(v),[&](ll a,ll b){return abs(a)>abs(b);});
    int cnt=0;
    ll ans=1;
    for(int i=0;i<k;++i)
    {
        ans=(ans*v[i])%M;
        cnt+=v[i]<0;
    }
    if(k==n || cnt%2==0 || ans==0)
    {
        cout<<(ans+M)%M;return 0;
    }
    ll val1,val2,val3,val4;
    bool found1=false,found2=false;
    for(int i=k-1;i>=0;--i)
    {
        if(v[i]<0)
        {
            val1=v[i];
            for(int j=k;j<n;++j)
            {
                if(v[j]>=0)
                {
                    found1=true;
                    val2=v[j];
                    break;
                }
            }
            break;
        }
    }
    for(int i=k-1;i>=0;--i)
    {
        if(v[i]>0)
        {
            val3=v[i];
            for(int j=k;j<n;++j)
            {
                if(v[j]<=0)
                {
                    found2=true;
                    val4=v[j];
                     break;
                }
            }
            break;
        }
    }
    if(found1 && found2)
    {
        if(val2*val3>=val4*val1)
        {
            ans=ans*power(val1,M-2,M)%M*val2%M;
        }
        else
            ans=ans*power(val3,M-2,M)%M*val4%M;
    }
    else if(found1)
        ans=ans*power(val1,M-2,M)%M*val2%M;
    else if(found2)
        ans=ans*power(val3,M-2,M)%M*val4%M;
    else
    {
        sort(all(v),greater<ll>());
        ans=1;
        for(int i=0;i<k;++i)
            ans=(ans*v[i])%M;
    }
    cout<<(ans+M)%M<<'\n';
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef runSieve
        sieve();
    #endif
    #ifdef NCR
        initialize();
    #endif
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--)
        _runtimeTerror_();
    return 0;
}

Measured memory_bytes: 4752
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007


    
int main()
{
    
 ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,i;
    cin>>n;
    ll h[n];
    for(i=0;i<n;i++)
    {
        cin>>h[i];
    }
   ll dp[n]={0};
   dp[0]=0;
   dp[1]=abs(h[1]-h[0]);
   for(i=2;i<n;i++)
   {
       dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
      // cout<<dp[i]<<endl;
   }
    cout<<dp[n-1]<<endl;
    return 0;
   
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

	double a,b,h,m;
	cin>>a>>b>>h>>m;

	double ans=0;
	double arg=0;
	arg = (h*30+m*30/60-m*6);
	if(arg<0)arg+=360;
	arg = arg/180.0*M_PI;
	ans=a*a+b*b-2*a*b*cos(arg);
	ans=sqrt(ans);
	
	cout<<setprecision(30)<<ans<<endl;

	return 0;
}


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

int main() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    ll a[x], b[y], c[z];
    for (int i = 0; i < x; i++) cin >> a[i];
    for (int i = 0; i < y; i++) cin >> b[i];
    for (int i = 0; i < z; i++) cin >> c[i];
    vector<ll> vec;
    for (int i = 0; i < x; i++) {
        for (int j = 0; j < y; j++) {
            vec.push_back(a[i] + b[j]);
        }
    }
    sort(vec.begin(), vec.end());
    int idx[z];
    for (int i = 0; i < z; i++) idx[i] = vec.size() - 1;
    priority_queue<ll> que;
    for (int i = 0; i < k; i++) {
        for (int j = 0; j < z; j++) {
            if (idx[j] < 0) continue;
            que.push(vec[idx[j]] + c[j]);
            idx[j]--;
        }
    }
    for (int i = 0; i < k; i++) {
        cout << que.top() << endl;
        que.pop();
    }
}

Measured memory_bytes: 44092
n,m=map(int,input().split())
l=list(list(map(int,input().split())) for i in range(m))
for i in range(m):
    l[i].append(i)
l.sort(key =lambda x:x[1])
l.sort(key =lambda x:x[0])
i=0
b=l[0][0]
for e in l:
    if b==e[0]:
        i+=1
    else:
        i=1
    e.append("%06d"%e[0]+"%06d"%i)
    b=e[0]
l.sort(key=lambda x:x[2])
for e in l:
    print(e[3])


Measured memory_bytes: 38456
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>

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

using namespace std;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main(){
    int n,a,b; cin >>n >> a >> b;
    cout << min(n*a,b) << endl;
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        x: i64,
        k: i64,
        d: i64,
    };
    let x = x.abs();
    let alpha = x / d;
    let beta = x % d;
    println!(
        "{}",
        if k <= alpha {
            x - k * d
        } else {
            if (k - alpha) % 2 == 0 {
                beta
            } else {
                d - beta
            }
        }
    )
}


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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const int MOD = (int) 998244353;
const int maxn = (int) 2e5 + 20;
const int maxm = (int) 1000000 + 20;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL m = MOD) {LL res = 1; for(; n; n >>= 1, a = a * a % m) if(n & 1) res = res * a % m; return res;}

void work()
{
    int a, b;
    cin >>a >>b;
    cout <<6 - a - b <<endl;
}

int main()
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int h,w;cin >>h>>w;
    vector<vector<int>>d(10,vector<int>(10));
    for (int i = 0; i <10; ++i) {
        for (int j = 0; j < 10; ++j) {
            cin >>d[i][j];
        }
    }
    for (int k = 0; k < 10; ++k) {
        for (int i = 0; i < 10; ++i) {
            for (int j = 0; j < 10; ++j) {
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    int ans=0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            int a;cin >>a;
            if(a!=-1) {
                ans += d[a][1];
            }
        }
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int ans = 0;
  int x = 0;
  rep(i, n){
    ans = (ans + (long long)a[i] * x) % mod;
    x = (x + a[i]) % mod;
  }
  cout << ans << endl;
  return 0;
}
  


Measured memory_bytes: 3996
int main(){
   int a,b,c,x;scanf("%d%d%d%d",&a,&b,&c,&x);
   int ans=0;
   for(int i = 0;i <= a;i++)
      for(int j = 0;j <= b;j++)
         for(int k = 0;k <= c;k++)
            if(500*i+100*j+50*k==x)ans++;
   printf("%d",ans);
   
}

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


void solve(long long A, long long B, long long N){
    if(N < B){
        long long x = N;
        cout << floor(A*x/B) - A * floor(x/B) << endl;
        return;
    } else{
        long long x = B-1;
        cout << floor(A*x/B) - A * floor(x/B) << endl;
        return;
    }
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long N;
    scanf("%lld",&N);
    solve(A, B, N);
    return 0;
}


Measured memory_bytes: 3848