akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int sch[110][10100];
int inq[110];

int main(){
	int n, t;
	while (cin >> n >> t, n | t){
		MEMSET(sch, 0);
		vector<int> cur(n), len(n);
		rep(i, n){
			int x;
			int y = 0;
			while (cin >> x, x){
				for (int j = len[i]; j < len[i] + x; ++j){
					sch[i][j] = y;
				}
				len[i] += x;
				y ^= 1;
			}
		}
		//rep(i, n){
		//	rep(j, t){
		//		cout << (sch[i][j%len[i]] ? "." : "*");
		//	}
		//	cout << endl;
		//}

		queue<int> q;
		MEMSET(inq, 0);
		int ans = 0;
		rep(i, t){
			rep(j, n){
				if (inq[j]) continue;
				if (sch[j][cur[j] % len[j]]){
					q.push(j);
					inq[j] = 1;
				}
				else{
					++cur[j];
				}
			}
			if (q.empty()) continue;
			ans += q.size() - 1;
			int use = q.front();
			++cur[use];
			if (!sch[use][cur[use] % len[use]]){
				q.pop();
				inq[use] = 0;
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 5556
import java.util.Scanner;

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

		while (true) {
			String s[] = sc.nextLine().split(" ");
			if (s[0].equals("0")) {
				break;
			}
			int sum = 0;
			int aCount = 0;
			for (int i = 0; i < s.length; i++) {
				int a = Integer.valueOf(s[i]);
				if (a == 1) {
					aCount++;
					sum += 11;
				} else if (10 <= a) {
					sum += 10;
				} else {
					sum += a;
				}
			}
			while (21 < sum && 0 < aCount) {
				sum -= 10;
				aCount--;
			}
			if (21 < sum) {
				System.out.println("0");
			} else {
				System.out.println(sum);
			}
		}
	}
}

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

using namespace std;

int main(){
    int n;
    cin>>n;
    int d[n][2];
    for(int i=0;i<n;i++){cin>>d[i][0]>>d[i][1];}
    
    int count = 0;
    for(int i=0;i<=n-3;i++){
        count = 0;
        for(int j=i;j<=i+2;j++){
            if(d[j][0]==d[j][1]){
                count++;
            }
        }
        if(count==3){
            cout<<"Yes"<<"\n";
            return 0;
        }
    }
    cout<<"No"<<"\n";
    return 0;
}


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

int main() {
  string t = "ABC";
  int n;
  string s;
  cin >> n >> s;
  int r = 0;
  for (int i = 0; i + t.size() - 1 < n; i++) {
    bool b = true;
    for (int j = 0; b && j < t.size(); j++) b = s[i + j] == t[j];
    if (b) r++;
  }
  cout << r << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);

int dp[5005][5005];

int main() {
    int n;
    string s;
    cin >> n >> s;
    for (int i = n-1; i >= 0; i--) {
        for (int j = n-1; j >= 0; j--) {
            if (s[i] != s[j]) dp[i][j] = 0;
            else dp[i][j] = dp[i+1][j+1] + 1;
        }
    }
    int ans = 0;
    rep(i,n)rep(j,n) {
        if (i >= j) continue;
        int now = min(dp[i][j], j-i);
        ans = max(ans, now);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 101336
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define all(a)  (a).begin(),(a).end()

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

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

int main(){
  int n,m; cin >> n >> m;
  vvi G(100001);
  vi a(n), b(n);
  rep(i, n){
    cin >> a[i] >> b[i];
    G[a[i]].push_back(b[i]);
  }

  int ans = 0;
  priority_queue<int> q;
  for (int i = 1; i < m+1; i++) {
    if(G[i].size() != 0) for(int j : G[i]) q.push(j);
    if(q.size() > 0){
      ans += q.top();
      q.pop();
    }
  }

  std::cout << ans << '\n';

}


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

const int MOD = 998244353;
int dp[403][403] , A[403] , B[403] , jc[403] , inv[403] , N , S;

int poww(long long a , int b){
	int times = 1;
	while(b){
		if(b & 1) times = times * a % MOD;
		a = a * a % MOD; b >>= 1;
	}
	return times;
}

int main(){
	cin >> N; for(int i = 1 ; i <= N ; ++i){cin >> A[i] >> B[i]; S += A[i];}
	dp[0][0] = MOD - 1; jc[0] = 1;
	for(int i = 1 ; i <= 400 ; ++i) jc[i] = 1ll * jc[i - 1] * i % MOD;
	inv[400] = poww(jc[400] , MOD - 2);
	for(int i = 399 ; i >= 0 ; --i) inv[i] = inv[i + 1] * (i + 1ll) % MOD;
	for(int i = 1 ; i <= N ; ++i)
		for(int j = S ; j >= 0 ; --j)
			for(int k = 400 ; k >= 0 ; --k)
				if(dp[j][k])
					for(int l = 0 , tms = 1 ; l < B[i] ; ++l , tms = 1ll * tms * A[i] % MOD)
						dp[j + A[i]][k + l] = (dp[j + A[i]][k + l] - 1ll * tms * inv[l] % MOD * dp[j][k] % MOD + MOD) % MOD;
	int ans = 0;
	for(int i = 1 ; i <= S ; ++i){
		int val = poww(i , MOD - 2) , val1 = i == S ? 1 : 1ll * S * poww(i , MOD - 2) % MOD;
		for(int j = 0 ; j <= 400 ; ++j)
			ans = (ans + 1ll * dp[i][j] * jc[j] % MOD * poww(val , j) % MOD * val1) % MOD;
	}
	cout << ans; return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
long long bit[62][2];
signed main(){
    int x , y , a=0;
    cin>>x>>y;
    if(abs(x) == abs(y)){
        if(x != y){
            a++;
        }
    }
    
    else if(abs(x) > abs(y)){
        if(x>0){
            a++;
        } 
        a+=abs(x)-abs(y);
    
        if(y>0){
            a++;
        }
    }
    
    else{
        if(x<0){
            a++;
        }
        a+=abs(y)-abs(x);
        if(y<0){
            a++;
        }
    }
    
    cout<<a<<endl;
    return(0);
}

Measured memory_bytes: 256
n,a,b=gets.split.map(&:to_i)
x=gets.split.map(&:to_i)
c=0
(n-1).times do |i|
  if (x[i+1]-x[i])*a>b
    c+=b
  else
    c+=(x[i+1]-x[i])*a
  end
end
puts c


Measured memory_bytes: 8452
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define N 1000000007
using namespace std;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,i,j;
    string s1,s2,s;
    cin>>n;
    cout<<"? ";
    for(i=1;i<=n;i++)
        cout<<i<<" ";
    cout<<endl;
    cin>>s1;
    ll l = 2;
    ll r = n+1;
    ll mid;
    while(l < r)
    {
        mid = (l+r)/2;
        cout<<"? ";
        for(i=0;i<n;i++)
            cout<<mid+i<<" ";
        cout<<endl;
        cin>>s2;
        if(s1 == s2)
        {
            l = mid+1;
        }
        else
        {
            r = mid;
        }
    }
    string ans = "";
    for(i=0;i<2*n;i++)
        ans += 'a';
    ans[l-2] = s1[0];
    if(s1[0] == 'R')
        ans[l+n-2] = 'B';
    else
        ans[l+n-2] = 'R';
    for(i=1;i<l-1;i++)
    {
        cout<<"? "<<i<<" ";
        for(j=l;j<l+n-1;j++)
            cout<<j<<" ";
        cout<<endl;
        cin>>s;
        ans[i-1] = s[0];
    }
    for(i=l+n;i<=2*n;i++)
    {
        cout<<"? "<<i<<" ";
        for(j=l;j<l+n-1;j++)
            cout<<j<<" ";
        cout<<endl;
        cin>>s;
        ans[i-1] = s[0];
    }
    vector <ll> vec;
    ll cnt = (n-1)/2;
    i = 0;
    while(vec.size() < cnt)
    {
        if(ans[i] == 'R')
            vec.pb(i);
        i++;
    }
    i = 0;
    while(vec.size() < 2*cnt)
    {
        if(ans[i] == 'B')
            vec.pb(i);
        i++;
    }
    for(i=0;i<2*n;i++)
    {
        if(ans[i] == 'a')
        {
            cout<<"? "<<i+1<<" ";
            for(auto j : vec)
                cout<<j+1<<" ";
            cout<<endl;
            cin>>s;
            ans[i] = s[0];
        }
    }
    cout<<"! "<<ans;
    return 0;
}

Measured memory_bytes: 724
/*
 * Coded by XIZCM
 */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <iomanip>
#include <vector>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <ctime>
#include <fstream>
#include <stdarg.h>

using namespace std;

typedef long long	ll;
typedef pair<int, int>	pii;

const bool	debug	= false;
const bool	INJUDGE = false;
const int	MAXN	= 100005;
const int	MOD	= 1000000007;
const int	INF	= 1000000007;

template<class T>T emax( T & a, T b )
{
	return(a = max( a, b ) );
}


template<class T>T emin( T & a, T b )
{
	return(a = min( a, b ) );
}


template<class T>void byebye( T info )
{
	cout << info << endl; exit( 0 );
}


template<class T1, class T2>ostream & operator<<( ostream & out, pair<T1, T2> P )
{
	out << P.first << " " << P.second; return(out);
}


template<class T>ostream & operator<<( ostream & out, vector<T> V )
{
	for ( int i = 0; i < V.size(); ++i )
		out << V[i] << " ";
	return(out);
}


ll	n;
ll	a, b, c, aa, bb, cc;

ll tradeBy2( ll n, ll a, ll b )
{
	if ( a < b )
	{
		return(n / a * b + n % a);
	}else{
		return(n / b * a + n % b);
	}
}


ll trade( ll n, ll b, ll bb, ll c, ll cc )
{
	ll ans = 0;
	for ( int i = 0; i <= n; i++ )
	{
		ll val = i / bb * b + i % bb + (n - i) / cc * c + (n - i) % cc;
		ans = max( ans, val );
	}
	return(ans);
}


int main()
{
	cin>>n>>a>>b>>c>>aa>>bb>>cc;

	bool fa	= (a < aa);
	bool fb	= (b < bb);
	bool fc	= (c < cc);

	int cnt = fa + fb + fc;

	if ( cnt == 3 || cnt == 0 )
	{
		ll ans = 0;
		for ( int i = 0; i <= n; i++ )
		{
			for ( int j = 0; j <= n - i; j++ )
			{
				ll val = tradeBy2( i, a, aa ) + tradeBy2( j, b, bb ) + tradeBy2( n - i - j, c, cc );
				ans = max( ans, val );
			}
		}

		cout << ans << endl;
	}

	if ( cnt == 2 )
	{
		ll ans = 0;
		for ( int i = 0; i <= n; i++ )
		{
			for ( int j = 0; j <= n - i; j++ )
			{
				ll val = 0;
				if ( fa && fb )
				{
					val	= tradeBy2( i, a, aa ) + tradeBy2( j, b, bb ) + n - i - j;
					ans	= max( ans, max( val, val / cc * c + val % cc ) );
				}
				if ( fb && fc )
				{
					val	= tradeBy2( i, b, bb ) + tradeBy2( j, c, cc ) + n - i - j;
					ans	= max( ans, max( val, val / aa * a + val % aa ) );
				}
				if ( fa && fc )
				{
					val	= tradeBy2( i, a, aa ) + tradeBy2( j, c, cc ) + n - i - j;
					ans	= max( ans, max( val, val / bb * b + val % bb ) );
				}
			}
		}

		cout << ans << endl;
	}

	if ( cnt == 1 )
	{
		ll ans = 0;
		if ( fa )
		{
			n	= n / a * aa + n % a;
			ans	= trade( n, b, bb, c, cc );
		}
		if ( fb )
		{
			n	= n / b * bb + n % b;
			ans	= trade( n, a, aa, c, cc );
		}
		if ( fc )
		{
			n	= n / c * cc + n % c;
			ans	= trade( n, a, aa, b, bb );
		}

		cout << ans << endl;
	}
}




Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

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

int P[100];
int main(){
    int N;
    cin >> N;
    REP(i,N){
        int p;
        cin >> p;
        P[i] = p;
    }
    sort(P,P+N);

    int sum = 0;
    for(int i = 0; i < N-1; i++) sum += P[i];
    sum += P[N-1]/2;
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int mod = 1e9 + 7;
const int MX = 110000;
ll inv[MX], f[MX], invf[MX];
void calc(){
	inv[0] = inv[1] = f[0] = f[1] = invf[0] = invf[1] = 1;
	for (int i = 2; i < MX; i++){
		inv[i] = mod - mod / i * inv[mod % i] % mod;
		f[i] = f[i - 1] * i % mod;
		invf[i] = invf[i - 1] * inv[i] % mod;
	}
}
inline ll P(ll n, ll k){
	return n >= k ? f[n] * invf[n - k] % mod : 0;
}
	
int dp[1 << 16];

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	calc();
	
	int n, m; cin >> n >> m;
	vi a(m), b; rep(i, m) cin >> a[i];
	a.insert(a.begin(), 1);
	a.pb((1 << n) + 1);
	rep(i, a.size() - 1) b.pb(a[i + 1] - a[i] - 1);
	
	rep(i, 1 << n) dp[i] = 1;
	
	rep(i, b.size()){
		rep(j, 1 << n) dp[j] = dp[j] * P(j - a[i] + 1, b[i]) % mod;
		
		if(i + 1 == b.size()) break;
		
		for(int k = n - 1; k >= 0; k--) rep(j, 1 << n) if(j >> k & 1)
			dp[j] = (dp[j] + mod - dp[j ^ 1 << k]) % mod;
		rep(j, 1 << n) dp[j] = dp[j] * max(0ll, j - a[i + 1] + 2ll) % mod;
		rep(k, n) rep(j, 1 << n) if(j >> k & 1) dp[j] = (dp[j] + dp[j ^ 1 << k]) % mod;
	}
	
	ll ans = dp[(1 << n) - 1];
	rep(i, n) ans = ans * 2 % mod;
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3072
#include <stdio.h>
int main ()
{
	int num;
	scanf ("%d", &num);
	long long int arr[num], max = 1e18, prod = 1, flag = 0, zero = 0;
	for (int i = 0; i < num; i++)
	{
		scanf ("%lld", &arr[i]);
		flag = (arr [i] > max) ? 1 : flag;
		prod *= arr [i];
		(arr [i]) ? max /= arr [i] : zero = 1;
	}
	(zero) ? puts("0") : ((flag)) ? puts("-1") : printf ("%lld\n", prod);
	return 0;
}

Measured memory_bytes: 2488
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

n = int(input())
cnt = 0
for i in range(1, n+1):
  if(i % 2 ==1 and len(make_divisors(i)) == 8):
    cnt += 1
print(cnt)


Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	string s;
	cin>>s;
	puts(s[0]==s[2]?"Yes":"No");
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define debug(x)        cout<<#x<<" :"<<x<<endl;
#define ff              first
#define ar              array
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define f(i,n)          for(int i=0;i<n;i++)
#define MOD             1000000007
#define pi              3.14159265
#define umii            unordered_map<int,int>
#define umci            unordered_map<char,int>
#define umsi            unordered_map<string,int>

void k_007()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("ip1.txt", "r", stdin);
	freopen("op1.txt", "w", stdout);
#endif
}
bool sortbysec(const pair<int, int> &a,
               const pair<int, int> &b);
int gcd(int a, int b) ;
int prime(int n);
int power(int x, int y);
int lcm(int a, int b);
int32_t main()
{
	k_007();
	int n, m;
	cin >> n >> m;
	int p[m];
	string s[m];
	f(i, m)
	{
		cin >> p[i] >> s[i];
	}

	int corr = 0;
	int pen = 0;
	map<int, int> wa, ac;
	for (int i = 0; i < m; i++)
	{
		if (ac[p[i]]) continue;
		if (s[i] == "AC")
		{
			corr++;
			ac[p[i]] = 1;
			pen += wa[p[i]];
		}
		else
		{
			wa[p[i]]++;
		}
	}

	cout << corr << " " << pen << endl;
}

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
	return (a.second < b.second);
}
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int prime(int n) {
	int flag = 1;
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0) {flag = 0; break;}
	}
	return flag;
}
int power(int x, int y)
{
	if (y == 0)
		return 1;
	else if (y % 2 == 0)
		return ((power(x, y / 2) % MOD) * ( power(x, y / 2) % MOD)) % MOD;
	else
		return ((x % MOD) * (power(x, y / 2) % MOD) * (power(x, y / 2) % MOD)) % MOD;
}
int lcm(int a, int b)
{
	return (a * b) / gcd(a, b);
}

Measured memory_bytes: 19980
import sys
input = sys.stdin.readline
import numpy as np
MOD = 10**9+7
  
n, k = map(int, input().split())
S = set()
i = 1
while i * i <= n:
  S.add(i)
  S.add(n//i)
  i += 1
L = np.array([0] + sorted(S), dtype=np.int64)
l = len(L) - 1
num = np.diff(L)
dp = np.zeros(l, dtype=np.int64)
dp[0] = 1
for _ in range(k):
  A = np.cumsum(dp)
  dp = A[::-1] * num
  dp %= MOD
ans = dp.sum() % MOD
print(ans)

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

const long MAXN=30100;
long n;
char s[MAXN];
char i,j,k;
long ans=0;

int main() {
	cin>>n;
	for(long tmp=1;tmp<=n;++tmp) {
		s[tmp]=getchar();
		while(s[tmp]<'0' || s[tmp]>'9')
			s[tmp]=getchar();
	}
	long pos1,pos2,pos3;
	for(i='0';i<='9';++i) {
		pos1=1;
		while(pos1<n-1 && s[pos1]!=i)
			++pos1;
		if(pos1==n-1) continue;
		for(j='0';j<='9';++j) {
			pos2=pos1+1;
			while(pos2<n && s[pos2]!=j)
				++pos2;
			if(pos2==n) continue;
			for(k='0';k<='9';++k) {
				pos3=pos2+1;
				while(pos3<=n && s[pos3]!=k)
					++pos3;
				if(pos3<=n) ++ans;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
using namespace std;

long long h[30008] = { 0 };
long le[15] = { 0 };
long cnt[15] = { 0 };
long ri[15] = { 0 };
int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		char c; cin >> c;
		h[i] = c - '0';
		if (cnt[c - '0'] == 0)le[c - '0'] = i;
		cnt[c - '0']++;
		ri[c - '0'] = i;
	}
	int ans = 0;
	for (int i = 0; i <= 999; i++) {
		int p = i / 100; int q = (i / 10) % 10; int r = i % 10;
		if (le[p] == 0 || ri[r] == 0)continue;
		for (int j = le[p] + 1; j < ri[r]; j++) {
			
			if (h[j] == q) {
				ans++; //cout << i << endl; 
				goto A;
			}
		}
	A:;
	}
	cout << ans << endl;


}

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

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

vector<int> g[N];
int ans[N];
int vis[N];

signed main(){
    IOS;
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    queue<int> q;
    q.push(1);
    while (!q.empty()) {
        int t = q.front();
        q.pop();
        for (auto i : g[t]) {
            if (vis[i]) continue;
            vis[i] = 1;
            q.push(i);
            ans[i] = t;
        }
    }
    int flag = 1;
    for (int i = 1; i <= n; i++) {
        if (ans[i] == 0) flag = 0;
    }
    if (!flag) cout << "No\n";
    else {
        cout << "Yes\n";
        for (int i = 2; i <= n; i++)
            cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 13884
#include<stdio.h>
#include <string.h>
#include<queue>
using std::queue;
typedef long long LL;
typedef std::pair<int, LL> Pil;
/*
dp[i][j]表示1~i的处理为有序，并且i在j 花费
dp[i+1]

*/



int pos[5005];

int roll = 0;
LL dp[2][5005];

LL min(LL x,LL y){
	return x < y ? x : y;
}
const LL INF = 4557430888798830399;
int main() {
	//freopen("in.txt", "r", stdin);
	memset(dp, 0x3f, sizeof dp);
	int n; scanf("%d", &n);
	LL A, B;scanf("%lld %lld", &A, &B);
	int x;
	for (int i = 1; i <=n; i++) {
		scanf("%d", &x);
		pos[x] = i;
	}
	dp[roll][0] = B;
	dp[roll][pos[1]] = 0;

	for(int i=2;i<=n;i++){
		memset(dp[roll ^ 1], 0x3f, sizeof dp[roll ^ 1]);
		for(int j=0;j<=n;j++)if(dp[roll][j]<INF){
				if(pos[i]>j){
					//留在原地
					dp[roll ^ 1][pos[i]] = min(dp[roll][j], dp[roll ^ 1][pos[i]]);
					//左移到[j~j+1)的合适位置
					dp[roll ^ 1][j] = min(dp[roll][j]+B, dp[roll ^ 1][j]);
				}
				else	
					//右移到[j~j+1)的合适位置
					dp[roll ^ 1][j] = min(dp[roll][j] + A, dp[roll ^ 1][j]);		
			}
		roll ^= 1;
	}
	LL ans = INF;
	for (int i=1;i<=n;i++){
		ans = min(ans, dp[roll][i]);
	}
	printf("%lld", ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

//閉路やばそう
//閉路の総和がPより大きいとヤバそう
//小さい場合は閉路を回る必要がないが

//閉路判定以外やるだけでは？

struct edge {
	int to; ll cost;
};
vector<edge> G[2500];
ll score[2500];
void solve() {
	int n; cin >> n;
	vector<string> s(n);
	rep(i, n) {
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
	}
	sort(s.begin(), s.end());
	ll ans = 0;
	rep(i, n) {
		int le = i;
		while (i + 1 < n&&s[i] == s[i + 1]) {
			i++;
		}
		ll len = i - le + 1;
		ans += len * (len - 1) / 2;
	}
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
	//stop
	return 0;
}


Measured memory_bytes: 5760
#include"bits/stdc++.h"
using namespace std;
int main() {
	int n, m, j, suu;
	while ((cin >> m >> n) && m != 0 || n != 0) {
		int check[1001] = { 0 };
		for (int i = 1; i <= m; i++)check[i] = i;
		j = 1;
		suu = m;
		for (int i = 1; i <= n; i++) {
			string str;

			cin >> str;
			if (suu > 1) {
				if (i % 15 == 0) {
					if (str != "FizzBuzz") {
						check[j] = 0;
						suu--;
					}
				}
				else if (i % 3 == 0) {
					if (str != "Fizz") {
						check[j] = 0;
						suu--;
					}
				}
				else if (i % 5 == 0) {
					if (str != "Buzz") {
						check[j] = 0;
						suu--;
					}
				}
				else {
					char buf[10] = { NULL };
					sprintf(buf, "%d", i);
					if (str != buf) {
						check[j] = 0;
						suu--;
					}
				}
				int j2 = j;
				for (int x = j+1; x <= m; x++) {
					if (check[x] != 0) {
						j2 = x; break;
					}
				}
				if (j == j2)for (int x = 1; x < j; x++) {
					if (check[x] != 0) {
						j2 = x; break;
					}
				}
				j = j2;
			}
		}
		int las;
		for (int i = m; i > 0; i--) if (check[i] != 0) {
			las = i; break;
		}
		for (int i = 1; i <= m; i++)
		{
			if (check[i] != 0)
			{
				cout << i;
				if (i<las)
					cout << " ";
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 3088
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 1; i <= n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, cnt = 0;
  cin >> n;
  REP(i,n) {
    if(i % 2 == 0) continue;
    int cnt1 = 0;
    REP(j,i) if(i % j == 0) cnt1++;
    if(cnt1 == 8) cnt++;
  }
  cout << cnt << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
dice1 = list(map(int, input().split()))
dice2 = list(map(int, input().split()))

def dicing(lis, inst):
    if inst == 'N':
        ans_lis = [lis[1],lis[5],lis[2],lis[3],lis[0],lis[4]]
    if inst == 'W':
        ans_lis = [lis[2],lis[1],lis[5],lis[0],lis[4],lis[3]]
    if inst == 'S':
        ans_lis = [lis[4],lis[0],lis[2],lis[3],lis[5],lis[1]]
    if inst == 'E':
        ans_lis = [lis[3],lis[1],lis[0],lis[5],lis[4],lis[2]]
    
    return(ans_lis)

def turn_right(lis):
    inst = list('ENW')
    for i in range(len(inst)):
        lis = dicing(lis, inst[i])
    return(lis)

def find_above(lis, num1, num2):
    inst1 = list('NNNEWW')
    for i in range(len(inst1)):
        if lis[0] == num1 and lis[5] == num2:
            break
        
        lis = dicing(lis, inst1[i])
        if lis[0] == num1 and lis[5] == num2:
            break
    return(lis)

YN = 'No'

lis = [1,2,3,4,5,6]
lis = find_above(dice1, dice2[0], dice2[5])
for j in range(4):
    lis = turn_right(lis)
    if lis == dice2:
        YN = 'Yes'
        break

print(YN)


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

 int main(){
 
 while(1){
  int x, y;
  cin>>x>>y;
  if(x == 0 && y == 0) break;
 
  if(x > y) swap(x, y); 
  cout<<x<<" "<<y<<endl;
}
 return 0;
}


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

int main()
{
        int n;
        cin >> n;
        int x[n];
        int y[n];
        for (int i = 0; i < n; ++i) {
                cin >> x[i];
        }
        for (int i = 0; i < n; ++i) {
                cin >> y[i];
        }
        int a[n];
        for (int i = 0; i < n; ++i) {
                a[i] = abs(x[i] - y[i]);
        }
        double D1 = 0;
        for (int i = 0; i < n; ++i) {
                D1 += a[i];
        }
        double D2 = 0;
        double tmp = 0;
        for (int i = 0; i < n; ++i) {
                tmp += pow(a[i], 2);
        }
        D2 = pow(tmp, 1./2);

        double D3 = 0;
        tmp = 0;
        for (int i = 0; i < n; ++i) {
                tmp += pow(a[i], 3);
        }
        D3 = pow(tmp, 1./3);

        int Dm = 0;
        for (int i = 0; i < n; ++i) {
                Dm = std::max(Dm, a[i]);
        }

        printf("%.6lf\n", D1);
        printf("%.6lf\n", D2);
        printf("%.6lf\n", D3);
        printf("%.6lf\n", (double)Dm);



}



Measured memory_bytes: 3348
#include<iostream>
#include<vector>
#include<string>
using namespace std;

vector<int> Change(vector<int> X, int m, int n){
	int x = X[m];
	X[m] = X[n];
	X[n] = x;
	return X;
}

vector<int> SelectionSort_withMark(vector<int> A, int i){
	int N = A.size() / 2;
	int j_0 = i;
	for(int j = i; j < N; j++){
		if(A[2*j+1] < A[2*j_0 +1]) j_0 = j;
	}
	if(j_0 != i){
		A = Change(A, 2*j_0 +1, 2*i+1);
		A = Change(A, 2*j_0, 2*i);
	}
	return A;
}

vector<int> BubbleSort_withMark(vector<int> A, int i){
	int N = A.size() / 2;
	int j = 0;
	for(int j = 0; j < N-i; j++){
		if(A[2*j+1] > A[2*j+3]){
			A = Change(A, 2*j+1, 2*j+3);
			A = Change(A, 2*j, 2*j+2);
		}
	}
	return A;
}

int MarkToNumber(char m){
	if(m == 'C') return 1;
	if(m == 'D') return 2;
	if(m == 'H') return 3;
	if(m == 'S') return 4;
}

char NumberToMark(int n){
	if(n == 1) return 'C';
	if(n == 2) return 'D';
	if(n == 3) return 'H';
	if(n == 4) return 'S';
}

void Output_withMark(vector<int> X){
	int N = X.size() / 2;
	for(int i = 0; i < N-1; i++){
		char m = NumberToMark(X[2*i]);
		cout << m << X[2*i+1] << ' ';
	}
	cout << NumberToMark(X[2*N-2]) << X[2*N-1] << endl;
}

vector<int> Arrange(vector<int> X){
	int N = X.size() / 2;
	vector<int> P;
	for(int i = 1; i <= 9; i++){
		for(int j = 0; j < N; j++){
			if(X[2*j+1] == i){
				P.push_back(X[2*j]);
				P.push_back(i);
			}
		}
	}
	return P;
}

void Answer(vector<int> X, vector<int> P){
	vector<int> Q = Arrange(X);
	if(Q == P) cout << "Stable" << endl;
	if(Q != P) cout << "Not stable" << endl;
}


int main(){
	int N;
	cin >> N;
	vector<int> A;
	for(int i = 0; i < N; i++){
		char m;
		int  n;
		cin >> m >> n;
		int l = MarkToNumber(m);
		A.push_back(l);
		A.push_back(n);
	}
	vector<int> P = Arrange(A);
	vector<int> B = A;
	for(int i = 1; i < N; i++) A = BubbleSort_withMark(A, i);
	Output_withMark(A);
	Answer(A, P);
	for(int i = 0; i < N; i++) B = SelectionSort_withMark(B, i);
	Output_withMark(B);
	Answer(B, P);
	return 0;
}

Measured memory_bytes: 1228
n = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
monster = [int(i) for i in input().split()] # 配列で数字

def gcd(x, y): #GCD
    # greatest_common_divisor
    if x < y:
        x, y = y, x
    if y == 0:
        return 0
    if x % y == 0:
        return y
    return gcd(y, x % y)


l = monster[0]
for m in monster:
    l = gcd(l, m)
print(l)

Measured memory_bytes: 62704
#include <iostream>
#include <vector>
#include <queue>
#include <climits>

using namespace std;

int main(int argc, char **argv)
{
        int V, E, r;
        cin >> V >> E >> r;
        vector<vector< pair<int, int>>> A(V);
        for (int i = 0; i < E; i++) {
                int s, t, d;
                cin >> s >> t >> d;
                A[s].push_back({t, d});
        }
        vector<int> d(V, INT_MAX);
        d[r] = 0;
        bool done = false;
        while (!done) {
                done = true;
                for (int i = 0; i < V; i++) {
                        if (d[i] == INT_MAX)
                                continue;
                        for (auto n: A[i]) {
                                int m = d[i] + n.second;
                                if (m < d[n.first]) {
                                        d[n.first] = m;
                                        done = false;
                                }
                        }
                }
        }
        for (int i = 0; i < V; i++) {
                if (d[i] == INT_MAX)
                        cout << "INF";
                else
                        cout << d[i];
                cout << endl;
        }
        return 0;
}

Measured memory_bytes: 11952
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        DecimalFormat df = new DecimalFormat("0.00000000");

        long a = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next());
        long c = Long.parseLong(sc.next());
        long ans = 0;
        while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
            long tmpA = b/2 + c/2;
            long tmpB = a/2 + c/2;
            long tmpC = a/2 + b/2;
            if (a == tmpA && b == tmpB && c == tmpC) {
                ans = -1;
                break;
            }
            a = tmpA;          
            b = tmpB;
            c = tmpC;
            ans++;
        }
        out.println(ans);
        
        out.flush();
    }
}

Measured memory_bytes: 21844
#include <iostream>

using namespace std;
int h[100010];
int main(){
	int i,n;
	cin >> n;
	for(i=1;i<=n;i++){
		 cin >> h[i];
	}
	h[0] = -1;
	for(i=1;i<=n;i++){
		if(h[i]>h[i - 1]) h[i]--;
	}
	for(i=1;i<=n;i++){
		if(h[i]<h[i - 1]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}
	

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) begin(v), end(v)
#define allg(v) begin(v), end(v), greater<int>()



int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<tuple<string, int, int>> p(n);
  rep(i, 0, n) {
    string s;
    int ppp;
    cin >> s >> ppp;
    ppp *= -1;
    p.at(i) = make_tuple(s, ppp, i);
  }
  
  sort(all(p));
  
  rep(i, 0, n) {
    int ii;
    tie(ignore, ignore, ii) = p.at(i);
    cout << ii +1 << "\n";
  }

}


Measured memory_bytes: 256
import math

def main():
    """ 以下にコードを書いてください """
    N = int(input())
    A = int(input())
    B = int(input())
    C = int(input())
    D = int(input())
    E = int(input())
    
    min_capacity = min(A,B,C,D,E)

    ans = math.ceil((N/min_capacity)) + 4

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  string s;
  R s;
  rep(i,s.size()) s[i]='x';
  pr(s);
}

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


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

using namespace std;

int main(){
  int n;
  vector<int> s;

  cin>>n;
  while(n!=0){
    s.resize(n);

    for(int i=0;i<n;i++){
      cin>>s[i];
    }
    sort(s.begin(),s.end());
    s.erase(s.begin());
    s.erase(s.end()-1);

    int ans = 0;

    for(int i=0;i<n-2;i++){
      ans += s[i];
    }

    cout<<ans/(n-2)<<endl;

    cin>>n;
  }
  return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define ll long long
#define pp pair<ll,ll>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
ll max(ll x, ll y)
{
    return x>y ? x : y;
}
ll min(ll x, ll y)
{
    return x<y ? x : y;
}
void _(ll&a , ll b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;cin >> n >> m;char a[n][m];
    for (int i = 0; i < n; ++i)
    {
    	for (int j = 0; j < m; ++j)
    	{
    		cin >> a[i][j];
    	}
    }
    ll dp[n][m];
    for (int i = 0; i < n; ++i)
    {
    	for (int j = 0; j < m; ++j)
    	{
    		dp[i][j]=1e18;
    	}
    }
    dp[0][0]=a[0][0]=='#';
    for(ll j=1;j<m;j++)dp[0][j]=dp[0][j-1]+(a[0][j]=='#' and a[0][j-1]=='.');
    for(ll i=1;i<n;i++)dp[i][0]=dp[i-1][0]+(a[i][0]=='#' and a[i-1][0]=='.');
    for (int i = 0; i < n; ++i)
    {
    	for (int j = 0; j < m; ++j)
    	{
    		if(i and j)
    		{
    			dp[i][j]=min(dp[i-1][j]+(a[i][j]=='#' and a[i-1][j]=='.')
    				,dp[i][j-1]+(a[i][j]=='#' and a[i][j-1]=='.'));
    		}
    	}
    }
    // for (int i = 0; i < n; ++i)
    // {
    // 	for (int j = 0; j < m; ++j)
    // 	{
    // 		cout << dp[i][j] << " ";
    // 	}
    // 	cout << "\n";
    // }
    cout << dp[n-1][m-1];
    }

Measured memory_bytes: 384
import numpy as np
N=int(input())
X=list(map(int, input().split()))
Y=list(map(int, input().split()))
Z=np.zeros(N)
for i in range(N):
  Z[i]=X[i]-Y[i]
print('{:.0f}'.format(sum(Z[np.where(Z>0)])))

Measured memory_bytes: 12488
#include <bits/stdc++.h>
using namespace std; 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define LINY "YES\n"
#define Liny "Yes\n"
#define LINN "NO\n"
#define Linn "No\n"
#define unordered_map umap
typedef long long ll;
typedef long double ld;
ll min(ll x,ll y){return (x<y ? x:y);}
ll max(ll x,ll y){return (x>y ? x:y);}
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){if(a<b){swap(a,b);} return a*b /gcd(a,b);}
bool isPrime(int n){if(n<2){return false;}for(int i=2;i<sqrt(n)+1;i++){if(n%i==0) return false;}return true;}

int main(){
  int A,B; cin>>A>>B;
  cout << ( (A<=8 && B<=8)? "Yay!": ":(" );
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 int f[366],m[366],sum;
ll checkbit(ll n , ll k)
{
    return (n&(1LL<<k));
}
bool comp(string a, string b)
{
  if(a.size()>=b.size())return false;
  else return true;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
     ll n,k;
     cin>>n>>k;
     ll ar[n+2];
     for(ll i=0;i<n;i++)
     {
         cin>>ar[i];
     }
     for(ll i=k;i<n;i++)
     {
         if(ar[i]<=ar[i-k]){cout<<"No"<<endl;}
         else cout<<"Yes"<<endl;
     }

}


Measured memory_bytes: 5212
import sys,heapq
def input():
    return sys.stdin.readline()[:-1]
X,Y,Z,K=map(int,input().split())
A=list(map(lambda x:int(x)*-1,input().split()))
B=list(map(lambda x:int(x)*-1,input().split()))
C=list(map(lambda x:int(x)*-1,input().split()))
h=[]
heapq.heapify(h)
for i in A:
    for j in B:
        heapq.heappush(h,i+j)
m=min(K,len(h))
l=[None]*m
for i in range(m):
    l[i]=heapq.heappop(h)
h=[]
heapq.heapify(h)
for i in l:
    for j in C:
        heapq.heappush(h,i+j)
for i in range(K):
    print(heapq.heappop(h)*-1)

Measured memory_bytes: 154212
#include <bits/stdc++.h>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD				1000000007
#define MOD1			998244353
#define EPS				1e-9
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)

using namespace std;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
const int tam = 10000010;

int main()
{
	//ios::sync_with_stdio(false); cin.tie(0);
	//freopen("asd1.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	string s;
	int ce = 0, un = 0;
	cin>>s;
	int res = 0;
	fore(i, 0, s.size())
	{
		if(s[i] == '0')
		{
			if(un > 0)
			{
				res+=2;
				un--;
			}
			else
				ce++;
		}
		else
		{
			if(ce > 0)
			{
				res += 2;
				ce--;
			}
			else
				un++;
		}
	}
	cout<<res<<'\n';
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

Measured memory_bytes: 512
n = int(input())
a = [int(input()) for i in range(n)]
a_re = sorted(a,reverse=True)

if len(a_re) > 1:
  for i in range(n):
    if a[i] != a_re[0]:
      print(a_re[0])
    elif a[i] == a_re[0]:
      print(a_re[1])
elif len(a_re) == 1 :
  for i in range(n):
    print(a_re[0])

Measured memory_bytes: 14064
# 問題：https://atcoder.jp/contests/abc140/tasks/abc140_a

n = int(input())
b = list(map(int, input().strip().split()))
res = b[0]
for i in range(1, n-1):
    res += min(b[i-1], b[i])
res += b[-1]
print(res)


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

int ChkD( const char *S )
{
	if( S[ 0 ] != 'd' ) return - 1;
	if( S[ 1 ] != 'r' ) return - 1;
	if( S[ 2 ] != 'e' ) return - 1;
	if( S[ 3 ] != 'a' ) return - 1;
	if( S[ 4 ] != 'm' ) return - 1;

	if( S[ 5 ] != 'e' ) return 5;
	if( S[ 6 ] != 'r' ) return - 1;

	if( S[ 7 ] == 'a' ) return 5;

	return 7;
}

int ChkE( const char *S )
{
	if( S[ 0 ] != 'e' ) return - 1;
	if( S[ 1 ] != 'r' ) return - 1;
	if( S[ 2 ] != 'a' ) return - 1;
	if( S[ 3 ] != 's' ) return - 1;
	if( S[ 4 ] != 'e' ) return - 1;

	if( S[ 5 ] != 'r' ) return 5;

	return 6;
}

char S[ 100100 ];

int main()
{
int i;
int iChk;
char C;

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

	cin >> S;

	i = 0;
	while( ( C = S[ i ] ) != '\0' )
	{
		if( C == 'd' )
		{
			iChk = ChkD( S + i );
			if( iChk <= 0 ) break;

			i += iChk;
		}
		else if( C == 'e' )
		{
			iChk = ChkE( S + i );
			if( iChk <= 0 ) break;

			i += iChk;
		}
		else
			break;
	}

	if( C == '\0' )
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 384
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 100000000000000;
const double PI = acos(-1);

vector<LL> v[4];
LL W[101], V[101];
int main() {
	int n, w;
	cin >> n >> w;
	LL minw = INF;
	for (int i = 0; i < n; i++) {
		cin >> W[i] >> V[i];
		minw = min(minw, W[i]);
	}
	for (int i = 0; i < n; i++) {
		v[W[i] - minw].emplace_back(V[i]);
	}
	sort(v[0].begin(), v[0].end(), greater<int>());
	sort(v[1].begin(), v[1].end(), greater<int>());
	sort(v[2].begin(), v[2].end(), greater<int>());
	sort(v[3].begin(), v[3].end(), greater<int>());
	for (int i = 0; i < 4; i++) {
		LL sum = 0;
		for (int j = 0; j < v[i].size(); j++) {
			//cout << v[i][j] << " ";
			sum += v[i][j];
			v[i][j] = sum;
		}
		//cout << endl;
	}
	LL ans = 0;
	for (int i = 0; i <= v[0].size(); i++) {
		for (int j = 0; j <= v[1].size(); j++) {
			for (int k = 0; k <= v[2].size(); k++) {
				for (int l = 0; l <= v[3].size(); l++) {
					LL num = 0;
					LL cost = 0;
					if (i != 0) {
						num += v[0][i - 1];
						cost += i*minw;
					}
					if (j != 0) {
						num += v[1][j - 1];
						cost += j*(minw + 1);
					}
					if (k != 0) {
						num += v[2][k - 1];
						cost += k*(minw + 2);
					}
					if (l != 0) {
						num += v[3][l - 1];
						cost += l*(minw + 3);
					}
					if (cost <= w) {
						ans = max(ans, num);
					}
				}
			}
		}
	}
	cout << ans << endl;
	system("pause");
}

Measured memory_bytes: 504
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define rep(i,n) for(int i=0;i<n;++i)
#define rep(j,m) for(int j=0;j<m;++j)
#define REP(i,n) for(int i=1;i<=n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define len(s)   ((int)s.size())
#define F first
#define S second
#define pb push_back
#define pf push_front
#define mp make_pair
typedef long long ll;
typedef double db;
typedef vector<int> ve;
typedef vector< vector < int> > vee;
typedef vector<pair<ll,ll> > vepa;
typedef set<char>se;
typedef map<ll,ll> mpp;
const ll N=1e5+5;
ll arr[N],A[N],cnt[N];
bool visited[N];
bool f,ff;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
   double n;
   cin>>n;
  //  cout << fixed << showpoint;
    //cout << setprecision(9);
    cout<< n*3.14*2;
go;
}


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

int main() {
  int n;
  cin >> n;
  vector<double> a(n);
  rep(i, n) cin >> a[i];

  sort(a.begin(), a.end());
  double ans = 0;
  rep(i, n-1) {
    if (i==0) {
      ans = (a[0]+a[1])/2;
      continue;
    }
    ans = (ans+a[i+1])/2;
  }
  cout << ans << endl;
}


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

void shuffle(int ary[],int size)
{
    for(int i=0;i<size;i++)
    {
        int j = rand()%size;
        int t = ary[i];
        ary[i] = ary[j];
        ary[j] = t;
    }
}

int main() {
  int N;
  cin >> N;
  int s[N];
  for (int i = 0; i < N; i++) {
    cin >> s[i];
  }
  int sum = 0;
  int num = 0;
  for (int i = 0; i < N; i++) {
    num += s[i];
  }
  if ((num % 10) != 0) {
    sum = num;
  } else {
    sort(s, s+N);
    for (int i = 0; i < N; i++) {
      if ((s[i] % 10) != 0) {
	num -= s[i];
	sum = num;
	break;
      }
    }
  }

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/math/common_factor.hpp>
using namespace std;
 
template< class t>
long long int gcd( t g,t h )
{
    return ( h==0 ? g : gcd(h,g%h) );
}
 
 
struct Comp {
  bool operator()(const std::pair<int, int> &a, const std::pair<int, int> &b) {
    if (a.first != b.first) {
      return a.first < b.first;
    }
    return a.second > b.second;
  }
 
}comp_functor;
 
 
int main() 
{
    ios_base::sync_with_stdio(false) ; cin.tie(0) ;
    
    unsigned long long int i,j,k,t,n,m,c=0,a[500005],h[3000006]={0},l,temp=0,ans=0,x,result;
    
    string s;
    
    cin>>s>>k;
    
    for(i=0;i<s.length();i++)
    {
        a[i]=s[i]-'0';
        //cout<<a[i]<<" ";
    }
    
    for(i=0;i<s.length();i++)
    {
        if(a[i]==1)
        {
            c++;
        }
        else
        {
            break;
        }
        
    }
    
    
    if(c>=k)
    {
        cout<<"1";
    }
    else
    {
        cout<<a[c];
    }
    
    return 0;
} 

Measured memory_bytes: 384
n = int(input())
a = input()
b = input()
c = input()

ans = 0
for i in range(n):
  h = [a[i], b[i], c[i]]
  h.sort()
  if h[0] != h[1] and h[1] != h[2]:
    ans += 2
  elif h[0] != h[2]:
    ans += 1
    
print(ans)

Measured memory_bytes: 3064