akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int n,k;
long long res;
int s[1005];
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		int t=i;
		for (int j=2;j<=t;j++)
		{
			while (t%j==0)
			{
				s[j]++;
				t=t/j;
			}
		}
	}
	const int mod=1e9+7;
	res=1;
	for (int i=1;i<=n;i++)
	{
		res*=s[i]+1;
		res%=mod;
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
from sys import stdin


def valid_month(n):
    return 0 < n <= 12


def solve(s):
    fst, snd = int(s[:2]), int(s[2:])
    is_yymm = valid_month(snd)
    is_mmyy = valid_month(fst)
    if is_yymm and is_mmyy:
        return 'AMBIGUOUS'
    elif is_yymm or is_mmyy:
        return 'YYMM' if is_yymm else 'MMYY'
    else:
        return 'NA'


def main():
    s = stdin.readlines()[0].strip()
    ans = solve(s)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<vector>
#include<cstring>
#include<cmath>
#include<cstring>
#include<string>
#include<map>
#include<set>
#include<unordered_map>
#define db double
#define ui unsigned int
#define ll long long
#define ull unsiged ll
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define per(i,r,l)for(int i=r;i>=l;i--)
#define boots ios::sync_with_stdio(0); cin.tie(0)
#define pb push_back
#define pp pop_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define inf  0x3f3f3f3f
#define lnf LLONG_MAX
#define mii map<int,int>
#define mll map<ll,ll>
#define mil map<int,ll>
#define umii unordered_map<char,int>
#define umll unordered_map<ll,ll>
#define umcc unordered_map<char,char>
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pf(n) printf("%lld\n",n)
#define sz size()
using namespace std;
const db pi = 3.1415926535898;
const int MX = 5e6 + 7;
const int esp = 1e-6;
ll INV2, INV6;
ll modulo(ll num, ll MOD = mod) { return ((num%MOD) + MOD) % MOD; }
ll gcd(ll a, ll b) { return ((b == 0) ? a : gcd(b, a%b)); }
unordered_map<ui, ll>mp1, mp;
int p[MX];
int sum[MX];
char s[MX / 10];
vector<int> pri;
vector<bool> isp(MX, true);
int k;
ll qpow(ll a, ll b)
{
	ll ans = 1;
	while (b)
	{
		if (b & 1)
			ans = ans * a%mod;
		a = a * a%mod;
		b >>= 1;
	}
	return ans;
}
ll INV(ll n)
{
	return qpow(n, mod - 2);
}
ll get_sum(ll d)
{
	if (d == 1)return k - 1;
	return d * d%mod*(qpow(d, k )*INV(d) - 1) % mod*INV(d - 1) % mod;
}
ll get_sum2(int n)
{
	return n * (n + 1) % mod*(2 * n + 1) % mod*INV6%mod;
}
int main()
{
	boots;
	int n, m;
	cin >> n;
	rep(i, 1, n)cin >> p[i];
	per(i, n - 1, 1) {
		if (p[i] >= p[i + 1])
			sum[i] = sum[i + 1] + 1;
		else sum[i] = 0;
	}
	int ans = 0;
	rep(i, 1, n)
	{
		if (sum[i] > ans)ans = sum[i];
		//ans = max(ans, sum[i]);
	}
	cout << ans << endl;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second
#define lwb lower_bound
#define upb upper_bound
#define uset unordered_set
#define umap unordered_map
#define all(x) (x).begin(),(x).end()

int chmin(int &a, int b) { if (a > b) { a = b; return 1; } return 0; }
int chmax(int &a, int b) { if (a < b) { a = b; return 1; } return 0; }

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n; cin >> n;
  int s = 1, p = 1;
  for (int i = 0; i < n; i++) {
    int t; cin >> t;
    s *= 3;
    if (t % 2 == 0) p *= 2;
  }
  cout << s - p << '\n';
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int R; cin >> R;
    cout << R*R << endl;
	
	return 0;
}

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

int H[10][10];
int m, n;
int I, J;

int solve(int i, int j, int k) {
	if (!k) {
		if (i == I || j == J)return 1;
		else return 0;
	}
	int res = 0;
	for (int t = 1; i + t < n; t++) {
		if (H[i + t][j] == 1) {
			H[i + t][j] = 0;
			res += solve(i + t, j, k - 1);
			H[i + t][j] = 1;
			break;
		}
	}
	for (int t = 1; i - t >= 0; t++) {
		if (H[i - t][j] == 1) {
			H[i - t][j] = 0;
			res += solve(i - t, j, k - 1);
			H[i - t][j] = 1;
			break;
		}
	}
	for (int t = 1; j + t < m; j++) {
		if (H[i][j + t] == 1) {
			H[i][j + t] = 0;
			res += solve(i, j + t, k - 1);
			H[i][j + t] = 1;
			break;
		}
	}
	for (int t = 1; j - t >= 0; t++) {
		if (H[i][j - t] == 1) {
			H[i][j - t] = 0;
			res += solve(i, j - t, k - 1);
			H[i][j - t] = 1;
			break;
		}
	}
	return res;
}
int main() {
	while (scanf("%d%d", &m, &n), m) {
		int cnt = 0;
		rep(i, n) {
			rep(j, m) {
				scanf("%d", &H[i][j]);
				if (H[i][j] == 1)cnt++;
				if (H[i][j] == 2) { I = i; J = j; }
			}
		}
		printf("%d\n", solve(I, J, cnt));
	}
	return 0;
}

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

from collections import Counter
def main():
    A = input()
    n = len(A)
    A = Counter(A)
    ret = n *(n-1)//2
    for i, c in A.items():
        ret -= c*(c-1)//2
    print(ret+1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9588
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int n,d[7];
double h;

int main(){
	cin>>n;
	while(cin>>h){
		double l=165.0;
		int m=1;
		while(h>=l&&m<6){l+=5.0;m++;}
		d[m]++;
	}
	for(int i=1;i<7;i++){
		cout<<i<<":";
		for(int j=0;j<d[i];j++)cout<<"*";
		cout<<endl;
	}
}

Measured memory_bytes: 0
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  ll n,i,j;
  vector<ll> x(10000010,1);
  cin >> n;
  for(i=2;i<=n;i++){
    for(j=i;j<=n;j=j+i){
      x[j]++;
    }
  }
  ll ans=0;
  for(i=1;i<=n;i++){
    ans+=x[i]*i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 81128
dat_r = []
dat_b = []

n = int(input())
for i in range(n):
    a,b = map(int, input().split())
    dat_r.append((a, b))

for i in range(n):
    c,d = map(int, input().split())
    dat_b.append((c, d))

dat_r.sort(key=lambda x: ( -x[1], -x[0]-x[1]))
dat_b.sort(key=lambda x: ( +x[0],  x[0]+x[1]))
#print("")
#print(dat_r)
#print(dat_b)
res = 0
"""
for i in range(n):
    for j in range(len(dat_b)):
        # print("{0} < {1} vs {2} < {3}".format(dat_r[i][0] ,dat_b[j][0] ,dat_r[i][1] ,dat_b[j][1]))
        if dat_r[i][0] < dat_b[j][0] and dat_r[i][1] < dat_b[j][1]:
            # print("ok")
            res += 1
            dat_b  = dat_b[0:j] + dat_b[j + 1:]
            break
print(res)
"""
for i in range(n):
    for j in range(len(dat_r)):
        #print("{0} < {1} vs {2} < {3}".format(dat_r[i][0] ,dat_b[j][0] ,dat_r[i][1] ,dat_b[j][1]))
        if dat_r[j][0] < dat_b[i][0] and dat_r[j][1] < dat_b[i][1]:
            #print("ok")
            res += 1
            dat_r  = dat_r[0:j] + dat_r[j + 1:]
            break
print(res)


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a=sc.nextLong();
		long b=sc.nextLong();
		if(a%b==0) {
			System.out.println(-1);
		}
		else {
		System.out.println(a*(b+1));
		}
	}
	}


Measured memory_bytes: 23508
#include<iostream>
#include<string>

using namespace std;

int main(){
	int n;
	string s;
	cin >> n >> s;
	int cnt = 0, lcnt = 0, rcnt = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == '('){
			cnt++;
		}else{
			if(cnt > 0){
				cnt--;
			}else{
				lcnt++;
			}
		}
	}
	cnt = 0;
	for(int i = n - 1; i >= 0; i--){
		if(s[i] == ')'){
			cnt++;
		} else{
			if(cnt > 0){
				cnt--;
			} else{
				rcnt++;
			}
		}
	}
	for(int i = 0; i < lcnt; i++){
		cout << '(';
	}
	cout << s;
	for(int i = 0; i < rcnt; i++){
		cout << ')';
	}
	cout << endl;
	return 0;
}

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

typedef long long ll;

int main(void)
{
    string s;
    cin >> s;
    int i = 0;
    if(s[i] >= 65 && s[i] <= 90)
        cout << "A\n";
    else
        cout << "a\n";

    return 0;
}


Measured memory_bytes: 3620
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		for(int i = 0 ; i < N ; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		System.out.println(a[N - 1] - a[0]);
	}
}


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

#define szv(V) ((int)(V).size())
#define allv(V) ((V).begin(), ((V).end()))
#define sortv(V) sort(allv(V))
#define uniquev(V) (V).erase(unique(allv(V)), (V).end())
#define compv(V) sortv(V), uniquev(V)
#define fs first
#define se second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int mod = 1e9 + 7;
const ll inf = 4e18;

ll gcd(ll x, ll y) { while (y) x %= y, swap(x, y); return x; }
pll operator+(pll a, pll b) { return pll(a.fs + b.fs, a.se + b.se); }
pll operator-(pll a, pll b) { return pll(a.fs - b.fs, a.se - b.se); }
ll operator*(pll a, pll b) { return a.fs * b.se - a.se * b.fs; }
int sign(ll x) { return x < 0 ? -1 : x > 0 ? 1 : 0; }
int ccw(pll a, pll b, pll c) { return sign((b - a) * (c - b)); }
template <class T> void setmin(T &x, T y) { if (x > y) x = y; }
template <class T> void setmax(T &x, T y) { if (x < y) x = y; }
template <class T> void addval(T &x, T y) { x += y; x %= mod; }

int n, m;
vector<pii> ps[100005];
char ans[100005][20];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int p, y;
        cin >> p >> y;
        ps[p].emplace_back(y, i);
    }
    for (int i = 1; i <= n; i++) {
        sort(ps[i].begin(), ps[i].end());
        
        for (int j = 0; j < ps[i].size(); j++) {
            sprintf(ans[ps[i][j].se], "%6d%6d\n", i, j + 1);
        }
    }
    for (int i = 1; i <= m; i++) {
        for (int j = 0; j < 20; j++) {
            if (ans[i][j] == ' ') ans[i][j] = '0';
        }
        cout << ans[i];
    }
    return 0;
}

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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() 
{
  int a,b,c; cin>>a>>b>>c;
  int cnt=0;
  if(a==b&&b==c) cnt=0;
  else if(a%2==b%2&&b%2==c%2)
  {
    if(a>=b&&a>=c) cnt=(a-b+a-c)/2;
    else if(b>=c&&b>=a) cnt=(b-c+b-a)/2;
    else cnt=(c-a+c-b)/2;
  }
  else if(a%2==b%2)
  {
    a++; b++;
    cnt++;
    if(a>=b&&a>=c) cnt+=(a-b+a-c)/2;
    else if(b>=c&&b>=a) cnt+=(b-c+b-a)/2;
    else cnt+=(c-a+c-b)/2;
  }
  else if(a%2==c%2)
  {
    a++; c++;
    cnt++;
    if(a>=b&&a>=c) cnt+=(a-b+a-c)/2;
    else if(b>=c&&b>=a) cnt+=(b-c+b-a)/2;
    else cnt+=(c-a+c-b)/2;
  }
  else if(b%2==c%2)
  {
    b++; c++;
    cnt++;
    if(a>=b&&a>=c) cnt+=(a-b+a-c)/2;
    else if(b>=c&&b>=a) cnt+=(b-c+b-a)/2;
    else cnt+=(c-a+c-b)/2;
  }
  
  print(cnt);

  return 0;
}

Measured memory_bytes: 256
S = input()
t = []
u = []
for i in range(len(S)):
    if S[i] in 'AGTC':
        u.append(S[i])
    else:
        w = u.copy()
        t.append(w)
        u = []
t.append(u)
v = [len(i) for i in t]
print(max(v))


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<utility>
using namespace std;
enum COLOR{WHITE, GRAY, BLACK};

int main(){
    int n;
    cin >> n;
    vector<vector<int> > G(n, vector<int>(n));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> G[i][j];
            if (G[i][j] == -1) G[i][j] = 1e8;
        }
    }
    vector<COLOR> COL(n, WHITE);
    COL[0] = GRAY;
    int sum = 0;
    while (1) {
        pair<int, int> min_bridge = make_pair(0, 0);
        for (int i = 0; i < n; i++) {
            if (COL[i] != GRAY) continue;
            bool flag = true;
            for (int j = 0; j < n; j++) {
                if (COL[j] != WHITE) continue;
                flag = false;
                if (G[i][j] < G[min_bridge.first][min_bridge.second]) {
                    min_bridge.first  = i;
                    min_bridge.second = j;
                }
            }
            if (flag) COL[i] = BLACK;
        }
        if (min_bridge.first == 0 && min_bridge.second == 0) break;
        COL[min_bridge.second] = GRAY;
        sum += G[min_bridge.first][min_bridge.second];
    }
cout << sum << endl;
    return 0;
}



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

int main() {
  int n, d;
  cin >> n >> d;
  int range = 1 + 2*d;
  int ans = ( n%range == 0 ) ? n/range: (n/range)+1;
  cout << ans << endl;
  return 0;
}


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

int factor[1003]={0};

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

    for(int j=2;j<=n;j++){
        int m = j;
        for (int i=2;i*i<=m;i++) {
            while (m % i == 0) {
                factor[i]++;
                m /= i;
            }
        }
        if (m != 1)
            factor[m]++;
    }

    long long int ans = 1;
    for(int i=1;i<=n;i++){
        if(factor[i])ans = ans * (factor[i] + 1) % 1000000007;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
    #include <vector>
    #include <cmath>
    #include <string>
    using namespace std;
    int main(){
        int N,L;
        cin >> N >> L;
        int last = L + N -1;
        int first = L;
        int taste = L*N + N*(N -1)/2;

        if (first >= 0){
            cout << taste - first << endl;
        }else if (last <= 0){
            cout << taste - last << endl;
        }else{
            cout << taste << endl;
        }
        return 0;
    }

Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        getAns(a, n);
    }
    static void getAns ( int [] a, int n)
    {
        var pre = a[0];
        var ans = 0;
        var count = 0;
        for (int i = 1; i < n; i++)
        {
            if (a[i] <= pre)
            {
                count++;
                if (count > ans) { ans = count; }
            }
            else count = 0;
            pre = a[i];
        }
        if (count > ans) { ans = count; }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 25052
h = 1
w = 1

while (h != 0):
    l = list(map(int,input().split()))

    h = l[0]
    w = l[1]
    for target_list in range(h):
        for target_list in range(w):
            print('#',end="")
        print('')
    
    if(h == 0 and w == 0):
        break
    print('')


Measured memory_bytes: 7008
#include<iostream>
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
    ll n, a[100000], b[100000];
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        b[a[i]-1] = i+1;
    }

    for(int i=0; i<n; i++)
        cout<<b[i]<<' ';

    return 0;
}


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

using namespace std ;

#define N 100010
#define inf 0x3f3f3f3f
#define ll long long

int n , t ;
int a[ N ] ;

int main() {
	scanf( "%d%d" , &n , &t ) ;
	for( int i = 1 ; i <= n ; i ++ ) scanf( "%d" ,&a[ i ] ) ;
	int ans = 0 , mx = 0 ;
	int tot = 0 ;
	for( int i = n ; i  ; i -- ) {
		mx = max( a[ i ] , mx ) ;
		ans = max( mx - a[ i ] , ans ) ;
	}
	mx = 0 ;
	for( int i = n ; i ; i -- ) {
		mx = max(  a[ i ] , mx ) ;
		if( mx - a[ i ] == ans ) tot ++ ;
	}
	printf( "%d\n" , tot ) ;
	return 0 ;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int a, b, k;
  cin >> a >> b >> k;

  for (int i = a; i <= b; ++i) {
    if (i - a < k || b - i < k) {
      cout << i << '\n';
    }
  }
  return 0;
}

Measured memory_bytes: 3600
s = int(input())

def collatz(n):
	if n % 2 == 0:
		return n // 2
	else:
		return 3 * n + 1

seen = [s]

while True:
	n = collatz(s)
	if n in seen:
		break
	seen.append(n)
	s = n

print(len(seen) + 1)

Measured memory_bytes: 38256
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <iostream>
#include <deque>
#include <functional>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

#define int long long

#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

#define debug(x) cerr << #x << ": " << x << endl;

const int MOD = 1e9 + 7;

signed main(void)
{
  int a, b; cin >> a >> b;
  if ((a + b) % 2 == 0) cout << (a + b) / 2 << endl;
  else cout << "IMPOSSIBLE" << endl;
  
}


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

#define ll long long
#define str string
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second

#define vc vector<char>
#define vvc vector<vc>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvvll vector<vvll>
#define vs vector<str>
#define vvs vector<vs>
#define vpii vector<pii>
#define vvpii vector<vpii>
#define vpll vector<pll>
#define vvpll vector<vpll>
#define vb vector<bool>
#define vvb vector<vb>
#define rep(i, a, b) for (int i = (a); i < int(b); i++)
#define repi(i, a, b) for (int i = (a); i <= int(b); i++)


using namespace std;
ll INF = LONG_LONG_MAX;
ll mod = 1000000000 + 7;

template <typename T, typename L>
void readVector(vector<T> & _data, L & _size, bool _shift) {
    _data.resize(_size + (ll)_shift);
    for (ll i = (ll)_shift; i < _size + (ll)_shift; i++)
        cin >> _data[i];
}

template <typename T, typename L>
void readMatrix(vector<vector<T>> & _data, L & _rows, L & _cols, bool _shiftRows, bool _shiftCols) {
    _data.resize(_rows + (ll)_shiftRows);
    for (ll i = 0; i < _rows + (ll)_shiftRows; i++)
        _data[i].resize(_cols + (ll)_shiftCols);
    for (ll i = (ll)_shiftRows; i < _rows + (ll)_shiftRows; i++)
        for (ll j = (ll)_shiftCols; j < _cols + (ll)_shiftCols; j++)
            cin >> _data[i][j];
}


//TODO: SOLUTION

void fillrem(vll & c, vb & u) {
    for (int i = u.size() - 1; i > 0; i--) {
        if (!u[i])
            c.push_back(i);
        u[i] = 1;
    }
}

void solve() {
    ll n, a, b;
    cin >> n >> a >> b;
    if (a + b - 1 > n || n > a*b) {
        cout << - 1 << endl;
        return;
    }

    vll c;
    int left = n;
    int blocs = 1;
    vb u(n + 1, false);

    while (left > 0) {
        ll k = n - a * blocs;
        if (k < 0)
            k = 0;
        repi(i, 1, a) {
            c.push_back(k + i);
            u[k + i] = 1;
            left--;
            if (i == a)
                blocs++;
            if (left + blocs - 1 == b) {
                fillrem(c, u);
                left = 0;
                break;
            }
        }

    }

    rep(i, 0, n)
    cout << c[i] << " ";
    cout << endl;
}


int main() {

    // TODO: Set value of this variable manually
    bool _multipleTestCases = false;

    if (_multipleTestCases) {
        ll t; cin >> t;
        while (t--)
            solve();
    }
    else {
        solve();
    }

    return 0;
}

Measured memory_bytes: 7500
#include <cstdio>
long long N, A, B, C, D;
int main()
{
	scanf("%lld%lld%lld%lld%lld", &N, &A, &B, &C, &D);
	N--;
	for (int i = 0; i <= N; i++)
	{
		long long End = A - i * D + (N - i) * C;
		if (End <= B && B - End <= (D - C) * N)
		{
			puts("YES");
			return 0;
		}
	}
	puts("NO");
	return 0;
}


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

// Macros
#define F  first
#define S  second
#define PB push_back

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m, y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// HELPERS
//  Tedious Grid Movements
vector<pii> moves_grid = { {0,1} , {0,-1} , {1,0} , {-1,0} };
inline bool move_okay(int x, int y, int n, int m) { return 0 <= x and x < n and 0 <= y and y < m; }
//  Remember:
//   * vec.assign() GOOD; vec.resize() BAD
//   * comparator uses <

// Output, Common Containers
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream& os, const set<T>& v)    { for (T i : v) os << i << ' '; return os; }
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) { os << "(" << v.F << "=>" << v.S << ") "; return os; }
template <typename T, typename S> ostream& operator << (ostream& os, const map<T,S>& v)  { for (auto i : v) os << i << ' '; return os; }

// Debugging
#ifdef SANYAM1101
	#define trace(args...) do{ cerr << "Trace On! (Line: " << __LINE__ << ")\n"; d_f(string(#args), args); } while(0)
	void d_f(__attribute__((unused)) string str) {}
	template<typename Head, typename... Tails> void d_f(string str, Head H, Tails... T) { cerr << "\t" << str.substr(0, str.find(", ")) << " <=> [" << H << "]\n"; d_f(str.substr(str.find(", ") + 2), T...); }
#else
	#define trace(args...)
#endif


// CODE STARTS HERE

void solve(){
	int n;
	cin >> n;

	map<string, int> m;
	while(n--){
		string s; cin >> s;
		++m[s];
	}

	for(auto s: {"AC", "WA", "TLE", "RE"})
		cout << s << " x " << m[s] << "\n";
}

signed main (void){
	// Fast_IO
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// Set Fixed Notation (default sucks), High Precision for Floating-Point Output
	cout << fixed << setprecision(20);

	// Multiple TCs
	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


Measured memory_bytes: 3660
while True:
        n = input()
        if n == 0:
            break
        m = input()
        s = raw_input()
        graph = []
        for i in xrange(n):
            graph.append({"I":2*i+1,"O":0})
            graph.append({"I":1,"O":2*(i+1)})
        graph.append({"I":2*n+1,"O":0})
        graph.append({"I":1,"O":2*n})
        cur,score = 0,0
        for c in s:
            cur = graph[cur][c]
            if cur == 2*n+1:
                score += 1
        print score

Measured memory_bytes: 6704
n = int(input())
a = list(map(int, input().split()))
#
# while n < 0:
#     print(a[n-1])
#     n -= 1

for i in range(n-1):
    print(a[n-i-1], end ="")
    print(" " , end="")
#         print(i , end="")
#
#     elif '3' in str(i):
#         print(" " , end="")
#         print(i , end="")
#
# print()
print(a[0])



Measured memory_bytes: 5624
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	while(cin>>s) {
		string ans = s<="2019/04/30" ? "Heisei" : "TBD";
		cout<<ans<<endl;
	}
	
	return 0;
}


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

#ifndef DEBUG
#define endl '\n'
#define debugf(...)
#define debug(...)
#else
#define debugf(...) printf(__VA_ARGS__)
#define debug(...) __VA_ARGS__
#endif

const int N = 1e5 + 5;



int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    int n; cin >> n;
    bool is = true;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        if (x & 1) continue;
        is &= (x % 3 == 0) || (x % 5 == 0);
    }

    cout << (is ? "APPROVED" : "DENIED") << endl;
    
    return 0;
%>

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
   int n,i,a[100];
   scanf("%d",&n);
   for(i=0;i<n;i++)
   {
       scanf("%d",&a[i]);
   }
   for(i=(n-1);i>=0;i--)
   {
       printf("%d",a[i]);
       if(i!=0) printf(" ");
   }
   printf("\n");
   return 0;
}


Measured memory_bytes: 2048
a, b, c, d, e, f = map(int, input().split())

max_concentration = 0
res = (0, 0)
for i in range(0, f//(100*a)+1):
    for j in range(0, (f-100*a*i)//(100*b)+1):
        water = 100 * (a*i + b*j)
        if water == 0:
            continue
        for k in range(0, f-i-j+1):
            for l in range(0, f-i-j-k+1):
                sugar = c*k + d*l
                if water + sugar > f:
                    break
                if sugar > water//100 * e:
                    break
                if water + sugar == 0:
                    continue
                concentration = sugar / (water+sugar)
                if concentration >= max_concentration:
                    max_concentration = concentration
                    res = (water+sugar, sugar)

print(*res)

Measured memory_bytes: 3064
#include<algorithm>
#include<iomanip>
#include<iostream>
#include<queue>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
const ll INF = 1000000000000000000;
 
ll N, K;
// ll p[100010 * 2];
double temp, ans = -1;
queue<double> q;
 
double calc_expected_value(ll x) {
    ll s = (x * (x + 1)) / 2;
    double ret = (double)s / (double)x;
    return ret;
}
 
int main() {
    cin >> N >> K;
    for(int i = 0; i<N; i++){
        ll pi;
        cin >> pi;
        double ev_pi = calc_expected_value(pi);
        temp += ev_pi;
        q.push(ev_pi);
        while(q.size() > K){
            temp -= q.front();
            q.pop();
        }
        if(q.size() == K){
            ans = max(ans, temp);
        }
    }
    cout << std::setprecision(32) <<  ans << endl;
}

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

ll N,A[100010],B[100010];
int main(){
	cin >> N;
	ll Sa = 0,Sb = 0;
	for(int i=1;i<=N;i++){
		cin >> A[i];
		Sa += A[i];
	}
	vector<pair<ll,int>> v;
	for(int i=1;i<=N;i++){
		cin >> B[i];
		Sb += B[i];
		v.push_back({A[i]-B[i],i});
	}
	sort(v.begin(),v.end());
	if(Sa<Sb){
		cout << -1 << endl;
		return 0;
	}
	int ans = N;
	ll value = 0;
	for(int i=0;i<N;i++){
		if(v[i].first<0){
			value -= v[i].first;
			ans--;
		}
		else break;
	}
	for(int i=N-1;i>=0;i--){
		if(value<=0) break;
		if(v[i].first>0){
			value -= v[i].first;
			ans--;
		}
	}
	cout << N-ans << endl;
}

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

vector<int> a[15];
const int INF = 1001001001;

int main(){
	int n,m,x;
	cin >> n >> m >> x;
	vector<int> c(n);
	rep(i,n){
		cin >> c[i];
		rep(j,m){
			int A;
			cin >> A;
			a[i].push_back(A);
		}
	}
	int ans = INF;
	rep(bit, 1 << n){
		bool ok = true;
		int count = 0;
		vector<int> algo(m,0);
		rep(j,n){
			if(bit & (1 << j)){
				count += c[j];
				rep(k, m){
					algo[k] += a[j][k];
				}
			}
		}
		rep(i,m){
			if(algo[i] < x) ok = false;
		}
		if(ok) ans = min(ans, count);
	}
	if(ans == INF){
		cout << -1 << endl;
	}else{
		cout << ans << endl;
	}
    return 0;
}



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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

//sort and remove duplicates for type vector
template<typename A>
void UNIQUE(vector< A > &a,int mode=0){
    if(mode==0){ sort(ALL(a),greater< A >());}else{ sort(ALL(a));}
    a.erase(unique(ALL(a)),a.en());
}

int main(){
    int n;
    cin>>n;
    Vi w(n);
    REP(i,n) cin>>w[i];

    int ans = 1e9;
    REP(t,n){
        int s1 = 0;
        int s2 = 0;
        REP(i,n){
            if(i<=t){
                s1 += w[i];
            }else{
                s2 += w[i];
            }
        }
        ans = min(ans,abs(s1-s2));
    }
    cout<<ans<<endl;

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<vector<int> > a(n + 1, vector<int>(n + 1, 0));
    for (int i = 1; i <= n; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v;
            cin >> v;
            a[u][v] = 1;
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            cout << a[i][j] << (j != n ? ' ' : '\n');
        }
    }
    return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
// e.g. sort(all(a), [](int a1, int a2) { return a1 < a2; });
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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

  ll ans = 0;
  ans += x/500*1000;
  x = x%500;
  ans += x/5*5;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){

  int N=0, K=0;//ボールの数,ペンキの色の種類の数
  int sum=0;
  int i=0;

  scanf("%d %d", &N, &K);

  for(i=1; i<=N; i++){
    if(i==1)
      sum=K;
    else{
      sum=sum*(K-1);
    }
  }

  printf("%d", sum);

  return 0;

}


Measured memory_bytes: 128
#include <iostream>

int main() {

  int r;
  int g;
  int b;

  std::cin >> r >> g >> b;

  int sum;
  sum = r * 100 + g * 10 + b;

  if (sum % 4 == 0) {
    std::cout << "YES" << std::endl;
  } else {
    std::cout << "NO" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main( void )
{
	int total; // ツ堕債額
	while ( cin >> total && total )
	{
		int sum = 0;
		for ( int i = 0; i < 9; i++ )
		{
			int cost; cin >> cost; sum += cost;
		}
		cout << total - sum << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法
#define JUUHATI 1000000000000000000 
#define JUUHATIPLUS 1000000000000000001 

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

// mapとsetの合わせ

int main(){
    ll N,ans=-1;
    cin >> N;
    string s;
    vector<string> S(N);
    map<string,ll> mpa;
    set<string> ss;

    for(ll i = 0;i < N;i++){
        cin >> S.at(i);
        ss.insert(S.at(i));
    }
    
    for(ll i = 0;i < N;i++)
        mpa[S[i]]++;
    
    for(auto x:ss){
        if(ans < mpa[x])
            ans = mpa[x];
    }

    //範囲for文
    for(auto x :ss){
        if(ans == mpa[x])
            cout << x << endl;

    }

}

Measured memory_bytes: 40612
# coding: utf-8
from bisect import bisect_left


def solve(*args: str) -> str:
    x = int(args[0])

    P = [pow(i, 5) for i in range(128)]
    ret = None
    for b, b5 in enumerate(P):
        a5 = x+b5
        like_a = bisect_left(P, a5)
        if like_a < len(P):
            if P[like_a] == a5:
                ret = (like_a, b)
                break

        a5 = abs(x-b5)
        like_a = bisect_left(P, a5)
        if like_a < len(P):
            if P[like_a] == a5:
                ret = (like_a if b5 < x else -like_a, -b)
                break

    return ' '.join(map(str, ret))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 9100
#include <iostream>
#include <algorithm>
using namespace std;
int selectionSort(int a[], int n);

int main() {

    int a[100], n, count;
    count = 0;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    count = selectionSort(a, n);
    for (int i = 0; i < n; i++) cout << a[i] << (i < n - 1 ? " " : "\n");
    cout << count << endl;

    return 0;
}

int selectionSort(int a[], int n) {
    int count, i, j, minj;
    count = 0;
    for (i = 0; i < n; i++) {
        minj = i;
        for (j = i + 1; j < n; j++) {
            if (a[j] < a[minj]) minj = j;
        }
        if (minj != i) {
            swap(a[i], a[minj]);
            count++;
        }
    }
    return count;
}


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

int main(){
    int n; cin >> n; 
    cout << n << ":";
    int div=2;
    int sor = n;
    while(n!=1){
        if(n%div==0){
            cout << " " << div;
            n/=div;
        }
        else
            div++;
        if(div>(int)(sqrt(sor))){
            cout << " " << n;
            break;
        }
    }
    cout << endl;
}


Measured memory_bytes: 3104
#include<stdio.h>
#include<string.h>

int main(){
    char a[4],b[4];
    scanf("%s",a);
    scanf("%s",b);


    if(a[0]==b[2] && a[1]==b[1] && a[2]==b[0]){
        printf("YES");
    }
    else{
        printf("NO");
    }
return 0;
}


Measured memory_bytes: 128
function Main(input) {
  var list = input.split("\n")[1].split(" ");
  var mismatch = [];
  for(var i = 0; i < list.length; i++){
    var tmp = parseInt(list[i]);
    if(tmp != i + 1){
       mismatch.push(tmp);
    }
  }
  if(mismatch.length == 0 || mismatch.length == 2){
     console.log("YES");
     return;
  }else{
    console.log("NO");
     return;
  }
  /*
  list[mismatch[0]] = mismatch[0];
  list[mismatch[1]] = mismatch[1];
  for(var i = 0; i < list.length; i++){
    var tmp = parseInt(list[i]);
    if(tmp != i){
       mismatch.push(tmp);
    }
  }*/
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

struct edge {
  ll to;
};
vector<vector<edge>> graph;
vector<map<ll, ll>> mv;
vector<queue<ll>> det;

void bfs(ll x, ll d, ll i){
    if(mv.at(i).count(x)){
        return;
    }
    mv.at(i)[x] = d + 1;
    det.at(i).push(x);
}

int main()
{
    ll N;
    cin >> N;
    graph.resize(N);
    mv.resize(N);
    det.resize(N);
    vector<string> S(N);
    rep(i, N){
        cin >> S.at(i);
    }
    rep(i, N){
        rep(j, N){
            if(S.at(i).at(j) == '1'){
                graph.at(i).push_back({j});
            }
        }
    }
    rep(i, N){
        mv.at(i)[i] = 0;
        det.at(i).push(i);
        while(!det.at(i).empty()){
            ll x = det.at(i).front();
            det.at(i).pop();
            ll d = mv.at(i).at(x);
            for(auto e : graph.at(x)){
                 bfs(e.to, d, i);
            }
        }
    }
    vector<ll> ans(N, -2);
    bool flag = false;
    rep(j, N){
        rep(i, N){
            chmax(ans.at(j), mv.at(j).at(i));
            for(auto e : graph.at(i)){
                if(mv.at(j).at(i) == mv.at(j).at(e.to)){
                    ans.at(j) = -2;
                    flag = true;
                    break;
                }
            }
            if(flag){
                flag = false;
                break;
            }
        }
    }
    ll m = -2;
    rep(i, N){
        chmax(m, ans.at(i));
    }
    m++;
    cout << m << endl;
}

Measured memory_bytes: 6584
#include<bits/stdc++.h>
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Freed freopen ("0in.txt","r",stdin);
#define Fout freopen ("0out.txt","w",stdout);
#define ll long long int
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define Mod 1000000007
#define limit 1000008
using namespace std;
bool vis[limit];
int cnt[limit],rem[limit];
void solve(int t)
{
    ll i,j,n,x,m,d,l=0,r=0,ct=0,a=0,ans=0;
    cin >> n >> x >> m;
    for(i=1; ; i++)
    {
        d = x%m;
        x = (x*x)%m;
        rem[i] = d;
        if(vis[d])
        {
            l = cnt[d];
            r = i-1;
            break;
        }
        cnt[d] = i;
        vis[d] = 1;  //cout <<i<<" "<<n<<" "<<d<<endl;
        if(i==n)
        {
            for(j=1; j<=n; j++)
                ans = (ans+rem[j]);
            cout <<ans<<endl;
            return ;
        }
    }
    ct = r-l+1;
    for(i=l; i<=r; i++)
        ans = (ans+rem[i]);
    n = n-l+1;
    a = n/ct;
    n = n%ct;
    ans = (ans*a);
    for(i=1; i<l; i++)
        ans = (ans+rem[i]);
    for(i=l,j=0; j<n; i++,j++)
        ans = (ans+rem[i]);
    cout <<ans<<endl;
    return ;
}
int  main()
{
//    Fast
//    Freed
//    Fout
    int t,tt=1;
 //   cin >> tt;
    for(t=1; t<=tt; t++)
        solve(t);
    return 0;
}




Measured memory_bytes: 4304
#include<bits/stdc++.h>
#define loop(a,b) for((b)=0;(b)<(a);(b)++)
#define append push_back
using namespace std;
vector<long>a[100006];
void dfs(int,int,int,int []);
int main(){
	int black[100006]={},white[100006]={};
	int n,i,j;
	cin>>n;
	n--;
	loop(n,i){
		int x,y;
		cin>>x>>y;
		x--;y--;
		a[x].append(y);
		a[y].append(x);
	}
	dfs(0,-1,0,black);
	dfs(n,-1,0,white);
	n++;
	int b=0,w=0;
	loop(n,i){
		if(black[i]<=white[i])b++;
		else w++;
	}
	if(b>w)puts("Fennec");
	else puts("Snuke");
	return 0;
}
void dfs(int node,int last,int depth,int graph []){
	graph[node]=depth;
	for(int i=0;i<(int)(a[node].size());i++){
		if(a[node][i]==last)continue;
		dfs(a[node][i],node,depth+1,graph);
	}
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,cost[1000000],weight[100],INF=1e9;
vector<int>dp(1000000,1e9);

void func(int a,int k)
{
    dp[1]=0;
    for(int i=1; i<=a; i++)
    {
        for(int j=i+1; j<=i+k; j++)
        {
            if(j<=a)
            {
                dp[j]=min(dp[j],dp[i]+abs(cost[i]-cost[j]));
                //cout<<dp[j]<<endl;
            }
            //dp[j]=min(dp[j],dp[i]+abs(cost[i]-cost[j]));
        }
    }
}

int main()
{
    int k;
    cin>>a>>k;
    for(int i=1; i<=a; i++)
    {
        cin>>cost[i];
    }
    func(a,k);
    cout<<dp[a]<<endl;
    //cout<<nCr(a,b)<<endl;

}


Measured memory_bytes: 4608
#include<stdio.h>
#include<string.h>
int main(){
    char s[5];
    scanf("%s", s);
    int len = strlen(s);
    int x = 0;
    
    for (int i=0; i<len-1; i++){
        if (s[i]=='A' && s[i+1]=='C'){
            printf("Yes\n");
            x = 1;
            break;
        }
    }
    
    if (x==0) printf("No\n");
    
    return 0;
}


Measured memory_bytes: 128
#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 H, W;
    cin >> H >> W;
    map<int, int> count;
    rep(i, H){
        rep(j, W){
            char a;
            cin >> a;
            count[a-'a']++;
        }
    }
    map<int, int> count2;
    rep(i, 26) count2[count[i]]++;
    if(H % 2 == 1 && W % 2 == 1){
        // ともに奇数 4,2,2,1
        bool judge = true;
        int one = 0;
        int four = 0;
        int tmp = ((W/2) * (H/2));
        rep(i,26) if(count[i] % 2) one++;
        if(one > 1) judge = false;
        if(tmp > 0){
            rep(i,26) if(count[i] >= 4) four += count[i] / 4;
            if(((W/2) * (H/2)) > four) judge = false;
        }
        if(judge) cout << "Yes" << endl;
        else cout << "No" << endl;
    }else if(W % 2 == 0 && H % 2 == 0){
        // ともに偶数
        bool judge = true;
        rep(i, 26) if(count[i] % 4 > 0) judge = false;
        int cnt = 0;
        rep(i, 26) cnt += count[i] / 4;
        if(cnt*4 != H*W) judge = false;
        if(judge) cout << "Yes" << endl;
        else cout << "No" << endl;
    }else{
        // どっちか偶数でどっちか奇数
        bool judge = true;
        int four = 0;
        int two = 0;
        int tmp = ((W/2) * (H/2));
        rep(i, 26) if(count[i]%2) judge = false;
        if(tmp > 0){
            rep(i,26) four += count[i] / 4;
            if(((W/2) * (H/2)) > four) judge = false;
        }
        if(judge) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;
using ll  = long long;
using ii  = pair < int , int >;
using i3  = pair < int , ii >;
using vi  = vector < int >;
using vii = vector < ii >;
using vi3 = vector < i3 >;

const int N = 2e5 + 5;
const ll INF = 1e12;
const double eps = 1e-9 , PI = acos(-1);

int n , m;
ii a[N];

bool cmp(ii x , ii y){
    if(x.second == y.second)return x.first < y.first;
        return x.second < y.second;
}

void solve(){
    scanf("%d" , &n);
    ll T = 0;

    for(int i = 0 ; i < n ; i ++){
        scanf("%lld %lld" , &a[i].first , &a[i].second);
    }
    sort(a , a + n , cmp);

    for(int i = 0 ; i < n ; i ++){
        T += a[i].first;
        if(T > a[i].second){
            printf("No\n");
            return;
        }
    }
    printf("Yes\n");

}

main(){
    int t = 1;
    //scanf("%d" , &t);

    while( t -- ){
            solve();
    }

    return 0;
}




Measured memory_bytes: 1792
n, k = map( int, input().split() )
p_n = 0
s = 0
m = k
while m > 1 :
    m = m / 2
    s += 1
geta = 2 ** s
p_n += 1
for i in range(1, n) :
    s = 0
    m = k / (i+1)
    while m > 1 :
        m = m / 2
        s += 1
    p_n += geta / 2 ** s
print(p_n / n/ geta)

Measured memory_bytes: 3316