akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<cassert>
#define rep(i, n) for ( int i = 0; i < n; i++)
using namespace std;

#define MAX 10
#define PMAX 23
#define HOUSE 3
#define SPACE 0
#define SMOKE 1
#define START 2
#define BLOCK 4

int H, W, n;

class State{
public:
  unsigned short pi, pj, total;
  bool V[PMAX];

  State(){total = 0;}

  bool operator < ( const State &s) const{
    if ( pi != s.pi ) return pi < s.pi;
    if ( pj != s.pj ) return pj < s.pj;
    for ( int i = 0; i < n; i++ ){
      if ( V[i] == s.V[i] ) continue;
      return V[i] < s.V[i];
    }
    return false;
  }
};

static int di[4] = {0, -1, 0, 1};
static int dj[4] = {1, 0, -1, 0};

int  G[MAX+2][MAX+2], I[MAX+2][MAX+2];

main(){
  int si, sj;

  while(1){
    cin >> W >> H;
    if ( W == 0 && H == 0 ) break;
    int total = 0;
    n = 0;
    for ( int i = 0; i < H+2; i++ )
      for ( int j = 0; j < W+2; j++ ) G[i][j] = BLOCK;
    for ( int i = 1; i <= H; i++ ){
      for ( int j = 1; j <= W; j++ ){
	cin >> G[i][j];
	if ( G[i][j] == START ){ si = i; sj = j;}
	if ( G[i][j] == SMOKE ) { total++; I[i][j] = n++; }
      }
    }

    State s = State();
    
    for ( int i = 0; i < n; i++ ) s.V[i] = true;

    map<State, int> M;
    State v;

    int ni, nj;
    M[s] = 0;
    
    for ( int r = 0; r < 4; r++ ){
      ni = si + di[r];
      nj = sj + dj[r];

      while(1){
	if ( G[ni][nj] == SMOKE && s.V[I[ni][nj]] ){
	  v = s;
	  v.pi = ni;
	  v.pj = nj;
	  v.V[I[ni][nj]] = false;
	  v.total = 1;
	  M[v] = 1;
	  break;
	} else if ( G[ni][nj] == BLOCK ) break;
	ni += di[r];
	nj += dj[r];
      }
    }

    map<State, int>::iterator it;
    
    int presize = M.size();

    int cc = 0;
    int x = 0;
    bool f;
    map<State, int> nM;

    while(1){
      nM.clear();
      f = true;
      for ( it = M.begin(); it != M.end(); it++ ){
	State cur = (*it).first;
	int cost = (*it).second;
	if ( cost == 0 ) continue;

	for ( int r = 0; r < 4; r++ ){
	  ni = cur.pi + di[r];
	  nj = cur.pj + dj[r];

	  while(1){
	    if ( G[ni][nj] == SMOKE && cur.V[I[ni][nj]]){
	      v = cur;
	      v.pi = ni;
	      v.pj = nj;
	      v.V[I[ni][nj]] = false;
	      v.total++;
	      f = false;
	      nM[v] += cost;
	      break;
	    } else if ( ni == si && nj == sj && cur.total == total ){
	      x += cost;
	      break;
	    } else if ( G[ni][nj] == BLOCK ) {
	      break;
	    }
	    ni += di[r];
	    nj += dj[r];
	  }
	}
      }
      if ( f ) break;
      M = nM;
    }

    cout << x << endl;
  }
}

Measured memory_bytes: 21000
#include <stdio.h>
#include <stdlib.h>

int compare(const void *a, const void *b) {
  return *(int *)b - *(int *)a;
}

int main(){
    int i, j, k, m, n;
    int b, c, bsum;
    int *aa;
    int *cb;
    long long int sum;

    scanf("%d %d", &n, &m);
    aa = (int *)malloc(sizeof(int) * n * 2);
    cb = (int *)malloc(sizeof(int) * m * 2);

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

    bsum = 0;
    for(i = 0; i < m; i++){
        scanf("%d %d", &cb[i*2+1], &cb[i*2+0]);
        bsum += cb[i*2+1];
    }
    

    qsort(cb, m, sizeof(int)*2, compare);

    k=0;
    for(i = 0; i < m; i++){
        for(j = 0; j < cb[i*2+1]; j++){
            if(k==n)break;
            aa[n+k] = cb[i*2+0];
            k++;
        }
        if(k==n)break;
    }

    qsort(aa, n*2, sizeof(int), compare);

    sum = 0;
    for(i = 0; i < n; i++){
        sum += aa[i];
    }
    printf("%lld\n", sum);
    
    return 0;
}

Measured memory_bytes: 2548
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<list>
#include<string>
#include<unordered_map>
#include<set>
#include<limits.h>
#include<string.h>
#include<functional>
#include<map>
#include<unordered_set>
#define int long long
using namespace std;

signed main() {
	int ans = 0;
	int n, k; cin >> n >> k;
	for (int i = k + 1; i <= n; i++) {
		ans += n / i*(i - k);
		int j = n%i;
		if(j)ans += max(0ll, j - (max(1ll,k))+1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main() {
	ios::sync_with_stdio(false);
	cin >> a >> b;
	if(a <= 0 && b >= 0)
		cout << "Zero\n";
	else if(a > 0 || abs(b) - abs(a) & 1)
		cout << "Positive\n";
	else
		cout << "Negative\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fastio ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
//const long long INF64 = 1'000'000'000'000'000'000ll;
#define MOD 1000000007
double pow(double a, int n){
    double ret =1;
    while(n){
        if(n%2==1)ret*=a;
        a*=a;
        n/=2;
    }
    return ret;
}
const int MAX_SIZE = 1000001; 
vector<int >isprime(MAX_SIZE , true); 
vector<int >prime; 
vector<int >SPF(MAX_SIZE); 
void manipulated_seive(int N) 
{ 
	 isprime[0] = isprime[1] = false ; 
	 for (int i=2; i<N ; i++) 
	 { 
		 if (isprime[i]) 
		 { 
			 prime.push_back(i); 
			 SPF[i] = i; 
		 } 
		 
		 for (int j=0;j < (int)prime.size() && i*prime[j] < N && prime[j] <= SPF[i];j++) 
		 { 
			 isprime[i*prime[j]]=false; 
			 SPF[i*prime[j]] = prime[j] ; 
		 } 
	 } 
}
#undef int
int main() {
    #define int long long
    //fastio;
    string s;
    cin>>s;
    int n=s.length();
    string t="";
    string c="";
    int count=0;
    for(int i=0;i<n;i++){
        c+=s[i];
        if(c!=t){
            count++;
            t=c;
            c="";
        }
    }
    cout<<count;
    return 0;
}


Measured memory_bytes: 16260
n=gets.to_i
ary=gets.split.map(&:to_i)
b=gets.split.map(&:to_i)
c=gets.split.map(&:to_i)
prev = -1
result = 0
ary.each do |a|
  result += b[a-1]
  if a - prev == 1
    result += c[a-2]
  end
  prev = a
end

puts result

Measured memory_bytes: 1788
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

struct Edge
{
	int to, dist, c;	
};

int main(){
	int n, m;
	while(cin >> n >> m && n) {
		int s, g;
		cin >> s >> g;
		s--, g--;
		vi x(m), y(m), d(m), c(m);
		rep(i, m) {
			cin >> x[i] >> y[i] >> d[i] >> c[i];
			x[i]--, y[i]--;
		}
		double time[35][35][35]; //time[to][from][speed]
		rep(i, 35) rep(j, 35) rep(k, 35) time[i][j][k] = 1e18;
		vector<vector<Edge>> es(n);
		rep(i, m) {
			es[x[i]].pb({y[i], d[i], c[i]});
			es[y[i]].pb({x[i], d[i], c[i]});
		}
		auto dijkstra = [&] {
			typedef pair<pair<double,int>, pair<int, int>> P;//time, speed, from, to
			priority_queue<P, vector<P>, greater<P> > q;
			time[s][34][0] = 0.0;
			q.push({{0.0, 0}, {34, s}});
			P p;
			while(!q.empty()) {
				p = q.top();	q.pop();
				double tmp = p.fi.fi;
				int from = p.se.fi, now = p.se.se, v = p.fi.se;
				//cout << from << " " << now << " " << v << " " << tmp << endl;
				if(time[now][from][v] < tmp) continue;
				for(auto& e : es[now]) {
					if(e.to == from) continue;
					int to = e.to, dist = e.dist, c = e.c;
					if(v > 1 && v-1 <= c) { 
						double nt = tmp + (double)dist / (v-1.0);
						if(nt +EPS< time[to][now][v-1]) {
							time[to][now][v-1] = nt;
							q.push({{nt, v-1}, {now, to}});
						}
					}
					if(v != 0 && v <= c) {
						double nt = tmp + (double)dist / v;
						if(nt +EPS < time[to][now][v]) {
							time[to][now][v] = nt;
							q.push({{nt, v}, {now, to}});
						}
					}
					if(v +1 <= c) {
						double nt = tmp + (double)dist / (v+1.0);
						if(nt +EPS< time[to][now][v+1]) {
							time[to][now][v+1] = nt;
							q.push({{nt, v+1}, {now, to}});
						}
					}
				}
			}
		};
		dijkstra();
		double ans = 1e18;
		for(int i = 0; i < n; i++) ans = min(ans, time[g][i][1]);
		if(ans == 1e18) cout << "unreachable" << endl;
		else printf("%.15lf\n", ans);
	}
}

Measured memory_bytes: 3844
N = int(input())
A = list(map(int,input().split()))

humidai = 0

for i in range(1,N):
  if A[i-1] > A[i]:
    humidai_plus = (A[i-1] - A[i])
    A[i] += humidai_plus
    humidai += humidai_plus
    
print(humidai)

Measured memory_bytes: 32248
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define F first
#define S second
//#define int long long

///My functions

//Constants
const int mxn = 3*1e5+5, inf = 1e9+7, mod = 1e9+7;
const long long infLL = 1e18+5;
const double EPS = 1e-9 , PI = acos(-1);

//Structs

//Variables
int n,m,Q,k,a,b,c,sum,ans,MAXans,MINans,sc,pos,acc[mxn],racc[mxn],ar[mxn];
vector<int>v,g[mxn];
bitset<mxn>flag;
bool sol ;
string s;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> n >> s ; s = "__" + s ;

    for( int i = 2 ; i <= n + 1 ; i++ ){
    	if( s[i] == 'C' and s[i - 1] == 'B' and s[i - 2] == 'A' ) ans++ ;
    }

    cout << ans ; 





    return 0;
}
























Measured memory_bytes: 8448
#include<iostream>
#include<cstdlib>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<cmath>
#include<iomanip>
#define rep(i,n) for(int i(0);i<n;i++)
const int INF = 1001001001;

using namespace std;
int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	
	string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";

	rep(i,s.length()){
		rep(j,26){
			if(s.substr(i,1) == alphabet.substr(j,1)) cout << alphabet.substr(j+n,1);
		}
	}

	cout << endl;

    return 0;
}


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

#define for(i, a, b) for(ll (i)=a;(i)<(b);++(i))
#define rep(i, n)    for(i, 0, n)

const ll inf = 1e15;
const ll mod = 1e9+7;

int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};

vector<ll> get_primes(ll n) {
    vector<ll> primes(n+1, 1);
    primes[0] = primes[1] = 0;
    for(i, 2, sqrt(n+1)+1)
        if(primes[i]) for(j, i*i, n+1) primes[j] = 0, j += (i - 1);
    return primes;
}

int main() {
    ll N;
    cin >> N;
    
    vector<ll> nums(N+1, 0);
    vector<ll> primes = get_primes(N);
    
    for(i, 2, N+1) if(primes[i]) {
        for(j, 2, N+1) {
            ll c = 0;
            ll x = j;
            while (x % i == 0) x /= i, c++;
            nums[i] += c;
        }
    }
    
    ll ans = 1;
    for(i, 2, N+1) {
        ans *= (nums[i] + 1);
        ans %= mod;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
    char S[3];
    int i,cou;
    scanf("%s",&S);
    for(i=0;i<3;i++){
        if(S[i]=='o'){
            cou++;
        }
    }
    printf("%d",700+cou*100);
    return 0;
}

Measured memory_bytes: 128
from collections import Counter


def main():
    n = int(input())
    ws = [input() for _ in range(n)]
    counts = Counter(ws)
    if any(v > 1 for v in counts.values()):
        print('No')
        return
    for i in range(1, n):
        if ws[i - 1][-1] != ws[i][0]:
            print('No')
            return
    print('Yes')


if __name__ == '__main__':
    main()


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

using namespace std;

long long INF=1e15;

int n,m;
char field[30][30];

void dfs(int x,int y){
    //今いる場所を書き換え
    field[y][x]='1';

    //移動を8ループ
    for(int dx=-1;dx<=1;dx++){
        for(int dy=-1;dy<=1;dy++){

            if(dx*dy!=0)continue;

            int nx=x+dx,ny=y+dy;

            if(0<=nx && nx<n && 0<=ny && ny<m && field[ny][nx]=='.')dfs(nx,ny);
        }
    }
    return ;
}

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

    while(1){
        cin>>n>>m;
        
        if(n==0&&m==0)break;

        int sx,sy;

        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                cin>>field[i][j];
                if(field[i][j]=='@'){
                    sx=j;sy=i;
                }
            }
        }

        dfs(sx,sy);

        int res=0;

        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                if(field[i][j]=='1')res++;
            }
        }

        cout<<res<<endl;

    }
}


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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  cout<<n*n*n<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define mod 1000000007
#define pb push_back
#define EPS 1e-6

inline lli moduloMultiplication(lli x, lli y) {
	return (x%mod * 1LL * y%mod) % mod;
}

 
int main(){
	fast;
	string s;
	cin>>s;
	int carry = 0, ans = 0;
	for(int i = s.size() - 1; i >= 0; i--)
	{
		int val = s[i] - '0';
		val += carry;
		carry = val / 10;
		val %= 10;
		if(val >= 6)
		{
			ans += (10 - val);
			carry = 1;
		}
		else if(val == 5)
		{
			if(i - 1 >= 0 && s[i - 1] >= '5')
			{
				ans += (10 - val);
				carry = 1;
			}
			else
				ans += val;
		}
		else
			ans += val;
	}	
	cout << ans + carry<<"\n";
	return 0;
}

Measured memory_bytes: 1948
#include <cstdio>
#include <iostream>
#include <vector>
#include <iomanip>
#include <fstream>
#include <map>
#include <algorithm>
#include <unordered_map>
#include <cmath>
#include <queue>

#define maxn 200010
#define inf 1LL<<60

using namespace std;
long long x[maxn];
long long dp[maxn];

int main() {
    // freopen("POLYGON.in", "r", stdin);
    // freopen("POLYGON.out", "w", stdout);
    int n;
    long long e, t;
    cin >> n >> e >> t;
    
    for (int i = 1; i <= n; ++i) {
        cin >> x[i];
    }
    x[n+1] = e;
    
    dp[1] = x[1];
    for (int i = 2; i <= n+1; ++i) {
        dp[i] = inf;
    }
    int j = 1;
    long long bonus = inf;
    for (int i = 1; i <= n; ++i) {
        while (j < n && 2*(x[j+1] - x[i]) <= t) {
            bonus += 3*(x[j+1] - x[j]);
            ++j;
            dp[j+1] = min(dp[j+1], bonus + x[j+1] - x[j]);
        }
        dp[j+1] = min(dp[j+1], dp[i] + 3*(x[j] - x[i]) + (t - 2*(x[j] - x[i])) + x[j+1] - x[j]);
        bonus = min(bonus, dp[i] + 3*(x[j]-x[i]));
        
        /*
        for (int j = i; j <= n; ++j) {
            dp[j+1] = min(dp[j+1], dp[i] + 3*(x[j] - x[i]) + max(0LL, t - 2*(x[j] - x[i])) + x[j+1] - x[j]);
        }
        */
    }
    cout << dp[n+1];
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
const int INFI=2147483647;
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


int main() {
  int n; cin >>n;
  set<int> S;
  rep(i, n){
    int buf; cin >>buf; S.insert(buf);
  }
  cout <<S.size() <<endl;
}


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

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define N (int)(2e5 + 10)

using namespace std;


void solve() {
	int n;
	cin >> n;
	int tot = 0;
	int cur = 1;
	while (n) {
		tot += cur;
		cur *= 2;
		n /= 2;
	}

	cout << tot << endl;

}

int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
	int t_c = 1;
//	cin >> t_c;
	while (t_c--)
		solve();
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
	char input_str[256];
	size_t len;
	int max, cur;
	int i;

	fgets(input_str, sizeof(input_str), stdin);
	len = strlen(input_str);

	cur = 0;
	max = 0;
	for ( i = 0; i < len; i++ ) {
		if (input_str[i] == 'R') {
			cur++;
		}
		else {
			cur = 0;
		}
		max = (max < cur) ? cur : max;
	}

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

	return 0;
}


Measured memory_bytes: 1600
mininf = 0

def cumsum(inlist):
    s = 0
    outlist = []
    for i in inlist:
        s += i
        outlist.append(s)
    return outlist

def maxtohere(inlist):
    s = mininf
    outlist = []
    for i in inlist:
        s = max(s, i)
        outlist.append(s)
    return outlist

n, length = [int(v) for v in input().split()]
sushi = [[int(v) for v in input().split()] for i in range(n)]

diff_distance_from_left = [sushi[i][0] - sushi[i-1][0] if i > 0 else sushi[0][0] for i in range(n)]
diff_distance_from_right = [sushi[i+1][0] - sushi[i][0] if i < n-1 else length - sushi[i][0] for i in range(n-1,-1,-1)]
sushi_oneway_from_left = [sushi[i][1]-diff_distance_from_left[i] for i in range(n)]
sushi_oneway_from_right = [sushi[-i-1][1] - diff_distance_from_right[i] for i in range(n)]
sushi_roundtrip_from_left = [sushi[i][1]-diff_distance_from_left[i]*2 for i in range(n)]
sushi_roundtrip_from_right = [sushi[-i-1][1] - diff_distance_from_right[i]*2 for i in range(n)]

sum_of_sushi_oneway_from_left = cumsum(sushi_oneway_from_left)
sum_of_sushi_roundtrip_from_left = cumsum(sushi_roundtrip_from_left)
sum_of_sushi_oneway_from_right = cumsum(sushi_oneway_from_right)
sum_of_sushi_roundtrip_from_right = cumsum(sushi_roundtrip_from_right)

sum_of_sushi_oneway_from_left = maxtohere(sum_of_sushi_oneway_from_left)
sum_of_sushi_roundtrip_from_left = maxtohere(sum_of_sushi_roundtrip_from_left)
sum_of_sushi_oneway_from_right = maxtohere(sum_of_sushi_oneway_from_right)
sum_of_sushi_roundtrip_from_right = maxtohere(sum_of_sushi_roundtrip_from_right)

sum_of_sushi_from_left = sum_of_sushi_oneway_from_left
sum_of_sushi_from_right = sum_of_sushi_oneway_from_right
for i in range(n-1):
    sum_of_sushi_from_left[i] += sum_of_sushi_roundtrip_from_right[-2-i]
for i in range(n-1):
    sum_of_sushi_from_right[i] += sum_of_sushi_roundtrip_from_left[-2-i]

print(max(sum_of_sushi_from_left+sum_of_sushi_from_right))

Measured memory_bytes: 64788
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 87;
int a[N];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    int ans = INT_MAX;
    for (int i = 0; i + k - 1 < n; ++i) {
        int j = i + k - 1;
        if (a[i] <= 0 && 0 <= a[j]) {
            ans = min(ans, a[j] - a[i] + min(-a[i],a[j]));
        } else if (a[j] < 0) {
            ans = min(ans, -a[i]);
        } else {
            ans = min(ans, a[j]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N = int(input())
    D = list(map(int, input().split()))

    C = [0] * (max(D) + 1)
    for d in D:
        C[d] += 1
    # print(C)
    
    if D[0] != 0 or C[0] >= 2:
        print(0)
        return
    
    ans = 1
    for i in range(len(C) -1):
        for _ in range(C[i+1]):
            ans *= C[i]
            ans %= 998244353
    
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 78444
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
 
using namespace std;
 
 
int main(){
 
  int n,a[310][310];
  cin >> n;
  
  for(int i=0;i<n;i++){
  for(int j=0;j<n;j++)
    cin >> a[i][j];
     
  }
  
  bool b[310][310];
    
  long long int ans = 0;
 
  for (int k = 0; k < n; k++){       
    for (int i = 0; i < n; i++) {    
      for (int j = 0; j < n; j++) {  
        
      if( a[i][j] > a[i][k] + a[k][j]){
        cout << " -1" << endl;
        return 0;
      }
        
       if( a[i][j] == a[i][k] + a[k][j] && a[i][k] > 0 && a[k][j]>0){
         b[i][j] = true;
       }
        
      }
    }
  }
  
  for(int i=0;i<n;i++){
    for(int j=0;j<=i;j++){
      if( b[i][j] == false) ans += a[i][j];
    }
  }
  
 cout << ans << endl;
}


Measured memory_bytes: 768
using Yorukatsu039.Questions;
using Yorukatsu039.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu039.Questions
{
    /// <summary>
    /// ABC066 B
    /// </summary>
    public class QuestionB : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var s = inputStream.ReadLine();

            var max = 0;
            for (int i = 1; i * 2 < s.Length; i++)
            {
                if (s.Substring(0, i) == s.Substring(i, i))
                {
                    max = 2 * i;
                }
            }

            yield return max;
        }
    }
}


namespace Yorukatsu039
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionB();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu039.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu039.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int a,b;
cin >> a >> b;
if(a%2==0||b%2==0) {
  cout << "Even" <<endl;
  
} else {
  cout << "Odd" << endl;
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

namespace std {
	#define u(x, a, b) for(ll x = a; x < b; x++)
	#define d(x, a, b) for(ll x = a; x > b; x--)
}

typedef long long ll;
typedef long double ld;

#define MAXI 100010
#define MOD 1000000007

int main(){
	
	ll n;
	cin >> n;
	
	ll a[10010] = {0};
	
	u(one, 1, 101){
		u(two, 1, 101){
			u(three, 1, 101){
				ll x = (one*one) + (two*two) + (three*three) + (one*two) + (two*three) + (three*one);
				if(x<=10000){a[x]++;}
			}
		}
	}
	
	u(one, 1, n+1){
		cout << a[one] << endl;
	}
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
typedef long long int ll;
using namespace std;
ll n,tw;
ll w[105];
ll v[105];
ll dp[105][1000005];

ll go(ll p,ll wl)
{
if (p==1)
{
	if (w[1]>wl)
	return 0;
	else
	return v[1];
	}
	else if (dp[p][wl]!=-1)
	return dp[p][wl];
	else
	{
		ll x;
		if (w[p]<=wl)
		x=max((v[p]+go(p-1,wl-w[p])),go(p-1,wl));
		else
		x=go(p-1,wl);
		dp[p][wl]=x;
		return x;
		}	
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   
    cin>>n>>tw;
    for (int i=1;i<=n;i++)
    cin>>w[i]>>v[i];
    memset(dp,-1,sizeof(dp));
    cout<<go(n,tw);
}


Measured memory_bytes: 820608
from operator import itemgetter
n, m = map(int, input().split())
bridge = 0
ab = []
for _ in range(m):
  a, b = map(int, input().split())
  ab.append((a,b))
ab = sorted(ab, key=itemgetter(1))
count = 0
for a, b in ab:
  if not a <= bridge <= b:
    count += 1
    bridge = b-1
print(count)


Measured memory_bytes: 58072
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        scan.close();

        int input = n;
        List<Integer> primeList = new ArrayList<Integer>();
        for (int i = 2; i <= Math.sqrt(n); i++) {
            while (n % i == 0) {
                n /= i;
                primeList.add(i);
            }
        }
        if (n > 1) {
            primeList.add(n);
        }

        System.out.print(input + ":");
        for (int prime : primeList) {
            System.out.print(" ");
            System.out.print(prime);
        }
        System.out.println("");
    }

}



Measured memory_bytes: 26332
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#

"""
GC027 C
"""

n,m = map(int,input().split())
s = list(input())
edges = [tuple(map(int,input().split())) for i in range(m)]
ali = [0 for i in range(n)]
bli = [0 for i in range(n)]


def addEdge(graph,u,v):
    graph[u].add(v)


from collections import defaultdict
graphAB = defaultdict(set)

def incrementAB(node,adj):
    if s[adj-1] == 'A':
        ali[node-1]+=1
    if s[adj-1] == 'B':
        bli[node-1]+=1

def decrementAB(node,adj):
    if s[adj-1] == 'A':
        ali[node-1]-=1
    if s[adj-1] == 'B':
        bli[node-1]-=1

for i,j in edges:
    addEdge(graphAB,i,j)
    addEdge(graphAB,j,i)

def adjAB(node):
    if ali[node-1]!=0 and bli[node-1]!=0:
        return(True)
    else:
        return(False)

graphvers = set(graphAB.keys())
visitset = set()
for i in range(1,n+1):
    if not i in graphvers:
        s[i-1] = 'C'
    else:
        for j in graphAB[i]:
            incrementAB(i,j)
        if not adjAB(i):
            visitset.add(i)


while bool(visitset):
    #print(graphAB)
    #print(graphABopp)
    #print(abli)
    i = visitset.pop()
    for j in graphAB[i]:
        if s[j-1] != 'C':
            decrementAB(j,i)
            if not adjAB(j):
                visitset.add(j)
    s[i-1] = 'C'

#print(graphAB)
#print(graphABopp)

sset= set(s)
sset.add('C')
sset.remove('C')
if bool(sset):
    print('Yes')
else:
    print('No')





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

public class MainClass
{
	public static void Main(string[] args)
	{
		string input = Console.ReadLine();
		int k = 0;
		bool[] d = new bool[input.Length];
		for(int i = 0; i < input.Length; i++)
		{
			d[i]=input[i]=='0';
		}
		for(int i = 0; i < d.Length-1; i++)
		{
			if(d[i]!=d[i+1])
				continue;
			d[i] = !d[i];
			d[i+1] = !d[i+1];
			k++;
			
		}
		Console.WriteLine(k);
	}

	public static int Clamp(int val, int max, int min = 0)
	{
		return Math.Min(max, Math.Max(min, val));
	}


}

Measured memory_bytes: 13144
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define All(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main() {
  Cin(int, a, b);

  int tap = 0;
  int ans = 1;

  while (true) {
    if (ans >= b) break;
    tap++;
    ans += a - 1;
  }
  cout << tap << endl;
}

int main() {
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
n = int(input())
an = [int(num) for num in input().split()]

one,two,four = 0, 0, 0
for a in an:
  if a%4 == 0:
    four += 1
  elif a%2 == 0:
    two += 1
  else :
    one += 1
    
if two == 0 and four >= one - 1 :
  print("Yes")
elif four >= one :
  print("Yes")
else :
  print("No")

Measured memory_bytes: 20052
import java.util.Scanner;

public class Main{
    public static Scanner scan  = new Scanner(System.in);
    public static void main(String[]args){
        int n = nextInt();
        if(n%1000==0){
            print(0);
            System.exit(0);
        }
        print(1000-n%1000);
    }

    public static int nextInt(){
        return Integer.parseInt(scan.next());
    }
    public static long nextLong(){
        return Long.parseLong(scan.next());
    }
    public static String next(){
        return scan.next();
    }
    public static double nextDouble(){
        return Double.parseDouble(scan.next());
    }
    public static float nextFloat(){
        return Float.parseFloat(scan.next());
    }

    //Yes or No
    public static void yesNo(boolean flag){
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    }

    //print
    public static void print(Object a){
        System.out.println(a);
    }


    //gcd
    public static int gcd (int a, int b){
        int tmp;
        while((tmp = a%b) != 0){
            a = b;
            b = tmp;
        }
        return b;
    }


    //lcm
    public static int lcm(int a,int b){
        int tmp;
        long c = a;
        c *= b;
        while((tmp = a%b) != 0){
            a = b;
            b = tmp;
        }
        return (int)(c/b);
    }
}

Measured memory_bytes: 35604
#include <stdio.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
int f[50];

void fi(int a) {
  f[a] = f[a - 2] + f[a - 1];
}

int main(void) {
  int n;
  scanf("%d", &n);
  rep(i, 50) f[i] = 0;
  f[0] = 1, f[1] = 1;
  for(int i = 2; i < 50; ++i) fi(i);
  printf("%d\n", f[n]);
  return 0;
}


Measured memory_bytes: 2724
#include <iostream>                                                     
using namespace std;                                                    
                                                                        
int main(void) {                                                        
  int x, y;                                                             
  while (true) {                                                        
    cin >> x >> y;                                                      
    if (x==0 && y==0) {                                                 
      break;                                                            
    }                                                                   
    int maxxy = max(x,y);                                               
    int minxy = min(x,y);                                               
    cout << minxy << " " << maxxy << endl;                              
  }                                                                     
  return 0;                                                             
}                                                                       
                                         

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

int main(){
  int N; cin >> N;
  string P;
  for(int i = 0; i < N; i++){
    int x;cin >> x;
    P += x;
  }
  string Q;
  for(int i = 0; i < N; i++){
    int x;cin >> x;
    Q += x;
  }
  string P1 = P;
  string Q1 = Q;
  sort(P1.begin(), P1.end());
  sort(Q1.begin(), Q1.end());
  int a = 0, b = 0, ansa, ansb;
  do{
    a++;
    if(P == P1)ansa = a;
  }while(next_permutation(P1.begin(), P1.end()));
  do{
    b++;
    if(Q == Q1)ansb = b;
  }while(next_permutation(Q1.begin(), Q1.end()));
  cout << abs(ansa- ansb) << endl;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

template<class T, class U>
istream& operator >> (istream&is, P<T,U>&p){
  is >> p.first >> p.second;
  return is;
}

int main(){
  string s,t; cin >> s >> t;
  cout << t << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

const int inf=1e9+10;

int main(){
	int n,m;
	cin>>n>>m;
	cout<<(n==m?"Yes":"No")<<endl; 
	return 0;
}


Measured memory_bytes: 256
/*
 * b.cc: 
 */
 
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;
 
/* constant */
 
/* typedef */
 
typedef vector<int> vi;
 
struct Node {
  int key;
  struct Node *l, *r;
  Node(): l(NULL), r(NULL) {}
  Node(int _k): key(_k), l(NULL), r(NULL) {}
};
 
/* global variables */
 
/* subroutines */
 
void insert(Node *(&root), Node *z) {
  Node *y = NULL, *x = root;
 
  while (x != NULL) {
    y = x;
    if (z->key < x->key) x = x->l;
    else x = x->r;
  }
 
  if (y == NULL) root = z;
  else if (z->key < y->key) y->l = z;
  else y->r = z;
}
 
bool find(Node *root, int key) {
  Node *x = root;
 
  while (x != NULL) {
    if (key == x->key) return true;
    x = (key < x->key) ? x->l : x->r;
  }
  return false;
}
 
void inorder(Node *nd, vi &v) {
  if (nd != NULL) {
    inorder(nd->l, v);
    v.push_back(nd->key);
    inorder(nd->r, v);
  }
}
 
void preorder(Node *nd, vi &v) {
  if (nd != NULL) {
    v.push_back(nd->key);
    preorder(nd->l, v);
    preorder(nd->r, v);
  }
}
 
void print_vec(vi &v) {
  for (int i = 0; i < v.size(); i++) printf(" %d", v[i]);
  putchar('\n');
}
 
/* main */
 
int main() {
  Node *root = NULL;
 
  int m;
  cin >> m;
 
  while (m--) {
    string op;
    cin >> op;
 
    if (op[0] == 'i') {
      int key;
      cin >> key;
      insert(root, new Node(key));
    }
    else if (op[0] == 'f') {
      int key;
      cin >> key;
      cout << (find(root, key) ? "yes" : "no") << endl;
    }
    else {
      vi v;
 
      v.clear();
      inorder(root, v);
      print_vec(v);
 
      v.clear();
      preorder(root, v);
      print_vec(v);
    }
  }
  return 0;
}







Measured memory_bytes: 17368
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ps push_back
#define fi first
#define so second
signed main()
{
   int n,i,j;
   cin>>n;
   string s;
   cin>>s;
   if(n%2) cout<<"No";
   else
   {
       int f=0;
       for(i=0;i<n/2;i++) if(s[i]!=s[i+n/2]) {f=1;break;}
       if(f==0) cout<<"Yes";
       else cout<<"No"
;   }
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  vector<int64_t> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  sort(H.begin(), H.end(), greater<int64_t>());
  int64_t res = 0;
  for (int i = K; i < N; i++) {
    res += H[i];
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(){
  int n,a=1;
  cin >> n;
  if(n==1) cout << 1<<endl;
  else{
    while(1){
    a*=2;
    if(a>n) {
      a/=2;
      break;
    }
    if(a==n) break;
  }
  cout <<a<<endl;
}
}


Measured memory_bytes: 256
using System;

class Aizu
{
    public static void Main()
    {
        int n = 10;
        int[] mts = new int[n];
        for(int i = 0; i < n;i++)
        {
            mts[i] = int.Parse(Console.ReadLine());
        }
        Array.Sort(mts);
        Array.Reverse(mts);
        for(int i = 0; i < 3;i++)
        {
            Console.WriteLine(mts[i]);
        }
    }
}


Measured memory_bytes: 15976
while ((n,x = gets.split(" ").map(&:to_i)).inject(:+) != 0) do
  max = 3*(n-1)
  if !((6..max).include?(x))
    puts 0
    next
  end
  r = []
  n.downto(1) do |n1|
    (n1-1).downto(1) do |n2|
      (n2-1).downto(1) do |n3|
        r<<[n1,n2,n3] if ((n1 + n2 + n3) == x)
      end
    end
  end
  puts r.length
end

Measured memory_bytes: 8828
use std::cmp::min;

#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, a, b) = scan!(usize, usize, usize);
    let vs = scan!(usize;;);
    let mut ans = 0;
    for (v0, v1) in vs.iter().zip(vs[1..].iter()) {
        let walk = (v1 - v0) * a;
        ans += min(walk, b)
    }
    println!("{}", ans)
}


Measured memory_bytes: 6396
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{

    class Program
    {
        private const long COMDIV = 1000000007;

        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            int ret = 0;
            SortedDictionary<int,int> items = new SortedDictionary<int, int>();
            for (int i = 0; i < N; i++)
            {
                var tmp = Console.ReadLine().Split().Select(int.Parse).ToArray();
                items.Add(tmp[0],tmp[1]);
            }

            Console.WriteLine(items.Last().Key + items.Last().Value);
        }
    }
}

Measured memory_bytes: 49848
#include <iostream>
using namespace std;
bool under(int b, int r)
{
	return (b - r < 0) ? true : false;
}
bool over(int b, int r,int m)
{
	return (b + r > m) ? true : false;
}
bool error(int w, int h, int x, int y, int r)
{
	if (under(x, r)) return true;
	if (under(y, r))  return true;
	if (over(x, r, w))  return true;
	if (over(y, r, h))  return true;
	return false;

}
int main()
{
	int w,h,x,y,r;
	cin >> w>>h>>x>>y>>r;
	if (error(w, h, x, y, r)) cout << "No" << endl;
	else  cout << "Yes" << endl;
	return 0;

}

Measured memory_bytes: 3092
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Console;

namespace AtCoder_1
{
    class Program
    {
        static void Main(string[] args)
        {
            var t = CinTAr();
            if(t[0] <= 5)
            {
                Cout(0);
            }else if(t[0] <= 12)
            {
                Cout(t[1] / 2);
            }
            else
            {
                Cout(t[1]);
            }
            Cin();
        }



        static readonly int MOD1E9 = (int)1e9 + 7;
        static string Cin() { return ReadLine(); }
        static string[] CinAr() { return ReadLine().Split(' '); }
        static int CinT() { return S2i(Cin()); }
        static int[] CinTAr() { return CinAr().Select((x, i) => { return S2i(x); }).ToArray(); }
        static long CinL() { return S2L(Cin()); }
        static long[] CinLAr() { return CinAr().Select((x, i) => { return S2L(x); }).ToArray(); }
        static double CinD() { return S2D(Cin()); }
        static double[] CinDAr() { return CinAr().Select((x, i) => { return S2D(x); }).ToArray(); }
        static int S2i(string s) { return int.Parse(s); }
        static long S2L(string s) { return long.Parse(s); }
        static double S2D(string s) { return double.Parse(s); }
        static void OYes() { Cout("Yes"); }
        static void ONo() { Cout("No"); }
        static void Cout(object s) { WriteLine(s); }
        static int[] yakusuu(int n)
        {
            if (n == 1) { return new int[] { 1 }; }
            HashSet<int> res = new HashSet<int>();
            for (int i = 1; i < Math.Ceiling(n / 2.0); i++)
            {
                if (n % i == 0)
                {
                    res.Add(i);
                    res.Add(n / i);
                }
            }
            return res.ToArray();
        }
        /// <summary>
        /// Debug時のみの使用を推奨
        /// </summary>
        /// <typeparam name="Type"></typeparam>
        /// <param name="types"></param>
        static void CoutAr<Type>(IEnumerable<Type> types)
        {
            string text = "";
            foreach (var i in types)
            {
                text += " " + i;
            }
            WriteLine(text.Substring(1));
        }
    }
}


Measured memory_bytes: 13268
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

ll ans = 0;

int main(void){
	int n; cin >> n;
	ans = (n/2);
	if(n%2 == 1) ans++;
	

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
S = str(input())

if S[K-1] == 'A':
  S= S[:K-1] + 'a' + S[K:]
elif S[K-1] == 'B':
  S= S[:K-1] + 'b' + S[K:]
elif S[K-1] == 'C':
  S= S[:K-1] + 'c' + S[K:]

print(S)

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<string>
#include <algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<set>
using namespace std;
using ll = long long;


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

		if (n - 999 <= 0) {
			cout << "ABC" << endl;
			return 0;
		}

		cout << "ABD" << endl;
		return 0;
	}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int i, j, loop, arr[4][13];
    char mk;
    int num;

    for(i = 0; i < 4; i++){
        for(j = 0; j < 13; j++){
            arr[i][j] = 0;
        }
    }

    scanf("%d", &loop);

    for(i = 0; i < loop; i++){
        getchar();
        scanf("%c %d", &mk, &num);
        
        switch(mk){
            case 'S':
                arr[0][num - 1] = 1;
                break;
            case 'H':
                arr[1][num - 1] = 1;
                break;
            case 'C':
                arr[2][num - 1] = 1;
                break;
            case 'D':
                arr[3][num - 1] = 1;
                break;
        }
    }

    char mark[4] = {'S', 'H', 'C', 'D'};
    for(i = 0; i < 4; i++){
        for(j = 0; j < 13; j++){
            if(!arr[i][j]){
                printf("%c %d\n", mark[i], j + 1);
            }
        }
    }
}


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

int n, k;
int a[100005][3];
int dp[100005][3];

void solve(){
	for (int i = 1; i <= n; i++){
		for (int j = 0; j < 3; j++){
			dp[i][j] = 0;
			for (int k = 0; k < 3; k++){
				if (k == j) continue;
				dp[i][j] = max(dp[i][j], dp[i-1][k]);
			}
			dp[i][j] += a[i][j];
		}
	}
	int mx = -1;
	for (int j = 0; j < 3; j++)
		mx = max(mx, dp[n][j]);
	cout << mx << '\n';
}
int main(){
	cin >> n;
	for (int i = 1; i <= n; i++)
		for (int j = 0; j < 3; j++)
			cin >> a[i][j];
	solve();
	return 0;
}


Measured memory_bytes: 2688