akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
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...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

int main()
{
	fastIO
	//inp_out();
	vll a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	ll k;
	cin>>k;
	cout<<a[k-1];
	return 0;
}



Measured memory_bytes: 256
import sys
import bisect
input = sys.stdin.readline

def main():
    n, q = map(int, input().split())
    a = list(map(int, input().split()))
    
    s = [0]*(n+1)
    odd = [0]*(n+1)
    even = [0]*(n+1)
    for i in range(n):
        s[i+1] += s[i]+a[i]
        odd[i+1] += odd[i]
        even[i+1] += even[i]
        if i%2:
            odd[i+1] += a[i]
        else:
            even[i+1] += a[i]
    
    key = []
    value = dict()
    v = 0
    for i in range(n):
        if i == n-1:
            k = pow(10, 9)
            key.append(k)
            value[k] = v
            continue
            
        k = (a[i+(n-i)//2]+a[i])//2
        v = s[i+(n-i)//2]-s[i]
        if (n-i)%2:
            if i%2:
                v += even[max(0, i)]
            else:
                v += odd[max(0, i)]
        else:
            if i%2:
                v += odd[max(0, i-1)]
            else:
                v += even[max(0, i-1)]
        
        key.append(k)
        value[k] = v
    
    sum_a = s[n]
    
    for i in range(q):
        x = int(input())
        k = key[bisect.bisect_left(key, x)]
        ans = sum_a-value[k]
        print(ans)
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 45652
A,B,C,X,Y = map(int,input().split())
if 2*C<=A+B:
    if X<=Y:
        ans = 2*C*X
        ans += (Y-X)*min(B,2*C)
    else:
        ans = 2*C*Y
        ans += (X-Y)*min(A,2*C)
else:
    if X<=Y:
        ans = (A+B)*X
        ans += (Y-X)*B
    else:
        ans = (A+B)*Y
        ans += (X-Y)*A
print(ans)    

Measured memory_bytes: 38384
L, R = map(int, input().split())
mod = 2019
ans = 10 ** 9 * 10

for l in range(L, min(L + mod, R) + 1):
    for r in range(l + 1, min(L + mod, R) + 1):
        ans = min(ans, (l * r) % mod)

print(ans)

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

int main()
{
	int a,b,c,d,sum=0;
	string s;
    vector<int> cnt(2,0);
    cin>>s;
	for(int i=0;i<s.length();i++)
    {
        cnt[s[i]-'0']++;
    }
	cout<<min(cnt[0],cnt[1])*2;
	
	return 0;
}
	

Measured memory_bytes: 512
#include<stdio.h>
using namespace std;
int a,b,k;
int main()
{
	scanf("%d%d%d", &k,&a,&b);
	for(int i=a;i<=b;i++)
	{
		if(i%k==0)
		{
			printf("OK");
			return 0;
		}
	}
	printf("NG");
 } 

Measured memory_bytes: 1732
var input = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  input += chunk.replace( '\n', '' );
  var output = [];
  for( var i=0; i<input.length; i++ ) {
    if( 'a' <= input[i] && input[i] <= 'z' ) {
      output.push( input[i].toUpperCase() );
    } else if( 'A' <= input[i] && input[i] <= 'Z' ) {
      output.push( input[i].toLowerCase() );
    } else {
      output.push( input[i] );
    }
  }
  console.log( output.join( '' ) );  
});

Measured memory_bytes: 8660
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
using namespace std;

const int MAXN = 1e5 + 5;
int happy[MAXN][3];
int dp[MAXN][3];

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

	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> happy[i][0] >> happy[i][1] >> happy[i][2];

	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j < 3; ++j) {
			for (int k = 0; k < 3; ++k) {
				if (j == k) continue;
				dp[i][j] = max(dp[i][j], dp[i-1][k] + happy[i-1][j]);
			}
		}
	}

	cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n'; cout << fixed << setprecision(10);

int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) { cin >> a[i];
	if (a[i] % 2 == 0) {
		if (a[i] % 3 != 0 && a[i] % 5 != 0) {
			cout << "DENIED"; return 0;
		}
	}
	}
	cout << "APPROVED";

}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int MOD = (int)1e9 + 7;
template<class T> void add(T &a, T b) { (a += (b % MOD + MOD) % MOD) %= MOD; }

int main() {
    int h, w; cin >> h >> w;
    int K; cin >> K; K--;
    vector<int> fib(w);
    fib[0] = 1, fib[1] = 2;
    for (int i = 2; i < w; i++) fib[i] = (fib[i - 1] + fib[i - 2]) % MOD;
    vector<vector<long long>> dp(h + 1, vector<long long>(w));
    dp[0][0] = 1;
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
        for (int dj: {-1, 0, 1}) if (0 <= j + dj && j + dj < w) {
            int left = max(0, j - 1), right = max(0, w - j - 2);
            if (dj == -1) left = max(0, j - 2);
            if (dj == 1) right = max(0, w - j - 3);
            add(dp[i + 1][j + dj], dp[i][j] * fib[left] * fib[right]);
        }
    }
    cout << dp[h][K] << endl;
    return 0;
}


Measured memory_bytes: 256
S = str(input())
ans = 'Yes'

from collections import Counter
SC = Counter(list(S))
h,i = 0,0
for a,b in SC.items():
  if a == 'h':
    h = b
  elif a == 'i':
    i = b
  else:
    ans = 'No'
    break

if h == i:
  for i in range(0,len(S)-1,2):
    if S[i]+S[i+1] != 'hi':
      ans = 'No'
      break
else:
  ans = 'No'
  
print(ans)

Measured memory_bytes: 3316
import java.util.*;

public class Main {

	public static void main(String[] args) {
		
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = a - (2 * b);
		if(c > 0) {
			System.out.println(c);
		} else {
			System.out.println(0);
		}
	}
}


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

#define deb(x) cerr<<"["#x<<" : "<<x<<" ]\n";

int main()
{
	int val = 0;
	for(int i = 0; i < 4; i++) {
		char ch;
		cin >> ch;
		if(ch == '+') val++;
		else val--;
	}
	cout << val;
}


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

using namespace std;
#define ll long long
#define mod 1000000007

ll n;
ll dp[101][100001], pre[101][100001];
vector<ll> v;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    ll k;
    cin >> n >> k;

    v.resize(n);
    for (auto &i : v) {
        cin >> i;
    }

    for (ll j = 0; j <= k; j++) {
        dp[0][j] = (v[0] >= j) ? 1 : 0;
        pre[0][j] = dp[0][j] + (j ? pre[0][j - 1] : 0);
        pre[0][j] %= mod;
    }

    for (ll i = 1; i < n; i++) {
        for (ll j = 0; j <= k; j++) {
            dp[i][j] = pre[i - 1][j] - ((j - v[i] > 0) ? pre[i - 1][j - v[i] - 1] : 0);
            if (dp[i][j] < 0) {
                dp[i][j] += mod;
            }
            pre[i][j] = dp[i][j] + (j ? pre[i][j - 1] : 0);
            pre[i][j] %= mod;
        }
    }

    cout << dp[n - 1][k];
}


Measured memory_bytes: 159880
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

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

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

bool comp(pll& a, pll& b) {
    if(a.first != b.first) return a.first < b.first;
    else return b.second < a.second;
}

void solve() {
    ll n;
    cin >> n;
    vll l(n), r(n);
    for(ll i = 0; i < n; i++) {
        cin >> l[i] >> r[i];
        r[i]++;
    }
    ll lmax = *max_element(l.begin(), l.end());
    ll rmin = *min_element(r.begin(), r.end());
    ll ans = 0;
    for(ll i = 0; i < n; i++) {
        chmax(ans, r[i] - l[i] + max(rmin - lmax, 0ll));
    }
    vpll p(n);
    for(ll i = 0; i < n; i++) {
        ll a = max(r[i] - lmax, 0ll);
        ll b = max(rmin - l[i], 0ll);
        p[i] = make_pair(a, b);
    }
    sort(p.begin(), p.end(), comp);
    ll a = p[0].second;
    for(ll i = 0; i < n; i++) {
        chmax(ans, p[i].first + a);
        chmin(a, p[i].second);
    }
    cout << ans << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 6352
import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29

def main():
    n = int(input())
    t = list(map(int,input().split()))
    m = int(input())
    time = sum(t)
    for i in range(m):
        p,x = map(int,input().split())
        print(time-t[p-1]+x)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end(),greater<int>());
    int alice = 0;
    int bob = 0;
    for(int i = 0;i < n;i++){
        if(i % 2 == 0){
            alice += a[i];
        }else{
            bob += a[i];
        }
    }
    
    cout << alice - bob << endl;
    return 0;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

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

int x, y, s;

int rate(int a, int r) {
	int k = floor(a*(100 + r) / 100);
	return k;
}

int main()
{
	while (cin >> x >> y >> s) {
		if (x == 0 && y == 0 && s == 0)return 0;

		vector<int> d;
		for (int i = s - 1; i >= 1; i--) {
			d.push_back(s-floor(i*(100 + x) / 100));
		}
		//cout << "a" << endl;
		int mx = 0;
		int mxi=0, mxj=0;
		for (int i = 0; i < d.size(); i++) {
			int j = lower_bound(d.begin(), d.end()-1, s - d[i]) - d.begin();
			//cout << j << endl;
			if (j != (int)d.size()) {
				if (d[i] + d[j] == s) {
					mx = max(mx,rate(s - 1 - i, y) + rate(s - 1 - j, y));

				}
			}
		}
		cout << mx << endl;

	}


	return 0;
}



Measured memory_bytes: 3148
#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>
#include<complex>
#include<numeric>
#include<chrono>
using namespace std;

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

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
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++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);


int d;
int s[365][26];
int c[26];


int calc(vector<int>& v) {
	int sum = 0;
	int las[26]; rep(i, 26)las[i] = 0;


	int dec = 0;
	rep(j, 26)dec += c[j];

	int aldec = 0;

	rep(i, d) {
		aldec -= c[v[i]] * (i - las[v[i]]);

		sum += s[i][v[i]];
		las[v[i]] = i;

		sum -= aldec;
		aldec += dec;
	}
	return sum;
}

void query(vector<int> v) {
	rep(i, d) {
		cout << v[i] + 1 << "\n";
	}
}
void solve() {
	cin >> d;
	rep(i, 26)cin >> c[i];
	rep(i, d)rep(j, 26)cin >> s[i][j];

	//init_answer
	vector<int> v;
	int las[26]; rep(j, 26)las[j] = 0;
	int sum = 0;

	rep(i, d) {
		int ma = -mod;
		int chk = -1;
		rep(j, 26) {
			int ad = s[i][j];
			ad += c[j] * (i - las[j]);
			if (ma < ad) {
				ma = ad;
				chk = j;
			}
		}
		v.push_back(chk);
		las[chk] = i;

		sum += s[i][chk];
		rep(j, 26) {
			sum -= c[j] * (i - las[j]);
		}
	}

	random_device rnd; mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
	uniform_int_distribution<> ud(0, d - 1);
	uniform_real_distribution<> rd(0.0, 1.0);
	vector<int> alt = v;


	int cur = sum;

	int ans = cur;
	vector<int> out = v;

	const int tm = 45000;
	double arfa = 0.001;
	rep(i, tm) {
		int id = ud(mt);
		rep(j, 26) {
			if (j == v[id])continue;
			alt[id] = j;
			int val = calc(alt);
			if (ans < val) {
				v = alt;
				cur = val;

				out = alt;
				ans = val;
				break;
			}
			double d = rd(mt);
			double d1;
			if (cur < val)d1 = 1;
			else d1 = exp((val-cur) / (double)pow(arfa, i / (double)tm));
			if (d <= d1) {
				//cout << i << " " << d << " " << d1 << " " << val - cur << "\n";
				v = alt;
				cur = val;
				break;
			}
		}
		alt = v;
		/*if (i % 100 == 0) {
			double d=(double)pow(arfa, i / (double)tm);
			cout << d << "\n";
		}*/
	}

	//cout << ans << "\n";
	query(out);
}


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


Measured memory_bytes: 4376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
const ll MOD = 1e9+7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi C(n);
    for (int i=0; i<n; i++) cin >> C[i];
    vll dp(n+1);
    dp[n] = 1;
    unordered_map<int, int> next;
    for (int i=n-1; i>=0; i--) {
        dp[i] = dp[i+1];
        auto it = next.find(C[i]);
        if (it != next.end() && it->second != i+1) {
            dp[i] = (dp[i] + dp[it->second]) % MOD;
        }
        next[C[i]] = i;
    }
    cout << dp[0] << '\n';
}


Measured memory_bytes: 10824
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;

template<typename T> class CumulativeSum{
    public:
        vector<T> sum;

        CumulativeSum(int n);
        void add(int i, T x);
        void build();
        T get(int i);
};

template<typename T> CumulativeSum<T>::CumulativeSum(int n){
    sum = vector<T>(n, 0);
}

template<typename T> void CumulativeSum<T>::add(int i, T x){
    sum[i] += x;
}

template<typename T> void CumulativeSum<T>::build(){
    for (int i = 1; i < sum.size(); i++) sum[i] += sum[i - 1];
}

template<typename T> T CumulativeSum<T>::get(int i){
    if (i < 0) return 0;
    return sum[min(i, (int)sum.size() - 1)];
}


int main(){
    int n;
    cin >> n;
    CumulativeSum<ll> cs(n);
    for (int i = 0; i < n; i++){
        ll a;
        cin >> a;
        cs.add(i, a);
    }

    cs.build();

    ll ans = 1LL<<60;
    for (int i = 0; i < n - 1; i++){
        ans = min(ans, abs(cs.get(i) - cs.get(n - 1) + cs.get(i)));
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int n,m;

main(){
  cin>>n>>m;

  n-=2;
  m-=2;
  if(n<0) n=1;
  if(m<0) m=1;
  cout<<n*m<<endl;

}


Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
int main(void){
	long long N=0,f1=1e13,f0=-1e13,a=0,b=0;
	cin>>N;
	for(int i=1;i<=sqrt(N);i++)
	{
		a=i;
		b=N/i;
		if((abs(a-b)<abs(f0-f1))&&N%i==0)
		{
			f0=a;
			f1=b;
			//cout<<"a="<<a<<" b="<<b<<endl;
		}
	}
	cout<<f0+f1-2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#define LOCAL

int main()
{
    char ch;
    int ans=0;
    while((ch=getchar())!='\n')
        ans += ch - '0';
    if(ans%9==0)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 1532
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
    let (n, m) = read_touple::<usize>();
    
    if n >= m/2 {
        println!("{}", m/2);
    } else {
        let sub = m - 2*n;
        let add = sub/4;
        println!("{}", n + add);
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N; cin >> N;
    if(N==1){cout << 1 << endl;return 0;}
    ll ans = 0;
    rep(i,2,N+1){
        ll tmp = i*i;
        while(tmp <= N){
            chmax(ans,tmp);
            tmp *= i;
        }
    }
    cout << ans << endl;
    return 0;
}

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


def main():
    S = input().rstrip()
    rS = S[::-1]
    l = len(S)
    ans = 0
    for s1, s2 in zip(S[:l//2], rS[:l//2]):
        if s1 != s2:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9024
#include <stdio.h>

int GetMinIndex(int *a, int start, int len) {
  int min = a[start], minIndex = start;
  for (int i = start + 1; i < len; i++) {
    if (min > a[i]) {
      min = a[i];
      minIndex = i;
    }
  }
  return minIndex;
}

void Swap(int *a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

void ReadArray(int *a, int len) {
  for (int i = 0; i < len; i++) {
    scanf("%d", &a[i]);
  }
}

void PrintArray(int *a, int len) {
  for (int i = 0; i < len; i++) {
    printf("%d%c", a[i], i + 1 == len ? '\n' : ' ');
  }
}

void InsertionSort(int *a, int len) {
  // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A
  PrintArray(a, len);
  for (int i = 1; i < len; i++) {
    int v = a[i];
    int j = i - 1;
    while (j >= 0 && a[j] > v) {
      a[j + 1] = a[j];
      j--;
      a[j + 1] = v;
    }
    PrintArray(a, len);
  }
}

void BubbleSort(int *a, int len) {
  int flg = 1;
  int swapCount = 0;
  while (flg) {
    flg = 0;
    for (int i = 0; i < len - 1; i++) {
      if (a[i] <= a[i + 1]) continue;
      flg = 1;
      swapCount++;
      Swap(&a[i], &a[i + 1]);
    }
  }
  PrintArray(a, len);
  printf("%d\n", swapCount);
}

int main(int argc, char *argv[]) {
  int N;
  scanf("%d", &N);
  int a[N];
  ReadArray(a, N);
  // InsertionSort(a, N);
  BubbleSort(a, N);
  return 0;
}

Measured memory_bytes: 1716
import fractions
from functools import reduce

N = int(input())
A = list(map(int, input().split()))

p = 10**9+7

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

lcm = lcm_list(A)

B = [lcm//i for i in A]

print(sum(B)%p)

Measured memory_bytes: 264572
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAx = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,x,y,z;
long long max_value = INF, max_index = -1;
long long min_value = MAx, min_index = -1;

typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
    char a;
    cin >> a;
    cout << (char)(a+1);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,l;cin >> n >> l;
    int sum=0;
    for(int i=0;i<n;i++){
        sum+=l+i;
    }
    int m=inf,ans;
    for(int i=0;i<n;i++){
        int t=abs(l+i);
        if(t<m){
            ans=sum-l-i;
            m=t;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
pre = 0
max_move = 0
count = 0
for h in H:
  if pre < h:
    if max_move < count:
      max_move = count
    count = 0
  else:
    count += 1
  pre = h

if max_move < count:
  max_move = count

print(max_move)


Measured memory_bytes: 15020
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val s = 0.until(n).map {
        readLine()?.toInt() ?: return
    }
    val sum = s.sum()
    if (sum % 10 != 0) {
        println(sum.toString())
        return
    }
    s.sorted().find { it % 10 != 0 }?.let {
        println("${sum - it}")
    } ?: println("0")
}


Measured memory_bytes: 34416
n,m = map(int,input().split())
stairs = [True for _ in range(n+1)]
broken_stairs = [int(input()) for i in range(m)]
mod = 10**9+7

for i in broken_stairs:
    stairs[i] = False

dp = [0]*(n+1)

if stairs[1]:
    dp[1] = 1
    
if stairs[0]:
    dp[0] = 1


for i in range(2,n+1):
    if stairs[i]:
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= mod
    
    else:
        dp[i] = 0

print(dp[-1])

Measured memory_bytes: 8600
n=int(input())
a0,b0=1,1
for _ in range(n):
  a,b=map(int,input().split())
  k=max(a0//a+(a0%a>0),b0//b+(b0%b>0))
  a0,b0=a*k,b*k
print(a0+b0)

Measured memory_bytes: 3060
/*
	Teleporter
	https://atcoder.jp/contests/agc004/tasks/agc004_d
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

const int N = 100100;
int n, k;
int ans;
vector<int> g[N];

int dfs(int v) {
	int x = 0;
	for (int u : g[v]) {
		int y = dfs(u);
		if (v != 0 && y == k)
			ans++;
		else
			x = max(x, y);
	}
	return x + 1;
}

int main()
{
	startTime = clock();
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++) {
		int v;
		scanf("%d", &v);
		v--;
		if (i == 0) {
			if (v) ans++;
			continue;
		}
		g[v].push_back(i);
	}
	dfs(0);
	printf("%d\n", ans);

	return 0;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    long ans;
    long x[n];
    cin >> x[0];
    long x_all = 0;
    long x_duplication = 0;
    for(int i = 1; i < n; i++){
        cin >> x[i];
        x_duplication += n + 1 - i * 2;
        x_all += x_duplication * (x[i] - x[i - 1]);
        x_all %= long(1e9 + 7);
    }
    ans = x_all;
    long y[m];
    cin >> y[0];
    long y_all = 0;
    long y_duplication = 0;
    for(int i = 1; i < m; i++){
        cin >> y[i];
        y_duplication += m + 1 - i * 2;
        y_all += y_duplication * (y[i] - y[i - 1]);
        y_all %= long(1e9 + 7);
    }
    ans *= y_all;
    cout << ans % long(1e9 + 7) << endl;
}


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

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 19;

ll D;
int Dn[MAX_N], Nr[MAX_N];
int Dy[MAX_N][MAX_N][MAX_N][10][10];
bool Vis[MAX_N][MAX_N][MAX_N][10][10];
int getDy(int mx, int l, int r, int p, int m) {
	if(Vis[mx][l][r][p][m]) return Dy[mx][l][r][p][m]; Vis[mx][l][r][p][m] = true;
	int &val = Dy[mx][l][r][p][m];
	p *= 10;
	if(l == r) {
		if(p - m - Dn[l] == 0) {
			if(mx != l) return val = 10;
			else return val = 9;
		}else return val = 0;
	}
	if(l == r+1) {
		int pp = (p - Dn[l]) * 10 - Dn[r] - m;
//		printf("%d\n", pp);
		if(pp % 9) return val = 0;
		else {
			pp /= 9;
			if(abs(pp) > 9) return val = 0;
			int cnt = 10 - abs(pp);
			if(l == mx && pp <= 0) cnt--;
			return val = cnt;
		}
	}

	for(int i=0; i<10; i++) for(int j=0; j<10; j++) {
		if(mx < l && i != 0) break;
		if(mx == l && i == 0) break;
		int ll = p + j - i - Dn[l], rr = i - j - Dn[r] - m;
		if(abs(rr) % 10) continue;
		if(ll < 0) continue;
		int nm = abs(rr) / 10;
		int np = ll;
		if(nm > 4 || np > 4) continue;
		int plus = getDy(mx, l-1, r+1, np, nm);
//		printf("[%d %d] choose %d %d (%d %d) (+ %d)\n", l, r, i, j, np*10, nm, plus);
		val += plus;
	}
	return val;
}
ll rev(ll n) {
	ll r = 0;
	while(n) {
		r *= 10;
		r += n % 10;
		n /= 10;
	}
	return r;
}
int main() {
	cin >> D;
	if(D % 9) {
		printf("0\n");
		return 0;
	}
	/*
	int cnt = 0;
	for(int n=1; n<=D*1000; n++) {
		if(rev(n) == n+D) {
//			printf("[%lld : %d]", D, n);
			cnt++;
		}
	}
	printf("%d\n", cnt);
	*/


	ll temp = D;
	int maxD = -1;
	for(int i=0; i<MAX_N; i++) {
		Dn[i] = temp % 10, temp /= 10;
		if(Dn[i] != 0) maxD = i;
	}

	int ans = 0;
	for(int x=maxD; x<MAX_N; x++) {
		ans += getDy(x, x, 0, 0, 0);
//		printf("[%d : %d]\n", x, ans);
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 640
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    a=list(map(int,readline().split()))

    a.sort(reverse=True)
    ans=0
    j=1
    cnt=0
    for i in range(n):
        if i==0:
            continue
        elif i==1:
            ans+=a[0]
        else:
            ans+=a[j]
            cnt+=1

        if cnt==2:
            cnt=0
            j+=1

    print(ans)

if __name__=="__main__":
    main()

Measured memory_bytes: 31420
N,M=[int(x) for x in input().split()]
set1=[]
setn=[]
for i in [None]*M:
    ipt=[int(x) for x in input().split()]
    if 1 in ipt:
        set1 += ipt
    if N in ipt:
        setn += ipt
if set(set1) & set(setn):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 26564
#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <vector>

using Card = long;

struct BC
{
  int b;
  long c;
};

long solve(std::vector<Card> cards, std::vector<BC> bcs)
{
  std::sort(cards.begin(), cards.end());
  std::sort(bcs.begin(), bcs.end(),
      [](const BC& lhs, const BC& rhs) { return lhs.c > rhs.c; });

  auto first = cards.begin();
  long result = 0;
  for (const auto& bc : bcs) {
    const auto d = std::min(static_cast<int>(std::distance(first, cards.end())), bc.b);
    const auto lb = std::lower_bound(first, first + d, bc.c);
    const auto count = std::distance(first, lb);
    result += bc.c * count;
    first = lb;
  }

  return result + std::accumulate(first, cards.end(), 0l);
}

int main()
{
  int n;
  int m;
  std::cin >> n >> m;

  std::vector<Card> cards(n);
  for (auto& a : cards) {
    std::cin >> a;
  }

  std::vector<BC> bcs(m);
  for (auto& bc : bcs) {
    std::cin >> bc.b >> bc.c;
  }

  std::cout << solve(cards, bcs) << std::endl;
}


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

using ll = long long;

#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N, std::vector<ll> a) {
  vector<ll> s(N, -1);

  ll v = a.at(0);

  FOR(i, 1, N) { v = v ^ a.at(i); }

  rep(i, N) { s.at(i) = v ^ a.at(i); }

  rep(i, N) {
    if (i == N - 1) {
      cout << s.at(i);
    } else {
      cout << s.at(i) << " ";
    }
  }
  cout << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  std::vector<ll> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  solve(N, std::move(a));
  return 0;
}


Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    ll x;
    cin  >> x;
    int cnt=0;
    rep(i,100000000){
        if( ((i*(i+1))/2) >= x ) break;
        cnt ++ ;
    }
    cout << cnt << endl;
}

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

x, y, a, b, c = map(int, input().split())
red = list(map(int, input().split()))
gre = list(map(int, input().split()))
tra = list(map(int, input().split()))

red = sorted(red)[-x:]
gre = sorted(gre)[-y:]
uni = tra + red + gre

ans = sum(sorted(uni)[-(x+y):])
print(ans)


Measured memory_bytes: 102124
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename T, typename Can> T bsearch(T L, T R, Can&& can, bool left_feasible = true) {
    static_assert(is_convertible<decltype(can), function<bool(T)>>::value, "can must be bool(T)");
    T& feasible = left_feasible ? L : R;
    T& infeasible = left_feasible ? R : L;
    for(int i = 0; i < 100; i++) {
        T M = L + (R - L) / 2;
        (can(M) ? feasible : infeasible) = M;
    }
    return feasible;
}
const double pi = acos(-1);
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    double a, b, x;
    cin >> a >> b >> x;
    cout << fixed << setprecision(6) << bsearch<double>(0, pi / 2, [&](double theta) {
        double aa = sqrt(2 * x / (a * tan(theta)));
        if(aa <= a) {
            double bb = aa * tan(theta);
            return bb < b;
        } else {
            double bb = a * tan(theta);
            double y = (2 * x / (a * a) - bb) / 2;
            return bb + y < b;
        }
    }) * 180 / pi << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int N;
	int l;
	int r;
	
	int ans=0;
	
	int i=0;
	
	cin>>N;
	for(i=0;i<N;i++){
		cin>>l>>r;
		ans=ans+r-l+1;
	}
	
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

A = LI()

for i in range(5):
    if A[i] != i+1:
        print(i+1)
        break

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

int x, y, z;
pair<int, int> ans;
string a, b, c;

void calc(int x, int y, int z) {
	if (x == 0 && z == 0) {
		ans.first = 2, ans.second = y;
		return ;
	}
	if (x == 0 && y == 0) {
		ans.first = 3, ans.second = z;
		return ;
	}
	if (y == 0 && z == 0) {
		ans.first = 1, ans.second = x;
		return ;
	}
	if (x <= z) {
		for (auto it : c) a.push_back(it);
		calc(x, y, z - x);
	}
	else {
		string tmp = c;
		c = b;
		b.clear();
		for (auto it : a) b.push_back(it);
		for (auto it : tmp) b.push_back(it);
		calc(x - z, z, y);
	}
}

int main() {
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin >> x >> y >> z;
		if (x == 0) {
			x = y, y = z, z = 0;
			a.push_back('b'); b.push_back('c'); c.push_back('a');
		}
		else a.push_back('a'), b.push_back('b'), c.push_back('c');
		calc(x, y, z);
		for (int i = 0; i < ans.second; i++) {
			if (ans.first == 1) cout << a;
			else if (ans.first == 2) cout << b;
			else cout << c;
		}
		cout << '\n';
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x,k,count = 0;
  cin >> k >> x;
  for(int i = x-k+1; i <= k+x-1; i++) {
    if(count != 0) cout << " ";
    cout << i;
    count++;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
int main(){
    int p,q,r;
    cin>>p>>q>>r;
    cout<<min(min(p+q,p+r),q+r);
    }

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main()
{
string a,b,c;
cin>>a>>b>>c;
if (a.back()==b.front()&&b.back()==c.front())
{
    cout<<"YES"<<endl;
}
else
{
    cout<<"NO"<<endl;
}


    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from queue import deque

def main():
  h, w = map(int, input().split())
  grids = [False] * (w * h)
  dq = deque()
  for i in range(h):
    for j, c in enumerate(list(input().strip())):
      if c == '#':
        grids[i*w + j] = True
        dq.append((0, i, j))
  
  while dq:
    cnt, i, j = dq.popleft()
    for dx, dy in zip([-1, 0, 1, 0], [0, -1, 0, 1]):
      if 0 <= i+dx < h and 0 <= j+dy < w and not grids[(i+dx)*w + (j+dy)]:
        grids[(i+dx)*w + (j+dy)] = True
        dq.append((cnt+1, i+dx, j+dy))
  print(cnt)
  
if __name__=='__main__':
  main()



Measured memory_bytes: 142680
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

lint k;
string s;
lint mod = 1e9 + 7;

// nCr mod p(n<p)をキビキビ計算する
// 構築:O(n), クエリ:O(1)
struct combination_mod {
    using lint = long long int;
    int sz;
    lint mod;
    vector<lint> fac;
    vector<lint> finv;
    combination_mod(int _sz, lint _mod) : sz(_sz), mod(_mod) {
        fac.assign(sz + 1, 1);
        finv.assign(sz + 1, 1);
        vector<lint> inv(sz + 1, 1);
        for (int i = 2; i <= sz; i++) {
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
    lint query(int n, int r) {
        return fac[n] * (finv[r] * finv[n - r] % mod) % mod;
    }
};

// a^n mod pを計算　O(log n)
long long pow_mod(long long a, long long n, long long p) {
    if (n == 0) return 1;
    if (n & 1) return pow_mod(a, n - 1, p) * a % p;
    long long temp = pow_mod(a, n / 2, p);
    return temp * temp % p;
}

int main() {
    cin >> k >> s;
    lint n = s.length();
    combination_mod comb((n + k) * 2, mod);
    lint ans = 0;
    for (int i = n; i <= n + k; i++) {
        lint dp = comb.query(k + n, k + n - i) * pow_mod(25, k + n - i, mod) % mod;
        ans = (ans + dp) % mod;
    }
    cout << ans << endl;
}

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

bool f(int x){
  int keta =0;
  while(x){
    keta++;
    x/=10;
  }
  return keta%2==1;
}
int main(){
  int n;
  cin>> n;
  int ans=0;
  for(int i=1;i<=n;i++){
    if(f(i))ans++;
  }
  cout<< ans<< endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static const int INFH = (1<<30)-1;
static const int INFL = -INFH;
 
vector<pair<char, int>> runLength(string x)
{
	char now = x[0];
	int count = 1;
	vector<pair<char, int>> ret;
	for (int i = 1; i < x.size(); ++i)
	{
		if(x[i] != now)
		{
			ret.push_back(make_pair(now, count));
			now = x[i];
			count = 1;
		}
		else
		{
			++count;
		}
	}
	ret.push_back(make_pair(now, count));
	return ret;
}
 
long long int wa(long long int x)
{
	if (x%2==0)
	{
		return (long long int)((x/2)*(x+1));
	}
	else
	{
		return (long long int)(x*((x+1)/2));
	}
}
 
int main()
{
	string in;
	cin >> in;
	vector<pair<char, int>> r = runLength(in);
	long long int ans = 0;
	if(r.size() == 1)
	{
		cout << wa(r[0].second) << endl;
		return 0;
	}
	for (int i = 0; i < r.size(); ++i)
	{
		if(i == 0 && r[i].first == '>')
		{
			ans += wa(r[i].second);
		}
		else if (i == r.size() - 1 && r[i].first == '<')
		{
			ans += wa(r[i].second);
		}
		else
		{
			ans += wa(max(r[i].second, r[i + 1].second)) + wa(min(r[i].second, r[i + 1].second)-1);
			++i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3580
N = int(input())
A = list(map(int, input().split()))
A.sort()
if A[0] == 0:
    print(0)
else:
    ans = 1
    for a in A:
        ans *= a
        th = 10**18
        if ans > th:
            print(-1)
            exit(0)
    print(ans)

Measured memory_bytes: 21804
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    double ans=0;
    
    for(int i=0;i<n;i++){
        double hoge;
        cin>>hoge;
        ans+=1/hoge;
    }
    
    cout<<fixed<<setprecision(6)<<1/ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 101010101000;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;

int main(){
  ll a,b,k;
  cin>>a>>b>>k;
  if(a>=k) a-=k;
  else if(a+b>=k){
    b-=(k-a);
    a=0;
  }
  else{
    a=0;
    b=0;
  }
  cout << a << ' ' << b;
}

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

int main(){
	string s;
	cin >> s;
	int64_t ans = 0;
	for(int i = 0; i < 1 << (s.size() - 1); i++){
		int64_t tmp = 0, puni = 0;
		for(int j = 0; j < s.size(); j++){
			puni *= 10;
			puni += s[j] - '0';
			if((i >> j) & 1){
				tmp += puni;
				puni = 0;
			}
		}
		ans += tmp + puni;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
	int a=sc.nextInt();
	int b=sc.nextInt();
	if(a<b){
	    System.out.println("a < b");
	}else if(a>b){
	    System.out.println("a > b");
	}else{
	    System.out.println("a == b");
	}
    }
}	

Measured memory_bytes: 26152
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <functional>
using namespace std;

typedef long long ll;

bool used[100003];

int main() {
	int k; cin >> k;
	deque<pair<int, int>> que;
	que.push_back({ 1, 1 });
	while (!que.empty()) {
		int d = que.front().first, t = que.front().second; que.pop_front();
		if (t == 0) {
			cout << d << endl;
			return 0;
		}
		if (used[t]) continue;
		used[t] = true;
		if (!used[(t + 1) % k]) que.push_back({ d + 1, (t + 1) % k });
		if (!used[(10 * t) % k]) que.push_front({ d, (10*t) % k });
	}
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
int main(){
	std::string m[3], w;
	while(std::cin >> m[0], m[0][0] != '0'){
		for(int i=1;i<3;i++)std::cin >> m[i];
		w = "NA";
		for(int i=0;i<3;i++){
			char c = m[i][0];
			if(2 * c - m[i][1] - m[i][2] == 0 && c - '+')w = c;
			c = m[0][i];
			if(2 * c - m[1][i] - m[2][i] == 0 && c - '+')w = c;
		}
		if(m[0][0] + m[1][1] - m[2][2] * 2 == 0 && m[0][0] - '+')w = m[0][0];
		if(m[0][2] + m[1][1] - m[2][0] * 2 == 0 && m[0][2] - '+')w = m[0][2];
		
		std::cout << w << '\n';
	}
}

Measured memory_bytes: 0
package main

import "fmt"

func main() {
	var N, K int
	MOD := 1000000000 + 7
	fmt.Scan(&N, &K)
	ans := 1
	for i := K; i < N+1; i++ {
		min_d, max_d := i * (i + 1) / 2, i * (2*(N+2-i) + (i - 1)) / 2
		ans += max_d - min_d + 1
		ans %= MOD
	}
	fmt.Println(ans)
}


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

using namespace std;

// 一点変更,区間GCD,セグメントツリー

template<typename type = int>
class segment_tree_gcd {
private:
    const int n;
    std::vector<type> st;
    const type LIM = 0;
    inline type query(int l, int r, int k, int L, int R) {
        if (R <= l || r <= L) {
            return LIM;
        }
        if (l <= L && R <= r) {
            return st[k];
        }
        type res = LIM;
        type h = (L + R) >> 1;
        if (l < h) {
            res = query(l, r, (k << 1) + 1, L, h);
        }
        if (h < r) {
            type rRet = query(l, r, (k << 1) + 2, h, R);
            if (rRet != LIM) {
                if (res == LIM) {
                    res = rRet;
                } else {
                    res = __gcd(res, rRet);
                }
            }
        }
        return res;
    }
    inline bool valid_query(int l, int r, int k, int L, int R, int cond) {
        if (R <= l || r <= L) {
            return true;
        }
        if (l <= L && R <= r) {
            return st[k] % cond == 0;
        }
        bool res = true;
        int h = (L + R) >> 1;
        return valid_query(l, r, (k << 1) + 2, h, R, cond) && valid_query(l, r, (k << 1) + 1, L, h, cond);
    }
    inline void update(int id, type el, int k, int L, int R) {
        if (id < L || R <= id) {
            return;
        }
        if (L + 1 == R && id == L) {
            st[k] = el;
            return;
        }
        const int h = (L + R) >> 1;
        update(id, el, (k << 1) + 1, L, h);
        update(id, el, (k << 1) + 2, h, R);
        st[k] = __gcd(st[(k << 1) + 2], st[(k << 1) + 1]);
    }
public:
    segment_tree_gcd() : n(-1) {}
    segment_tree_gcd(int _n) : n(_n), st(_n << 2, LIM){}
    //範囲 [l, r) !!!!!
    inline type query(int l, int r) {
        return this->query(l, r, 0, 0, n);
    }
    // gcd が cond の倍数になるか
    inline type valid_query(int l, int r, int cond) {
        return this->valid_query(l, r, 0, 0, n, cond);
    }
    inline void update(int id, type el) {
        update(id, el, 0, 0, n);
    }
};

int main() {
  int n;
  cin >> n;
  segment_tree_gcd<long long> seg(n);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    seg.update(i, a);
  }
  
  long long ans = seg.query(1, n);
  for (int i = 1; i < n; i++) {
    const auto l = seg.query(0, i);
    const auto r = seg.query(i + 1, n);
    ans = max(ans, __gcd(l, r));
  }
  ans = max(ans, seg.query(0, n - 1));

  cout << ans << endl;
}


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

// 
// https://abc097.contest.atcoder.jp/submissions/2502682 
//
int main()
{
	string S;
	int K;

	vector < string > vec;
	
	cin >> S >> K;

	for ( int i = 0; i < S.size(); i++ ) {
		for ( int j = 1; i + j <= S.size() && j <= K; j++ ) {
			vec.push_back(S.substr(i, j));
		}
	}
	sort(begin(vec), end(vec));	
	vec.erase(unique(begin(vec), end(vec)), end(vec));

	cout << vec[K - 1] << endl;

	return (0);
}



Measured memory_bytes: 1660
n,l=map(int,input().split())
taste=[l+i-1 for i in range(1,n+1)]
ttastee=[]
for i in taste:
	if i<0:
		ttastee.append(i*(-1))
	else:
		ttastee.append(i)

taste.pop(ttastee.index(min(ttastee)))
print(sum(taste))

Measured memory_bytes: 3060
# Problem A - Colorful Slimes 2

# input process
N = int(input())
a_list = list(map(int, input().split()))

# initialization
magic_num = 0
chohuku_num = 0

# count process
for i in range(0, N):
    if i==0:
        continue

    if a_list[i]==a_list[i-1]:
        chohuku_num += 1
    else:
        magic_num += (chohuku_num + 1) // 2
        chohuku_num = 0
magic_num += (chohuku_num + 1) // 2

print(magic_num)


Measured memory_bytes: 38256