akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

char S[20];

int main()
{
	scanf("%s", S);
	i64 ans = 0;
	int len = strlen(S);
	for (int i = 0; i < (1 << (len - 1)); ++i) {
		i64 sum = 0, cur = 0;
		for (int j = 0; j < len; ++j) {
			if (j > 0 && (i & (1 << (j - 1)))) {
				sum += cur;
				cur = 0;
			}
			cur = cur * 10 + (S[j] - '0');
		}
		sum += cur;
		ans += sum;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> a(3*N);
    for(auto &in:a) cin >> in;
    sort(a.begin(),a.end());
    ll res = 0;
    for(int i = 0; i < N;i++){
        res += a[3*N - 2 - 2*i];
    }
    cout << res<<endl;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=998244353 ;
ll add(ll a,ll b){
    ll t=(a+b);
    if(t>=p)t-=p;
        return t;
}
ll sub(ll a,ll b){
    ll t=a-b+p;
    t=t%p;
    return t;
}
ll power(ll a,ll x){
    if(x<0)return 1;
    ll r=1;
    while(x!=0){
        if(x%2==1){
            r=r*a;r%=p;
        }
        a=a*a;a%=p;
        x=x/2;
    }
    return r;
}
ll mul(ll a,ll b){
    ll t=(a*b);
    if(t>=p)t%=p;
    return t;
}
map<int,int> m;
int rec(int i){
    if(i==1)return 0;
    if(m.find(i)!=m.end())return m[i];
    int x;
    if(i%2==0){
        x=1+rec(i/2);
    }
    else{
        x=1+rec(3*i+1);
    }
    m[i]=x;
    return x;
}
int getKth(int lo, int hi, int k) {
    int arr[1001];
    memset(arr,-1,sizeof(arr));
    pair<int,int> b[hi-lo+1];
    for(int i=1;i<=1000;i++){
        if(arr[i]==-1){
            rec(i);
        }
        arr[i]=m[i];
    }
    for(int i=lo;i<=hi;i++){
        b[i-lo].first=arr[i];
        b[i-lo].second=i;
    }
    sort(b,b+hi-lo+1);
    return b[k-1].second;
}
int main() {
   
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
        ll k,n;cin>>k>>n;
        ll a[n];
        rep(i,n)cin>>a[i];
        ll ans=1e17;
        repA(i,1,n-1){
            ans=min(ans,k-a[i]+a[i-1]);
        }
        ans=min(ans,a[n-1]-a[0]);
        cout<<ans;
    }   
    return 0;   
}   

Measured memory_bytes: 1792
#include<cstdio>
#include<vector>
#include<algorithm>


using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using ll=long long;
using vll=vector<ll>;


void min_u(int&m, int v)
{
	if(m>v) m=v;
}


int main(void)
{
	int h, w, n;

	while(scanf("%d%d%d", &h, &w, &n)==3)
	{
		vll b(n);
		int ans=h;

		for(int i=0;i<n;i++)
		{
			int x, y;

			scanf("%d%d", &x, &y);
			ll p=x*1000000LL+y;
			b[i]=p;
		}
		sort(b.begin(), b.end());
		int sx=1, sy=1;
		for(int i=0;i<n;i++)
		{
			int x=b[i]/1000000;
			int y=b[i]%1000000;

			if((x-sx)>(y-sy))
			{
				ans=x-1;
				break;
			}
			if((x-sx)==(y-sy))
			{
				sx=x;
				sy=y-1;
			}
		}

		printf("%d\n", ans);
	}

	return 0;
}


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

int main()
{
  ll N; cin >> N;
  vector<ll> B(N-1);
  for (int i=0; i<N-1; i++){
    cin >> B[i];
  }

  ll ans = 0;
  ans = B[0] + B[N-2];
  for (int i=0; i<N-2; i++) {
    ans += min(B[i], B[i+1]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,l;
    cin>>n>>l;
    vector<pair<int,int>>v;
    int z;
    for(int i=1;i<=n;i++)
    {
       z=l+i-1;
       v.push_back(make_pair(i,z));
    }
    int z1=0;
    for(int i=0;i<n;i++)
    {
         z1=z1+v[i].second;
    }
   int result=1000000;
   int ans=0;
    for(int i=0;i<n;i++)
    {
         int r1=z1-v[i].second;
         int r2=z1-r1;
         if(result>abs(r2))
         {
              result=abs(r2);
              ans=r2;
         }

    }
    cout<<z1-ans<<endl;
}



Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
#include <queue>
#include <functional>
#include <algorithm>
#include <random>
#include <cmath>
#include <climits>
#include <iomanip>
#include <cfloat>
#include <set>
int main() {
	int n, m; std::cin >> n >> m;
	while (n != 0) {
		std::vector<long long int> scone(n);
		for (auto &s : scone) std::cin >> s;
		scone[0] %= m;
		for (auto i = 1; i < n; ++i) scone[i] = (scone[i] + scone[i - 1]) % m;
		std::set<long long int> set;
		long long int result = 0;
		for (const auto s : scone) {
			set.insert(s);
			auto upper = set.upper_bound(s);
			if (upper != set.end()) {
				if (result < m - (*upper) + s) result = m - (*upper) + s;
			}
			else {
				if (result < s) result = s;
			}
		}
		std::cout << result << std::endl;
		std::cin >> n >> m;
	}
}


Measured memory_bytes: 4304
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#define DEB2(X) cout<<X<<" ";
#else
#define DEB(X) {}
#define END {}
#define DEB2(X) {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
string S;
int A[500010];
int B[500010];

signed main(){
	cin>>S;
	int N=S.size();
	int cnt=0,cnt2=0;
	A[0]=0;
	DEB2(A[0])
	for(int i=1;i<=N;i++){
		if(S[i-1]=='<'){
			cnt++;
		}
		else{
			cnt=0;
		}
		A[i]=cnt;
		DEB2(A[i])
	}
	END
	B[N]=0;
	for(int i=N-1;0<=i;i--){
		if(S[i]=='>'){
			cnt2++;
		}
		else{
			cnt2=0;
		}
		B[i]=cnt2;
	}
	int ans=0;
	for(int i=0;i<=N;i++){
		ans+=max(A[i],B[i]);
		DEB2(B[i])
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 8708
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
typedef long long int ll;
int main(){
  ll H, W;
  int N;
  map<ll, int> mpa;
  ll num[10];
  fill(num, num + 10, 0);
  cin >> H >> W >> N;
  for(int i = 0; i < N; i++){
    ll a, b;
    cin >> a >> b;
    a--; b--;
    for(ll j = 0; j < 3; j++){
      for(ll k = 0; k < 3; k++){
	ll na = a + j;
	ll nb = b + k;
	if(na < 2 || nb < 2 || na >= H || nb >= W) continue;
	mpa[na * W + nb]++;
      }
    }
  }
  num[0] = (H - 2) * (W - 2);
  for(auto e : mpa){
    num[e.second]++;
    num[0]--;
  }
  for(int i = 0; i <= 9; i++){
    cout << num[i] << endl;
  }
  return 0;
}


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

namespace ABC164
{
    class A
    {
        static void Main(string[] args)
        {
            var SW = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (SW[0] <= SW[1]) Console.WriteLine("unsafe");
            else Console.WriteLine("safe");

        }
    }
}


Measured memory_bytes: 28236
from sys import exit


S = input()

for i in range(len(S)):
    num = i+1
    if num % 2 == 1 and S[i] == 'L':
        print('No')
        exit()
    if num % 2 == 0 and S[i] == 'R':
        print('No')
        exit()
print('Yes')


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


typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#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 FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/
typedef pair<int,int> pii;



int main(){
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W;
    cin >> H >> W;

    char s[100][100];
    vector<vector<int>> dist(H,vector<int>(W,-1));

    

    int ct = 0;
    rep(i,H)rep(j,W){
        cin >> s[i][j];
        if(s[i][j] == '.')ct++;
    }

    queue<pii> q;
    dist[0][0] = 1;

    q.push(pii(0,0));
    while(!q.empty()){
        pii r = q.front();
        q.pop();
        if(r.first < H-1 && dist[r.first+1][r.second] == -1 && s[r.first+1][r.second] == '.'){
            dist[r.first+1][r.second] = dist[r.first][r.second] + 1;
            q.push(pii(r.first+1,r.second));
        }
        if(r.second < W-1 && dist[r.first][r.second+1] == -1 && s[r.first][r.second+1] == '.'){
            dist[r.first][r.second+1] = dist[r.first][r.second] + 1;
            q.push(pii(r.first,r.second+1));
        }
      	if(r.first > 0 && dist[r.first - 1][r.second] == -1 && s[r.first-1][r.second] == '.'){
            dist[r.first-1][r.second] = dist[r.first][r.second] + 1;
            q.push(pii(r.first-1,r.second));
        }
        if(r.second > 0  && dist[r.first][r.second-1] == -1 && s[r.first][r.second-1] == '.'){
            dist[r.first][r.second-1] = dist[r.first][r.second] + 1;
            q.push(pii(r.first,r.second-1));
        }
         
    }

  	if(dist[H-1][W-1] == -1) cout << -1 << endl;
    else cout << ct - dist[H-1][W-1] << endl;

}

Measured memory_bytes: 256
# include <algorithm>
# include <cassert>
# include <cctype>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <set>
# include <sstream>
# include <stack>
# include <string>
# include <vector>
# include <iomanip>

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;


int main() {
  int n;

  while (cin >> n) {
    if (!n) break;

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

    int  sum = 0;
    int _max = scr[0];
    int _min = scr[0];

    for (int s : scr) {
      sum  += s;
      _min = min(_min, s);
      _max = max(_max, s);
    }

    sum -= _max;
    sum -= _min;

    cout << sum / (n-2) << endl;
  }

  return 0;
}

Measured memory_bytes: 3084
class UnionFind :
    def __init__(self, size) :
        """
        Parameters
        ---
        size : int
            頂点数
        """
        self.parent = list(range(size))
        self.height = [0] * size
        self.size = [1] * size
        self.component = size

    def root(self, index) :
        """
        親のインデックスの取得

        Parameters
        ---
        index : int
            取得する頂点のインデックス

        Returns
        ---
        rootIndex : int
            指定した頂点の根のインデックス
        """
        if self.parent[index] == index :  # 根の場合
            return index
        rootIndex = self.root(self.parent[index])  # 葉の場合親の根を取得
        self.parent[index] = rootIndex  # 親の付け直し
        return rootIndex

    def union(self, index1, index2) :  # 結合
        """
        木の結合

        Parameters
        ---
        index1 : int
        index2 : int
            結合する頂点のインデックス
        """
        root1 = self.root(index1)
        root2 = self.root(index2)

        if root1 == root2 :  # 連結されている場合
            return

        self.component -= 1  # 連結成分を減らす

        if self.height[root1] < self.height[root2] :
            self.parent[root1] = root2  # root2に結合
            self.size[root2] += self.size[root1]
        else :
            self.parent[root2] = root1  # root1に結合
            self.size[root1] += self.size[root2]
            if self.height[root1] == self.height[root2] :
                self.height[root1] += 1
        return

    def isSameRoot(self, index1, index2) :
        """
        同じ木に属するかを判定する

        Parameters
        ---
        index1 : int
        index2 : int

        Returns
        ---
        boolean
        """
        return self.root(index1) == self.root(index2)

    def sizeOfSameRoot(self, index) :
        """
        指定した頂点の属する木の大きさを取得する
        """
        return self.size[self.root(index)]

    def getComponent(self) :
        """
        連結成分数を取得する
        """
        return self.component


N, M = map(int, input().split())
tree = UnionFind(N)

for _ in range(M):
    X, Y, _ = map(int, input().split())
    X -= 1
    Y -= 1
    tree.union(X, Y)

ans = tree.getComponent()
print(ans)

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

int main() {
  int n, k;
  int a = 0;
  long count = 0;
  cin >> n >> k;
  vector<long> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h.at(i);
  }
  sort(h.begin(), h.end());
  reverse(h.begin(), h.end());
  while(n > 0) {
    if (k > 0) {
      a++;
      n--;
      k--;
      continue;
    }
    count += h.at(a);
    a++;
    n--;
  }
  cout << count << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 100000000000000009
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int N,x,y;
    int dpx[2][114514]={};
    int dpy[2][114514]={};
    string S;
    cin >> S;
    cin >> x >> y;
    N=S.size();
    vector<int> X,Y;
    
    bool mode=0;//0ならX 1ならY
    int w=0;
    REP(i,N){
        if(S[i]=='F'){
            w++;
        }
        if(S[i]!='F' || i==N-1){
            if(mode==0){
                X.push_back(w);
                mode=1;
            }else{
                Y.push_back(w);
                mode=0;
            }
            w=0;
        }
    }
    x-=X[0];
    X[0]=0;
    
    //cout << x;REP(i,X.size()){cout <<" "<< X[i];}cout << endl;
    //cout << y;REP(i,Y.size()){cout <<" "<< Y[i];}cout << endl;
    
    REP(i,X.size()){
        x+=X[i];
        X[i]*=2;
    }
    REP(i,Y.size()){
        y+=Y[i];
        Y[i]*=2;
    }
    
    if(x<0 || y<0){
        cout << "No" << endl;
        return 0;
    }
    //cout << x;REP(i,X.size()){cout <<" "<< X[i];}cout << endl;
    //cout << y;REP(i,Y.size()){cout <<" "<< Y[i];}cout << endl;
    
    dpx[0][0]=1;
    dpy[0][0]=1;
    
    REP(j,X.size()){
        REP(i,19810){
            if(dpx[0][i]==1){
                dpx[1][i]=1;
                dpx[1][i+X[j]]=1;
            }
        }
        REP(i,19810){
            dpx[0][i]=dpx[1][i];
            dpx[1][i]=0;
        }
    }
    REP(j,Y.size()){
        REP(i,19810){
            if(dpy[0][i]==1){
                dpy[1][i]=1;
                dpy[1][i+Y[j]]=1;
            }
        }
        REP(i,19810){
            dpy[0][i]=dpy[1][i];
            dpy[1][i]=0;
        }
    }
    
    if(dpx[0][x]==1 && dpy[0][y]==1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3968
/** "Ever tried.
         Ever failed.
               No matter.
                   Try Again.
                        Fail again.
                             Fail better.**/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define bp  __builtin_popcount
#define pb push_back
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define Unique(n)        (n).erase(unique(s(n)), (n).end())
#define NumofDigits(n)   ((long long)log10(n)+1)
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
const  double EPS = 1e-9;
const int MOD = 1e9+7;
/*
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll fastpow(ll b, ll p)
{if(!p)return 1;ll ret = fastpow(b, p >> 1);ret *= ret;if(p&1)ret*= b;return ret;}
int dx[] = {- 1, 0, 0, 1, 0 };
int dy[] = { 0,- 1, 1, 0, 0 };*/
void File()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}

int arr[105];
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n;
    cin>>n;
    ll sum=0;
    for(int i=1;i<=n;i++)
        cin>>arr[i],sum+=arr[i];
    int m;
    cin>>m;
    while(m--)
    {
        int p,x;
        cin>>p>>x;
        cout<<(sum+x-arr[p])<<endl;
    }
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1



int main() {
  vector<int> A(3);
  rep(i, 3)
    cin >> A[i];
  sort(ALL(A));
  if(A[0]==A[1]&&A[1]!=A[2])
    cout << "Yes" << endl;
  else if(A[1]==A[2]&&A[1]!=A[0])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int N;
vector<ll> v;
ll dfs(int cur, ll acc, ll pre){
  if(cur == N) return 0;
  ll Sum = v[cur] + acc;
  ll ret;
  if(pre*Sum < 0) return dfs(cur+1, acc,  Sum);
  if(Sum == 0){
    if(pre>0) ret =  dfs(cur+1, acc-1, -1) +1;
    else ret =  dfs(cur+1, acc+1, +1) +1;
  }else{
    if(pre>0) ret =  dfs(cur+1, acc-Sum-1, -1) +abs(Sum) +1;
    else ret = dfs(cur+1, acc-Sum+1, 1) +abs(Sum) +1;
  }
  return ret;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cin >> N;
  v = vector<ll>(N);
  rep(i,N)cin >> v[i];
  rep(i,N-1) v[i+1] += v[i];
  ll count = dfs(0,0,1);
  count = min(count,dfs(0,0,-1));
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
//#include <math>
using namespace std;
typedef long long ll;
int M = 1000000000;
int main(){
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;

  int ans = M;
  int i=0;
  int bound = max(X,Y);
  while(i<=bound){
    int Aremain = max(0,X-i);
    int Bremain = max(0,Y-i);
    ans = min(ans, 2*i*C+A*Aremain+B*Bremain);
    i++;
  }
  cout << ans << endl;


  
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val K = nextLong()
    fun sum(n: Long) = n.toString().map { it - '0' }.reduce { ac, v -> ac + v }
    fun compare(x: Long, y: Long) = !(x * sum(y) <= y * sum(x))
    var ans = 0L
    var a = 1L
    for (i in 0 until K) {
        if (compare(ans + a, ans + 10 * a)) a *= 10
        ans += a
        println(ans)
    }
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun nextLong() = java.lang.Long.parseLong(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }
fun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }


Measured memory_bytes: 30584
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long 
#define dd cout<<endl
#define lll __int128
const int inf=1e9+7;
const int mod=1e9+7;

//const int maxn=

int main()
{
//	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);;
	
	int n,k;
	
	scanf("%d%d",&n,&k);
	
	priority_queue<ll int>q;
	
	ll int sum=0;
	ll int x;
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&x);
		sum+=x;
		q.push(x);
	}
	
	for(int i=0;i<k;i++)
	{
		ll int now=q.top();
		q.pop();
		
		ll int now1=now/2;
		
		sum-=(now-now1);
		
		q.push(now1);
		
	}
	
	printf("%lld\n",sum);
	
	return 0;
}

Measured memory_bytes: 1400
//### In The Name Of GOD ###

#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;

const int MOD = 1000000007;
const int INF = 30 * 1000 + 20;
const int MAXN = 2600;
const int MLOG = 18;
const int NMAX = 60;

#define int ll
#define pb push_back
#define pp pop_back
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);
#define sz(a) (int)(a.size())
#define ct(x) const_cast<const int&>(x)

int32_t main(){
	int n , k;
	cin >> n >> k;
	bool mark[10] ={};
	for(int i = 0; i < k ; i++){
		int a;
		cin >> a;
		mark[a] = true;
	}
	for(int i = n ; i < n*100; i++){
		int a = i;
		while(a > 0 && !mark[a%10])
			a/=10;
		if(a==0){
			cout << i;
			return 0;
		}
	}
}

Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = {False: 'No', True: 'Yes'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
# sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def main():
    s = S()
    t = S()
    s_pos = {k: set() for k in l_alp}
    t_pos = {k: set() for k in l_alp}

    for i in range(len(s)):
        s_pos[s[i]].add(i)
        t_pos[t[i]].add(i)

    for c in l_alp:
        loc = s_pos[c]
        candidates = set()
        for i in loc:
            candidates.add(t[i])

        if len(candidates) > 1:
            print('No')
            return

    for c in l_alp:
        loc = t_pos[c]
        candidates = set()
        for i in loc:
            candidates.add(s[i])

        if len(candidates) > 1:
            # print(c, candidates)
            print('No')
            return

    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 87992
/*
Author :: Shahadat Hossain Nirob
............SUST_MATH14..........
*/
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <set>
#include <string>
#include <vector>

#define Long long long
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define II() ( { int a ; read(a) ; a; } )
#define LL() ( { Long a ; read(a) ; a; } )
#define DD() ({double a; scanf("%lf", &a); a;})
#define DB if(0) 
#define D(x) cout << #x " is " << x << endl
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;
typedef vector<PII> VII;
typedef vector<string> VS;

const int INF = 2000000009;
const int MX = 200005;
const double EPS = 1e-9;
const int MOD = 1000000007;

template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }

template<class T>inline bool read(T &x){
    int c=getchar();int sgn=1;
    while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}
    for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; 
    x*=sgn; return ~c;
}

#define nl puts ("")
#define sp printf ( " " )
#define phl printf ( "hello\n" )
#define ff first
#define ss second
#define POPCOUNT __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
#define MP make_pair
#define FOR(i,x,y) for(vlong i = (x) ; i <= (y) ; ++i)
#define ROF(i,x,y) for(vlong i = (y) ; i >= (x) ; --i)
#define CLR(x,y) memset(x,y,sizeof(x))
#define UNIQUE(V) (V).erase(unique((V).begin(),(V).end()),(V).end())
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1)
#define SQ(x) ((x)*(x))
#define ABS(x) ((x)<0?-(x):(x))
#define FABS(x) ((x)+eps<0?-(x):(x))
#define ALL(x) (x).begin(),(x).end()
#define LCM(x,y) (((x)/gcd((x),(y)))*(y))
#define SZ(x) ((vlong)(x).size())
#define NORM(x) if(x>=mod)x-=mod;
#define MOD(x,y) (((x)*(y))%mod)
#define ODD(x) (((x)&1)==0?(0):(1))

typedef string st;
typedef vector<st> vs;
#define rep(i, n) for(int i = 0; i < n; i++)
#define fogg(i,a,b) for(int i = (a); i <= (b); i++)
#define ford(i,a,b) for(int i = (a); i >= (b); i--)
#define test int t; cin >> t; while(t--)
#define endl '\n'
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main()
{
	/*
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    */
    
    int a[3];
    rep(i,3) a[i]=II();
    sort(a,a+3);
    cout << a[2]-a[0] << endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
pair<ll,ll>p[214514];
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>p[i].second>>p[i].first;
	sort(p,p+n);
	ll cnt=0;
	for(int i=0;i<n;i++){
		if(cnt+p[i].second>p[i].first){
			cout<<"No"<<endl;
			return 0;
		}
		cnt+=p[i].second;
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
struct Card {
    char m;
    int n;
    int index;
};
int partition(Card* a, int p, int r)
{
    int x = a[r].n;
    int i = p - 1;
    for (int j = p; j <= r; j++) {
	if (a[j].n <= x) {
	    i++;
	    Card tmp = a[i];
	    a[i] = a[j];
	    a[j] = tmp;
	}
    }
    return i;
}
void quickSort(Card* a, int p, int r)
{
    if (p < r) {
	int q = partition(a, p, r);
	quickSort(a, p, q - 1);
	quickSort(a, q + 1, r);
    }
}

bool checkStable(Card* a, int size)
{
    Card* prevCard = (Card*)malloc(sizeof(Card));
    for (int i = 0; i < size; i++) {
	if (prevCard->n == a[i].n && prevCard->index > a[i].index) {
	    return false;
	}
	*prevCard = a[i];
    }
    return true;
}
int main()
{
    int n = 0;
    std::cin >> n;
    Card* a = (Card*)malloc(n * sizeof(Card));
    for (int i = 0; i < n; i++) {
	std::cin >> a[i].m;
	std::cin >> a[i].n;
	a[i].index = i;
    }
    quickSort(a, 0, n - 1);
    bool isStable = checkStable(a, n);
    if (isStable) {
	std::cout << "Stable" << std::endl;
    } else {
	std::cout << "Not stable" << std::endl;
    }
    for (int i = 0; i < n; i++) {
	std::cout << a[i].m << " " << a[i].n << std::endl;
    }
}

Measured memory_bytes: 4260
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int N, T; cin >> N >> T;
    vector<pair<int, int>> nonzero;
    vector<int> zero;
    for (int i = 0; i < N; i++) {
        int a, b; cin >> a >> b;
        if (a == 0) zero.push_back(b);
        else nonzero.emplace_back(a, b);
    }
    auto compare = [](pair<int, int>& X, pair<int, int>& Y) {
        return Y.first * (X.second + 1LL) < X.first * (Y.second + 1LL);
    };
    sort(begin(nonzero), end(nonzero), compare);
    vector<Int> dp(32, T + 1);
    dp[0] = 0;
    for (int i = 0; i < nonzero.size(); i++) {
        Int a, b; tie(a, b) = nonzero[i];
        for (int j = dp.size() - 2; j >= 0; j--) {
            Int t0 = dp[j];
            Int t1 = t0 + 1 + a * (t0 + 1) + b;
            if (t1 < dp[j + 1]) {
                dp[j + 1] = t1;
            }
        }
    }
    sort(begin(zero), end(zero));
    vector<Int> sum(zero.size() + 1);
    for (int i = 0; i < zero.size(); i++) {
        sum[i + 1] += sum[i] + zero[i] + 1;
    }
    int ans = 0;
    int j = sum.size() - 1;
    for (int i = 0; i < 32; i++) {
        while (j >= 0 && dp[i] + sum[j] > T) j--;
        if (j >= 0) {
            ans = max(ans, i + j);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2804
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    VI a(n);
    REP(i,0,n) cin >> a[i];
    if (a[0] != 0) {
        cout << -1 << endl;
        return;
    }
    REP(i,1,n) {
        if (a[i] > a[i-1] + 1) {
            cout << -1 << endl;
            return;
        }
    }
    LL cnt = 0;
    REP(i,1,n-1) {
        if (a[i] != a[i+1] - 1) cnt += a[i];
    }
    cnt += a[n-1];
    cout << cnt << endl;
}

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

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>

int main () {

    int n;
    std::cin >> n;

    int64_t ans = 0;
    for(int64_t i = 1; i <= n; i++) {
        if((i % 3) != 0 && (i % 5) != 0) ans += i;
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 3164
#!/usr/bin/env python3

def main():
    n = int(input())
    tn = [int(input()) for i in range(n)]
    print(lcm(tn))

def lcm(li):
    res = 1
    for x in li:
        res *= (x // gcd(res, x))
    return res

def gcd(x, y):
    if x < y:
        x, y = y, x  # x >= y
    while y > 0:
        r = x % y
        x = y
        y = r
    return x

main()



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define rep(i, n) repr(i, 0, n)
#define repr(i, a, t) reps(i, a, t, 1)
#define reps(i, a, t, s) for (long long (i) = (a); (i) < (long long)(t); (i) += (s))
#define rrep(i, n) rrepr(i, (n - 1), 0)
#define rrepr(i, a, t) rreps(i, a, t, 1)
#define rreps(i, a, t, s) for (long long (i) = (a); (i) >= (long long)(t); (i) -= (s))
#define each(v, c) for (auto &&(v) : (c))
using namespace std;
using namespace boost::multiprecision;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ml = cpp_int;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ifstream ifs;
  if (getenv("LOCAL") != nullptr) {
    ifs.open("src/_in.txt");
    cin.rdbuf(ifs.rdbuf());
  }

  ll N;
  vector<ll> A, B, C;
  cin >> N;
  rep (i, N) {
    ll a;
    cin >> a;
    A.push_back(a);
  }
  rep (i, N) {
    ll b;
    cin >> b;
    B.push_back(b);
  }
  rep (i, N) {
    ll c;
    cin >> c;
    C.push_back(c);
  }

  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());

  // c_counts[i]: B[i] の下における C の数
  vector<ll> c_counts(N);
  int c = 0;
  rep (b, N) {
    while (c < N && B[b] >= C[c]) {
      c++;
    }
    c_counts[b] = N - c;
  }

  vector<ll> cumsum(N + 1);
  ll cs = 0;
  cumsum[N] = cs;
  rrep (i, N) {
    cs += c_counts[i];
    cumsum[i] = cs;
  }
  ll s = accumulate(cumsum.begin(), cumsum.end(), 0ll);

  ll ans = 0;
  int b = 0;
  rep (a, N) {
    while (b < N && A[a] >= B[b]) {
      b++;
    }
    ans += cumsum[b];
  }
  cout << ans << "\n";
}

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

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

	int L,D=0;
	int count=0;
	for (int i = 0; i < N; i++) {
		cin >> L;
		D += L;
		if (D <= X) {
			count++;
		}
		//cout << D << endl;
	}
	
	cout << count+1 << endl;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
const int INF = 1000000000;
typedef pair<int, int> P;
const int MAX_N = 200000;
const int MAX_L = 100000000;
const int MAX_SQRT_B = 10000;
typedef int64_t ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

string N;

int main() {
	cin >> N;
	ll tmp = 0;
	rep(i, N.size()) {
		tmp += N.at(i) - '0';
	}
	if (tmp%9==0)
	{
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

int main() {
  int hmc;
  cin >> hmc;
  vector<int> cards(hmc);
  for(int i = 0; i < hmc; i++) {
    cin >> cards.at(i);
  }
  sort(cards.begin(), cards.end());
  reverse(cards.begin(), cards.end());
  int ap = 0;
  int bp = 0;
  for(int j = 0; j < hmc; j++) {
    if (j % 2 == 0) {
      ap += cards.at(j);
    }
    else {
      bp += cards.at(j);
    }
  }
  cout << ap - bp << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for (int i = 0; i < N; i ++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  int x = 1;
  
  for(int i = 0; i < N-1; i ++){
    if (vec.at(i) < vec.at(i+1)){
      x ++;
    }
    
  }
  
  cout << x << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(30) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  flag=-1;
  rep(i,0,50001){
    K=1.08*i;
    if(K==N)flag=i;
  }
  if(flag==-1)Out(":(");
  else Out(flag);
}

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

int main(){

int a[5][4][11],n;
for (int i=0;i<5;i++)
for (int j=0;j<4;j++)
for (int k=0;k<11;k++) a[i][j][k]=0;

cin >>n;
for(int i=0;i<n;i++){
int b,f,r,v;
cin >>b >>f >>r >>v;
a[b][f][r]+=v;
}

for (int f=1;f<=4;f++){
if(f>1)cout <<"####################\n";
for(int b=1;b<=3;b++){
for(int r=1;r<=10;r++){
cout <<" "<<a[f][b][r];
}
cout <<endl;
}
}
return 0;
}

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

#define watch(x) cout << (#x) << " = " << x << endl;
#define mkp make_pair
#define mkt make_tuple
#define pb push_back
#define ll long long
#define ld long double

using namespace std;

int n, m, dp[3010][3010];
pair<int, int> pre[3010][3010];
string s, t;

void bt(int i, int j){
	if(pre[i][j] != mkp(-1, -1)) bt(pre[i][j].first, pre[i][j].second);

	if(i == 0 || j == 0) return;
	if(s[i - 1] == t[j - 1]) cout << s[i - 1];
}

int main(){
	getline(cin, s);
	getline(cin, t);

	//s = '-' + s;
	//t = '-' + s;

	n = s.size(), m = t.size();

	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= m; j++) {dp[i][j] = -1e9; pre[i][j] = mkp(-1, -1);}
	}

	for(int i = 0; i <= n; i++) dp[i][0] = 0;
	for(int j = 0; j <= m; j++) dp[0][j] = 0;

	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			if(s[i - 1] == t[j - 1]){
				if(dp[i][j] < dp[i - 1][j - 1] + 1) pre[i][j] = mkp(i - 1, j - 1);
				dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
			} else {
				if(dp[i][j] < dp[i - 1][j]) pre[i][j] = mkp(i - 1, j);
				dp[i][j] = max(dp[i][j], dp[i - 1][j]);
				if(dp[i][j] < dp[i][j - 1]) pre[i][j] = mkp(i, j - 1);
				dp[i][j] = max(dp[i][j], dp[i][j - 1]);
			}
		}
	}

	bt(n, m);
	cout << endl;

	return 0;
}

Measured memory_bytes: 106496
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int input = Integer.parseInt(sc.nextLine());
		int result = 0;
		for (int i=0; i<1; i++) {
			result = 1 * input;
			for (int j=0; j<1; j++) {
				result += input * input;
				for (int k=0; k<1; k++) {
					result += input * input * input;
				}
			}
		}
	    System.out.println(result);
	}
}


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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  int j;
  int v;
  for (int i = 0; i < vec.size(); i++) {
    cin >> vec.at(i);
    if (i > 0) cout << " ";
    cout << vec.at(i);
  }
  cout << endl;
  for (int i = 1; i < n; i++) {
    v = vec.at(i);
    j = i - 1;
    while (j >= 0 && vec.at(j) > v) {
      vec.at(j + 1) = vec.at(j);
      j--;
    }
    vec.at(j + 1) = v;
    for (int i = 0; i < vec.size(); i++) {
      if (i > 0) cout << " ";
      cout << vec.at(i);
    }
    cout << endl;
  }
}



Measured memory_bytes: 3080
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*
import kotlin.comparisons.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val n = readInt()

    println(n * (n+1) / 2)
    pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }


// Extensions
fun<T> List<T>.toBuckets(bucketKeys: List<T>): Map<T, Int> {
    val buckets = bucketKeys.associate { t -> Pair(t, 0) }.toMutableMap()
    this.forEach { t ->
        buckets[t] = buckets[t]!! + 1
    }
    return buckets
}

fun <K, V> Map<K, V>.toMutableMap(): MutableMap<K, V> = HashMap(this)

// Util Functions
fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int N;
int A[1000];

int solve(int k){
  vector<int> a;
  int sum=0;
  rep(i,N){
    if(A[i]%k!=0)continue;
    int tmp=A[i]/k;
    while(tmp%2==0)tmp/=2;
    if(tmp!=1)continue;
    a.push_back(A[i]/k);
    sum+=A[i]/k;
  }
  if((int)a.size()==0)return 0;
  int M=a.size();
  vector<int> dp(sum+1,-1);
  dp[0]=0;
  rep(i,M){
    for(int j=sum-a[i];j>=0;j--){
      if(dp[j]==-1)continue;
      if((j&(a[i]-1))==0&&j+a[i]<=sum)maxch(dp[j+a[i]],dp[j]+1);
    }
  }
  int res=0;
  for(int j=1;j<=sum;j<<=1)maxch(res,dp[j]);
  return res;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  while(1){
    cin>>N;
    if(N==0)break;
    rep(i,N)cin>>A[i];

    int res=0;
    repl(k,1,501){
      maxch(res,solve(k));
    }
    cout<<res<<endl;
  }
  return 0;
}



Measured memory_bytes: 3644
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





















int main() {
	ll n;
	cin >> n;
	ll c = 1000, pre;
	cin >> pre;
	REP(i, n - 1) {
		ll a;
		cin >> a;
		if (pre < a) {
			c += (a - pre) * (c / pre);
		}
		pre = a;
	}
	cout << c << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>

int binarySearch(int *,int,int);

int main(){
  int S[100000];
  int T[50000];
  int N,q,i;
  int cnt=0;

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
    if(binarySearch(S,N,T[i]))cnt++;
  }

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

  return 0;
}

int binarySearch(int A[],int N,int key){
  int right=N;
  int left=0;
  int mid=0;

  while(right > left){

    mid = (left + right) / 2;

    if(A[mid] == key)return 1;

    if(A[mid] < key){
      left = mid + 1;
    }
    else if(A[mid] > key){
      right = mid;
    }

  }

  return 0;
}
    



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

using namespace std;

#define debug(x) '[' << #x << " is: " << x << "] "
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int nax = 1e5 + 100;
int f[nax][2];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
	#endif
	int n;
	cin>>n;
	vector<ll> a(n);
	ll sum = 0,ans = 1e18;
	for(int i=0;i<n;i++){
		cin>>a[i];
		a[i] -= i + 1;
		sum += a[i];
	}
	sort(a.begin(),a.end());
	ll pre=0;
	for(int i=0;i<n;i++){
		ans = min(ans , sum - a[i]*(n-i) + a[i] * i - pre);
		pre+=a[i];
		sum-=a[i];
	}
	ans = min(ans , a[n-1]*n - pre);
	cout << ans << endl;
}

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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...)
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.txt", "r", stdin);
		//freopen("b.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int N = 1e5;
	vector<int> c(N+1);
	for (int i = 1; i <= N; ++i)
		c[i] = c[i-1] + (to_string(i).length()%2 == 1);

	int n;
	cin >> n;
	cout << c[n] << "\n";

	return 0;
}


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

int main() {
  int N, sum;
  cin >> N;
  sum = 0;
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    sum += b - a + 1;
  }
  cout << sum << endl;
}

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

#define    ll     long long int

const int N = 100005;
int ara[N];
int cnt[N];

int main( )
{
    int i, j, k, n, mx = 0, c;
    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> ara[i];
        cnt[ara[i]]++;
    }
    for (i = 1; i <= n; i++) {
        j = ara[i];
        c = cnt[j];
        if (j != 0) {
            c += cnt[j - 1];
        }
        c += cnt[j + 1];
        mx = max(mx, c);
    }
    cout << mx << '\n';
    return 0;
}


Measured memory_bytes: 1024