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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n;
int a[20], b[20];
int dp[(1 << 18) + 5][55];
void solve() {
    int n;
    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];

    fillArray(dp, iinf);
    dp[0][0] = 0;
    rep(s, 1 << n) {
        int cnt = 0;
        rep(i, n) if (((s >> i) & 1) == 1) cnt++;

        vector<pair<int, int>> v;
        int now = 0;
        rep(i, n) if (((s >> i) & 1) == 0) v.emplace_back(i, now++);

        rep(j, 52) {
            rep(i, v.size()) {
                int i0 = v[i].first;
                int i1 = v[i].second;
                int x = abs(cnt - i0) % 2 == 0 ? a[i0] : b[i0];
                if (x >= j) mins(dp[s | (1 << i0)][x], dp[s][j] + i1);
            }
        }
    }
    int ans = iinf;
    rep(i, 52) mins(ans, dp[(1 << n) - 1][i]);
    if (ans == iinf) cout << -1 << endn;
    else cout << ans << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 56576
#include<iostream>
#include<atcoder/all>
using namespace std;
typedef long long li;
#define binom2(n) ((n)*(n-1)/2)
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

struct mono{
  li v,c0,c1;
  mono(bool x){ v=0; c0=(!x); c1=x; };
  mono(){ v=0; c0=0; c1=0; };
  mono(li a,li b,li c){ v=a; c0=b; c1=c; };
};
mono e(){return mono();}
mono pl(mono m1, mono m2){ return {m1.v+m2.v+m1.c1*m2.c0, m1.c0+m2.c0, m1.c1+m2.c1}; }
std::ostream& operator<<(std::ostream& os, const mono& m){
  // ここでストリームに obj を書き込みます。
  cout << m.v;
  return os;
}

std::istream& operator>>(std::istream& os,mono& m){
  // ここでストリームに obj を書き込みます。
  int a; cin >>a;
  m=a;
  return os;
}

struct gr{
  bool flag;
  gr(bool x=0){ flag=x; };
};

mono sayo(gr g,mono m){
  li n=m.c0+m.c1;
  if(g.flag){
    m.v=binom2(n)-m.v-binom2(m.c0)-binom2(m.c1);
    swap(m.c0,m.c1);
  }
  return m;
}
gr comp(gr a,gr b){return a.flag^b.flag;}
gr id(){return gr();}

int main(){
  int n,q; cin >>n >>q;
  vector<mono> vec(n); rep(i,n) cin >>vec[i];
  atcoder::lazy_segtree<mono,pl,e,gr,sayo,comp,id> lz(vec);
  rep(_,q){
    int t,l,r; cin >>t >>l >>r; l--;
    if(t==1) lz.apply(l,r,1);
    else print(lz.prod(l,r));
  }
  
  
  
  if(df){
    print("read q");
    int _q; cin >> _q;
    rep(_,_q){
      int x,y,z;
      cin >>x >>y >>z;
      mono a={x,y,z};
      cin >>x >>y >>z;
      mono b={x,y,z};
      
      mono c=pl(a,b);
      print(c.v,c.c0,c.c1);
      c=sayo(0,c);
      print(c.v,c.c0,c.c1);
      c=sayo(1,c);
      print(c.v,c.c0,c.c1);
      a=sayo(1,a);
      b=sayo(1,b);
      print(a.v,a.c0,a.c1);
      print(b.v,b.c0,b.c1);
      c=pl(a,b);
      print(c.v,c.c0,c.c1);
    }    
  }
  
  
}


Measured memory_bytes: 20256
//do not think about past and stay in this moment
//organize and work - Abhinav IIITA
#include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define int long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end() 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int fre[26];

// -----------------------------------------------------------------------

void solve(){
int n;
cin>>n;
  int arr[n];
  int sp=0;
  for(int i=0;i<n;++i)
  {cin >> arr[i]; sp+=arr[i];}
  int m;
  cin>>m;
  while(m--){
    int p,s;
    cin>>p>>s;p--;
    int tp=sp;
    tp-=arr[p];
    tp+=s;
    cout<<tp<<endl;
  }
}


// -----------------------------------------------------------------------


int32_t main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); 	
	int t=1;
//	cin>>t;
	while(t--)
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
int a[maxn],b[maxn];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n; 
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		b[a[i]]++;
		b[a[i]+1]++;
		b[a[i]-1]++;
	}
	int ans=-inf;
	for(int i=0;i<=maxn;i++)
		if(b[i]>ans)
			ans=b[i];
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX=1e5+10;
ll dp[MAX],w[MAX],val[MAX];
int main (){
    int N,W;cin >> N >> W;

    for(int i=0;i<N;i++){
        //int w,val;
        cin >> w[i] >> val[i];
        for(int j=MAX;j>=w[i];j--){
                if(j - w[i]>=0)
                dp[j] = max(dp[j],dp[j - w[i]] + val[i]);
        }
    }
    ll res=0;
    for(int i=0;i<=W;i++){
        //if(dp[i])cout<<i<<" "<<dp[i]<<endl;
        res = max(res,dp[i]);
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;

int main(){
    const int INF = 100000000;
    int n, m; cin >> n >> m;
    vector<int> a(m), kypt(m, 0);
    REP(i, m){
        int b; cin >> a[i] >> b;
        REP(j, b){
            int c; cin >> c;
            kypt[i] += (1 << (c-1));
        }
    }
    
    vector<vector<int>> dp(m+1, vector<int>((1<<n), INF));
    dp[m][0] = 0;
    REP(i, m){
        dp[i][0] = 0;
        REP(j, (1<<n)){
            if(dp[i][j] != INF){
                dp[i+1][j|kypt[i]] = min(dp[i+1][j|kypt[i]], dp[i][j] + a[i]);
                dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            }
        }
    }
 /*   REP(i, m+1){
        REP(j, (1<<n)){
            if(j) cout << " ";
            cout << dp[i][j];
        }
        cout << "\n";
    }*/
    
    
    cout << (dp[m][(1<<n)-1] != INF ? dp[m][(1<<n)-1] : -1) << "\n";
    
    return 0;
}

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

namespace ITP1_9_C
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int turn = ReadInt();
            int taroS = 0;
            int hanakoS = 0;

            for (int i = 0 ; i < turn ; i++)
            {

                string[] line = ReadStAr();
                int res = String.Compare(line[0], line[1]);

                if (res < 0)
                {
                    hanakoS += 3;
                }
                else if (res > 0)
                {
                    taroS += 3;
                }
                else
                {
                    hanakoS++;
                    taroS++;
                }
            }
            Console.WriteLine("{0} {1}",taroS,hanakoS);
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



Measured memory_bytes: 18728
#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.txt"
 


int main() {
    string st;
    vector<int>nums(26);
    while (getline(cin, st)) {

        for (auto c : st) {
            if (c <= 'z'&&c >= 'a')nums[c - 'a']++;
            if (c <= 'Z'&&c >= 'A')nums[c - 'A'] ++;
        }
    }
    for (int i = 0; i < 26; ++i) {
        cout << char('a' + i) << " : " << nums[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD (long long)(1e9+7)
int main(){
	ll n,m;
	cin>>n>>m;
	if(abs(n-m)>1){
		cout<<0<<endl;
	}
	else if(abs(n-m)>0){
		ll ans=1;
		for(ll i=1;i<=n;i++)ans=(ans%MOD)*i;
		for(ll i=1;i<=m;i++)ans=(ans%MOD)*i;
		cout<<ans%MOD<<endl;
	}
	else{
		ll ans=1;
		for(ll i=1;i<=n;i++)ans=(ans%MOD)*i;
		for(ll i=1;i<=m;i++)ans=(ans%MOD)*i;
		ans=(ans%MOD)*2;
		cout<<ans%MOD<<endl;
	}
	
}


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


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

struct edge {int to; ll cost; };

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

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

ll LCM(ll a, ll b){
  if(a<b) swap(a,b);
  return a/GCD(a,b)*b;
}
 
int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  ll mod = 1000000007;
  vector<ll> inv(200005);
  inv[0] = 0;
  inv[1] = 1;
  for(int i=2; i<=200001; i++){
    inv[i] = -(mod/i)*inv[mod%i];
    inv[i] %= mod;
    if(inv[i]<0) inv[i] += mod;
  }
  vector<ll> comb(200005);
  comb[0] = 1;
  comb[1] = n;
  for(int i=2; i<=min(int(n),200001); i++){
    comb[i] = comb[i-1]*inv[i];
    comb[i] %= mod;
    comb[i] *= n-i+1;
    comb[i] %= mod;
  }
  ll ans = 1;
  ll tmp = 2;
  while(n>0){
    if(n%2){
      ans *= tmp;
      ans %= mod;
    }
    n /= 2;
    tmp *= tmp;
    tmp %= mod;
  }
  ans--;
  ans -= comb[a];
  ans -= comb[b];
  ans %= mod;
  if(ans<0) ans += mod;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6400
# https://atcoder.jp/contests/cf17-final/tasks/cf17_final_b

s = input()
a = b = c = 0
for i in range(len(s)):
    if s[i] == 'a':
        a += 1
    elif s[i] == 'b':
        b += 1
    else:
        c += 1
if abs(a - b) <= 1 and abs(b - c) <= 1 and abs(c - a) <= 1:
    print('YES')
else:
    print('NO')

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

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
string s;


void test_case() {
	cin >> s;
	int n = s.size();
	int l = 0, r = 0;
	bool ok = false;
	vector<int> arr(28, 0);
	arr[s[0] -'a'] = 1;
	while(r < n) {
		if(r - l > 2) {
			arr[s[l] - 'a'] -= 1;
			l ++;
		} else {
			r ++;
			if(r < n) {
				arr[s[r] - 'a'] += 1;
			}
		}
		if(r - l == 2) {
			for(int i = 0; i <= 27; i ++) {
				if(arr[i] >= 2) {
					ok = true;
					cout << l + 1 << " " << (r == n?r: r + 1);
					break;
				}
			}
		}
	
		debug() << imie(r) imie(l) imie(arr);
		if(ok) break;
	}
	if(!ok) {
		if(r - l > 2) {
				arr[s[l] - 'a'] -= 1;
				l ++;
		}
		if(r - l == 2) {
			for(int i = 0; i <= 27; i ++) {
				if(arr[i] >= 2) {
					ok = true;
					cout << l + 1 << " " << (r == n?r: r + 1);
					break;
				}
			}
		}
	}
	if(!ok) cout << "-1 -1";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1; 
	//scanf("%d", &t);
	while(t --) {
		test_case();
	}
	return 0;
}


Measured memory_bytes: 3676
a,b,c = map(int,input().split())
#a,b,cの中に偶数があれば0, 無かったら最大の数を半分にした数
if a%2 == 0 or b%2 == 0 or b%2 == 0:
    print(0)
    exit()

max_num = max(a,b,c)
num = max_num//2
num2 = max_num - num

if max_num == a:
    print((num2- num)*b*c)
    exit()
if max_num == b:
    print((num2 - num)*a*c)
    exit()
if max_num == c:
    print((num2 - num)*a*b)
    exit()

Measured memory_bytes: 3064
### SNIPPET
  # n = gets.split.map(&:to_i)
  # array = n.times.map { gets.split.map(&:to_i) }
  # [].all?(&:even?)
  # a = [*1..m].repeated_combination(n).to_a
  # [1,2,3,4,5].select { |num| num.even? }  # => [2, 4]
  # ["a","a","b"].group_by(&:itself).map{|k,v| [k, v.count]}.to_h #=> {"a"=>2, "b"=>1}
  # 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
  # 3.upto(6) do |i|, 6.downto(3) do |i|
  # 公約数125.gcd(100)、公倍数125.lcm(100)
  # PI = Math::PI
  # 高さ = a * Math.sin(w / 180.0 * Math::PI), 底辺 = a * Math.cos(w / 180.0 * Math::PI)
  # def chmax(a, b) a > b ? a : b end
  # INF = Float::INFINITY
  # def chmin(a, b) a < b ? a : b end
n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
imos = nil
k.times do
  imos = Array.new(n,0)
  a.each_with_index do |ele,i|
    min = (i-ele) > 0 ? i-ele : 0
    max = (i+ele+1) < n ? i+ele+1 : n
    imos[min] += 1
    imos[max] -= 1 if max < n
  end
  
  a = imos
  0.upto(n-2) do |j|
    a[j+1] += a[j]
  end
  break if a.all?{|x|x==n}
end

puts a.join(" ")




Measured memory_bytes: 80812
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

M = 10**9+7

def pow(a,b,M):
    if b == 0:
        return 1
    elif b % 2 == 0:
        return pow((a**2)%M,b//2,M) % M
    else:
        return ((a % M) * pow((a**2)%M,b//2,M)) % M

def inv(a,p):
    return pow(a,p-2,p)

ans,comb = 0,1
#i番目ではcomb = (K-1-i)_C_(K-1)
#max,min以外での選ぶ個数は常にK-1であることに注目すればcomb関数はいらなかった
for i in range(N-K+1):
    if i > 0:
        comb = (comb * (K-1+i) * inv(i,M)) % M
    ans = (ans + comb*((A[K-1+i]-A[N-K-i]) % M)) % M
print(ans)


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

int main()
{
    int64_t n, k; cin >> n >> k;

    while (n >= abs(n - k))
    {
        if(n/k > 0) {
            n = n%k;
        } else {
            n = abs(n - k);
        }
    }
    
    cout << n << endl;
}

Measured memory_bytes: 3588
#include <cstdio>
#include <algorithm>
 
int replacement[4][2][5] = {
    {{1, 2, 3, 15, 19}, {28, 29, 30, 16, 21}},
    {{7, 8, 9, 13, 10}, {22, 23, 24, 18, 12}},
    {{1, 4, 7, 10, 16}, {24, 27, 30, 21, 18}},
    {{3, 6, 9, 12, 13}, {22, 25, 28, 19, 15}}
};
 
int p[31];
 
bool isComplete(){
    for(int i=1;i<=9;i++){
        if(p[i] != p[1]){return false;}
    }
 
    for(int i=22;i<=30;i++){
        if(p[i] != p[22]){return false;}
    }
 
    for(int i=10;i<=21;i++){
        if(p[i] != p[10+(i-10)/3*3]){return false;}
    }
 
    return true;
}
 
void replace(int index){
    for(int i=0;i<5;i++){
        std::swap(p[replacement[index][0][i]],
                  p[replacement[index][1][i]]);
    }
}
 
int dfs(int t){
    if(isComplete()){return t;}
    if(t >= 8){return 1001001001;}
 
    int res = 1001001001;
    for(int i=0;i<4;i++){
        replace(i);
        res = std::min(res, dfs(t+1));
        replace(i);
    }
 
    return res;
}
     
int main(){
    int N;
    scanf("%d", &N);
 
    while(N--){
        for(int i=1;i<=30;i++){
            scanf("%d", p+i);
        }
 
        printf("%d\n", dfs(0));
    }
}

Measured memory_bytes: 2728
N = 26
D = int(input())
C = [int(i) for i in input().split()]

S = []
for i in range(D):
  s = [int(i) for i in input().split()]
  m = max(s)
  i = s.index(m)
  S.append(i+1)

for i in S:
  print(i)

Measured memory_bytes: 9208
#include <cstdio>
    #include <cmath>
    int n;
    double x[1005], y[1005], X, Y, d, e;
    double dist(double a, double b) {
    	return a*a + b*b;
    }
    int main() {
    	scanf("%d", &n);
    	for (int i = 0; i < n; i++) {
    		scanf("%lf%lf", &x[i], &y[i]);
    		X += x[i]; Y += y[i];
    	}
    	X /= n; Y /= n;
    	double P = 0.1;
    	for (int i = 0; i < 30000; i++) {
    		int f = 0;
    		d = dist(X - x[0], Y - y[0]);
    		for (int j = 1; j < n; j++) {
    			e = dist(X - x[j], Y - y[j]);
    			if (d < e) { d = e; f = j; }
    		}
    		X += (x[f] - X)*P;
    		Y += (y[f] - Y)*P;
    		P *= 0.999;
    	}
    	printf("%.12lf",sqrt(d));
    }

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

void solve()
{
    ll a, b, c;

    std::cin >> a >> b >> c;

    if ((c - a - b) > 0 && 4ll * a * b <  (c - a - b) * (c - a - b))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

int main()
{
//    std::cout << solve() << std::endl;
    solve();

    return 0;
}

Measured memory_bytes: 256
N,k = map(int,input().split())
l = list(map(int,input().split()))
cost = [0] * N

for i in range(1,N):
    temp = []
    cost[i] = min([cost[j]+abs(l[i]-l[j]) for j in range(max(0,i-k),i)])
print(cost[N-1])

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

constexpr int prep = 10;
int64_t dp[(1<<prep)+2][100001];

int main(){
    int n;
    scanf("%d", &n);
    static int64_t v[(1<<18)+2], w[(1<<18)+2];
    static int depth[(1<<18)+2];
    depth[0] = 0;
    for(int i=1;i<=n;++i) depth[i] = depth[i/2] + 1;

    for(int i=1;i<=n;++i){ scanf("%" SCNd64 "%" SCNd64, &v[i], &w[i]); }

    for(int i=1;i<=min(n,(1<<prep)-1);++i){
        for(int j=0;j<=100000;++j) dp[i][j] = dp[i/2][j];
        for(int j=0;j<=100000;++j){
            if(j + w[i] <= 100000) dp[i][j + w[i]] = max(dp[i][j+w[i]], dp[i/2][j] + v[i]);
        }
        for(int j=1;j<=100000;++j) if(dp[i][j-1] > dp[i][j]) dp[i][j] = dp[i][j-1];
    }

    int q;
    scanf("%d", &q);
    while(q--){
        int vv, ll;
        scanf("%d%d", &vv, &ll);
        if(vv < (1<<prep)){ printf("%" PRId64 "\n", dp[vv][ll]); continue; }
        int64_t cand = 0;
        for(int ptn=0;ptn<(1<<depth[vv]-prep);++ptn){
            int ii = vv, p = ptn;
            int64_t we = 0, vl = 0;
            while(depth[ii] > prep){
                if(p & 1){ we += w[ii]; vl += v[ii]; }
                ii /= 2; p /= 2;
                if(we > ll) goto l_ng;
            }
            cand = max(cand, dp[ii][ll-we] + vl);
            l_ng:;
        }
        printf("%" PRId64 "\n", cand);
    }
    return 0;
}

Measured memory_bytes: 808188
#include <iostream>
#include <iomanip>
#include <math.h>
#include <map>
#include <list>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <sstream>
#include <bitset>
#include <string.h>
// #include <limits.h>

#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long        ll;
typedef unsigned long long    ull;

#define INTMAX  99999999

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

int N,M;
#define MAX_N 100000
#define MAX_M 100000

vector<int> counts;
vector<bool> exists;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);

	cin >> N >> M;

	exists.resize(N,false);
	exists[0] = true;
	counts.resize(N,1);

	FOR(i,M) {
		int x,y;
		cin >> x >> y;
		x--;y--;
		if(counts[x]==0) {
		}
		else if(counts[x]==1) {
			if(exists[x]) {
				exists[y] = true;
				exists[x] = false;
			}
			else {
			}
			counts[x]--;
			counts[y]++;
		}
		else {
			if(exists[x]) {
				exists[y] = true;
			}
			else {
			}
			counts[x]--;
			counts[y]++;
		}
		// cout << "---" << endl;
		// FOR(n,N) {
		// 	cout << exists[n] << " ";
		// }
		// cout << endl;
		// FOR(n,N) {
		// 	cout << counts[n] << " ";
		// }
		// cout << endl;
		// cout << "---" << endl;
	}

	int ans = 0;
	FOR(n,N) {
		if(exists[n]) {
			ans++;
		}
	}

	cout << ans <<endl;

	return 0;
}
 


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

int main()
{
	int N,W,T=0;
	while(cin>>W, W)
	{
		cin >> N;
		int dp[1024]={0};

		int v,w; char c;
		for(int i=0; i<N; i++)
		{
			cin>>v>>c>>w;
			for(int j=W-w; j>=0; j--)
			{
				dp[j+w] = max(dp[j+w], dp[j]+v);
			}
		}

		int mi=W;
		for(int i=W; i>=0; i--)
		{
			if(dp[i]!=dp[mi])
			{
				cout << "Case " << ++T << ":\n";
				cout << dp[mi] << "\n" << mi << "\n";
				break;
			}
			mi=i;
		}
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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; }

lli h, n;

int main(void){
    cin >> h >> n;
    vector<lli> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    lli ma = *max_element(a.begin(), a.end());
    vector<lli> dp(h+ma+5, 1e9);
    dp[0] = 0;
    rep(i, h){
        rep(j, n){
            chmin(dp[i+a[j]], dp[i]+b[j]);
        }
    }
    lli ans = 1e18;
    for(int i = h; i <= h+ma; i++){
        ans = min(ans, dp[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3696
#include <stdio.h>
int main(){
  int n,m,c=0;
  char N[50][51],M[50][51];
  scanf("%d%d",&n,&m);
  for(int i=0;i<n;i++)scanf("%s",N[i]);
  for(int i=0;i<m;i++)scanf("%s",M[i]);
  for(int i=0;i<n-m+1;i++){
    for(int j=0;j<n-m+1;j++){
      int f=1;
      for(int k=0;k<m;k++){
        for(int l=0;l<m;l++){
          if(N[i+k][j+l]!=M[k][l])f=0;
        }
      }
      if(f)c=1;
    }
  }
  puts(c==1?"Yes":"No");
  return 0;
}

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

int main(){
  string n;
  cin >> n;

  if( n[1]==n[2] && (n[1]==n[0] || n[1]==n[3])){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int main() {
    int r, D, x2000;
    cin >> r >> D >> x2000;

    ll x = x2000;
    rep(i, 10) {
        x = r * x - D;
        write(x);
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<ctime>
#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
#include<fstream>
#include<complex>
#include<algorithm>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ll long long
using namespace std;
const int INF = 0x3f3f3f3f;
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	ll n;
	cin>>n;
	ll t;
	if(n==1) {cout<<1<<endl;return 0;}
	for(ll i=1;i<=100;i++){
		if((1ll<<i)>n) {t=i;break;} 
	}
	t--;
	ll sum=(1ll<<t)-1;
	//cout<<sum<<endl;
	cout<<sum+(1ll<<t)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0;
#define ll long long

int n, x, ans;
map <int, int> a;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    while(n-- && cin >> x) a[x]++;
    for(auto i : a)
        if(i.second < i.first) ans += i.second;
        else ans += i.second-i.first;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4736
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,a,b = inpl()
res = 0
for i in range(1,n+1):
    tmp = str(i)
    cnt = 0
    for j in tmp:
        cnt += int(j)
    if a <= cnt <= b:
        res += i
print(res)


Measured memory_bytes: 39920
//前置き
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>

using namespace std;

typedef  long long ll;

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)

//関数定義
//最大公約数
ll gcd(ll a, ll b);

//最小公倍数
ll lcm(ll a, ll b);

int main(){
    // ========================================================
    map<string, int> mp;
    mp["SUN"] = 8;
    mp["MON"] = 2;
    mp["TUE"] = 3;
    mp["WED"] = 4;
    mp["THU"] = 5;
    mp["FRI"] = 6;
    mp["SAT"] = 7;
    string s;
    cin >> s;
    if(s == "SUN") cout << 7 << endl;
    else cout << mp["SUN"] - mp[s] << endl;
}

//最大公約数
ll gcd(ll a, ll b) {  
    if (!b)  
        return a;  
    return gcd(b, a%b);  
}

//最小公倍数
ll lcm(ll a, ll b) {  
    return a*b/gcd(a,b);  
} 

Measured memory_bytes: 256
#include <bits/stdc++.h> // Include every standard library
using namespace std;
int dirx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int diry[8] = {0, 1, -1, 0, -1, 1, -1, 1};
#define sqr(x) ((LL)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define ALLA(arr, sz) arr, arr + sz
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define TC(t) while (t--)
#define ms(s, n) memset(s, n, sizeof(s))
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define size(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed << setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vii;
typedef vector<vi> vvi;
const int MOD = (int)1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int)1e9;
const ll LINF = (ll)1e18;
const ld PI = acos((ld)-1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b)
{
    ll r;
    while (b)
    {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
inline ll fpow(ll n, ll k, int p = MOD)
{
    ll r = 1;
    for (; k; k >>= 1)
    {
        if (k & 1)
            r = r * n % p;
        n = n * n % p;
    }
    return r;
}
inline ll isqrt(ll k)
{
    ll r = sqrt(k) + 1;
    while (r * r > k)
        r--;
    return r;
}
inline ll icbrt(ll k)
{
    ll r = cbrt(k) + 1;
    while (r * r * r > k)
        r--;
    return r;
}
inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }
int modulo(int a, int b) { return (a % b + b) % b; }
#define db(x) cerr << #x << " = " << (x) << " ";


int main()
{
    IOS 
    int N, W;
    scanf("%d %d", &N, &W);
    //dp[i]=min weight when sum of values =i
    vi w;
    vi v;
    for (int a = 0; a < N; a++)
    {
        int wgt, val;
        scanf("%d %d", &wgt, &val);
        w.pb(wgt);
        v.pb(val);
    }
    int sum=0;
    sum = accumulate(all(v), sum);
    vl dp(sum + 1, INF);
    dp[0] = 0;
    for (int a = 0; a < N; a++)
    {
        // using push forward dp
        for (int b = sum - v[a]; b >= 0; b--) /*ierating over sumof values that can already be in the knapsack 
        if i pick up an item of value v[a]*/
            dp[b + v[a]] = min(dp[b + v[a]], dp[b] + w[a]);
    }
    ll res = 0;
    for (ll a = 0; a <= sum; a++)
    {
         if(dp[a]<=W)
             res = max(res, a);
    }
        printf("%lld", res);
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    vector<int> a(4);
    a[0] = 0;
    for (int i = 1; i <= 3; ++i) cin >> a[i];
    sort(a.begin(), a.end());

    ll ans = 0;
    do {
        if (a[0] == 0 || a[3] == 0) continue; 
        ll tmp;
        if (a[1] == 0) {
            tmp = a[0] + 10 * a[2] + a[3];
        }
        else {
            tmp = 10 * a[0] + a[1] + a[3];
        }
        ans = max(ans, tmp);
    } while (next_permutation(a.begin(), a.end()));
    cout << ans << endl;
}

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

#define pb push_back
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define SKY ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long int
void solve()
{
    int n;
    cin>>n;
    int a[n];
    for(auto &it: a)
        cin>>it;
    int ans=0;
    sort(a,a+n,greater<int>());
    for(int i=0;i<n;i++)
    {
        int x=a[i];
        for(int j=i+1;j<n;j++)
        {
            int y=a[j];
            for(int k=j+1;k<n;k++)
            {
                int z=a[k];
                if(x!=y and x!=z and y!=z and x<y+z and y<x+z and z<x+y)
                    ans++;
            }
        }
    }
    cout<<ans;
        return;
    
}
int32_t main()
{
    SKY;
    int T = 1;
    //cin >> T;
    for(int i = 1 ; i <= T ; i++)
        solve();
    return 0;
}
/*
 Umang Agrawal
 */


Measured memory_bytes: 3656
n, x = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
dio = 0 #お前は今までに食べたキャンディの数を覚えているのか？
if(a[0] > x):
    dio += a[0] - x
    a[0] = x
for i in range(n - 1):
    extra = a[i] + a[i + 1] - x
    if(extra > 0):
        a[i + 1] -= extra
        dio += extra
print(dio)

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

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;
}


long long solve(long long  h, long long w){
    long long sa, sb, sc;
    
    long long res = 1<<30;
    for (long long i=1; i<h; i++){
        sa = w * i;
        
        sb = ((h-i) / 2) * w;
        sc = (h- i - ((h-i) / 2))*w; 
        
        chmin(res, max({sa, sb, sc}) - min({sa, sb, sc}));

        sb = (h - i) * (w / 2);
        sc = (h - i) * (w - (w/2));
    
        chmin(res, max({sa, sb, sc}) - min({sa, sb, sc}));
    }
    
    return res;
}

int main(void){
    long long h, w;
    cin >> h >> w;
    
    cout << min(solve(h, w), solve(w, h)) << endl;
}


Measured memory_bytes: 3620
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	x := getNextInt(scanner)
	y := getNextInt(scanner)
	z := getNextInt(scanner)
	x, y = y, x
	x, z = z, x
	fmt.Fprintln(writer, x)
	fmt.Fprintln(writer, y)
	fmt.Fprintln(writer, z)
}


Measured memory_bytes: 640
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = iss()
    print('x'*len(S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {
	
	int n, k;
	scanf("%d%d", &n, &k);
	printf("%d\n", n - k + 1);
	
	Please AC;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define mod 1e9+7
vector<int>dp; 

int min_cost(int b[],int n,int k){
	//cout<<n<<" ";
         if(n==0){
		   dp[n]=b[n]; 
		   return 0;}
		   
		 if(dp[n] !=-1)
         return dp[n];
         
         int sum=INT_MAX;
         for(int i=1; i<=k; i++){
			
		      if(n>=i){
			   sum=min(sum,abs(b[n]-b[n-i])+min_cost(b,n-i,k) ); 
			  }
		 }
            
           return dp[n]=sum;
                          
         

}
               
int main(){
      ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);    
          int n,k;
             cin>>n>>k;
             dp.resize(n+1);
             for(int i=0; i<=n; i++)
               dp[i]=-1;
        //     memset(dp,-1,sizeof(dp));
        
             int b[n];
             for(int i=0; i<n; i++)
                cin>>b[i];
                
          cout<<min_cost(b,n-1,k)<<endl; 
        //  min_cost_using_taabulation(n,b,k);
    }
    /*void min_cost_using_taabulation(int n,int b[],int k)
          dp[0]=0;
            dp[1]=abs(b[1]-b[0]);
            for(int i=2;i<n; i++){
			  
			   dp[i]=min( abs(b[i]-b[i-1])+dp[i-1],abs(b[i]-b[i-2])+dp[i-2]);
			   //cout<<dp[i]<<" ";
			  
			}
         
            cout<<dp[n-1]<<endl;
}
 */
//a z q !


Measured memory_bytes: 8832
#include <iostream>
#include <cstdio>

using namespace std;

int A[101], n;

void print () {
  for (int i = 0; i < n; i++)
    if (i == n - 1)
      cout << A[i] << endl;
    else
      cout << A[i] << " ";
}

void insertionSort () {
  int temp, j;
  
  for (int i = 1; i < n; i++) {
    print();

    temp = A[i];
    j = i - 1;

    while (j >= 0 && A[j] > temp) {
      A[j + 1] = A[j];
      j--;
    }

    A[j + 1] = temp;
  }
}

int main () {
  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }

  insertionSort();
  print();

  return 0;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

int sum[20*M], lef[20*M], rgt[20*M], NEXT_FREE_INDEX = 1;
int inp[M], lap[M], root[20*M], ar[M], otp[M], tp[M], ls[M];
void build(int l,int h,int id)
{
	sum[id] = 0;
	if(l == h)
		return;
	int mid = l + (h-l)/2;
	lef[id] = NEXT_FREE_INDEX ++;
	rgt[id] = NEXT_FREE_INDEX ++;
	build(l,mid,lef[id]);
	build(mid+1,h,rgt[id]);
	sum[id] = sum[lef[id]] + sum[rgt[id]];
}
int update(int l,int h,int p,int v,int id)
{
	int ID =  NEXT_FREE_INDEX ++;
	sum[ID] = sum[id] + 1; // for count keeping persistent tree
	if(l == h)
	{
		//sum[ID] = (ar[p] += v); // for adding persistent tree
		return ID;
	}	
	int mid = l + (h-l)/2;
	lef[ID] = lef[id];
	rgt[ID] = rgt[id];
	if(p <= mid)
		lef[ID] = update(l,mid,p,v,lef[ID]);
	else
		rgt[ID] = update(mid+1,h,p,v,rgt[ID]);
	//sum[ID] = sum[lef[ID]] + sum[rgt[ID]]; // for adding persistent tree
	return ID;
}
int query(int l,int h,int ql,int qh,int id,int ID)
{
	// for count array
	// returns the count of elements between ql and qh between id and ID
	if(l >= ql && h <= qh)
		return sum[ID]-sum[id];
	else if(l > qh || h < ql)
		return 0;
	int mid = l + (h-l)/2;
	return query(l,mid,ql,qh,lef[id],lef[ID]) + query(mid+1,h,ql,qh,rgt[id],rgt[ID]); 
}
int getk(int l,int h,int k,int id,int ID)
{
	// get kth element in the range (ql..qr) : id = root[ql-1] , ID = root[qr]
	if(l == h)
		return l;
	int lc = sum[lef[ID]]-sum[lef[id]];
	int mid = l+(h-l)/2;
	if(lc >= k)
		return getk(l,mid,k,lef[id],lef[ID]);
	else
		return getk(mid+1,h,k-lc,rgt[id],rgt[ID]);
}

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

	ll n,q,i,l,r;

	cin >> n >> q;
	for(i=1;i<=n;++i)
		cin >> tp[i];
	for(i=1;i<=n;++i)
		ls[i] = n+1;
	for(i=n;i>=1;i--)
	{
		ar[i] = ls[tp[i]];
		ls[tp[i]] = i;
	}

	build(0,n+1,0);
	for(i=1;i<=n;++i)
		root[i] = update(0,n+1,ar[i],i,root[i-1]);
	while(q--)
	{
		cin >> l >> r;
		ll last = r+1-l-query(0,n+1,0,r,root[l-1],root[r]);
		cout << last << "\n";
	}
 
	return 0;
}



	

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

using namespace std;

vector<string> text;
string buf;
int cux, cuy;

void edit(char cmd)
{
	switch(cmd){
		case 'a':
			cux = 0;
			break;
		
		case 'e':
			cux = text[cuy].size();
			break;
			
		case 'p':
			if(cuy > 0)
				--cuy;
			cux = 0;
			break;
			
		case 'n':
			if(cuy < text.size()-1)
				++cuy;
			cux = 0;
			break;
			
		case 'f':
			if(cux < text[cuy].size())
				++cux;
			else if(cuy < text.size()-1){
				cux = 0;
				++cuy;
			}
			break;
			
		case 'b':
			if(cux > 0)
				--cux;
			else if(cuy > 0){
				--cuy;
				cux = text[cuy].size();
			}
			break;
			
		case 'd':
			if(cux == text[cuy].size()){
				if(cuy < text.size()-1){
					text[cuy] += text[cuy+1];
					for(int i=cuy+1 ; i<text.size()-1 ; ++i)
						text[i] = text[i+1];
					text.pop_back();
				}
			}else
				text[cuy].erase(cux, 1);
			break;
			
		case 'k':
			if(cux == text[cuy].size()){
				if(cuy < text.size()-1){
					edit('d');
					buf = "\n";
				}
			}else{
				buf = text[cuy].substr(cux, text[cuy].size()-cux);
				text[cuy] = text[cuy].substr(0, cux);
			}
			break;
			
		case 'y':
			if(buf != ""){
				if(buf == "\n"){
					text.push_back(text[text.size()-1]);
					for(int i=text.size()-2 ; i>cuy ; --i)
						text[i+1] = text[i];
					text[cuy+1] = text[cuy].substr(cux, text[cuy].size()-cux);
					text[cuy] = text[cuy].substr(0, cux);
					++cuy;
					cux = 0;
				}else{
					text[cuy] = text[cuy].substr(0, cux) + buf + text[cuy].substr(cux, text[cuy].size()-cux);
					cux += buf.size();
				}
			}
			break;
	}
}

int main()
{
	for(;;){
		string str;
		getline(cin, str);
		if(str == "END_OF_TEXT")
			break;
		text.push_back(str);
	}
	
	char cmd;
	while(cin>>cmd, cmd!='-')
		edit(cmd);
	
	for(int i=0 ; i<text.size() ; ++i)
		cout << text[i] << endl;
	
	return 0;
}

Measured memory_bytes: 0
n=int(input())
a=[[]]
for i in range(n-1):
    c,s,f=map(int,input().split())
    a.append((c,s,f))

for i in range(1,n+1):
    ans=0
    for j in range(i,n):
        c,s,f=a[j]
        if ans<s:
            ans=s
        else:
            ans+=0 if ans%f==0 else f-ans%f
        ans+=c
    print(ans)

Measured memory_bytes: 43628
n,k = list(map(int, input().split()))
a=list(map(int, input().split()))
x=0
ans = 0
for i in range(45,-1,-1):
  c=0
  for p in a:
    if (p >> i) & 1:
      c += 1
  if n - c > c and x + (1<<i) <= k:
    ans += (n-c) * (1<<i)
    x += 1<<i
  else:
    ans += c * (1<<i)
print(ans)


Measured memory_bytes: 14176
#include<iostream>
#include<algorithm>
using namespace std;
struct m{
  int v;
  int p;
};
//bool compare(m a, m b){return a.v < b.v}
int main()
  {
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
  	cin >> n;
    /*bool b[n]={false};
  	m a[n];*/
  int a[n];
  	for(int i = 0; i < n;i++)
    {
      /*cin >> a[i].v;
      a[i].p=i;*/
      cin >> a[i];
    }
  int nb=0;
  for(int i = 1; i < n-1; i++)
  {
    if((a[i]>a[i-1] && a[i]<a[i+1]) || (a[i]<a[i-1] && a[i]>a[i+1]))
      nb++;
  }
    cout << nb << '\n';
  }
                                              

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

int main() {
	int n, r[810], ans = 1;
	cin >> n;
	for (int i = 0;i<n; i++) {
		cin >> r[i];
	}
	sort(r, r + n);
	for (int i = 1; i < n; i++) {
		if (r[i] > r[i - 1]) {
			ans++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256