akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int H,W,M;
    cin >> H >> W >> M;
    map<P,int>Mp;
    vector<P>tate(H),yoko(W);
    vector<int>h(M),w(M);
    for(int i = 0; i < M; i++) {
        cin >> h[i] >> w[i];
        h[i]--;w[i]--;
        Mp[{h[i],w[i]}]++;
        tate[h[i]].first++;
        yoko[w[i]].first++;
    }
    for(int i = 0; i < H; i++) {
        tate[i].second = i;
    }
    for(int i = 0; i < W; i++) {
        yoko[i].second = i;
    }
    sort(tate.rbegin(),tate.rend());
    sort(yoko.rbegin(),yoko.rend());
    int ans = 0;
    int h2 = H-1,w2 = W-1;
    for(int i = 1; i < H; i++) {
        if(tate[i].first < tate[i-1].first) {
            h2 = i-1;
            break;
        }
    }
    for(int i = 1; i < W; i++) {
        if(yoko[i].first < yoko[i-1].first) {
            w2 = i-1;
            break;
        }
    }
    for(int i = 0; i <= h2; i++) {
        for(int j = 0; j <= w2; j++) {
            if(!Mp.count({tate[i].second,yoko[j].second})) {
                ans = max(ans,tate[i].first+yoko[j].first);
                cout << ans << endl;
                return 0;
            }
            else {
                ans = max(ans,tate[i].first+yoko[j].first-1);
            }
        }
    }
    cout << ans << endl;
}


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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define X first
#define Y second

struct Q {
    vector<pii> q;

    void rotate() {
        REP(i, SZ(q)) {
            q[i] = {-q[i].Y, q[i].X};
        }
    }

    void adjust() {
        int dx = q[0].X, dy = q[0].Y;
        q[0].X = 0;
        q[0].Y = 0;
        FOR(i, 1, SZ(q)) {
            q[i].X -= dx;
            q[i].Y -= dy;
        }
    }

    bool eq(vector<pii>& r) {
        if (SZ(q) != SZ(r)) return false;
        REP(i, SZ(q)) {
            if (q[i].X == r[i].X && q[i].Y == r[i].Y) {
            } else {
                return false;
            }
        }
        return true;
    }
};

int main() {
    int N;
    while (cin >> N, N) {
        vector<Q> p(N+1);
        REP(i, N+1) {
            int M;
            cin >> M;
            REP(j, M) {
                int x, y;
                cin >> x >> y;
                p[i].q.push_back({x, y});
            }
        }
        p[0].adjust();
        FOR(i, 1, N+1) {
            REP(j, 4) {
                p[i].adjust();
                if (p[i].eq(p[0].q)) {
                    cout << i << endl;
                    break;
                }
                reverse(ALL(p[i].q));
                p[i].adjust();
                if (p[i].eq(p[0].q)) {
                    cout << i << endl;
                    break;
                }
                p[i].rotate();
            }
        }
        cout << "+++++" << endl;
    }
}

Measured memory_bytes: 3044
#include <iostream>
#define N_MAX 300000
using namespace std;

int main(){
  int N,i,ans,cnt;
  int d[N_MAX]={0};
  char c;
  cin >> N;
  for(i=0;i<N;i++){
      cin >> c;
      switch(c){
        case 'E':d[i]=1;break;
        case 'W':d[i]=-1;break;
      }
  }
//1番目がリーダーの時の人数  
  cnt=0;
  for(i=1;i<N;i++){
    if(d[i]==1){cnt++;}
  }
  ans=cnt;
  for(i=1;i<N;i++){
    if(d[i-1]==-1){cnt++;}
    if(d[i]==1){cnt--;}
    if(ans>cnt){ans=cnt;}
  }
  cout << ans <<endl;
  return 0;
}

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

typedef long long ll;

const ll mod = 1000000007;
const int INF = 101234567;

int main() {
    int n, m;
    cin >> n >> m;
    
    map<int, vector<int>>p;
    map<int, int>post;

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        p[a].push_back(b);
        p[b].push_back(a);
    }

    queue<int>que;
    post[1] = 0;
    que.push(1);

    while (!que.empty()) {
        int cur = que.front();
        que.pop();

        for (const int& node : p[cur]) {
            if (post.count(node)) continue;
            post[node] = cur;
            que.push(node);
        }
    }

    if (post.size() != n) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
        for (int i = 2; i <= n; i++) {
            cout << post[i] << endl;
        }
    }
}


Measured memory_bytes: 20064
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
constexpr int MAX = 10000;
lint fact[MAX], finv[MAX], inv[MAX];
void cominit() {
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  FOR(i, 2, MAX){
    fact[i] = fact[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}
lint power(lint x, lint n, lint mod) {
  lint ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return ret;
}
lint ncr(lint n, lint r, lint mod) {
  if(n < 0 || r < 0 || n-r < 0) return 0;
  return fact[n]*finv[r]%mod*finv[n-r]%mod;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint S;
  cin >> S;
  lint ans = 0;
  cominit();
  FOR(i, 1, S+1) {
    lint a = S - i*3;
    if(a < 0) continue;
    ans = (ans + ncr(a+i-1, i-1, MOD)) % MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3884
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define cpresent(c,x) ((c).find(x) != (c).end()) 
#define vpresent(c,x) (find(all(c),x) != (c).end())
#define endl '\n'
#ifdef LOCAL
#include "/home/iggaboi/Desktop/CP/debug.h"
#else
#define debug(Args...)
#endif
using ll = long long;
using namespace __gnu_pbds;
using namespace std;
template<class T>
using indexed_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;

void shit() {
	ll a, b, x; cin >> a >> b >> x;
    cout << b/x - (a - 1ll)/x + (a == 0ll && x != 1ll ? 1ll : 0ll)<< endl;
}

int32_t main() {
	ios_base::sync_with_stdio(false),cin.tie(nullptr);
	// int t; cin >> t;
	// while(t--)
		shit();
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;

int main(){
    int x, n;
    cin>>x >>n;
    
    if(n==0){
        cout << x << endl;
        return 0;
    }
    
    vi q(102,1);
    int a;
    rep(i,n){
        cin>>a;
        q[a]=0;
    }
    
    for(int j=0; j<102; j++){
        if(x-j>=0 && q[x-j]){
            cout << x-j << endl;
            return 0;
        }
        if(x+j<102 && q[x+j]){
            cout << x+j << endl;
            return 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;


int main(){
    ll N;
    cin >> N;
    ll M;
    cin >> M;   
    ll L;
    cin >> L;
    vector<ll> A(M,0);
    vector<ll> B(M,0);
    vector<ll> C(M,0);
    for(ll i=0;i<M;i++){
        cin>>A[i]>>B[i]>>C[i]
    ;}
    ll Q;
    cin >> Q;
    vector<ll> s(Q,0);
    vector<ll> t(Q,0);
    for(ll i=0;i<Q;i++){
        cin>>s[i]>>t[i]
    ;}
    vector<vector<ll>> d(N+1, vector<ll>(N+1, INF));
    for(ll i=0;i<N;i++){
        d[i+1][i+1]=0
    ;}
    for(ll i=0;i<M;i++){
        d[A[i]][B[i]]=C[i];
        d[B[i]][A[i]]=C[i];
    ;}
    for(ll i=1;i<=N;i++){
     for(ll j=1;j<=N;j++){
         for(ll k=1;k<=N;k++){
             d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
         ;}
     ;}
    ;}
    vector<vector<ll>> d2(N+1, vector<ll>(N+1, INF));
    for(ll i=0;i<N;i++){
        d2[i+1][i+1]=0
    ;}
    for(ll i=1;i<=N;i++){
     for(ll j=1;j<=N;j++){
         if(d[i][j]<=L){
             d2[i][j]=1;
         }
     ;}
    ;}
    for(ll i=1;i<=N;i++){
     for(ll j=1;j<=N;j++){
         for(ll k=1;k<=N;k++){
             d2[j][k]=min(d2[j][k],d2[j][i]+d2[i][k]);
         ;}
     ;}
    ;}
    for(ll i=0;i<Q;i++){
        if(d2[s[i]][t[i]]==INF){cout<<-1<<endl;continue;}
        cout<<d2[s[i]][t[i]]-1<<endl;
    ;}


    return 0;
}


Measured memory_bytes: 4352
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <unordered_map>
#include <numeric>
#define INFI LLONG_MAX
using namespace std;
//#include<bits/stdc++.h>
#include <map>
long long int g=998244353;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    long int x;cin>>x;long int cnt=1;
    long int u=x;
    while(u%360!=0)
    {
        cnt++;
        u+=x;
    }
    cout<<cnt<<'\n';
    
}


Measured memory_bytes: 3596
function myout(text){console.log(text);}//standard output
function Main(input) {
	input = input.trim();
	//input = parseInt(input.trim());
	//input = input.trim().split(" ");
	input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  var N = parseInt(input[0].split(" ")[0]);
  var K = parseInt(input[0].split(" ")[1]);
  var Q = parseInt(input[0].split(" ")[2]);
  input.shift();
  input = input.map((a)=>Number(a));
  var pointList = new Array(N);
  pointList.fill(0);
  for(var i = 0; i < input.length; i++){
    pointList[input[i] - 1]++;
  }
  for(var i = 0; i < pointList.length; i++){
    if(Q - pointList[i] < K){
       myout("Yes");
       }else{
       myout("No");
       }
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;

int main()
{
	set<string> str;

	int n;
	cin >> n;

	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		str.insert(s);
	}
	cout << str.size() << endl;
}

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

int main() {
	pair<int, int> p[200001];
	int n, idx=0;
	long long now=0;
	cin>>n; for(int i=0;i<n;i++){
		int a, b; cin>>a>>b;
		p[i]=make_pair(b,a);
	}
	sort(p,p+n);
	while(idx<n){
		now+=p[idx].second;
		if(now>p[idx].first) break;
		idx++;
	}
	if(idx==n) cout<<"Yes";
	else cout<<"No";
	
	return 0;
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

ll a,b,c,d;

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

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> a >> b >> c >> d;
  a--;

  ll g = gcd(c,d);
  ll v1 = b / c + b / d - b / (c*d/g);
  ll v2 = a / c + a / d - a / (c*d/g);

  cout << (b-a) - (v1-v2) << endl;

  return 0;
}


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

using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.rbegin(), a.rend());
    ll ans = a[0];
    int j = 1;
    for (int i = 2; i < n; i++) {
        if (i < n) {
            ans += a[j];
            i++;
        }
        if (i < n) {
            ans += a[j];
        }
        j++;
    } 
    cout << ans;
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

ll t , x;

int main()
{
    _FastIO;
    cout.precision(10);
    cin >> t >> x;
    long double ans = t * 1.0 / x * 1.0;
    cout << fixed << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<string>

using namespace std;

int main(){
    int N;
    int ans=10000000,sum=0,left=0;
    int a;
    cin >> N;
    vector<int> W(N);
    for(int i = 0; i < N; i++){
        cin >> W[i];
        sum += W[i];
    }
    for(int i = 0; i < N; i++){
        left += W[i];
        sum -= W[i];
        a = abs(left - sum);
        // cout << a << endl;
        ans = min(ans, a);
    }
    cout << ans << endl;




}

Measured memory_bytes: 888
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

#define REP(i, n) for(int i=0; i<(n); i++)
#define REPS(i, n) for(int i=0; i<=(n); i++)
#define FOR(i, a, b) for(int i=a; i<(b); i++)
#define FORS(i, a, b) for(int i=a; i<=(b); i++)
// for container x
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define LB(v, x) distance((v).begin(), lower_bound(ALL(v), (x)))
#define UB(v, x) distance((v).begin(), upper_bound(ALL(v), (x)))

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#pragma endregion

bool is_ok(vector<string> c, int k) {
    int cnt = 0;
    REP(i, c.size()){
        cnt+=count(ALL(c[i]), '#');   
    }
    if (cnt==k) return true;
    else return false;
}
void display_map(vector<string> c){
    REP(i, c.size()){
        cout << c[i] << endl;
    }
}

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    // vector<vector<string>> c(h, vector<string>());
    vector<string> c(h);
    REP(i, h) cin >> c[i];
    int ans = 0;
    for (int i=0; i < (1 << h); i++){
        for (int j=0; j < (1 << w); j++) {
            vector<string> ccopy(h);
            copy(ALL(c), ccopy.begin());
            REP(veci, h) if (i & (1 << veci)) REP(vecj, w) ccopy[veci][vecj]='0';
            REP(vecj, w) if (j & (1 << vecj)) REP(veci, h) ccopy[veci][vecj]='0';
            // display_map(ccopy);
            // cout << "next" << endl;
            if (is_ok(ccopy, k)) ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3536
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		for(int i = 0; i < N; i++){
			int K = sc.nextInt();
			int P = sc.nextInt();
			if(K < P)
				System.out.println(K);
			else if(K%P == 0)
				System.out.println(P);
			else
				System.out.println(K%P);
		}
	}
}

Measured memory_bytes: 20376
using System;
using System.Collections.Generic;

namespace ALDS1_11D{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            var N = sr.Next<int>();

            var g = new List<int>[N];
            for(var i = 0; i < N; i++){
                g[i] = new List<int>();
            }

            var M = sr.Next<int>();
            for(var i = 0; i < M; i++){
                var S = sr.Next<int>();
                var T = sr.Next<int>();
                g[S].Add(T);
                g[T].Add(S);
            }

            var cnt = 0;
            var color = new int[N];

            Action<int> bfs = x =>{
                if(color[x] != 0) return;
                var que = new Queue<int>();
                color[x] = ++cnt;
                que.Enqueue(x);

                while(que.Count > 0){
                    var now = que.Dequeue();
                    foreach(var next in g[now]){
                        if(color[next] != 0) continue;

                        color[next] = cnt;
                        que.Enqueue(next);
                    }
                }
            };

            for(var i = 0; i < N; i++) bfs(i);

            var Q = sr.Next<int>();
            for(var i = 0; i < Q; i++){
                var S = sr.Next<int>();
                var T = sr.Next<int>();
                Console.WriteLine(color[S] == color[T] ? "yes" : "no");
            }
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = Console.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }
    }
}

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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vli;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define I cin
#define O cout
#define EN endl
#define ln cout<<endl
#define pb(a) push_back(a)
#define x first
#define y second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
  return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
  return a / gcd(a, b) * b;
}

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

int n;
int a[101];
int ans = 0;
int memo[101][10001];

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

  if(val % 10) ans = max(ans, val);
  
  return memo[idx][val] = ans;
}

int main()
{
  I >> n;

  for(int i = 0; i < n; i++) I >> a[i];

  memset(memo, -1, sizeof(memo));
  
  O << dfs(0, 0) << EN;
  
  return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define ll long long int
#define PI 3.14159265359
using namespace std;

int main()
{
    ll ans;
    string str;
    cin >> str;
    if(str == "AAA" || str == "BBB") cout << "No" << endl;
    else cout << "Yes" << endl;


    return 0;
}

Measured memory_bytes: 764
<?php
 $a=trim(fgets(STDIN));
$aArray = explode(" ",trim(fgets(STDIN)));
$vArray = explode(" ",trim(fgets(STDIN)));
     $B=0;
for($i=0;$i<$a;$i++){
     $B +=max($aArray[$i]-$vArray[$i],0);}
      echo $B;
 ?>

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


int main() {
	int n;

	cin >> n;
	int count = 0;


	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a - 1 == count) {
			count++;
		}
	}
	if (count == 0) {
		cout << -1 << endl;
	} else {
		cout <<  n - count << endl;
	}
	return 0;
}

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

typedef long long ll;
typedef long double ld;

const int N=5e5+10;



int main(){
    //freopen("a.txt", "r", stdin);
    //freopen("answers.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin>>s;
    if((s[0]==s[1] && s[1]==s[2])||(s[1]==s[2] && s[2]==s[3]))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;




    return 0;

}

Measured memory_bytes: 256
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
check = [[False] * W for _ in range(H)]
now_flag = True     # True : Even, False : Odd
past_flag = True
ans = 0
ans_list = []
for h in range(H):
    if h % 2 == 0:
        for w in range(W):
            past_flag = now_flag
            now_flag = True if A[h][w] % 2 == 0 else False
            if not past_flag:      # odd
                now_flag = False if now_flag else True     # now is odd -> next is even
                ans += 1
                if h != 0 and w == 0:
                    ans_list.append([h, w+1, h+1, w+1])
                else:
                    ans_list.append([h+1, w, h+1, w+1])
    if h % 2 == 1:
        for w in range(W-1, -1, -1):
            past_flag = now_flag
            now_flag = True if A[h][w] % 2 == 0 else False
            if not past_flag:
                now_flag = False if now_flag else True
                ans += 1
                if h != 0 and w == W-1:
                    ans_list.append([h, w+1, h+1, w+1])
                else:
                    ans_list.append([h+1, w+2, h+1, w+1])

print(ans)
for a in ans_list:
    print(*a)
            

Measured memory_bytes: 32272
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
enum MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    auto T = sread();
    long N = T.length;
    auto ans = new char[](N);
    foreach (i; 0 .. N)
    {
        ans[i] = T[i];
        if (T[i] == '?')
        {
            if (0 < i && ans[i - 1] == 'P')
            {
                ans[i] = 'D';
                continue;
            }
            if (i < N - 1 && T[i + 1] == 'D')
            {
                ans[i] = 'P';
                continue;
            }
            if (i < N - 1 && T[i + 1] == '?')
            {
                ans[i] = 'P';
                continue;
            }
            ans[i] = 'D';
        }
    }
    writeln(ans);
}


Measured memory_bytes: 3904
//git pull --rebase origin master
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define wi(t) int t;cin>>t;while(t--)
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];
ll int gcd(ll int a, ll int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
int tc=1;
void solve()
    { 
        int n;
        cin>>n;
        int ans=0;
        bool f=false;
        while(n--)
        {
            int x,y;
            cin>>x>>y;
            if(x==y) {ans++;if(ans>=3) f=true;}
            else ans=0;
            
        }
        if(f) cout<<"Yes";
        else
        {
            cout<<"No";
        }
        
    }

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

   // wi(t)
    {
      solve();
    }

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
    int i, u, v;
    while(m--){
        cin>>u>>v;
    u--, v--;
        g[u].pb(v);
        g[v].pb(u);
    }
}

void dfs(int u, int par){
    for(int v:g[u]){
        if (v == par) continue;
        dfs(v, u);
    }
}







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

int main(){
  int N;
  cin>>N;
  int p[5000];
  for(int i=0;i<N;i++){
    cin>>p[i];
  }
  int min_sum=20000;
  for(int I=0;I<=p[0];I++){
    int q[5000];
    for(int i=0;i<N;i++){
      q[i]=p[i];
    }
    int sum=I;
    q[0] -= I;
    for(int i=0;i<=N-2;i++){
      if(q[i]<=0)continue;
      sum+=q[i]*2;
      q[i+1] -= q[i];
    }
    if(q[N-1]>0){
      sum+=q[N-1];
    }
    min_sum=min(min_sum,sum);
  }
  cout<<min_sum<<endl;
}



Measured memory_bytes: 3168
#include<iostream>
#include<unordered_map>
using namespace std;
int main()
{
  unordered_map<string,int>um;
  int n;
  cin>>n;
  string s;
  for(int i=0;i<n;i++)
  {
    cin>>s;
    um[s]++;
  }
  cout<<"AC"<<" x "<<um["AC"]<<endl;
  cout<<"WA"<<" x "<<um["WA"]<<endl;
  cout<<"TLE"<<" x "<<um["TLE"]<<endl;
  cout<<"RE"<<" x "<<um["RE"];
}

Measured memory_bytes: 3616
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<
//ll,
//null_type,
//less<int>,
//rb_tree_tag,
//tree_order_statistics_node_update>
//ordered_set;
//struct Node
//{
//    ll pos, val, color;
//    bool operator<( const Node &A) const
//    {
//        return A.val > val;
//    }
//};

string s, ss, str;
int main()
{
    ll n, m, t, k, a, ans = 0, b;
    cin>>n>>a>>b;
    if( a > b ) swap( a, b );

    ll x = n - a + n - b;
    ll y = a + b - 2;
    if( (b - a)%2 == 0 ) cout<<(b - a)/2<<"\n";
    else cout<<min( x / 2 + x % 2, y / 2 + y % 2 )<<"\n";
    return 0;
}


Measured memory_bytes: 256
/**
 * File    : B.cpp
 * Author  : Kazune Takahashi
 * Created : 1/20/2019, 9:01:34 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

ll s;
ll a[1000010];
set<ll> S;

ll f(ll n)
{
  if (n % 2 == 0)
  {
    return n / 2;
  }
  else
  {
    return 3 * n + 1;
  }
}

int main()
{
  cin >> s;
  a[0] = s;
  for (auto i = 0; i < 1000010 - 1; i++)
  {
    if (S.find(a[i]) == S.end())
    {
      S.insert(a[i]);
      a[i + 1] = f(a[i]);
    }
    else
    {
      cout << i + 1 << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
import sys 
from collections import deque
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())
def LS(): return list(sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def Main():
    a,b,c,k = IL()
    ta = min(k,a)
    tb = min(k-ta,b)
    if tb<0:    tb = 0
    tc = k-ta-tb
    print(ta-tc)
    return

if __name__=='__main__':
    Main()

Measured memory_bytes: 9476
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits.h>

using std::cin;
using std::cout;
using std::endl;
using std::vector;

int min_diff(const vector<int>& ws) {
  int sum1 = 0;
  int sum2 = 0;
  int min_abs_diff = INT_MAX;
  for (int w : ws) {
    sum1 += w;
  }
  for (int w : ws) {
    sum2 += w;
    sum1 -= w;
    int abs_diff = std::abs(sum1 - sum2);
    if (abs_diff < min_abs_diff) {
      min_abs_diff = abs_diff;
    }
  }
  return min_abs_diff;
}

int main(int argc, char* argv[]) {
  int n;
  cin >> n;
  std::vector<int> ws(n);
  for (int i = 0; i < n; ++i) {
    cin >> ws[i];
  }
  cout << min_diff(ws);
  return 0;
}


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

using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll (i) = 0; i < n; i++)
#define FORN(i, a, b) for (ll (i) = a; i < b; i++)
#define FORE(i, l) for (auto (i) : l)

#define pb push_back
#define pob pop_back
#define emp emplace

#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    ll n;
    cin >> n;
    vll p(n);
    FOR(i, n) cin >> p[i];
    vll q(n);
    FOR(i, n) cin >> q[i];
    ll a = 0, b = 0;
    vll thing(n);
    FOR(i, n) thing[i] = i + 1;
    do
    {
        if (p == thing) break;
        a++;
    } while (next_permutation(thing.begin(), thing.end()));
    FOR(i, n) thing[i] = i + 1;
    do
    {
        if (q == thing) break;
        b++;
    } while (next_permutation(thing.begin(), thing.end()));
    cout << abs(a - b) << '\n';
}



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

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

    // 確率pの事象が成功するまでの回数の期待値は1/p回
    int ans = pow(2, M) * (1900 * M + 100 * (N - M));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

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

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

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int a,b,c,d;
  cin>>a>>b>>c>>d;

  while(true){
    c-=b;
    if(c<=0){
      cout<<"Yes"<<endl;
      return 0;
    }
    a-=d;
    if(a<=0){
      cout<<"No"<<endl;
      return 0;
    }
  }

  return 0;
}




Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}

signed main()
{
  string S;
  cin >> S;
  int N = S.size();
  
  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    if (S.at(i) == 'g') ans += i % 2;
    else ans += i % 2 - 1;
  }

  cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.*;
import java.lang.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int Asum=0;
		for(int i=1;i<=a;i++) {
			int sum=0;
			for(int j=i;j>0;j/=10) {
			   int d=j%10;
			   sum+=d;
			 }
			 if(b<=sum&&sum<=c)Asum+=i;
		}
		System.out.println(Asum);
	}
}

Measured memory_bytes: 21844
#include <iostream>

int main()
{
  int a, b;
  std::cin >> a >> b;
  int res = 0;
  if (a > b) {
    res += a;
    a--;
  } else {
    res += b;
    b--;
  }
  if (a > b) {
    res += a;
    a--;
  } else {
    res += b;
    b--;
  }
  std::cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,ac=0,wa=0,tle=0,re=0;
    string s;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>s;
        if(s=="AC")
            ac++;
        if(s=="WA")
            wa++;
        if(s=="TLE")
            tle++;
        if(s=="RE")
            re++;
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
    return 0;

}


Measured memory_bytes: 3644
#include <iostream>
bool s[100001];
main()
{
	std::ios_base::sync_with_stdio(0),std::cin.tie(0);
	char ch;
	int n = 0;
	while ((ch = std::cin.get()) != 10)
		s[++ n] = ch == 49;
	if (s[1] && ! s[n])
	{
		bool * sL = s + 1,* sR = s + n - 1;
		while (sL < sR)
		{
			if (* sL != * sR)
				break;
			++ sL,-- sR;
		}
		if (sL >= sR)
		{
			int pre = 1;
			for (int i = 2;i < n;++ i)
				if (s[i])
					while (pre < i)
						std::cout << i << ' ' << pre ++ << '\n';
			std::cout << n << ' ' << pre << '\n';
			return 0;
		}
	}
	std::cout << "-1\n";
}

Measured memory_bytes: 1536
#include <stdio.h>

int main(){
    int a, b, c, d, n;
    int count = 0;

    while (scanf("%d", &n) != EOF) {
        count = 0;
        for (a = 0; a <= 9; a++) {
            for (b = 0; b <= 9; b++) {
                for (c = 0; c <= 9; c++) {
                    for (d = 0; d <= 9; d++) {
                        if (n == a+b+c+d) {
                            count++;
                        }
                    }
                }
            }
        }
        printf("%d\n", count);
    }

    return 0;
}

Measured memory_bytes: 596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "No";
            for (int i = 0; i <= (100 / 7) + 1; i++)
            {
                for (int j = 0; j <= (100 / 4); j++)
                {
                    if (iN == 7 * i + 4 * j)
                    { sOut = "Yes"; break; }
                }
                if (sOut == "Yes") { break; }
            }

            // 出力
            System.Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
//
// Created by Nihith on 22-02-2020.
//
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int m=1e9+7;
ll inv[200005];
ll fastexpo(ll n,int k){
    ll res=1LL;
    while(k>0){
        if(k&1) res=(res*n)%m;
        n=(n*n)%m;
        k>>=1;
    }
    return res;
}
ll nck(ll n, ll k){
 ll ans=1LL;
    for(int i=1;i<=k;i++){
        ans=ans*(n-i+1)%m*inv[i]%m;
    }
   return ans;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n,a,b;
    cin>>n>>a>>b;
    inv[1] = 1;
    for(int i = 2; i <=2e5; ++i)
    inv[i] = (m - (m/i) * inv[m%i] % m) % m;
    ll cnt=fastexpo(2,n);
    cnt=(cnt+2*m-nck(n,a)-nck(n,b)+m-1)%m;
    cout<<(cnt)<<endl;
    return 0;
}



Measured memory_bytes: 1792
long_str = input()
short_str = input()
short_list = list(short_str)

long_len = len(long_str)
short_len = len(short_str)
iter_num = long_len - short_len + 1

max_count = 0
for i in range(iter_num):
  tmp = 0
  obj_list = list(long_str[i:(short_len+i)])
  for s, o in zip(short_list, obj_list):
    tmp += int(s == o)
  max_count = max(max_count, tmp)

print(short_len - max_count)


Measured memory_bytes: 8824
#include <stdio.h>
int main(void)
{
    int W=0,H=0,x=0,y=0,r=0;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(W>=(x+r)&&H>=(y+r)&&x>0&&y>0)
    {
        printf("Yes\n");
    }
    else if(x<0||y<0)
    {
        printf("No\n");
    }
    else
    {
        printf("No\n");
    }
}



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

int ans1,ans2;

string S;

int main() {
	cin >> S;
	int len = S.size();
	for(int i = 0;i < len;i++) {
		ans1 += S[i] - '0';
		if(i == 0) {
			ans2 += (S[i] - '0' - 1);
			continue;
		}
		ans2 += 9;
	}
	printf("%d\n",max(ans1,ans2));
	return 0;
}

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

using namespace std;

using ll = long long;

const long long MOD = 1e9 + 7;
const int INF = 1e9 + 7;

void dfs(const vector<vector<int>>& graph, int v, vector<bool> is_visit, int& cnt) {
    is_visit[v] = true;
    bool ok = true;
    for (bool b : is_visit) ok &= b;
    if (ok) {
        ++cnt;
        return;
    }
    for (auto u : graph[v]) {
        if (is_visit[u]) continue;
        dfs(graph, u, is_visit, cnt);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<vector<int>> graph(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    vector<bool> is_visit(N, false);
    int ans = 0;
    dfs(graph, 0, is_visit, ans);
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long c = sc.nextLong();
    long[] sum = new long[n + 1];
    long[] x = new long[n + 1];
    long[] v = new long[n + 1];
    long[] dp1 = new long[n + 1];
    long[] dp2 = new long[n + 1];
    for(int i = 1; i < n + 1; i++) {
      x[i] = sc.nextLong();
      v[i] = sc.nextLong();
      sum[i] = sum[i - 1] + v[i];
      dp1[i] = Math.max(dp1[i - 1], sum[i] - x[i]);
    }
    dp2[n] = Math.max(0, sum[n] - sum[n - 1] - (c - x[n])); 
    for(int i = n - 1; i >= 1; i--) {
      dp2[i] = Math.max(dp2[i + 1], sum[n] - sum[i - 1] - (c - x[i]));
    }
    long ans = Math.max(dp1[n], dp2[1]);
    for(int i = 1; i < n + 1; i++) {
      if(i < n) ans = Math.max(ans, sum[i] - 2 * x[i] + dp2[i + 1]);
      if(i > 1) ans = Math.max(ans, sum[n] - sum[i - 1] - 2 * (c - x[i]) + dp1[i - 1]);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 95896
#include <bits/stdtr1c++.h>
#define pb push_back
#define fi first
#define sc second
#define inf    10000000000LL
#define MP make_pair
#define N 
#define MOD 1000000007 
#define orta ((x+y)/2)
using namespace std;
typedef long long int lint;

vector <lint> asal;
void asllar()
{
    int n=100004;
    bool prime[100005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (lint p=3; p*p<=n; p+=2) 
    { 
        if (prime[p] == true) 
        { 
            for (lint i=p*p; i<=n; i += 2*p) 
                prime[i] = false; 
        } 
    } 
  
    asal.push_back(2);
    for (int p=3; p<=n; p+=2) 
       if (prime[p]) 
            asal.push_back(p);
}
inline pair<lint,lint> deleteCubes(lint x)
{
    lint Val=1,reVal=1;
    for (auto i: asal)
    {
        if(i*i>x) break;
        if(x%i==0)
        {
            int cnt=0;
            while(x%i==0)
            {
                cnt++;
                x/=i;
            }
            cnt%=3;
            for (int j = 0; j < cnt; j++)
                Val*=i;
            if(cnt==1 || cnt==2)            
            for (int j = 0; j < 3-cnt; j++)
                reVal*=i;
        }
    }
    if(x>1)
    {
        int cnt=1;
        for (int j = 0; j < cnt; j++)
            Val*=x;
        if(cnt==1 || cnt==2)            
        for (int j = 0; j < 3-cnt; j++)
            reVal*=x;
    }
    return MP(Val,reVal);
}

unordered_map <lint,int> occurance;

unordered_map <lint, pair<lint,lint>> calculated;

vector < pair<lint,lint> > numbers;  
void solve(int ts)
{
    asllar();
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        lint o;
        cin >> o;
        if(calculated.count(o)==0)
        {
            pair<lint,lint> ret= deleteCubes(o);
            numbers.push_back(ret);
            calculated[o]=ret;
        }
        else
            numbers.push_back(calculated[o]);
        occurance[numbers.back().first]++;
    }
    lint ans=0;
    if(occurance[1]>=1)
        ans++;
    for (int i = 0; i < n; i++)
    {
//        cout << numbers[i].first << " " << numbers[i].second << endl;
        lint value = numbers[i].first;
        int occuranceVal = occurance[value];
        if(occuranceVal==0) continue;
        if(value==1) continue;
        lint reverseValue = numbers[i].second;
        ans += max(occuranceVal, occurance[reverseValue]);
        occurance[reverseValue]=0;
        occurance[value]=0;
    }
    cout << ans << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
//    cin >> t;
    for (int i = 0; i < t; i++)
        solve(i+1);
}

Measured memory_bytes: 18760
T = 0
X = 1
Y = 2
item = input()
tabiji = [[0,0,0]]
for i in range(1, int(item)+1):
    tabiji.append(input().split(' '))

a = 'Yes'
for i in range(0, len(tabiji)-1):
    time = int(tabiji[i+1][T]) - int(tabiji[i][T])
    dX = int(tabiji[i+1][X]) - int(tabiji[i][X])
    dY = int(tabiji[i+1][Y]) - int(tabiji[i][Y])
    for j in range(time):
        if dX > 0:
            dX -= 1
        elif dX < 0:
            dX += 1
        elif dY > 0:
            dY -= 1
        elif dY < 0:
            dY += 1
        if dX == 0 and dY == 0 and (time - j+1) % 2 == 1:
            a = 'No'
            break
        elif dX == 0 and dY == 0 and (time - j+1) % 2 == 0:
            break
    if dX != 0 or dY != 0:
        a = 'No'

print(a)

Measured memory_bytes: 32148
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int x[4], y[4];
  scanf("%d%d%d%d",&x[0], &y[0], &x[1], &y[1]);
  
  x[2] = x[1] + y[0] - y[1];
  y[2] = -x[0] + x[1] + y[1];
  x[3] = x[0] + y[0] - y[1];
  y[3] = x[1] - x[0] + y[0];
  
  printf("%d %d %d %d", x[2], y[2], x[3], y[3]);
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using i64 = long long;


int main() {
    int ret[500][500];
    int n;
    std::cin >> n;

    for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) {
        for (int k = 0; k < 10; k++) {
            if ((i & (1 << k)) ^ (j & (1 << k))) {
                ret[i][j] = ret[j][i] = k + 1;
                break;
            }
        }
    }

    for (int i = 0; i + 1 < n; i++) {
        for (int j = i + 1; j < n; j++) std::cout << ret[i][j] << " ";
        std::cout << std::endl;
    }

    return 0;
}


Measured memory_bytes: 1408
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	int n,out=0,a;
	cin>>n;
	rep(i,n){
		cin>>a;
		while(a%2==0){
			out++;a/=2;
		}
	}
	cout<<out<<endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
class Program
{
	static void Main(string[] args)
	{
        var result = true;
    	var steps = Console.ReadLine();
        foreach (var item in steps.Select((value, i) => new { i, value })) 
        {
  			var step = item.value;
  			var index = item.i;
        	if(item.i%2==0 && item.value != 'R' && item.value !='U' && item.value !='D')
            {
              Console.WriteLine("No");
              return;
            }
            else if(item.i%2==1 && item.value != 'L' && item.value !='U' && item.value !='D')
            {
              Console.WriteLine("No");
              return;
            }
		}
      
      	Console.WriteLine("Yes");

	}
}

Measured memory_bytes: 13268
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys
input = sys.stdin.readline
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

s = input()
print(s[:3])

Measured memory_bytes: 61676