akhauriyash/Code-Regression huggingface dataset:
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
int64_t A[200000];

std::unordered_map<int64_t, int64_t> M;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	for (int32_t i = 0; i < N; i++)
	{
		in >> A[i];
	}

	for (int32_t i = 1; i < N; i++)
	{
		A[i] += A[i - 1];
	}


	M[0]++;
	for (int32_t i = 0; i < N; i++)
	{
		M[A[i]]++;
	}

	int64_t res = 0;
	for (auto& i : M)
	{
		res += i.second*(i.second - 1)/2;
	}
	out << res << endl;


	return 0;
}
#endif


Measured memory_bytes: 10056
#include <iostream>
#include <vector>
#include <string>

using namespace std;

using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;
using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;

int main(int argc, char* argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  i64 H;
  i32 N;
  cin >> H >> N;
  for(i32 i = 0; i < N; ++i) {
    i32 A;
    cin >> A;
    H -= A;
  }
  if(H <= 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

#define FOR(i, n, m) for(int i = (n);i < (m);i++)
#define REP(i, n) for(int i = 0;i < (n);i++)
#define PII pair<int, int>

typedef long long int lli;

using namespace std;

int n, W;
int v[1000], w[1000];

int main(void){
    int cs = 1;
    while(cin >> W && W){
        int dp[1000+1][1000+1] = {};
        cin >> n;
        REP(i, n){
            int a, b;
            scanf("%d, %d", &a, &b);
            v[i] = a;
            w[i] = b;
        }

        REP(i, n){
            REP(j, W+1){
                if(j < w[i]){
                    dp[i+1][j] = dp[i][j];
                }else{
                    dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
                }
            }
        }

        cout << "Case " << cs << ":" << endl;
        cout << dp[n][W] << endl;
        int min_w = 100000000;
        REP(j, W+1){
            if(dp[n][j] == dp[n][W])
                min_w = min(min_w, j);
        }
        cout << min_w << endl;
        cs++;
    }
    return 0;
}

Measured memory_bytes: 5172
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int N, K, chk[200005], result, dcount;

int main()
{
    scanf("%d %d", &N, &K);
    for(int i = 0; i < N; i++)
    {
        int num;
        scanf("%d", &num);
        if(chk[num] == 0)
        {
            dcount++;
        }
        chk[num]++;
    }
    sort(chk + 1, chk + N + 1);
    for(int i = 1; i <= N; i++)
    {
        if(chk[i] == 0)
        {
            continue;
        }
        if(dcount <= K)
        {
            break;
        }
        dcount--;
        result += chk[i];
    }
    printf("%d", result);
}

Measured memory_bytes: 1024
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {

        static void Main(string[] args)
        {
            //var N = long.Parse(Console.ReadLine());
            var NM = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var M = NM[0];
            var D = NM[1];
            var ans = 0L;


            for (int i = 1; i <= M; i++)
            {
                for (int j = 1; j <= D; j++)
                {
                    var ten = j / 10;
                    var ich = j - (ten * 10);

                    if(ten >= 2 && ich >= 2 && ten*ich == i)
                    {
                        ans++;
                    }
                }
            }


            Console.WriteLine(ans);
            

            
            
        }


    }


}


Measured memory_bytes: 28056
#-swank
(unless (member :child-sbcl *features*)
  (quit
	:unix-status
	(process-exit-code
	  (run-program *runtime-pathname*
				   `("--control-stack-size" "128MB"
					 "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
					 "--eval" "(push :child-sbcl *features*)"
					 "--script" ,(namestring *load-pathname*))
				   :output t :error t :input t))))

(let* ((h (read))
	  (n (read))
	  (magic (loop repeat n collect (cons (read) (read))))
	  (dp (make-array h :initial-element (expt 10 30)))
	  (ans (expt 10 30)))
  (setf (aref dp 0) 0)
  (loop for i below h do
		(mapc (lambda (m)
				(let ((damage (car m))
					  (mp (cdr m)))
				  (if (>= (+ i damage) h)
					(setf ans (min ans (+ (aref dp i) mp)))
					(setf (aref dp (+ i damage)) (min (aref dp (+ i damage))
													  (+ (aref dp i) mp))))))
			  magic))
  (princ ans))


Measured memory_bytes: 62260
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

int main(){
	int n, i, x = 0, y, v[1000], c[1000];
	cin >> n;
	for(i = 0; i < n; i++){
		cin >> v[i];
	}
	for(i = 0; i < n; i++){
		cin >> c[i];
	}
	for(i = 0; i < n; i++){
		if(v[i] > c[i]){
			x = x + v[i] - c[i];
		}
	}
	cout << x;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
int k;
string s;
int n;
ll F[2000005];
ll I[2000005];
ll E26[2000005];
ll E25[2000005];
ll exp(ll a, ll x){
    if (x == 0) return 1ll;
    ll p = exp(a,x/2);
    p = (p*p)%mod;
    if (x & 1) p = (p*a)%mod;
    return p;
}
ll C(ll n ,ll k){
    return ((F[n]*I[n-k])%mod*I[k])%mod;
}
ll ans = 0;
int main(){
    cin >> k >> s;
    n = (int)s.size();
    F[0] = I[0] = E25[0] = E26[0] = 1;
    for (int i = 1; i <= 2000000; i++){
        F[i] = (F[i-1]*i)%mod;
        I[i] = exp(F[i],mod-2);
        E25[i] = (E25[i-1]*25ll)%mod;
        E26[i] = (E26[i-1]*26ll)%mod;
    }
    for (int i = n-1; i < n+k; i++){
        ans += (((C(i,n-1)*E25[i-n+1])%mod)*E26[(n+k)-i-1])%mod;
        ans %= mod;
    }
    printf("%lld",ans);
}


Measured memory_bytes: 66756
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func small(N, X, M int) {
	a := X
	ans := X
	for i := 2; i <= N; i++ {
		a *= a
		a %= M
		ans += a
	}
	out(ans)
}

type countMod struct {
	mod int
	m   []int
	pat []int
	sum int
	f   func(a, b int) int
}

// Fは累計処理関数　a+bのみ確認
func newCounter(n, mod int, f func(a, b int) int) *countMod {
	var ret countMod
	ret.mod = mod
	ret.m = make([]int, mod)
	ret.pat = make([]int, 0)
	ret.sum = 0
	ret.f = f
	return &ret
}

// vは次の値、Nは繰り返し回（トータル）
// 新しい値を登録する。巡回パターンが見つかると
// 初期部＋繰り返し部＋残りを加算した総和を返す
func (c *countMod) append(v, N int) (int, bool) {
	a := v
	if c.m[a] == 0 {
		c.m[a]++
		c.pat = append(c.pat, a)
		c.sum = c.f(c.sum, a)
		if len(c.pat) == N {
			return c.sum, true
		}
		return c.sum, false
	}
	start := 0
	ret := 0
	tot := c.sum
	for i := 0; i < len(c.pat); i++ {
		if c.pat[i] == a {
			start = i
			break
		}
		ret = c.f(ret, c.pat[i])
		tot -= c.pat[i]
	}
	N -= start
	loop := len(c.pat) - start
	n := N / loop
	ret += n * tot
	rest := N % loop
	for i := 0; i < rest; i++ {
		ret = c.f(ret, c.pat[start+i])
	}
	return ret, true
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	N, X, M := getInt(), getInt(), getInt()

	c := newCounter(N, M, func(a, b int) int {
		return a + b
	})
	for {
		sum, flg := c.append(X, N)
		// out(sum, flg, X, N)
		if flg {
			out(sum)
			return
		}
		X *= X
		X %= M
	}

}


Measured memory_bytes: 4928
//verma_ankit484

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const int mod = (int) 1e9+7;

using namespace std;
//using namespace __gnu_pbds;

//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


int32_t main() {
  IOS
  #ifdef AV
  freopen("input.txt", "r", stdin);
  #endif
  string s;
  cin >> s;
  map<int, int> mp;
  mp[0]++;
  int c = 0;
  int n = s.length();
  int p = 1, pr = 0;
  for (int i = n - 1; i >= 0; i--) {
    int pp = p * (s[i] - '0') + pr;
    pp %= 2019;
    mp[pp]++;
    pr = pp;
    p *= 10;
    p %= 2019;
  }
  int ans = 0;
  for (auto i: mp) {
    c = i.second;
    c = c * (c - 1) / 2;
    ans += c;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3724
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner cin = new Scanner(System.in);
		long sum = 0;
		long res = 0;
		int N = cin.nextInt();
		int dummyN = N;
		while (dummyN-->0) {
			int num = cin.nextInt();
			res += num * num;
			sum += num;
		}
		long bestX1 = (long)Math.ceil((double)(sum) / N);
		long bestX2 = (long)Math.floor((double)(sum) / N);
		System.out.println(Math.min(res, Math.min((N * bestX1 - 2 * sum) * bestX1, (N * bestX2 - 2 * sum) * bestX2) + res));
	} 
}


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

int main(){
    int h,w,i,j;
    while(true){
        cin >> h >> w;
        if(h==0 && w==0) return 0;
        for(i=0; i<w; i++){
            cout << "#";
        }
        cout << endl;
        for(i=1; i<h-1; i++){
            cout << "#";
            for(j=1; j<w-1; j++){
                cout << ".";
            }
            cout << "#";
            cout << endl;
        }
        for(i=0; i<w; i++){
            cout << "#";
        }
        cout << endl;
        cout << endl;
        
    }
}


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

const int N = 1e5;

int a,b,m;
int li[N+5],li2[N+5];

int main(){
	cin >> a >> b >> m;
	int mini = 1e9;
	int ans = 0;
	for(int i=1;i<=a;i++) cin >> li[i],mini = min(mini,li[i]);
	ans = mini;
	mini = 1e9;
	for(int i=1;i<=b;i++) cin >> li2[i],mini = min(mini,li2[i]);
	ans+=mini;
	for(int i=1;i<=m;i++){
		int x,y,c;
		cin >> x >> y >> c;
		int tmp = li[x] + li2[y] - c;
		ans = min(ans,tmp);
	}
	cout << ans << endl;
	return 0;
}

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;


void rec(const vvi& human, const vvi& language, vector<bool>& used, vector<bool>& lused, int cur) {
    if (used[cur]) return;

    used[cur] = true;
    for (auto& lang: human[cur]) {

        if (lused[lang]) continue;

        lused[lang] = true;
        for (auto to: language[lang]) {
            rec(human, language, used, lused, to);
        }
    }
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n, m;
    cin >> n >> m;

    vvi human(n), language(m);

    rep(i, n) {
        int k;
        cin >> k;
        rep(j, k) {
            int l;
            cin >> l;
            l--;
            human[i].push_back(l);
            language[l].push_back(i);
        }
    }

    vector<bool> used(n, false);
    vector<bool> lused(m, false);
    rec(human, language, used, lused, 0);

    rep(i, n) {
        if (!used[i]) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 8440
#include<bits/stdc++.h>
using namespace std;
int ans;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<s.size()-1;i++)
	{
		if(s[i]!=s[i+1]) ans++;
	}
	cout<<ans<<endl;
	
	return 0;
}



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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
const double PI = acos(-1.0);

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

int a[maxn];

void solve() {
    int n, k, d, x;
    cin >> n >> k;
    while (k--) {
        cin >> d;
        for (int i = 1; i <= d; i++) cin >> x, a[x] = 1;
    }
    int res = 0;
    for (int i = 1; i <= n; i++) if (!a[i]) res++;
    cout << res << endl;
}

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


Measured memory_bytes: 3652
import java.util.Scanner;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int max = 0;
		System.out.println(Math.max(Math.max(a-b,a+b),a*b));
	}
}

Measured memory_bytes: 22996
use std::collections::{HashMap, HashSet};
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: ident) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}
trait Monoid {
    fn unit() -> Self;
    fn add(lhs: Self, rhs: Self) -> Self;
}

struct SegTree<T: Monoid + Clone> {
    dat: Vec<T>,
    n: usize,
}

impl<T: Monoid + Copy> SegTree<T> {
    pub fn new(n: usize) -> Self {
        let dat = vec![T::unit(); n << 1];
        SegTree { dat: dat, n: n }
    }
    pub fn update(&mut self, k: usize, v: T) {
        let mut k = k + self.n;
        self.dat[k] = v;
        while {
            k >>= 1;
            k > 0
        } {
            self.dat[k] = T::add(self.dat[k << 1], self.dat[k << 1 | 1]);
        }
    }
    pub fn get(&self, a: usize, b: usize) -> T {
        let mut a = a + self.n;
        let mut b = b + self.n;
        let mut va = T::unit();
        let mut vb = T::unit();
        while a < b {
            if a & 1 != 0 {
                va = T::add(va, self.dat[a]);
                a += 1;
            }
            if b & 1 != 0 {
                vb = T::add(self.dat[b - 1], vb);
            }
            a >>= 1;
            b >>= 1;
        }
        T::add(va, vb)
    }
}

impl Monoid for usize {
    fn unit() -> usize {
        return 0;
    }
    fn add(lhs: Self, rhs: Self) -> Self {
        lhs | rhs
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut it = s.split_whitespace();
    let n: usize = parse!(it);
    let s = it.next().unwrap();
    let q: usize = parse!(it);
    let mut seg = SegTree::<usize>::new(n);
    for (i, b) in s.bytes().enumerate() {
        seg.update(i, 1 << (b - b'a'));
    }
    for _ in 0..q {
        let t: usize = parse!(it);
        if t == 1 {
            let i: usize = parse!(it);
            let i = i - 1;
            let cq = it.next().unwrap().bytes().next().unwrap();
            seg.update(i, 1 << (cq - b'a'));
        } else {
            let (l, r): (usize, usize) = parse!(it, 2);
            let c = seg.get(l - 1, r);
            println!("{}", c.count_ones());
        }
    }
}


Measured memory_bytes: 12668
#include<bits/stdc++.h>
using namespace std;
int main()
{
      ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
      string s;
      cin >>s;
      for (int i=0; i<s.size(); i++)
      {
            if (s[i]=='?')
            {
                  s[i]='D';
            }
      }cout << s <<  endl;
      return 0;
}


Measured memory_bytes: 3772
import sys
from collections import deque

input = sys.stdin.readline


def log(*args):
    print(*args, file=sys.stderr)


def main():
    h, w, k = map(int, input().strip().split())
    x1, y1, x2, y2 = map(int, input().strip().split())
    x1 -= 1
    y1 -= 1
    x2 -= 1
    y2 -= 1
    m = []
    costs1 = [[None for j in range(w)] for i in range(h)]
    costs2 = [[None for j in range(w)] for i in range(h)]
    for _ in range(h):
        m.append(list(input().strip()))
    q1 = deque()
    q1.append((x1, y1, 0))
    costs1[x1][y1] = 0
    q2 = deque()
    q2.append((x2, y2, 0))
    costs2[x2][y2] = 0
    directions = [(1, 0), (0, 1), (-1, 0), (0, -1)]
    while q1 and q2:
        (x, y, cost) = q1.popleft()
        if not costs2[x][y] is None:
            print(cost + costs2[x][y])
            return
        for (add_x, add_y) in directions:
            for dist in range(1, k + 1):
                new_x = x + add_x * dist
                new_y = y + add_y * dist
                if new_x >= h or new_x < 0 or new_y >= w or new_y < 0 or m[new_x][new_y] == '@' or ((not costs1[new_x][new_y] is None) and costs1[new_x][new_y] < cost + 1):
                    break
                if costs1[new_x][new_y] is None:
                    costs1[new_x][new_y] = cost + 1
                    q1.append((new_x, new_y, cost + 1))
        (x, y, cost) = q2.popleft()
        if not costs1[x][y] is None:
            print(cost + costs1[x][y])
            return
        for (add_x, add_y) in directions:
            for dist in range(1, k + 1):
                new_x = x + add_x * dist
                new_y = y + add_y * dist
                if new_x >= h or new_x < 0 or new_y >= w or new_y < 0 or m[new_x][new_y] == '@' or ((not costs2[new_x][new_y] is None) and costs2[new_x][new_y] < cost + 1):
                    break
                if costs2[new_x][new_y] is None:
                    costs2[new_x][new_y] = cost + 1
                    q2.append((new_x, new_y, cost + 1))
    print("-1")


if __name__ == '__main__':
    main()


Measured memory_bytes: 51328
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
template <class T> bool chmax(T &a,const T &b) {if(a<b) {a=b;return 1;} return 0;}
template <class T> bool chmin(T &a,const T &b) {if(b<a) {a=b;return 1;} return 0;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    string s;
    cin>>s;
    int n=SZ(s);
    auto check=[&](int k) {
        auto rev=[&](string &t) {
            FORE(x,t) {
                if(x=='1') x='0';
                else if(x=='0') x='1';
            }
        };
        auto ch=[&](string t) {
            int beg=-1;
            REP(i,n) {
                if(t[i]=='1') {
                    if(beg==-1) beg=i;
                } else {
                    if(beg!=-1) {
                        int l=i-beg;
                        if(k>beg && beg+l+k>n) {
                            return false;
                        }
                        beg=-1;
                    }
                }
            }
            if(beg!=-1) {
                int l=n-beg;
                if(k>beg && beg+l+k>n) {
                    return false;
                }
            }
            return true;
        };

        string t=s;
        rev(t);
        return ch(s) || ch(t);
    };

    int L=1,R=n+1;
    while(R-L>1) {
        int M=(L+R)/2;
        if(check(M)) {
            L=M;
        } else {
            R=M;
        }
    }
    cout<<L<<endl;
    return 0;
}


Measured memory_bytes: 720
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;

//#[proconio::fastout]
fn main() {
    input! {
        n: usize,
        a: [i64;n],
    }

    /* _dp0[i][j] : [0,i) から j 個選んで、a[i-1]を選ばなかった場合
       _dp1[i][j] : [0,i) から j 個選んで、a[i-1]を選んだ場合
       (i-1)/2 <= j <= (i+1)/2

       (i-1)/2 = b とする
       dp0[i][j-b+1] = dp0[i][j]
       dp1[i][j-b+1] = dp1[i][j]
    */

    const MIN_SUM: i64 = -1000_000_000i64 * 200000;

    let mut dp0 = vec![vec![MIN_SUM; 4]; n + 1];
    let mut dp1 = vec![vec![MIN_SUM; 4]; n + 1];
    fn f(i:usize,j:i64)->usize{
        let b =  (i as i64 - 1) >> 1;
        ( j + 1 - b ) as usize
    }

    dp0[0][f(0,0)] = 0;
    for i in 1..=n {
        let b = (i as i64 - 1) >> 1;
        for j in b..=b + 1 {
            dp0[i][f(i,j)] = max(dp0[i - 1][f(i-1,j)], dp1[i - 1][f(i-1,j)]);
            dp1[i][f(i,j)] = dp0[i - 1][f(i-1,j) - 1] + a[i - 1];
            //println!("{} {}", f(i,j), f(i-1,j));
            //println!("{} {}", dp0[i][f(i,j)], dp1[i][f(i,j)]);
        }
    }
    let j = n as i64 / 2;
    println!("{}", max(dp0[n][f(n,j)], dp1[n][f(n,j)]));
}


Measured memory_bytes: 33868
import math

K = int(input())
ans = 0
tmp = {}

for i in range(201):
    tmp[i] = 0

for i in range(1, K+1):
    for j in range(1, K+1):
        tmp[math.gcd(i, j)] += 1

for k in range(1, K+1):
    for key in tmp.keys():
        ans += math.gcd(key, k) * tmp[key]
print(ans)


Measured memory_bytes: 9092
#include<stdio.h>
 int main(void)
 {
     int X,Y,Z;

     scanf("%d %d %d",&X,&Y,&Z);

     if((X%(Y+Z)==0)||(X%(Y+Z)<Z))
       printf("%d\n",X/(Y+Z)-1);
     else printf("%d\n",X/(Y+Z));

     return 0;
 }



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

using namespace std;

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    vector <string> c(n);
    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
    }
    int ans = 0;
    for (int mask = 0; mask < (1 << n); mask++)
    {
        for (int msk = 0; msk < (1 << m); msk++)
        {
            int cnt = 0;
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < m; j++)
                {
                    if (c[i][j] != '#') continue;
                    if (((mask >> i) & 1) == 0 && ((msk >> j) & 1) == 0) cnt++;
                }
            }
            if (cnt == k)
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3580
N = int(input())
A = [0] + list(map(int, input().split())) + [0]

d = []
for i in range(len(A) - 1):
    d.append(abs(A[i] - A[i + 1]))
s = sum(d)

for i in range(0, N):
    print(s - d[i] - d[i + 1] + abs(A[i] - A[i + 2]))


Measured memory_bytes: 14048
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int n , x;
int a[1010];
int main(){
	cin >> n >> x;
	for(int i = 1 ; i <= n ; ++ i){
		cin >> a[i];
		x -= a[i];
	}
	int ans = n;
	sort(a + 1 , a + n + 1);
	ans += x / a[1];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

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

		for (int i = 0; i < N; i++) {
			d[i] = sc.nextInt();
		}

		sc.close();
		Arrays.sort(d, Collections.reverseOrder());

		int ans = 1;
		for (int i = 0; i < N-1; i++) {
			if (d[i] > d[i+1]) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22736
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef tuple<char, int, int> T;

int main()
{
    int H, W, wnum = 0,ans = -1;
    cin >> H >> W;
    vector<vchar> s(H + 1, vchar(W + 1)); //1-indexed
    for (int i = 1; i <= H; i++)
    {
        for (int j = 1; j <= W; j++)
        {
            cin >> s[i][j];
            if (s[i][j] == '.')
                wnum++;
        }
    }
    queue<tuple<char, int, int>> q;
    q.push((tuple<char, int, int>){s[1][1], 1, 1});
    vvint dis(H + 1, vint(W + 1));
    dis[1][1] = 1;
    //  int x = 0, y = 0;
    while (q.size() != 0)
    {
       
       int y = get<1>(q.front());
       int x = get<2>(q.front());
       if(x==W and y==H)
       {
           break;
       }
       q.pop();
       s[y][x] = '#';
       if (y + 1 <= H and 1 <= y + 1 and s[y + 1][x] == '.')
       {
           dis[y + 1][x] = dis[y][x] + 1;
           s[y + 1][x] = '#';
           q.push((T){s[y + 1][x], y + 1, x});
        }
        if (y - 1 >= 1 and y - 1 <= H and s[y - 1][x] == '.')
        {
            dis[y - 1][x] = dis[y][x] + 1;
            s[y - 1][x] = '#';
            q.push((T){s[y - 1][x], y - 1, x});
        }
        if (x + 1 <= W and 1 <= x and s[y][x + 1] == '.')
        {
            dis[y][x + 1] = dis[y][x] + 1;
            s[y][x + 1] = '#';
            q.push((T){s[y][x + 1], y, x + 1});
        }
        if (x - 1 <= W and x - 1 >= 1 and s[y][x -1] == '.')
        {
            dis[y][x - 1] = dis[y][x] + 1;
            s[y][x - 1] = '#';
            q.push((T){s[y][x - 1], y, x - 1});
        }
        
    }
    if(dis[H][W] != 0)
        ans = wnum - dis[H][W];
    std::cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

 
void solve(){
    int n, t;
    cin >> n >> t;
    int cost = 1e9;
    for(int i = 0; i < n; i++){
        int c, time;
        cin >> c >> time;
        if(time <= t){
            cost = min(cost, c);
        }
    }
    if(cost == 1e9) cout << "TLE";
    else cout << cost;
}

 
int main() {
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
#define INF 1000000000
#define debug3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n";
#define debug2(index, value) cout << index << " " << value << "\n";
#define debug1(value) cout << value << "\n";
#define openfile(string1, string2) \
    freopen(string1, "r", stdin);  \
    freopen(string2, "w", stdout);
using namespace std;

void solve() {
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //openfile("input.txt", "output.txt");
    int d, t, s;
    cin >> d >> t >> s;
    if (s * t >= d) {
        cout << "Yes";
    } else
        cout << "No";

    solve();

    return 0;
}

Measured memory_bytes: 3636
N = gets.to_i
H_LIST = gets.split(' ').take(N).map(&:to_i)

# [[i, size], ...]
def mk_candidate_list(list)
  candidate_list = []
  i = 0
  while i < list.size
    l = list[i..-1].take_while.with_index do |h, j|
      h < H_LIST[i + j]
    end
    if l.size > 0
      candidate = [i, l.size]
      candidate_list.push(candidate)
    end
    i += l.size + 1
  end
  candidate_list
end

answer = 0
list = Array.new(N, 0)
candidate_list = mk_candidate_list(list)
while candidate_list.size > 0
  i, size = candidate_list.max_by { |i, size| size }
  list =
    list[0...i] + list[i, size].map(&:next) + list[(i + size)..-1]
  candidate_list = mk_candidate_list(list)
  answer += 1
end
puts answer


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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

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

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n;
    cin>>n;

    vector<int>a;

    int cur=11;
    while(a.size() < n){
        bool isprime=true;
        for(int i=2;i<=sqrt(cur)+1;++i)if(cur%i==0)isprime=false;
        if(isprime)a.emplace_back(cur);

        cur+=10;
    }

    for(int ai:a)cout<<ai<<" ";

    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 256
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

H = get_int

def count(h)
  return 0 if h == 0

  1 + count(h/2) * 2
end

puts count(H)


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

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) {
        int hi;
        cin >> hi;
        h[i] = hi;
    }
    reverse(h.begin(), h.end());
    int hight = h[0];
    bool flg = true;
    for (int i=1; i<(n); i++) {
        if (h[i] > hight+1) flg = false;
        else hight = min(hight, h[i]);
    }
    if (flg) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main(){
  string S;
  cin >> S;
  int N = S.size();
  
  bool ans = true;
  for(int i=0; i<N; i++){
    if(i % 2 == 0){ //(0)文字目は奇数文字目
      if(S.at(i) == 'L'){
        ans = false;
      }
    }
    else{
      if(S.at(i) == 'R'){
        ans = false;
      }
    }
  }
  
  if(ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

}

Measured memory_bytes: 256
while True:
    count=0
    a,b=map(int,input().split())
    if a==0 and b==0:
        break
    elif a<b:
        a,b=b,a
    while True:
        if b==0:
            break
        a=a%b
        a,b=b,a
        count+=1
    print(a,count)



Measured memory_bytes: 5608
import heapq
N,M=map(int,input().split())

A=list(map(int,input().split()))

for i in range(N):
  A[i]*=-1
heapq.heapify(A)
for i in range(M):
  n=heapq.heappop(A)
  heapq.heappush(A,-((-n)//2))
print(-sum(A))

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const double eps = 1e-9;

struct V {
    double x, y;

    V(double x = 0, double y = 0) : x(x), y(y) {}

    V &operator+=(const V &v) {
        x += v.x;
        y += v.y;
        return *this;
    }

    V operator+(const V &v) const { return V(*this) += v; }

    V &operator-=(const V &v) {
        x -= v.x;
        y -= v.y;
        return *this;
    }

    V operator-(const V &v) const { return V(*this) -= v; }

    V &operator*=(double s) {
        x *= s;
        y *= s;
        return *this;
    }

    V operator*(double s) const { return V(*this) *= s; }

    V &operator/=(double s) {
        x /= s;
        y /= s;
        return *this;
    }

    V operator/(double s) const { return V(*this) /= s; }

    double dot(const V &v) const { return x * v.x + y * v.y; }

    double cross(const V &v) const { return x * v.y - v.x * y; }

    double norm2() const { return x * x + y * y; }

    double norm() const { return sqrt(norm2()); }

    int ort() const { // orthant
        if (abs(x) < eps && abs(y) < eps) return 0;
        if (y > 0) return x > 0 ? 1 : 2;
        else return x < 0 ? 3 : 4;
    }

    bool operator<(const V &v) const {
        int o = ort(), vo = v.ort();
        if (o != vo) return o < vo;
        return cross(v) > 0;
    }
};

istream &operator>>(istream &is, V &v) {
    is >> v.x >> v.y;
    return is;
}

ostream &operator<<(ostream &os, const V &v) {
    os << "(" << v.x << "," << v.y << ")";
    return os;
}

int main() {
    int N;
    cin >> N;
    vector<V> v(N);
    rep(i, N) cin >> v[i];

    sort(v.begin(), v.end());
    double ans = 0;
    rep(l, N) {
        int i = l;
        V now;
        rep(r, N) {
            now += v[i];
            ans = max(ans, now.norm());
            i = (i + 1) % N;
        }
    }

    printf("%.12f\n", ans);
}

Measured memory_bytes: 256
x_1, y_1, x_2, y_2 = map(int, input().split())
x = x_2 - x_1
y = y_2 - y_1
x_3 = x_2 - y
y_3 = y_2 + x
x_4 = x_1 - y
y_4 = y_1 + x
print("{} {} {} {}".format(x_3, y_3, x_4, y_4))

Measured memory_bytes: 3060
/*
 *  author : Atul Anand   
 *  created on : Wed Apr 01 2020
 */

import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        int N = in.nextInt();
        println(N*N*N);
        
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

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

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

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

const long long INF = 1LL<<60;

int main(){
  int i,N,a[100000];
  long long dp[100000];

  cin >>N;
  for(i=0;i<N;i++){cin>>a[i];}
  for(i=0;i<100000;i++){dp[i]=INF;}

  dp[0]=0;
  for(i=1;i<N;i++){
    chmin(dp[i],dp[i-1]+abs(a[i]-a[i-1]));
    if(i>1)chmin(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
  }

  cout<< dp[N-1]<< endl;

}

Measured memory_bytes: 1408
W,H,N=map(int,input().split())
x=[0 for i in range(N)]
y=[0 for i in range(N)]
a=[0 for i in range(N)]
for i in range(N):
    x[i],y[i],a[i]=map(int,input().split())
C=[[0 for i in range(W)] for j in range(H)]
for k in range(N):
    if a[k]==1:
        for i in range(H):
            for j in range(x[k]):
                C[i][j]=1
    elif a[k]==2:
        for i in range(H):
            for j in range(x[k],W):
                C[i][j]=1
    elif a[k]==3:
        for i in range(y[k]):
            for j in range(W):
                C[i][j]=1
    else:
        for i in range(y[k],H):
            for j in range(W):
                C[i][j]=1
Ans=0
for i in range(H):
    for j in range(W):
        if C[i][j]==0:
            Ans+=1
print(Ans)



Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

ll a[100001],b[100001];
int main(){
    int n;
    ll k;
    cin>>n>>k;
    rep(i,n) cin>>a[i]>>b[i];
    ll mx=0;
    rep(i,n)if((a[i]|k)==k) mx+=b[i];
    ll tmp=1;
    int cnt=0;
    while(tmp<=k){
        ll t=k&~(tmp);
        if(k==t){
            tmp<<=1;++cnt;continue;
        }
        rep(i,cnt) t|=(1<<i);
        ll sum=0;
        rep(i,n){
            if((a[i]|t)==t) sum+=b[i];
        }
        //cout<<sum<<endl;
        mx=max(mx,sum);
        tmp<<=1;++cnt;
    }
    cout<<mx<<endl;
    return 0;
}

Measured memory_bytes: 1792
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を文字の配列で返却する
def gets_nsp_list()
  gets.chomp.split("")
end

s = gets_nsp_list

if s[0] != "A"
  puts "WA"
  exit
end

if s[2..(s.size-2)].count("C") != 1
  puts "WA"
  exit
end

ls = s - ["A", "C"]

if ls == ls - ("A".."Z").to_a
  puts "AC"
  exit
end

puts "WA"


Measured memory_bytes: 14444
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=100005;
int Stack[N],tot,cnt[N],n,Q,x,ans[N];
signed main(){
	scanf("%lld%lld",&n,&Q);
	Stack[++tot]=n;
	while (Q--){
		scanf("%lld",&x);
		while (tot&&x<=Stack[tot])tot--;
		Stack[++tot]=x;
	}
	for (int i=tot;i;i--){
		if (i==tot)cnt[i]=1;
		else cnt[i]+=Stack[i+1]/Stack[i]*cnt[i+1];
		if (i==1){
			ans[Stack[1]]+=cnt[1];
			continue;
		}
		int r=Stack[i]%Stack[i-1];
		while (r>Stack[1]){
			int k=lower_bound(Stack+1,Stack+tot+1,r)-Stack-1; 
			cnt[k]+=r/Stack[k]*cnt[i];
			r%=Stack[k];
		}
		ans[r]+=cnt[i];
	}
	for (int i=n;i;i--)ans[i]+=ans[i+1];
	for (int i=1;i<=n;i++)printf("%lld\n",ans[i]);
	return 0;
} 

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define ll              long long
#define dd              double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vll             vector<long long>
#define vdd             vector<double>
#define vpii            vector<pair<int,int>>
#define vpll            vector<pair<long long,long long>>
#define vvi             vector<vector<int>>
#define vvl             vector<vector<long long>>
#define mii             map<int,int>
#define mll             map<long long,long long>
#define umii            unordered_map<int,int>
#define umll            unordered_map<long long,long long>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep2(i,a,b)     for(int i=a;i<b;i++)
#define rev(i,n)        for(int i=n;i>=0;i--)
#define rev2(i,a,b)     for(int i=a;i>=b;i--)
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define inf             9e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define fio             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl            '\n'
#define all(x)          x.begin(),x.end()
#define d0(x)           cout <<x<<" "
#define d1(x)           cout <<x<<endl
#define d2(x,y)         cout <<x<<" "<<y<<endl
#define d3(x,y,z)       cout <<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w)     cout <<x<<" "<<y<<" "<<z<<" "<<w<<endl
#define read2(x,y)      cin>>x>>y
#define read3(x,y,z)    cin>>x>>y>>z
#define read4(x,y,z,w)  cin>>x>>y>>z>>w
#define read5(x,y,z,w,a)cin>>x>>y>>z>>w>>a
#define sz(a)           (int)a.size()
const ll mod=1e9+7;
const double PI = 3.14159265359;
const ll MOD=998244353;
void i_o()
{
   #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
   #endif
}
ll help(vll& A,ll k){
   ll n=sz(A)-1,curr=1,k1=k,st,i;
   vi is(n+1,-1);
   for(i=0;i<=n+3;i++){
      if(k1==0) return curr;
      if(is[curr]==1){
         st=curr;
         break;
      }
      is[curr]=1;
      curr=A[curr];
      k1--;
   }
   ll j=i;
   curr=st;
   vi ind(n+1,-1);
   ind[curr]=j;
   while(1>0){
      curr=A[curr];
      j++;
      if(curr==st) break;
      else ind[curr]=j;
   }
   ll len=j-i;
   k=k%len;
   for(int i=1;i<=n;i++){
      if(ind[i]!=-1&&ind[i]%len==k) return i;
   }
   return 1;
}
int main() {
   fio
   i_o();
   ll n,k;
   cin>>n>>k;
   vll A(n+1);
   rep2(i,1,n+1) cin>>A[i];
   d1(help(A,k));
   return 0;
}



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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  rep(i, N) cin >> vec[i];
  int notequal = 0;
    
  for (int i = 0; i < N; i++) {
    if (vec[i] != i+1) notequal++;
  }
  
  if (notequal <= 2){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
using namespace std;
int main(void){
    // Your code here!
    string s; cin>>s;
    int k; cin>>k;
    set<string> can;
    for(int i = 1; i <= k; ++i){
        for(int j = 0; j + i <= s.size(); ++j){
            can.insert(s.substr(j,i));
        }
    }
    int a=1;
    string ans;
    for(string x:can){
        ans = x;
        if(a==k)break;
        ++a;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true) {
			int x = scan.nextInt();
			int y = scan.nextInt();
			if(x == 0 && y == 0) {
				break;
			}
			if(y > x) {
				System.out.println(x + " " + y);
			}else {
				System.out.println(y + " " + x);
			}
		}
		scan.close();
	}
}


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

int main() {
#ifdef LOCAL_DEFINE
  //freopen("data.in", "rt", stdin);
  //freopen("data.out", "w", stdout);
  auto _start = chrono::high_resolution_clock::now();
#endif
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	int n;
	cin >> n;
	for(int i = n; i < 2000; i++) {
		int a = i / 100;
		int b = i / 10 % 10;
		int c = i % 10;
		if(a == b && b == c) {
			cout << i << '\n';
			return 0;
		}
	}

#ifdef LOCAL_DEFINE
  auto _end = chrono::high_resolution_clock::now();
  cerr << "elapsed time: " << chrono::duration<double, milli>(_end - _start).count() << " ms\n";
#endif
	return 0;
}

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

#define pb push_back
#define ll long long int
#define mpi map<int, int>
#define vi vector<int>
#define si set<int>
#define pii pair<int, int>
#define vpi vector<pii>
#define vs vector<string>
#define pri priority_queue<int>
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define For(i, n) for (int i = 0; i < n; i++)
#define Ford(i, a, b) for (int i = a; i >= b; i--)
#define Rep(i, x, y) for (int i = x; i <= y; i++)
#define mem(a, b) memset(a, b, sizeof(a))
#define fastio                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)

double tick()
{
    static clock_t oldt, newt = clock();
    double diff = 1.0 * (newt - oldt) / CLOCKS_PER_SEC;
    oldt = newt;
    return diff;
}

int main()
{
    int n;
    cin >> n;
    ll res = 0;
    Rep(i, 1, n)
    {
        Rep(j, 1, n)
        {
            Rep(k, 1, n)
            {
                ll t = __gcd(i, j);
                t = __gcd(t, (ll)k);
                res += t;
            }
        }
    }
    cout << res << endl;
    cerr << "execution time is: " << tick() << "\n";
}


Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  int n,m;
  cin>>n>>m;
  int sum=0;
  for (int i = 0; i < m; ++i)
  {
    int tmp;
    cin>>tmp;
    sum+=tmp;
  }
  cout<<max(n-sum,-1);

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N, M;
    cin >> N >> M;
    if(M >= N) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256