akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
inline void read(int &x){
	x=0;static char ch;static bool flag;flag = false;
	while(ch=getchar(),ch<'!');if(ch == '-') ch=getchar(),flag = true;
	while(x=10*x+ch-'0',ch=getchar(),ch>'!');if(flag) x=-x;
}
#define rg register int
#define rep(i,a,b) for(rg i=(a);i<=(b);++i)
#define per(i,a,b) for(rg i=(a);i>=(b);--i)
const int maxn = 200010;
int a[maxn],ws[maxn],num[maxn];
int main(){
	int n,m;read(n);read(m);
	rep(i,1,n) read(a[i]),ws[a[i]] ++ ;
	int ans = 0;
	rep(i,1,n) if(ws[i]){
		num[max(i-ws[i]+1,1)] ++ ;
		num[min(i+1,n+1)] -- ;
	}
	rep(i,1,n) num[i] += num[i-1],ans += (num[i] == 0);
	while(m--){
		int t,y,x;read(t);read(y);
		x = a[t];a[t] = y;
		if((x-ws[x]+1) >= 1 && (x-ws[x]+1) <= n){
			if(-- num[x-ws[x]+1] == 0) ++ ans;
		}-- ws[x];++ ws[y];
		if((y-ws[y]+1) >= 1 && (y-ws[y]+1) <= n){
			if(++ num[y-ws[y]+1] == 1) -- ans;
		}printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 3712
#include<stdio.h>

int main()
{
  int a, b, c, i, count=0;

  scanf("%d%d%d", &a, &b, &c);

  for(i = a; i <= b; i++){
    if(c % i == 0) count++;
  }

  printf("%d\n", count);

  return 0;
}

Measured memory_bytes: 596
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
PII arr[MAXN];
int main(){
	//~ #ifndef ONLINE_JUDGE
    //~ freopen("file.in", "r", stdin);
	//~ #endif		
	int n;
	ll k;
	scanf("%d%lld",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&arr[i].ff,&arr[i].ss);
	sort(arr+1,arr+n+1);
	for(int i=1;i<=n;i++){
		if(arr[i].ss<k){
			k-=arr[i].ss;
			continue;
		}
		printf("%d\n",arr[i].ff);
		break;
	}
	return 0;
}


Measured memory_bytes: 1024
n = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
l = make_divisors(n)
if l[len(l)//2]**2 == n:
    print(l[len(l)//2]*2-2)
else:
    print(l[len(l)//2-1]+l[len(l)//2]-2)


Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
const int INF = 1 << 29;
const ll LINF = 1l << 61;
const ld PI = abs(acos(-1));
#define pq priotity_queue
#define P pair<int, int>
#define P2 pair<int, P>
#define P3 pair<int, P2>
#define fr(i, a, b) for (int i = a; i < b; i++)    //[a, b)
#define frr(i, a, b) for (int i = b; i >= a; i--)  //[a, b]
#define rp(i, b) for (int i = 0; i < b; i++)       //[0, b)
#define rrp(i, b) for (int i = b; i >= 0; i--)     //[0, b]
#define cbuf(buf, init) memset(buf, init, sizeof(buf))

ll N;

int main()
{
    //
    cin >> N;
    if (N == 0) {
        cout << 2 << endl;
    }
    else if (N == 1) {
        cout << 1 << endl;
    }
    else {
        ll l = 2, r = 1;
        fr(i, 2, N)
        {
            ll t = l + r;
            l = r;
            r = t;
        }
        cout << l + r << endl;
    }
}


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

string T = "357";
Int N; 

// sで始まる753数の個数
int dfs(string S){
    if(S != "" && stoll(S) > N) return 0;

    int res = 0;

    vector<bool> flag(3, false);
    rep(i, S.length())rep(j, 3){
        if(S[i] == T[j]) flag[j] = true;
    }
    if(flag[0] && flag[1] && flag[2]) res++;

    rep(i, 3) res += (dfs(S+T[i]));
    return res;
}

int main(){
    cin >> N;
    cout << dfs("") << endl;
}

Measured memory_bytes: 256
n,aa,bb = list(map(int, input().split()))

a = max(aa,bb)
b = min(aa,bb)
p = 1000000007

xs0 = [0]*(n+1)
os0 = [0]*(n+1)

os0[0] = 1

for i in range(b,a-1):
    for j in range(b,i+1):
        xs0[i] += os0[i-j]
        xs0[i] %= p
    for j in range(1,i+1):
        os0[i] += xs0[i-j]
        os0[i] %= p


#print(xs0[:50])
#print(os0[:50])

os = [0]*a

for i in range(b,a-2): #number-x
    for j in range(2,a-i): # adding o
        os[i+j] += xs0[i] * (j-1)

x = [0]*(n+1)
o = [0]*(n+1)

for i in range(b+1,a): # adding distination
    for j in range(b,i): # length of xs
        o[i] += xs0[j]
        o[i] %= p

x[0] = 1
o[0] = 1

for i in range(1,n+1):
    for j in range(1,min(b,i+1)):
        x[i] += o[i-j]
    for j in range(1,min(a,i+1)):
        o[i] += x[i-j]
    for j in range(b+2,min(a,i+1)):
        o[i] += x[i-j]*os[j]
    x[i] %= p
    o[i] %= p

for i in range(b+1,a):
    for j in range(b,i):
        o[n] += xs0[j] * x[n-i]
        o[i]%=p

ans = o[n] + x[n]
ans %= p

#print(ans)

beki2 = [1]*5001

for i in range(5000):
    beki2[i+1] = beki2[i]*2
    beki2[i+1] %= p

ans = beki2[n] - ans
ans += p
ans %= p

print(ans)









































Measured memory_bytes: 70140
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define ll long long
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define vi vector<int>
#define pii pair<int, int>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;
template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
#define pt complex<double>

int a, b, h, m;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> a >> b >> h >> m;
    pt p1 = polar(1.0 * a, (h + m / 60.0) * 2 * M_PI / 12.0);
    pt p2 = polar(1.0 * b, m * 2 * M_PI / 60.0);
    cout << fixed << setprecision(10);
    cout << abs(p1 - p2) << '\n';
}

Measured memory_bytes: 4104
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define printx(x) printf("%lld\n",x);
#define printxy(x,y) cout << x << y <<endl;
#define printxyz(x,y,z) cout << x << y << z <<endl;
#define deba(a) cout << #a << a << endl;
#define debab(a,b) cout << #a << a << #b << b << endl;
int main()
{
	fast;
	ll a, b, c;
	cin >> a >> b >> c;
	if (a == 5 and b == 5 and c == 7)
		cout << "YES" << endl;
	else if (a == 5 and b == 7 and c == 5)
		cout << "YES" << endl;
	else if (a == 7 and b == 5 and c == 5)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}

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

int main() {
int N,K;
cin >>N>>K;
int counter=0;
 vector<int> h(N);
 for(int i=0;i<N;i++){
 cin >>h.at(i);
 
 if(h.at(i)>=K){
 counter++;
 }
 }
 
 cout << counter <<endl;
 
}




Measured memory_bytes: 640
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18

N, M = map(int, raw_input().split())
cost = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}
A = sorted(map(int, raw_input().split()))

DP = [0] + [-1] * N
ans = [0, 0] * N

for i in range(1, N + 1):
    for j in A:
        pos = i - cost[j]
        if pos < 0 or DP[pos] < 0:
            continue
        if DP[i] <= DP[pos] + 1:
            DP[i] = DP[pos] + 1
            ans[i] = j

S = ""
pos = N
while pos:
    S += str(ans[pos])
    pos -= cost[ans[pos]]

print S

Measured memory_bytes: 3576
var
	s,t:ansistring;
	a,b:array['a'..'z'] of char;
	fs,ft:array['a'..'z'] of boolean;
	i,l:longint;
procedure cant;
begin
	writeln('No');
	halt;
end;
begin
	readln(s); readln(t);
	l:=length(s);
	fillchar(fs,sizeof(fs),true);
	fillchar(ft,sizeof(ft),true);
	for i:=1 to l do
	begin
		if fs[s[i]] then
		begin	
			fs[s[i]]:=false;
			a[s[i]]:=t[i];
		end
		else if a[s[i]]<>t[i] then cant;
		if ft[t[i]] then 
		begin
			ft[t[i]]:=false;
			b[t[i]]:=s[i];
		end
		else if b[t[i]]<>s[i] then cant;
	end;
	writeln('Yes');
end.

Measured memory_bytes: 512
Option Explicit On
Imports System

Module Program
    Sub Main(args As String())

        Dim tmp As String() = Split(Console.ReadLine(), " ")

        Dim X As Integer = CInt(tmp(0))
        Dim N As Integer = CInt(tmp(1))

        If N = 0 Then
            Console.WriteLine(X)
            Exit Sub
        End If

        Dim tmp2 As String() = Split(Console.ReadLine(), " ")

        Dim P As New List(Of Integer)

        For i As Integer = 0 To N - 1
            P.Add(tmp2(i))
        Next

        Dim min As Integer = 1000
        Dim ans As Integer = 0

        For i As Integer = 0 To 101
            Dim wk As Integer = Math.Abs(i - X)
            If Not P.Contains(i) Then
                If min > wk Then
                    min = wk
                    ans = i
                End If
            End If
        Next

        Console.WriteLine(ans)

    End Sub
End Module


Measured memory_bytes: 28644
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y-1);(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()

#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
//template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

typedef vector<vector<pii>> Graph;
int haji[1123];

ll dfs(int v,int p,Graph &g,int a){
  ll re=0;
  int f=0;
  for(pii w:g[v])
    if(w.X!=p){
      f=1;
      ll tmp=dfs(w.X,v,g,w.Y);
      re=max(re,tmp+w.Y);
    }
  if(!f){
    re-=a;
    haji[v]=1;
  }
  return re;
}

ll memo[1123][1123];

ll solve(int v,int p,Graph &g){
  if(memo[v][p]) return memo[v][p];
  ll re=0,sum=0;
  for(pii w:g[v])
    if(w.X!=p){
      re+=solve(w.X,v,g);
      if(haji[w.X])
	re+=w.Y;
      else
	re+=w.Y*3;
    }
  //  cout<<v<<","<<p<<":"<<re<<","<<sum<<endl;
  return memo[v][p]=re;
}

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n;
  while(cin>>n){
    if(!n)break;
    memset(memo,0,sizeof(memo));
    memset(haji,0,sizeof(haji));
    vector<int> ps(n-1);
    rep(i,n-1)
      cin>>ps[i];
    Graph g(n);
    int v;
    ll sum=0;
    rep(i,n-1){
      cin>>v;
      sum+=v;
      --ps[i];
      g[i+1].eb(ps[i],v);
      g[ps[i]].eb(i+1,v);
    }
    //cout<<g;
    sum*=2;
    ll d=1e15,re=1e15;
    vector<ll> a(n);
    rep(i,n) a[i]=dfs(i,-1,g,0);
    rep(i,n){
      re=min(re,solve(i,n,g)-a[i]);
    }
    //    rep(i,n+1){rep(j,n+1)cout<<memo[i][j]<<",";cout<<endl;}
    cout<<re<<endl;
  }
  return 0;
}

Measured memory_bytes: 11196
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xs = readLine()!!.split(' ').map { it.toInt() }

    val ans = IntArray(9)
    for (x in xs) {
        val i = x / 400
        if (i >= 8) {
            ans[8]++
        } else {
            ans[i] = 1
        }
    }

    println("${ans.take(ans.size - 1).sum().let { if (it == 0) 1 else it }} ${ans.sum()}")
}


Measured memory_bytes: 36356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int A1, A2, A3;

int main() {
  cin >> A1 >> A2 >> A3;
  cout << (A1 + A2 + A3 >= 22 ? "bust" : "win") << endl;
  return 0;
}


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

int main() {
  int a, b; cin >> a >> b;
  int ans = 0;
  for (int i = a; i <= b; ++i) {
    string s = to_string(i);
    if (s[0] == s[4] and s[1] == s[3]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c,d;
	scanf("%d%d%d",&a,&b,&c);
	d=(a!=b)+(b!=c)+(c!=a);
	if(d==0)
	{
		printf("1");
	}
	else
	{
		printf("%d",d);
	}
	return 0;
 }  

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <queue>
#include <cstdlib>

using namespace std;

#define LL long long
#define INF 0x7fffffff
#define P 998244353

inline LL read(){
    LL x=0,f=1; char ch=getchar();
    while (ch<'0' || ch>'9') {if (ch=='-') f=-1; ch=getchar();}
    while (ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
int a[1000010];
int main(){

	// int t =read();
	// while (t--){
	// 	int n=read();

	// 	for (int i=1; i<=n; i++) a[i]=read();
	// 		int cnt0=0,cnt1=0,cnt2=0;
	// 	for (int i=1; i<=n; i++) if (a[i]%3==0) cnt0++;
	// 		else if (a[i]%3==1) cnt1++;
	// 	else if(a[i]%3==2) cnt2++;
	// 	if (cnt2<cnt1) swap(cnt2,cnt1);
	// 	int t = cnt2 -cnt1;
	// 	int ans=cnt0+cnt1+t/3;
	// 	printf("%d\n",ans);
	// }


	LL  K=read(),A=read(),B=read();
	if (B<=A+2 || K<=A){
		printf("%d\n",K+1);
		return 0;
	}
	LL t = K-(A-1);
	LL p = t/2;
	// cout<<p<<endl;
	LL ans = A+ p*(B-A)+(t%2);
	// cout<<t<<endl;

	// LL t = (1LL*A*K-1)/(A+1);
	// LL ans= (1LL+t)-(1LL+t)/A*A + (1LL+t)/A*B;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int a[110];
int main()
{
	int n,m;
	int i;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++) scanf("%d",&a[i]);
	sort(a,a+n);
	for(i=0;i<n;i++)
	if(a[i]<=m) m-=a[i];
	else break;
	if(i==n && m!=0) i--;
	printf("%d",i);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int M=1e6+5;

int cnt=0,c2=0,c3=1,types[M];
long long prime[M],a,b,g,divs[M],tot=0;
bool isp[M];

void sieve(int p){
	memset(isp,true,sizeof(isp));
	isp[0]=isp[1]=false;
	for (int i=2;i<=p;i++){
		if (isp[i]){
			prime[++cnt]=i;
		}
		for (int j=1;j<=cnt && i*prime[j]<=p;j++){
			isp[i*prime[j]]=false;
			if (i%prime[j]==0) break;
		}
	}
}
long long gcd(long long a,long long b){
	return b==0?a:gcd(b,a%b);
}

int main(){
	sieve(1000000);
	cin>>a>>b;
	g=gcd(a,b);
	for (int i=1;i<=cnt;i++){
		while (g%prime[i]==0){
			divs[++c2]=prime[i];
			g/=prime[i];
		}
	}
	if (g!=1) divs[++c2]=g;
	long long os=0;
	for (int i=1;i<=c2;i++){
		if (divs[i]!=os){
			os=divs[i];
			c3++;
			types[c3]=1;
		} else {
			types[c3]++;
		}
	}
	cout<<c3;
	return 0;
}


Measured memory_bytes: 5212
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#ifdef __has_include
  #if __has_include(<boost/version.hpp>)
    #include <boost/range.hpp>
    #include <boost/range/irange.hpp>
    #include <boost/range/adaptors.hpp>
    #include <boost/range/algorithm.hpp>
    #include <boost/range/algorithm_ext.hpp>
    using namespace boost;
    using namespace boost::adaptors;
  #endif
#endif

auto init_ = []{
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed;
	return 0;
}();

template <typename T>
inline T in() {
    T x;
    std::cin >> x;
    return x;
}

template <typename T, typename U = std::vector<T>>
inline U in(int n) {
    U v(n);
    for(int i = 0; i < n; ++i) {
        std::cin >> v[i];
    }
    return v;
}

template <typename T, typename U = std::vector<T>, typename V = std::vector<U>>
inline V in(int h, int w) {
    V vv(h, U(w));
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j) {
            std::cin >> vv[i][j];
        }
    }
   return vv;
}

template <typename T>
inline void out(const T& x) {
	std::cout << x << std::endl;
}

template <char delimiter = ' ', typename T, typename... Ts>
inline void out(const T& t, const Ts&... ts) {
	std::cout << t << delimiter;
	out(ts...);
}

template <char delimiter = ' ', typename T>
inline void vout(const T& v, int n) {
	for(int i = 0; i < n; ++i) {
		if(i) std::cout << delimiter;
		std::cout << v[i];
	}
	std::cout << std::endl;
}


int main() {

    typedef long long ll;

    auto n = in<ll>();
    auto t = in<ll>(n);
    auto a = in<ll>(n);

    if(t.back() != a.front()) {
        out(0);
        return 0;
    }

    vector<ll> f1(n), f2(n), mini(n, 1LL << 53);
    
    f1[0] = t[0];
    for(int i = 1; i < n; ++i) {
        if(t[i] != t[i - 1]) {
            f1[i] = t[i];
        }

        mini[i] = min(mini[i], t[i]);
    }

    f2[n - 1] = a[n - 1];
    for(int i = n - 2; i >= 0; --i) {
        if(a[i] != a[i + 1]) {
            f2[i] = a[i];
        }

        mini[i] = min(mini[i], a[i]);
    }

    for(int i = 0; i < n; ++i) {
        if((f1[i] != 0 && t[i] > a[i]) || (f2[i] != 0 && a[i] > t[i])){
            out(0);
            return 0;
        }

        if(f1[i] != 0 && f2[i] != 0 && f1[i] != f2[i]) {
            out(0);
            return 0;
        }
    }


    ll ans = 1;
    const ll mod = 1000000000 + 7;

    for(int i = 1; i < n - 1; ++i) {
        if(f1[i] == 0 && f2[i] == 0) {
            ans *= mini[i];
            ans %= mod;
        }
    }

    out(ans);
}

Measured memory_bytes: 4224
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int numN = inpt[0];
        int arrLen = inpt[1];
        int diff = inpt[2];

        decimal heikinDiff = 0;
        if(diff == 0) {
            decimal hit1 = numN;
            heikinDiff = (hit1 / numN) / numN * (arrLen - 1);
        }
        else if(numN >= diff * 2) {
            decimal hit1 = diff * 2;
            decimal hit2 = numN - hit1;
            heikinDiff = ((hit1 / numN) + (hit2 * 2 / numN)) / numN * (arrLen - 1);
        } else {
            decimal hit1 = numN - (numN - diff) * 2;
            decimal hit0 = numN - hit1;
            heikinDiff = (hit1 / numN) / numN * (arrLen - 1);
        }
        Console.WriteLine(heikinDiff);
    }



    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"


2 3 1


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 13524
(* O(n log n) *)
open Printf;;
Scanf.scanf " %d" @@ fun n ->
  let g = Array.make n [] in
  for _ = 1 to n - 1 do
    Scanf.scanf " %d %d" @@ fun u v ->
      let u, v = u - 1, v - 1 in
      g.(u) <- v :: g.(u);
      g.(v) <- u :: g.(v);
  done;
  let cs = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ (+) 0 in
  Array.sort (fun x y -> y - x) cs;
  let ans = Array.make n 0 in
  let i = ref 0 in
  let rec dfs v p =
      ans.(v) <- cs.(!i);
      incr i;
      let f j v2 = if v2 <> p then dfs v2 v in
      List.iteri f g.(v) in
  dfs 0 @@ -1;
  Array.fold_left (+) 0 cs - cs.(0) |> printf "%d\n";
  printf "%d" ans.(0);
  Array.sub ans 1 @@ n - 1 |> Array.iter @@ printf " %d";
  print_newline ()

Measured memory_bytes: 5376
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import perm
# from scipy.misc import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

########

N = i_inpl()
H = l_inpl()

ans = 0
max_val = -INF
for Hi in H:
    if Hi >= max_val:
        ans += 1
    max_val = max(max_val, Hi)
print(ans)

Measured memory_bytes: 3700
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int N, M; cin >> N >> M; int ans[N] = {};
  rep(i, M){
    int s, c; cin >> s >> c; s--;
    if(s==0 && c==0 && N!=1){
      cout << -1 << endl; return 0;
    }
    if(ans[s]!=0 && ans[s]!=c){
      cout << -1 << endl; return 0;
    }
    ans[s]=c;
  }
  rep(i, N){
    if(i==0 && ans[0]==0 && N!=1) cout << 1;
    else cout << ans[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,t,c1,t1,mc,i;
	scanf("%d %d",&n,&t);
	mc=9999;
	for(i=0;i<n;i++)	{
		scanf("%d %d",&c1,&t1);
		if(t1<=t)	mc=min(mc,c1);
	}
	if(mc!=9999)	printf("%d\n",mc);
	else printf("TLE\n");
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

const int LIM=1000010;

bool sosu[LIM];
int ok[LIM];

int main() {
	int i,j;
	for(i=0;i<LIM;i++){
		sosu[i]=true;
	}
	sosu[0]=sosu[1]=false;
	for(i=0;i<LIM;i++){
		if(sosu[i]){
			for(j=i*2;j<LIM;j+=i){
				sosu[j]=false;
			}
		}
	}
	int n,x;
	while(n=in(),x=in()){
		int c;
		memset(ok,0,sizeof(ok));
		ok[0]=1;
		for(i=0;i<n;i++){
			cin>>c;
			for(j=c;j<LIM;j++){
				if(ok[j-c]){
					ok[j]=1;
				}
			}
		}
		for(;!sosu[x]||!ok[x];){
			x--;
			if(x==0)break;
		}
		if(x==0)cout<<"NA\n";
		else cout<<x<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

// namespace
using namespace std;
namespace mp = boost::multiprecision;

// types
using pii = pair<int, int>;
using ll = long long int;
using ld = long double;
using mpi = mp::cpp_int;
using mpf = mp::number<mp::cpp_dec_float<1024>>;

string str;

bool isP(string s, int i, int j) {
    for (int a = 0, b = j - 1; a < b; ++a, --b) {
        // cout << a << " " << s[a] << " " << b << " " << s[b] << endl;
        if (s[a] != s[b]) return false;
    }
    return true;
}

int main() {
    cin >> str;
    int n = str.size();
    if (isP(str, 0, n) && isP(str, 1, (n-1)/2) && isP(str, (n+3)/2, n)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  int a[n];
  int count=0;
  int count_zero=0;
  for(int i=0; i<n; i++){
    cin >> a[i];
    if(a[i] < 0) count++;
    else if(a[i] == 0) count_zero++;
  }
  sort(a, a+n);
  long long ans=0;
  if(count_zero>0){
    for(int i=0; i<count; i++){
      ans -= a[i];
    }
    for(int i=count; i<n; i++) ans += a[i];
  }
  else{
    if(count%2 == 1){
      for(int i=0; i<count-1; i++) ans -= a[i];
      for(int i=count-1; i<n; i++) ans += a[i];
      if(count<n) ans = max(ans, ans-2*a[count-1]-2*a[count]);
    }
    else{
      for(int i=0; i<count; i++) ans -= a[i];
      for(int i=count; i<n; i++) ans += a[i];
    }
  }
  cout << ans << endl;
  return 0;
}

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

void solve() {
	map<char, int> alphabets; // 各アルファベットとその出現回数を記録する辞書
	string s; cin >> s; // 入力文字列

	// 入力文字列を前から読んでいき, 各アルファベットの個数をカウントする
	rep(i, s.size()) alphabets[s[i]]++;

	// 辞書内を探索していく, 一つでも奇数個のアルファベットがあれば美しくない(=No)
	bool beautiful = true;
	for (auto & it : alphabets) {
		if (it.second % 2 != 0) { // 奇数個のアルファベットが見つかった!
			beautiful = false;
			break;
		}
	}

	// 答え出力
	cout << (beautiful ? "Yes" : "No") << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int x, y, z, k; cin >> x >> y >> z >> k;
	long long int a[1005], b[1005], c[1005];
	vector<long long int> ab, abk, ans;
	for(int i=0;i<x;i++){
		cin >> a[i];
	}
	for(int i=0;i<y;i++){
		cin >> b[i];
	}
	for(int i=0;i<z;i++){
		cin >> c[i];
	}
	for(int i=0;i<x;i++){
		for(int j=0;j<y;j++){
			ab.push_back(a[i]+b[j]);
		}
	}
	sort(ab.begin(), ab.end());
	reverse(begin(ab), end(ab));
	int l = min(x*y,k);
	for(int i=0;i<l;i++){
		abk.push_back(ab[i]);
	}
	for(int i=0;i<l;i++){
		for(int j=0;j<z;j++){
			ans.push_back(ab[i]+c[j]);
		}
	}
	sort(ans.begin(), ans.end());
	reverse(begin(ans), end(ans));
	for(int i=0;i<k;i++){
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 42884
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#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__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
const int nax=307;
ll mod;

int n, k;

ll kom[nax][nax];

ll mag[nax];
ll dppom[nax][nax];
ll dpsum[nax][nax];


int main()
{
	scanf("%d%d%lld", &n, &k, &mod);
	for (int i=0; i<nax; i++)
	{
		kom[i][0]=1%mod;
		for (int j=1; j<=i; j++)
			kom[i][j]=(kom[i-1][j]+kom[i-1][j-1])%mod;
	}
	for (int i=0; i<=k; i++)
	{
		dppom[0][i]=1;
		dpsum[0][i]=k-i+1;
	}
	for (int i=1; i<=n; i++)
	{
		for (int j=k; j>=0; j--)
		{
			for (int g=0; g<i; g++)
			{
				//~ for (int l=j+1; l<=k; l++)
				//~ {
					//~ dppom[i][j]=(dppom[i][j]+((dppom[g][l]*dppom[i-1-g][j])%mod)*kom[i-1][g])%mod;
				//~ }
				dppom[i][j]=(dppom[i][j]+((dpsum[g][j+1]*dppom[i-1-g][j])%mod)*kom[i-1][g])%mod;
			}
			dpsum[i][j]=(dpsum[i][j+1]+dppom[i][j])%mod;
		}
	}
	printf("%lld\n", dppom[n][0]);
	return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

const int mod = 1000000007;
struct mint {
ll x; // typedef long long ll;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
}
mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
}
mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
mint operator+(const mint a) const { return mint(*this) += a;}
mint operator-(const mint a) const { return mint(*this) -= a;}
mint operator*(const mint a) const { return mint(*this) *= a;}
mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
}
// for prime mod
mint inv() const { return pow(mod-2);}
mint& operator/=(const mint a) { return *this *= a.inv();}
mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

ll f(ll l, ll r){
    return (r+l)*(r-l+1) / 2;
}

int main(){
    int n, k;
    cin >> n >> k;
    mint ans = 0;
    for(int i = k; i <= n+1; i++){
        ll minNum = f(0, 0+i-1);
        ll maxNum = f(n-i+1, n);
        ans += (maxNum - minNum)+1;
    }
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  ll A, B; cin >> A >> B;
  if ((A+B)%2 == 0) cout << (A+B)/2 << endl;
  else cout << "IMPOSSIBLE" << endl;
}

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

int main(){
    int s,h,m;

    cin >> s;

    h = s / 3600;
    s = s - 3600 * h;
    m = s / 60;
    s = s - 60 * m;

    cout <<  h << ":" << m << ":" << s << endl;

return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define N 10000005
using namespace std;
int n,m,ar[N],t,x;
int main()
{
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		if(x%2==1)
			t++;
	}
	if(n==1 || t%2==0)
		cout<<"YES";
	else
		cout<<"NO";
		
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define N 100000

int A[N];
int Partition(int A[],int p,int r);
int main(){
  
  int i,j,n,x;
  
  scanf("%d",&n);
  /*
    A = malloc(sizeof(int)*n+1);
    B = malloc(sizeof(int)*n+1);
  */
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  
  x=Partition(A,0,n-1);
  for(i=0;i<x;i++){
    printf("%d ",A[i]);   
  }
  printf("[%d] ",A[x]);
  for(i=x+1;i<n;i++){
    printf("%d",A[i]);
    if(i!=n-1)
      printf(" ");    
  }
  printf("\n");
  return 0;
}

int Partition(int A[],int p,int r){
  int x,i,j,n;
  x=A[r];
  i=p-1;
  for(j=p;j<=r-1;j++){
    if(x>=A[j]){
      i=i+1;
      n=A[j];
      A[j]=A[i];
      A[i]=n;
    }
  }
  n=A[r];
  A[r]=A[i+1];
  A[i+1]=n;
  return i+1;
}

Measured memory_bytes: 992
#include <bits/stdc++.h>
#define maxn 3005
using namespace std;

long long num[maxn];
long long dp[maxn][maxn];
int n;

int main()
{
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> num[i];
    for (int i = n; i >= 1; --i)
    {
        for (int j = i; j <= n; ++j)
        {
            dp[i][j] = max(num[i] - dp[i + 1][j], num[j] - dp[i][j - 1]);
        }
    }
    cout << dp[1][n];
    return 0;
}

Measured memory_bytes: 70016
#include <iostream>

#define MAX_N 100

unsigned long long int N;
unsigned long long int L[MAX_N];

unsigned long long int Lukas(int N) {
    L[0] = 2;
    L[1] = 1;
    for (int i=2; i<=N; i++) L[i] = L[i-1]+L[i-2];
    return L[N];
}

int main() {
    std::cin >> N;
    std::cout << Lukas( N ) << std::endl;
    return 0;
}


Measured memory_bytes: 384
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 998244353
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0};
int dy[8]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int a,b,c,d;cin>>a>>b>>c>>d;
    if(a+b>c+d)
        cout<<"Left"<<endl;
    else if(a+b==c+d)
        cout<<"Balanced"<<endl;
    else
        cout<<"Right"<<endl;
    
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






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

int main() {
  int a, b, k, c = 0;
  cin >> a >> b >> k;
  for(int i = max(a, b); i > 0; i--) {
    if(a % i == 0 && b % i == 0){
      c++;     
    }
    if(c == k) {
      cout << i;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int A,B,K; cin >> A >> B >> K;
    rep(i,K){
        if(i%2==0){
            B+=A/2;
            A=A/2;
        }
        else {
            A+=B/2;
            B=B/2;
        }
    }
    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void 
debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n;
int ar[100005];
pi ar2[100005];
int main(){
  cin>>n;
  REP(i,n){
    cin>>ar[i];
    ar2[i]=mp(ar[i],i);
  }
  sort(ar2,ar2+n);
  int res=0;
  REP(i,n) if(i&1 && ar2[i].sc%2==0) ++res;
  cout<<res<<endl;
  return 0;
}





Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include<numeric>
#include<cstdlib>
#include <iostream>
#define ll long long int
#define all(x) x.begin(),x.end()

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define v vector<long long int> 
#define vv vector< int> 
#define gcd(m,n) __gcd(m,n)
#define vp vector<pair<long long int ,long long int>>
#define pb push_back
#define mp make_pair
#define pp pop_back
#define itr vector<long long int>::iterator
#define pa pair<long long int ,long long int> 
#define f(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,n) for (ll i=a ; i<n ;i+=1)
#define fe(d,e) for(auto d:e)
#define mod 1000000007
#define F first
#define S second
#define sett set<long long int>
#define um unordered_map<ll,ll>
# define N 100005LL
# define cout1(x) cout<<x<<"\n";
# define  deb(x) cout<<#x<<" "<<x<<"\n";
#define  vii vector<pa>;
using namespace std;

// template<typename... T>
// void read(T&... args){
//     ((cin>>args), ...);
// }
// template<typename... T>
// void write(T... args){
//     ((cout<<args<<"\n"), ...);
// }

v visited(N);
vector<ll> ans={-1};
v level(N);
v ind(N);
ll sz[N];




// void dfs(ll node, ll par){
    
//     visited[node]=1;
//     if (node==1)level[1]=0;
//     else level[node] = level[par]+1;
//     ans.pb(node);
//     for(auto x:graph[node]){
//         if (!visited[x]){
//             dfs(x,node);
//             sz[node]+=sz[x];

//         }
       
//     }
//      ++sz[node];
    
// }
// map<ll,ll> cnt;
// ll answer(ll ans,ll x){
//     cout<<ans<<" "<<x<<endl;
//     if (cnt[ans%x]==0)return ans;
//     else if (cnt[ans%x==1] && ans>x)return ans;
//     else{
//         cnt[ans%x]-=1;
//         cnt[ans]+=1;
//         answer(ans+1,x);
//     }



// }
int main(){

    fastio;
    map<string,ll> mm;
     mm["SUN"]=7;
     mm["MON"]=6;
    mm["TUE"]=5,mm["WED"]=4,mm["THU"]=3,mm["FRI"]=2,mm["SAT"]=1;
    string s;
    cin>>s;
    cout<<mm[s]<<"\n";


    
}
    
    
    

    
    

        


Measured memory_bytes: 5416
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 = inp()
ll = [0] * 90
ll[0] = 2
ll[1] = 1
for i in range(86):
    ll[i+2] = ll[i+1] + ll[i]
print(ll[n])

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n, t;
vector<pair<int, int>> v;
ll dp[3010][3010];

int main() {
    cin >> n >> t;
    rep(i, n) {
        int a, b; cin >> a >> b;
        v.emplace_back(make_pair(a, b));
    }
    sort(v.begin(), v.end());

    for (int i = 0; i < n; i++) {
        int a = v[i].first;
        int b = v[i].second;
        for (int sum_t = 0; sum_t < t; sum_t++) {
            // i番目の料理を食べるとき
            if (sum_t - a >= 0) {
                chmax(dp[i+1][sum_t], dp[i][sum_t - a] + b);
            }
            // 食べないとき
            chmax(dp[i+1][sum_t], dp[i][sum_t]);
        }
    }

    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < t; j++) {
            ll tmp = dp[i][j];
            if (i < n) tmp += v[i].second;
            chmax(ans, tmp);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 70912
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d,n,ans;
	cin>>n;
	for(int i=0;i<n;i++){
		ans=0;
		cin>>a>>b>>c>>d;
		ans+=a*c+b*d;
		if(c>=5 && d>=2){
			ans=ans*0.8;
		}
		else if(c>=5 && d<2){
			if(ans>(a*c+b*2)*0.8)
			ans=(a*c+b*2)*0.8;
		}
		else if(c<5 && d>=2){
			if(ans>(a*5+b*d)*0.8)
			ans=(a*5+b*d)*0.8;
		}else{
			if(ans>(a*5+b*2)*0.8)
			ans=(a*5+b*2)*0.8;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
// D - Pairs

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
//const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

ll A[200000];
ll N, K;
ll max_negative_idx = -1;
ll min_positive_idx = -1;

bool is_ok(int i, int j, ll t) {
	return A[i] * A[j] <= t;
}

int find_lower_limit(int i, ll t, int lower, int upper) {
	if (!is_ok(i, upper - 1, t)) return -1; // 存在しない

	int ok = upper - 1;
	int ng = lower - 1;

	while(ok - ng > 1) {
		int trying = (ok + ng) / 2;

		if (is_ok(i, trying, t)) {
			ok = trying;
		} else {
			ng = trying;
		}
	}

	return ok;
}

int find_upper_limit(int i, ll t, int lower, int upper) {
	if (!is_ok(i, lower, t)) return -1; // 存在しない

	int ok = lower;
	int ng = upper;

	while(ng - ok > 1) {
		int trying = (ng + ok) / 2;

		if (is_ok(i, trying, t)) {
			ok = trying;
		} else {
			ng = trying;
		}
	}

	return ok;
}


// 積がt以下となる組み合わせの場合の数を求める
ll get_comb_of_t_or_less(ll t) {
	//cout << "積が" << t << "以下となる組み合わせの数" << endl; // **** debug ****

	ll result = 0;
	ll comb;
	if (t < 0) {
		// ---- A[i]が負, A[j]が正の場合を考える ---- //
		if (min_positive_idx != -1) {
			for (int i=0; i<=max_negative_idx; i++) {
				ll min_idx = find_lower_limit(i, t, min_positive_idx, N);
				if (min_idx == -1) comb = 0;
				else comb = N - min_idx;
				//cout << "i=" << i << " A[i]=" << A[i] << " comb=" << comb << endl; // **** debug ****
				result += comb;
			}
		}
	} else {
		// ---- 全てのA[i]について考える（組み合わせなのでi<j） ---- //
		for (int i=0; i<N-1; i++) {
			if (A[i] < 0) {
				// A[i]が負 -> A[j]は大きい側がOK、小さい側がNG
				ll min_idx = find_lower_limit(i, t, i+1, N);
				if (min_idx == -1) comb = 0;
				else comb = N - min_idx;
			} else if (A[i] == 0) {
				// A[i]が0 -> tが0以上なら全てOK, 0未満なら全てNG
				if (t >= 0) comb = N - (i+1); // (i<j)
				else comb = 0;
			} else {
				// A[i]が正 -> A[j]は小さい側がOK、大きい側がNG
				ll max_idx = find_upper_limit(i, t, i+1, N);
				if (max_idx == -1) comb = 0;
				else comb = max_idx - i;
			}

			//cout << " i=" << i << " A[i]=" << A[i] << " comb=" << comb << endl; // **** debug ****
			result += comb;
		}
	}

	//cout << " total_comb : " << result << endl; // **** debug ****

	return result;
}

int main() {
	cin >> N >> K;

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

	sort(A, A+N);

	for (int i=0; i<N; i++) {
		if (A[i] < 0) {
			max_negative_idx = i;
		} else if (A[i] > 0) {
			min_positive_idx = i;
			break;
		}
	}


	// 積がt以下になるものの組み合わせの数がK未満かつ
	// 積が(t+1)以下になる組み合わせの数がK以上であれば、
	// K番目の数はt+1
	ll ok = -(1e18) - 1;
	ll ng = 1e18 + 1;
	ll t;
	while(ng - ok > 1) {
		ll t = (ng + ok) / 2;

		if (get_comb_of_t_or_less(t) < K) {
			ok = t;
		} else {
			ng = t;
		}
	}

	ll ans = ng;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

const ll mod = 1000000007;

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

  vll l(n);
  vll mins(n+1);
  mins[0] = INF;

  ll ans = 0;
  rep(i, n) {
    cin >> l[i];
    if (l[i] <= mins[i]) ans++;
    mins[i + 1] = min(l[i], mins[i]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3328