akhauriyash/Code-Regression huggingface dataset:
use proconio::*;
use std::collections::*;
use std::ops::Bound::*;
use std::cmp::*;

fn rand_memory() -> usize {
    Box::into_raw(Box::new("I hope this is a random number")) as usize
}

fn rand() -> usize {
    static mut X: usize = 0;
    unsafe {
        if X == 0 {
            X = rand_memory();
        }
        X ^= X << 13;
        X ^= X >> 17;
        X ^= X << 5;
        X
    }
}

const F: usize = 26;

#[fastout]
fn run() {
    input! {
        d: usize,
        c: [i64; F],
        mut s: [[i64; F]; d],
    }
    let mut t = vec![0; d];
    let mut last = [0; 26];
    for (i, s) in s.iter().enumerate() {
        let i = i as i64 + 1;
        let mut score = (std::i64::MIN, 0);
        for t in 0..F {
            let mut v = 0;
            v += s[t];
            let save = last[t];
            last[t] = i;
            for (c, last) in c.iter().zip(last.iter()) {
                v -= *c * (i - *last);
            }
            score = max(score, (v, t));
            last[t] = save;
        }
        t[i as usize - 1] = score.1;
        last[score.1] = i;
    }
    let mut score = 0;
    let mut set = vec![BTreeSet::new(); F];
    for set in set.iter_mut() {
        set.insert(0);
    }
    for (i, (s, &t)) in s.iter().zip(t.iter()).enumerate() {
        let k = i as i64 + 1;
        score += s[t];
        set[t].insert(i + 1);
        for (c, set) in c.iter().zip(set.iter()) {
            let last = *set.iter().rev().next().unwrap() as i64;
            score -= *c * (k - last);
        }
    }
    for set in set.iter_mut() {
        set.insert(d + 1);
    }
    s.insert(0, vec![]);
    t.insert(0, 0);
    let func = |contest: usize, day: usize| -> i64 {
        let day = day as i64;
        c[contest] * day * (day - 1) / 2
    };
    let mut max = score;
    for _ in 0..6000000 {
        let d = rand() % d + 1;
        let q = rand() % F;
        let save = t[d];
        let x = t[d];
        assert!(set[x].remove(&d));
        let a = *set[x].range((Unbounded, Included(&d))).rev().next().unwrap();
        let b = *set[x].range((Included(&d), Unbounded)).next().unwrap();
        score -= s[d][x];
        score += func(x, d - a) + func(x, b - d);
        score -= func(x, b - a);
        let x = q;
        t[d] = x;
        let a = *set[x].range((Unbounded, Included(&d))).rev().next().unwrap();
        let b = *set[x].range((Included(&d), Unbounded)).next().unwrap();
        assert!(set[x].insert(d));
        score += s[d][x];
        score += func(x, b - a);
        score -= func(x, d - a) + func(x, b - d);
        if score > max {
            max = score;
        } else {
            score = max;
            t[d] = save;
            assert!(set[x].remove(&d));
            assert!(set[save].insert(d));
        }
    }
    let mut ans = vec![];
    for (i, set) in set.into_iter().enumerate() {
        for v in set {
            if v != 0 && v != d + 1 {
                ans.push((v, i));
            }
        }
    }
    ans.sort();
    for a in ans {
        println!("{}", a.1 + 1);
    }
}

fn main() {
    run();
}


Measured memory_bytes: 2388
#include<stdio.h>
#define max 2000000

int h, c;
int x[max+1];

void hmax(int a){
  int l=2*a,r=2*a+1,largest;
  if(l<=h && x[l]>x[a])largest=l;
  else largest=a;
  if(r<=h && x[r]>x[largest])largest=r;
  if(largest != a){
    c=x[a];
    x[a]=x[largest];
    x[largest]=c;
    hmax(largest);
  }
}

int main(){
  int i;
  scanf("%d",&h);
  for(i=1 ; i<=h ; i++)scanf("%d",&x[i]);
  for(i=h/2 ; i>=1 ; i--)hmax(i);
  for(i=1 ; i<=h ; i++){
    printf(" %d",x[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 3644
from collections import defaultdict

n, m = list(map(int, input().split()))
ab_list = [list(map(int, input().split())) for _ in range(m)]

towns_road = defaultdict(list)
for a, b in ab_list:
    towns_road[a].append(b)
    towns_road[b].append(a)

for i in range(1, n + 1):
    print(len(towns_road[i]))


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<ctime>
#include<set>
#include<iomanip>
#define sqr(x) (x)*(x)
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
//#define T_ int
using namespace std;
//struct bit{T_ arr[1000005];int lowbit(int x){return x&(-x);}void add(int x,T_ y){for (int i=x;i<=n;i+=lowbit(i)) arr[i]+=y;}T_ query(int x){T_ s=0;for (int i=x;i>0;i-=lowbit(i)) s+=arr[i];return s;}};
//struct seg{struct treedot{int l,r;T_ sum,add;void update(T_ x){sum+=(r-l+1)*x; add+=x;}}c[800005];void pushdown(int id){if (c[id].add){c[id*2].update(c[id].add);c[id*2+1].update(c[id].add);c[id].add=0;}}void pushup(int id){c[id].sum=c[id*2].sum+c[id*2+1].sum;}void build(int id,int l,int r){if (l>r) return;c[id].l=l;c[id].r=r;c[id].sum=0;c[id].add=0;if (l==r) c[id].sum=0;else{int mid=l+(r-l)/2;build(id*2,l,mid);build(id*2+1,mid+1,r);pushup(id);}}void update(int id,int le,int ri,T_ x){if (le>c[id].r||ri<c[id].l) return;if (le<=c[id].l&&c[id].r<=ri) c[id].update(x);else{pushdown(id);update(id*2,le,ri,x);update(id*2+1,le,ri,x);pushup(id);}}T_ query(int id,int le,int ri){if (ri<c[id].l||c[id].r<le) return 0;if (le<=c[id].l&&c[id].r<=ri) return c[id].sum;T_ ans=0;pushdown(id);ans+=query(id*2,le,ri);ans+=query(id*2+1,le,ri);pushup(id);return ans;}};
//struct bit_2d{T_ a[2005][2005];int lowbit(int x){return x&(-x);}void add(int x,int y,T_ z){int i,j;for (i=x;i<=2000;i+=lowbit(i)){for (j=y;j<=2000;j+=lowbit(j)){a[i][j]+=z;}}}T_ query(int x,int y){int i,j;T_ s=0;for (i=x;i;i-=lowbit(i)){for (j=y;j;j-=lowbit(j)){s+=a[i][j];}}return s;}T_ query(int x,int y,int xx,int yy){return query(xx,yy)-query(x-1,yy)-query(xx,y-1)+query(x-1,y-1);}};
int n,m,i,j,sum,ans[5005],vis[5005],ans2[5005];
struct ii
{
	int x,id;
}a[55];
bool cmp(ii x,ii y){return x.x>y.x;}
int main()
{
	scanf("%d%d",&n,&m);
	fz1(i,n)
	{
		scanf("%d",&a[i].x);sum+=a[i].x;
		a[i].id=i;
	}
	sort(a+1,a+n+1,cmp);
	fz1(i,sum)
	{
		sort(a+1,a+n+1,cmp);
		fz1(j,n) if (!vis[a[j].id]) break;
		if (j>n)
		{
			memset(vis,0,sizeof(vis));fz1(j,n) if (!a[j].x) vis[a[j].id]=2;vis[ans2[i-1]]=1;
			int f=0,g=3;fz1(j,n) {f=max(f,vis[j]);g=min(g,vis[j]);}
			i--;if (f==1) m--;
			if (g){sum=i;break;}
			continue;
		}
		vis[a[j].id]=1;ans[i]=j;ans2[i]=a[j].id;a[j].x--;
	}
	if (m<=0)
	{
		printf("%d\n",sum);
		fz1(i,sum) printf("%d ",ans2[i]);
	}
	else puts("-1");
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            QueueTest();
        }

        static void QueueTest()
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = l[0], q = l[1];

            var queue = new Queue<Model>();
            for (var i = 0; i < n; i++)
            {
                var t = Console.ReadLine().Split();
                queue.Enqueue(new Model() { P = t[0], Value = int.Parse(t[1])});
            }

            var total = 0;
            while (queue.Count > 0)
            {
                var x = queue.Dequeue();
                var minus = q;
                if (q > x.Value) minus = x.Value;
                total += minus;

                x.Value -= minus;
                if (x.Value > 0)
                    queue.Enqueue(x);
                else
                    Console.WriteLine($"{x.P} {total}");
            }
        }
    }

    class Model
    {
        public string P { get; set; }
        public int Value { get; set; }
    }
}



Measured memory_bytes: 27064
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x*y) // fractions.gcd(x,y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())

numbers = [int(input()) for i in range(N)]

print(lcm_list(numbers))

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

int main(){
  int n;
  cin >> n;
  int k = n % 10;
  if(k == 3) puts("bon");
  else if(k == 2 || k == 4 || k == 5 || k == 7 || k == 9) puts("hon");
  else puts("pon");
  return 0;
}


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

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

    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int res = 0;
    rep (i, A+1) {
        rep (j, B+1) {
            rep (k, C+1) {
                if (i*500 + j*100 + k*50 == X)
                    ++res;
            }
        }
    }

    cout << res << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<cmath>
#include<queue>	
#include<functional>
#include<climits>
#include<utility>
#include<tuple>
#include<cassert>
#include<stack>
using namespace std;

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long
#define PB push_back
#define LB lower_bound
#define UB upper_bound


//constant
const int MOD = 1000000007;
const int INF = INT_MAX / 3 - 1;
const double EPS = 1e-9;
const int dx4[4] = { 1,0,-1,0 };
const int dy4[4] = { 0,1,0,-1 };
const int dx8[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy8[8] = { -1,-1,-1,0,0,1,1,1 };

//typedef
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;


int main() {
	int n;
	cin >> n;
	vi a(n);
	int b;
	REP(i, n) {
		cin >> b;
		a[i] = b - 1;
	}
	int cnt = 0;
	REP(i, n) {
		if (a[a[i]]==i)
			cnt++;


	}
	cout << cnt / 2 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	ll a, b, n;
	cin >> a >> b >> n;
	ll ans = 1e18;
	for(int i = 1; i<= n; i++) {
		for(int j = 1; j <= n; j++) {
			if(j  > b) break;
			if(b%j != 0) continue;
			ll k = b / j;
			ans = min(ans, abs(i * k - a));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3068
def gen(n, d, v)
  if d == 0
    return (v.to_i <= n && v.split("").uniq.length == 3) ? 1 : 0
  else
    c = 0
    c += gen(n, d - 1, v + "7")
    c += gen(n, d - 1, v + "5")
    c += gen(n, d - 1, v + "3")
    return c
  end
end

n = gets.to_i
digits = n.to_s.length
count = 0
(3..digits).each do |d|
  count += gen(n, d, "")
end
puts count


Measured memory_bytes: 1916
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;


namespace templete
{
    class LinearSearch
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] num_n = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int q = int.Parse(Console.ReadLine());
            int[] num_q = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int count=0;
            for(int i=0; i<q; i++){
                for(int j=0; j<n; j++){
                    if(num_q[i] == num_n[j]){
                        count++;
                        break;
                    }
                }
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 10148
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 1000000000
#define PI 3.14159265359
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;
vector<vector<bool>> graph;
vector<bool> reached;
ll MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<int> S(N,0);
    int sum = 0;
    for(int i=0;i<N;i++){
        cin >> S[i];
        sum += S[i];
    }
    sort(S.begin(),S.end());

    if(sum%10 == 0){
        bool zero = true;
        for(int i=0;i<N;i++){
            if(S[i]%10 != 0){
                sum -= S[i];
                zero = false;
                break;
            }
        }
        if(zero) sum = 0;
    }
    cout << sum << endl;

}


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

void solve(){
    int x;
    cin >> x;
    if(105%x==0&&x!=1) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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


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

int main()
{
    int a[2];
    while (cin >> a[0] >> a[1])
    {
        if (a[0] == 0 && a[1] == 0)
            break;
        sort(a, end(a));
        cout << a[0] << " " << a[1] << endl;
    }
}


Measured memory_bytes: 3108
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    long a = sc.nextLong();
    long b = sc.nextLong();
    
    os.println(a * b / gcd(a, b));

  }

  private static long gcd(long m, long n) {
    if(m < n) return gcd(n, m);
    if(n == 0) return m;
    return gcd(n, m % n);
  }

}

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

int main(){
	int n, m;
    cin >> n >> m;
    if(n <= 2*m){
    	cout << 0 << endl;
    }else{
    	cout << n-2*m << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>
#include <complex>

using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const int INF = (1<<30);
const ll INFL = (1LL<<62);
const ll MOD = 1000000007;
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> ll mod_pow(ll a, ll n, T mod) { mod=(ll)mod; ll res=1, p=a%mod; while(n){ if(n&1) res=res*p%mod; p=p*p%mod; n>>=1; } return res; }
template<int mod>
struct ModInt {
    using ll = long long; ll x;
    ModInt() : x(0) {}
    ModInt(int y) : x(y >= 0 ? ll(y % mod) : (ll)((mod - (-y) % mod))) {}
    ModInt(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod)) {}
    ModInt &operator+=(const ModInt &rhs) { if((x += rhs.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &rhs) { if((x += mod - rhs.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &rhs) { x = x * rhs.x % mod; return *this; }
    ModInt &operator/=(const ModInt &rhs) { *this *= rhs.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(const ModInt &rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(const ModInt &rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(const ModInt &rhs) const { return ModInt(*this) /= rhs; }
    ModInt operator==(const ModInt &rhs) const { return x == rhs.x; }
    ModInt operator!=(const ModInt &rhs) const { return x != rhs.x; }
    friend ostream &operator<<(ostream &os, const ModInt &rhs) { return os << rhs.x; }
    friend istream &operator>>(istream &is, ModInt &rhs) { ll t; is >> t; rhs = ModInt<mod> (t); return (is); }
private:
    ModInt inverse() const { ll a = x, u = 1LL, v = 0LL, t, b = (ll)mod; while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return  ModInt(u); }
};
using mint = ModInt<MOD>;

int main() {
    int a, b;
    cin >> a >> b;
    if(a+b <= 23) cout << a+b << endl;
    else cout << a+b-24 << endl;

    return 0;
}

Measured memory_bytes: 256
X, K, D = [int(x) for x in input().split()]

X = abs(X)
fl = X // D
cl = fl + 1

if fl > K:
    ans = X - K * D
elif K % 2 == fl % 2:
    ans = X - fl * D
else:
    ans = cl * D - X

print(ans)

Measured memory_bytes: 9148
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;
    
    int res = 0;
    char c = s[0];
    for (int i = 1; i < (int)s.size(); i++) {
        if (c != s[i]) ++res;
        c = s[i];
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PA;
typedef priority_queue<int, vector<int>, greater<int> > PQG;
#define REP(i, a, n) for(ll i = (ll) a;i < (ll) n;i++)
#define fi first
#define se second
#define pb push_back
#define INF 1000000009
#define MOD 1000000007
#define MAXN 100005
#define MAXC 100000000000014
#define MAXV 1000000009
 
int n, x[MAXN], y[MAXN], t[MAXN], rec;
 
int main()
{
    cin >> n;
    REP(i, 1, n + 1){
        cin >> t[i] >> x[i] >> y[i];
        if(x[i] == x[i - 1] && y[i] == y[i - 1]){
            if((t[i] - t[i - 1]) % 4 == 0){
                rec++;
            }
        }
        else if((t[i] - t[i - 1]) % (abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])) == 0){
            rec++;
        }
    }
    if(rec < n){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
 
 
 
 
    return 0;
}
 
 

Measured memory_bytes: 1408
def euclidean_algorithm(x, y):
    cnt = 0

    if x < y:
        x, y = y, x
    while y:
        x = x % y
        x, y = y, x
        cnt += 1
    return x, cnt

import sys
f = sys.stdin

while True:
    a, b = map(int, f.readline().split())
    if a == 0:
        break
    print(*euclidean_algorithm(a, b))

Measured memory_bytes: 6720
import sys
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,c,k=mp()
t=sorted([int(input()) for i in range(n)])
count=1
f=t[0]
ans=1
for i in range(1,n):
    count+=1
    d=t[i]-f
    if d>k or count>c:
        ans+=1
        count=1
        f=t[i]

print(ans)

Measured memory_bytes: 8280
n,s=open(0)
n=int(n)
a=[0]*(n+1)
b=[0]*(n+2)
for i in range(n):
  a[i+1]=a[i]
  b[n-i]=b[n-i+1]
  if s[i]=='W':
    a[i+1]+=1
  if s[n-i-1]=='E':
    b[n-i]+=1
print(min(a[i]+b[i]-1for i in range(1,n+1)))

Measured memory_bytes: 46572
let scanInts () = stdin.ReadLine().Split() |> Array.map int

let [|n|] = scanInts ()

let rec rfn arr n =
  let s = if n % 2 = 0  then 0 else -1
  let t = if n % 2 = 0  then "0" else "1"
  match n with
  | 0 -> arr
  | _ -> rfn (t::arr) (-(n+s)/2)

if n = 0 then printfn "0"
else rfn [] n |> String.concat "" |> printfn "%s"


Measured memory_bytes: 14160
sx, sy, tx, ty = map(int, input().split())
x = tx - sx
y = ty - sy
r1 = "R"*x + "U"*y
r2 = "L"*x + "D"*y
r3 = "D" + "R"*(x+1) + "U"*(y+1) + "L"
r4 = "U" + "L"*(x+1) + "D"*(y+1) + "R"
ans = r1 + r2 + r3 + r4
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

long long dp[100][2];

int main() {
    int N;
    long long K;
    cin >> N >> K;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    
    for (int i = 0; i < 100; ++i) dp[i][0] = dp[i][1] = -1;
    dp[45][0] = 0;
    for (int d = 44; d >= 0; --d) {
        long long mask = 1LL<<d;
        int num = 0;
        for (int i = 0; i < N; ++i) if (A[i] & mask) ++num;
        
        if (dp[d+1][1] >= 0) chmax(dp[d][1], dp[d+1][1] + mask * max(num, N-num));
        if (dp[d+1][0] >= 0) {
            if (K & (1LL<<d)) {
                chmax(dp[d][1], dp[d+1][0] + mask * num);
                chmax(dp[d][0], dp[d+1][0] + mask * (N-num));
            }
            else {
                chmax(dp[d][0], dp[d+1][0] + mask * num);
            }
        }
        
        //cout << d << ": " << dp[d][0] << ", " << dp[d][1] << endl;
    }
    cout << max(dp[0][0], dp[0][1]) << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(std::vector<T>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}

void DFS(int V,vector<vector<int> >&GRAPH,vector<int>&dist,int depth)
{
  dist[V] = depth;
  for (int i = 0; i < GRAPH[V].size(); i++)
  {
    if(dist[GRAPH[V][i]] == -1)
    {
      DFS(GRAPH[V][i],GRAPH,dist,depth+1);
    }
  }
  return;
}
void solve(void)
{
  int X;
  cin>>X;
  int A,B;
  cin>>A>>B;
  if(A - B >= 0)
  {
    cout<<"delicious"<<endl;
  }
  else if(B - A <= X)
  {
    cout<<"safe"<<endl;
  }
  else
  {
    cout<<"dangerous"<<endl;
  }
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int ans = 0;
		for(int i=1;i*i<=m;i++) {
			if (m % i != 0) continue;
			ans = Math.max(ans, f(i,n,m));
			ans = Math.max(ans, f(m/i,n,m));
		}
		System.out.println(ans);
	}
	public static int f(int i, int n, int m) {
		int g = i;
		int num = m / g;
		if (num < n) return 0;
		return g;
	}
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
const ll INF=1e18+7;
const ll MOD=1e9+7;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	vector<ll> v;
	ll q;
	cin >> q;
	FOR(i,0,q){
		ll x,a;
		cin >> a;
		if(a!=2)cin >> x;
		if(a==0){
			v.push_back(x);
		}else if(a==1){
			cout << v[x] << endl;
		}else{
			v.pop_back();
		}
	}	
}



Measured memory_bytes: 4976
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int main(){
    string b;
    cin >> b;
    if (b == "A")
        cout << 'T' << endl;
    else if (b == "C")
        cout << 'G' << endl;
    else if (b == "G")
        cout << 'C' << endl;
    else if (b == "T")
        cout << 'A' << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <math.h>
#include <map>
#include <stack>
using namespace std;
static const int INF = 1e9+7;
// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i =a; i < b; i++)
#define all(a) a.begin(), a.end()
#define PI 3.14159265359

int main(){
    string s; cin >> s;
    int cnt = 0;
    int alp[135] = {};

    rep(i, s.size()){
        alp[int(s[i])]++;
    }
    bool flg = true;
    repr(i, 96, 123){
        if(alp[i] % 2 != 0){
            flg = false;
        }
    }
    if(flg){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3596
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val s = readLine()!!

    val left = s.count{it=='('}
    val right = n - left
    var diff = left - right

    /** (で増えて)で減る */
    var count = 0

    val result = StringBuilder()

    for (c in s) {
        if (c == '(') {
            count++
            result.append('(')

        } else {
            count--
            if (count < 0) {
                result.insert(0, '(')
                result.append(')')
                count++
            } else {
                result.append(')')
            }
        }
    }
    repeat(count) { result.append(')') }

    println(result)

}


Measured memory_bytes: 33712
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
string s,t;
vector<vector<ll> > dp(3002, vector<ll> (3002,-1));

ll val(ll i,ll j,ll n,ll m){
    if(i==n || j==m)
    return 0;
    
    if(dp[i][j]!=-1) return dp[i][j];
    
    if(s[i]==t[j])
    return dp[i][j]=1+val(i+1,j+1,n,m);
    
    return dp[i][j]=max(val(i+1,j,n,m),val(i,j+1,n,m));
}

int main() {
    fastio
    
	ll n,i,j,x=0,k;
	cin>>s>>t;
	
	k=val(0,0,s.size(),t.size());
	i=0,j=0;
	
	while(1){
	    if(dp[i][j]==-1) break;
	    
	    if(s[i]==t[j]){
	        cout<<s[i];
	        i++,j++;
	        continue;
	    }
	    
	    if(dp[i+1][j]>dp[i][j+1])
	    i++;
	    else j++;
	}
	
	return 0;
}



Measured memory_bytes: 74484
n, k = map(int, input().split())
a = list(map(int, input().split()))
dp = [0] * n

for i in range(1, n):
    dp[i] = min(dp[j] + abs(a[i] - a[j])
                for j in range(i - 1, max(i - k - 1, -1), -1))

print(dp[-1])


Measured memory_bytes: 53216
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;
const int V = 100005;

int main(){
    ll r,g; cin >> r >> g;
    cout << g + (g-r) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n, a;
    cin >> n;
    bool f = n&1;
    deque<int> v;
    fore(i,0,n) {
        cin >> a;
        if (!f) v.pb(a);
        else v.push_front(a);
        f ^= 1;
    }
    fore(i,0,n) {
        cout << v[i] << " \n"[i+1==n];
    }
}


Measured memory_bytes: 3072
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.Remoting.Contexts;
class Simple {
    private int W, a, b;
    void Solve() {
        //input
        W = io.Int;
        a = io.Int;
        b = io.Int;
        //cal
        if(a>b)
            swap(ref a,ref b);
        var ans = Math.Max(0,b-(a+W));
        //ret
        Console.WriteLine(ans);
    }
    void swap(ref int a, ref int b) {
        int t = b;
        b = a;
        a = t;
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    private void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //System.Console.SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}
class SimpleIO {
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] {' ', '"', ','};
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
    public SimpleIO() {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next() {
        if(_bufferCnt < _nextBuffer.Length) return _nextBuffer[_bufferCnt++];
        var st = Console.ReadLine();
        while(st == "") st = Console.ReadLine();
        if(st != null) _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        else st = "";
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() { Console.Out.Flush(); }
}
static class NumericEx {
    public static string pad0 <T>(this T v, int n) { return v.ToString().PadLeft(n, '0'); }
    public static double RoundOff(this double v, int n) { return Math.Round(v, n - 1, MidpointRounding.AwayFromZero); }
    public static bool Odd(this int v) { return v % 2 != 0; }
    public static bool Odd(this long v) { return v % 2 != 0; }
    public static void REP(this int v, Action <int> act) {
        for(int i = 0; i < v; ++i) act(i);
    }
    public static void REPR(this int v, Action <int> act) {
        for(int i = v - 1; i >= 0; --i) act(i);
    }
}


Measured memory_bytes: 11092
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	a, b, x = tin()
	#s = input()
	ret = 'YES' if (x >= a and x <= a+b) else 'NO'
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

using namespace std;

int main() 
{
	int m,n;
	cin>>m>>n;
	if((m%2==0 && n%2==0) || (m%2==1 && n%2==1)) 
	cout<< (m+n)/2;
	else cout<<"IMPOSSIBLE";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int n;
  cin >> n;
  map<int,int> mp[2];
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (i & 1) {
      mp[1][a]++;
    } else {
      mp[0][a]++;
    }
  }
  vector<pair<int,int>> p[2];
  for (int i = 0; i < 2; i++) {
    for (auto pp: mp[i]) {
      p[i].push_back(make_pair(pp.second, pp.first));
    }
  }
  sort(p[0].rbegin(),p[0].rend());
  sort(p[1].rbegin(),p[1].rend());
  int a1 = p[0][0].first, a2 = 0;
  int b1 = p[1][0].first, b2 = 0;
  if (p[0].size() > 1) {
    a2 = p[0][1].first;
  }
  if (p[1].size() > 1) {
    b2 = p[1][1].first;
  }
  if (p[0][0].second == p[1][0].second) {
    cout << min(n - a1 - b2, n - a2 - b1);
  } else {
    cout << n - a1 - b1;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 6136
import java.util.Scanner;

public class Main {

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

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define pb push_back
#define ppb pop_back()

using namespace std;

int main()
{/*
	int q;cin>>q;
	while(q--)
	{
		int n;cin>>n;
		string s;cin>>s;
		string str="";
		for(int i=0 ; i<s.length() ; i++)
		{
			if(!str.empty() and str.back()=='1' and s[i]=='0')
			{
				while(str.back()=='1') str.ppb;
			}
			str+=s[i];
		}
		cout << str<<endl;
	}*/
	string s,t;
	cin>>s>>t;
	if(t.length()!=s.length()) {cout<<0;return 0;}
	int cnt=0;
	for(int i=0 ; i<s.length() ; i++)
	{
		if(s[i]!=t[i]) cnt++;
	}
	cout<< cnt;

	return 0;

}

Measured memory_bytes: 3816
n=int(input())
dp=[[0]*3 for i in range(n)]
happy=[]
for i in range(n):
    tmp=list(map(int,input().split()))
    happy.append(tmp)
dp[0][0]=happy[0][0]
dp[0][1]=happy[0][1]
dp[0][2]=happy[0][2]
for i in range(1,n):
    dp[i][0] = max(dp[i-1][1],dp[i-1][2])+happy[i][0]
    dp[i][1] = max(dp[i-1][0],dp[i-1][2])+happy[i][1]
    dp[i][2] = max(dp[i-1][0],dp[i-1][1])+happy[i][2]
print(max(dp[n-1][0],dp[n-1][1],dp[n-1][2]))


Measured memory_bytes: 74732
s = input()
t = input()

ds = {}
dt = {}

ret = True
for i in range(len(s)):
  cs = s[i]
  ct = t[i]
  ccs = ds.get(cs, 0)
  cct = dt.get(ct, 0)
  if ccs == 0:
      ds[cs] = ct
  elif ccs == ct:
      pass
  else:
      ret = False
      break
  
  if cct == 0:
      dt[ct] = cs
  elif cct == cs:
      pass
  else:
      ret = False
      break

if ret == True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3632
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    int a, b,c,d;
    cin>>a>>b>>c>>d;

    if(abs(a-c)<=d) cout<<"Yes"<<endl;
    else{
        if(abs(a-b)<=d && abs(c-b)<=d) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3560
#include "bits/stdc++.h"
using namespace std;
typedef pair<int,int> pii;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 1<<30
#define MAX_V 200

// ????????¨???
struct edge{int to,cap,rev;};

vector<edge> G[MAX_V];  //??°???????????????
int level[MAX_V];       //?§??????????????????¢
int iter[MAX_V];        //???????????§????????????

// from??????to?????????????????????cap???????????°?????????????????????
void add_edge(int from,int to,int cap){
    G[from].push_back(  (edge){ to  ,cap,(int)G[to  ].size()   }  );
    G[to  ].push_back(  (edge){ from,0  ,(int)G[from].size()-1 }  );
}

// s????????????????????¢???BFS??§?¨??????????
void bfs(int s){
    rep(i,MAX_V)level[i]=-1;
    queue<int> que;
    level[s]=0;
    que.push(s);
    while(!que.empty()){
        int v=que.front();que.pop();
        
        rep(i,G[v].size()){
            edge &e=G[v][i];
            if(e.cap>0 && level[e.to]<0){
                level[e.to]=level[v]+1;
                que.push(e.to);
            }
        }
    }
}

//?¢?????????????DFS??§??¢???
int dfs(int v,int t,int f){
    if(v==t)return f;
    for(int &i=iter[v];i<G[v].size();i++){
        edge &e=G[v][i];
        if(e.cap>0&&level[v]<level[e.to]){
            int d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}

// s??????t???????????§???????±???????
int max_flow(int s,int t){
    int flow=0;
    for(;;){
        bfs(s);
        if(level[t]<0)return flow;
        memset(iter,0,sizeof(iter));
        int f;
        while((f=dfs(s,t,INF))>0){
            flow+=f;
        }
    }
}

int main(){
    int v,e;
    cin>>v>>e;
    rep(i,e){
        int uu,vv,cc;
        cin>>uu>>vv>>cc;
        add_edge(uu,vv,cc);
    }
    cout<<max_flow(0,v-1)<<endl;
}

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

void solve() {
  int r, d, x;
  cin >> r >> d >> x;
  int prev = x;
  rep(i, 10) {
    x = r * x - d;
    cout << x << endl;
  }
  
}

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

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


int main()
{
	int N, i, j, k, flag;
	cin >> N;
	vector<int>A(N);
	flag = 0;
	long long int sum = 0;

	for (i = 0; i < N; i++) {
		cin >> A[i];
	}
	if (A[0] != 0) {
		flag = 1;
	}
	else {
		for (i = 0; i < N - 1; i++) {
			if (A[i + 1] > A[i] + 1) {
				flag = 1;
				break;
			}
			else if (A[i + 1] == A[i] + 1) {
				sum += 1;
			}
			else if (A[i + 1] <= A[i]) {
				sum += A[i + 1];
			}
			
		}
	}
	if (flag == 1) {
		cout << "-1" << endl;
	}
	else {
		cout << sum << endl;
	}

	return 0;
}





Measured memory_bytes: 1152
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

void solve() {
	char S[10];
	scanf("%s", S);
	int n = (int)strlen(S);
	int ok = 0;
	for(int i=0;i<n-1;i++) if(S[i] == 'A' && S[i+1] == 'C') ok = 1;
	puts(ok ? "Yes" : "No");
}

int main(){
	int Tc = 1; // scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		// printf("Case #%d: ", tc);
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int
ll n ;
#define vrr vector<vector<ll>> 
#define modm 1000000007

vrr arr  , identity ;
vrr mult(vrr a , vrr  b  )
{
    vrr res(n,vector<ll>(n)) ;
    for( ll i= 0 ;i < n ;i++)
    {
        for( ll j =0 ;j <n ; j++)
        {
            res[i][j] =0 ;
            for( ll k =0 ;k < n ;k++)
            {
                res[i][j] =  (res[i][j] +  (( (b[i][k])%modm)*((a[k][j])%modm)%modm  )%modm )%modm ;
            }
        }
    }
    return res ;
    
    
    
    
}

vrr power(ll k )
{
    if(k==1)
    return arr  ;
    if(k==0)
    return identity ; 
    
        vrr crr = power(k/2) ;
    if(k%2 == 0)
    {
        return mult(crr , crr) ;
            }else
            {
                crr = mult(crr , crr) ;
                return mult( crr , arr ) ;
            }
}

int main()
{
    
    cin >> n; 
    ll k ;
    cin >> k;
    vrr a(n ,vector<ll>(n)) , b (n,vector<ll>(n));
    for( ll i=0 ;i < n ;i++)
    {
        for( ll j=0 ;j < n ;j++)
        {
            cin>> a[i][j] ;
            if(i==j)
            b[i][j] =1 ;
            else
            b[i][j] = 0 ;
            
        }
    }
    
        
        identity  =b ; 
        ll  res= 0;
        
        arr= a ;
        
        vrr ams = power(k) ;
        for( ll i =0 ;i <  n ;i++ )
        {
            for( ll j=0 ;j < n ;j++)
            {res = (res+ams[i][j] )%modm;
                
            }}
    cout<< res  ;
    return 0 ;
    }


Measured memory_bytes: 384
n  = gets.to_i
ps = gets.split.map(&:to_i)

cnt = 0
1.upto(n-2) do | i |
  cnt += 1 if ps[i-1] < ps[i] && ps[i] < ps[i+1]
  cnt += 1 if ps[i-1] > ps[i] && ps[i] > ps[i+1]
end
p cnt

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
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 pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////


signed main(){
  int n,k,h[210000];
  cin>>n>>k;rep(i,n)cin>>h[i];
  sort(h, h+n);
  int ans = 0;
  rep(i,n-k)ans += h[i];
  cout << ans << endl;
}



Measured memory_bytes: 1792
# -*- coding: utf-8 -*-

N=int(input())
H=list(map(int,input().split()))

count=[0]*N
count[0]=1

for ii in range(1,N):
    if H[ii] >= max(H[:ii]):
        count[ii]=1
    else:
        count[ii]=0
    
print(sum(count))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, K, T, W, H, M, C;

const int MAX = 5100000;
const int MOD = 1e9 + 7;

const double PI=3.14159265358979323846;


long long fac[MAX], finv[MAX], inv[MAX];

vector<double> cx, cy, c;
 ll MM = 1e12;

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

std::vector<int> Eratosthenes(int n ){
    std::vector<bool> is_prime( n + 1 );
    for( int i = 0; i <= n; i++ ) is_prime[ i ] = true;
    std::vector<int> P;
    for( int i = 2; i <= n; i++ ){
        if( is_prime[ i ] ){
            for( int j = 2 * i; j <= n; j += i ){
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}

ll gcd(ll a, ll b){
    if(a%b == 0) return b;
    else return gcd(b, a%b);
}

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



int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    
    ll ans1 = (b/c) - ((a + c-1)/c) ;
    ll ans2 = (b/d) - ((a + d-1)/d) ;
    ll l = lcm(c,d);
    ll ans3 = (b/l) - ((a + l-1)/l);

    cout << (b-a) + ans3 - ans1 - ans2;
    return 0;

}

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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
    ll n;
    cin>>n;
    Array a(n);
    REP(i,n) cin>>a[i];

    map<ll,ll> mp;
    REP(i,n) mp[a[i]]++;
    bool flag=false;
    if(mp.size()==1){
        auto it=mp.begin();
        if(it->first+1==it->second) flag=true;
        if(it->first*2<=it->second) flag=true;

    }
    if(mp.size()==2){
        auto it=mp.begin();
        flag=true;
        if(it->first<it->second) flag=false;
        auto it2=it;
        it2++;
        if(it2->first!=it->first+1) flag=false;
        if(it2->second<(it2->first-it->second)*2) flag=false;
    }
    cout<<(flag?"Yes":"No")<<en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

int main() {
    ll n;
    cin >> n;
    
    vl v;
    while(n > 0) {
        if(n%26 == 0) {
            v.pb(26);
            n -= 26;
        }
        else {
            v.pb(n%26);
            n -= n%26;
        }
        n /= 26;
    }

    vector<char> ans;
    for(auto x : v) {
        char c = 'a' + (x - 1);
        ans.pb(c);
    }
    reverse(all(ans));

    for(auto c : ans) {
        cout << c;
    }

    cout << endl;
    re0;
}

Measured memory_bytes: 3632