akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <stdlib.h>
#include <functional>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <set>
#include <queue>
#include <map>
using namespace std;
int main(){
	string a("abcdefghijklmnopqrstuvwxyz");
	string s;
	int k;
	cin>>s>>k;
	int len=s.size();
	for(int i=0;i<len;i++){
		int b=0;
		for(int j=0;j<26;j++){
			if(a[j]==s[i]){
				b=j;
				break;
			}
		}
		if(26-b<=k&&b>0){
			s[i]='a';
			k=k-(26-b);
		}
	}
	if(k>0){
		int c;
		for(int j=0;j<26;j++){
			if(a[j]==s[len-1]){
				c=j;
				break;
			}
		}		
		s[len-1]=a[(c+k)%26];
	}
	cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; 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;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
long long int dp[100040] = {};
int main() {
	long long int n;
	cin >> n;
	long long int ans = 0;
	for (long long int i = 1; i <= pow(n,0.5); i++) {
		if (i * i <= n) {
			ans = max(ans, i*i);
		}
	}
	cout << ans;
}


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

int main(){
    string a, b;
    cin >> a >> b;
    if ((a == "H" && b=="H") || (a=="D" && b=="D")){
        cout << "H" << endl;
    }else if ((a == "D" && b=="H") || (a=="H" && b=="D")){
        cout << "D" << endl;
    }
    
}


Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio

using namespace std;

inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }

const int N = 1000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

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

int n, m;
string a[N];
int d[N][N];

int bfs() {
    queue<pair<int, int> > q;
    rep(i, 0, n) {
        rep(j, 0, m) {
            if (a[i][j] == '#') {
                d[i][j] = 0;
                q.push({i, j});
            } else {
                d[i][j] = inf;
            }
        }
    }
    while (!q.empty()) {
        int x = q.front().fi, y = q.front().se;
        q.pop();
        rep(i, 0, 4) {
            if (x + dx[i] >= 0 && x + dx[i] < n && y + dy[i] >= 0 && y + dy[i] < m) {
                if (d[x + dx[i]][y + dy[i]] == inf) {
                    d[x + dx[i]][y + dy[i]] = d[x][y] + 1;
                    q.push({x + dx[i], y + dy[i]});
                }
            }
        }
    }
    int ans = 0;
    rep(i, 0, n) {
        rep(j, 0, m) {
            setmax(ans, d[i][j]);
        }
    }
    return ans;
}

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    cin >> n >> m;
    rep(i, 0, n) {
        cin >> a[i];
    }
    cout << bfs() << "\n";
    return 0;
}

Measured memory_bytes: 13456
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod = 1e9+7;
char a[105];
char b[105];
int main(void)
{
	int n;
	scanf("%d",&n);
	scanf("%s",a);
	scanf("%s",b);
	int cnt=0;
	for(int i=0;i<n;i++){
		int flag=1;
		for(int j=0;j+i<n;j++){
			if(a[j+i]!=b[j]){
				flag=0;
				break;
			}
		}
		if(flag){
			cnt=n-i;break;}
	}
	printf("%d\n",2*n-cnt);
	return 0;
}


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

namespace AtCorder
{
	public class Program
	{
		const long MOD = 1000000007;
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			long[] a = cin.ArrayLong(n);

			long ans = 1;
			long c1 = 0;
			long c2 = 0;
			long c3 = 0;
			for (int i = 0; i < n; i++) {
				long val = a[i];
				if (c1 == val && c2 == val && c3 == val) {
					ans = (ans * 3) % MOD;
					c1++;
				} else if (c1 == val && c2 == val) {
					ans = (ans * 2) % MOD;
					c1++;
				} else if (c1 == val) {
					c1++;
				} else if (c2 == val && c3 == val) {
					ans = (ans * 2) % MOD;
					c2++;
				} else if (c2 == val) {
					c2++;
				} else if (c3 == val) {
					c3++;
				} else {
					Console.WriteLine(0);
					return;
				}
			}

			Console.WriteLine(ans);
		}
	}


	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 19296
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

int N, M, K, Q, W, H, R, C;
string S;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;

    REP(i, 2000) {
        double moto = (double)i;
        if ((int)floor(moto * 0.08) == A && (int)floor(moto * 0.1) == B) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

long long x[10];

void swap(long long *a, long long *b){
    long long tmp;
    tmp = *a; *a = *b; *b = tmp;
}

int main(){
    int r, d, xx;
    scanf("%d%d%d", &r, &d, &xx);
    for(int i = 0; i < 10; i++){
        if(i == 0) x[i] = 1ll * r * xx - 1ll * d;
        else x[i] = 1ll * r * x[i - 1] - 1ll * d;
    }
    for(int i = 0; i < 9; i++){
        for(int j = i + 1; j < 10; j++){
            if(x[i] > x[j]) swap(&x[i], &x[j]);
        }
    }
    for(int i = 0; i < 10; i++) printf("%d\n", x[i]);
}

Measured memory_bytes: 128
#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<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
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 long double ld;
typedef complex<ld> Point;
const ld eps = 1e-3;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int h[1 << 17]; int n;
ll dp[1 << 17];
int main() {
	cin >> n;
	rep1(i, n)cin >> h[i];
	dp[1] = 0; dp[2] = abs(h[2] - h[1]);
	Rep1(i, 3, n) {
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << dp[n] << endl;
	//stop
	return 0;
}

Measured memory_bytes: 1408
N,K=map(int,input().split())
li=[]
ans=0
for i in range(K):
    A=int(input())
    li.append(list(map(int,input().split())))

flat=[flatten for inner in li for flatten in inner]


B=len(flat)


for k in range(N):
        if k+1 in flat:
            pass
        else:
            ans=ans+1
        
print(ans)


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

using namespace std;

const int MAX_N = 5 * (int) 1e5;
int n;
int v[MAX_N];

bool check(int x)
{
    int middle = n - 1;
    int range = 1;

    while (range <= n - 1 && ((v[middle - range] >= x) == (v[middle + range] >= x)) && ((v[middle - range] >= x) != (v[middle - range + 1] >= x)))
        range++;

    return v[middle - range + 1] >= x;
}

int binsearch(int left, int right)
{
    if (left == right)
        return left;
    if (left == right - 1)
    {
        if (check(right))
            return right;
        else
            return left;
    }

    int middle = (left + right) / 2;

    if (check(middle))
        return binsearch(middle, right);
    else
        return binsearch(left, middle - 1);
}

int main()
{
    scanf("%d", &n);
    int s = 2 * n - 1;

    for(int i = 0; i < s; i++)
    {
        scanf("%d", &v[i]);
    }

    int _min = v[0], _max = v[0];
    for(int i = 1; i < s; i++)
    {
        _min = min(_min, v[i]);
        _max = max(_max, v[i]);
    }
    printf("%d", binsearch(_min, _max));

    return 0;
}


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

int main() {
  int a = 0;
  int b = 0;
  int c = 0;
  cin >> a >> b;
  c = (a + b) /2;
  if((a + b)%2 != 0)
  {
    c += 1;
  }
  cout << c << endl;
}

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

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

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
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);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    string s; cin >> s;
    int bl=0, wr=0;
    vec bc(N+1, 0), wc(N+1, 0);
    rep(i, N){
        if(s[i] == '.'){
            wr = max(wr, i);
            bc[i+1] = bc[i];
        }else{
            bc[i+1] = bc[i]+1;
        }
    }
    reverse(all(s));
    rep(i, N){
        if(s[i] == '#'){
            bl = max(bl, i);
            wc[i+1] = wc[i];
        }else{
            wc[i+1] = wc[i]+1;
        }
    }
    ll res = INF;
    rep(i, N+1){
        res = min(res, (ll)bc[i]+wc[N-i]);
    }
    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 6420
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=b-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
#define vec vector
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main(){
	fast_io();
	int n,k;
	cin >> n >> k;
	ll dp[n+1][k+1] = {};
	dp[0][0] = 1;
	fu(i,1,n){
		int a;
		cin >> a;
		ll rsum = 0;
		fu(j,0,k){
			rsum += dp[i-1][j];	
			if(j-a-1 >= 0)rsum -= dp[i-1][j-a-1];
			rsum %= MOD;rsum+=MOD;rsum%=MOD;
			dp[i][j] = rsum;
		}
	}
	cout << dp[n][k] << '\n';
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  string s;
  cin >> s;
  int n = s.size();
  bool ok_1 = true, ok_2 = true, ok_3 = true;

  for (int i = 0; i < n / 2; i ++) {
    if (s[i] != s[n - i - 1]) ok_1 = false;
  }

  int m = (n - 1) / 2;
  for (int i = 0; i < m; i ++) {
    if (s[i] != s[m - i - 1]) ok_2 = false;
  }

  int l = (n + 3) / 2;
  for (int i = 0; i < n - l; i ++) {
    if (s[l + i - 1] != s[n - i - 1]) ok_3 = false;
  }

  if (ok_1 && ok_2 && ok_3) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;

	ll dist = abs(a - b);
	ll u = v - w;

	if (a == b) YES();
	else {
		if (u > 0 && dist <= u * t) YES();
		else NO();
	}
}


Measured memory_bytes: 3656
#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>;


int main() {
    int N;
    cin >> N;
    vector<int> v(N);
    rep(i,N) cin >> v.at(i);

    sort(v.begin(), v.end());
    double ans = (v.at(0) + v.at(1)) / 2.0;
    rep(i,N-2) {
        ans = (ans + v.at(i+2)) / 2.0;
    }
    cout << fixed << setprecision(7) << ans << endl;
}


Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
string s,p;
int main()
{
    ft
    ll t,i,j,n,m,l=0,r,x;
    cin>>s>>p;
    n=s.size();
    for(i=0;i<n;i++)
    {
        if(s[i]==p[i])
        {
            l++;
        }
    }
    cout<<l<<"\n";
    return 0;
}



Measured memory_bytes: 3520
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int r,g,b;
  cin>>r>>g>>b;
  if((r*100+g*10+b)%4==0){
    cout<<"YES"<<'\n';
  }
  else{
    cout<<"NO"<<'\n';
  }
  return(0);
}


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

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

        int ans =n%10;
        if(ans ==2||ans == 4|| ans == 5||ans == 7|| ans ==9)
        {
                cout << "hon" << endl;
        }
        else if(ans == 0|| ans == 1|| ans == 6|| ans == 8)
        {
                cout << "pon" << endl;
        }
        else if(ans == 3)
        {
                cout << "bon" << endl;
        }
}


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

int main(){
  int n,k;cin>>n>>k;
  vector<int> arr(n);
  for(int i=0;i<n;++i)cin>>arr[i];
  vector<int> dp(n,1e9);
  dp[0] = 0;
  for(int i=1;i<n;++i){
    for(int j=1;j<=min(i,k);++j){
    	dp[i] = min(dp[i-j]+abs(arr[i]-arr[i-j]),dp[i]);
    }
    //cout<<dp[i]<<" ";
  }
  //cout<<endl;
  cout<<dp[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K, A;
  cin >> N >> K;
  A = 1;
  for( int i=0; i<N; i++){
    if ( (A*2) < (A+K) ){
      A*=2;
    }
    else{
      A+=K;
    }
  }
  cout << A << endl;
}

Measured memory_bytes: 256
t = 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
print(t[int(input())-1])


Measured memory_bytes: 38256
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++){
		    a[i] = sc.nextInt();
		}
		
		// 計算
		String result = "Second";
		boolean[] dp = new boolean[k+1];
		for(int i = 0; i < k+1; i++){
		    for(int j = 0; j < n; j++){
		        if(i-a[j] >= 0 && !dp[i-a[j]]) dp[i] = true;
		    }
		}
		if(dp[k]) result = "First";
		
		// 出力
		System.out.println(result);
	}

	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	ll n, i;
	cin >> n;
	vector <int> v;
	for(i = 2; i <= sqrt(n); i++) {
		int cnt = 0;
		while(n % i == 0) {
			n /= i;
			cnt++;
		}
		if(cnt) v.pb(cnt);
	}
	if(n > 1)
	v.pb(1);
	
	int ans = 0;
	for(int x : v) {
		int curr = 0, cnt = 0, i = 1;
		while(curr + i <= x) {
			curr += i;
			i++;
			cnt++;
		}
		ans += cnt;
	}
	cout << ans;
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
using namespace std;
ll n,k;
int main(){
	cin >> n >> k;
	
	for(int i=1; i<=n; i++){
		if(i%2)k--;
	}
	
	if(k<=0)cout << "YES";
	else cout<<"NO";
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  string s;
  cin >> s;
  int bottom = 0, top = s.size()-1;
  int ans = 0;
  while (bottom < top) {
    if (s[bottom] == 'x' && s[top] == 'x') {
      bottom++; top--;
      continue;
    }
    if (s[bottom] == 'x') {
      bottom++; ans++;
      continue;
    }
    if (s[top] == 'x') {
      top--; ans++;
      continue;
    }
    if (s[bottom] != s[top]) {
      cout << -1 << endl;
      return 0;
    }
    bottom++; top--;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
n=int(input())
a=list(map(int,input().split()))
dic={}
for i in range(1,n+1):
  dic[a[i-1]]=i
sorted_dict=sorted(dic.items(), key=lambda x:x[0])
ans=""
for i in range(n):
  ans+=str(sorted_dict[i][1])+" "
print(ans)

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

int main()
{
    int number,score,n;
    int winnerNumber,winnerScore = -1;

    cin >> n;

    for(int i=0; i<n; i++){
        cin >> number >> score;

        if(score > winnerScore ){
            winnerScore = score;
            winnerNumber = number;
            continue;
        }
        if(score == winnerScore && number < winnerNumber){
            winnerScore = score;
            winnerNumber = number;
        }
    }

    cout << winnerNumber << ' ' << winnerScore << endl;

    return 0;
}

Measured memory_bytes: 1160
// Vicfred
// https://atcoder.jp/contests/abc160/tasks/abc160_e
// greedy
import std.algorithm;
import std.math;
import std.array;
import std.conv;
import std.stdio;
import std.container;

void main() {
    long x, y, a, b, c;
    readf("%s %s %s %s %s", &x, &y, &a, &b, &c);
    readln;

    auto p = readln.split.map!(to!long).array;
    auto q = readln.split.map!(to!long).array;
    auto s = readln.split.map!(to!long).array;

    reverse(sort(p));
    reverse(sort(q));
    reverse(sort(s));

    long ans = 0;

    foreach(i; 0..x)
        ans += p[i];

    foreach(i; 0..y)
        ans += q[i];

    x -= 1;
    y -= 1;

    foreach(apple; s) {
        if((x >= 0 && apple > p[x]) && (p[x] < q[y] || y < 0)) {
            ans += apple - p[x];
            x -= 1;
        }
        else if(y >= 0 && apple > q[y]) {
            ans += apple - q[y];
            y -= 1;
        } else {
            break;
        }
    }

    ans.writeln;
}



Measured memory_bytes: 12872
n, k = map(int, input().split())
s = input()
a = [0]
for i in range(n):
    if (s[i] == "0") == (len(a) % 2 == 1):
        a.append(1)
    else:
        a[-1] += 1
t = [0]
for i in a:
    t.append(i + t[-1])
ans = 0
for i in range(len(t)):
    if i % 2 == 0:
        # print(min(i + 2 * k + 1, len(t) - 1))
        ans = max(ans, t[min(i + 2 * k + 1, len(t) - 1)] - t[i])
print(ans)


Measured memory_bytes: 13784
n,k = map(int,input().split())
p = list(map(int,input().split()))
mx = sum(p[0:k])
zn = sum(p[0:k])
for i in range(n-k):
  zn -= p[i]
  zn += p[i+k]
  if zn > mx:
    mx = zn
print((mx+k)/2) 
  
  
  

Measured memory_bytes: 25060
n,k = gets.chomp.split.map{ |item| item.to_i}
arr = gets.chomp.split.map{ |item| item.to_i}
hash = Hash.new(0)
arr.each do |i|
  hash[i] += 1
end
size = hash.size - k
arr = hash.sort{ |(k1,v1),(k2,v2)| v1 <=> v2}
ans = 0
size.times do |i|
  ans += arr[i][1]
end
print ans,"\n"


Measured memory_bytes: 42232
m,d=map(int,input().split())
x=0
if m>=4 and d>=22:
  for i in range(4,m+1):
    for j in range(22,d+1):
      if j%10>1 and int(str(j)[1])*int(str(j)[0])==i:
        x+=1
print(x)

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

int main(){
  int X, thou, five;
  cin >> X;
  thou = int(X / 500);
  five = int((X - (500 * thou)) / 5);
  int result = thou * 1000 + five * 5;
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
/*
created by sanyam singhal
*/

#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long int
#define mod 1000000007
#define w(t) int t;	cin>>t while(t--)
#define triplet pair<int,pair<int,int>>
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define fastIO ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
#define loop(i, k, n) for(ll i=k; i<n; i+=1)
#define loop2(i, k, n) for(ll i=k; i>=n; i--)

const ll inf = 1e18;
const int N = 500;

ll dp[N][N];
ll sumij[N][N];

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

ll solve_by_dp(vector<ll> &a, ll i, ll j){
  if(j==i){
    return 0;
  }
  else if(dp[i][j]!=-1)
    return dp[i][j];
  else{
    ll ans = LLONG_MAX;
    for(ll k=i+1; k<=j; k++){
      ll part1 = solve_by_dp(a, i, k-1);
      ll part2 = solve_by_dp(a, k, j);
      ll curr_ans = part1 + part2 + sumij[i][k-1] + sumij[k][j];
      // cout<<curr_ans<<endl;
      if(curr_ans < ans){
        ans = curr_ans;
      }
    }
    return dp[i][j] = ans;
  }
}

void solve(){
  ll n; cin>>n;
  vector<ll>a(n);
  loop(i, 0, n) 
    cin>>a[i];

  memset(dp, -1, sizeof(dp));
  // loop(i, 0, n)
  //   cout<<a[i]<<" ";

  for(int i=0; i<n; i++){
    for(int j=i; j<n; j++){
      for(int k=i; k<=j; k++){
        sumij[i][j] += a[k];
      }
    }
  }

  // for(int i=0; i<n; i++){
  //   for(int j=0; j<n; j++){
  //     cout<<sumij[i][j]<<" ";
  //   }
  //   cout<<endl;
  // }

  cout<<solve_by_dp(a, 0, n-1)<<endl;
  return;
}

int main(){

  fastIO;
  // take_fileIO();
  solve();
  return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    
    if(a<b){
        cout << "a < b" << endl;
    }else if(a>b){
        cout << "a > b" << endl;
    }else{
        cout << "a == b"<< endl;
    }
    
    return 0;
}


Measured memory_bytes: 3048
#include<bits/stdc++.h>
using namespace std;
int n,m;
int ans=0;
struct jobs {
	int day,reward;
	friend bool operator < (const jobs &x,const jobs &y){
		if(x.reward<y.reward) return true;
		else return false;
	}
};jobs j[100010];
bool cmp(const jobs &x,const jobs &y) {
	if(x.day>y.day) return true;
	else return false;
}
int main() {
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) {
		scanf("%d%d",&j[i].day,&j[i].reward);
		j[i].day=m-j[i].day;
	}
	sort(j+1,j+1+n,cmp);
	priority_queue<jobs> q;
	int t=1;
	for(int i=m-1;i>=0;i--) {
		while(j[t].day>=i && t<=n) q.push(j[t]),t++;
		if(!q.empty()) {
			ans+=q.top().reward;
			q.pop();
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back;
#define IOS ios_base::sync_with_stdio(NULL);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
    IOS;
    int a ,b , c;
    cin>>a>>b>>c;
    cout<<c<<' '<<a<<' '<<b<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

// #define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) ;
#define LINE 	;
#define dumpV(v);
#define STOP 	;
#endif
#define mp make_pair

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fi<<", "<<a.se<<')';
    return out;
  }
}


int main(){
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	rep(i, h) cin >> s[i];
	auto isOutOfRange = [](int h, int w, int H, int W) {
		return h < 0 || h >= H || w < 0 || w >= W;
	};
	
	rep(i, h) rep(j, w) {
		if(s[i][j] == 'x') {
			REP(k, -1, 2) REP(l, -1, 2) {
				int x = j + l;
				int y = i + k;
				if(isOutOfRange(y, x, h, w) || s[y][x] != '-') continue;
				s[y][x] = 'z';
			}
		}
		else if(s[i][j] == 'o') {
			REP(k, -1, 2) {
				int x = j + k;
				int y = i;
				if(isOutOfRange(y, x, h, w) || s[y][x] != '-') continue;
				s[y][x] = 'z';
			}
		}
	}
	int ans = 0;
	REP(i, 1, h) rep(j, w) if(s[i][j] == '-') ans++;
	cout << ans << endl;
	rep(i, h) dump(s[i]);
	return 0;
}

Measured memory_bytes: 3240
#include<stdio.h>

int main(void){
    int n, p[50], i, x=0;

    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &p[i]);
        if(p[i] != i+1){
            x++;
        }
    }
    if(x > 2){
        printf("NO\n");
    }else{
        printf("YES\n");
    }
    return 0;
}

Measured memory_bytes: 1644
#include<stdio.h>

int main(void)
{
  int n, r, a;
  
  scanf("%d%d",&n,&r);
  
  if(n>=10) printf("%d\n",r);
  
  else{
    a=r+(100*(10-n));
    printf("%d\n",a);
  }
  return 0;
}

Measured memory_bytes: 128
// median time 21mins
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)

int main()
{
    ll N;
    cin >> N;
    cout << (N - 1) * N / 2 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100

int main(void){
  	void check(char [],char[]);
  	char s[N],s_n[N];
  
	scanf("%s",&s);
 	scanf("%s",&s_n);
  
  	check(s,s_n);
  	return 0;
}

void check(char s[N], char s_n[N]){
  	int F = 1;
  	for(int j = 0; s[j] != '\0';j++){
      	//printf("s = %c, s_n = %c\n",s[j],s_n[j]);
     	if(s[j] != s_n[j]){
          	printf("No\n");
          	F = 0;
          	break;
        }     
    }
  	if(F)
      printf("Yes\n");
}



Measured memory_bytes: 1628
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  string S;
  cin >> S;
  S[3] = '8';
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
  int root(int x) {
        if (data[x] < 0) return x;
        else return data[x] = root(data[x]);
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main() { 
  int n,m;
  cin >> n >> m;
  vi p(n),pi(n);
  UnionFind tree(n);
  rep(i,n){
    cin >> p[i];
    p[i]--;
    pi[p[i]] = i;
  }
  rep(i,m){
    int x,y;
    cin >> x >> y;
    x--;y--;
    tree.unite(x,y);
  }
  int ans = 0;
  rep(i,n){
    if(tree.same(i,pi[i]) || i == p[i])ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1408
#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;

int n, v[200000], g[200000];
vector<vi> e;

void rec(int c, vi &stk, vi &loop){
	//dbg(c);
	v[c] = 1;
	stk.pb(c);
	for(int i : e[c]) if(v[i] != 2){
		if(v[i] == 1){
			for(int j = stk.size() - 1; ; j--){
				assert(j >= 0);
				loop.pb(stk[j]);
				if(stk[j] == i) break;
			}
			return;
		}
		else rec(i, stk, loop);
		if(loop.size()) return;
	}
	v[c] = 2;
	stk.pop_back();
}
int grundy(int c){
	if(g[c] >= 0) return g[c];
	set<int> s;
	for(int i : e[c]) s.insert(grundy(i));
	for(int i = 0; ; i++) if(!s.count(i)) return g[c] = i;
}
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	cin >> n;
	e.resize(n);
	rep(i, n){
		int p; cin >> p;
		e[p - 1].pb(i);
	}
	vi stk, loop;
	rep(i, n) if(!v[i]){
		rec(i, stk, loop);
		if(loop.size()) break;
	}
	if(loop.empty()){
		cout << "POSSIBLE" << endl;
		return 0;
	}
	memset(g, -1, sizeof(g));
	for(int i : loop) g[i] = -2;
	rep(i, n) if(g[i] == -1) grundy(i);
	
	//dbg(loop);
	
	vi tmp(n);
	rep(i, n) tmp[i] = g[i];
	
	rep(it, 2){
		rep(i, n) g[i] = tmp[i];
		int v = loop[0], a = -1, b = -1;
		bool ok = 1;
		set<int> s;
		for(int i : e[v]) s.insert(g[i]);
		for(int i = 0; b < 0; i++) if(!s.count(i)){
			if(a < 0) a = i;
			else b = i;
		}
		g[v] = it ? a : b;
		for(int i : loop) grundy(i);
		for(int c : loop){
			set<int> ss;
			for(int i : e[c]){
				assert(g[i] >= 0 && g[c] >= 0);
				ss.insert(g[i]);
			}
			if(ss.count(g[c])){
				ok = 0;
				break;
			}
			for(int i = 0; i < g[c]; i++) if(!ss.count(i)){
				ok = 0;
				break;
			}
		}
		if(ok){
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 24308
menu = [int(input()) for ii in range(0,5)]
remainder=[0]*len(menu)

for ii in range(0,len(menu)):
    remainder[ii] =abs(10-menu[ii] % 10)
    if remainder[ii] == 10:
        remainder[ii]=0

final_menu_index = remainder.index(max(remainder))

print(sum(menu)+sum(remainder)-remainder[final_menu_index])


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());

    vector<ll> v1, v2;
    for (int i = 0; i < n; i++) {
        if (a[i] < 0) v1.push_back(a[i]);
        else v2.push_back(a[i]);
    }
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());

    vector<P> ans;
    ll sum = 0;
    if (v1.empty()) {
        ll tmp = v2[0];
        for (int i = 1; i < v2.size(); i++) {
            if (i + 1 < v2.size()) {
                ans.emplace_back(tmp, v2[i]);
                tmp -= v2[i];
            } else {
                ans.emplace_back(v2[i], tmp);
                tmp = v2[i] - tmp;
            }
        }
        sum = tmp;
    } else {
        if (v2.empty()) {
            ll tmp = v1.back();
            for (int i = 0; i + 1 < v1.size(); i++) {
                ans.emplace_back(tmp, v1[i]);
                tmp -= v1[i];
            }
            sum = tmp;
        } else {
            ll tmp = v1[0];
            for (int i = 1; i < v2.size(); i++) {
                ans.emplace_back(tmp, v2[i]);
                tmp -= v2[i];
            }

            ans.emplace_back(v2[0], tmp);
            tmp = v2[0] - tmp;
            for (int i = 1; i < v1.size(); i++) {
                ans.emplace_back(tmp, v1[i]);
                tmp -= v1[i];
            }
            sum = tmp;
        }
    }

    cout << sum << "\n";
    for (int i = 0; i < n - 1; i++) {
        cout << ans[i].first << " " << ans[i].second << "\n";
    }
    return 0;
}

Measured memory_bytes: 6384
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int
var t float64

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n, u, v := intScanner(), intScanner()-1, intScanner()-1
	edges := make([][]int, n)
	for i := 0; i < n-1; i++ {
		a, b := intScanner()-1, intScanner()-1
		edges[a] = append(edges[a], b)
		edges[b] = append(edges[b], a)
	}
	ts := make([]int, n)
	as := make([]int, n)
	for i := 0; i < n; i++ {
		ts[i], as[i] = -1, -1
	}
	ts[u], as[v] = 0, 0
	q := make([]int, 0, n)
	q = append(q, u)
	for len(q) != 0 {
		idx := q[0]
		q = q[1:]
		for _, v := range edges[idx] {
			if ts[v] == -1 {
				ts[v] = ts[idx] + 1
				q = append(q, v)
			}
		}
	}
	q = append(q, v)
	for len(q) != 0 {
		idx := q[0]
		q = q[1:]
		for _, v := range edges[idx] {
			if as[v] == -1 {
				as[v] = as[idx] + 1
				q = append(q, v)
			}
		}
	}
	ans := -1
	for i := 0; i < n; i++ {
		if as[i] > ts[i] {
			ans = larger(as[i], ans)
		}
	}
	fmt.Println(ans - 1)
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int H=in(),W=in();
	vector<vector<int>> M(H,vector<int>(W,0)),CH(H,vector<int>(W,0)),CW(H,vector<int>(W,0));

	REP(i,H){
		string S=in<string>();
		REP(j,W){
			if(S[j]=='#') M[i][j]=1;
		}
	}
	REP(i,H){
		int start=0,cnt=0;
		REP(j,W){
			if(M[i][j]==1){
				for(int k=start;k<j;k++){
					CW[i][k]=cnt;
				}
				cnt = 0;
				start = j+1;
			}
			else{
				cnt++;
			}
		}
		if(cnt>0){
			for(int k=start;k<W;k++){
				CW[i][k]=cnt;
			}
		}
	}
	REP(j,W){
		int start=0,cnt=0;
		REP(i,H){
			if(M[i][j]==1){
				for(int k=start;k<i;k++){
					CH[k][j]=cnt;
				}
				cnt = 0;
				start = i+1;
			}
			else{
				cnt++;
			}
		}
		if(cnt>0){
			for(int k=start;k<H;k++){
				CH[k][j]=cnt;
			}
		}
	}

	int maxC=0;
	REP(i,H){
		REP(j,W){
			maxC = max(maxC,CW[i][j]+CH[i][j]-1);
		}
	}

	out(maxC);
	return 0;
}


Measured memory_bytes: 47360
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;

const int inf = int(1e9);
const int mod = inf + 7;
using namespace std;
const int N = 1001;


int n, m;
int d[N][N];
bool check(int x, int y){
	if(x < n && x >= 0 && y < m &&  y >= 0) return true;
	return false;
}
void solve()
{
	cin >> n >> m;
	char c[n][m];
	rep(i, n) rep(j, m) {
		cin >> c[i][j]; 
		if(c[i][j] == '.')
			d[i][j] = inf;
	}
	rep(i, n) rep(j, m)	{
		for(int dx = -1; dx <= 1; ++dx)
		{
			for(int dy = -1; dy <= 1; ++dy)
			{
				if((dx == -1 || dx == 1) && (dy == -1 || dy == 1)) continue;
				if(check(i + dx, j + dy)){
					d[i][j] = min(d[i + dx][j + dy] + 1, d[i][j]);
				}
			}
		}
	}
	repr(i, n) repr(j, m)	{
		for(int dx = -1; dx <= 1; ++dx)
		{
			for(int dy = -1; dy <= 1; ++dy)
			{
				if((dx == -1 || dx == 1) && (dy == -1 || dy == 1)) continue;
				if(check(i + dx, j + dy)){
					d[i][j] = min(d[i + dx][j + dy] + 1, d[i][j]);
				}
			}
		}
	}
	int mx = 0;
	rep(i, n) rep(j, m) mx = max(mx, d[i][j]);
	cout << mx;

}
int main()
{
	Red;
	solve();
	return 0;
}

Measured memory_bytes: 5120