akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
typedef long long ll;
using namespace std;

const ll MAXN = 200000;
const ll INF = 1001001001;

ll N, K, ans=0, tmp=0;
vector<ll> A, B;
map<ll,ll> M;

signed main(){
    cin >> N >> K;
    A.push_back(0);
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        tmp = A.back();
        a += tmp;
        A.push_back(a);
    }
    for(int i=0;i<N;i++) {
        for(int j=i+1;j<=N;j++) {
            ll num = A[j]-A[i];
            B.push_back(num);
            int k=0;
            while(num>=1) {
                M[k]+=num%2;
                num /= 2;
                k++;
            }
        }
    }
    ll id=0;
    map<ll,ll>::iterator itr=M.end();
    while(itr!=M.begin()) {
        itr--;
        pair<ll,ll> p = *itr;
        if(p.second>=K) {
            ans += pow(2,p.first);
            for(int i=0;i<B.size();i++) {
                ll nump = B[i]/pow(2,p.first);
                if(nump%2==0) {
                    B[i] = 0;
                }
            }
            break;
        }
    }
    while(itr!=M.begin()) {
        itr--;
        pair<ll,ll> p = *itr;
        ll ct=0;
        for(int i=0;i<B.size();i++) {
            ll nump = B[i]/pow(2,p.first);
            if(nump%2==1) {
                ct++;
            }
        }
        if(ct>=K) {
            ans += pow(2,p.first);
            for(int i=0;i<B.size();i++) {
                ll nump = B[i]/pow(2,p.first);
                if(nump%2==0) {
                    B[i] = 0;
                }
            }
        }
    }    
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const ll INF = (1LL << 55);

struct SegmentTree{
  vector<ll> mini, maxi;
  int sz;
  SegmentTree(int n)
  {
    sz = 1;
    while(sz < n) sz *= 2;
    mini.resize(2*sz-1, INF);
    maxi.resize(2*sz-1, -INF);
  }
  void update(int k, ll x)
  {
    k += sz - 1;
    mini[k] = x;
    maxi[k] = x;
    while(k > 0){
      k = (k - 1) / 2;
      mini[k] = min(mini[2*k+1], mini[2*k+2]);
      maxi[k] = max(maxi[2*k+1], maxi[2*k+2]);
    }
  }
  ll minimum(int a, int b, int k, int l, int r)
  {
    if(r <= a || b <= l) return INF;
    if(a <= l && r <= b) return mini[k];
    ll vl = minimum(a, b, 2*k+1, l, (l+r)/2);
    ll vr = minimum(a, b, 2*k+2, (l+r)/2, r);
    return min(vl, vr);
  }
  ll maximum(int a, int b, int k, int l, int r)
  {
    if(r <= a || b <= l) return -INF;
    if(a <= l && r <= b) return maxi[k];
    ll vl = maximum(a, b, 2*k+1, l, (l+r)/2);
    ll vr = maximum(a, b, 2*k+2, (l+r)/2, r);
    return max(vl, vr);
  }
  ll minimum(int a, int b)
  {
    return minimum(a, b, 0, 0, sz);
  }
  ll maximum(int a, int b)
  {
    return maximum(a, b, 0, 0, sz);
  }
};

int main()
{
  ll N, M, K, A[20010];
  cin >> N >> M >> K;
  SegmentTree seg(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  ll dp[20010];
  fill(dp, dp + 20010, INF);
  dp[0] = 0;
  for(int i = 0; i < N; i++){
    ll maxi = -INF, mini = INF;    
    for(int j = 1; j <= min(M, N-i); j++){
      maxi = max(maxi, A[i+j-1]);
      mini = min(mini, A[i+j-1]);
      ll dif = maxi - mini;
      dp[i + j] = min(dp[i + j], dp[i] + K + j*dif);
    }
  }
  cout << dp[N] << endl;
  return 0;
}

Measured memory_bytes: 2328
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define M 1000000007
typedef long long ll;
int main() { 
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n,a[1000000],i,k,s=0;
    cin>>n>>k;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=0;i<max(0ll,n-k);i++){
        s+=a[i];
    }
    cout<<s<<"\n";
    return 0;
}


Measured memory_bytes: 3840
N = int(input())
uv = [[int(i) for i in input().split()] for _ in range(N - 1)]

e = 0
for u, v in uv :
  e += min(u, v) * (N - max(u, v) + 1)

v = 0
for i in range(1, N + 1) :
  v += i * (N + 1 - i)
  
print(v - e)

Measured memory_bytes: 102588
#include <bits/stdc++.h> 
using namespace std;
typedef long long int ll;
ll dp[105][100005];
int main()
{
    memset(dp,0,sizeof(dp));
    ll n,w;
    cin>>n>>w;
    ll wrr[n+1];
    ll vrr[n+1];
    for(ll i=1;i<=n;i++)
        cin>>wrr[i]>>vrr[i];
    for(ll i =1;i<=n;i++)
    {
        for(ll j=1;j<=w;j++)
        {
            if(j - wrr[i] >= 0)
            {
                dp[i][j] = max(dp[i-1][j-wrr[i]] + vrr[i],dp[i-1][j]);
                //cout<<dp[i][j];
            }
            else
                dp[i][j] = dp[i-1][j]; 
        }
        //cout<<endl;
    }
    cout<<dp[n][w]<<endl;
    
}

Measured memory_bytes: 82304
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

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

	lint N;
	cin >> N;

	string ans;

	if (!N) ans = '0';
	while (N != 0) {
		if (N % 2) ans += '1', N--;
		else ans += '0';
		N /= -2;
	}

	reverse(ans.begin(), ans.end());
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e9 + 5;
#define INF 1000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;



int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	int n;
	cin >> n;
	string s;
	cin >> s;
	int l = s.size();
	string ans;
	for(int i=0; i<l; i++){
		int x = s[i]-'A';
		x=(x+n)%26;
		ans+=('A'+x);
	}
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3456
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

use std::cmp::max;

const TBL: &'static [i64] = &[0, 2, 5, 5, 4, 5, 6, 3, 7, 6];

fn main() {
    input! {
        mut n: i64,
        m: usize,
        mut a: [usize; m],
    }
    a.sort();

    let minu = a.iter().map(|&a| TBL[a]).min().unwrap();
    let maxa = *a.iter().filter(|&&a| TBL[a] == minu).max().unwrap();

    let mut ans: Vec<usize> = vec![];
    while n / minu > 18 {
        ans.push(maxa);
        n -= minu;
    }

    let mut tbl = vec![None; n as usize + 1];
    let mut rest = solve(n as usize, &a, &mut tbl).unwrap();

    while rest > 0 {
        ans.push(rest as usize % 10);
        rest /= 10;
    }

    ans.sort();
    ans.reverse();

    for v in ans {
        print!("{}", v);
    }
    println!();
}

fn solve(n: usize, a: &[usize], tbl: &mut [Option<Option<i64>>]) -> Option<i64> {
    if n == 0 {
        return Some(0);
    }
    if let Some(ret) = tbl[n] {
        return ret;
    }

    let mut ret = None;
    for &c in a.iter() {
        if TBL[c] <= n as i64 {
            if let Some(rmax) = solve(n - TBL[c] as usize, a, tbl) {
                let cur = rmax * 10 + c as i64;
                if ret.is_none() {
                    ret = Some(cur);
                } else if ret < Some(cur) {
                    ret = Some(cur);
                }
            }
        }
    }

    tbl[n] = Some(ret);
    ret
}


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

int digit_sum(int x){
  int ret = 0;
  while(x > 0){
    ret += x % 10;
    x /= 10;
  }
  return ret;
}

int main(){
  int N, A, B;
  cin >> N >> A >> B;

  long long ans = 0;
  for(int i = 1; i <= N; i++){
    if(A <= digit_sum(i) && digit_sum(i) <= B){
      ans += i;
    }
  }
  cout << ans << endl;
}


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

int main(void) {
	long X;
	scanf("%ld", &X);
	int i = 0;
	while (1) {
		bool isPrime = true;
		for (long j = 2; j*j < X + i; j++) {
			// cout << X + i << " " << j << endl;
			if ((X + i) % j == 0) {
				isPrime = false;
				break;
			}
		}
		if (isPrime) {
			printf("%ld", X + i);
			return 0;
		}
		i++;
	}

	return 0;
}


Measured memory_bytes: 3780
#!/usr/bin/env python3
#AGC5 B

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
lst = [0 for i in range(n+1)]
for i in range(n):
    lst[a[i]] = i

l = [0]*n
r = [0]*n
ans = 0
for i in range(1,n+1)[::-1]:
    x = lst[i]
    if x + 1 < n and a[x+1] > i:
        R = r[x+1]
    else:
        R = x
    if x - 1 >= 0 and a[x-1] > i:
        L = l[x-1]
    else:
        L = x
    l[R] = L
    r[L] = R
    ans += (x - L + 1)*(R - x + 1)*i
print(ans)

Measured memory_bytes: 80336
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {/*
        var nm = Add.ar;
        var ads = new List<int>[nm[0]];
        for (var i = 0; i < nm[0]; i++)
            ads[i] = new List<int>();
        var ct = 0L;
        for(var i = 0; i < nm[1]; i++)
        {
            var inp = Add.ar;
            ads[inp[0] - 1].Add(inp[1] - 1);
        }
        for(var i = 0; i < nm[0]; i++)
        {

        }*/
        var abk = Add.ar;
        var list = new List<int>();
        for(var i = 1; i <= Min(abk[0], abk[1]); i++)
        {
            if (abk[0] % i == 0 && abk[1] % i == 0)
            {
                list.Add(i);
            }
        }
        list = list.OrderByDescending(v => v).ToList();
        WriteLine(list[abk[2] - 1]);
    }
}

public class Add
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public  static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 13396
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int ah,am,as,zh,zm,zs,wh=0,wm=0,ws=0;
    for(int i=0;i<3;i++){
        cin>>ah>>am>>as>>zh>>zm>>zs;
        ws=zs-as;
        if(ws<0){
            ws=ws+60;
            wm--;
        }
        wm=wm+zm-am;
        if(wm<0){
            wm=wm+60;
            wh--;
        }
        wh=wh+zh-ah;
        cout<<wh<<" "<<wm<<" "<<ws<<endl;
        wh=wm=ws=0;
    }
    
}



Measured memory_bytes: 3080
#include <iostream>
#include <string>
#define SIZE 10005
#define MAX  105
  const int mod = (int)1e9 + 7;
  std::string s;
  int k, dp[SIZE][2][MAX];

  inline int add(int a, int b, int mod) {a += b; return a >= mod ? a - mod : a;}

  int digit_dp(int pos, int small, int d) {
    if(pos == s.length()) return d == 0;

    int& ans = dp[pos][small][d];
    if(ans!=-1) return ans;

    ans=0;
    int mx=9;
    if(!small) mx = s[pos]-'0';
    for(int i=0; i<=mx; i++) {
        int nsmall = small;
        if(i < mx) nsmall=1;
        ans = add(ans, digit_dp(pos+1, nsmall, (d+i)%k), mod);
    }

    return ans;
  }

  int main(void) {
    std::cin >> s >> k;
    for(int i=0; i<SIZE; i++) for(int j=0; j<2; j++) for(int l=0; l<MAX; l++) dp[i][j][l] = -1;

    printf("%d", add(digit_dp(0,0,0), mod-1, mod));
    return 0;
  }







Measured memory_bytes: 9216
s = input()
for i, char in enumerate(s):
    if i % 2 == 0 and char not in ('R', 'U', 'D'):
        print('No')
        break
    elif i % 2 == 1 and char not in ('L', 'U', 'D'):
        print('No')
        break
else:
    print('Yes')
      

Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
	int x,y;
    char op;
    
    
    bool hasEnd = false;
    
    while(!hasEnd){
        int result;
        cin>>x>>op>>y;
    switch(op){
        case '+':
        result = x + y;
        break;
        case '-':
        result = x - y;
        break;
        case '*':
        result = x * y;
        break;
        case '/':
        result = x / y;
        break;
        case '?':
        hasEnd = true;
        break;
    }
    if(!hasEnd){
        cout<<result<<endl;
    }
    
    }
    
    
    
	return 0;
}

Measured memory_bytes: 3104
import java.util.Scanner;

public class  Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in); //3つのキャンディーパックを２人に分ける
        String a = sc.next(); //キャンディーa
        String b = sc.next(); //キャンディーb
        String c = sc.next(); //キャンディーc
        
        System.out.println("A" + b.substring(0, 1) + "C");
}
}

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define debug(v) {for (auto x : v) cerr << x << ' '; cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n;
	scanf("%d", &n);
	int g = 0;
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		g = __gcd(g, x);
	}
	printf("%d\n", g);
}


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

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    println!(
        "{}",
        if a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 {
            "Possible"
        } else {
            "Impossible"
        }
    );
}

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


Measured memory_bytes: 4476
local n = io.read("n")
local b = {}
for i = 1, n do
    b[i] = io.read("n")
end
local a = {}
for i = n,1,-1 do
    for j = i,1,-1 do
        if b[j] == j then
            a[i] = j
            table.remove(b, j)
            break
        end
    end
    if #b == i then
        print(-1)
        return 0
    end
end
for i = 1,n do
    print(a[i])
end

Measured memory_bytes: 760
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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

__attribute__ ((constructor))
void init() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
}

signed main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(c - (a - b),0) << endl;
    return 0;
}

Measured memory_bytes: 3616
import itertools
N, K = [int(_) for _ in input().split()]
if (N - 1) * (N - 2) // 2 < K:
    print(-1)
    exit()
ans1 = []
ans2 = []
for i in range(1, N):
    ans1 += [[i, N]]
for ab in itertools.combinations(range(1, N), 2):
    a, b = ab
    ans2 += [[a, b]]
ans = ans1 + ans2[:len(ans2) - K]
print(len(ans))
for ab in ans:
    a, b = ab
    print(a, b)


Measured memory_bytes: 4256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1145141919364364
#define double long double
using namespace std;
typedef pair<ll, ll>P;
struct edge { ll to, cost; };
ll n;
vector<edge> g[114514];
ll d[114514];
ll x[114514], y[114514];
void dijkstra(ll s) {
	prique<P, vector<P>, greater<P>>que;
	fill(d, d + n + 1, inf);
	d[s] = 0;
	que.push(P(0, s));
	while (que.size()) {
		P p = que.top(); que.pop();
		ll nv = p.second;
		if (d[nv] < p.first)continue;
		for (int i = 0; i < g[nv].size(); i++) {
			edge e = g[nv][i];
			if (d[e.to] > d[nv] + e.cost) {
				d[e.to] = d[nv] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}
signed main() {
	cin >> n;
	rep(i, n - 1) {
		ll a, b, c;
		cin >> a >> b >> c;
		g[a].push_back({ b,c });
		g[b].push_back({ a,c });
	}
	ll q, k;
	cin >> q >> k;
	dijkstra(k);
	rep(i, q)cin >> x[i] >> y[i];
	rep(i, q)cout << d[x[i]] + d[y[i]] << endl;
	ggr
}

Measured memory_bytes: 12032
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

// solution 
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input! {
        N: usize,
        M: usize,
        ship: [(usize, usize); M],
    }

    let mut tochu = vec![false; N+1];
    for &(a, b) in ship.iter() {
        if a == 1 {
            if tochu[b] {
                println!("POSSIBLE");
                return
            } else {
                tochu[b] = true;
            }
        } else if b == N {
            if tochu[a] {
                println!("POSSIBLE");
                return
            } else {
                tochu[a] = true;
            }
        }
    }
    println!("IMPOSSIBLE");
}


Measured memory_bytes: 8444
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        long n = long.Parse(Console.ReadLine());
        var so = PrimeFactors(n).GroupBy(v => v);
        long sum = 0;
        foreach(var key in so)
        {
            sum += culcCount(key.Count());
        }
        Console.WriteLine(sum);
    }

    static long culcCount(long c)
    {
        long bef = 0;
        long val = 1;
        long count = 1;
        long plus = 2;
        while (true)
        {
            bef = val;
            val += plus;
            if (bef <= c && c < val) return count;
            plus++;
            count++;
        }
    }


    public static IEnumerable<long> PrimeFactors(long n)
    {
        long i = 2;
        long tmp = n;

        while (i * i <= n) //※1
        {
            if (tmp % i == 0)
            {
                tmp /= i;
                yield return i;
            }
            else
            {
                i++;
            }
        }
        if (tmp != 1) yield return tmp;//最後の素数も返す
    }


}




Measured memory_bytes: 18664
#include <cstring>
#include <cstdlib>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define ABS(a) ((a)<0?(-(a)):(a))
#define CS while(cases())
#define I(n) int n = gi()
#define II(n) n = gi()
#define L(n) ll n = gli()
#define LL(n) n = gli()
#define F(i, n) for (int i = 0; i < n; i++)
#define Fa(n, a) for (int i = 0; i < n; i++) a[i] = gi()
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

template<class T>
T gcd(T a, T b) {
    return (b == 0 ? a : gcd(b, a%b));
}

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int cases() {
    static int t = gi();
    return t--;
}

#define M 1000000007LL
char a[1000004];
ll p25[1000004], p26[1000004], f[2000004];

/*
>>> 26**5*1*25**0
11881376
>>> 26**4*3*25**1
34273200
>>> 26**3*6*25**2
65910000
>>> 26**2*10*25**3
105625000
>>> 26**1*15*25**4
152343750
>>> 26**0*21*25**5
205078125
>>>
>>> 205078125+152343750+105625000+65910000+34273200+11881376
575111451
*/

ll pw(ll a, ll b) {
    if (b == 0)
        return 1LL;
    ll x = pw(a, b/2LL);
    x = (x*x) % M;
    if (b%2LL)
        return (x*a)%M;
    return x;
}

ll C(ll a, ll b) {
    ll r = f[a];
    r *= pw(f[b], M-2LL);
    r %= M;
    r *= pw(f[a-b], M-2LL);
    r %= M;
    return r;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n = gi();
    scanf("%s", a);
    int k = strlen(a);

    p25[0] = 1;
    p26[0] = 1;
    f[0] = 1;
    for (int i = 1; i < 2000004; i++) {
        if (i < 1000004) {
            p25[i] = (p25[i-1] * 25LL) % M;
            p26[i] = (p26[i-1] * 26LL) % M;
        }
        f[i] = (f[i-1] * ll(i)) % M;
    }

    ll s = 0;
    for (int i = 0; i <= n; i++) {
        ll a = (p25[i] * p26[n-i]) % M;
        a *= C(k-1+i, k-1);
        a %= M;
        s += a;
        s %= M;
    }

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 35884
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main p = new Main();
	}

	public Main() {
		Scanner sc = new Scanner(System.in);
		while(true){
			int w = sc.nextInt();
			int h = sc.nextInt();
			if(w==0 && h==0)
				break;
			
			boolean[][] wwall = new boolean[h][w];
			boolean[][] hwall = new boolean[h][w];
			
			for(int i=0;i<2*h-1;i++){
				if(i%2==0){
					for(int j=0;j<w-1;j++)
						wwall[i/2][j] = sc.nextInt()==1;
				}else{
					for(int j=0;j<w;j++)
						hwall[i/2][j] = sc.nextInt()==1;
				}
			}
			
			System.out.println(solve(w, h, wwall, hwall));
		}
		
	}

	final int MAX = 100000;
	int[] dx = { -1, 0, 1, 0 };
	int[] dy = { 0, -1, 0, 1 };
	public int solve(int w, int h, boolean[][] wwall, boolean[][] hwall) {
		int[][] map = new int[h][w];
		for(int i=0;i<map.length;i++)
			Arrays.fill(map[i], MAX);
		
		Queue<int[]> q = new LinkedList<int[]>();
		q.add(new int[]{0, 0, 1});
		map[0][0] = 0;
		while(!q.isEmpty()){
			int[] cur = q.poll();
			for(int i=0;i<4;i++){
				int nx = cur[0] + dx[i];
				int ny = cur[1] + dy[i];
				
				if(nx<0 || w<=nx || ny<0 || h<=ny || 
						(i%2==1 && hwall[Math.min(cur[1], ny)][nx]) ||
						(i%2==0 && wwall[ny][Math.min(cur[0], nx)]))
					continue;
				
				int nc = cur[2]+1;
				if(map[ny][nx]>nc){
					map[ny][nx] = nc;
					q.add(new int[]{nx, ny, nc});
				}
			}
		}
		
		return map[h-1][w-1]==MAX ? 0 : map[h-1][w-1];
	}

}

Measured memory_bytes: 62396
#include <bits/stdc++.h>
using namespace std;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
 
const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
 
const int MAX = 1000000;
const int MOD = 1000000007;
 
int main(){
  int n;
  cin >> n;
  vector<pii>a(n);
  rep(i, 0, n){
    cin >> a[i].first;
    a[i].second = i+1;
  }
  sort(a.begin(),a.end());
  rep(i, 0, n)cout << a[i].second << " ";
  cout << endl;
}

Measured memory_bytes: 4004
#include <stdio.h>
#include <stdlib.h>

int solve(int i, int m,int *A, int n){
  int res;
  if(m == 0){
    return 1;
  }
  if(i >= n){
    return 0;
  }
  if(solve(i + 1, m, A, n) ==1 || solve(i + 1, m - A[i], A, n)==1)
  return 1;
}

int main(){

  int n, *A, q, *m, i, j=0;

  //入力処理
  scanf("%d",&n);

  A = (int *)malloc(sizeof(int)*n);

  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);

  m = (int *)malloc(sizeof(int)*n);

  for(i=0; i<q; i++){
    scanf("%d",&m[i]);
  }

  //再起
  for(i=0; i<q; i++){
    if(solve(j, m[i], A, n)==0) printf("no\n");
       else printf("yes\n");
       }
    return 0;
  }


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

int main(){

    int a,b,c,d,e;

    cin >> a >> b >> c >> d >> e;

    if(a == 0) cout << '1' << endl;
    else if( b == 0) cout << '2' << endl; 
    else if( c == 0) cout << '3' << endl;
    else if( d == 0) cout << '4' << endl;
    else cout << '5' << endl;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int N;
vector<int> a, b, c;

int main() {
    cin >> N;
    a = c = b = vector<int>(N);
    rep(i, N) cin >> a[i] >> b[i] >> c[i];

    // 状態 (i,prev) : i 日たって，前回 prev の遊びをした状態
    // ma(i,prev) : 状態(i,prev) での幸福度の最大値

    // もらうDP
    vector<vector<int>> ma(N + 1, vector<int>(3, -1));
    ma[0][0] = ma[0][1] = ma[0][2] = 0;

    for (int i = 1; i <= N; i++) {
        for (int prev = 0; prev < 3; prev++) {
            if (prev == 0) {
                ma[i][prev] = max(ma[i][prev], ma[i - 1][1] + a[i - 1]);
                ma[i][prev] = max(ma[i][prev], ma[i - 1][2] + a[i - 1]);
            }
            if (prev == 1) {
                ma[i][prev] = max(ma[i][prev], ma[i - 1][0] + b[i - 1]);
                ma[i][prev] = max(ma[i][prev], ma[i - 1][2] + b[i - 1]);
            }
            if (prev == 2) {
                ma[i][prev] = max(ma[i][prev], ma[i - 1][0] + c[i - 1]);
                ma[i][prev] = max(ma[i][prev], ma[i - 1][1] + c[i - 1]);
            }
        }
    }

    cout << max(ma[N][0], max(ma[N][1], ma[N][2])) << endl;

    // ddump(ma);
    return 0;
}

Measured memory_bytes: 9844
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
ll MOD = 1000000007;

bool compare(pii& lhs, pii& rhs) {
  if (lhs.first < rhs.first)
    return true;
  else if (lhs.first == rhs.first)
    return lhs.second < rhs.second;
  return false;
}

int main() {
  //
  int N;
  cin >> N;
  vl A(N);
  rep(i, N) {
    int a;
    cin >> a;
    A[i] = a - (i + 1);
  }
  sort(ALL(A));
  int x = A[N / 2];
  ll ans = 0;
  rep(i, N) { ans += abs(A[i] - x); }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
using namespace std; 
 
const int N = 3e5 + 100, OO = 1e9, M = 998244353, P = 6151, SQ = 120, lg = 22;
typedef pair <int, int> pii;

pair<int, int> p[N];
map<int, int> mp;
vector<int> v;
bool cmp(pair<int, int> p1, pair<int, int> p2) {
    return p1.ss<p2.ss;
}
int fac[N], inv[N];
 
int pw(int x, int y) {
	if(y == 0)
		return 1;
	int cnt = pw(x, y / 2);
	cnt = (cnt * cnt) % M;
	cnt = (cnt * (y % 2 == 1 ? x : 1)) % M;
	return cnt;
}
 
void prepro() {
	fac[0] = 1;
	for(int i = 1; i <= N - lg; i++) 
		fac[i] = (fac[i - 1] * i) % M;
	inv[N - lg] = pw(fac[N - lg], M - 2);
	for(int i = N - lg - 1; i > -1; i--) 
		inv[i] = (inv[i + 1] * (i + 1)) % M;
}
 
int c(int x, int y) {
	return ((fac[x] * inv[y] % M) * inv[x - y]) % M;
}

int32_t main() {
    use_fast;
	prepro();
int k = 0;
for(int i = 0; i < N; i++) {
	k += i;
	k %= N;
}
k/= 1001293;
for(int i = 0; i < 10; i++) {
	for(int j = 0; j < 10; j++) {
		k += 1011;
		k %= N;
	}
}
k /= 10;
for(int i = 0; i < 10100; i++)
	k = (k + 1) % 101000;
k /= 100;
k = 0;
   int n;
    cin >> n;
    for(int i = 0 ; i <n ; i++ ) {
        int x, b;
        cin >> x >> b;
        p[i].ff=x-b;
        p[i].ss=x+b;
        v.pb(x-b);
        v.pb(x+b);
    }
    int o=0;
    sort(v.begin(),v.end());
    for(int u: v) {
        mp[u]=o;
        o++;
    }
    for(int i = 0 ; i < n ; i++ ) {
        p[i].ff=mp[p[i].ff];
        p[i].ss=mp[p[i].ss];
    }
    sort(p, p + n, cmp);
    int ans = 0, mxr = 0;
    for(int i = 0 ; i < n ; i++ ) {
        if(i==0) {
            ans++;
            mxr = p[i].ss;
        }
        else {
            if(p[i].ff < mxr) 
				continue;
            mxr = p[i].ss;
            ans++;
        }
    }
    cout << ans;
 	return 0; 
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/	

Measured memory_bytes: 23920
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
int main()
{
  int n,i,j,k,p2,p5;
  int c[19][19];
  ll a,t,res=0;
  string s;
  cin >> n;
  for(i=0;i<19;i++)
    fill(c[i],c[i]+19,0);
  for(i=0;i<n;i++){
    cin >> s;
    for(j=0;j<s.size();j++)
      if(s[j]=='.')
        break;
    a=stoi(s.substr(0,j))*1e9;
    if(j<s.size()-1){
      t=stoi(s.substr(j+1));
      for(k=s.size();k<j+10;k++)
        t*=10;
      a+=t;
    }
    p2=0;
    while(a%2==0&&p2<18){
      a/=2;
      p2++;
    }
    p5=0;
    while(a%5==0&&p5<18){
      a/=5;
      p5++;
    }
    for(j=18-p2;j<19;j++)
      for(k=18-p5;k<19;k++)
        res+=c[j][k];
    c[p2][p5]++;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll sum=0;
    for(int i=1;i<=n;i++){
    	if(i%3&&i%5)sum+=i;
    }
    cout << sum <<endl;
    return 0;
}


Measured memory_bytes: 3656
#include<cstdio>
int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if (a<b){
		if(b<c){
			printf("Yes\n");
		}else if (b>=c){
			printf("No\n");
		}
	}else if (a>=b){
		printf("No\n");
	}
	return 0;
}


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

int main() {
	char S[100];
	long long int K, i, len;

	scanf("%s", S);
	scanf("%lld", &K);

	len = strlen(S);
	for (i = 0; i < len; i++) {
		if (S[i] != '1') {
			break;
		}
	}

	if (i == len || i > K - 1) {
		printf("1");
	}
	else {
		printf("%c", S[i]);
	}

	return 0;
}

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

typedef long long ll;
using namespace std;
ll X, Y, Z, K;
ll A[4000], B[4000], C[4000];
ll x[1000000], y[3000000];

int main() {
    cin >> X >> Y >> Z >> K;
    for (int i = 0; i < X; i++) {
        cin >> A[i];
        A[i] = -A[i];
    }
    for (int i = 0; i < Y; i++) {
        cin >> B[i];
        B[i] = -B[i];
    }
    for (int i = 0; i < Z; i++) {
        cin >> C[i];
        C[i] = -C[i];
    }
    int k = 0;
    for (int i = 0; i < X; i++) {
        for (int j = 0; j < Y; j++) {
            x[k++] = A[i] + B[j];
        }
    }
    sort(x, x + k);
    int kk = 0;
    for (int i = 0, l = min(k, 3000); i < l; i++) {
        for (int j = 0; j < Z; j++) {
            y[kk++] = x[i] + C[j];
        }
    }
    sort(y, y + kk);
    for (int i = 0; i < K; i++) {
        cout << -y[i] << endl;
    }
}

Measured memory_bytes: 31616
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int fiveHundred = Integer.parseInt(scanner.nextLine());
        int hundred = Integer.parseInt(scanner.nextLine());
        int fifty = Integer.parseInt(scanner.nextLine());
        int money = Integer.parseInt(scanner.nextLine());

        if (money % 100 == 50) {
            if (fifty == 0) {
                System.out.println(0);
                System.exit(0);
            }
            fifty -= 1;
            money -= 50;
        }

        int total = 0;
        for (int i = Math.min(fiveHundred, Math.floorDiv(money, 500)); i >= 0; i--) {
            total += countUp(money - (500 * i), hundred, fifty);
        }
        System.out.println(total);
    }

    public static int countUp(int sum, int hundred, int fifty) {
        int c = 0;
        for (int i = Math.min(hundred, sum / 100); i >= 0; i--) {
            if ((sum - (i * 100)) <= (fifty * 50)) {
                c++;
            }
        }
        return c;
    }
}

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

int main() {

    int a, b;

    while (cin >> a >> b) {
        int n = 1;
        for(int i = 0; ; i++) {
            if (a + b < n)  {
                cout << i << endl;
                break;
            }
            n = n * 10;
        }
    }
     
    return 0;

}

Measured memory_bytes: 0
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
using namespace std;
typedef long long int lli;
int main(void)
{
    int N, M;
    cin >> N >> M;
    string s;
    int tmp1, tmp2;
    vector<int> x, y;
    for (int i = 0; i < M; i++)
    {
        cin >> tmp1 >> tmp2;
        x.push_back(tmp1);
        y.push_back(tmp2);
    }
    if (M > 0)
    {
        for (int i = 0; i < 1000; i++)
        {
            s = to_string(i);
            for (int k = 0; k < M; k++)
            {
                if (s[x[k] - 1] - '0' == y[k])
                {
                    /*if (k == M - 1 && (int)(log10(i) + 1) == N)
                {
                    cout << i << endl;
                    return 0;
                }*/
                    if ((N == 3 && s[0] - '0' != 0 && (int)(log10(i) + 1) == N && k == M - 1) || (N == 2 && k == M - 1 && (int)(log10(i) + 1) == N) || (N == 1 && k == M - 1))
                    {
                        cout << i << endl;
                        return 0;
                    }
                }
                else
                {
                    break;
                }
            }
        }
    }
    else
    {
        if (N == 1)
        {
            cout << 0 << endl;
            return 0;
        }
        else if (N == 2)
        {
            cout << 10 << endl;
            return 0;
        }
        else
        {
            cout << 100 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

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

long long N, t[100100], x[100100], y[100100], dt, dx, dy;
bool valid=true;

int main() {
    cin >> N;
	for (int i=1; i<=N; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }
    for (int i=1; i<=N; i++){
        dt = t[i]-t[i-1];
        dx = abs(x[i]-x[i-1]);
        dy = abs(y[i]-y[i-1]);
        
        if (((dx+dy-dt)%2==0) && (dt>=dx+dy)){
            valid = true;
        }
        else{
            valid=false;
            break;
        }
    }
    if (valid == true){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 5872
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

static const int N = 1000;

static int lcs(string& s1, string& s2) {
    int table[N + 1][N + 1];

    int m = s1.size();
    int n = s2.size();

    int max_len = 0;

    s1 = ' ' + s1;
    s2 = ' ' + s2;

    for (int i = 0; i <= m; i++) table[i][0] = 0;
    for (int j = 0; j <= m; j++) table[0][j] = 0;

    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            if (s1[i] == s2[j]) {
                table[i][j] = table[i - 1][j - 1] + 1;
            } else {
                table[i][j] = max(table[i - 1][j], table[i][j - 1]);
            }

            max_len = max(table[i][j], max_len);
        }
    }

    return max_len;
}

int main() {
    int n;

    cin >> n;

    for (int i = 0; i < n; i++) {
        string s1, s2;

        cin >> s1 >> s2;

        cout << lcs(s1, s2) << endl;
    }

    return 0;
}

Measured memory_bytes: 7064
#include<bits/stdc++.h>
#define ll long long
#define mod7 1000000007
using namespace std;

void myfunc() {
    int n;
    cin >> n;
    vector<pair<int,int>> d(n, pair<int,int>(0,0));
    int a,b;
    for(int i=0;i<n;i++)
    {
		cin >> d[i].first >> d[i].second;
	}
	int flag=0;
	for(int i=2;i<n;i++) {
		if(d[i].first==d[i].second && d[i-1].first==d[i-1].second 
		&& d[i-2].first==d[i-2].second) {
		flag=1;
		break;
	}
	}
	if(flag)
	cout << "Yes" << endl;
	else
	cout <<  "No" << endl;
}

int main() {
    long t;
    t=1;
    //cin >> t;
    while(t--)
    myfunc();
    return 0;
}


Measured memory_bytes: 3628
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	int n;
	int u,k,v;
	//n---頂点数
	//u---頂点の番号
	//k---uの出次数
	//v---uに隣接する頂点の番号
	
	int[][] list;
	
	public void input() {
		n = sc.nextInt();
		list = new int[n][n];
		for(int i=0; i<n; i++) {
			u = sc.nextInt();
			k = sc.nextInt();
			while(k > 0) {
				v = sc.nextInt();
				list[u-1][v-1] = 1;
				k--;
			}
		}
	}
	
	public void output() {
		for(int i=0; i<n; i++) {
			for(int j=0; j<n; j++) {
				if(j==n-1) System.out.print(list[i][j]+"\n");
				else System.out.print(list[i][j]+" ");
			}
		}
	}
	
	public static void main(String[] args) {
		Main obj = new Main();
		obj.input();
		obj.output();
	}
}



Measured memory_bytes: 35512
from enum import Enum
from queue import Queue
import collections

import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

N = int(input())

digit_num = len(str(N))

ans = 0

if digit_num % 2 !=0:
    ans += N-10**(digit_num-1)+1

for i in reversed(range(1,digit_num)):
    if i % 2 != 0:
        ans += 9*(10**(i-1))

print(ans)


Measured memory_bytes: 4328
#include <iostream>

using namespace std;

int main()
{
    int w=0,p=0,y=0,g=0;
    int n;
    cin>>n;
    char a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        switch(a[i]){
            case 'W':if(w==0){w+=1;}
        break;
            case 'P':if(p==0){p+=1;}
        break;
            case 'G':if(g==0){g+=1;}
        break;
            case 'Y':if(y==0){y+=1;}
        break;}
    }
    switch(w+p+g+y){
        case 1:cout<<"One";
        break;
        case 2:cout<<"Two";
        break;
        case 3:cout<<"Three";
        break;
        case 4:cout<<"Four";
        break;}
    return 0;
}


Measured memory_bytes: 256
def calc(W, H):
    ans = float("inf")
    for w in range(1, W//2+1):
        x = w * H
        w_ = W - w
        if w_ % 2 == 0 or H % 2 == 0:
            y = (w_*H)//2
            li = sorted([x, y, y])
        else:
            if w_ < H:
                a, b = w_, H
            else:
                a, b = H, w_
            y = a * (b//2)
            z = a * (b-b//2)
            li = sorted([x,y,z])
        ans = min(ans, li[2] - li[0])
    return ans



def main():
    import sys
    input = sys.stdin.readline
    w, h = map(int, input().split())
    ans = calc(w,h)
    ans = min(calc(h,w), ans)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 41836
#include <bits/stdc++.h>
using namespace std;
int dp[100010];
int main(void)
{
	string x;
	cin>>x;
	dp[0]=1;
	string y;
	for(int i=0;i<x.length();i++)
	{
		y=x.substr(i,5);
		if(y=="dream")
		{
			if(dp[i]==1)
			{
				dp[i+5]=1;
			}
		}	
		y=x.substr(i,7);
		if(y=="dreamer")
		{
			if(dp[i]==1)
			{
				dp[i+7]=1;
			}
		}
		y=x.substr(i,5);
		if(y=="erase")
		{
			if(dp[i]==1)
			{
				dp[i+5]=1;
			}
		}
		y=x.substr(i,6);
		if(y=="eraser")
		{
			if(dp[i]==1)
			{
				dp[i+6]=1;
			}
		}	
	}	
	if(dp[x.size()]==1)
	{
		cout <<"YES"<<endl;
	}
	else
	{
		cout <<"NO"<<endl; 
	}
	return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

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

        char b = sc.next().charAt(0);

        System.out.println(solve(b));

        sc.close();
    }

    static char solve(char b) {
        if (b == 'A') {
            return 'T';
        } else if (b == 'T') {
            return 'A';
        } else if (b == 'C') {
            return 'G';
        } else {
            return 'C';
        }
    }
}

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

int main() {
    int p, q, r;
    cin >> p >> q >> r;

    int ans = 1e9;
    ans = min(p+q,ans);
    ans = min(q+r,ans);
    ans = min(r+p,ans);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
using namespace std;
const int maxn=200001;
const int INF=1e8;
typedef pair<int,int> pii;
#define x first
#define y second
#define mp make_pair

map<int,vector<int> > a[maxn];
map<int,int> pt[maxn];
vector<pii> path[maxn*4];
int dist[maxn*4];
set<pii> s;
bool vis[maxn*4];
int n,m,p,q,c,tot,ori[maxn];

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d%d",&p,&q,&c);
		a[p][c].push_back(q);
		a[q][c].push_back(p);
	}
	
	tot=0;
	for(int i=1;i<=n;i++)
	{
		ori[i]=++tot;
		for(map<int,vector<int> >::iterator ii=a[i].begin();
			ii!=a[i].end();ii++)
		{
			pt[i][ii->first]=++tot;
			path[ori[i]].push_back(mp(tot,1));
			path[tot].push_back(mp(ori[i],1));
			
			for(int j=0;j<ii->second.size();j++)
				{
					int tmp=ii->second[j];
					if (tmp>i) continue;
					path[tot].push_back(mp(pt[tmp][ii->first],0));
					path[pt[tmp][ii->first]].push_back(mp(tot,0));
				}
		}
	}
	
	for(int i=1;i<=tot;i++) dist[i]=INF;
	dist[ori[1]]=0;vis[ori[1]]=true;
	s.insert(mp(0,ori[1]));
	
	while(!s.empty())
	{
		pii cur=*s.begin();
		s.erase(s.begin());
		
		int pos=cur.y,len=cur.x;
		for(int i=0;i<path[pos].size();i++)
		{
			int tmp=path[pos][i].x;
			if (!vis[tmp])
			{
				vis[tmp]=true;
				dist[tmp]=len+path[pos][i].y;
				s.insert(mp(dist[tmp],tmp));
			}
			else if (dist[tmp]>len+path[pos][i].y)
			{
				s.erase(s.find(mp(dist[tmp],tmp)));
				dist[tmp]=len+path[pos][i].y;
				s.insert(mp(dist[tmp],tmp));
			}
		}
	}
	
	if (dist[ori[n]]==INF) printf("%d\n",-1);
	else printf("%d\n",dist[ori[n]]/2);
	return 0;
}

Measured memory_bytes: 127360
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
  	cin >> n;
  	int sum = 0;
  	int a[n];
  	for(int i = 0 ; i < n ; i++)
    {
		cin >> a[i];
      	sum += a[i];
    }
  	int mm = 9999999;
  	int cur = 0;
  	for(int i = 0 ; i < n - 1  ; i++){
      	cur += a[i];
		mm = min(mm , abs(sum-2*cur));
    }
  	cout << mm << endl;
 	return 0;
}

Measured memory_bytes: 256
import sys

N, M = map(int, input().split())
if N >= M:
    print(0)
    sys.exit(0)

X = list(map(int, input().split()))
X.sort()

distance_list = []
for i in range(M-1):
    distance_list.append(X[i+1] - X[i])

distance_list.sort(reverse=True)
print(X[-1] - X[0] - sum(distance_list[:N-1]))


Measured memory_bytes: 13968
bingonum=[[0,0,0],[0,0,0],[0,0,0]]
bingo=[["False","False","False"],["False","False","False"],["False","False","False"]]
for i in range(3):
    bingonum[i][0],bingonum[i][1],bingonum[i][2] = map(int,input().split())
N = int(input())
b=[]
for _ in range(N):
    b.append(int(input()))
for x in range(N):
    for i in range(3):
        for j in range(3):
            if bingonum[i][j]==b[x]:
                bingo[i][j]="True"
IsBingo = "No"
for i in range(3):
    if bingo[i][0]=="True" and bingo[i][1]=="True" and bingo[i][2]=="True":
        IsBingo="Yes"
    if bingo[0][i]=="True" and bingo[1][i]=="True" and bingo[2][i]=="True":
        IsBingo="Yes"
if (bingo[0][0]=="True" and bingo[1][1]=="True" and bingo[2][2]=="True") or (bingo[0][2]=="True" and bingo[1][1]=="True" and bingo[2][0]=="True"):
    IsBingo="Yes"
print(IsBingo)


Measured memory_bytes: 3064
#include<bits/stdc++.h> 
using namespace std;
typedef long long int ll;
#define MOD 1000000007
#define fo(i,k,n) for(i=k;i<=n;i++)
#define endl '\n'
void solve(){
	ll i,j,n;
	cin>>n;
	ll h[n];
	fo(i,0,n-1) cin>>h[i];
	ll dp[n];
	dp[0]=0;
	dp[1]=dp[0]+abs(h[1]-h[0]);
	fo(i,2,n-1){
		ll op1 = dp[i-1] + abs(h[i]-h[i-1]);
		ll op2 = dp[i-2] + abs(h[i]-h[i-2]);
		dp[i] = min(op1,op2);
	}
	cout<<dp[n-1]<<endl;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll t;
	t=1;//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 1792