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

long long int d[200002];
long long int r[200003];
map<long long int,int> m;

int main() {

    int ans = 0,n;

    cin >> n;

    for(int i=0;i<n;i++){
        scanf(" %lld",&d[i]);
    }

    for(int i=0;i<n;i++){
        r[i+1] = d[i] + r[i];
    }

    for(int i=0;i<n+1;i++){
        if(m[r[i]] == 0 && r[i] != 0){
            m[r[i]] = i;
        }
        else{
            ans = max(ans,i-m[r[i]]);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 18716
#include<iostream>
#include<queue>
#include<bitset>
#include<algorithm>
#include<climits>
#include<vector>
#include<deque>
#include<cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> P;
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define dump(a) rep(i,a.size()){ cout<<a[i]<<" "; } cout<<endl;
#define dumparr(a,n) rep(i,n){ cout<<a[i]<<" "; } cout<<endl;
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define INF INT_MAX/3
#define FINF DBL_MAX/3
#define EPS 1e-7
#define OUT1(n1) cout<<n1<<endl
#define OUT2(n1,n2) cout<<n1<<" "<<n2<<endl
#define OUT3(n1,n2,n3) cout<<n1<<" "<<n2<<" "<<n3<<endl
#define OUT4(n1,n2,n3,n4) cout<<n1<<" "<<n2<<" "<<n3<<" "<<n4<<endl
#define OUT5(n1,n2,n3,n4,n5) cout<<n1<<" "<<n2<<" "<<n3<<" "<<n4<<" "<<n5<<endl
#define OUT6(n1,n2,n3,n4,n5,n6) cout<<n1<<" "<<n2<<" "<<n3<<" "<<n4<<" "<<n5<<" "<<n6<<endl
#define OUT(n, ...) OUT##n(__VA_ARGS__)

/* algo: *が隣り合ってるときはそれを同時にやると1手で-2, 単体の*の時は両端のどちらかと交換して-1
 * algo: *
 *
 * 最小性の証明: まず*の個数より
 *
 * *を消すのに最低1swapは必要
 * 組み合わせると少なくなる
 */

int main(){
  ll n;
  ll a[100001];
  cin>>n;
  rep(i,n){
    cin>>a[i];
  }
  ll c = 0;

  rep(i,n-1) {
    if(a[i] == i+1) {
      // swap i, i+1
      ll tmp;
      tmp = a[i];
      a[i] = a[i+1];
      a[i+1] = tmp;
      c++;
    }
  }
  if(a[n-1] == n) {
    // swap n-1, n-2
    ll tmp;
    tmp = a[n-1];
    a[n-1] = a[n-2];
    a[n-2] = tmp;
    c++;
  }
  OUT(1, c);
  return 0;
}


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

int main()
{
    int a, b;
    int n10k, nk, nc, nd, n1, counter = 0;

    cin >> a >> b;
    for (int n = a; n< b + 1; n++)
    {
        n10k = n / 10000;
        nk = (n - n10k * 10000) / 1000;
        nc = (n - n10k * 10000 - nk * 1000) / 100;
        nd = (n - n10k * 10000 - nk * 1000 - nc * 100) / 10;
        n1 = (n - n10k * 10000 - nk * 1000 - nc * 100 - nd * 10);

        if ((n10k == n1) && (nk == nd))
        {
            counter++;
        }
    }    
    cout << counter;

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007


int main()
{
    int t=1;
    //cin>>t;

    while( t-- )
    {
        int x,y;
        cin>>x>>y;

        if( y%2==0 )
        {
            if( x*2<=y && y<=x*4 )
                cout<<"Yes";
            else
                cout<<"No";
        }
        else
            cout<<"No";
    }
    return 0;
}


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

struct card{
	char suit, value;
};

void BubbleSort(struct card C[], int N){
	for(int i = 0; i < N; i++){
		for(int j = N - 1; j > i; j--){
			if(C[j].value < C[j - 1].value){
				card t = C[j]; C[j] = C[j - 1]; C[j - 1] = t;
			}
		}
	}
}

void SelectionSort(struct card C[],int N){
	int minj;
	for(int i = 0; i < N; i++){
		minj = i;
		for(int j = i + 1; j < N; j++){
			if(C[j].value < C[minj].value) minj = j;
		}
		card t = C[minj]; C[minj] = C[i]; C[i] = t;
	}
}

void print(struct card C[], int N){
	for(int i = 0; i < N; i++){
		if(i) cout<<" ";
		cout<<C[i].suit<<C[i].value;
	}
	cout<<endl;
}

int StableSort(struct card C1[], struct card C2[],int N){
	for(int i = 0; i < N; i++){
		if(C1[i].suit != C2[i].suit) return false;
	}
	return true;
}

int main(){
	card C1[100], C2[100];
	int  N;
	char ch;
	
	cin>>N;

	for(int i = 0; i < N; i++){
		cin>>C1[i].suit>>C1[i].value;
	}

	for(int i = 0; i < N; i++) C2[i] =C1[i];

	BubbleSort(C1, N);
	SelectionSort(C2,N);

	print(C1, N);
	cout<<"Stable"<<endl;

	print(C2, N);

	if(StableSort(C1, C2, N)) cout<<"Stable"<<endl;
	else cout<<"Not stable"<<endl;

	return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
namespace io{
	const int L=(1<<19)+1;
	char ibuf[L],*iS,*iT,c;int f;
	char gc(){
		if(iS==iT){
			iT=(iS=ibuf)+fread(ibuf,1,L,stdin);
			return iS==iT?EOF:*iS++; 
		}
		return*iS++;
	}
	template<class I>void gi(I&x){
		for(f=1,c=gc();c<'0'||c>'9';c=gc())if(c=='-')f=-1;
		for(x=0;c<='9'&&c>='0';c=gc())x=x*10+(c&15);x*=f;
	}
};
using io::gi;
using io::gc;
int n;
int di(int x){
	int c=0;
	while(x>0){
		c+=x%10;
		x/=10;
	}
	return c;
}
int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	scanf("%d",&n);
	int ans=100000000;
	for(int A=1;A<n;A++){
		int as=di(A)+di(n-A);
		ans=min(ans,as);
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
#include <numeric>

long int Euclid(long int A, long int B){
  if(A<B) return Euclid(B, A);
  while(B!=0){
    long int R = A%B;
    A = B; B = R;
  }
  return A;
}

int main(){
  long int N;
  std::cin>>N;
  std::vector<int> A(N);
  std::copy_n(std::istream_iterator<int>(std::cin),N,A.begin());
  std::vector<long int> gcd_front(1, 1);
  std::vector<long int>  gcd_back(1, 1);
  gcd_front.push_back(A[0]);
  gcd_back.push_back(A[N-1]);
  long int gcd_f = A[0]; long int gcd_b = A[N-1];
  for(int i = 1 ; i < N ; i++ ){
    gcd_front.push_back(Euclid(gcd_f, A[i]));
    gcd_back.push_back(Euclid(gcd_b, A[N-i-1]));
    gcd_f = gcd_front[i+1];
    gcd_b = gcd_back[i+1];
  }
  long int gcd = 0;
  long int max_gcd = gcd_back[N-1];
  for(int i = 2 ; i < N ; i++ ){
    gcd = Euclid(gcd_front[i-1],gcd_back[N-i]);
    if(max_gcd<=gcd) max_gcd = gcd;
  }
  gcd = gcd_front[N-1];
  if(max_gcd<=gcd) max_gcd = gcd;
  std::cout<<max_gcd<<std::endl;
  return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    if(N % 2 == 0) {
        cout << N/2 -1 << endl;
    } else {
        cout << (N-1)/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

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

func solve() {
	n := getInt()
	as := make([]int, n+2)
	as[0], as[n+1] = 0, 0
	sum := 0
	for i := 1; i < len(as); i++ {
		if i != len(as)-1 {
			as[i] = getInt()
		}
		sum += abs(as[i] - as[i-1])
	}

	for i := 1; i < n+1; i++ {
		x, y := abs(as[i]-as[i-1]), abs(as[i+1]-as[i])
		z := abs(as[i+1] - as[i-1])
		ans := sum - (x + y) + z

		fmt.Fprintln(wr, ans)
	}
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

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

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

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

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

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


Measured memory_bytes: 3712
M = int(input())
a = list(map(int, input().split()))

box = [0]*M
for i in range(M)[::-1]:
    s = sum(box[i::i +1])
    if s % 2 != a[i]:
        box[i] = 1
M = sum(box)
print(M)
if M != 0:
    for i, j in enumerate(box):
        if j == 1:
            print(i + 1)

Measured memory_bytes: 8784
#include<iostream>
#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;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    string s,t;
    cin>>s>>t;
    int n=s.size();
    s+=s;
    vector<int> v[26];
    rep(i,2*n){
        v[s[i]-'a'].push_back(i);
    }
    int idx = -1;
    ll ans = 0;
    rep(i,t.size()){
        if(v[t[i]-'a'].empty()){
            cout<<-1<<endl;
            return 0;
        }
        int nxt = *upper_bound(v[t[i]-'a'].begin(),v[t[i]-'a'].end(),idx);
        if(nxt>=n){
            ans+=n;
            nxt-=n;
        }
        idx = nxt;
    }
    ans += idx;
    cout<<ans+1<<endl;
    return 0;
}

Measured memory_bytes: 1784
#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e2 + 5;
int n,m;
char s[maxn];
int dp[maxn][maxn][maxn];
int main () {
    int ans = 0;
    scanf(" %s%d",s,&m);
    n = strlen(s);
    for(int i=n;i>=1;i--) s[i] = s[i-1];
    for(int l=1;l<=n;l++) {
        for(int r=n;r>=l;r--) {
            for(int k=0;k<=m;k++) {
                int t = max(dp[l-1][r][k], dp[l][r+1][k]);
                if(s[l]==s[r]) t = max(t, dp[l-1][r+1][k] + 1);
                if(k>0) t = max(t, dp[l-1][r+1][k-1] + 1);
                dp[l][r][k] = t;
                ans = max(ans, dp[l][r][k]*2 - (l==r ? 1 : 0));
//                printf("dp %d %d %d = %d (%c and %c)\n",l,r,k,dp[l][r][k],s[l],s[r]);
            }
        }
    }
    printf("%d",ans);
}


Measured memory_bytes: 110464
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;
#define P pair<ll, ll>
const ll maxn = 1e5 + 111;
const ll mod = 1e9 + 7;
ll jc[100005];
void init() {  //打表n!
    jc[0] = 1;
    ll ret = 1;
    for (ll i = 1; i <= 100000; ++i) {
        ret = ret * i % mod;
        jc[i] = ret;
    }
}
ll binaryPow(ll a, ll b, ll m) {
    ll ret = a, ans = 1;
    while (b) {
        if (b & 1) ans = (ans * ret) % m;
        ret = ret * ret % m;
        b >>= 1;
    }
    return ans;
}
inline ll cal(ll a, ll b) {
    return jc[a] * binaryPow(jc[b] * jc[a - b] % mod, mod - 2, mod) % mod;
}
ll s[1111][1111];
int main() {
    init();
    ll n, m;
    scanf("%lld%lld", &n, &m);
    s[0][0] = 1;
    for (ll i = 1; i <= 1111; i++) {
        for (ll j = 1; j <= 1111; j++) {
            s[i][j] = ((s[i - 1][j - 1] * (m - j + 1)) % mod +
                       (j * s[i - 1][j]) % mod) %
                      mod;
        }
    }
    if (n < m) {
        puts("0");
        return 0;
    }
    ll ans = 1;
    for (ll i = 1; i <= m; ++i) {
        ans = ans * i % mod;
    }
    printf("%lld\n", s[n][m] % mod);
    return 0;
}



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

int main(){
    int n;
    cin >> n;
    int a[n];
    int count=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        while(1){
            if(a[i]%2==0){
                a[i]/=2;
            }else{
                break;
            }
            count++;
        }
    }
    cout << count << endl;

}

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

int main()
{
	int N,C;
	int s,t,c;
	int csum[35][100010]={};
	int ans=0;
	
	cin >> N >> C;
	for(int i=0;i<N;i++)
	{
		cin >> s >> t >> c;
		csum[c][s]++;
		csum[c][t+1]--;
	}
	
	for(int i=1;i<=C;i++)
		for(int j=1;j<=100000;j++)
			csum[i][j]+=csum[i][j-1];
	
	for(int i=1;i<=C;i++)
		for(int j=1;j<=100000;j++)
			csum[i][j]=min(csum[i][j],1);
	
	for(int i=1;i<=C;i++)
		for(int j=1;j<=100000;j++)
			csum[i][j]+=csum[i-1][j];
	
	for(int i=0;i<=100000;i++)
		ans=max(ans,csum[C][i]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 13952
#include <algorithm>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <string.h>
#include <vector>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <list>
using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    int N;
    cin >> N;
    vector<int> A = igets(N);
    sort(A.begin(),A.end());
    cout << A[N-1]-A[0] << endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
/*FUNC*/
//各桁の和
int EDSum(ll number){
    int ans=0;
    while(1){
        ans += number % 10;
        number /= 10;
        if(number == 0) break;
    }
    return ans;
}

//エラトステネスのふるい(素数発見アルゴリズム)
vector<int> SOE(int min, int max)
{
    //0,1は含まれない
    if (min < 2) min = 2;
    //探索リスト作成
    vector<int> int_array;
    for (int i = min; i <= max; i++) int_array.push_back(i);
    //素数リスト
    vector<int> sosu;
    //√max
    double stop = sqrt(max);
    //計算
    while (true)
    {
        //素数リストに追加
        sosu.push_back(int_array.front());
        int_array.erase(int_array.begin());
        //停止
        if (stop < (double)(sosu.back())) break;
        //ふるい
        for (int i = 0; i < (int)int_array.size(); i++)
        {
            if (int_array[i] % sosu.back() == 0)
                int_array.erase(int_array.begin() + i);
        }
    }
    sosu.insert(sosu.end(), int_array.begin(), int_array.end());
    return sosu;
}

//最小公倍数
int MinCM(int a, int b)
{
    int c = a * b;
//入れ替え
    if (a < b)
        swap(a, b);
    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return c / b;
}

//最大公約数
int MaxCD(int a, int b)
{
//入れ替え
    if (a < b)
        swap(a, b);
    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
//iget cin int 2 vector
vector<int> igets(int N){
    vector<int> A;
    int temp;
    for (int i = 0; i < N; ++i) {
        cin >> temp;
        A.push_back(temp);
    }
    return A;
}

ll nPr(ll n,ll r) {
    ll ans=1;
    r=n-r;
    while(n!=r) {
        ans*=n;
        --n;
    }
    return ans;
}

ll nE(ll n) {
    return nPr(n,n);
}

ll nCr(ll n,ll r) {
    if(r==0)return -1;
    else{
        if(0!=n-r&&n-r<r)r=n-r;
        return nPr(n,r)/nE(r);
    }
}

Measured memory_bytes: 256
x, n = list(map(int, input().split()))
nums = list(map(int, input().split()))

if x not in nums:
    print(x)
    exit()
for i in range(1, 200):
    if x-i not in nums:
        print(x-i)
        exit()
    if x+i not in nums:
        print(x+i)
        exit()


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define IMP cout << "IMPOSSIBLE" << endl
#define Imp cout << "Impossible" << endl
#define imp cout << "impossible" << endl
#define M1 cout << "-1" << endl
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using vpint = vector<pint>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

ll dp[110][3][7];

void Main()
{
    arrayFill(dp, 0);
    string s = in();
    int K = in();
    int l = s.size();

    dp[0][0][0] = 1;
    rep(i, l)
    {
        const int D = s[i] - '0';
        rep(j, 2)
        {
            rep(k, 4)
            {
                for (int d = 0; d <= (j ? 9 : D); ++d)
                {
                    // 0 を入れる場合
                    if (d == 0)
                    {
                        dp[i + 1][j || (d < D)][k] += dp[i][j][k];
                    }
                    else
                    {
                        if (k == K)
                            continue;
                        // 0 以外を入れる場合
                        dp[i + 1][j || (d < D)][k + 1] += dp[i][j][k];
                    }
                }
            }
        }
    }

    cout << dp[l][0][K] + dp[l][1][K] << endl;
}

signed main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <queue>
#include <assert.h>
#include <cmath>
using namespace std;
using ll = long long;
const int mxn = 200010;
const ll inf = 1e18L+5;
ll dp[mxn], t[2*mxn], lazy[2*mxn];
int N, tree_size;

void apply(int p, ll val) {
	t[p]+=val;
	if(p<tree_size) lazy[p]+=val;
}

void build(int p) {
	while(p>1) p/=2, t[p] = min(t[2*p], t[2*p+1])+lazy[p];
}

void push(int p) {
	int h = floor(log2(tree_size));
	for(int s=h; s>0; --s) {
		int i = p>>s;
		assert(i);
		if(lazy[i]!=0) {
			apply(2*i, lazy[i]);
			apply(2*i+1, lazy[i]);
			lazy[i] = 0;
		}
	}
}

void inc(int l , int r, ll val) {
	//cout << "inc\n";
	l+=tree_size, r+=tree_size;
	int l0 = l, r0 = r;
	for(; l<=r; l/=2, r/=2) {
		if(l&1) apply(l, val);
		if(!(r&1)) apply(r, val);
		l++, r--;
	}
	build(l0);
	build(r0);
}

ll get_min(int l, int r) {
	//cout << "get_min\n";
	l+=tree_size, r+=tree_size;
	push(l);
	push(r);
	ll ret = inf;
	for(; l<=r; l/=2, r/=2) {
		if(l&1) ret = min(ret, t[l]);
		if(!(r&1)) ret =min(ret, t[r]);
		l++, r--;
	}
	assert(ret!=inf);
	return ret;
}

vector<pair<int, int> > intervals[mxn];

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

	cin>>N;
	int M; cin>>M;

	ll sum = 0;
	while(M--) {
		int l, r, val;
		cin>>l>>r>>val;
		intervals[r].emplace_back(l, val);
		sum = sum+(ll) val;
	}
	tree_size = N+1;
	dp[0] = 0; inc(0, 0, 0);
	dp[1] = 0; inc(1, 1, 0);

	for(int i=2; i<=N+1; i++) {
		for(auto x:intervals[i-1]) {
			int l = x.first, val = x.second;
			inc(0, l-1, (ll) val);
		}
		dp[i] = get_min(0, i-1);
		inc(i, i, dp[i]);
	}

	cout << sum-dp[N+1] << '\n';
	return 0;
}

Measured memory_bytes: 19072
a = input()
d = 'TBD'
if int(a[0:4]) ==2019:
  if int(a[5:7]) == 4:
    if int(a[8:10]) <=30:
      d = 'Heisei'
  elif int(a[5:7]) <=3:
    d = 'Heisei'
elif int(a[0:4]) <= 2018:
  d = 'Heisei'
print(d)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


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

    cout << int(N/3) << endl;

    return 0;
}

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

char a;
int n;
set<int> s;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf(" %c",&a);
		s.insert(a);
	}
	if(s.size()==4) printf("Four");
	if(s.size()==3) printf("Three");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define INF 2000000000
#define MIN(a, b) ((a) < (b) ? (a) : (b))

int a[100][100];
int d[100][100];
int V,E;

int WarshallFloyd(){
	for(int k=0;k<V;k++){
		for(int i=0;i<V;i++){
			if(d[i][k]!=INF){
				for(int j=0;j<V;j++){
					if(d[k][j]!=INF){
						d[i][j]=MIN(d[i][j],d[i][k]+d[k][j]);
						if(j==k && d[j][k]<0){
							printf("NEGATIVE CYCLE\n");
							return 1;
						}
					}
				}
			}
		}
	}
	return 0;
}

int main(){
	int s,t,cost;
	int i,j;
	
	scanf("%d %d",&V,&E);
	
	for(i=0;i<V;i++){
		for(j=0;j<V;j++){
			if(i==j)d[i][j]=0;
			else d[i][j]=INF;
		}
	}
	
	for(i=0;i<E;i++){
		scanf("%d %d %d",&s,&t,&cost);
		d[s][t]=cost;
	}
	
	if(WarshallFloyd())return 0;
	
	for(i=0;i<V;i++){
		for(j=0;j<V;j++){
			if(j==V-1){
				if(d[i][j]==INF)printf("INF\n");
				else printf("%d\n",d[i][j]);
			}
			else {
				if(d[i][j]==INF)printf("INF ");
				else printf("%d ",d[i][j]);
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 2104
#include <stdio.h>

int main(){

    int x,a,b;

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

    if(b-a<=0){
        printf("delicious");
    }

    else
    {
        if(b-a<=x){
            printf("safe");
        }

        else{
            printf("dangerous");
        }
    }
    
    
    return 0;
}

Measured memory_bytes: 128
a,b,k = map(int, input().split())

while(k>0):
    tmp = a//2
    a = tmp
    b += tmp
    k -=1
    if k==0:
        break
    
    tmp = b//2
    b = tmp
    a += tmp
    k -=1
    if k==0:
        break
print(a,b)

Measured memory_bytes: 3060
h, w = map(int, input().split())
a = [input() for _ in range(h)]

row = [False] * h
col = [False] * w
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            row[i] = True
            col[j] = True
for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j], end = "")
        print()

Measured memory_bytes: 4468
N=int(input())
DIC={}
for i in range(N):
    S=input()
    if S in DIC:
        DIC[S]+=1
    else:
        DIC[S]=1
largest=max(DIC.values())
ans=[]
for s in DIC:
    if DIC[s]==largest:
        ans.append(s)
    else:
        continue
ans.sort()
for t in ans:
    print(t)

Measured memory_bytes: 32096
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
//#include <iomanip> : 表示桁数, ex) cout << fixed << setprecision(15) << ...

#define pi 3.14159265358979323846
#define rep(i, n) for (int i = 0; i < n; i++)
using  ll = long long;
using ld = long double;
using Byte = unsigned char;
using namespace std;

//string ans = "Yes";
int X, N;

int SetAns() {
	cin >> X >> N;
	vector<int> p(N);
	rep(i, N) cin >> p[i];

	int ans = 0;
	while (true) {
		bool flagU = true;
		bool flagL = true;
		rep(i, N) {
			if (X - ans == p[i]) flagL = false;
			if (X + ans == p[i]) flagU = false;
		}
		if (flagL == true) return X - ans;
		if (flagU == true) return X + ans;
		ans++;
	}
}

int main() {
	
	cout << SetAns()<< endl;
	return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vpi = vector<pi>;
using vvpi = vector<vpi>;
const ull MOD = 998244353;
#ifdef LOCAL
#include "../../pp.hpp"
#define debug pp::debug
#else
#define debug(args...)
#endif

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

    int N, W; cin >> N >> W;
    vector<long long> w(N);
    vi v(N);
    for (int i = 0; i < N; ++i) cin >> w[i] >> v[i];

    vector<vector<long long>> dp(N, vector<long long>(100001, -1));
    for (int i = 0; i < N; ++i) dp[i][0] = 0;
    dp[0][v[0]] = w[0];
    for (int i = 1; i < N; ++i) {
        for (int val = 1; val <= 100000; ++val) {
            dp[i][val] = dp[i-1][val];
            if (val >= v[i] && dp[i-1][val - v[i]] != -1) {
                if (dp[i][val] == -1) dp[i][val] = dp[i-1][val - v[i]] + w[i];
                else dp[i][val] = min(dp[i][val], dp[i-1][val - v[i]] + w[i]);
            }
        }
    }

    for (int val = 100000; val >= 0; --val) {
        for (int i = N-1; i >= 0; --i) {
            if (dp[i][val] != -1 && dp[i][val] <= W) {
                cout << val << '\n';
                return 0;
            }
        }
    }
}


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

using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 1e5 + 5;

void debug_out() {
    cerr << endl;
}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
set<ll>v[MAXN];
int main() {
    FAST
    ll n;
    cin>>n;
    ll arr[n];
    map<ll,ll>m;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        m[(i+1)-arr[i]]++;
    }
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        ans+=m[(i+1)+arr[i]];
    }
    cout<<ans<<endl;




    return 0;
}


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

int main(){
     int r, c, i, j, allsum = 0;
     cin >> r >>c;
     int mat[r*c], rsum[r], csum[c];
     for(i = 0; i <= r*c-1; i++){
          cin >> mat[i];
     }

     for(i = 0; i <= r-1; i++){
          rsum[i] = 0;
          for(j = 0; j <= c-1; j++){
               rsum[i] += mat[c*i+j];
          }
     }

     for(i = 0; i <= c-1; i++){
          csum[i] = 0;
          for(j = 0; j <= r-1; j++){
               csum[i] += mat[c*j+i];
          }
     }

     for(i = 0; i <= r-1; i++){
          allsum += rsum[i];
     }

     for(i = 0; i <= r*c-1; i++){
          cout << mat[i] << ' ';
          if((i+1)%c == 0){
               cout << rsum[(i+1)/c-1] << endl;
          }
     }
     for(i = 0; i <= c-1; i++){
          cout << csum[i] << ' ';
     }
     cout << allsum << endl;

     return 0;
}

Measured memory_bytes: 1200
h,w,a,b=map(int,input().split())
p=[0]*h
q=[0]*w
for i in range(h):
	d=""
	for j in range(w):
		if p[i]+1<=w-a and q[j]+1<=h-b:
			p[i]+=1
			q[j]+=1
			d+="1"
		else:
			d+="0"	
	print(d)

Measured memory_bytes: 4084
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
using namespace std;

int main(){
  
  int n; cin >> n;
  vector<int> h(n);
  for(int i=0; i<n; i++) cin >> h[i];
  string ans="Yes";

  for (int i=n-1; i>0; i--){
    if (h[i-1]-h[i]>1){
      ans="No";
      break;
    }
    if (h[i-1]-h[i]==1) h[i-1]--;
  }

  cout << ans << endl;

 
  return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <map>
#include <algorithm>
#include <set>
using namespace std;

int n;
typedef pair<int,int> P;
P points[1000001];

int dist(int i, int j) {
  return (points[i].first-points[j].first)*(points[i].first-points[j].first)
      + (points[i].second-points[j].second)*(points[i].second-points[j].second);
}

int main() {
  scanf("%d", &n);

  int x,y;
  for (int i=0; i<n; ++i) {
    scanf("%d %d", &x, &y);
    points[i].first = x, points[i].second = y;
  }
  sort(points, points+n);
  int ans = dist(0,1);
  set<int> q; q.insert(0); q.insert(1);
  for (int i=2; i<n; ++i) {
    for (set<int>::iterator it = q.begin(); it != q.end(); ++it) {
      int v = *it;
      ans = min(ans, dist(i,v));
      if (points[i].first-points[v].first > ans || points[i].second-points[v].second > ans) {
        q.erase(it);
      }
    }
    q.insert(i);
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 8860
a,b=map(int,input().split())
a1=-(-a//0.08)
a+=1
a2=-(-a//0.08)-1
b1=b*10
b+=1
b2=b*10-1
if b1<=a2<=b2:
    print(int(b1))
elif a1<=b2<=a2:
    print(int(a1))
else:
    print(-1)


Measured memory_bytes: 3060
H, W, K = map(int, input().split())

h = [ [ 0 for i in range(W) ] for j in range(H+1) ]
h[0][0] = 1
fib = [0, 0, 1, 1, 2, 3, 5, 8, 13, 21, 34]

for hi in range(1, H+1):
    if W==1:
        h[H][K-1] = 1
    else:
        for wi in range(0, W):
            if wi==0:
                cen = fib[W+1]
                rig = fib[W]
                h[hi][wi] = cen * h[hi-1][wi] + rig * h[hi-1][wi+1]
            elif wi==W-1:
                lef = fib[W]
                cen = fib[W+1]
                h[hi][wi] = lef * h[hi-1][wi-1] + cen * h[hi-1][wi]
            else:
                lef = fib[wi+1] * fib[W-1-wi+2]
                cen = fib[wi+2] * fib[W-1-wi+2]
                rig = fib[wi+2] * fib[W-1-wi+1]
                h[hi][wi] = lef * h[hi-1][wi-1] + cen * h[hi-1][wi] + rig * h[hi-1][wi+1]

print(h[H][K-1]%1000000007)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,c;
  string b;
  cin>>a>>b>>c;
  
  if(b=="+"){
      cout<<a+c<<endl;
  }
  else if(b=="-"){
      cout<<a-c<<endl;
  }
}


Measured memory_bytes: 3596
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


void Main()
{
    string s;cin>>s;
    int k;cin>>k;

    int n = SIZE(s);

    REP(i,n){
        int sa = ('{'-s[i])%26;
        if(sa <= k){
            k -= sa;
            s[i] = 'a';
            //dump(k)
        }
    }
    s[n-1] = 'a' + (s[n-1]-'a' + k%26)%26;

    cout<<s<<endl;
	return;
}

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

Measured memory_bytes: 592
#include<iostream>

int getDigit(int n){
    int digit=0;
    while(n>0){
        digit++;
        n/=10;
    }
    return digit;
}

int main(void){
    int a,b;
    while(std::cin>>a>>b){
        std::cout<<getDigit(a+b)<<std::endl;
    }
    return 0;
}


Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9 * 2;

int main() {
	int n, ma, mb;
	cin >> n >> ma >> mb;
	vector<int> a(n), b(n), c(n);
	rep(i, n) cin >> a[i] >> b[i] >> c[i];
	vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(401, vector<int>(401)));
	rep(i, n + 1){
		rep(j, 401){
			rep(k, 401){
				dp[i][j][k] = INF;
			}
		}
	}
	dp[0][0][0] = 0;
	rep(i, n){
		rep(j, 401){
			rep(k, 401){
				if(j < a[i] || k < b[i]) dp[i + 1][j][k] = dp[i][j][k];
				else dp[i + 1][j][k] = min(dp[i][j - a[i]][k - b[i]] + c[i], dp[i][j][k]);
			}
		}
	}
	int out = INF;
	rep(i, 400){
		rep(j, 400){
			if(i != 0 && j != 0 && ma * j == mb * i) out = min(out, dp[n][i][j]);
		}
	}
	cout << (out == INF ? -1 : out) << endl;
}


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

int main() {
	string s;
	cin >> s;
	int sm = 0;
	rep(i, s.size()) {
		sm += s[i] - '0';
	}
	puts(stoi(s) % sm == 0 ? "Yes" : "No");
        return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int r = scanner.nextInt();
        int d = scanner.nextInt();
        int x = scanner.nextInt();
        for (int i = 0; i < 10; i++) {
            x = x * r - d;
            System.out.println(x);
        }
    }
}

Measured memory_bytes: 22996
import sys

n, y = map(int, input().split())

for i in range(n+1):
  for j in range(n+1):
    k = n - i - j
    if (k < 0):
      continue
    total = 10000 * i + 5000 * j + 1000 * k
    if i + j + k == n and total == y:
      print('{0} {1} {2}'.format(i, j, k))
      sys.exit()

print('-1 -1 -1')


Measured memory_bytes: 2940
n,m,x = map(int, input().split())
ca=[list(map(int,input().split())) for i in range(n)]

ans=10**20
from itertools import *
for tmp in list(product([True,False], repeat=n)):
    cost=0
    algo = [0] * m
    for i in range(n):
        if tmp[i]:
            cost+=ca[i][0]
            for j in range(m):
                algo[j] += ca[i][j+1]

    ok=True
    for i in range(m):
        if algo[i] < x:
            ok=False
    if ok:
        ans=min(ans,cost)

if ans==10**20:
    print(-1)
else:
    print(ans)

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

import sys
import os

for s in sys.stdin:
    n = int(s)
    if n == 0:
        break

    M = []
    for i in range(n):
        lst = list(map(int, input().split()))
        lst.append(sum(lst))
        M.append(lst)

    last_lst = []
    # vertical sum
    for i in range(n+1):
        sumv = 0
        for row in M:
            sumv += row[i]
        last_lst.append(sumv)
    M.append(last_lst)

    # answer
    for row in M:
        for val in row:
            print(str(val).rjust(5), end='')
        print()

Measured memory_bytes: 7508
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int count = 0;
	string a;
	cin >> a;
	for (int i = 0; i < 3; i++) {
		if (a[i] == '1')count++;
	}
	cout << count << endl;
	int x;
	cin >> x;
	return 0;
}

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

#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> using V = vector<T>;
using P = pair<int, int>;

/*
 *  */

signed main() {
  int n;
  cin >> n;
  cout << (n+1)/2 << endl;
  return 0;
}


Measured memory_bytes: 764
#include <stdio.h>

typedef struct {
    int y, x;
    int yy, xx;
} _;

_ arr[500 * 500 + 5];

int main()
{
    int h, w;
    int mp[505][505];
    int n = 0;

    scanf("%d %d", &h, &w);
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            scanf("%d", &mp[i][j]);
        }
    }

    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if (i != h && j == w) {
                if (mp[i][j] % 2) {
                    arr[n] = (_){i, j, i + 1, j};
                    n++;
                    
                    mp[i + 1][j] += 1;
                }
            } else if (j < w) {
                if (mp[i][j] % 2) {
                    arr[n] = (_){i, j, i, j + 1};
                    n++;

                    mp[i][j + 1] += 1;
                }
            }
        }
    }

    printf("%d\n", n);
    for (int i = 0; i < n; i++) {
        printf("%d %d %d %d\n", arr[i].y, arr[i].x, arr[i].yy, arr[i].xx);
    }

    return 0;
}


Measured memory_bytes: 4992
N = int(input())
X = input().split()
X = [int(l) for l in X]

s = 0
for x in X:
    s += (x-X[0])**2
S = s

if N == 1:
    print(S)
else:
    m = max(X)
    n = min(X)
    for P in range(n,m+1):
        s = 0
        for x in X:
            s += (x-P)**2
        if s < S:
            S = s
    print(S)

Measured memory_bytes: 3064
N = gets.chomp.to_i
a = []
(0..(N-1)).each do |i|
  a[i] = gets.chomp.to_i
end

sorted = a.sort_by { |i| -i }
m = sorted[0]
n = sorted[1]

a.each do |i|
  if i == m
    p n
  else
    p m
  end
end

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

int main()
{
    const int N_Mux = 3;
    vector<int> v;
    int a;

    for (int i = 0; i < N_Mux; i++) {
        cin >> a; 
        v.push_back(a);
    }

    sort(v.begin(), v.end());
    cout << v[0] << " ";
    cout << v[1] << " ";
    cout << v[2] << endl; 
}

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

#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ld long double
#define pb push_back
#define fe first
#define se second
#define nl "\n"
#define pp pair < ll , ll > 
#define sz(x) (ll)x.size()
#define st(x) sort(x.begin(),x.end())
#define rst(x) sort(x.rbegin(), x.rend())
#define all(x) x.begin(),x.end()
long double pi = 3.14159265358979323;
 
const double EPS = 1e-12;
const int N = 1e6 + 5;
const int mod = 1e9 + 7;
 
 
 
 
int main()
{
    fast;
    ll n , w;
    cin >> n >> w;
    ll wt[n+1] , val[n+1];
    ll sum = 0 ;
    for(int i = 1 ; i <= n ;i++ ){
        cin >> wt[i] >> val[i];
        sum += val[i];
    }

    //sum -> maximum profit that can be possible
    ll dp[n+1][sum + 1] = {};

    for(int i = 0 ; i <= n ; i++ ){
        for(int j = 0 ;  j <= sum ; j++ ){
            dp[i][j] = mod;
        }
    }
    dp[0][0] = 0;
    //value of profit can be from 0 to sum
    //we will find minimum weight needed to form p profit from i items;
    for(int i = 1 ; i <= n ; i++ ){
        for(ll profit  = 0 ; profit <= sum; profit++ ){ 
        //for(int i )

            if(profit >= val[i]){
                dp[i][profit] = min(dp[i-1][profit] , dp[i-1][profit-val[i]] + wt[i]);
            }
            else
                dp[i][profit] = dp[i-1][profit];
           // cout << dp[i][profit] << " ";
            //dp[profit][i] = min(dp[profit][i] , dp[profit][i-1])
        }
       // cout << "\n";
    }

    ll ans = 0 ;
    for(ll profit = 0  ; profit <= sum ; profit++ ){
            if(dp[n][profit] <= w){
                ans = profit;
            }
            //dp[profit][n] 
    }
    cout << ans;





















    
    return 0;
    
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,x); REP(i,sizeof(a)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

ll x[1010],y[1010],z[1010];
ll v[1010];

int main(){
  int N,M; cin>>N>>M;
  REP(i,N){
    cin>>x[i]>>y[i]>>z[i];
  }
  
  ll ans = -1;
  for(int bits=0;bits<pow(2,3);++bits){  
    int temp = bits;
    int fugou;
    
    if(temp%2==1){ fugou = 1;}
    else{ fugou = -1;}
    REP(i,N){ v[i] = x[i]*fugou; }
    temp /= 2;
    
    if(temp%2==1){ fugou = 1; }
    else{ fugou = -1;}
    REP(i,N) { v[i] += y[i]*fugou; }
    temp /= 2;
    
    if(temp%2==1){ fugou = 1; }
    else{ fugou = -1;}
    REP(i,N){ v[i] += z[i]*fugou; }
    
    sort(v,v+N,greater<ll>());
    ll cand = sum(v,M);
    if(cand>ans){ ans = cand;}
  }
  cout << ans <<"\n";
}

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

int GCD(int num1, int num2)
{
    int c;
    while ((c = num1 % num2))
    {
        num1 = num2;
        num2 = c;
    }

    return num2;
}

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

    long a, b, gcd;
    cin >> a >> b;
    if (a > b)
        gcd = GCD(a, b);
    else
        gcd = GCD(b, a);
    cout << a * b / gcd << endl;

    return 0;
}

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

#define int long long
#pragma GCC optimize ("O3")
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359


/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace __gnu_pbds;
typedef tree<pii,null_type,less <pii>,rb_tree_tag,tree_order_statistics_node_update>ind_set;
*/
///*X.find_by_order("index")
///X.order_of_key("key")



#define deb(x) cerr<<#x<< " : " <<x<<"\n";
#ifndef local
	#define deb(x) ;
#endif
///----------------------------------------------------------------------------------
int n,x,l[100005];
void solve()
{
	double w,h,x,y;
	cin>>w>>h>>x>>y;
	cout<<fixed<<setprecision(8)<<(w*h)/2<<" ";
	if (x==(w/2) && y==h/2)cout<<1;else cout<<0;
}

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);

    #ifdef local
    freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    #endif

    clock_t qwertyuiop = clock();
    int t=1;
    ///cin>>t;
    rep(a,0,t)
    {
        ///cout<<"Case #"<<a+1<<": ";
        solve();
    }
    #ifdef local
	{qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}


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

#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")

using namespace std;

typedef long long ll;
typedef long double ld;


void solve() {
    int n;
    cin >> n;
    ll res = 0;
    int maxi = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        if (x < maxi) res += maxi - x;
        else maxi = x;
    }
    cout << res << "\n";
}

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

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int n = 3;
  
  vector<int> v(n);
  for(int i; i < n; i++)
    cin >> v.at(i);
  
  sort(v.begin(), v.end());
  int j = v.at(0);
  int k = v.at(1);
  
  cout << k + j << endl;
}
    

Measured memory_bytes: 256
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int n;
  string s,t,u;
  while(cin>>s&&s[0]!='-'){
    n=atoi(s.substr(0,s.find(".")).c_str());
    if(n>255){
      cout<<"NA"<<endl;
      continue;
    }
    t=u="0000";
    for(i=1;i<(s.find(".")==string::npos?1:(int)(s.length()-s.find(".")));i++)
      t[i-1]=s[s.find(".")+i];
    if(t[0]>'4'){
      t[0]-=5;
      u[0]++;
    }
    if(t[0]>'1'&&t[1]>'4'){
      t[0]-=2;
      t[1]-=5;
      u[1]++;
    }else if(t[0]>'2'){
      t[0]-=3;
      t[1]+=5;
      u[1]++;
    }
    if(t[0]>'0'&&t[1]>'1'&&t[2]>'4'){
      t[0]-=1;
      t[1]-=2;
      t[2]-=5;
      u[2]++;
    }
    if(t[1]>'5'&&t[2]>'1'&&t[3]>'4'){
      t[1]-=6;
      t[2]-=2;
      t[3]-=5;
      u[3]++;
    }
    if(t!="0000"){
      cout<<"NA"<<endl;
      continue;
    }
    for(i=0;i<8;i++){
      cout<<n/(int)pow(2,7-i);
      n%=(int)pow(2,7-i);
    }
    cout<<"."<<u<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int INF=0x3f3f3f3f;
const double pi=3.141592654;
vector<int> v[100005];
int boom[100005];
int main()
{
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    int a,b;
    for(int i=0; i<m; i++)
    {
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    //for(int i=0;i<v[6].size();i++) cout<<v[6][i]<<endl;
    queue<int>q;
    q.push(1);
    while(!q.empty())
    {
        int t=q.front();
        q.pop();
        for(int i=0; i<v[t].size(); i++)
        {
            if(boom[v[t][i]]==0)
            {
                boom[v[t][i]]=t;
                q.push(v[t][i]);
            }
        }
    }
    int i;
    for( i=2;i<=n;i++)
        if(boom[i]==0) break;
    if(i!=n+1)
        cout<<"No"<<endl;
    else
    {
        cout<<"Yes"<<endl;
        for(int j=2;j<=n;j++)
            cout<<boom[j]<<endl;
    }
    return 0;
}


Measured memory_bytes: 10408
class D_Linked_List:
    class Node:
        def __init__(self, key, next = None, prev = None):
            self.next = next
            self.prev = prev
            self.key = key

    def __init__(self):
        self.nil = D_Linked_List.Node(None)
        self.nil.next = self.nil
        self.nil.prev = self.nil

    def insert(self, key):
        node_x = D_Linked_List.Node(key, self.nil.next, self.nil)
        self.nil.next.prev = node_x
        self.nil.next = node_x

    def _listSearch(self, key):
        cur_node = self.nil.next
        while (cur_node != self.nil) and (cur_node.key != key):
            cur_node = cur_node.next
        return cur_node

    def _deleteNode(self, node):
        if node == self.nil:
            return None
        node.prev.next = node.next
        node.next.prev = node.prev

    def deleteFirst(self):
        self._deleteNode(self.nil.next)

    def deleteLast(self):
        self._deleteNode(self.nil.prev)

    def deleteKey(self, key):
        node = self._listSearch(key)
        self._deleteNode(node)

    def show_keys(self):
        cur_node = self.nil.next
        keys = []
        while cur_node != self.nil:
            keys.append(cur_node.key)
            cur_node = cur_node.next
        print(*keys)


import sys

d_ll = D_Linked_List()

for i in sys.stdin:
    if 'insert' in i:
        x = int(i.split()[1])
        d_ll.insert(x)
    elif 'deleteFirst' in i:
        d_ll.deleteFirst()
    elif 'deleteLast' in i:
        d_ll.deleteLast()
    elif 'delete' in i:
        x = int(i.split()[1])
        d_ll.deleteKey(x)
    else:
        pass

d_ll.show_keys()

Measured memory_bytes: 205336
h,w=map(int,input().split())
g=[input() for _ in range(h)]
a=['' for _ in range(h)]
for y in range(w):
  if any(s[y]=='#' for s in g):
    for x in range(h):
      a[x]+=g[x][y]
for s in a:
  if s.count('#'): print(s)

Measured memory_bytes: 9172