akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    int n;
    lli ans=0;
    cin>>n;
    vi a(n),b(n),c(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    rep(i,n-1) cin>>c[i];
    int prev=30;
    rep(i,n){
        ans+=b[a[i]-1];
        if(a[i]==prev+1){
            ans+=c[prev-1];
        }
        prev=a[i];
    }
    out(ans);
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

struct Scanner<R: Read> {
    reader: R,
}

impl<R: Read> Scanner<R> {
    fn new(r: R) -> Scanner<R> {
        Scanner { reader: r }
    }
    fn read<T: FromStr>(&mut self) -> T {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let n: usize = sc.read();

    let mut sps = Vec::new();
    for i in 1..n+1 {
        let s: String = sc.read();
        let p: u32 = sc.read();
        sps.push((i, s, p));
    }
    sps.sort_by(|l,r| {
        if l.1 == r.1 {
            r.2.partial_cmp(&l.2).unwrap()
        } else {
            l.1.partial_cmp(&r.1).unwrap()
        }
    });
    for (i, _, _) in sps {
        println!("{}", i);
    }
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main(void){
    
    int N;
    int ans = 0;
    string S;
    cin >> N >> S;
    
    for(int i = 0; i < N-2;){
        if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C'){
            i += 3;
            ans++;
            continue;
        }
        i++;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
//ITNOA
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <fstream>
#include <cstring>
#include <cstdlib>
#include <iomanip>

using namespace std;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;


#define rep(i, s, e) for(int i = s; i < e; i ++)
#define X first
#define Y second

typedef long long ll;
typedef long double ld;

const int maxN = 50 + 5;
const int mod = 1000*1000*1000 + 7;
const int base = 701;
const int SQ = 500;
const int maxL = 20;

ll a[maxN];
int32_t main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	ll k; cin >> k;
	int n = 50;
	cout << n << endl;
	for(int i = 0; i < n; i ++)
		a[i] = n-1;

	ll d = k / n;
	for(int i = 0; i < n; i ++)
		a[i] += d;

	if(k % n) {
	 	int rem = k % n;
		rem = n - rem;
		for(int i = rem; i < n; i ++)
		   a[i] += rem;
		for(int i = 0; i < rem; i ++)
			a[i] += rem - n;		
	}

	for(int i = 0; i < n; i ++)
		cout << a[i] << ' ';
	cout << endl;
	return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }

  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};


int main(){
  int n,m,k;
  cin>>n>>m>>k;
  vector<vector<int>> fr(n);
  vector<vector<int>> bl(n);
  vector<int> deg(n);

  UnionFind tree(n);


  rep(i,m){
    int a,b;
    cin >>a>>b;
    a--;b--;
    fr[a].push_back(b);
    fr[b].push_back(a);
    tree.unite(a,b);
    deg[a]++;
    deg[b]++;
  }
  rep(i,k){
    int c,d;
    cin>>c>>d;
    c--; d--;
    bl[c].push_back(d);
    bl[d].push_back(c);
    if(tree.same(c,d)){
      deg[c]++;
      deg[d]++;
    }
  }

  rep(i,n){
    int ans=tree.size(i)-1-deg[i];
    cout<<ans<<" ";
  }




}


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

int main(){
  int n,ix,iy,nx,ny,mx,my,c,mc;
  cin>>n;
  while(n--){
    mc=mx=my=nx=ny=0;
    while(1){
      cin>>ix>>iy;
      if(!ix&&!iy) break;
      nx+=ix,ny+=iy;
      c=nx*nx+ny*ny;
      if(mc<c||(mc==c&&mx<nx)) mx=nx,my=ny,mc=c;
    }
    cout<<mx<<' '<<my<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()

ll dp[1010][4097];

int main(){
	for (int i = 0;i < 1010;i++)
		for (int j = 0;j < 4097;j++)
			dp[i][j] = LLONG_MAX;

	ll N, M, a, b, c, f;
	cin >> N >> M;
	int x = 1;
	ll d2[13];d2[0] = 1;
	for (int i = 0;i < N;i++) {
		x *= 2;
		d2[i + 1] = x;
	}

	vector<pair<ll,ll>> V(M);
	for (int i = 0;i < M;i++) {
		f = 0;
		cin >> a >> b;
		for (int j = 0;j < b;j++) {
			cin >> c;
			c--;
			f += d2[c];
		}
		V[i] = { a,f };
	}

	dp[0][0] = 0;
	for (int i = 0;i < M;i++) {
		tie(a, b) = V[i];
		for (int j = 0;j < 4096;j++) {
			if (dp[i][j] == LLONG_MAX) continue;
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
			dp[i + 1][j | b] = min(dp[i + 1][j | b], dp[i][j] + a);
		}
	}
	if (dp[M][x - 1] == LLONG_MAX)cout << -1 << endl;
	else cout << dp[M][x - 1] << endl;
}

Measured memory_bytes: 32640
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int n;
  string s;
  cin >> s;
  n = s.size();
  vi ans(n);
  rep(ri,2) {
    {// solve R
      int cnt = 0;
      rep(i,n) {
        if (s[i] == 'R') cnt++;
        else {
          ans[i] += cnt/2;
          ans[i-1] += (cnt+1)/2;
          cnt = 0;
        }
      }
    }

    reverse(rng(ans));
    reverse(rng(s));
    rep(i,n) {
      if (s[i] == 'L') s[i] = 'R';
      else s[i] = 'L';
    }
  }
  
  rep(i,n) {
    printf("%d\n", ans[i]);
  }
  return 0;
}

Measured memory_bytes: 1024
N = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(N):
  deta = input()
  if deta == 'AC':
    AC += 1
  elif deta == 'WA':
    WA += 1
  elif deta == 'TLE':
    TLE += 1
  else :
    RE += 1
print('AC x {}'.format(AC))   
print('WA x {}'.format(WA))  
print('TLE x {}'.format(TLE))  
print('RE x {}'.format(RE)) 

Measured memory_bytes: 8924
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int h,w;
	cin>>h>>w;
	char s[h+1][w+1];
	for(int i=0;i<=h;i++){
		for(int j=0;j<=w;j++){
			s[i][j]='.';
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin>>s[i][j];
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(s[i][j]=='#'){
				if(s[i][j-1]=='.'&&s[i][j+1]=='.'&&s[i-1][j]=='.'&&s[i+1][j]=='.'){
					cout<<"No"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"Yes"<<endl;

}

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

using namespace std;

int main() {
    char b;
    cin >> b;

    switch (b) {
        case 'A':
            cout << 'T' << endl;
            break;
        case 'T':
            cout << 'A' << endl;
            break;
        case 'C':
            cout << 'G' << endl;
            break;
        case 'G':
            cout << 'C' << endl;
            break;
    }
}

Measured memory_bytes: 3564
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let a: usize = read();

    println!(
        "{}",
        match n % 500 <= a {
            true => "Yes",
            false => "No",
        }
    )
}


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

int next_combination(int sub) {
    int x = sub & -sub, y = sub + x;
    return (((sub & ~y) / x) >> 1) | y;
}


int main(){
    int n, k;
    long long ans=0;
    cin>>n>>k;
    ans=k*pow(k-1,n-1);
    cout << ans<< endl;
}


Measured memory_bytes: 4032
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		String s = sc.next();
		String t = sc.next();

		for(int i = 0; i < s.length(); i++) {
			if(s.equals(t)) {
				System.out.println("Yes");
				return;
			}
			s = rotate(s);
		}
		System.out.println("No");
    }

	static String rotate(String str) {
		return str.substring(1) + str.charAt(0);
	}
}


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

using namespace std;

using ll = long long int;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

bool solve(int h, int w, vs a) {
	vi alphabet(26);
	for (auto row : a) {
		for (auto c : row) {
			alphabet[c - 'a']++;
		}
	}

	if (h % 2 == 0 && w % 2 == 0) {
		for (auto v : alphabet) {
			if (v % 4 != 0) {
				return false;
			}
		}

		return true;
	}

	if ((h & 1) && (w & 1)) {
		vi cnt(4);
		for (auto v : alphabet) {
			if (v == 0) continue;
			cnt[v % 4]++;
		}

		if (cnt[3] || cnt[1] != 1 || cnt[2] > (h - 1) / 2 + (w - 1) / 2) {
			return false;
		}

		return true;
	}


	if (w % 2) {
		swap(h, w);
	}

	vi cnt(4);
	for (auto v : alphabet) {
		if (v == 0) continue;
		cnt[v % 4]++;
	}

	if (cnt[1] || cnt[3] || cnt[2] > w / 2) {
		return false;
	}

	return true;
}

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

	int h, w;
	cin >> h >> w;

	vs a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}

	cout << (solve(h, w, a) ? "Yes" : "No") << endl;
	return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  ll h, w;
  int n;
  cin >> h >> w >> n;
  map<P, int> mp;
  rep(i, n) {
    int a, b; cin >> a >> b;
    if(1 < a && a < h && 1 < b && b < w) ++mp[P(a, b)];
    rep(k, 8) {
      int na = a+di[k], nb = b+dj[k];
      if(1 < na && na < h && 1 < nb && nb < w) ++mp[P(na, nb)];
    }
  }
  vector<ll> ans(10, 0);
  ans[0] = (h-2)*(w-2) - mp.size();
  for(auto x : mp) ++ans[x.second];
  for(auto x : ans) cout << x << endl;
}


Measured memory_bytes: 59772
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
const MOD: i64 = (1e+9 as i64) + 7;

fn calc(memo: &mut Vec<i64>, depth: usize, nexts: &Vec<usize>) -> i64 {
    let n = nexts.len();
    if depth == n {
        return 1;
    }
    if memo[depth] != -1 {
        return memo[depth];
    }
    let mut ret = 0;
    let next = nexts[depth];
    if next != n && next != depth + 1 {
        ret = (ret + calc(memo, next, nexts)) % MOD;
    }
    ret = (ret + calc(memo, depth + 1, nexts)) % MOD;
    memo[depth] = ret;
    return ret;
}

fn main() {
    let n = read::<usize>();
    let mut seq = vec![0; n];
    let mut prevs = vec![n; 200000];
    let mut nexts = vec![n; n];
    for i in 0..n {
        seq[i] = read::<usize>() - 1;
        let prev = prevs[seq[i]];
        if prev != n {
            nexts[prev] = i;
        }
        prevs[seq[i]] = i;
    }
    let mut memo = vec![-1; n];
    let ans = calc(&mut memo, 0, &nexts);
    println!("{}", ans);
}


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

typedef long long ll;
typedef vector<ll> vi;
vi v;
int n;

int main() 
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    while(cin >> n)
    {
        v = vi(n);
        for(int i = 0; i < n; i++)
            cin >> v[i];
        if(v[0] != 0) { cout << -1 << '\n'; continue; }
        ll ans = 0, ok = 1;
        for(int i = 1; i < n; i++) {
            if(v[i] != v[i-1]+1)
                ans += v[i-1];
            if(v[i] >= v[i-1]+2)
                ok = 0;
        }
        ans += v[n-1];
        cout << (!ok? -1 : ans) << '\n';
    }
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <math.h>
#include <fstream>
#include <sstream>
#include <unordered_map>
using namespace std;

const unsigned long long BASE = (unsigned long long)(1e9 + 7);
int path[5001];
long long value[5001];
bool visited[5001];

#define FROM_0(i, n) for(int i = 0; i < (n); i++)
#define FROM_S(i, s, e) for(int i = (s); i < (e); i++)
#define ITER_BEGIN_END(iter, vec) for(auto iter = vec.begin(); iter < vec.end(); iter++)

int main()
{
    int n, k;
    cin >> n >> k;
    FROM_0(i, n)
    {
        visited[i] = false;
        cin >> path[i];
        path[i]--;
    }
    FROM_0(i, n)
    {
        cin >> value[i];
    }

    // find loop
    vector<vector<int>> cycle;
    FROM_0(start, n)
    {
        if (visited[start])
            continue;
        int now = start;
        vector<int> route;
        while (!visited[now])
        {
            visited[now] = true;
            route.push_back(now);
            now = path[now];
        }
        cycle.push_back(route);
    }

    long long maxValue = -10e10;
    ITER_BEGIN_END(iter, cycle)
    {
        const auto & route = *iter;
        vector<long long> segmentSum;
        long long fullValue = 0;
        FROM_0(i, route.size())
            fullValue += value[route[i]];
        FROM_S(step, 1, route.size())
        {
            long long sum = 0;
            FROM_0(i, step)
            {
                sum += value[route[i]];
            }
            long long maxSum = sum;
            FROM_S(i, step, step + route.size() - 1)
            {
                int idx = i >= route.size() ? i - route.size() : i;
                sum += value[route[idx]];
                idx = idx - step < 0 ? idx - step + route.size() : idx - step;
                sum -= value[route[i - step]];
                maxSum = sum > maxSum ? sum : maxSum;
            }
            segmentSum.push_back(maxSum);
        }
        int addition = k % route.size();
        if (fullValue > 0)
        {
            long long value = addition == 0 ? 0 : -10e10;
            FROM_0(i, addition)
                value = max(value, segmentSum[i]);
            long long value1 = (long long)(k / route.size()) * fullValue + value;
            long long value2 = value1;
            if (k >= route.size())
            {
                value = -10e10;
                FROM_0(i, segmentSum.size())
                    value = max(value, segmentSum[i]);
                value2 = (long long)(k / route.size() - 1) * fullValue + value;
            }
            maxValue = max(max(value1, value2), maxValue);
        }
        else
        {
            int end = min(k, (int)segmentSum.size());
            long long value = -10e10;
            FROM_0(i, end)
                value = max(value, segmentSum[i]);
            maxValue = max(value, maxValue);
        }
    }
    cout << maxValue << endl;

    return 0;
}


Measured memory_bytes: 3776
// In the name of Allah
// #ISART 
// yedune bashe mashti bashe :D

#include<bits/stdc++.h>

#define ll long long

using namespace std;

const int MAXN = 50;

deque<int> a[MAXN], b[MAXN];

int main(){
	int m = 1, cnt;
	ll n; cin >> n;
	ll po = 2;

	while(po - 1 < n) po *= 2, m ++;
	if(po - 1 > n) po /= 2, m --;
	
	n -= po - 1;
	cnt = m + 1;
	for(int i = m; i > -1; i --){
		if(n & (1ll << i)){
			a[1].push_front(cnt);
			b[m - i].push_back(cnt);
			cnt ++;
		}
	}
	cnt = 2 * (cnt - 1);
	cout << cnt << endl;
	for(auto u : a[1]) cout << u << ' ';
	for(int i = 1; i <= m; i ++) cout << i << ' ';
	for(int i = 1; i <= m; i ++){
		cout << i << ' ';
		for(auto u : b[i])
			cout << u << ' ';
	}
	return 0;
}

Measured memory_bytes: 256
#A
D = int(input())
c = [0] + list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

last = [0] * 27
manzoku = [0] * 27
for i in range(1, D+1):
    for j in range(1, 27):
        manzoku[j] -= c[j] * (i - last[j])
    manzoku[s[i-1].index(max(s[i-1]))] += max(s[i-1])
    last[s[i-1].index(max(s[i-1]))] = i
    result = s[i-1].index(max(s[i-1])) + 1
    print(result)





Measured memory_bytes: 9324
#include <stdio.h>

int main(void)
{
  int a, b, c;
  
  int flag=0;
  
  
  scanf("%d%d%d",&a,&b,&c);
     
  if(a==b&&b==c)
    flag=1;
  else if(a!=b&&b!=c&&c!=a)
    
    flag=1;
  
  if(flag)
    printf("No");
  else
    printf("Yes");
return 0;
}
  

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
typedef long long LL;
#define FOR(i, a, b) for(LL i=(LL)(a);i<(LL)(b);i++)
#define REP(i,x) for(LL i=0;i<(LL)(x);i++)

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    // cout << fixed << setprecision(10);
    LL a, b;
    cin >> a >> b;
    LL ret_a = (a <= 1) ? 0 : a * (a-1) / 2;
    LL ret_b = (b <= 1) ? 0 : b * (b-1) / 2;
    LL ret = ret_a + ret_b;
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
typedef pair<int,int> P;
int main(){
    string s;
    cin>>s;
    bool f=true;
    REP(i,s.size()){
        if(i==0)continue;
        if(s[i]!='9')f=false;
    }
    if(s.size()==1){
        cout<<s[0]<<endl;
        return 0;
    }
    if(f)cout<<(s.size()-1)*9+(s[0]-'0')<<endl;
    else cout<<(s.size()-1)*9+(s[0]-'0'-1)<<endl;
}

Measured memory_bytes: 256
from collections import defaultdict

N,M = map(int,input().split())

KEN = defaultdict(list)
KENOUT = defaultdict(dict)
OUTPUT = []
for i in range(M):
    p,y = map(int,input().split())
    KEN[p].append(y)
    OUTPUT.append((p,y))

for p in KEN:
    for i,y in enumerate(sorted(KEN[p])):
        KENOUT[p][y] = i+1
        
for p,y in OUTPUT:
    print(str(p).zfill(6)+str(KENOUT[p][y]).zfill(6))

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

int main() {
  string s;
  cin >> s;
  
  int rainyDays_i=0;
  bool isLonging = true;
  for (int i=0; i<3; i++) {
    if (s.at(i) == 'R') {
      if (isLonging) {
        rainyDays_i++;
      }
      else {
        rainyDays_i = 1;
      }
      isLonging = true;
    }
    else {
      isLonging = false;
    }
  }
  cout << rainyDays_i << endl;
}     

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    int x;
    cin >> x;

    int maior = 1;
    for ( int i = 2; i <= x; i++ ) {
        for ( int j = 2; (int) pow(i, j) <= x; j++ ) maior = max(maior, (int) pow(i, j));
    }
    
    cout << maior << endl;

    return 0;
}

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

int main(){
  int n; cin>>n;
  vector<double> a(110);
  double x=0;
  for(int i=0;i<n;i++){
    cin>>a.at(i);
    x+=1/(a.at(i));
  }
  cout<<1/x<<endl;
}

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

#define ll long long int
#define ull unsigned long long int
#define Max 1000005
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define pi acos(-1.0)
#define pb push_back
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define endl '\n'

#define sc(n) scanf("%d",&n)
#define scan(n) scanf("%lld",&n)
/*        speed up       */
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF    1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));
#define tst() _fastio;int testsalam;cin >> testsalam;while(testsalam--)
#define Mod 100000007
#define YES cout<<"Yes"<<endl;
#define NO cout<<"No"<<endl;

//void inversemod(ll n, ll mod, ll invmod[],ll MOD){for(int i=2; i<=n; ++i) invmod[i]=MOD-MOD/i*invmod[MOD%i]%MOD;}
//void bigmod( ll a, ll b ,ll mod){ll r = 1;a = a%mod;while(b){if( b%2 ) r = (r*a)%mod;b = b/2;a = (a*a)%mod; }return (ll)r;}
string inttostr(ll n){std::stringstream ss;ss << n;string out=ss.str();return out;}
ll stringtoint(string s){istringstream iss (s);ll n;iss >> n;return n;}
template <typename T> T gcd(T a,T b){if(a < 0)return gcd(-a,b);if(b < 0)return gcd(a,-b);return (b == 0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a < 0)return lcm(-a,b);if(b < 0)return lcm(a,-b);return a*(b/gcd(a,b));}
typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;
typedef tuple<ll,ll,ll>tpl;

int main()
{
    int n;
    cin >> n;
    int arr[n+10];
    load(arr,n);
    sort(arr,arr+n);
    reverse(arr,arr+n);
    ll sum=0;
    int m=n/2+1;
    vector<int> v(n+10);
    for(int i=0;i<m;i++)v[i]=arr[i],sum+=arr[i];
    sum-=arr[m-1];

	int rest=n-m;
	// cout<<"sum "<<sum<<endl;
	for (int i = 0; i < rest; ++i)
	{
		sum+=min(v[i],v[i+1]);
		// cout<<"for "<<v[i]<<' '<<v[i+1]<<endl;
	}
    
    return cout<<sum<< endl,0;
}
/*
     remember:
     ll vs int
     array size
     case for 1 2 3 
*/



Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) std::begin(x), std::end(x)
using namespace std;

inline constexpr int32_t modpow(uint_fast64_t x, uint64_t k, int32_t MOD) {
    assert (0 <= x and x < MOD);
    uint_fast64_t y = 1;
    for (; k; k >>= 1) {
        if (k & 1) (y *= x) %= MOD;
        (x *= x) %= MOD;
    }
    assert (0 <= y and y < MOD);
    return y;
}

template <int32_t MOD>
struct mint {
    int32_t value;
    mint() : value() {}
    mint(int64_t value_) : value(value_ < 0 ? value_ % MOD + MOD : value_ >= MOD ? value_ % MOD : value_) {}
    mint(int32_t value_, std::nullptr_t) : value(value_) {}
    explicit operator bool() const { return value; }
    inline constexpr mint<MOD> operator + (mint<MOD> other) const { return mint<MOD>(*this) += other; }
    inline constexpr mint<MOD> operator - (mint<MOD> other) const { return mint<MOD>(*this) -= other; }
    inline constexpr mint<MOD> operator * (mint<MOD> other) const { return mint<MOD>(*this) *= other; }
    inline constexpr mint<MOD> & operator += (mint<MOD> other) { this->value += other.value; if (this->value >= MOD) this->value -= MOD; return *this; }
    inline constexpr mint<MOD> & operator -= (mint<MOD> other) { this->value -= other.value; if (this->value <    0) this->value += MOD; return *this; }
    inline constexpr mint<MOD> & operator *= (mint<MOD> other) { this->value = (uint_fast64_t)this->value * other.value % MOD; return *this; }
    inline constexpr mint<MOD> operator - () const { return mint<MOD>(this->value ? MOD - this->value : 0, nullptr); }
    inline constexpr mint<MOD> pow(uint64_t k) const { return mint<MOD>(modpow(value, k, MOD), nullptr); }
};
template <int32_t MOD> mint<MOD> operator * (int64_t value, mint<MOD> n) { return mint<MOD>(value) * n; }
template <int32_t MOD> std::istream & operator >> (std::istream & in, mint<MOD> & n) { int64_t value; in >> value; n = value; return in; }
template <int32_t MOD> std::ostream & operator << (std::ostream & out, mint<MOD> n) { return out << n.value; }


constexpr int MOD = 998244353;
mint<MOD> solve(int n, const vector<int> & d) {
    if (d[0] != 0) return 0;
    vector<int> cnt(n);
    for (int d_i : d) {
        ++ cnt[d_i];
    }
    if (cnt[0] != 1) return 0;
    mint<MOD> answer = 1;
    REP (k, n - 1) {
        if (cnt[k] == 0 and cnt[k + 1] != 0) return 0;
        answer *= mint<MOD>(cnt[k]).pow(cnt[k + 1]);
    }
    return answer;
}

int main() {
    int n; cin >> n;
    vector<int> d(n);
    REP (i, n) {
        cin >> d[i];
    }
    cout << solve(n, d) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
 
using namespace std;
 
#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009
#define pi 3.141592653589793238
 
typedef pair<int, int> P;
 
 
signed main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
    // Failed to predict input format
    int N; cin>>N;
    vector<int> a(N);
    REP(i,N){
        cin>>a[i];
    }
    int ans = 0;
    map<int,int> ma;
    vector<int> b(N);
    REP(i,N){
        ma[i-a[i]]++;
    }
    REP(i,N){
        ans+=ma[a[i]+i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 28964
import std.stdio, std.algorithm, std.conv, std.string;

void main()
{
    foreach(input; stdin.byLine().map!(line => line.split.map!(to!int)))
    {
        if(input[0] == 0) break;
        solve(input[0], input[1], 0).writeln;
    }
}

int solve(int numDigits, int sum, int min)
{
    int combinations;

    if(sum < min || numDigits <= 0) return 0;
    else if(numDigits == 1) return min <= sum && sum <= 9 ? 1 : 0;

    foreach(i; min..10)
    {
        combinations += solve(numDigits - 1, sum - i, i + 1);
    }

    return combinations;
}

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

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

    int count[10]; memset(count, 0, sizeof count);
    int N;
    for (int i = 0; i < 4; i++) {
        cin >> N;
        count[N]++;
    }
    
    cout << (count[1] == 1 && count[9] == 1 && count[7] == 1 && count[4] == 1 ? "YES" : "NO") << endl;
}


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

#define ll long long
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

void solve()
{
	ll n,k,sum=0;
	cin>>n>>k;
	ll a[n];
	for(ll i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	for(ll i=0;i<k;i++) sum+=a[i];
	cout<<sum;
}

int main() 
{
	FAST
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++) solve();
	return 0;
}

Measured memory_bytes: 3664
#define _CRT_SECURE_NO_WARNINGS

#pragma GCC optimize("O3")

#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <cstring>
#include <numeric>
#include <set>
#include <queue>
#include <deque>
#include <array>
#include <string>
#include <cmath>
#include <random>
#include <ctime>
#include <map>
#include <functional>
#include <bitset>
#include <complex>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>

#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define pb push_back

using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using ld = long double;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	const int mod = 1e9 + 7;
	int n, k;
	cin >> n >> k;
	vi a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vi dp(k + 1, 0);
	dp[0] = 1;
	vi pref(k + 1, 1);
	for (int i = 0; i < n; i++) {
		vi dp_new(k + 1, 0);
		for (int j = 0; j <= k; j++) {
			int l = max(0, j - a[i]);
			dp_new[j] = pref[j] - (l ? pref[l - 1] : 0);
			if (dp_new[j] < 0) {
				dp_new[j] += mod;
			}
		}
		dp = dp_new;
		pref = dp;
		for (int i = 1; i <= k; i++) {
			(pref[i] += pref[i - 1]) %= mod;
		}
	}
	cout << dp.back();
}


Measured memory_bytes: 1408
use std::collections::HashMap;
// stdin
macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

// input
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"6 3 4
3
1
3
2
" => r"No
No
Yes
No
No
No",

r"6 5 4
3
1
3
2
" => r"Yes
Yes
Yes
Yes
Yes
Yes",

r"10 13 15
3
1
4
1
5
9
2
6
5
3
5
8
9
7
9
" => r"No
No
No
No
Yes
No
No
No
Yes
No"
}

fn solve(src: &str) -> String {
    input! {
        source=src,
        n:i32,
        k:i32,
        q:i32,
        a:[i32;q],
    };

    let n: i32 = n;
    let k: i32 = k;
    let q: i32 = q;
    let a: Vec<i32> = a;

    let mut map = HashMap::new();

    for &v in a.iter() {
        match map.get(&v) {
            None => {
                map.insert(v, 1);
            }
            Some(&vv) => {
                map.insert(v, vv + 1);
            }
        }
    }

//    let mut ans = vec![];

    for num in 1..n + 1 {
        match map.get(&num) {
            None => {
                if k - q > 0 {
                    println!("Yes");
                }else{
                    println!("No");
                }
            },
            Some(&v) => {
                if k - (q - v) > 0 {
                    println!("Yes");
                }else{
                    println!("No");
                }

            },
        };
//        ans.push(tmp);
    }

//    let ans = ans.join("\n");
    "".to_string()
//    format!("{}", ans)
}


fn main() {
    println!("{}", solve(&stdin!()));
}



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

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

const int N = 2e5 + 5;

int a[N];
int aord[N];
vector<int> g[N];
int ans[N];

int id;
const int B = N * 60; // Should be fine
int X[B], L[B], R[B];

int n;
int Build(int l=0, int r=n) {
    int u = ++id;
    if (r - l <= 1) {
        X[u] = 0;
        return u;
    }

    int mid = (l + r) / 2;
    L[u] = Build(l, mid);
    R[u] = Build(mid, r);
    X[u] = X[L[u]] + X[R[u]];
    return u;
}

int Add(int u, int pos, int value, int l=0, int r=n) {
    int v = ++id;
    if (r - l <= 1) {
        X[v] = X[u] + value;
        return v;
    }

    int mid = (l + r) / 2;
    if (pos < mid)
        L[v] = Add(L[u], pos, value, l, mid), R[v] = R[u];
    else
        R[v] = Add(R[u], pos, value, mid, r), L[v] = L[u];
    X[v] = X[L[v]] + X[R[v]];
    return v;
}

// -1 if there's no element in a position >=pos, otherwise the index of the lower bound
int LowerBound(int u, int pos, int l=0, int r=n) {
    if (X[u] == 0 || r <= pos)
        return -1;

    if (r-l <= 1)
        return l;

    int mid = (l + r) / 2;
    int ansLeft = LowerBound(L[u], pos, l, mid);
    if (ansLeft != -1) // found the lower bound in the left node
        return ansLeft;
    return LowerBound(R[u], pos, mid, r); // not found in the left, let's try the right node
}


int roots[N];
void dfs(int u, int p=0) {
    int x = lower_bound(aord+1, aord+n+1, a[u]) - (aord+1);
    int lb = LowerBound(roots[p], x);

    if (lb == -1) {
        roots[u] = Add(roots[p], x, 1);
    } else {
        roots[u] = Add(roots[p], lb, -1);
        roots[u] = Add(roots[u], x, 1);
    }

    ans[u] = X[roots[u]];

    for (int v : g[u]) if (v != p) {
        dfs(v, u);
    }
}

int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        aord[i] = a[i];
    }
    sort(aord+1, aord+n+1);
    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        g[u].emplace_back(v);
        g[v].emplace_back(u);
    }

    roots[0] = Build();
    dfs(1);

    for (int u = 1; u <= n; u++)
        cout << ans[u] << endl;

    return 0;
%>

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

using namespace std;
#define ll long long
const int N=15,M=1005,INF=1e9+5;
int dp[N][M],dp2[N][M];
string a[N];
int n,m,k;
int v[N][M];
int sum[N];
int C(int n)
{
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            if(v[i][j]>k)
                return INF;
    memset(sum,0,sizeof sum);
    int ret=0;
    for(int j=0;j<m;)
    {
        bool ok=1;
        for(int i=0;i<n;i++)
            if((sum[i]+=v[i][j])>k)
                ok=0;
        if(!ok)
            for(int i=0;i<n;i++)
                sum[i]=0;
        if(!ok) ret++;
        j+=ok;
    }
    return ret;
}
int solve(int msk)
{
    int ret=0,idx=0;
    memset(v,0,sizeof v);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
            v[idx][j]+=(a[i][j]-'0');
        idx+=(msk>>i)&1;
    }
    return C(idx)+__builtin_popcount(msk)-1;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>m>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    int ans=INF;
    for(int i=0;i<(1<<n);i++)
    {
        int msk=(i|(1<<(n-1)));
        ans=min(ans,solve(msk));
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
    long long n, k;
    cin >> n >> k;
    vector<long long> A(n);
    REP(i, n) cin >> A[i];

    vector<long long> X(n + 1, 0), Y(n + 1, 0);
    REP(i, n){
        X[i + 1] = A[i] + X[i];
        Y[i + 1] = max(0ll, A[i]) + Y[i];
    }

    long long ma = -1e18;
    REP(i, n - k + 1){
        ma = max(ma, max(0ll, X[i + k] - X[i]) + Y[n] - (Y[i + k] - Y[i]));
    }
    cout << ma << endl;

    return 0;
}

Measured memory_bytes: 2560
# 素数と個数を求める
def factorize(n):
    res = []
    for i in range(2,n):
        if i*i > n: break
        if n%i: continue
        res += [[i,0]]
        while n%i == 0:
            n //= i
            res[-1][1] += 1
    if n != 1: res += [[n,1]]
    return res

n = int(input())
P = factorize(n)
ans = 0
for p, c in P:
    pi = 1
    for i in range(1, c+1):
        pi *= p
        if n%pi: continue
        n //= pi
        ans += 1
print(ans)


Measured memory_bytes: 9196
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 211
#define mod 998244353

int n, i, j, k;
pair<int, int> P[maxN];
vector< pair<int, int> > ord;

ll pows[maxN];
ll ans, dx, dy, d;

ll gcd(ll a, ll b) {
    if (a < 0) a *= -1;
    if (b < 0) b *= -1;
    if (a < b) swap(a, b);

    while (b > 0) {
        a %= b;
        swap(a, b);
    }

    return a;
}

int main()
{
  //  freopen("test.in","r",stdin);

    cin >> n;
    for (i = 1; i <= n; i++)
        cin >> P[i].first >> P[i].second;

    pows[0] = 1;
    for (i = 1; i <= n; i++)
        pows[i] = (pows[i - 1] * 2) % mod;

    ans = pows[n];

    for (i = 1; i <= n; i++) {
        ord.clear();
        for (j = i + 1; j <= n; j++) {
            dx = P[i].first - P[j].first;
            dy = P[i].second - P[j].second;

            if (dx < 0) {
                dx *= -1;
                dy *= -1;
            }

            if (dx == 0 && dy < 0)
                dy *= -1;

            d = gcd(dx, dy);
            dx /= d;
            dy /= d;
            ord.pb(mp(dx, dy));
        }

        sort(ord.begin(), ord.end());
        for (j = 0; j < ord.size(); j = k) {
            for (k = j; k < ord.size(); k++)
                if (ord[j] != ord[k])
                    break;

            ans += mod - pows[k - j] + 1;
            ans %= mod;
        }

        ans += mod - 1;
        ans %= mod;
    }

    ans += mod - 1;
    ans %= mod;

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        long sho = n / (a + b);
        long amari = n % (a + b);

        long pulus = 0;
        if (amari <= a) {
            pulus = amari;
        } else {
            pulus = a;
        }

        System.out.println(sho * a + pulus);

    }
}

Measured memory_bytes: 23764
import java.util.*;
public class Main {
  public static void main(String[] args){
     new Main().run();
  }

  void run() {
    Scanner sc = new Scanner(System.in);
    long limit = (long)Math.pow(10, 18);
    long N = sc.nextLong();
    long ans = sc.nextLong();

    long i=1;
    try {
      for (; i<N; i++) {
        ans = Math.multiplyExact(ans, sc.nextLong());
      }
    } catch (Exception e) {
      ans = -1;
      i++;
      for (; i<N; i++) {
        if (sc.nextLong() == 0) {
          ans = 0;
        }
      }
    }
    if (limit < ans) {
      ans = -1;
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 59928
#include <bits/stdc++.h>
#define MAX_N 200001
#define mod 1000000007
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define REV(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin(), v.end()
#define pb push_back
const ll INF = 9e18;
string s;
ll n;
ll rgbi[MAX_N][3], rgbk[MAX_N][3];

signed main(){
    cin >> n >> s;

    // set rgbi and rgbk
    rgbi[1][0] = rgbi[1][1] = rgbi[1][2] = 0;
    rgbk[1][0] = rgbk[1][1] = rgbk[1][2] = 0;
    // j = 1 (1 <= j <= n-2)
    if(s[0]=='R') rgbi[1][0]++;
    if(s[0]=='G') rgbi[1][1]++;
    if(s[0]=='B') rgbi[1][2]++;
    for(ll k=2; k<n; k++){
        if(s[k]=='R') rgbk[1][0]++;
        if(s[k]=='G') rgbk[1][1]++;
        if(s[k]=='B') rgbk[1][2]++;
    }
    // j > 1 (1 <= j <= n-2)
    for(ll j=2; j<=n-2; j++){
        rgbi[j][0] = rgbi[j-1][0];
        rgbi[j][1] = rgbi[j-1][1];
        rgbi[j][2] = rgbi[j-1][2];
        if(s[j-1]=='R') rgbi[j][0]++;
        if(s[j-1]=='G') rgbi[j][1]++;
        if(s[j-1]=='B') rgbi[j][2]++;

        rgbk[j][0] = rgbk[j-1][0];
        rgbk[j][1] = rgbk[j-1][1];
        rgbk[j][2] = rgbk[j-1][2];
        if(s[j]=='R') rgbk[j][0]--;
        if(s[j]=='G') rgbk[j][1]--;
        if(s[j]=='B') rgbk[j][2]--;
    }

    // for(ll j=1; j<=2; j++) cout << rgbi[j][0] << ' ' << rgbi[j][1] << ' ' << rgbi[j][2] << endl;
    // for(ll j=1; j<=2; j++) cout << rgbk[j][0] << ' ' << rgbk[j][1] << ' ' << rgbk[j][2] << endl;

    ll ret = 0;
    for(ll j=1; j<=n-2; j++){
        if(s[j] == 'R') ret += rgbi[j][1] * rgbk[j][2] + rgbi[j][2] * rgbk[j][1];
        if(s[j] == 'G') ret += rgbi[j][2] * rgbk[j][0] + rgbi[j][0] * rgbk[j][2];
        if(s[j] == 'B') ret += rgbi[j][0] * rgbk[j][1] + rgbi[j][1] * rgbk[j][0];
    }

    for(ll j=1; j<=n-2; j++){
        for(ll i=0; i<j; i++){
            ll k = j + (j - i);
            if(k < n){
                if(s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) ret--;
            }
        }
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 3672
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)

A,B,C,D = map(int,input().split(" "))
min_C = B//C-(A-1)//C
min_D = B//D-(A-1)//D
lcm = lcm(C,D)
min_lcm = B//lcm-(A-1)//lcm
print(B-A-min_C-min_D+min_lcm+1)



Measured memory_bytes: 3060
#include <iostream>
#include <string.h>
#include <algorithm>
typedef long long ll;
using namespace std;

int main()
{
  ll h,w,ans;
  cin >> h >> w;
  ans = h*(w/2)+(h/2+h%2)*(w%2);
  if(h==1 || w == 1){
  ans = 1;
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())
 
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
 
template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}
 
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}
 
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}
 
#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
 
constexpr ll INF = TEN(18);
 
int main() {
    int N, K;
    cin >> N >> K;
    V<int> P(N), C(N);
    rep(i, N) cin >> P[i], --P[i];
    rep(i, N) cin >> C[i];
 
    ll ans = -INF;
 
    rep(i, N) {
        int v = i;
        ll cycle_sum = 0;
        int cycle_cnt = 0;
 
        while (true) {
            cycle_cnt++;
            cycle_sum += C[v];
            v = P[v];
            if (v == i) break;
        }
 
        ll path = 0;
        int cnt = 0;
 
        while (true) {
            cnt++;
            path += C[v];
 
            if (cnt > K) break;
 
            int num = (K - cnt) / cycle_cnt;
            ll score = path + max(0ll, cycle_sum) * num;
            chmax(ans, score);
 
            v = P[v];
            if (v == i) break;
        }
    }
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 3676