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

#define all(x) (x).begin(), (x).end()
#define sz(x) static_cast<int>((x).size())

using LL = long long;
template<class T, size_t D>
struct vec : vector<vec<T, D - 1>> {
  template<class... Args>
  vec(size_t n = 0, Args... args)
    : vector<vec<T, D - 1>>(n, vec<T, D - 1>(args...)) {}
};
template<class T>
struct vec<T, 1> : vector<T> {
  template<class... Args>
  vec(Args... args)
    : vector<T>(args...) {}
};

template<class T>
inline bool asMn(T& a, const T& b) { return a > b ? a = b, true : false; }
template<class T>
inline bool asMx(T& a, const T& b) { return a < b ? a = b, true : false; }
inline int nex(int i, int n) { return i == n - 1 ? 0 : i + 1; }
inline int pre(int i, int n) { return !i ? n - 1 : i - 1; }

mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

template<int MOD>
struct ModInt {
  int a;
  ModInt(int a_ = 0) {
    a = (a_ < MOD ? (a_ < 0 ? a_ + MOD : a_) : a_ - MOD);
  }
  friend ostream& operator<<(ostream& os, const ModInt& o) {
    os << o.a;
    return os;
  }

  bool operator!() const { return !a; }
  explicit operator bool() const { return !!a; }

  ModInt operator-() const { return ModInt() - *this; }
  ModInt operator+(const ModInt& o) const { return ModInt(a + o.a); }
  ModInt operator-(const ModInt& o) const { return ModInt(a - o.a); }
  ModInt operator*(const ModInt& o) const { return ModInt(static_cast<int>(static_cast<LL>(a) * o.a % MOD)); }
  ModInt operator/(const ModInt& o) const { return *this * o.inv(); }
  ModInt& operator+=(const ModInt& o) { return *this = *this + o; }
  ModInt& operator-=(const ModInt& o) { return *this = *this - o; }
  ModInt& operator*=(const ModInt& o) { return *this = *this * o; }
  ModInt& operator/=(const ModInt& o) { return *this = *this / o; }
  ModInt inv() const { return pow(MOD - 2); }
  template<class T>
  ModInt pow(T exp) const {
    ModInt ret(1), c = *this;
    for (; exp; exp >>= 1, c *= c) {
      if (exp & 1) {
        ret *= c;
      }
    }
    return ret;
  }
};
using Mint = ModInt<static_cast<int>(1e9 + 7)>;

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

//  freopen("input.txt", "r", stdin);

  int n; cin >> n;
  array<string, 2> s; cin >> s[0] >> s[1];
  vec<Mint, 2> f(3, 3);
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      if ((i == j) == (s[0][0] == s[1][0])) {
        f[i][j] = Mint(1);
      }
    }
  }
  for (int i = 1; i < n; ++i) {
    vec<Mint, 2> nxtF(3, 3);
    for (int j = 0; j < 3; ++j) {
      for (int k = 0; k < 3; ++k) {
        for (int nxtJ = 0; nxtJ < 3; ++nxtJ) {
          for (int nxtK = 0; nxtK < 3; ++nxtK) {
            if ((s[0][i] == s[0][i - 1]) == (nxtJ == j) &&
                (s[1][i] == s[1][i - 1]) == (nxtK == k) &&
                (s[0][i] == s[1][i]) == (nxtJ == nxtK)) {
              nxtF[nxtJ][nxtK] += f[j][k];
            }
          }
        }
      }
    }
    f.swap(nxtF);
  }

  Mint ans;
  for (int j = 0; j < 3; ++j) {
    for (int k = 0; k < 3; ++k) {
      ans += f[j][k];
    }
  }
  cout << ans << '\n';

  return 0;
}


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

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var str = Console.ReadLine();
                if (string.IsNullOrEmpty(str)) return;
                Console.WriteLine(str.Split(' ').Select(s => int.Parse(s)).Sum().ToString().Length);
            }
        }
    }
}

Measured memory_bytes: 5880
/*
 *  Lang    : C++
 *  Author  : little_angel
 */
#include <bits/stdc++.h>

using namespace std;
#define int long long
const int mod = 1e9 + 7;

inline int mul(int a, int b) {
    return a * b % mod;
}

inline void add(int &a, int b) {
    a += b;
    if (a >= mod)a -= mod;
}

int dp[2][101][2];
// {dp, new_dp}, sum, is_small

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

    string k;
    int d, f = 0;
    cin >> k >> d;
    int n = k.length();

    dp[0][0][0] = 1;
    for (int pos = 0; pos < n; ++pos) {
        for (int sum = 0; sum < d; ++sum) {
            for (bool small:{false, true}) {
                for (int dig = 0; dig < 10; ++dig) {
                    if (dig > k[pos] - '0' && !small)break;
                    add(dp[f ^ 1][(sum + dig) % d][small || dig < k[pos] - '0'], dp[f][sum][small]);
                }
            }
        }
        for (int sum = 0; sum < d; ++sum)
            for (bool small:{false, true})
                dp[f][sum][small] = 0;
        f ^= 1;
    }
    cout << (dp[f][0][false] + dp[f][0][true] - 1 + mod) % mod << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var NQ = ReadLine().Split().Select(int.Parse).ToArray();
        var N = NQ[0];
        var Q = NQ[1];
        var bit =  new RangeSumBIT(N);
        for (int i = 0; i < Q; i++)
        {
            var line = ReadLine().Split().Select(int.Parse).ToArray();
            if (line[0] == 0) bit.Add(line[1] - 1, line[2]);
            else
            {
                WriteLine(bit.Sum(line[2]) - bit.Sum(line[1]-1));
            }
        }
    }
}

public class RangeSumBIT
{
    int N;
    int[] buffer;

    public RangeSumBIT(int size)
    {
        N = size;
        buffer = new int[size + 1];
    }

    public void Add(int index, int value)
    {
        for (int i = index + 1; i <= N; i += i & -i) buffer[i] += value;
    }

    public int Sum(int index)//[0,index)
    {
        int ret = 0;
        for (int i = index; i > 0; i -= i & -i) ret += buffer[i];
        return ret;
    }
}


Measured memory_bytes: 22496
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long
constexpr int INF = 1000000000 + 8;

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

    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];

    sort(h.begin(), h.end());

    int ans = INF;

    for (int i = 0; i < n - k+1; i++) {
        ans = min(h[i + k - 1] - h[i], ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
def resolve():
    #n=int(input())
    #a,b=map(int,input().split())
    #x=list(map(int,input().split()))
    #a=[list(map(lambda x:int(x)%2,input().split())) for _ in range(h)]

    def popcount(n):
        c=format(n,'b').count('1')
        if c!=0:
            return n%c
        else:
            return 0
    def f(n):
        count=0
        while n>0:
            n=popcount(n)
            count+=1
        return count
        
    n=int(input())    
    x=input()
    cnt=x.count('1')
    x10=int(x,2)
    ans=[]
    a=x10%(cnt+1)
    if cnt==1:
        b=0
    else:
        b=x10%(cnt-1)
    for i in range(n):
        if x[i]=='1' and cnt==1:
            print(0)
            continue
        elif x[i]=='1':
            cal=(b-pow(2,n-1-i,cnt-1))%(cnt-1)
        else:
            cal=(a+pow(2,n-1-i,cnt+1))%(cnt+1)
        print(f(cal)+1)

if __name__ == '__main__':
    resolve()

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    string s;
    cin >> s;
    vector<ll> ans(int(s.length()));
    char ex = 'R';
    ll tmp = 0;
    REP(i, int(s.length())){
        if(ex == s[i]) tmp++;
        else{
            if(ex == 'R'){
                ans[i-1] += tmp / 2 + (tmp%2);
                ans[i] += tmp / 2;
            }
            else{
                ans[i-tmp-1] += tmp / 2;
                ans[i-tmp] += tmp / 2 + (tmp%2);
            }
            // cout << "tmp: " << tmp << endl;
            ex = s[i];
            tmp = 1;
        }
    }
    ans[int(s.length())-tmp-1] += tmp / 2;
    ans[int(s.length())-tmp] += tmp / 2 + (tmp%2);
    REP(i, int(s.length())) cout << ans[i] << " ";
    return 0;
}

Measured memory_bytes: 4280
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 ln         PIC X(30).
01 A          PIC 9(10).
01 B          PIC 9(10).
01 ans        PIC 9(10).
01 zs         PIC Z(9)9.

PROCEDURE DIVISION.
  ACCEPT ln.
  UNSTRING ln DELIMITED BY SPACE INTO A B.
  MULTIPLY A BY B GIVING ans.
  MOVE ans TO zs.
  DISPLAY FUNCTION TRIM(zs).
  STOP RUN.


Measured memory_bytes: 3864
n,m=map(int,input().split())
A=[]
for i in range(n):
    x,y,z=map(int,input().split())
    A.append([x,y,z])
    
F=[[1,1,1],[1,1,-1],[1,-1,1],[-1,1,1],[1,-1,-1],[-1,1,-1],[-1,-1,1],[-1,-1,-1]]
ans=0
for f in F:
    C=[]
    for i in range(n):
        s=f[0]*A[i][0]+f[1]*A[i][1]+f[2]*A[i][2]
        C.append([s,i])
    C=list(reversed(sorted(C)))
    cnt=[0,0,0]
    for i in range(m):
        a=C[i][1]
        for i in range(3):
            cnt[i]+=A[a][i]
    ans=max(abs(cnt[0])+abs(cnt[1])+abs(cnt[2]),ans)
print(ans)

Measured memory_bytes: 3316
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip, std.regex;

void main() {
    auto S = readln.chomp;
    auto K = readln.chomp.to!int;
    auto N = S.length.to!int;

    bool[string] cnt;
    foreach (len; 1..min(11, N+1)) {
        foreach (i; 0..N-len+1) {
            cnt[S[i..i+len]] = true;
        }
    }

    auto x = cnt.keys.array;
    x.sort();
    x[K-1].writeln;
}


Measured memory_bytes: 6908
#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-1);
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};
#define ll long long
#define inf int(1e9+7)
#define pb push_back
#define mp make_pair
string s;
int alph[26],ch[26];
int main()
{
	cin>>s;
	//if(s=="zyxwvutsrqponmlkjihgfedcba")
	//{
	//	puts("-1");
	//	return 0;
	//}
	for(int i=0;i<s.size();i++)
		alph[s[i]-'a']++;
	for(int i=0;i<26;i++)
		if(alph[i]==0)
		{
			cout<<s<<char(i+'a');
			return 0;
		}
	int j=0;
	for(int i=s.size()-1;i>=0;i--)
	{
		j++;
		string t=s;
		t.erase(i,j);
		memset(ch,0,sizeof(ch));
		for(int k=0;k<t.size();k++)
			ch[t[k]-'a']++;
		for(int k=0;k<26;k++)
			if(ch[k]==0)
			{
				string u=t;
				u+=(char)k+'a';
				//cout<<u<<endl;
				if(u>s)
				{
					cout<<u;
					return 0;
				}
			}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
const Int MAX = 303;
Int a[MAX][MAX];
signed main(){
  Int n,m;
  cin>>n>>m;
  for(Int i=0;i<n;i++)
    for(Int j=0;j<m;j++)
      cin>>a[i][j],a[i][j]--;

  auto check=
    [&](Int x)->Int{
      vector<Int> p(n,0),cnt(m,0),used(m,0);
      for(Int i=0;i<n;i++) cnt[a[i][p[0]]]++;

      queue<Int> q;
      for(Int j=0;j<m;j++)
        if(cnt[j]>x) q.emplace(j);

      while(!q.empty()){
        Int v=q.front();q.pop();
        if(used[v]) continue;
        used[v]=1;
        for(Int i=0;i<n;i++){
          if(p[i]==m) continue;
          while(used[a[i][p[i]]]){
            p[i]++;
            if(p[i]==m) break;
            cnt[a[i][p[i]]]++;
            if(cnt[a[i][p[i]]]>x)
              q.emplace(a[i][p[i]]);
          }
        }
      }
      
      for(Int j=0;j<m;j++)
        if(!used[j]) return 1;
      return 0;      
    };
  
  Int l=0,r=n;
  while(l+1<r){
    Int mid=(l+r)>>1;
    if(check(mid)) r=mid;
    else l=mid;
  }
  cout<<r<<endl;
  return 0;
}


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

void maxHeapify(vector<int>& heap, int i)
{
    while (i <= (heap.size() - 1) / 2) {
        int largest = i;
        if (heap[largest] < heap[i * 2]) {
            largest = i * 2;
        }
        if (i * 2 + 1 < heap.size() && heap[largest] < heap[i * 2 + 1]) {
            largest = i * 2 + 1;
        }
        if (largest != i) {
            swap(heap[i], heap[largest]);
        } else {
            break;
        }
        i = largest;
    }
}

void buildHeap(vector<int>& heap)
{
    for (int i = heap.size() / 2; i >= 1; --i) {
        maxHeapify(heap, i);
    }
}

int main()
{
    // Input
    int n;
    cin >> n;
    vector<int> heap(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> heap[i];
    }

    // Solve
    buildHeap(heap);

    // Output
    for (int i = 1; i < heap.size(); ++i) {
        cout << " " << heap[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 4576
#include <stdio.h>

/* 配列の要素を順番に出力 */
void trace(int A[],int N) {
	int i;//出力する配列の先頭アドレス、出力する数
	for(i=0;i<N;i++) {
		/* 隣接する要素の間に1つの空白を出力 */
		if(i>0) printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
}

/* 挿入ソート(0オリジン配列) */
void insertionSort(int A[], int N) {
	int i,j,v;
	for(i=1;i<N;i++) {
		v=A[i];
		j=i-1;
		while(j>=0 && A[j] > v) {
			A[j+1] = A[j];
			j--;
		}
		A[j+1]=v;
		trace(A,N);
	}
}

int main(void)
{
	int N, i, j;
	int A[100];
	scanf("%d",&N);
	for(i=0;i<N;i++) scanf("%d",&A[i]);
	
	trace(A,N);
	insertionSort(A,N);
	return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, N);
    vector<int> a(1e5+10, 0);

    int MAX = 0;
    for (int i = 0; i < N; i++) {
        int temp;
        cin >> temp;
        a[temp + 0]++;
        a[temp + 1]++;
        a[temp + 2]++;
        MAX = max(MAX, temp + 2);
    }

    int ans = 0;
    for (int i = 0; i <= MAX; i++) {
        ans = max(ans, a[i]);
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long ll;

template <typename T> inline bool chkmin(T &x,T y) { return y < x ? x = y,1 : 0; }
template <typename T> inline bool chkmax(T &x,T y) { return x < y ? x = y,1 : 0; }

const int INF = 0x3f3f3f3f;
const int N = 2e3 + 10,mod = 998244353;

int va[N][N],Sa[N][N],vb[N][N],Sb[N][N],ans[N * 2];

inline int read() {
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-')ch = getchar();
	if(ch == '-')flag = -1,ch = getchar();
	while(isdigit(ch))x = (x << 3) + (x << 1) + (ch - '0'),ch = getchar();
	return x * flag;
}

int main() {

	int k = read(),n = read();
	va[0][0] = va[1][0] = va[1][1] = Sa[1][0] = 1;
	For(i,0,n) Sa[0][i] = 1;
	For(i,1,n) Sa[1][i] = 2;

	For(i,2,k) For(j,0,n) {
		va[i][j] = va[i - 2][j];
		if(j) va[i][j] = (va[i][j] + 2ll * Sa[i - 2][j - 1]) % mod;
		Sa[i][j] = va[i][j];
		if(j) Sa[i][j] = (Sa[i][j - 1] + Sa[i][j]) % mod;
	}

	For(i,0,k + 1) Sb[0][i] = 1;
	vb[0][k + 1] = 1;
	For(i,1,n) Fordown(j,k,1) {
		vb[i][j] = Sb[i - 1][j];
		Sb[i][j] = (Sb[i][j + 1] + vb[i][j]) % mod;
	}

	For(i,2,k + 1) For(j,0,n) ans[i] = (ans[i] + 1ll * va[i - 1][j] * Sb[n - j][i]) % mod;
	For(i,2,k + 1) printf("%d\n",ans[i]);
	Fordown(i,k,2) printf("%d\n",ans[i]);
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

int dp[3001][3001];

void solve() {
  string s, t;
  cin >> s >> t;
  int n = s.size();
  int m = t.size();
  rep(i, n) rep(j, m) {
    amax(dp[i+1][j+1], max(dp[i+1][j], dp[i][j+1]));
    if (s[i] == t[j]) amax(dp[i+1][j+1], dp[i][j] + 1);
  }
  string ans;
  int x = n, y = m;
  while (true) {
    if (dp[x][y] == 0) break;
    if (x > 0 && dp[x][y] == dp[x-1][y]) { x--; continue; }
    if (y > 0 && dp[x][y] == dp[x][y-1]) { y--; continue; }
    x--, y--;
    ans += s[x];
  }
  reverse(all(ans));
  cout << ans << endl;
}


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

#ifdef TESTING
  #include "dump.hpp"
#else
  #define DUMP(...)
  #define DEBUG(...)
#endif

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define INT(n) int n;assert(0<scanf("%d",&n))
#define LL(n) ll n;assert(0<scanf("%lld",&n))

int main(){
  ll ans = 0;
  vector<ll> xs, vs;
  INT(n); LL(c);
  REP(n){
    LL(x); LL(v); xs.PB(x); vs.PB(v);
  }
  vector<ll> l1, l2, r1, r2;
  l2.PB(0); r2.PB(0);
  REP(i, n){
    l2.PB(l2[i] + vs[i]);
    l1.PB(l2[i + 1]);
    r2.PB(r2[i] + vs[n - 1 - i]);
    r1.PB(r2[i + 1]);
  }
  REP(i, n){
    l1[i] -= xs[i];
    l2[i + 1] -= xs[i] * 2;
    r1[i] -= (c - xs[n - 1 - i]);
    r2[i + 1] -= (c - xs[n - 1 - i]) * 2;
  }
  REP(i, 1, n + 1){
    l2[i] = max(l2[i - 1], l2[i]);
    r2[i] = max(r2[i - 1], r2[i]);
  }
  REP(i, 1, n){
    l1[i] = max(l1[i - 1], l1[i]);
    r1[i] = max(r1[i - 1], r1[i]);
  }
  ans = max(ans, l1[n - 1]);
  ans = max(ans, r1[n - 1]);
  REP(i, n){
    ans = max(ans, l2[n - 1 - i] + r1[i]);
    ans = max(ans, r2[n - 1 - i] + l1[i]);
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 6380
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <time.h>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <string.h>

#define sf scanf
#define pf printf
#define lf double
#define ll long long
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define p(n) printf("%d",n);
#define pln(n) printf("%d\n",n);
#define s(n) scanf("%d",&n);
#define ss(n) scanf("%s",n);
#define ps(n) printf("%s",n);
#define sld(n) scanf("%lld",&n);
#define pld(n) printf("%lld",n);
#define slf(n) scanf("%lf",&n);
#define plf(n) printf("%lf",n);
#define sc(n) scanf("%c",&n);
#define pc(n) printf("%c",n);
#define gc getchar();
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
using namespace std;
const ll mod = 1e9+7;
ll a[100050];
ll b[100050];

int main() {
    //pld(C)
    ll n,m;
    sld(n)
    sld(m)
    ll cheng1 = 0;
    ll cheng2 = 0;
    ll sum = 0;
    sld(a[0])
    sum = a[0];
    for(ll i = 1; i < n; i ++){
        sld(a[i])
        cheng1 += (((a[i]*i)%mod)-sum+mod+mod)%mod;
        cheng1 += mod+mod;
        cheng1 %= mod;
        sum += a[i];
        sum %=mod;
    }
    sum = 0;
    sld(b[0])
    sum = b[0];
    for(ll i = 1; i < m; i ++){
        sld(b[i])
        cheng2 += (((b[i]*i)%mod)-sum+mod+mod)%mod;
        cheng2 += mod+mod;
        cheng2 %= mod;
        sum += b[i];
        sum %=mod;
    }
    pld((cheng1*cheng2) %mod) pn



    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    int n, m, a, b, c;
    string s, t;
    cin >> s;
    n = 700;
    rep(i, 3) {
        if(s[i] == 'o') n += 100;
    }
    cout << n;
}


Measured memory_bytes: 256
n = int(input())
a = []

for i in range(n):
    syougen_num = int(input())
    ai = []
    for j in range(syougen_num):
        xi_yi = list(map(int, input().split()))
        ai.append(xi_yi)
    a.append(ai)

res = 0
for i_bin in range(1 << n):
    syougen_list = [[0, 0] for i in range(n)]
    one_counter = 0
    for keta in range(n):
        # 1を正直者にした
        if i_bin >> keta & 1 == 1:
            one_counter += 1
            for i_syougen in a[keta]:
                #yi :0は不親切 :1は正直者 
                xi, yi = i_syougen
                syougen_list[xi - 1][yi] += 1
    for i_syougen in range(n):
        if syougen_list[i_syougen][0] >= 1 and syougen_list[i_syougen][1] >= 1:
            break
        elif syougen_list[i_syougen][0] >= 1 and i_bin >> i_syougen & 1 == 1:
            break
        elif syougen_list[i_syougen][1] >= 1 and i_bin >> i_syougen & 1 == 0:
            break
    else:
        res = max(res, one_counter)
        flag = i_bin
    # print(syougen_list, i_bin, one_counter, flag)
print(res)





Measured memory_bytes: 9188
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <cstdlib>
#define PI acos(-1.0)
#define ll long long int
#define db double
#define ull unsigned long long int
#define Fill(x,y) memset(x,y,sizeof(x))
#define bug printf("!!!!!!\n");
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
using namespace std;
const db eps = 1e-6;
const int inf = 0x3f3f3f3f; //用这个可以直接mem
const ll INF = 1e18;
const int mod = 1e9+7;
const int maxn = 1e5+5;
int cas=1;
int vis[200];
void solve()
{
    int n , y;
    cin >> n >> y;
    y /= 1000;
    for (int i = 0 ; i <= n ; i++) {
        for (int j = 0 ; j+i <= n ; j++){
            int k = n - i - j;
            if (i * 10 + j * 5 + k == y) {
                cout << i << ' ' << j << ' ' << k << endl;
                return ;
            }
        }
    }
    cout << -1 << ' ' << -1 << ' ' << -1 << endl;
}
int main()
{
   //  freopen("in.txt","r",stdin);
    //  freopen("out.txt","w",stdout);
    int t = 1 ;
    //scanf("%d",&t);
    while(t--){
       // printf("Case %d: ", cas++);
        solve();
        //printf("\n");
    }
}









Measured memory_bytes: 256
#include <stdio.h>

int main(void){

	int word[26];
	char x;

	for(x=0; x<26; x++){
		word[x]=0;
	}

	while(!feof(stdin)){
		x = fgetc(stdin);
		if('a'<=x && x<='z'){
			x-='a'-'A';
		}
		if('A'<=x && x<='Z'){
			word[x-'A']++;
		}
	}

	for(x=0; x<26; x++){
		printf("%c : %d\n", 'a'+x, word[x]);
	}

	return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int n = s.size();
    for(int i=0;i<n;i++)
    {
        if(i%2==0)
        {
            if(s[i]=='R' || s[i]=='U' || s[i]=='D')
                continue;
            else
            {
                return cout<<"No\n",0;
            }
        }
        else
        {
            if(s[i]=='L' || s[i]=='U' || s[i]=='D')
                continue;
            return cout<<"No\n",0;
        }
    }
    cout<<"Yes\n";
    return 0;
}


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

string s;

void solve() {
  int ans = 0;
  int start = 0;
  int end = s.size() - 1;
  while (start < end) {
    if (s[start] == s[end]) {
      start++;
      end--;
    } else if (s[start] == 'x') {
      start++;
      ans++;
    } else if(s[end] == 'x') {
      end--;
      ans++;
    } else {
      cout << -1 << endl;
      return;
    }
  }
  cout << ans << endl;
}

int main() {
  cin >> s;

  solve();
  return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
int main(void){
    int a, b;
    char op;
    
    
    while(1){
        scanf("%d %c %d",&a,&op,&b);
        
        if(op == '?'){
            break;
        }
        
        else if(op == '+'){
        printf("%d\n", a+b);
        }
        
        else if(op == '-'){
        printf("%d\n", a-b);
        }
        
        else if(op == '*'){
        printf("%d\n", a*b);
        }
        
        else if(op == '/'){
        printf("%d\n", a/b);
        }
    }
    return 0;
}    


Measured memory_bytes: 2080
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define MAX 200001
s64 fac[MAX], finv[MAX], inv[MAX];

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

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

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

    s64 n, k;
    cin >> n >> k;
    COMinit();

    k = MIN(n, k);
    s64 ans = 0;
    rep (i, k + 1)
    {
        ans += (COM(n, i) * COM(n - 1, i)) % MOD;
        ans %= MOD;
    }

    cout << ans << "\n";
    return 0;
}



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

sq = [xi ** 2 for xi in x]

sum_sq = sum(sq)
sum_x = sum(x)

hp = []

for p in range(min(x), max(x)+1):
    hp.append(sum_sq - 2*p*sum_x + n* (p **2))

print(min(hp))

Measured memory_bytes: 3064
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
#include<limits>
#include <bitset>
#include <numeric>
#include <type_traits>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
const int N = 1000000;
const int INF = 1 << 30;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
int main() {
	int n, m;
	int v[200010] = {}, v2[200010] = {};
	bool bb = 0;
	cin >> n >> m;
	rep(i, m) {
		int a, b; cin >> a >> b;
		if (a == 1) { 
			v[b] = 1;
			if (v2[b] == 1) { bb = 1; break; }
		}
		if (b == n) { 
			v2[a] = 1; 
			if (v[a] == 1) { bb = 1; break; }
		}
	}
	cout<<(bb?"POSSIBLE":"IMPOSSIBLE")<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <set>

using namespace std;

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

    string S;
    cin >> S;
    set<int> p[26];
    for(int i=0; i<S.length(); i++){
        p[S[i]-'a'].insert(i);
    }

    int Q;
    cin >> Q;
    vector<int> ans;
    for(int i=0; i<Q; i++){
        int type;
        cin >> type;
        if(type == 1){
            int t;
            char c;
            cin >> t >> c;
            t--;
            p[S[t]-'a'].erase(t);
            p[c-'a'].insert(t);
            S[t] = c;
        }else{
            int l, r;
            cin >> l >> r;
            l--;r--;
            int cnt = 0;
            for(int j=0; j<26; j++){
                auto it = p[j].lower_bound(l);
                if(it == p[j].end()) continue;
                if(*it <= r) cnt++;
            }
            ans.push_back(cnt);
        }
    }

    for(int i=0; i<ans.size(); i++){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 24452
def solve(start, end, limit):
    # time O(1)
    return ":(" if end - start > limit else "Yay!"


def main():
    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())
    e = int(input())
    k = int(input())

    ans = solve(a, e, k)
    print(ans)


main()


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;

int main(){
    int n;
    cin >> n;
    int np = n;
    int m = 0;
    while(np != 0){
        m += np%10;
        np /= 10;
    }
    bool f = n%m == 0;
    cout << (f ? "Yes" : "No") << endl;
}

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

int main()
    {
     	vector<int> x(3);
      for( int i = 0;i <3; ++i ){
        cin >> x[i];
      }
      sort(x.begin(),x.end());
      if( x[0] == 5 && x[1] == 5 && x[2] == 7 ){
       cout << "YES"; 
      }
      else {
        cout << "NO"; 
      }
      cout << endl;
    	return 0; 
    }

Measured memory_bytes: 888
# -*- coding: utf-8 -*-
"""
All Numbers Lead to 6174
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0259

"""
import sys


Memo = {d*4: 'NA' for d in '0123456789'}
Memo['6174'] = 0

def solve(N):
    x = N
    res = []
    while x not in Memo:
        res.append(x)
        l = ''.join(sorted(x, reverse=True))
        s = ''.join(sorted(x))
        x = '{:04d}'.format(int(l) - int(s))
    for i, r in enumerate(res):
        Memo[r] = len(res) - i + Memo[x]
    return Memo[N]


def main(args):
    while True:
        N = input()
        if N == '0000':
            break
        ans = solve(N)
        print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])



Measured memory_bytes: 6552
package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	"strings"
)

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var s string
	Fscan(in, &s)
	Fprintln(out, strings.Repeat("x", len(s)))
}

func main() { run(os.Stdin, os.Stdout) }


Measured memory_bytes: 640
m = {}
ans = 0
n = int(input())
def C(x:int) -> 'conbination_nC2':
	return x*(x-1)/2

for i in range(n):
	s = input()
	new_str = ''.join(sorted(s))
	if new_str in m.keys() :
		m[new_str] += 1
	else :
		m[new_str] = int(1)
	

for i in m:
	ans += C(m[i])

print(int(ans))



Measured memory_bytes: 17888
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
			String[] s = str.split(" ",0);
			int a = Integer.parseInt(s[0]);
			int b = Integer.parseInt(s[1]);
			int c = Integer.parseInt(s[2]);
			int[] x = new int[3];
			x[0] = a + b;
			x[1] = a + c;
			x[2] = b + c;
			Arrays.sort(x);
			System.out.println(x[0]);

		}catch (Exception e) {
			System.exit(0);
		}
	}
}


Measured memory_bytes: 21332
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    if(N<10){System.out.println(N);}
    else if(N<100){System.out.println(9);}
    else if(N<1000){System.out.println(N-90);}
    else if(N<10000){System.out.println(909);}
    else if(N<100000){System.out.println(N-9090);}
    else{System.out.println(90909);}
  }
}

Measured memory_bytes: 21844
//सत्यान्न प्रमदितव्यम्  ||
//Still, Taking my time to perfect the beats
//And I still got love for the streets, it's the A-D-D-U

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define nt _int128
#define fir first
#define sec second
#define fast_as_levi ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define debug(x) cout<<x<<"\n";
#define debugged cout<<"debugged\n";
#define inf 0x3f3f3f3f
#define LINF  0x3f3f3f3f3f3f3f3fll
#define rall(v) v.rbegin(),v.rend()
#define all(v) v.begin(),v.end() 

const ll mod = 999983;
#define mx 1000005
const ll mxi = 10005;

int main()
{
    fast_as_levi;
    ll n,k;
    cin>>n>>k;
    ll ar[n+1] = {0};
    while(k--)
    {
        ll d;
        cin>>d;
        while(d--)
        {
            ll x;
            cin>>x;
            ar[x] = 1;
        }
    }
    ll ans = 0;
    for(int i=1;i<=n;i++)
    {
        if(ar[i]==0)
        {
            ans++;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3604
//32
#include<iostream>
#include<utility>
#include<algorithm>

using namespace std;

int h,w,s;
int u[33][33];
int mn;
int um[33][33][33][33];
int bm[33][33][33][33];

typedef pair<int,int> pii;

int getp(int l,int t,int r,int b){
  return u[b][r]-u[b][l]-u[t][r]+u[t][l];
}

pii add(pii a,pii b){
  return make_pair(a.first+b.first,min(a.second,b.second));
}

pii dfs(int l,int t,int r,int b){
  if(um[l][t][r][b]){
    return make_pair(bm[l][t][r][b],um[l][t][r][b]);
  }else{
    pii rt=pii(1,getp(l,t,r,b));
    for(int i=l+1;i<r;i++){
      if(getp(l,t,i,b)>=mn&&getp(i,t,r,b)>=mn){
	rt=max(rt,add(dfs(l,t,i,b),dfs(i,t,r,b)));
      }
    }
    for(int j=t+1;j<b;j++){
      if(getp(l,t,r,j)>=mn&&getp(l,j,r,b)>=mn){
	rt=max(rt,add(dfs(l,t,r,j),dfs(l,j,r,b)));
      }
    }
    um[l][t][r][b]=rt.second;
    bm[l][t][r][b]=rt.first;
    return rt;
  }
}
 
int main(){
  while(cin>>h>>w>>s,h|w|s){
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	int c;
	cin>>c;
	u[i+1][j+1]=u[i+1][j]+u[i][j+1]-u[i][j]+c;
      }
    }
    int us=getp(0,0,w,h);
    mn=us-s;
    fill(um[0][0][0],um[33][0][0],0);
    fill(bm[0][0][0],bm[33][0][0],0);
    pii r=dfs(0,0,w,h);
    cout<<r.first<<' '<<r.second-mn<<endl;
  }
  return 0;
}

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

bool is_prime(const unsigned n){
    switch(n){
        case 0:
        case 1: return false;
        case 2: return true;
    }

    if(n%2 == 0) return false;

    for(unsigned i=3;i*i<=n;i+=2){
        if(n%i == 0) return false;
    }

    return true;
}

int main(){
    int q;cin>>q;
    vector<pair<int, int>> queries(q);
    int max_r = 0;
    for (int i=0;i<q;i++){
        int l, r;
        cin >> l >> r;
        if (r >= max_r){
            max_r = r;
        }
        queries[i] = make_pair(l, r);
    }
    map<int, long long> acc;
    acc[-1] = 0;
    for (int i=1;i<=max_r;i+=2){
        if (is_prime(i) && is_prime((i + 1) / 2)){
            acc[i] = acc[i - 2] + 1;
        } else {
            acc[i] = acc[i - 2];
        }
    }
    for (auto p : queries){
        cout << acc[p.second] - acc[p.first - 2] << endl;
    }
    return 0;

}

Measured memory_bytes: 4608
import sys
from collections import deque
input = sys.stdin.readline

Y, M, D = map(int, input().split('/'))
if Y < 2019 :
    print('Heisei')
elif Y == 2019 and M < 3:
    print('Heisei')
elif Y == 2019 and M == 4 and D <= 30:
    print('Heisei')
else:
    print('TBD')

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N,K;
    cin>>N>>K;
    long double counter=0.0;
    long double proS=1.0/N;
    long double proALL=proS;

    for(int i=1; i<=N; i++) {
        int point=i;
        if(point>=K) proALL=proS;
        else {
            /*while(point<=K) {
                point*=2;
                proALL/=2;
            }*/
            for(int j=point; ; j++) {
                if(point>=K) break;
                else {
                    point*=2; proALL/=2;
                }
            }
        }
        counter+=proALL;
        proALL=proS;
    }
    cout<<fixed<<setprecision(15);
    cout<<counter<<endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split()))
max_h = [0]*N
ans = 0
for i in range(M):
    a, b = map(int, input().split())
    max_h[a-1] = max(max_h[a-1], H[b-1])
    max_h[b-1] = max(max_h[b-1], H[a-1])
for j in range(N):
    if max_h[j] < H[j]:
       ans += 1
print(ans)


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

int main() {
  long long N, D;
  cin >> N >> D;
  int count = 0;

  for(int i = 0; i < N; i++){
    long long X, Y;
    cin >> X >> Y;
    if(X*X + Y*Y <= D*D){
      count ++;
    }
  }
  cout << count;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
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; }
#define int ll
signed main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 1000;
    ll stock = 0;
    rep(i,n-1) {
        if(a[i] < a[i+1]) {
            ll buy = ans/a[i];
            stock += buy;
            ans -= buy * a[i];
        } else if(a[i] > a[i+1]){
            ans += stock * a[i];
            stock = 0;
        }
    }
    ans += stock * a[n-1];
    cout << ans << endl;
}


Measured memory_bytes: 3656
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <iomanip>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
ll w,h,x,y;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> w>>h>>x>>y;
    ll ans=w*h/2;
    double am=0.0;
    if((w*h)%2==1){
        am=0.5;
    }
    char c='0';
    if(w/2==x&&h/2==y&&w%2==0&&h%2==0){
        c='1';
    }
    cout<<setprecision(27)<< ans+am;
    cout<<" "<<c<<"\n";
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

MOD = 10 ** 9 + 7

def cumprod(A, MOD = MOD):
    L = len(A); Lsq = int(L**.5+1)
    A = np.resize(A, Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        A[:,n] *= A[:,n-1]; A[:,n] %= MOD
    for n in range(1,Lsq):
        A[n] *= A[n-1,-1]; A[n] %= MOD
    return A.ravel()[:L]


def make_fact(U, MOD = MOD):
    x = np.arange(U, dtype = np.int64); x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64); x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    fact.flags.writeable = False
    fact_inv.flags.writeable = False
    return fact,fact_inv

fact, fact_inv = make_fact(2 * 10**6 + 10)

def F(i,j):
    return fact[i+j+2] * fact_inv[i+1] % MOD * fact_inv[j+1] % MOD

a,b,c,d = map(int,read().split())

answer = F(c,d) - F(a-1,d) - F(c,b-1) + F(a-1,b-1)
answer %= MOD
print(answer)


Measured memory_bytes: 90548
import java.util.*;
import java.io.*;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author /\
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DKi solver = new DKi();
        solver.solve(1, in, out);
        out.close();
    }

    static class DKi {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int q = in.nextInt();
            List<Integer>[] adj = new List[n];
            for (int i = 0; i < n; i++) {
                adj[i] = new ArrayList<>();
            }
            for (int i = 0; i < n - 1; i++) {
                int a = in.nextInt();
                int b = in.nextInt();
                adj[a - 1].add(b - 1);
                adj[b - 1].add(a - 1);
            }
            long[] added = new long[n];
            while (q-- > 0) {
                int p = in.nextInt() - 1;
                int x = in.nextInt();
                added[p] += x;
            }
            long[] res = new long[n];
            res[0] = added[0];
            boolean[] vis = new boolean[n];
            vis[0] = true;
            dfs(0, res, added, adj, vis);
            StringBuilder sb = new StringBuilder();
            for (long i : res) {
                sb.append(i).append(" ");
            }
            out.print(sb);
        }

        static void dfs(int node, long[] res, long[] added, List<Integer>[] adj, boolean[] vis) {
            for (int i : adj[node]) {
                if (!vis[i]) {
                    vis[i] = true;
                    res[i] = res[node] + added[i];
                    dfs(i, res, added, adj, vis);
                }
            }
        }

    }

    static class Scanner {
        private StringTokenizer st;
        private BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

int main() {
 int n ;cin>>n; double sum=0; string u[n];double x[n];
  for(int i=0;i<n;i++){
    cin>>x[i]>>u[i];
  }
    
   
  for(int i=0;i<n;i++) {
   // cout<<u[i];
    if(u[i]=="BTC") sum += 380000.0*x[i];
      else sum+= x[i];
   // cout<<sum<<endl;
 }
  
   
  cout<<sum<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)
#define pi 3.141592653589793238462643

void solve(){
    char ch;
    cin>>ch;
    cout<<char(ch+1)<<endl;
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        
    
}


Measured memory_bytes: 256