akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    string s; cin >> s;
    ll prev = 0, cnt = 1;
    ll ans = 0;
    auto f = [](ll x){return (x+1) * x / 2;};
    REP(i,s.size()) {
        if (i == s.size()-1) {
            if (s[i] == '>') {
                //cerr << " ";
                ans += f(min(prev,cnt)-1);
                ans += f(max(prev,cnt));
            } else ans += f(cnt);
        } else if (s[i] != s[i+1]) {
            if (s[i] == '>') {
                ans += f(min(prev,cnt)-1);
                ans += f(max(prev,cnt));
                prev = 0;
                cnt = 0;
            } else {
                prev = cnt;
                cnt = 0;
            }
        }
        cnt++;
        //cerr << cnt << endl;
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 1172
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    a, b = list(map(int, input().rstrip('\n').split()))
    for i in range(1, 1500):
        if int(i * 0.08) == a and int(i * 0.1) == b:
            print(i)
            exit()
    print(-1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38512
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MAX max<ll>
#define MIN min<ll>
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll devc(ll x, ll y) { return (x + y - 1) / y; }

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

    ll N;
    cin >> N;
    vec S(N);
    ll sum = 0, mn = INF;
    rep(i, N){
        cin >> S[i], sum += S[i];
        if(S[i] % 10 != 0) chmin(mn, S[i]);
    }
    if(sum % 10 != 0) drop(sum);
    else if(mn != INF) drop(sum - mn);
    else drop(0);


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin(),(x).end()
#define lowbit(x) x&-x
#define pb push_back
#define ls (id<<1)
#define rs (id<<1|1)
#define Rint register int
#define UNI(x) sort(ALL(x)),x.resize(unique(ALL(x))-x.begin())
#define GETPOS(c,x) (lower_bound(ALL(c),x)-c.begin())
#define LEN(x) strlen(x)
#define MS0(x) memset((x),0,sizeof((x)))
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<pii> Vpii;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(ll &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const ll &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
const int MAXN=1e6+10,MAXM=4e6+10;
const int INF=INT_MAX,SINF=0x3f3f3f3f;
const ll llINF=LLONG_MAX;
const int MOD=1e9+7,mod=998244353;
const int inv2=5e8+4;
const int Lim=1<<20;


void solve()
{
    int a,b,c,d;
    R(a,b,c,d);
    while(1)
    {
        c-=b;
        if(c<=0)return W("Yes");
        a-=d;
        if(a<=0)return W("No");
    }
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
	int t=1;
	//R(t);
	while(t--)solve();
	return 0;
}


Measured memory_bytes: 3828
h,w,k = map(int,input().split())
c_list = []
for _ in range(h):
    c_list.append([c for c in input()])

row_count = [c_row.count("#") for c_row in c_list]
column_count = [[c_low[i] for c_low in c_list].count("#") for i in range(w)]
all_count = sum(row_count)

def bit_tansaku(num):
    list_num = list(range(num))
    list_num_all = []
    for i in range(2**len(list_num)):
        list_temp = []
        for j in range(len(list_num)):
            if (i >> j) &1 == 1:
                list_temp.append(list_num[j])
        list_num_all.append(list_temp)
    return list_num_all

def reducible_num(row_list,column_list,row_count,column_count,c_list):
    count = sum([row_count[i] for i in row_list])+sum([column_count[i] for i in column_list])
    for i in row_list:
        for j in column_list:
            if c_list[i][j] == "#":
                count -= 1
    return count
list_h_all = bit_tansaku(h)
list_w_all = bit_tansaku(w)

count = 0
for list_h_i in list_h_all:
    for list_w_j in list_w_all:
        if all_count - reducible_num(list_h_i,list_w_j,row_count,column_count,c_list)==k:
            count+=1
print(count)

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const long double PI=3.14159265358979323846264338327950;
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  while(cin>>n){
      if(n==0){
          break;
      }
      string s;
      cin>>s;
      vint player(n,0);
      int ba=0;
      int si=s.size();
      rep(i,si){
          if(s[i]=='S'){
              ba+=player[i%n];
              player[i%n]=0;
              ba++;
          }
          else if(s[i]=='L'){
              player[i%n]++;
              player[i%n]+=ba;
              ba=0;
          }
          else{
              player[i%n]++;
          }
      }
      sort(all(player));
      rep(i,n){
          cout<<player[i]<<' ';
      }
      cout<<ba<<'\n';

  }
  return(0);
}


Measured memory_bytes: 3260
#include<stdio.h>

int main()
{
	int t;
	scanf("%d", &t);
	
	int a, b, cnt = 0, flag = 0;
	
	while(t--)
	{
		scanf("%d %d", &a, &b);
		if(a == b) cnt++;
		else cnt = 0;
		//printf("%d\n ", cnt);
		if(cnt >= 3) flag = 1;
	}
	
	if(flag) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

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

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????统一类型        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    string n;cin>>n;
    map<char,int>m;
    for(int i=0;i<4;i++)m[n[i]]++;
    cout<<m['2']<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------







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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

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


std::ostream &operator<<(std::ostream &dest, __int128_t value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
    if ('0' <= s[i] && s[i] <= '9')
      ret = 10 * ret + s[i] - '0';
  return ret;
}

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

  int n;
  cin >> n;

  __int128 x = 1;

  __int128 max_val;

  __int128 c, d;
  c = 1e9;
  d = 1e9;

  max_val = c * d + 1;

  rep(i, n){
    string s;
    cin >> s;
    __int128 a = parse(s);

    x = min(x*a, max_val);

  }
  
  if(x == max_val){
    cout << -1 << endl;
  }else{
    cout << x << endl;
  }

  return 0;
}


Measured memory_bytes: 3660
class Dice:
    def __init__(self, eyes):
        self._eyes = eyes

    @property
    def eye(self):
        return self._eyes[1]

    def roll(self, direction):
        if direction == 'N':
            old = self._eyes
            new = ['dummy'] * 7
            new[1] = old[2]
            new[2] = old[6]
            new[3] = old[3]
            new[4] = old[4]
            new[5] = old[1]
            new[6] = old[5]
            self._eyes = new
        elif direction == 'S':
            old = self._eyes
            new = ['dummy'] * 7
            new[1] = old[5]
            new[2] = old[1]
            new[3] = old[3]
            new[4] = old[4]
            new[5] = old[6]
            new[6] = old[2]
            self._eyes = new
        elif direction == 'W':
            old = self._eyes
            new = ['dummy'] * 7
            new[1] = old[3]
            new[2] = old[2]
            new[3] = old[6]
            new[4] = old[1]
            new[5] = old[5]
            new[6] = old[4]
            self._eyes = new
        elif direction == 'E':
            old = self._eyes
            new = ['dummy'] * 7
            new[1] = old[4]
            new[2] = old[2]
            new[3] = old[1]
            new[4] = old[6]
            new[5] = old[5]
            new[6] = old[3]
            self._eyes = new
        else:
            raise ValueError('NEWS箱推し')


eyes = ['dummy'] + input().split()
dice = Dice(eyes)

direction_text = input()
for d in direction_text:
    dice.roll(d)

print(dice.eye)



Measured memory_bytes: 5576
#include <iostream>
#include <cmath>

using namespace std;

int max_sum (int a, int b, int c, int k);
int main()
{
  int a, b, c;
  int k;
  cin >> a >> b >> c;
  cin >> k;
  int m = max_sum(a, b, c, k);
  cout << m << endl;
}

int max_sum (int a, int b, int c, int k)
{
  int sum;
  int r = pow(2, k);
  if((a - b >= 0) && (a - c >= 0)) {
    sum = r * a + b + c;
  } else if ((b - a >= 0) && (b - c >= 0)) {
    sum = r * b + a + c;
  } else {
    sum = r * c + a + b;
  }

  return sum;
}

Measured memory_bytes: 256
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())

const int maxn=200005;
const int H=31;
const ll mod=1e16+7;
int n;
string s;
char c[maxn];
int cnt[30];
ll ans;

int main(){
	scanf("%s",c);
	s=c;
	n=s.size();
	rep(i,n)cnt[s[i]-'a']++;
	ans=(ll)n*(ll)(n-1)/2ll+1ll;
	rep(i,26){
		ans-=(ll)cnt[i]*(ll)(cnt[i]-1)/2ll;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority queue
#include<deque>//double_ended queue
using namespace std;
int main()
{ 
    int h,w,n;
    cin>>h>>w>>n;
    int a[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    //せいぜい1万通りなので全部記述する。
    vector<vector<int> > v;
    vector<int> c;
    for(int i=1;i<=n;i++){
        for(int j=0;j<a[i];j++){
            c.push_back(i);
            if(c.size()==w){
                v.push_back(c);
                c.clear();            }
        }
    }
    int cnt=0;
    for(int i=0;i<h;i++){
        if(cnt==0){
            cnt=1;
            c=v.back();
            v.pop_back();
            for(int j=0;j<w-1;j++){
                cout<<c[j]<<' ';
            }
            cout<<c[w-1]<<endl;
        }
        else{
            cnt=0;
            c=v.back();
            v.pop_back();
            reverse(c.begin(),c.end());
            for(int j=0;j<w-1;j++){
                cout<<c[j]<<' ';
            }
            cout<<c[w-1]<<endl;
        }

    }
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define S second
#define I insert
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define debug1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define debug2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define debug3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"
#define INF (int)10000000000000000
#define PI (double)3.14159265358979
// #define M 421412341324321
#define MOD 1000000007


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

	

	int n, m;
	cin>>n>>m;

	int a[n];
	for (int i=0;i<n;++i)
	{
		cin>>a[i];
	}
	sort(a, a+n, greater <int> ());
	int l=0, h=2e5;
	while(l<h)
	{
		int mid = (l+h+1)/2;
		// debug1(mid);
		int start = 0, end = n-1, cnt=0;
		while(start<=end)
		{
			if (a[start]+a[end]>=mid)
			{
				cnt+=2*(end-start+1)-1;
				start++;	
			}
			else
			{
				end--;
			}
		}
		if (cnt>=m)
		{
			l=mid;
		}
		else
		{
			h = mid-1;
		}
	}
	int mn = l+1;
	int pre[n+1]={0};
	pre[0]=0;
	for (int i=0;i<n;++i)
	{
		pre[i+1]=pre[i]+a[i];
	}
	int start = 0, end = n-1, ans=0, c=0;
	while(start<=end)
	{
		if (a[start]+a[end]>=mn)
		{
			ans+=a[start]*(2*(end-start+1))+(pre[end+1]-pre[start+1])*2;
			c+=2*(end-start+1)-1;
			start++;
		}
		else
		{
			end--;
		}
	}
	int temp = m-c;
	// debug2(l, temp);
	ans+=temp*l;
	cout<<ans<<"\n";


	



	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void solve()
{
    string s, t; cin >> s >> t;
    int ans = INT_MAX;
    for (int i = 0; i + t.size() - 1 < s.size(); ++i) {
        int curr = 0;
        for (int j = 0; j < t.size(); ++j) {
            curr += t[j] != s[i + j];
        }
        ans = min(ans, curr);
    }
    cout << ans << '\n';
}

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

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#include <algorithm>
#include <queue>
using namespace std; 
int main(){
	int N; 
	cin >> N; 
	long long int ans = 0; 
	long long int A[100010] = {}, B[100010] = {}; 
	for(int i = 0; i < N; i++){
		cin >> A[i] >> B[i]; 
	}
	for(int i = N-1; i >= 0; i--){
		long long int c = B[i] - 1 - (A[i] + ans + B[i] - 1) % B[i]; 
		ans += c; 
	}
	cout << ans << endl; 
}

Measured memory_bytes: 1792
import collections

arr_length = int(input().rstrip())
arr = list(map(int,input().rstrip().split()))

arr_odd = arr[0::2]
arr_even = arr[1::2]

def count_strange(arr):
    c = collections.Counter(arr)
    keys, vals = zip(*c.most_common())
    return keys, vals

def proc(arr1, arr2):
    keys1, vals1 = count_strange(arr1)
    keys2, vals2 = count_strange(arr2)
    
    if keys1[0] == keys2[0]:
        if len(keys1) == 1 and len(keys2) == 1:
            print(vals1[0])# n = even number
        elif len(keys1) == 1 and len(keys2) > 1:
            print(len(arr2)-vals2[1])
        elif len(keys1) > 1 and len(keys2) == 1:
            print(len(arr1)-vals1[1])
        else: #>1
            print(
                min(
                    len(arr1)-vals1[1] + len(arr2)-vals2[0],
                    len(arr1)-vals1[0] + len(arr2)-vals2[1]
                    )
                    )
    else:
        print(len(arr1)-vals1[0] + len(arr2)-vals2[0])
    
proc(arr_odd, arr_even)

Measured memory_bytes: 21160
n,x=map(int, input().split())
lst=list(map(int,input().split()))
cnt=0
for i in range(n-1):
  if lst[i]+lst[i+1]>x:
    temp=(lst[i]+lst[i+1]-x)
    if lst[i+1]-temp>0:
      cnt+=temp
      lst[i+1]-=temp
    else:
      cnt+=temp
      lst[i+1]-=temp
      lst[i]+=lst[i+1]
      lst[i+1]=0
print(cnt)
      

Measured memory_bytes: 19988
#include<cstdio>

#define R(i, n) for(int i = 0; i < n; i++)
#define RR(i, n) for(int i = n; i >= 0; i--)
#define F(i, m, n) for(int i = m; i < n; i++)
#define FR(i, m, n) for(int i = m; i >= n; i--)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define P(a) printf("%d\n", a)
using namespace std;

int N;
char S[50];

int main(){
	S(N);
	scanf("%s", S);
	int ans = 0, i = 0;
	while(i < N){
		if(S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C'){
			ans++;
			i += 3;
		}else{
			i++;
		}
	}
	P(ans);
};

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
long long dp[101][100001];
pair<int,int> Array[105];

long long FindMaximumValue( int N , int W ){
    int i , j;

    for( i = 1 ; i <= N ; ++i ){
        for( j = 1 ; j <= W ; ++j ){
            if( j >= Array[i].first ) dp[i][j] = Array[i].second + dp[i - 1][j - Array[i].first];
            dp[i][j] = max( dp[i][j] , dp[i - 1][j] );
        }
    }

    return dp[N][W];
}

int main(){ 
    int N , W , i;
    scanf( "%d%d" , &N , &W );
   
    for( i = 1 ; i <= N ; ++i )
        scanf( "%d%d" , &Array[i].first , &Array[i].second );

    printf( "%lld\n" , FindMaximumValue( N , W ) );
    return 0;
}

Measured memory_bytes: 78336
N = int(input())
S = input()
com = 0
S_set = [set(S[_] for _ in range(N))]
for i in range(1, N - 1):
    S_com = set(S[:i]) & set(S[i:])
    if com < len(S_com):
        com = len(S_com)
print(com)

Measured memory_bytes: 3060
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int x = sc.nextInt();
      int happy = 0;
      int cnt1 = 0;
      int cnt2 = 0;
      while(x>=500){
         cnt1++;
         x = x-500;
      }
      happy += 1000*cnt1;
      while(x>=5){
         cnt2++;
         x = x-5;
      }
      happy += 5*cnt2;
      System.out.println(happy);     
   }
}

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

#define MAX 20*2000
using namespace std;
 
int main(void){

	int dp[MAX]={0};
	int n,q;
	int inp;
	int max=0,maxl;
	dp[0]=1;

	cin>>n;

	for(int i=0;i<n;i++){
		cin>>inp;
		maxl=0;
		for(int j=max;j>=0;j--){
			if(dp[j]==1){
				if(maxl<j+inp) maxl=j+inp;
				dp[j+inp]=1;
			}
		}
		max=maxl;
	}

	cin>>q;

	for(int i=0;i<q;i++){
		cin>>inp;
		if(dp[inp]==1) cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}

    return 0;
}

Measured memory_bytes: 1316
import java.util.*;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String S = in.readLine();
		if (S.equals("Sunny")) {
			System.out.println("Cloudy");
		} else if (S.equals("Cloudy")) {
			System.out.println("Rainy");
		} else {
			System.out.println("Sunny");
		}
	}
}


Measured memory_bytes: 20692
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define has(c,i) 		((c).find(i) != end(c))
#define has_str(s, c)	((s).find(c) != string::npos)
typedef long long ll;
int main() {
#ifdef online_judge
    freopen("input.txt", "rt", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, d;
    cin >> n >> d;
    int cnt = 0;
    while (n--) {
        double x, y;
        cin >> x >> y;
        x *= x;
        y *= y;
        double dist = x + y;
        dist = ceil(sqrt(dist));
        if(dist <= d)
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3864
#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;
 
int main() {
double x1, y1, x2, y2, x3, y3, xp ,yp,ss,s1,s2,s3;
while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>xp>>yp){
ss=fabs((x3-x1)*(y2-y1)-(x2-x1)*(y3-y1));
s1=fabs((x3-xp)*(y2-yp)-(x2-xp)*(y3-yp));
s2=fabs((x3-xp)*(y1-yp)-(x1-xp)*(y3-yp));
s3=fabs((x2-xp)*(y1-yp)-(x1-xp)*(y2-yp));
 
if(fabs(s1+s2+s3-ss)<0.001){
    cout<<"YES"<<endl;
}
else{
    cout<<"NO"<<endl;
}}
    return 0;
}

Measured memory_bytes: 3056
#include <stdio.h>
int main(){
  int n,max=0,sum=0;
  scanf("%d",&n);
  int l[n];
  for (int i=0;i<n;i++){
    scanf("%d",&l[i]);
    sum+=l[i];
    if (l[i]>l[max]){
      max=i;
    }
  }
  if (sum>2*l[max]){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
use proconio::input;

fn main(){
  input!{
    N:usize,
    M:usize,
    L:[[usize;2];M]
  }
  let mut ans=vec![0;N];
  for i in 0..M{
    for j in 0..2{
      ans[L[i][j]-1]=ans[L[i][j]-1]+1;
    }
  }
  for i in 0..N{
    println!("{}",ans[i]);
  }
}

Measured memory_bytes: 2124
#pragma GCC optimize("O3")
                #pragma comment(linker, "/stack:200000000")
                #pragma GCC optimize("unroll-loops")
                 
                #include <algorithm>
                #include <bitset>
                #include <cassert>
                #include <chrono>
                #include <cmath>
                #include <complex>
                #include <cstdio>
                #include <cstdlib>
                #include <cstring>
                #include <ctime>
                #include <deque>
                #include <functional>
                #include <iomanip>
                #include <iostream>
                #include <iterator>
                #include <limits>
                #include <climits>
                #include <list>
                #include <map>
                #include <numeric>
                #include <queue>
                #include <random>
                #include <ratio>
                #include <set>
                #include <sstream>
                #include <stack>
                #include <string>
                #include <unordered_map>
                #include <unordered_set>
                #include <utility>
                #include <vector>
                using namespace std;
                 
                typedef long long ll;
                typedef long double LD;
                #define int ll
                #define double LD
                #define pb push_back
                #define mp make_pair
                #define REP(i,n) for (int i = 0; i < n; i++)
                #define loop(i,n) for (int i = 0; i < n; i++)
                #define FOR(i,a,b) for (int i = a; i < b; i++)
                #define REPD(i,n) for (int i = n-1; i >= 0; i--)
                #define FORD(i,a,b) for (int i = a; i >= b; i--)
                #define remax(a,b) a = max(a,b)
                #define remin(a,b) a = min(a,b)
                #define mem(a, b) memset(a, b, sizeof a)
                #define append push_back
                #define all(v) v.begin(),v.end()
                #define F first
                #define S second
                #define print(x) cout << (x) << endl
                #define PRECISION(x) cout << fixed << setprecision(x)
                #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
                #define N 1010
                #define pb push_back
                const double PI=acos(-1);
                const int MOD = 1000000007;
                const int FMOD = 998244353;
                const double eps = 1e-9;
                 
                mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
     	signed main(){		
     			int n,m,t;
	cin >> n >> m >> t;
	vector<int> a(n),b(m);
	FOR(i,0,n){
		cin >> a[i];
	}
	FOR(i,0,m)
	{
		cin >> b[i];
	}
	FOR(i,1,n){
		a[i] += a[i-1];
	}
	FOR(i,1,m){
		b[i] += b[i-1];
	}
	int ans = 0;
	int cur = upper_bound(all(b),t) - b.begin() - 1;
	ans = cur+1;
	FOR(i,0,n){
		if(t < a[i])
			break;
		int tans = i+1;
		int add = upper_bound(all(b),t-a[i]) - b.begin();
		ans = max(ans,tans+add);
	}
	cout << ans << "\n";
    return 0;
     	}

Measured memory_bytes: 6420
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
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;}

int main(){
    int n;
    cin >> n;
    vll a(n);
    rep(i, n) {
        cin >> a[i];
    }
    Sort(a);
    ll ans = 1;
    ll tmp = 1e18;
    ll test = 1e18;
    rep(i, n) {
        if(a[i] == 0){
            ans *= 0;
            break;
        }
        ans *= a[i];
        if(tmp < a[i]) {
            ans = -1;
            break;
        }
        tmp = (tmp+a[i]-1)/a[i];
        if(ans > test) {
            ans = -1;
        }
    }
    cout << ans << endl;
    return 0;
}

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

long long x[100010];

int main(void){
	int n, k;
	long long ans=0;
	cin >> n >> k;
	for(int i=0; i<n; i++) cin >> x[i];

	for(int i=0; i<=n-k; i++){
		long long l, r;
		l = x[i];
		r = x[i+k-1];
		long long p = min(abs(l)+abs(r-l), abs(r)+abs(r-l));
		if(i==0 || ans>p) ans = p;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<cstdio>


using ll=long long;


void max_u(ll&m, ll v)
{
	if(m<v) m=v;
}


int main(void)
{
	ll n, a, b, c, d, e;

	while(scanf("%lld%lld%lld%lld%lld%lld", &n, &a, &b, &c, &d, &e)==6)
	{
		ll ans=0;

		max_u(ans, (n-1)/a);
		max_u(ans, (n-1)/b);
		max_u(ans, (n-1)/c);
		max_u(ans, (n-1)/d);
		max_u(ans, (n-1)/e);
		ans+=5;
		printf("%lld\n", ans);
	}
}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const ll inf = -TEN(9) * 2;

int main() {
	int N; cin >> N;
	vi A(N);
	rep(i, N) cin >> A[i];

	sort(ALL(A));

	int ans = inf;
	int all = 0;
	rep(i, N) all += A[i];

	int sum = 0;
	
	rep(i, N) {
		sum += A[i];
		if (i < N-1) {
			ans = max(ans, (all - sum) - sum);
		}
	}
	cout << ans << endl;

	int positive = 0, negative = 0;

	rep(i, N) {
		if (A[i] >= 0) {
			positive++;
		} else {
			negative++;
		}
	}

	if (positive == N) {
		--positive;
		++negative;
	}

	if (negative == N) {
		--negative;
		++positive;
	}
	vector<pii> ope;

	if (positive <= negative) {
		reverse(ALL(A));
		vi vec;
		rep(i, positive) {
			int x, y;
			if (i == 0) {
				x = A[0];
				y = A[positive];
			} else {
				x = A[i + positive];
				y = A[i];
			}
			ope.eb(x, y);
			vec.pb(x - y);
		}
		for (int i = 1; i < (int)vec.size(); ++i) {
			int x, y;
			x = vec[0]; y = vec[i];
			vec[0] -= vec[i];
			ope.eb(x, y);
		}
		for (int i = positive * 2; i < N; ++i) {
			int x, y;
			x = vec[0]; y = A[i];
			vec[0] -= A[i];
			ope.eb(x, y);		
		}
	} else {
		vi vec;
		rep(i, negative) {
			int x, y;
			x = A[i]; y = A[negative + i];
			vec.pb(x - y);
			ope.eb(x, y);
		}
		for (int i = negative * 2; i < N - 1; ++i) {
			int x = vec[0], y = A[i];
			vec[0] -= y;
			ope.eb(x, y);
		}
		for (int v : vec) {
			int x = A[N-1], y = v;
			ope.eb(x, y);
			A[N-1] -= v;
		}
	}

	assert(ope.size()==N-1);
	for (auto p : ope) {
		cout << p.fi << " " << p.se << endl;
	}

	return 0;
}

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

int mod = 1000000007;
int power(int x, int y) { //x^y
	long long p = 1;
	for (long long b = x; y > 0; y >>= 1, b = b * b % mod) {
		if (y & 1)
			p = p * b % mod;
	}
	return p;
}
int inverce(int x) {
	return power(x, mod - 2);
}

const int factMax = 2000;
int fact[factMax + 1];
void initialize() {
	fact[0] = 1;
	for (int i = 1; i <= factMax; i++)
		fact[i] = (long long) fact[i - 1] * i % mod;
}

int comb(int n, int k) {
	if (k < 0 || n - k < 0)
		return 0;
	int denom = (long long) fact[k] * fact[n - k] % mod;
	return (long long) fact[n] * inverce(denom) % mod;
}
int part(int n, int k) {
	return comb(n + k - 1, n);
}

int main() {
	initialize();
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= k; i++)
		cout << (long long) part(k - i, i) * part(n - k - (i - 1), i + 1) % mod
				<< endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define fst first
#define snd second

void Max(int &x, int y) {
    if (x < y) x = y;
}

void Min(int &x, int y) {
    if (x > y) x = y;
}


int main(void) {

    int n;
    cin >> n;
    ll s = 0;
    int i = 1;
    for (i = 1; i <= n; ++ i) {
        s += i;
        if (s >= n) {
            break;
        }
    }


    for (int j = i; j >= 1; -- j) if (n >= j) {
        cout << j << endl;
        n -= j;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

	int n,i;

	scanf("%d",&n);

	if(n>100){
		return 0;
	}

	int a[n];

	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=n-1;i>0;i--){
		printf("%d ",a[i]);
	}

	printf("%d\n",a[i]);

	return 0;

}


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

using namespace std;

long long calc(long long N, long long D){
    return N/D;
}

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long A, B, C, D;
    cin >> A >> B >> C >> D;
    long long G = C*D/__gcd(C, D);
    long long ans = B-A+1;
    ans -= calc(B, C) + calc(B, D) - calc(B, G);
    ans += calc(A-1, C) + calc(A-1, D) - calc(A-1, G);
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();
		int min = 0;

		for(int i =1;i<=1009;i++) {
			if((int)(i*0.08) == a && (int)(i*0.1) == b) {
				min = i;
				break;
			}else {
				min = -1;
			}
		}

		System.out.println(min);

		scan.close();

	}

}


Measured memory_bytes: 23892
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
    #define Vl vector<ll>
     
    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
     
const ll MOD = 1e9 + 7;
const ll ZER = 0;

// UnionFind木(サイズ持ち)
class UnionFind {
    public : 

        vector<int> par;

        UnionFind(int N){
            par = vector<int>(N, -1);
        }

        int parent(int x){
            return par[x];
        }

        int root(int x){
            if(par[x] < 0)return x;
            return par[x] = root(par[x]);
        }

        int size(int x){
            return -par[root(x)];
        }

        void connect(int x, int y){
            int rx = root(x);
            int ry = root(y);
            if(rx == ry)return;

            if(size(rx) < size(ry))swap(rx, ry);

            par[rx] += par[ry];
            par[ry] = rx;

            return;
        }

        bool same(int x, int y){
            return root(x) == root(y);
        }
};

int main(){
   int n, m;
   cin >> n >> m;
   UnionFind uf(n);
   rep(i, m){
       int a, b;
       cin >> a >> b;
       a--;b--;
       uf.connect(a, b);
   }
   int res = 0;
   rep(i, n){
       chmax(res, uf.size(i));
   }
   cout << res << endl;
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pci pair<char, int>
#define pic pair<int, char>
#define plvl pair<long long, vector<long long> >
#define pcvc pair<char, vector<char> >


using namespace std;

const int mod = 1e9 + 7;

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

template <typename T>
void show1(vector<T> dp) {
	for(auto d : dp) {
		cout << d << " ";
	}
	cout << endl;
}

template <typename T>
void show2(vector<vector<T> > dp) {
	for(auto d : dp) {
		for(auto dd : d) {
			cout << dd << " ";
		}
		cout << endl;
	}
}

set<int> solve(int x) {
	set<int> ret;
	for(int i = 1; i <= sqrt(x) ; i++) {
		if(x % i == 0) {
			ret.insert(i);
			ret.insert(x / i);
		}
	}
	return ret;
}

void executeCode() {
	ll n , cnt = 0;
	cin >> n;
	unordered_map<int, int> mp;
	for(int i = 0 ; i < n ; i++) {
		int x;
		cin >> x;
		mp[x]++;
	}
	for(auto m : mp) {
		set<int> div = solve(m.first);
		mp[m.first]--;
		bool flag = true;
		for(auto d : div) {
			if(mp.find(d) != mp.end() && mp[d] > 0) {
				flag = false;
				break;
			}
		}
		mp[m.first]++;
		if(flag) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return;
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int tt = 1;
	// cin >> tt;
	while(tt--) {
		executeCode();	
	}
	return 0;
}

Measured memory_bytes: 11324
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main(){
    string s,t;
    int n,i;
    cin >> s >> t;

    vector<int> x,y;
    map<char, int> a,b;

    for(i = 0; i < s.size(); i++)
        a[s[i]]++;
    for(i = 0; i < s.size(); i++){
        b[t[i]]++;
    }

    for(char i = 'a'; i <= 'z'; i++)
        x.push_back(a[i]);
    for(char i = 'a'; i <= 'z'; i++)
        y.push_back(b[i]);

    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    for(i = 0; i < x.size(); i++)
    {
        if(x[i] != y[i])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}




Measured memory_bytes: 1020
#include <iostream>
#include <algorithm>

int main(){
    using namespace std;
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    cout << max(max(a[0],a[1]),a[2]) - min(min(a[0],a[1]),a[2]) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
inline void write(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
long long x[100010],y[100010],a[100010];
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n=read();int now=0;long long d;
	for(int i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+n+1);
	int p=0;d=a[1];
	for(int i=2;i<n;i++)
	{
		if(a[i]<0)p=i;
		if(a[i]>=0)
		{
			now++;
			x[now]=d,y[now]=a[i];
			d-=a[i];
		}
	}now++;
	x[now]=a[n],y[now]=d;a[n]-=d;
	for(int i=2;i<=p;i++){now++;x[now]=a[n],y[now]=a[i];a[n]-=a[i];}
	printf("%lld\n",a[n]);
	for(int i=1;i<=now;i++)printf("%lld %lld\n",x[i],y[i]);
    return 0;
}

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

using namespace std;

int main() {
    int n, d, x;
    cin >> n >> d >> x;
    int a[n];
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int result = 0;
    for(auto choco : a) {
        int day = 0;
        int count = 0;
        while(day <= d) {
            day = choco * count + 1;
            if(day <= d) result++;
            count++;
        }
    }
    result += x;
    cout << result << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner scn=new Scanner(System.in);
        int n=scn.nextInt();
        scn.close();
        long answer=0;
        long b1=0;
        long b2=0;
        for(int i=0;i<=n;i++){
            if(i==0){
                answer =2;
                b1=2;
            }else if(i==1){
                answer =1;
                b2=1;
            }else{
                answer =b1+b2;
                b1=b2;
                b2=answer;
            }
        }
        System.out.println(answer);
    }
}

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

using namespace std;

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

int main(){
    long long n;
    cin >> n;
    vector<long long> a(n);
    long long y_1 =0;
    rep(i, n){
        cin >> a[i];
        y_1 += a[i];
    }
    y_1 /= n;
    long long y_2 = y_1 + 1;
    long long y_3 = y_1 - 1;

    long long cost1 = 0;
    long long cost2 = 0;
    long long cost3 = 0;
    rep(i, n){
        cost1 += pow((a[i] - y_1),2);
        cost2 += pow((a[i] - y_2),2);
        cost3 += pow((a[i] - y_3),2);
    }

    cout << min(min(cost1, cost2), cost3);
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
dict = {}
for i in range(N):
    if(a[i] - 1 in dict):
        dict[a[i] - 1] += 1
    else:
        dict[a[i] - 1] = 1
    if(a[i] in dict):
        dict[a[i]] += 1
    else:
        dict[a[i]] = 1
    if(a[i] + 1 in dict):
        dict[a[i] + 1] += 1
    else:
        dict[a[i] + 1] = 1
maxNum = 0
l = list(dict.values())
for i in range(len(l)):
    maxNum = max(maxNum, l[i])
print(maxNum)

Measured memory_bytes: 18752
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
typedef long long ll;
int main()
{int N; cin >> N;
 vector<ll> A(N);
 for(int i = 0; i < N ; i++)
 {cin >> A[i];}
 vector<ll> B(N);
 for(int i = 0; i < N; i++)
 { B[i] = A[i] - i - 1;}
 
 sort(B.begin(),B.end());
 
 ll sum0 = 0;
 
 for(int i = 0; i < N; i++)
 { sum0 += B[i];}
 if( N % 2 == 0)
 {int M = N/2;
  ll sum1 = 0;
  for(int i = 0 ; i < M ; i++)
  {sum1 += B[i];}
  cout << sum0 - 2*sum1 << endl;}
 else if( N == 1){cout << 0 << endl;}
 else
 {int M = (N-1) / 2;
  ll sum2  = 0;
  
  for(int i = 0; i < M; i++)
  {sum2 += B[i];}
  cout << sum0 - 2*sum2 - B[M] << endl;}
 
 return 0;
}


Measured memory_bytes: 3328
A,B,K = map(int,input().split())

if B-A+1 > 2*K:
   for up in range(A,A+K):
       print(up)
   for down in range(B-K+1,B+1):
       print(down)

else:
    for i in range(A,B+1):
        print(i)

Measured memory_bytes: 3060
import numpy as np
import sys
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

r = I()
print(3*(r**2))

Measured memory_bytes: 21776
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

constexpr ll INF = 1e16;
constexpr ll INM = 114514;
constexpr ll MOD = 1e9 + 7;
constexpr ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll n;
	cin >> n;
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ans += i;
	}
	dump(ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int N = S.length();
        int C[] = new int[N];

        int status = 0;
        int countL = 0;
        int countR = 0;
        int posRL = 0;


        for (int i=0;i<N;i++) {
            if (status == 0) {
                if (S.charAt(i) == 'R') {
                    //Count R
                    status = 0;
                    countR++;
                    C[i] = 0;
                } else { // S.charAt(i) == 'L'
                    // RL!
                    status = 1;
                    posRL = i - 1;
                    C[i-1] = (countR+1)/2;
                    C[i] = 1 + countR/2;
                    countL = 0;
                    countR = 0;
                }
            } else { // status == 1
                if (S.charAt(i) == 'R') {
                    // End
                    status = 0;
                    countR++;
                    C[posRL] += (countL+1)/2;
                    C[posRL+1] += countL/2;
                    C[i] = 0;
                } else { // S.charAt(i) == 'L'
                    // Count L
                    status = 1;
                    countL++;
                    C[i] = 0;
                }
            }
        }

        if (countL > 0) {
            C[posRL] += (countL+1)/2;
            C[posRL+1] += countL/2;
        }

        for (int i=0;i<N;i++) {
            System.out.print(C[i]);
            if (i == N - 1) System.out.println();
            else System.out.print(" ");
        }
    }
}


Measured memory_bytes: 45920