akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pi=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
void Yes(bool c) { if (c)print("Yes"); else print("No"); };
void YES(bool c) { if (c)print("YES"); else print("NO"); };

void solve() {
    string s; cin >> s;
    int s_len = s.size();
    int ans = 0;
    rep(idx,s_len){
        rng(len,1,s_len-idx+1){
            string t = s.substr(idx,len);
            bool ok = 1;
            for(char c:t){
                if(c!='A' && c!='G' && c!='C' && c!='T') {
                    ok = 0;
                    break;
                }
            }
            if(ok) ans = max(ans,len);
        }
    }
    print(ans);
}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	long long X;
	cin>>X;
	long long x=1;
	long long sum=0;
	while (true){
		sum+=x;
		if (sum>=X){
			cout<<x<<endl;
			return 0;
		}
		x++;


	}
	return 0;
}

Measured memory_bytes: 256
N=int(input())
S=[]
for i in range(N):
    S.append(input())

Ssort=[sorted(s) for s in S]
sort2=sorted(Ssort)

total=0
counter=0
ref=sort2[0]
for i in range(1,N):
    if(sort2[i]==ref):
        counter=counter+1
        if(i==N-1):
            total=total+sum(list(range(counter+1)))
    else:
        total=total+sum(list(range(counter+1)))
        counter=0
        ref=sort2[i]

print(total)



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

int main() {
	int N;
	cin >> N;
	vector<int> l(N), r(N);
	for (int i = 0; i < N; i++) {
		cin >> l.at(i) >> r.at(i);
	}
	int counter = 0;
	for (int i = 0; i < N; i++) {
		counter = counter + (1 + r.at(i) - l.at(i));
	}
	cout << counter << endl;
}

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

const int mod=998244353;

signed main()
{
   int N; cin>>N;
   vector<int> a(N);
   for(int i=0;i<N;i++) cin>>a[i];

   int S=0;
   for(int i=0;i<N;i++) S+=a[i];
   vector<vector<int> > dp(N+1,vector<int>(S+1));
   vector<vector<int> > dp2(N+1,vector<int>(S+1));

   dp[0][0]=dp2[0][0]=1;
   for(int i=0;i<N;i++){
      for(int j=0;j+a[i]<=S;j++){
         (dp[i+1][j+a[i]]+=dp[i][j])%=mod;
         (dp[i+1][j]+=dp[i][j])%=mod;

         (dp2[i+1][j+a[i]]+=dp2[i][j])%=mod;
         (dp2[i+1][j]+=dp2[i][j]*2)%=mod;
      }
   }

   int ans=1;
   for(int i=0;i<N;i++) ans=ans*3%mod;

   if(S%2==1){
      for(int i=(S+1)/2;i<=S;i++){
         (ans+=(mod-dp2[N][i])*3)%=mod;
      }
   }
   else{
      for(int i=S/2;i<=S;i++){
         (ans+=(mod-dp2[N][i])*3)%=mod;
      }
      (ans+=dp[N][S/2]*3)%=mod;
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 423744
#include <cstdio>
#define R register
using namespace std;
int main(void)
{
	int n, m, blk, x, y; char c;
	scanf("%d%d%d", &n, &m, &blk);
	for (R int i = 1; i <= n; ++i)
	{
		for (R int j = 1; j <= m; ++j)
		{
			x = (i + j + m) / blk % 2, y = (i - j + m) / blk % 2;
			printf("%c", "YBGR"[2 * x + y]);
		}
		putchar(10);
	}

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll cheng(ll n)
{
    ll k=1;
    for(int i=1;i<=n;i++)
        k*=2;
    return k;
}
int main()
{
  ll n;
  cin>>n;
  ll sum=0;
  for(ll i=1;;i++)
  {
     if(n==0)
        break;
        n/=2;
     sum+=cheng(i-1);
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
int main(void){
	char a[1500];
	int s = 1;
	for (; s != 0;){
		s = 0;
		scanf("%s", a);
		for (int i = 0; i < strlen(a); i++)s = s + a[i] - 48;
		if(s!=0) printf("%d\n", s);
	}
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    string ans = "";
    for(int i=0;i<s.size();++i){
        if(s[i] == '0')
            ans.push_back('0');
        else if(s[i] == '1')
            ans.push_back('1');
        else if(ans.size() != 0){
            ans.pop_back();
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define length(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, length(a))cin >> a[i]
#define ccin(i, j, a) rep(i, length(a))rep(j, length(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define sqrtl sqrt
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
intl kai(intl k){
    intl a = 1;
    for(intl i = 1; i <= k; i++){
        a *= i;
        debug(a);
    }
    return a;
}
int main(){
    intl n,m;
    cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2 << endl;
    return 0;
}

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

int main()
{
	long long n;
	cin>>n;
	long long a[n+1];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		
	}
	sort(a,a+n);
	for(int i=0;i<n-1;i++)
	{
		if(a[i]==a[i+1])
		{
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES";
}

Measured memory_bytes: 1792
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
int GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
bool dp[200005][5][5][5];
int main(){
ll n,a,b,c;
cin>>n>>a>>b>>c;
V<string> s(n);
for(int i=0;i<n;i++)cin>>s[i];
V<char> ans(n);
bool ok=true;
for(int i=0;i<n;i++){
    if(s[i]=="AC"){
        if(a==0&&c==0)ok=false;
        if(a<c){
            a++;c--;
            ans[i]='A';
        }
        else if(c<a){
            a--;c++;
            ans[i]='C';
        }
        else{
            if(i+1<n){
                if(s[i+1]=="AB"){
                    a++;c--;ans[i]='A';
                }else if(s[i+1]=="BC"){
                    c++;a--;ans[i]='C';
                }
                else{
                     a--;c++;
                     ans[i]='C';
                }
            }else{
                     a--;c++;
                     ans[i]='C';
                }
        }
    }
   else if(s[i]=="BC"){
       if(b==0&&c==0)ok=false;
        if(b>c){
            b--;c++;
           ans[i]='C';
        }
        else if(b<c){
            b++;c--;
            ans[i]='B';
        }else{
            if(i+1<n){
                if(s[i+1]=="AB"){
                    b++;c--;ans[i]='B';
                }else if(s[i+1]=="AC"){
                    c++;b--;ans[i]='C';
                }
                else{
                    b++;c--;
                    ans[i]='B';
                }
            } else{
                    b++;c--;
                    ans[i]='B';
                }
        }
    }
   else if(s[i]=="AB"){
       if(a==0&&b==0)ok=false;
        if(a<b){
            a++;b--;
            ans[i]='A';
        }
        else if(a>b){
            b++;a--;
            ans[i]='B';
        }else{
            if(i+1<n){
                if(s[i+1]=="AC"){
                    a++;b--;ans[i]='A';
                }else if(s[i+1]=="BC"){
                    b++;a--;ans[i]='B';
                }
                else{
                    b++;a--;
                    ans[i]='B';
                }
            }
            else{
                    b++;a--;
                    ans[i]='B';
                }
        }
    }
}
if(ok){
cout<<"Yes"<<"\n";
for(int i=0;i<n;i++)cout<<ans[i]<<"\n";
}
else cout<<"No"<<"\n";
}

Measured memory_bytes: 6624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    ll a, b, n;
    cin >> a >> b >> n;
    /*for (double x = 0; x <= n; x++) {
        ll f = floor(a * x / b) - a * floor(x / b);
        cout << "x:" << x << " " << "f:" << f << endl;
    }*/
    double x1 = min(n, b - 1);
    ll f1 = floor(a * x1 / b) - a * floor(x1 / b);
    //double x2 = min(n, b - 1);
    //ll f2 = floor(a * x2 / b) - a * floor(x2 / b);
    cout << f1 << endl;
    return 0;
}


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

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];

int main(){
    ll a;
    ll H,N,K,M,sum=0;
    cin >> N >> K;
    vector<int>A(N+5);
    for(int i=0; i<N; i++){
        cin >> a;
        A[i] = -a;
    }
    sort(A.begin(),A.end());
    for(int i=K; i<N; i++){
        sum += -A[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 1024
N, K = map(int, input().split())

# a+b, b+c, c+a が全てKの倍数になるのは、
# 1. (a%K, b%K, c%K) = (0, 0, 0)
# 2. (a%K, b%K, c%K) = (K/2, K/2, K/2) の時だけ
# このうち、2の条件はKが奇数の時成立しないので、Kの偶奇で分けてそれぞれの条件を考える

# 1の条件: a, b, c は N以下のKの倍数 なので、その個数の3乗
cnt = int(N / K) ** 3

# 2の条件: N以下のKで割ってK/2余る数 = N+K/2以下のKの倍数 の個数の3乗
if K % 2 == 0:
    cnt += int((N + K / 2) / K) ** 3

print(cnt)


Measured memory_bytes: 2940
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        String N = in.next();
        int sum = 0;
        for (char c : N.toCharArray())
            sum += c - '0';
        if (sum % 9 == 0)
            out.println("Yes");
        else
            out.println("No");

        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}


Measured memory_bytes: 37144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<(k) ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=(k) ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef jayinnn
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
const ll MAXN = 100005;

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

/********** Good Luck :) **********/
int main () {
    TIME(main);
    IOS();
    int n, k;
    cin >> n >> k;
    vector<double> a(n);
    vector<double> b(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        a[i] = (a[i] + 1) / 2.0;
    }
    b[0] = a[0];
    for(int i=1;i<n;i++){
        b[i] = a[i] + b[i-1];
    }
    double ans = b[k-1];
    for(int i=1;i<=n-k;i++){
        ans = max(ans, b[i+k-1] - b[i-1]);
    }
    
    cout << fixed << setprecision(8) << ans << endl;

    return 0;
}

Measured memory_bytes: 3456
'use strict'
function main(inp) {
  inp = inp.trim().split('\n')
  inp.shift()
  inp = inp[0].split(' ')
    .map((n, i) => [Number(n), i+1])
    .sort((a, b) => a[0] - b[0])
    .map(arr => arr[1])
  console.log(inp.join(' '))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 37412
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

int main(){
  string s; cin>>s;
  for(int i=0; i<3; i++){
     cout << s[i];
  }
  cout<<endl;
}


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

int main() {
	int N;
	int d[110];
	cin >> N;
	for (int i = 0; i < N; ++i) cin >> d[i];

	int num[110] = { 0 };	
	for (int i = 0; i < N; ++i) {
		num[d[i]]++;
	}

	int res = 0;
	for (int i = 1; i <= 100; ++i) {
		if (num[i]) {
			++res;
		}
	}

	cout << res << endl;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <cstdlib>
#include <unordered_map>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007 
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
using namespace std;
long long geko[200][200];
int main() {
	int a, b;
	cin >> a >> b;
	a--;
	b--;
	for (int i = 1; i <= 100; ++i) {
		for (int q = 1; q <= 100; ++q) {
			if (i <= 50) {
				geko[i][q] = 1;
			}
			else {
				geko[i][q] = 2;
			}
		}
	}
	for (int i = 2; b != 0; i += 2) {
		for (int q = 2; b != 0 && q <= 98; q += 2) {
			b--;
			geko[i][q] = 2;
		}
	}
	for (int i = 52; a != 0; i += 2) {
		for (int q = 2; a != 0 && q <= 98; q += 2) {
			a--;
			geko[i][q] = 1;
		}
	}
	cout << "100 100" << endl;
	for (int i = 1; i <= 100; ++i) {
		for (int q = 1; q <= 100; ++q) {
			if (geko[i][q] == 1) {
				cout << ".";
			}else cout << "#";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1016
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1LL<<60;
long double pi=3.141592653589793238462643383279L;
double eps=1e-12;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string s;cin>>s;
    s="0"+s;
    ll n=s.size();
    ll dp[n+1][2];
    rep(i,0,n+1)rep(j,0,2)dp[i][j]=inf;
    dp[0][0]=0;
    rep(i,0,n){
        rep(j,0,2){
            int ne=s[n-1-i]-'0'+j;
            rep(k,0,10){
                int nj=0;
                int t=k-ne;
                if(t<0){
                    t+=10;
                    nj=1;
                }
                dp[i+1][nj]=min(dp[i+1][nj],dp[i][j]+k+t);
            }
        }
    }
    cout<<dp[n][0]<<endl;
}




Measured memory_bytes: 16968
inputStr = list(input())
def evenStrJudg(s):
  sameCheck = True
  if len(s) % 2 != 0:
    sameCheck = False
  else:
    for i in range(int(len(s) / 2)):
      if s[i] != s[i + int(len(s) / 2)]:
        sameCheck = False
        break
  return sameCheck

for i in range(int(len(inputStr) / 2)):
  del inputStr[-1]
  del inputStr[-1]
  if evenStrJudg(inputStr):
    break
print(len(inputStr))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

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

	vector<pair<int, int>> vpi(n);

	for (int i = 0; i < n; i++) {
		int num;
		cin >> num;
		vpi[i] = make_pair(num, i + 1);
	}

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

	for (int i = 0; i < n; i++) {
		cout << vpi[i].second << " ";
	}
	cout << endl;

}


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

int main(){

    int k, t; cin >> k >> t;
    int a = 0;
    for(int i = 0; i < t; i++){
        int in; cin >> in;
        a = max(a, in);
    }
    
    cout << ((2*a - 1 - k > 0) ? (2*a - 1 - k) : (0)) << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	m := make(map[int]bool)
	var a int
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		b, ok := m[a]
		if !ok {
			m[a] = true
			continue
		}
		m[a] = !b
	}

	var r int
	for _, v := range m {
		if v {
			r++
		}
	}
	fmt.Println(r)
}

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

using namespace std;

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

    long long dp[n][2];
    dp[1][0] = a[0] + a[1];
    dp[1][1] = -a[0] - a[1];
    for (int i = 2; i < n; i++) {
        dp[i][0] = max(dp[i-1][0], dp[i-1][1]) + a[i];
        dp[i][1] = max(dp[i-1][0] - 2 * a[i-1], dp[i-1][1] + 2 * a[i-1]) - a[i];
    }

    cout << max(dp[n-1][0], dp[n-1][1]) << endl;

    return 0;
}

Measured memory_bytes: 2176
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	static int n;

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		// n = Integer.parseInt(br.readLine());
		String str[] = br.readLine().split(" ");

		int h = Integer.parseInt(str[0]);
		int n = Integer.parseInt(str[1]);

		str = br.readLine().split(" ");
		int sum = 0;

		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(str[i]);
			sum += a;
			if (h <= sum) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 33804
# coding:utf-8

import sys

# ??\???
n = int(input())

display = []
for i in range(n):
    num = i + 1
    # 3??§?????????????????´???
    if (num % 3 == 0):
        display.append(num)
        continue

    # ????????????????????????3????????????????????´???
    original = num
    while (num != 0):
        last_digit = int(num % 10)
        if (last_digit == 3):
            display.append(original)
            num = 0
        num = int(num / 10)

for x in display:
    
    sys.stdout.write(' ' + str(x))
print('')

Measured memory_bytes: 7892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    ll k;
    cin >> k;
    ll x = 0;
    for (i = 0; i < 1010101; i++) {
        x *= (ll)10;
        x += (ll)7;
        x %= k;
        if (x == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int a[105],n,k,ans,y;
int main()
{
cin>>n>>k;
int x;
for(int i=1;i<=k;i++)
{
	cin>>x;
	for(int j=1;j<=x;j++)
	{
		cin>>y;
		a[y]++;
	}
}
for(int i=1;i<=n;i++)
{
	if(a[i]==0)ans++;
}
cout<<ans;
return 0;

}

Measured memory_bytes: 3576
n, m = map(int, input().split())

matrix = [[0 for  _ in range(m)] for _ in range(n)]

for i in range(n):
    List = list(map(int, input().split()))
    for j in range(m):
        matrix[i][j] = Ⅼist[j]
    

multiple = []
for _ in range(m):
    i = int(input())
    multiple.append(i)

Answer = []

for item in matrix:
    figure = 0
    for i in range(m):
        figure += item[i]*multiple[i]
    Answer.append(figure)

for i in range(n):
    print(Answer[i])


Measured memory_bytes: 6080
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int A,B,C;
  cin >> A >> B >> C;
  int sum = 0;
  bool ans = false;
  for(int i=0;i<10000;i++)
  {
    if((A*i)%B==C)
    {
      ans = true;
    }
  }
  if(ans==true)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
  
  return 0;
}


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

int main() {
  string s ,t ;
  cin >> s >> t ;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  
 // cout << s << endl << t << endl;
  
  if(s<t)
    cout << "Yes" ;
  else 
    cout << "No";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ls p<<1
#define rs p<<1|1 
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define mm make_pair
#define pi 2*acos(0.0)
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout.precision(i);cout<<fixed<<ans<<endl;
#define lowbit(x) (x)&(-x)
#define out(x) {cout<<x<<endl;return 0;} 
#define all(v) v.begin(),v.end() 
#define mem(x,i) memset(x,i,sizeof(x)) 
#define mec(x,y) memcpy(x,y,sizeof(y))
#define eps 1e-8 
#define ull unsigned long long
#define cps CLOCKS_PER_SEC
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
ll gcd(ll x,ll y){if(y==0) return x;else return gcd(y,x%y);} 
ll ksm(ll a,ll b){ll r=1;while(b){if(b&1) r=(r*a)%mod;a=a*a%mod;b>>=1;}return r;} 
void exgcd(ll a, ll b, ll &x, ll &y, ll &d){if(!b) d=a,x=1,y=0;else exgcd(b,a%b,y,x,d),y-=a/b*x;}
ll inv(ll a, ll p){ll x,y,d;exgcd(a,p,x,y,d);x=(x%p+p)%p;return x;}
inline int read()
{
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
const int maxn=2e5+100;
ll cnt[2][maxn],c[2],n,val[2];
ll ans[maxn],ok[maxn];
char s[maxn];
map<ll,ll> mp;
inline ll cou(ll x)
{
	if(x==0) return 1;
	if(mp.count(x)) return mp[x];
	ll num=0,xx=x;
	while(x)
	{
		if(x%2) num++;
		x/=2;
	}
	ll ans=1+cou(xx%num);
	return mp[x]=ans;
}
int main()
{
	scanf("%d%s",&n,s+1);
	int num=0;
	FOR(i,1,n) 
	{
		if(s[i]=='1') num++; 
	}
	c[0]=num-1;
	c[1]=num+1;
	
	if(c[0]!=0)
	{
		num=1;
		for(int i=1;i<=n;i++) 
		{
			cnt[0][i]=num%c[0];
			num*=2;
			num%=c[0];
		}
	} 
	num=1;
	for(int i=1;i<=n;i++)
	{
		cnt[1][i]=num%c[1];
		num*=2;
		num%=c[1];
	}
	
	ll sum=0;
	FOR(i,1,n) 
	{
		if(s[i]=='1') val[0]+=cnt[0][n-i+1],val[1]+=cnt[1][n-i+1];
		if(s[i]=='1') sum+=(1<<(n-i));
	}
	//cout<<sum<<endl;
	FOR(i,1,n)
	{
		if(s[i]=='1') 
		{
			if(c[0]==0) {ans[i]==0;ok[i]=1;continue;} 
			ans[i]=val[0]-cnt[0][n-i+1];
			ans[i]%=c[0];
		}
		else
		{
			ans[i]=val[1]+cnt[1][n-i+1];
			ans[i]%=c[1];
		}
	}
	
	FOR(i,1,n) 
	{
		if(!ok[i]) printf("%lld\n",cou(ans[i]));
		else printf("0\n");
	}
	
	return 0;
}

Measured memory_bytes: 8616
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
  int N,M;
  cin >> N >> M;
  int X[M];
  rep(i,M) cin >> X[i];
  sort(X,X+M);
  int X2[M-1];
  rep(i,M-1) X2[i]=X[i+1]-X[i];
  int ans=0;
  if(N>=M) cout << ans << endl;
  else{
    sort(X2,X2+M-1);
    rep(i,M-N) ans+=X2[i];
    cout << ans << endl;
  }
}

Measured memory_bytes: 1024
n = int(input())
lst = list(map(int, input().split()))
mod = 10**9+7

# 累積和(Cumulative sum)リストの作成
cumsum = [0]*(n+1)
for i in range(n):
    cumsum[i+1] = lst[i] + cumsum[i]

# 題意より、lst の1つ前までが対象
ans = 0
for i in range(n-1):
    ans += (cumsum[n] - cumsum[i+1]) * lst[i]
print(ans % mod)


Measured memory_bytes: 31744
// Try AtCoder
// author: Leonardone @ NEETSDKASU
package main

import (
	"bufio"; "fmt"; "os"; "strconv"; "strings"
    "math/big"; "sort"
)

func atoi(s string) int { v, _ := strconv.Atoi(s); return v }
func atou(s string) uint64 { v, _ := strconv.ParseUint(s, 10, 64); return v }
func atof(s string) float64 { v, _ := strconv.ParseFloat(s, 64); return v }
func max(a, b int) int { if a > b { return a }; return b }
func min(a, b int) int { if a < b { return a }; return b }

var (_ = fmt.Println; _red = bufio.NewScanner(os.Stdin); _tok []string)
func init() { _red.Buffer(make([]byte, 1e7), 1e7) }
func gettok() (t string, e bool) {
	if len(_tok) == 0 { if !_red.Scan() { return }; _tok = strings.Split(_red.Text(), " ") }
	t = _tok[0]; _tok = _tok[1:]; e = len(_tok) == 0; return
}
func read(vs ...interface{}) {
	for _, v := range vs {
		switch v := v.(type) {
		case *int: t, _ := gettok(); *v = atoi(t)
		case *int64: t, _ := gettok(); *v = int64(atou(t))
		case *uint64: t, _ := gettok(); *v = atou(t)
		case *float64: t, _ := gettok(); *v = atof(t)
		case *string: *v, _ = gettok()
		case *[]int:
			if len(*v) == 0 { for { t, e := gettok(); *v = append(*v, atoi(t)); if e { break } }
			} else { for j := range *v { t, _ := gettok(); (*v)[j] = atoi(t) } }
		case *[]int64:
			if len(*v) == 0 { for { t, e := gettok(); *v = append(*v, int64(atou(t))); if e { break } }
			} else { for j := range *v { t, _ := gettok(); (*v)[j] = int64(atou(t)) } }
		case *[]uint64:
			if len(*v) == 0 { for { t, e := gettok(); *v = append(*v, atou(t)); if e { break } }
			} else { for j := range *v { t, _ := gettok(); (*v)[j] = atou(t) } }
		case *[]float64:
			if len(*v) == 0 { for { t, e := gettok(); *v = append(*v, atof(t)); if e { break } }
			} else { for j := range *v { t, _ := gettok(); (*v)[j] = atof(t) } }
		case *[]string:
			if len(*v) == 0 { *v = append(*v, _tok...); _tok = _tok[:0]
			} else { for j := range *v { (*v)[j], _ = gettok() } }
		}
	}
}

func solve(k int, xs []int) bool {
    sort.Ints(xs)
    if xs[len(xs)-1] < k {
        return false
    }
    if i := sort.SearchInts(xs, k); xs[i] == k {
        return true
    }
    t := big.NewInt(int64(xs[0]))
    for _, x := range xs[1:] {
        t.GCD(nil, nil, t, big.NewInt(int64(x)))
    }
    return t.Mod(big.NewInt(int64(k)), t).Int64() == 0
}

func main() {
    var n int
    var k int
    read(&n, &k)
    xs := make([]int, n)
    read(&xs)
    if ans := solve(k, xs); ans {
        fmt.Println("POSSIBLE")
    } else {
        fmt.Println("IMPOSSIBLE")
    }
}


Measured memory_bytes: 19456
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){

    string s;
    cin>>s;
    
    if(s=="Sunny") cout<<"Cloudy"<<endl;
    else if(s=="Cloudy") cout<<"Rainy"<<endl;
    else cout<<"Sunny"<<endl;
}



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

using namespace std;

int main()
{
    //freopen("test.inp","r",stdin);
    long long int n,d,dem = 0,x1,y1,tong = 0;
    cin >> n >> d;
    for ( long long int i = 1; i <= n; i++)
    {
        cin >> x1 >> y1;
        tong = x1*x1 + y1*y1;
        if (sqrt(tong)<= d)
        {
          // cout << " chon " << tong << " "  << " vi" << tong << "< " << d<< endl;
            dem++;
        }
    }
    cout <<dem<< endl;
    return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
 
using namespace std;

typedef long long ll;
const int mod=1e9+7;
const int INF=1<<30;

int main(){
  string S;
  cin >> S ;
  if(S.length()==2){
    if(S[0]==S[1]){
      cout << "1 2" << endl;
      return 0;
    }else{
      cout << "-1 -1" << endl;
      return 0;
    }
  }
  rep(i,S.length()-2){
    if(S[i]==S[i+1] || (S[i]==S[i+2] || S[i+1]==S[i+2])){
      cout << i+1 << " " << i+3 << endl;
      return 0;
    }
  }
  cout << "-1 -1" << endl;
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void) {

  int n;
  scanf("%d", &n);
  long a[n],b[n];
  for (int i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }
  for (int i = 0; i < n; i++) {
    scanf("%ld", &b[i]);
  }
  long sum_a = 0;
  long sum_b = 0;
  for (int i = 0; i < n; i++) {
    sum_a += a[i];
    sum_b += b[i];
  }
  if (sum_a > sum_b) {
    printf("No\n");
    return 0;
  }
  long operation = sum_b-sum_a;
  long stock = 0;
  long add_to_a;
  for (int i = 0; i < n; i++) {
    if (a[i] > b[i]) {
      if (a[i]-b[i] > operation) {
        printf("No\n");
        return 0;
      }
      operation -= a[i]-b[i];
      stock += (a[i]-b[i])*2;
      b[i] = a[i];
    }
  }
  for (int i = 0; i < n; i++) {
    if (b[i] > a[i]) {
      if ((b[i]-a[i])/2 <= stock/2) {
        add_to_a = (b[i]-a[i])/2*2;
        a[i] += add_to_a;
        stock -= add_to_a;
      } else {
        a[i] += stock;
        stock = 0;
      }
      if (b[i] > a[i]) {
        if (b[i]-a[i] > operation) {
          printf("No\n");
          return 0;
        }
        operation -= b[i]-a[i];
      }
    }
  }
  printf("Yes\n");

  return 0;
}

Measured memory_bytes: 256
from itertools import groupby

N = int(input())
#k,x = map(int,input().split())

ans=0
S=[]
for i in range(N):
    s=list(input())
    s.sort()
    S.append(''.join(x for x in s))

S.sort()

for key, value in groupby(S):
    l = len(list(value))
    ans += (l*(l-1) // 2)


print(str(ans))

Measured memory_bytes: 63320
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;

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

constexpr int MAX_N = 14;
constexpr int INF = 0xfffffff;
vector<string> cities;

int n;
int dp[MAX_N][MAX_N];
int memo[MAX_N][(1 << MAX_N)];

int connect(int front, int back) {
	if(dp[front][back] != -1) return dp[front][back];
	const int f_length = static_cast<int>(cities[front].size());
	const int b_length = static_cast<int>(cities[back].size());

	for(int i = min(f_length, b_length); i > 0; --i) {
		if(cities[front].substr(f_length - i) == cities[back].substr(0, i)) {
			return dp[front][back] = b_length - i;
		}
	}

	return dp[front][back] = b_length;
}

int dfs(int idx, int used) {
	if(memo[idx][used] != -1) return memo[idx][used];
	if(used == (1 << n) - 1) return memo[idx][used] = 0;

	int res = INF;
	for(int i = 0; i < n; ++i) {
		if(used & (1 << i)) continue;
		chmin(res, dfs(i, (used | (1 << i))) + connect(idx, i));
	}

	return memo[idx][used] = res;
}

void init() {
	for(int i = 0; i < n;) {
		for(int j = 0; j < n; ++j) {
			if(i == j) continue;

			if(cities[j].find(cities[i]) != string::npos) {
				cities.erase(cities.begin() + i);
				--n;
				goto next;
			}
		}
		++i;
	next:;
	}
}

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

	while(cin >> n && n) {
		cities.clear();
		cities.resize(n);
		for(int i = 0; i < n; ++i) {
			cin >> cities[i];
		}

		init();

		memset(memo, -1, sizeof(memo));
		memset(dp, -1, sizeof(dp));

		int ans = INF;
		for(int i = 0; i < n; ++i) {
			chmin<int>(ans, cities[i].size() + dfs(i, (1 << i)));
		}

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 2124
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>

using namespace std;

typedef long long ll;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep1(i,n) for(int i=1; i<=(int)(n); i++)
#define all(c) c.begin(),c.end()
#define psb push_back
#define ppb pop_back

const int INF = 1001001001;

const long double EPS = 0.000000001;

int main() {
    long double A, B;

    cin >> A >> B;

    ll ans = A*B+0.001;

    cout << ans << endl;
}


Measured memory_bytes: 3728
/*
СТРОИМ СТЕНУ РАБОТЯГИ!
█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
const int MAXN = 5007;
const int INF = 1000 * 1000 * 1000 + 7;
int a[MAXN], b[MAXN][MAXN];
ll mod[MAXN][MAXN];
int gol[MAXN], gor[MAXN];
void add(int x1, int y1, int x2, int y2, int val)
{
	mod[x1][y1] += val;
	mod[x2 + 1][y1] -= val;
	mod[x1][y2 + 1] -= val;
	mod[x2 + 1][y2 + 1] += val;
}
int main()
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 2; i <= n; i++)
	{
		scanf("%d", &a[i]);
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			scanf("%d", &b[i][j]);
		}
	}
	for (int i = 1; i <= m; i++)
	{
		vector<pair<int, int> > st;
		st.push_back(make_pair(0, INF));
		for (int j = 1; j <= n; j++)
		{
			while (st.back().second < b[j][i]) st.pop_back();
			gol[j] = st.back().first + 1;
			st.push_back(make_pair(j, b[j][i]));
		}
		st.clear();
		st.push_back(make_pair(n + 1, INF));
		for (int j = n; j >= 1; j--)
		{
			while (st.back().second < b[j][i]) st.pop_back();
			gor[j] = st.back().first - 1;
			st.push_back(make_pair(j, b[j][i]));
		}
		for (int j = 1; j <= n; j++)
		{
		//	mod[gol[j]][gor[j]] += b[j][i];
			add(gol[j], j, j, gor[j], b[j][i]);
		//	cerr << gol[j] << " " << gor[j] << " " << b[j][i] << endl;
		}
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			mod[i][j] = mod[i - 1][j] + mod[i][j - 1] - mod[i - 1][j - 1] + mod[i][j];
		}
	}
	ll res = 0;
	for (int i = 1; i <= n; i++)
	{
		ll dist = 0;
		for (int j = i; j <= n; j++)
		{
			if (j != i) dist += a[j];
			res = max(res, mod[i][j] - dist);
		}
	}
	printf("%lld\n", res);
}



Measured memory_bytes: 219904
import sys
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())
if A1*T1+A2*T2 == B1*T1+B2*T2:
    print('infinity')  
    sys.exit()
d1 = A1*T1-B1*T1
d2 = A2*T2-B2*T2
d = d1+d2
if d1<0:
    d = -d
    d1 = -d1
    d2 = -d2
if d>0:
    print(0)
    sys.exit()
d = -d
if d1%d == 0:
    print(d1//d*2)
else:
    ans = d1//d*2+1
    print(ans)




Measured memory_bytes: 38324
n=int(input())
a=list(map(int,input().split()))
sortA=sorted(set(a))+[float('inf')]
def isOK(m):
  x=sortA[m]
  count=[0]*(2*n+1)
  count[n+1]=1
  i=n+1
  s=1
  res=0
  for b in a:
    if b>=x:
      i+=1
      s+=count[i]
    else:
      s-=count[i]
      i-=1
    res+=s
    count[i]+=1
    s+=1
  if res>=n*(n+1)//4:
    return False
  else:
    return True
l=0
r=len(sortA)-1
while r>l+1:
  mid=(r+l)//2
  if isOK(mid):
    r=mid
  else:
    l=mid
print(sortA[l])

Measured memory_bytes: 87092
H,W=map(int, input().split())
S = tuple(input().rstrip() for _ in range(H))
a=0
d=[(1,0),(-1,0),(0,1),(0,-1)]
lity=[[0 for i in range(W)] for j in range(H)]
lity[0][0]=1
def roop()->None:
  p=[(0,0)]
  while p:
    x,y=p.pop(0)
    for dx,dy in d:
      if 0<=x+dx<H and 0<=y+dy<W and S[x+dx][y+dy]=='.' and lity[x+dx][y+dy]==0:
        p.append((x+dx,y+dy))
        lity[x+dx][y+dy]=lity[x][y]+1
roop()
white=sum(t.count(".") for t in S)
x=lity[-1][-1]
ans = white - x if x else -1
print(ans)

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

void solve()
{
    int x, a, b;
    cin >> x >> a >> b;
    if (-a + b <= 0)
        cout << "delicious" << endl;
    else if (-a + b <= x)
        cout << "safe" << endl;
    else
        cout << "dangerous" << endl;
}

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

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
using namespace std;

int main(){
long long int n,x,ans=0;
cin>>n>>x;
vector<long long int>a(10000000);
for(int i=0;i<n;i++){
    cin>>a[i];
}
for(int i=0;i<n-1;i++){
    if((a[i]+a[i+1])>x){
        ans+=(a[i]+a[i+1]-x);
        a[i+1]=a[i+1]-(a[i]+a[i+1]-x);
        if(a[i+1]<0){
            a[i]+=a[i+1];
            a[i+1]=0;
        }
    }
}
cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 78336
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Addition and Subtraction Easy
            
            var s = Console.ReadLine();
            var array = s.Split(' ');

            int a = int.Parse(array[0]);
            int b = int.Parse(array[2]);
            string op = array[1];

            if (op == "+")
            {
                Console.WriteLine(a + b);
            }
            else
            {
                Console.WriteLine(a - b);
            }
        }
    }
}

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

int main() {
    int x1, x2, x3, x4, x5;
    int position;
    cin >> x1 >> x2 >> x3 >> x4 >> x5;
    int arr[5] = {x1, x2, x3, x4, x5};
    for (int i = 0; i < 5; i++) {
        if (arr[i] == 0) {
            position = i+1;
        }
    }
    cout << position << '\n';
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000LL;
constexpr auto MOD = 1000000007;

int main() {

	ll a;
	long double b;
	cin >> a >> b;

	cout << (ll)(a * b) << endl;

}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef int ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1000000001;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int a,b,c;cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {

	in := nextInt
	n, m := in(), in()
	mp := make(map[int]int)

	for i := 0; i < n; i++ {
		mp[in()]++
	}

	for i := 0; i < m; i++ {
		v := in()
		mp[in()] += v
	}

	a := []int{}
	for k := range mp {
		a = append(a, k)
	}
	sort.Ints(a)

	ans := int64(0)
	cnt := n
	for i := len(a) - 1; i >= 0; i-- {
		v := mp[a[i]]
		if cnt >= v {
			ans += int64(a[i]) * int64(v)
			cnt -= v
		} else {
			ans += int64(a[i]) * int64(cnt)
			cnt -= cnt
		}
		if cnt <= 0 {
			break
		}
	}

	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

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

func max(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func anser(b bool, y string, n string) string {
	if b {
		return y
	}
	return n
}

Measured memory_bytes: 14720