akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;

const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int n;
bool vis[N];
int col[N];
const int M = 2e5+5;
vector<pair<int,int>>adj[M];
void dfs(int parent ,int cur,int color){
    if(vis[cur])return;
    vis[cur]=1;
    col[cur]=color;
    for(int i=0;i<adj[cur].size();i++){
        auto node = adj[cur][i];
        if(node.first==parent)continue;
        dfs(cur,node.first,color^node.second);
    }
}
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    scanf("%d",&n);
    for(int i=1;i<n;i++){
        int from,to,w;
        scanf("%d%d%d",&from,&to,&w);
        adj[from].push_back({to,w%2});
        adj[to].push_back({from,w%2});
    }
    dfs(-1,1,0);
    for(int i=1;i<=n;i++){
        printf("%d\n",col[i]);
    }
    return 0;
}

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

using namespace std;

int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    int dp[n+2];
    memset(dp,0,sizeof(dp));
    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    //cout<<"dp[1] is "<<dp[1]<<endl;
    for(int i=2;i<n;i++)
    {
        int r=i-k;
        if(r<=0)
        r=0;
        int miny=INT_MAX;
        for(int j=r;j<i;j++)
        {
            if(dp[j]+abs(a[j]-a[i]) < miny)
            miny=dp[j]+abs(a[j]-a[i]);
        }
        dp[i]=miny;
    }
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define MOD 1000000007
typedef long long ll;

int main(){
	ll h, w;
	scanf("%lld%lld", &h, &w);
	if(h == 1 || w == 1){
		printf("1");
		return 0;
	}
	if(w % 2 == 0 || h % 2 == 0){
		printf("%lld", h * w / 2);
		return 0;
	}
	printf("%lld", h * w / 2 + 1);
	return 0;
}


Measured memory_bytes: 128
use std::io;
use std::cmp;

// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}


fn main() {
    let n_a_b = read_t_in_line::<i32>();
    let (n, a, b) = (n_a_b[0], n_a_b[1], n_a_b[2]);
    println!("{}", min::<i32>(n * a, b));
}


Measured memory_bytes: 4352
function Main(input) {
    var N = parseInt(input[0], 10);
    var A = parseInt(input[1], 10);
    var B = parseInt(input[2], 10);

    var C = N * A;

    console.log(C < B ? C : B);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 22076
#include <bits/stdc++.h> 
#define pb push_back
#define sp " "
#define sl "\n"
#define fi first
#define se second
#define mp make_pair
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define rev(a) reverse(a.begin(),a.end())
#define PI 3.141592

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int N=1005,mod=1000000007;
int a,b;
int main() { 
	cin.tie(0); cout.tie(0); 
	ios_base::sync_with_stdio();
	cin>>a>>b;
	cout<<a*b;
	return 0;
}
// Recuerda limites 
// Recuerda casos especiales


Measured memory_bytes: 3624
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush
from fractions import gcd

def solve():
    a, b = MI()

    g = gcd(a, b)

    def prime_factorization(n):
        res = []
        for i in range(2, int(pow(n, 0.5))+1):
            if n % i: continue
            ex = 0
            while n % i == 0:
                n = n // i
                ex += 1
            res.append((i, ex))
        if n != 1:
            res.append((n, 1))
        return res

    fact = prime_factorization(g)
    print(len(fact) + 1)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 5300
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };

template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};
const int mod = 1e9+7;
using modint = ModInt< mod >;

int N,K;
void input(){
    fast_io();
    cin >> N >> K;
}

vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int solve(){
	vector<int> div;
	for (int i = 1; i*i <= N; i++)
	{
		div.push_back(i);
		if(i*i!=N) div.push_back(N/i);
	}
	sort(div.begin(),div.end());
	int S = div.size();
	// S = sqrt(N)
	vector<vector<modint>> dp(K+1,vector<modint>(S,0));
	dp[0][0] = 1;
	for (int i = 0; i < K; i++)
	{
		for (int t = S-1; t>=0; t--)
		{
			dp[i+1][t] += dp[i][S-1-t];
		}
		for (int t = S-1; t>0; t--)
		{
			dp[i+1][t-1] += dp[i+1][t];
			dp[i+1][t] *= (div[t]-div[t-1]);
		}
	}
	modint ans = 0;
	for (int i = 0; i < S; i++) ans += dp[K][i];
	cout << ans << "\n";
    return 0;
}

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

Measured memory_bytes: 28936
s=gets.strip.reverse
strs=['dream','dreamer','erase','eraser']
flag=true
end_flag=true
while flag do
    end_flag=true
    strs.each do |n| 

        if s[0..n.length-1]==n.reverse
            s.slice!(0..n.length-1)

            end_flag=false
            break
        end
    end
    if end_flag
        flag=false
    end
end
puts s.empty? ? 'YES': 'NO'

Measured memory_bytes: 82764
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){
	int a,b,c,d,x,y,n;
	while(cin>>a>>b>>c,a){
		x=a*a+b*b;
		if(b*b+c*c<x)x=b*b+c*c;
		if(c*c+a*a<x)x=c*c+a*a;
		cin>>n;
		for(int i=0;i<n;i++){
			cin>>y;
			if(x<y*y*4)cout<<"OK"<<endl;
			else cout<<"NA"<<endl;
		}
	}
}

Measured memory_bytes: 0
n = int(input())
a = list(map(int, input().split()))
mod = 1000000007
res = 0
a_sum = sum(a)

for i in range(n - 1):
    main = a[i]
    a_sum = a_sum - main
    res =  (res + main * a_sum % mod) % mod
print(res)

Measured memory_bytes: 31592
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define all(a)  (a).begin(),(a).end()
#define elif else if

signed main(){
  int n;
  cin>>n;
  V<int> a(n);
  fo(i,n){
    cin>>a[i];
  }
  Sort(a);
  int ans=0;
  for(int i=0; i<n; i=i){
    int b=a[i];
    int c=0;
    while(i<n){
      if(b==a[i])
        c++;
      else
        break;
      i++;
    }
    if(c%2==1)
      ans++;
  }
  cout<<ans<<endl;
}

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

int main(){
  int N;
  vector<int> V;
  vector<int> C;
  
  cin>>N;
  for(int i=0;i<N;i++){
    int x;
    cin>>x;
    V.push_back(x);
  }
  
  for(int i=0;i<N;i++){
    int x;
    cin>>x;
    C.push_back(x);
  }
  
  int answer;
  for(int i=0;i<N;i++){
    if(V.at(i)>C.at(i)) answer+=(V.at(i)-C.at(i));
  }
  
  cout<<answer<<endl;
}



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

long long solve(long long a, long long b) {
    if(a > b) swap(a, b);
    if(a == 0) return -b;
    else return 2LL * a * (b / a) + solve(a, b % a);
}

int main() {
    long long N, X;
    cin >> N >> X;
    cout << N + solve(X, N - X) << endl;
}

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

set<int> st[26];

int main() {
	int n; string s; cin >> n >> s;
	for (int i = 1; i <= n; i++)
		st[s[i - 1] - 'a'].insert(i);
	int q; cin >> q;
	for (int i = 0; i < q; i++) {
		int op; cin >> op;
		if (op == 1) {
			int j; char c; cin >> j >> c;
			st[s[j - 1] - 'a'].erase(j);
			st[c - 'a'].insert(j);
			s[j - 1] = c;
		} else {
			int l, r; cin >> l >> r;
			int ans = 0;
			for (int j = 0; j < 26; j++) {
				auto it = st[j].lower_bound(l);
				if (it != st[j].end() and *it <= r)
					++ans;
			}
			cout << ans << "\n";
		}
	}
}

Measured memory_bytes: 26244
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 1000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

int n, m;

int modmul(int x, int y) {
    return x*y%mod;
}

signed main(void) {
    cin>>n>>m;
    int xsum=0, ysum=0;
    REP(i, 1, n) {
        int x; cin>>x;
        xsum+=((i-1)-(n-i))*x;
        xsum%=mod;
    }
    REP(i, 1, m) {
        int x; cin>>x;
        ysum+=((i-1)-(m-i))*x;
        ysum%=mod;
    }
    
    cout << modmul(xsum,ysum) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ld,ll> P;
vector<ll> node[605],dnode[605];
ll edge_size[605]={0};
vector<P> cos[605];
bool used[605];
ld first_solve(ll n){
  vector<ld> dist(605,0);
  for(int pos=n;pos>=1;pos--){
    for(int i=0;i<node[pos].size();i++){
      ll to=node[pos][i];
      ld now_cos=dist[pos]+1;
      now_cos/=(ld)edge_size[to];
      cos[to].push_back(P(now_cos,pos));
      dist[to]+=now_cos;
    }
  }
  return dist[1];
}
ld second_solve(ll n){
  vector<ld> dist(605,0);
  for(int pos=n;pos>=1;pos--){
    for(int i=0;i<node[pos].size();i++){
      ll to=node[pos][i];
      if(to==-1) continue;
      ld now_cos=dist[pos]+1;
      now_cos/=(ld)edge_size[to];
      dist[to]+=now_cos;
    }
  }
  return dist[1];
}
void dfs(ll pos){
  used[pos]=true;
  for(int i=0;i<dnode[pos].size();i++){
    ll to=dnode[pos][i];
    if(to==-1) continue;
    if(!used[to]){
      used[to]=true;
      dfs(to);
    }
  }
}
int main(){
  ll n,m;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    ll s,t;
    cin>>s>>t;
    node[t].push_back(s);
    dnode[s].push_back(t);
    edge_size[s]++;
  }
  ld ans=first_solve(n);
  for(int i=1;i<=n;i++) used[i]=false;
  dfs(1);
  cout<<fixed;
  for(int i=1;i<n;i++){
    sort(cos[i].rbegin(),cos[i].rend());
    ll cut_edge=cos[i][0].second;
    if(used[i]&&edge_size[i]==1) continue;
    for(int j=0;j<node[cut_edge].size();j++){
      if(node[cut_edge][j]==i){
        node[cut_edge][j]=-1;
        edge_size[i]--;
        ans=min(ans,second_solve(n));
        node[cut_edge][j]=i;
        edge_size[i]++;
      }
    }
  }
  cout<<setprecision(10)<<ans<<endl;
}


Measured memory_bytes: 14336
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[10005]={};
  for(int i=1;i<=100;i++){
    for(int j=1;j<=100;j++){
       for(int k=1;k<=100;k++){
         int l=pow(i,2)+pow(j,2)+pow(k,2)+i*j+j*k+k*i;
         if(l<10001) a[l]++;
       }
    }
  }
  for(int i=1;i<=n;i++) cout<<a[i]<<endl;
  return 0;
}


Measured memory_bytes: 3556
#include <stdio.h>

int main(){
  int n,k;
  scanf("%d%d",&n,&k);
  int d[2000];
  int i;
  for(i=0; i<=1000; ++i) d[i]=0;
  for(i=0; i<n; ++i){
    int a;
    scanf("%d",&a);
    d[a]++;
  }
  
  int ans=0, t=0;
  
  for(i=0; t<k;){
    if(d[i]==0) i++;
    else {
      d[i]--;
      ans += i;
      t++;
    }
  }
  
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 1716
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
import bisect #bisect.bisect_left(B, a)
from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

class Segtree: #1-indexed
    def __init__(self, n, A, segfunc, ide_ele):
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n-1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        #　配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = A[i]
        for i in range(self.num-1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2*i], self.tree[2*i+1])
        
    def update(self, ind, val): #0-indexed
        ind += self.num
        self.tree[ind] = val
        while ind > 1:
            self.tree[ind >> 1] = self.segfunc(self.tree[ind], self.tree[ind^1])
            ind >>= 1

    def find(self, l, r): #[1, r), 0-indexed
        res = self.ide_ele
        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

N = ii()
A = [ii() for i in range(N)]
compress = lambda arr: list(map({e: i for i, e in enumerate(sorted(set(arr)))}.__getitem__, arr))
A = compress(A)
'''
# 座標圧縮
d = defaultdict(int)
for i, num in enumerate(sorted(list(set(A)))):
    d[num] = i
for i, num in enumerate(A):
    A[i] = d[num]
'''
# Segtreeを用いたDP
dp = [0 for _ in range(N)]
seg = Segtree(N, dp, max, 0)

for num in A:
    dp[num] = seg.find(0, num) + 1
    seg.update(num, dp[num])

print(max(dp))
    


Measured memory_bytes: 24012
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

pub struct Graph {
    graph: Vec<Vec<usize>>,
    v: usize,
}

type Edge = (usize, usize);
impl Graph {
    pub fn new_directed(edges: &[Edge], v: usize) -> Self {
        let mut graph = vec![Vec::new(); v];
        for &(u, v) in edges {
            graph[u].push(v);
        }
        Graph { graph, v }
    }

    pub fn solve(&self, mut indegreev: Vec<usize>) -> isize {
        let mut res = 0;
        let mut que = VecDeque::new();
        for u in 0..self.v {
            if indegreev[u] == 0 {
                que.push_back(u);
            }
        }
        loop {
            if que.len() == 0 {
                break;
            }
            res += 1;
            que = self.next_que(que, &mut indegreev);
        }
        let is_ok = indegreev.into_iter().all(|x| x == 0);
        if is_ok {
            res as isize
        } else {
            -1
        }
    }

    fn next_que(&self, mut que: VecDeque<usize>, indegreev: &mut Vec<usize>) -> VecDeque<usize> {
        let mut res = VecDeque::new();
        while let Some(u) = que.pop_front() {
            for &v in &self.graph[u] {
                indegreev[v] -= 1;
                if indegreev[v] == 0 {
                    res.push_back(v);
                }
            }
        }
        res
    }
}

fn solve() {
    input! {
        n: usize,
        matchv: [[Usize1; n - 1]; n]
    };

    let vn = n * (n - 1) / 2;
    let mut indegreev = vec![0; vn];
    let mut edges = Vec::new();
    let mut id_table: HashMap<(usize, usize), usize> = HashMap::new();
    let mut cur_id = 0;
    for i in 0..n {
        let a = i;
        for mv in matchv[i].windows(2) {
            let b = mv[0];
            let key = (a.min(b), a.max(b));
            let u = match id_table.get(&key) {
                Some(id) => *id,
                None => {
                    let id = cur_id;
                    id_table.insert(key, id);
                    cur_id += 1;
                    id
                }
            };
            let c = mv[1];
            let key = (a.min(c), a.max(c));
            let v = match id_table.get(&key) {
                Some(id) => *id,
                None => {
                    let id = cur_id;
                    id_table.insert(key, id);
                    cur_id += 1;
                    id
                }
            };
            indegreev[v] += 1;
            edges.push((u, v));
        }
    }

    let graph = Graph::new_directed(&edges, vn);
    let res = graph.solve(indegreev);
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 84940
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define MAX ((ll)(1e17+100))
#define MX ((ll)(1e5+100))
#define ARRS ((ll)(1e6+100))
#define ARS ((ll)(1e3+100))
#define HS ((ll)(233))
#define MOD ((ll)(1e9+7))
#define EP ((double)(1e-9))
#define LG 21
using namespace std;

int main(){
	ios::sync_with_stdio(0);
 	ll n;
	vector<ll> v;
	cin>>n;
	ll c=0,l=-1,k=0;
	for(int i=0; i<n; i++){
		cin>>k;
		if(k==l)c++;
		else v.pb(c),c=1;
		l=k;
	}
	ll pas=0;
	v.pb(c);
	for(auto x:v){
		pas+=x/2;
	}
	cout<<pas;  


}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T binarysearch(vector<T> A, T key) {
	ll left = 0;ll right = 4;ll mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)//階乗
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

template<typename T>
T keta(T a) {
	ll kazu = 1;
	while (1) {
		if (a / 10 != 0) { a /= 10;kazu++; }
		else break;
	}
	return kazu;
}//桁数


template<typename T>
T nCr(ll n, T r) {
	ll ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/

int main() {
	ll X;cin >> X;
	bool ok = false;
	ll a[120];
	for (ll i = 0;i <= 120;i++) {
		a[i] = i*i*i*i*i;
	}
	//for (int i = 0;i < 120; i++)cout << a[i] << endl;
	for (ll i = 0;i<120;i++) {
		for (ll j = i;j<120;j++) {
			if (a[j]+a[i]==X) {
				cout << j << " " << -i << endl;
				ok = true;
				break;
			}
			if (a[j]-a[i]==X) {
				cout << j << " " << i << endl;
				ok = true;
				break;
			}
		}
		if (ok) break;
	}
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

// chmax, chmin
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;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long X)
{
  LL cur = 100;
  int i = 0;
  for (i = 0; cur < X; i++)
  {
    cur += cur / 100;
  }
  cout << i << endl;
}

int main()
{
  cout << setprecision(10);
  long long X;
  scanf("%lld", &X);
  solve(X);
  return 0;
}


Measured memory_bytes: 3772
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  var line = chunk.toString().split('\n')[0].split(' ');
  var length = Number(line[0]);
  var width = Number(line[1]);
  console.log((length * width) + ' ' + (length * 2 + width * 2));
});

Measured memory_bytes: 7644
#include<stdio.h>
#include<stdlib.h>
int main()
{
    char ch[100],ch1[100];
    int i,flag=0;
    for(i=0;i<3;i++)
    {
        scanf(" %c ",&ch[i]);
    }
     for(i=0;i<3;i++)
    {
        scanf(" %c ",&ch1[i]);
    }
    for(i=0;i<3;i++)
    {
        if(ch[i]==ch1[i])
        {
            flag++;
        }
    }
    if(flag==0)
    {
        printf("0");
    }
    if(flag==1)
    {
        printf("1");
    }
    if(flag==2)
    {
        printf("2");
    }
    if(flag==3)
    {
        printf("3");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
#define inf 0x3f3f3f3f
typedef long long LL;
const int N=1e3+10;
LL c[N],w[N];
LL dp[N][N*10];
int main()
{
    ios::sync_with_stdio(0);
    int V,m;
    cin>>V>>m;

    for(int i=0; i<m; i++)
        cin>>c[i]>>w[i];
 for(int i=0;i<=m;i++)
 for(int j=0;j<=V;j++)
	dp[i][j]=inf;

    for (int i = 0; i < m; i++)
        for (int j = 1; j <= V; j++)
		{
			if(j>c[i])
				dp[i+1][j] = min( dp[i+1][j - c[i]] + w[i], dp[i][j]);
			else
				dp[i+1][j]=min(dp[i][j],w[i]);
		}


    cout<<dp[m][V]<<endl;
    return 0;
}


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

using namespace std;

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
#define repi(i, a, b)    for(int i = a; i < b; i++)
#define repd(i, a, b)    for(int i = b-1; i >= a; i--)   
#define rep(i, n)        for(int i = 0; i < n; ++i)
#define ll               long long int
#define I                iterator
#define lf               long double
#define pb               push_back
#define pq               priority_queue
#define all(c)           (c).begin(), (c).end()
#define tr(c, it)        for(auto it = c.begin(); it != c.end(); ++it)

int main(){
    int n;
    cin >> n;
    ll a = 180*n - 360;
    cout << a << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		cin >> n;
		int ans =0 ;
		fn1{
			if(i%3==0 || i%5==0){

			}
			else
				ans+=i;
		}
		cout <<ans;
	
	
	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	int ans=0;
	for(int i=1;i<=n;i+=2){
		int sum=0;
		for(int j=1;j<=i;++j){
			if(i%j==0)++sum;
		}
		if(sum==8)++ans;
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

B = []
C = []

for i in range(N):
    if i % 2 == 0:
        B.append(A[i])
    else:
        C.append(A[i])

ans = []
if N % 2 == 0:
    C.reverse()
    ans = C + B
else:
    B.reverse()
    ans = B + C

print(*ans) 


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

typedef long long ll;
const int MOD = 1e9 + 7;
typedef vector<ll> vll;

int main() {
    int n;
    cin >> n;
    if (n == 1) {
        cout << "Hello World" << endl;
    } else if (n == 2) {
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
/* テンプレートここまで */
const int MOD = 1e9 + 7;
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; }

const int MAX = 1e5;
vector<vector<int>> edge(MAX);
//0:black, 1:white
vector<vector<ll>> dp(MAX, vector<ll>(2, 0));

void dfs(int parent, int root){
  dp[root][0] = dp[root][1] = 1;

  FOREACH(child, edge[root]){
    if(child == parent) continue;
    dfs(root, child);
    (dp[root][0] *= dp[child][1]) %= MOD;
    (dp[root][1] *= (dp[child][0] + dp[child][1])%MOD) %= MOD;
  }

}

int main() {
  int N;  cin >> N;
  REP(i, N-1){
    int x, y;
    cin >> x >> y;
    x--; y--;
    edge[x].push_back(y);
    edge[y].push_back(x);
  }

  dfs(-1, 0);
  cout << (dp[0][0] + dp[0][1])%MOD << endl;
}


Measured memory_bytes: 16768
#include <iostream>
using namespace std;
typedef long long  ll;

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

void swap(ll *s, ll *t) {
	ll x;
	x = *t;
	*t = *s;
	*s = x;
}

void sort(ll *L, ll size, bool asc) {
	for (int i = 0; i < size; i++) {
		for (int j = i + 1; j < size; j++) {
			if (asc) {
				if (L[i] > L[j]) {
					swap(L[i], L[j]);
				}
			}
			else {
				if (L[i] < L[j]) {
					swap(L[i], L[j]);
				}
			}
		}
	}
}
int main()
{
	ll  N, K; cin >> N >> K;
	ll L[50];
	rep(i, 0, N) {
		cin >> L[i];
	}

	sort(L, N, false);
	ll sum = 0;
	rep(i, 0, K) {
		sum += L[i];
	}
	cout << sum << endl;
}

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

int calc(int N) {
  int cnt = 1;
  for(int i = 3; i <= N; i+=2) {
    int tmp = 1;
    while(N % i == 0) {
      N /= i;
      tmp++;
    }
    cnt *= (tmp);
  }
  return cnt;
}

int main() {
  int N; cin >> N;
  int ans = 0;
  for(int i = 1; i <= N; i+=2) {
    if(calc(i) == 8) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {

      
 public static void main(String[] args) {
    
    Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    int N = in.nextInt();
    int M = in.nextInt();
   
    List<Integer>[] graph = new ArrayList[N];
    int[] dp = new int[N];
    int ans = 0;
    
    for(int i = 0; i < N; i++) {
        graph[i] = new ArrayList();
    }
    
    for(int i = 0; i < M; i++) {
        int u = in.nextInt()-1;
        int v = in.nextInt()-1;
        graph[u].add(v);
    }
    
    List<Integer> order = topologicalSort(graph, N);
    
    for(int u : order) {
        ans = Math.max(dp[u], ans);
        for(int v : graph[u]) {
            dp[v] = Math.max(dp[v], dp[u]+1);
        }
    }
    
    System.out.println(ans);
    
  }
  
  private static List<Integer> topologicalSort(List<Integer>[] g, int N) {
      int[] indeg = new int[N];
      List<Integer> order = new ArrayList();
      int q = 0;
      
      for(int i = 0; i < N; i++) {
          for(int v : g[i]) {
              indeg[v]++;
          }
      }

      for(int i = 0; i < N; i++) {
          if(indeg[i] == 0) {
              order.add(i);
              q++;
          }
      }
      
      for(int i = 0; i < q; i++) {
          for(int v : g[order.get(i)]) {
              if(--indeg[v] == 0) {
                  order.add(v);
                  q++;
              }
          }
      }
      
      return order;
      
  }
  
}

Measured memory_bytes: 99864
def dfs(i, f):
    if i == n - 1:
        return sum(list(map(int, f.split("+"))))

    return dfs(i + 1, f + s[i + 1]) + dfs(i + 1, f + "+" + s[i + 1])


s = input()
n = len(s)

print(dfs(0, s[0]))

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[] num = new int[n];
		Arrays.fill(num, -1);
		
		boolean flag = false;
		
		for (int i = 0; i < m; i++) {
			int s = sc.nextInt() - 1;
			int c = sc.nextInt();
			if (num[s] > 0 && num[s] != c || c == 0 && s < n - 1) {
				flag = true;
				break;
			} else {
				num[s] = c;
			}
		}
		for (int i = 1; i < num.length; i++) {
			if (num[i] < 0) {
				num[i] = 0;
			}
		}
		if (num[0] < 0) {
			num[0] = 1;
			if (num.length == 1) {
				num[0] = 0;
			}
		}
		if (flag || (num.length > 1 && num[0] == 0)) {
			System.out.println(-1);
		} else {
			for (int i = 0; i < num.length; i++) {
				System.out.print(num[i]);
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 22996
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

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

	vector<int>a(n);
	vector<int>b(n);
	rep(i, n) {
		cin >> a[i] >> b[i];
	}

	vector<pair<int, int>>c(n);
	rep(i, n) {
		c[i].first = a[i];
		c[i].second = b[i];
	}

	sort(c.begin(), c.end());

	ll ans = 0;
	ll pur = 0;

	rep(i,n){
		while (c[i].second > 0 && pur < m) {
			int x = c[i].second;
			pur++;
			c[i].second = x - 1;
			ans += c[i].first;
		}
		if (pur == m) {
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <vector>

int N;
int K;
std::vector<int> h;

int cost(int to) {
	if(to <= 0) {
		return 0;
	}
	static const int INVALID = -1;
	static std::vector<int> memo(N, INVALID);
	if(memo.at(to) != INVALID) {
		return memo.at(to);
	}

	int result;

	std::vector<int> list;
	for(int d = K; d >= 1; d--) {
		const int from = to - d;
		if(from < 0) {
			continue;
		}
		list.emplace_back(cost(from) + std::abs(h.at(from) - h.at(to)));
	}
	result = *std::min_element(list.begin(), list.end());

	memo.at(to) = result;
	return result;
}

int main() {
	std::cin >> N;
	std::cin >> K;
	h.resize(N);
	for(auto &hh : h) {
		std::cin >> hh;
	}

	const int result = cost(N - 1);

	std::cout << result << std::endl;

	return 0;
}

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

//LIFE IS NOT A PROBLEM TO BE SOLVED

#define rep(i,a,b) for( int i = (int) a; i < (int) b; i++ )
#define F first
#define S second
#define pb push_back
#define debug(a) cout << #a << " = " << a << endl;
#define debug2(a,b) cout << #a << " = " << a << " --- " << #b << " = " << b << endl;
#define debugP(a) cout << a.F << " " << a.S << endl;
#define debugM(mat,n,m) rep( i, 0, n ){ rep( j, 0, m ) cout << mat[i][j] << " "; cout << endl; }
#define all(s) s.begin(), s.end()

using namespace std;

typedef long long int ll;
typedef pair<int, int> ii;

int pset[100010], sz[100010];

int findset(int x){
	if(x!=pset[x]) pset[x] = findset(pset[x]);
	return pset[x];
}

void unionset(int x, int y, ll &ans){
	x = findset(x), y = findset(y);
	ans += (ll)(sz[x])*(sz[x]-1)/2;
	ans += (ll)(sz[y])*(sz[y]-1)/2;
	sz[x] += sz[y];
	sz[y] = 0;
	ans -= (ll)(sz[x])*(sz[x]-1)/2;
	pset[y] = x;
}

bool sameset(int x, int y){
	return findset(x)==findset(y);
}

vector <ii> edg;
int n, m, u, v;
ll resp[100010];

int main(){
	
	scanf("%d %d", &n, &m);
	
	rep(i, 1, n+1) pset[i] = i, sz[i] = 1;
	
	rep(i, 0, m){
		scanf("%d %d", &u, &v);
		edg.pb(ii(u, v));
	}
	
	ll ans = resp[m-1] = (ll)n*(n-1)/2;
	
	for(int i=edg.size()-1; i>=1; i--){
		int u = edg[i].F, v = edg[i].S;
		if(!sameset(u, v)) unionset(u, v, ans);
		resp[i-1] = ans;
	}
	
	rep(i, 0, m) printf("%lld\n", resp[i]);
	
	return 0;
}

Measured memory_bytes: 3828
def main11():
    str = input("");
    flag = True;
    for i in range((len(str)-1)):
        for j in range(i+1,len(str)):
            if(str[i]==str[j]):
                flag = False;
    if flag:
        print("yes");
    else:
        print("no");



if __name__ == '__main__':
    main11()

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		System.out.println(Math.pow((double) n / 3, 3));
	}
}


Measured memory_bytes: 21204
A, V = list(map(int, input().split()))
B, W = list(map(int, input().split()))
T = int(input())

flag = ""
dist = abs(A-B)
speed = V-W
if(dist <= (V-W) * T):
    flag = "YES"
else:
    flag = "NO"

if dist == 0: flag = "YES"
print(flag)


Measured memory_bytes: 9120
def printData(data) :
    for i, value in enumerate(data) :
        if i > 0 :
            print(" ", end = "")
        print(value, end = "")
    print()
    
def bubbleSort(data) :
    flag = 1
    count = 0
    for i in range(len(data)):
        if not flag :
            break
        flag = 0
        for j in reversed(range(i + 1, len(data))):
            if data[j] < data[j - 1] :
                buf = data[j]
                data[j] = data[j - 1]
                data[j - 1] = buf
                flag = 1
                count += 1
    
    printData(data)
    print(count)
    
    
input()
data = [int(char) for char in input().split()]
bubbleSort(data)


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

using namespace std;

int main()
{
    int N, K;
    string S;
    int t, f;
    int cnt;

    cin >> N >> K;
    cin >> S;

    if(S[0] == 'R'){
        for(int i=0; i<N; ++i){
            if(S[i] == 'R') S[i] = 'L';
            else if(S[i] == 'L') S[i] = 'R';
        }
    }

    f = 0;
    for(int i=1; i<N; ++i){
        if(S[i] == 'R' && !f) {
            t = i;
            f = 1;
        }
        else if((S[i] == 'L') && f){
            for(int j=t; j<i; ++j) S[j] = 'L';
            f = 0;
            --K;
        }
        if(K == 0) break;
    }

    if((K > 0) && (S[N-1] == 'R') && f){
        for(int i=0; i<N; ++i) S[i] = 'L';
    }

    cnt = 0;
    for(int i=0; i<N-1; ++i){
        if(S[i] == S[i+1]) ++cnt; 
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 512
n, m = map(int, input().split())

req = []
for i in range(m):
    a, b = map(int, input().split())
    req.append((b-1, a-1))

req.sort()

removed = 0
last = 0
for b, a in req:
    if a >= last:
        removed += 1
        last = b

print(removed)

Measured memory_bytes: 54236
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<long long int>v(N);
	for (auto &i : v)cin >> i;
	cin >> M >> K;
	vector<int>p(N - 1);
	for (int i = 0; i < N - 1; i++)p[i] = i;
	for (int i = 0; i < M; i++) {
		cin >> L;
		swap(p[L - 2], p[L - 1]);
	}
	vector<vector<int>>to(62, vector<int>(N - 1));
	for (int i = 0; i < N - 1; i++)to[0][i] = p[i];
	for (int i = 1; i < 62; i++) {
		for (int j = 0; j < N - 1; j++) {
			to[i][j] = to[i - 1][to[i - 1][j]];
		}
	}
	for (int i = 0; i < N - 1; i++) {
		long long int box = K;
		int cnt = i;
		for (int j = 0; j < 62; j++) {
			if ((box >> j) & 1) {
				cnt = to[j][cnt];
			}
		}
		p[i] = cnt;
	}
	long long int num = v[0];
	cout << num << endl;
	for (auto i : p) {
		//cout << i << endl;
		num += v[i+1]-v[i];
		cout << num << endl;
	}
	return 0;
}

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

const int MAX = 10000;
int main() {
	int N, a[MAX], b[MAX];
	cin >> N;
	for (int i = 0;i < N;i ++) cin >> a[i];
	for (int i = 0;i < N;i ++) cin >> b[i];
	int64_t aAdd = 0, bAdd = 0;
	for (int i = 0;i < N;i ++) {
		if (b[i] - a[i] > 0) {
			aAdd += (b[i] - a[i]) / 2;
		} else if (a[i] - b[i] > 0) {
			bAdd += a[i] - b[i];
		}
	}
//	cout << aAdd << " " << bAdd << endl;
	if (aAdd >= bAdd) cout << "Yes";
	else cout << "No";
	return 0;
}
/*
まず、Bi-Ai>0の場所全てに(Bi-Ai)/2だけ2を追加する
次に、Ai-Bi>0の場所全てにBi-Aiだけ1を追加する
そして、2を追加した個数>=1を追加した個数ならおｋ
*/

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

int main(){
    int H,W,seigen=0,ans=0,hante=0,count=0;
    vector<char> iti(70);

    cin>>H>>W;

    for(int i=0;i<H*W;i++){
        cin>>iti[i];
    }

    for(int i=0;i<H;i++){
         for(int j=0;j<W;j++){
            if(j<seigen&&iti[count]=='#'){
                ans=1;
                break;
            }
            if(iti[count]=='#'&&seigen<j){
                seigen=j;
            }
            count++;
        }
    }

    if(ans==1){ 
        cout<<"Impossible"<<endl;
    }else{
    cout<<"Possible"<<endl;        
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n,q;
  cin >> n >> q;
  string s;
  cin >> s;
  vec sum(n);
  for(ll i=0;i<n-1;i++) {
    sum[i+1]=sum[i];
    if(s[i]=='A'&&s[i+1]=='C') {
      sum[i+1]++;
    }
  }
  while(q--) {
    ll l,r;
    cin >> l >> r;
    cout << sum[r-1]-sum[l-1] << endl;
  }
}

Measured memory_bytes: 1792
from operator import itemgetter

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    BC = []
    for i in range(M):
        bc = list(map(int, input().split()))
        BC.append(bc)

    BC.sort(key=itemgetter(1), reverse=True)
    # B = []
    # for b, c in BC:
    #     B = B + [c] * b
    #     if len(B) > N:
    #         break

    A.sort(reverse=True)
    
    i = 0
    j = 0
    r = []

    cnt = 0
    while len(r) != N:
        # print(i, j)
        if j > M - 1:
            r.append(A[i])
            i += 1
            continue

        b, c = BC[j]
        if A[i] >= c:
            r.append(A[i])
            i += 1
        else:
            r.append(c)
            cnt += 1
            if cnt == b:
                j += 1
                cnt = 0

    # print(r)
    ans = sum(r)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 32976
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

int main() {
    int N; cin >> N;
    vector<ll> S(1<<N);
    rep(i,1<<N) cin >> S[i];

    priority_queue<ll,vector<ll>> q,next;
    multiset<ll> left;
    ll M = -1;
    rep(i,1<<N) {
        if (M < S[i]) {
            if (M > 0) left.insert(M);
            M = S[i];
        } else {
            left.insert(S[i]);
        }
    }
    q.push(M);
    bool flag = true;
    rep(i,N) {
        while (!q.empty()) {
            ll x = q.top(); q.pop();
            auto itr = left.lower_bound(x);
            if (itr == left.begin()) {
                flag = false;
                break;
            }
            --itr;
            next.push(x);
            next.push(*itr);
            left.erase(itr);
        }
        if (!flag) break;
        swap(q,next);
    }
    if (flag) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    return 0;
}

Measured memory_bytes: 20724
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n;
  long long k;
  cin>>n>>k;
  int a[n];
  REP(i, n){
    cin>>a[i];
    a[i]--;
  }
  vector<bool> used(n, false);
  int p = -1;
  int now = 0;
  while(true){
    used[now] = true;
    if(used[a[now]]){
      p = a[now];
      break;
    }
    now = a[now];
  }
  long long bsteps = 0;
  now = 0;
  while(true){
    if(now == p) break;
    now = a[now];
    bsteps++;
  }
  long long lsteps = 0;
  while(true){
    lsteps++;
    now = a[now];
    if(now == p) break;
  }
  
  int ans;
  if(k <= (long long)bsteps){
    now = 0;
    REP(_, k) now = a[now];
    ans = now;
  }else{
    long long steps = (k - bsteps) % lsteps;
    now = p;
    REP(_, steps) now = a[now];
    ans = now;
  }
  cout << ans + 1 << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(int i=ll(m); i<ll(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;


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

	FOR(i, -1000, 1000) {
		FOR(j, -1000, 1000) {
			ll k = pow(i, 5);
			ll l = pow(j, 5);
			
			if (k - l == x) {
				cout << i << ' ' << j << endl;
				return 0;
			}

		}
	}


}


Measured memory_bytes: 4080