akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;

#define endl '\n'

ll dp[105][100005];
ll pre[105][100005];
ll mod = 1e9+7;
int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);

    cout.tie(0);

    memset(dp,0,sizeof(dp));
    memset(pre,0,sizeof(pre));
    ll n,k;
    cin>>n>>k;
    ll arr[1+n];
    for(ll i=0;i<n;i++){
        cin>>arr[i];
    }

    for(ll i=n-1;i>=0;i--){

        for(ll j=0;j<=k;j++){

             if(i==n-1){
                if(j>=0 and j<=arr[i]){
                    dp[i][j] = 1;
                    pre[i][j] = 1;
                }
             }
             else{
                if(j==arr[i]){
                    dp[i][j] = (mod+pre[i+1][j])%mod;
                }
                else
                dp[i][j] = (mod+pre[i+1][j] - pre[i+1][j-min(j,arr[i])-1])%mod;
                pre[i][j] = dp[i][j];

             }

        }
        for(ll j=1;j<=k;j++){
            pre[i][j] = (mod+pre[i][j]+pre[i][j-1])%mod;
        }
    }

    cout<<dp[0][k]<<endl;







}


Measured memory_bytes: 164352
<?php
$n = intval(trim(fgets(STDIN)));
$s = trim(fgets(STDIN));
$ans = -1;
$place = ($n-1)*(-1);
for ($tmp = 0; $tmp < $n-1; $tmp++){
    $factor = 0;
    $sentence1 = array_values(array_unique(str_split(substr($s, 0, $tmp+1))));
    $sentence2 = array_values(array_unique(str_split(substr($s, $place))));
    for ($tmp2 = 0; $tmp2 < count($sentence1); $tmp2++){
        $val = $sentence1[$tmp2];
        if (in_array($val, $sentence2, TRUE)){
            $factor++;
        }
    }
    $ans = max($ans, $factor);
    $place += 1;
}
print("$ans\n");
?>

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

int main() {
    int N;
    cin >> N;
    if (N==1) {
        cout << "Yes" << endl;
        return 0;
    }

    int H[N];
    for (int i=0; i<N; i++) {
        cin >> H[i];
    }

    for (int i=N-1; i>0; i--) { 
        if (H[i-1] - H[i] > 1) {
            cout << "No" << endl;
            return 0;
        }
        if (H[i-1] - H[i] == 1) {
            H[i-1]--;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define N 2010
inline int read() {
    int x=0;
    char ch=getchar();
    while (!isdigit(ch)) ch=getchar();
    while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
    return x;
}
inline int gcd(int x,int y) {
    return y?gcd(y,x%y):x;
}
int f[N][N];
int a[N],vis[N],ind[N];
vector<int> v[N];
inline void dfs(int x,int n) {
    vis[x]=true;
    for (int i=1;i<=n;i++) {
        if (!f[x][i] || vis[i]) continue;
        ind[i]++,v[x].push_back(i),dfs(i,n);
    }
}
inline void Top(int n) {
    priority_queue<int> q;
    for (int i=1;i<=n;i++) 
        if (!ind[i]) q.push(i);
    while (!q.empty()) {
        int x=q.top(); q.pop();
        printf("%d ",a[x]);
        for (int i=0;i<v[x].size();i++) q.push(v[x][i]);
    }
}
int main() {
    int n=read();
    for (int i=1;i<=n;i++) a[i]=read();
    sort(a+1,a+n+1);
    for (int i=1;i<=n;i++) {
        for (int j=1;j<=n;j++) {
            if (gcd(a[i],a[j])!=1) f[i][j]=true;
        }
    }
    for (int i=1;i<=n;i++)
        if (!vis[i]) dfs(i,n);
    Top(n);
    return 0;
}

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

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

const long long MOD = 1000000007;

int main(){
  int k,a,b;
  bool ans = false;
  cin >> k >> a >> b;
  for(int i=a;i<=b;i++){
      if(i%k==0) ans=true;
  }
  if(ans) cout << "OK" <<endl;
  else cout << "NG" << endl;
}


Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>	
#include <time.h>
#include <vector>
#include <stdio.h>
#include <memory.h>
#include <string>
#include <string.h>
#include <map>
#include <algorithm>
#include <queue>
#include <set>
#include <time.h>
#include <assert.h>
#include <sstream>
//#include <unordered_map>
#include <bitset>
#include <utility>
#include <iomanip>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <math.h>
#include <cmath>
#include <complex>
using namespace std;
typedef long long ll;

struct node {
	int u;
	ll c;
	node() { }
	node(int u, ll c):u(u), c(c) { }
	inline bool operator<(const node &e)const {
		return c > e.c;
	}
};
struct edge {
	int u, v, c;
	edge() { }
	edge(int u, int v, int c):u(u), v(v), c(c) { }
};
const int N = 2e5 + 10;
const int M = 1e9 + 7;
int n, m, vis[N], s, t;
ll cost[2][N], dp[2][N];
vector<node>adj[N];
vector<edge>e;
void dijkstra(int s, int bit) {
	memset(vis, 0, sizeof vis);
	for(int i = 0; i < n; ++i)
		cost[bit][i] = 1e18;
	cost[bit][s] = 0;
	dp[bit][s] = 1;
	priority_queue<node>q;
	q.push(node(s, 0));
	node e;
	while(q.size()) {
		e = q.top();
		q.pop();
		if(vis[e.u])
			continue;
		vis[e.u] = 1;
		for(int i = 0; i < adj[e.u].size(); ++i) {
			int v = adj[e.u][i].u;
			ll c = adj[e.u][i].c + e.c;
			if(vis[v] || cost[bit][v] < c)
				continue;
			if(cost[bit][v] == c) {
				dp[bit][v] += dp[bit][e.u];
				if(dp[bit][v] >= M)
					dp[bit][v] -= M;
			}
			else {
				dp[bit][v] = dp[bit][e.u];
				q.push(node(v, c));
				cost[bit][v] = c;
			}
		}
	}
}

int main() {

	scanf("%d%d", &n, &m);
	scanf("%d%d", &s, &t);
	--s; --t;
	while(m--) {
		int u, v, c;
		scanf("%d%d%d", &u, &v, &c);
		--u; --v;
		adj[u].push_back(node(v, c));
		adj[v].push_back(node(u, c));
		e.push_back(edge(u, v, c));
	}
	dijkstra(s, 0);
	dijkstra(t, 1);
	ll ans = dp[0][t] * dp[0][t] % M;
	ll D = cost[0][t];
	for(int i = 0; i < n; ++i)
		if(cost[0][i] + cost[1][i] == D && cost[0][i] == cost[1][i]) {
			ll x = dp[0][i] * dp[0][i] % M;
			ll y = dp[1][i] * dp[1][i] % M;
			ans -= x * y % M;
			if(ans < 0)
				ans += M;
		}
	for(int i = 0; i < e.size(); ++i) {
		int u = e[i].u;
		int v = e[i].v;
		int c = e[i].c;
		if(cost[0][u] > cost[0][v]) swap(u, v);
		if(cost[0][u] * 2 < D && cost[1][v] * 2 < D && cost[0][u] + c + cost[1][v] == D) {
			ll x = dp[0][u] * dp[0][u] % M;
			ll y = dp[1][v] * dp[1][v] % M;
			ans -= x * y % M;
			if(ans < 0)
				ans += M;
		}
	}
	printf("%lld\n", ans);


	return 0;
}


Measured memory_bytes: 26656
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int n,x;
    cin>>n>>x;
    vector<int> v(n);
    rep(i,n)cin>>v[i];

    sort(all(v));

    int ans = INF;
    for(int l=0;l<n-x+1;l++){
        assert(l+x-1<n);
        ans = min(ans,v[l+x-1]-v[l]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;
//ここから

void solve(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int x=0;
  int ans=0;
  rep(i,n){
    if(s[i]=='I')++x;
    else --x;
    chmax(ans,x);
  }
  cout<<ans;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 256
if __FILE__ == $0
  while line = gets
    cards = (1..10).to_a
    c1, c2, c3 = line.split.map{|i| i.to_i}
    cards.delete(c1)
    cards.delete(c2)
    cards.delete(c3)
    rest = 20 - (c1 + c2)
    matchCards = 0
    cards.each do |c|
      if c <= rest
        matchCards += 1
      end
    end
    if (matchCards.to_f / cards.length.to_f) >= 0.5
      puts "YES"
    else
      puts "NO"
    end
  end
end

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

#define FOR(i,l,r) for(int i=l;i<=r;++i)
#define REP(i,l,r) for(int i=l;i<r;++i)

inline int read(){
	int ss=0,ff=1; char chr=getchar();
	while(chr<'0'||chr>'9') {if(chr=='-') ff=-1; chr=getchar();}
	while('0'<=chr&&chr<='9') ss=(ss<<3)+(ss<<1)+chr-'0',chr=getchar();
	return ss*ff;
}

const int N=1e5+7;
int n,a[N],b[N],ans;

int main(){
	n=read();
	int x=0;
	FOR(i,1,n){
		a[i]=read();
		ans+=fabs(a[i]-x);
		x=a[i];
	}ans+=fabs(a[n]);
	FOR(i,1,n){
		x=ans-fabs(a[i-1]-a[i])-fabs(a[i]-a[i+1])+fabs(a[i-1]-a[i+1]);
		printf("%d\n",x);
	}
}

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

 
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll k,x;
    cin>>k>>x;
    for(ll i=x-k+1;i<x+k;i++)
    cout<<i<<" ";

	return 0;
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  int ans = 0;
  int N; cin >> N;
  cout << (N-1)/2 << endl;
  return 0;
}

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

using namespace std;

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

  int ans = 0;

  ans = (n % 2 == 1)?n / 2 + 1 : n/2;

  cout << ans<< endl;

  
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <map>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    int N;
    cin >> N;
    vector<LL> A(N);
    map<LL, LL> addAdic;
    map<LL, LL> subAdic;
    REP(i, N){
        cin >> A[i];

        LL addA = A[i] + i + 1;
        LL subA = i + 1 - A[i]; 
        if(addAdic.count(addA) == 0){
            addAdic[addA] = 1;
        }else{
            addAdic[addA]++;
        }

        if(subAdic.count(subA) == 0){
            subAdic[subA] = 1;
        }else{
            subAdic[subA]++;
        }

    }

    LL count = 0;
    for(auto itr = addAdic.begin(); itr!=addAdic.end(); itr++){
        LL key = itr->first;
        LL value = itr->second;
        if(subAdic.count(key) == 1){
            count += subAdic[key]*value;
        }

    }

    cout << count << endl;
    return 0;
    
}

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

typedef long long ll;
typedef unsigned long long ull;

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

#define INF INT_MAX/3

typedef long double D;
typedef complex<D> P;

#define X real()
#define Y imag()

const D eps=1e-8;
const D inf=1e12;
const D PI=acos(-1);

namespace std{
  bool operator<(const P& a,const P& b){
    return a.X==b.X?a.Y<b.Y:a.X<b.X;
  }
}
D cross(P a,P b){
  return (conj(a)*b).Y;
}
D dot(P a,P b){
  return (conj(a)*b).X;
}
struct L : public vector<P> { // line and segment
  L(const P& a,const P &b){
    push_back(a);
    push_back(b);
  }
};
struct C{
  P p; D r;
  C(const P& p,D r):p(p),r(r){}
};

enum RELATION{SAME=1,CONTAINED=2,OVER=4,NO_CROSS=8,ONE_CROSS=16,ONE_CONTAINED_CROSS=32,ONE_OVER_CROSS=64,TWO_CROSS=128};
int cRel(C c1, C c2) {
  D d=abs(c1.p-c2.p);
  D dr1=c1.r-c2.r,dr2=c2.r-c1.r;
  D ar=c1.r+c2.r;
  if(d<eps&&c1.r==c2.r)return SAME;
  if(d<dr1)return OVER;
  if(d<dr2)return CONTAINED;
  if(d==dr1)return ONE_OVER_CROSS;
  if(d==dr2)return ONE_CONTAINED_CROSS;
  if(d==ar)return ONE_CROSS;
  if(d>ar)return NO_CROSS;
  return TWO_CROSS;
}

L tanC(C c,D t){
    P p=c.p+polar(c.r,t);
    P d=polar(c.r,t)*P(0,1);
    return L(p-d,p+d);
}
vector<L> tanCC(C c1,C c2){
  vector<L> res;
  D d=arg(c2.p-c1.p);
  D i=acos((c1.r+c2.r)/abs(c2.p-c1.p));
  D o=acos((c1.r-c2.r)/abs(c2.p-c1.p));
  int r=cRel(c1,c2);
  if(r==NO_CROSS){
    res.push_back(tanC(c1,d+i));
    res.push_back(tanC(c1,d-i));
  }
  if(!(r&(SAME|CONTAINED|OVER|ONE_CONTAINED_CROSS|ONE_OVER_CROSS))){
    res.push_back(tanC(c1,d+o));
    res.push_back(tanC(c1,d-o));
  }
  if(r&(ONE_CROSS|ONE_CONTAINED_CROSS|ONE_OVER_CROSS)){
    res.push_back(tanC(c1,d));
  }
  return res;
}

P projection(const L& l,const P& p){
  P b=l[1]-l[0],c=p-l[0];
  return l[0]+b*(c/b).X;
}
D distanceLP(const L& l,const P& p) {
  return abs(p-projection(l,p));
}

int n;

int main(){
	cin.sync_with_stdio(false);
  vector<L> hoge=tanCC(C(P(0,0),1),C(P(2,2),5));
  rep(i,hoge.size()){
    cout<<hoge[i][0]<<" "<<hoge[i][1]<<endl;
  }
  while(1){
    cin>>n;
    if(n==0)break;
    vector<C> a;
    rep(i,n){
      D x,y,r,m;
      cin>>x>>y>>r>>m;
      a.push_back(C(P(x,y),r));
      a.push_back(C(P(x,y),r+m));
    }
    int res=1;
    rep(i,a.size())rep(j,i){
      vector<L> tmp=tanCC(a[i],a[j]);
      rep(k,tmp.size()){
        int s=0;
        for(int l=0;l<a.size();l+=2){
          if(a[l].r-eps<=distanceLP(tmp[k],a[l].p)&&distanceLP(tmp[k],a[l].p)<=a[l+1].r+eps){
            s++;
          }
        }
        maxch(res,s);
      }
    }
    cout<<res<<endl;
  }
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mk make_pair
#define pi pair<int, int>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
using namespace std;
int dt[][2]= {{1,0},{-1,0},{0,1},{0,-1},{0,0}};
//typedef pair<int, int> P;
//priority_queue<int, vector<int>, greater<int> > q;
int main()
{
   IOS;
   ll n,d;
   cin >> n >> d;
   int cnt = 0;
   while(n--){
       ll a,b;
       cin >> a >> b;
       long double k = sqrt(a*a+b*b);
       if(k<=d)++cnt;
   }
   cout << cnt <<endl;
}


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

int t[4],u[4],used[4];
char tx[3]={'+','-','*'};
void rec(int);
void rec2();
bool check(int,int,int);
void print(int,int,int);
bool check2(int,int,int);
void print2(int,int,int);
int flg;

int main(){
	while(1){
		flg=0;
		for(int i=0;i<4;i++)cin>>t[i];		
		if(t[0]+t[1]+t[2]+t[3]==0)break;
		for(int i=0;i<4;i++)used[i]=0;
		rec(0);
		if(flg==0)cout<<flg<<endl;
	}
	return 0;
}


void rec(int x){
	if(x==4)rec2();
	else{
		for(int i=0;i<4;i++){
			if(flg)return;
			if(used[i]==0){
				used[i]=1;
				u[x]=t[i];
				rec(x+1);
				used[i]=0;
			}
		}
	}
}

void rec2(){
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				if(flg)return;
				//cout<<i<<" "<<j<<" "<<k<<endl;
				if(check(i,j,k)){
					print(i,j,k);
					flg=1;
					return;
				}
				if(check2(i,j,k)){
					print2(i,j,k);
					flg=1;
					return;
				}

			}
		}
	}


}

bool check(int a,int b,int c){
	int ans;
	if(a==0){
		ans=u[0]+u[1];
	}else if(a==1){
		ans=u[0]-u[1];
	}else{
		ans=u[0]*u[1];
	}

	if(b==0){
		ans=ans+u[2];
	}else if(b==1){
		ans=ans-u[2];
	}else{
		ans=ans*u[2];
	}

	if(c==0){
		ans=ans+u[3];
	}else if(c==1){
		ans=ans-u[3];
	}else{
		ans=ans*u[3];
	}
	//cout<<ans<<endl;
	if(ans==10)return true;
	else return false;
}

void print(int a,int b,int c){
	cout<<"(("<<u[0]<<tx[a]<<u[1]<<")"<<tx[b]<<u[2]<<")"<<tx[c]<<u[3]<<endl;
}

bool check2(int a,int b,int c){
	int ans,ans2,ans3;
	if(a==0){
		ans=u[0]+u[1];
	}else if(a==1){
		ans=u[0]-u[1];
	}else{
		ans=u[0]*u[1];
	}

	if(c==0){
		ans2=u[2]+u[3];
	}else if(c==1){
		ans2=u[2]-u[3];
	}else{
		ans2=u[2]*u[3];
	}

	if(b==0){
		ans3=ans+ans2;
	}else if(b==1){
		ans3=ans-ans2;
	}else{
		ans3=ans*ans2;
	}
	//cout<<ans<<endl;
	if(ans3==10)return true;
	else return false;
}

void print2(int a,int b,int c){
	cout<<"("<<u[0]<<tx[a]<<u[1]<<")"<<tx[b]<<"("<<u[2]<<tx[c]<<u[3]<<")"<<endl;
}

Measured memory_bytes: 1164
from collections import Counter
n = int(input())
lis = list(map(int,input().split()))
l = Counter(lis)
d = [0]+[l[i+1] for i in range(10**5)]
q = int(input())
s = sum(lis)
for i in range(q):
    a,b=map(int,input().split())
    if d[a]!=0:
        temp = d[a]
        d[a]=0
        d[b]+=temp
        s += temp*(b-a)
    print(s)

Measured memory_bytes: 21472
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>

#ifdef GONGKUNPENG
#include <cassert>

#define _GG 1
#else
#define _GG 0
#endif

#define uint unsigned
#define vector std::vector
#define max(a, b) std::max(a, b)
#define min(a, b) std::min(a, b)
#define swap(a, b) std::swap(a, b)
#define sort(...) std::sort(__VA_ARGS__)
#define ms(a, v) memset(a, v, sizeof(a))
#define ufor(i, n) for (int i = 1; i < n; ++i)
#define sfor(i, n) for (int i = 1; i <= n; ++i)
#define tfor(i, n) for (int i = 0; i < n; ++i)

#if __cplusplus >= 201103L
using ll = long long;
using ull = unsigned long long;
#else
typedef long long ll;
typedef unsigned long long ull;
#endif

int main() {
  char in[10];
  scanf("%s", in);
  printf(in[2] == in[3] && in[4] == in[5] ? "Yes\n" : "No\n");
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if(a == b){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
const int oo = 1e9 + 7;

char a[22][22];
int vs[22][22];
const int ver[] = { 0, 0, -1, 1 };
const int hor[] = { -1, 1, 0, 0 };
int h, w;

int bfs(int x, int y, int u, int v) {
  memset(vs, -1, sizeof vs);
  vs[x][y] = 0;
  queue<ii> q;
  q.push(ii(x, y));
  while (!q.empty()) {
    ii p = q.front();
    q.pop();
    for (int k = 0; k < 4; ++k) {
      int e = p.first + ver[k];
      int f = p.second + hor[k];
      if (1 <= e && e <= h && 1 <= f && f <= w && vs[e][f] == -1 && a[e][f] == '.') {
        vs[e][f] = vs[p.first][p.second] + 1;
        q.push(ii(e, f));
      }
    }
  }
  return vs[u][v];
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> h >> w;
  for (int i = 1; i <= h; ++i)
    cin >> a[i] + 1;
  int ans = 0;
  for (int x = 1; x <= h; ++x)
    for (int y = 1; y <= w; ++y)
      if (a[x][y] == '.')
        for (int u = 1; u <= h; ++u)
          for (int v = 1; v <= w; ++v)
            if (a[u][v] == '.') {
              int res = bfs(x, y, u, v);
              if (res >= 0) {
                ans = max(ans, res);
              }
            }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextInt();
        long M = sc.nextInt();
        if(N == 1 && M == 1)    System.out.println(1);
        else if(N == 1 && M > 1)    System.out.println(M-2);
        else if(N > 1 && M == 1)    System.out.println(N-2);
        else if(N == 2 || M == 2)  System.out.println(0);
        else    System.out.println((N-2)*(M-2));
    }
}

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

public class Main {
	public static void main(String[] args) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String str = br.readLine();
	int num = Integer.parseInt(str);

	System.out.println((int)Math.pow(num, 3));
	}
}



Measured memory_bytes: 24120
def resolve():
    import sys
    input = sys.stdin.readline
    # 整数 1 つ
    n = int(input())
    # 整数複数個
    # a, b = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    import math
    print(math.ceil(n/1000)*1000-n)


resolve()

Measured memory_bytes: 61940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265359

int main(void)
{
    int n;

    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    for (int i=n-1;i>0;--i)
    {
        cout << a[i] << " ";
    }

    cout << a[0] << endl;
}



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

void solve() 
{
    int k;string s;cin>>k>>s;
    if(s.size()<=k){
        cout<<s<<endl;
    }else{
        REP(i,k)cout<<s[i];cout<<"..."<<endl;
    }
}

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

Measured memory_bytes: 3608
<?php
fscanf(STDIN, '%d', $cnt);
$nums = array_map('intval', explode(' ', trim(fgets(STDIN))));
sort($nums);
$ans = 0;
for ($i=0; $i < $cnt; $i++) { 
    for ($j=0; $j < $i; $j++) { 
        for ($k=0; $k < $j; $k++) { 
            $a = $nums[$i];
            $b = $nums[$j];
            $c = $nums[$k];
            if ($a == $b || $b == $c || $a == $c) {
                continue;
            }
            if ($c + $b > $a) {
                $ans++;
            }
        }
    }
}
echo $ans;

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

int main(){
    int N, x=0;
    cin>>N;
    int V[N], C[N];
    for (int i = 0; i < N; i++)
    {
        cin>>V[i];
    }
    for (int i = 0; i < N; i++)
    {
        cin>>C[i];
    }
    for (int i = 0; i < N; i++)
    {
        if (V[i]>C[i])
        {
            x += V[i]-C[i];
        }
        
    }
    cout<<x<<endl;
    
    
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string S;
    cin >> S;
    for(int i=0; i<26; i++)
    {
    	char key = 'a' + i;
    	bool flag = false;
    	for(int j=0; j<=S.size(); j++)
    	{
    		if(S[j]==key)
    		{
    			flag = true;
    		} 
    	}
    	if(!flag)
    	{
    		cout << key << endl;
    		return 0;
    	} 
    }
    cout << "None" << endl;
	return 0;
}

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

int main(){
  int n; cin >>n;
  int t[100100], x[100100], y[100100];
  t[0] = x[0] = y[0] = 0;
  rep(i,n) cin >>t[i+1] >>x[i+1] >>y[i+1];
  bool can = true;
  rep(i,n){
    int dist = abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
    int dt = t[i+1]-t[i];
    if(dt<dist) can = false;
    if(dt%2!=dist%2) can = false;
  }
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0; 
}


Measured memory_bytes: 1408
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18


struct P {
	string f;
	int s;
	int x;
};

bool comp(P p1, P p2) {
	if (p1.f != p2.f) {
		return p1.f < p2.f;
	}
	else {
		return p1.s >= p2.s;
	}
}

void dump(const vector<P> a) {
	int n = a.size();
	for (int i = 0; i < n; i++) {
		cout << a[i].f << " " << a[i].s << endl;
	}
}

/*
vector<P> a(n);
for (int i = 0; i < n; i++) {
		cin >> a[i].f>>a[i].s;
	}

	sort(a.begin(), a.end(),comp);

*/

int main() {

	int n; cin >> n;

	vector<P> a(n);
	for (int i = 0; i < n; i++) {

		cin >> a[i].f >> a[i].s;
		a[i].x = i+1;
	}

	sort(a.begin(), a.end(), comp);

	for (int i = 0; i < n; i++) {
		cout << a[i].x << endl;
	}




	return 0;
}

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

#define ll long long 

int main() {
    ios::sync_with_stdio(0); 
    

    // generate all combinations of buying the books 

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

    int books[n][m];
    int cost[n];
    for (int i = 0; i < n; i++) {
        cin >> cost[i];
        for (int j = 0; j < m; j++) 
            cin >> books[i][j]; 
    }

    int mark[n];
    int ans = 1e9;
    for (int b = 0; b < (1 << n); b++) {
        for (int i = 0; i < n; i++) mark[i] = (b >> i) & 1;
        int curr_cost = 0;
        int understanding[m];
        memset(understanding, 0, sizeof(understanding));
        for (int i = 0; i < n; i++) {
            if (mark[i]) {
                curr_cost += cost[i];
                for (int x = 0; x < m; x++) 
                    understanding[x] += books[i][x];
            }
        }
        bool ok = true;
        for (int b = 0; b < m; b++) 
            if (understanding[b] < x) ok = false;
        
        if (ok) ans = min(ans, curr_cost);
    }

    if (ans == 1e9) cout << -1 << endl;
    else cout << ans << endl;

    return 0; 
}



Measured memory_bytes: 3644
import sys, os, math \
    # , bisect, itertools, collections, heapq, queue

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque
# import copy

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()
    Q = ii()
    M = il()

    num_set = set()
    for i in range(1 << N):
        num = 0
        for n in range(N):
            if i >> n & 1:
                num += A[n]
        num_set.add(num)

    for m in M:
        if m in num_set:
            print('yes')
        else:
            print('no')


if __name__ == '__main__':
    main()



Measured memory_bytes: 5700
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using llong = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int main() {
   string w;
   cin >> w;
   string end = "END_OF_TEXT";
   int ans = 0;
   while (true) {
      string t;
      cin >> t;
      if (t == end) break;
      rep(i, t.size()) t[i] = tolower(t[i]);
      if(t == w) ans++;
   }
   cout << ans << endl;
   return 0;
}


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

int main(void) {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
    vector<long long> dp(N);
    dp[0] = 0;
    for (int i = 1; i < N; i++) {
        long long _min = LLONG_MAX;
        for (int j = 1; j <= K; j++) {
            if (i - j < 0) continue;
            _min = min(dp[i - j] + abs(h[i] - h[i - j]), _min);
        }
        dp[i] = _min;
    }
    cout << dp[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define H 12
#define W 6
using namespace std;
bool del[H][W],used[H][W];
string s[H];
int dy[4]={-1,0,1,0};
int dx[4]={0,1,0,-1};

void mark(){
  int cnt=0;
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      if(used[i][j])cnt++;
  if(cnt<4)return;
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      if(used[i][j])del[i][j]=true;
}

void mark2(){
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++){
      if(s[i][j]!='O')continue;
      for(int k=0;k<4;k++){
	int ni=i+dy[k],nj=j+dx[k];
	if(ni<0||nj<0||H<=ni||W<=nj)continue;
	if(del[ni][nj]&&s[ni][nj]!='O')del[i][j]=true;
      }
    }
}

void dfs(int y,int x,char c){
  used[y][x]=true;
  for(int i=0;i<4;i++){
    int ny=y+dy[i],nx=x+dx[i];
    if(ny<0||nx<0||H<=ny||W<=nx)continue;
    if(used[ny][nx])continue;
    if(s[ny][nx]==c)dfs(ny,nx,c);
  }
}

bool Del(){
  bool res=false;
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      if(del[i][j])s[i][j]='.',res=true;
  while(1){
    int flag=0;
    for(int i=H-1;i>=1;i--)
      for(int j=0;j<W;j++)
	if(s[i][j]=='.'&&s[i-1][j]!='.')
	  swap(s[i][j],s[i-1][j]),flag=1;
    if(!flag)break;
  }
  return res;
}

int solve(){
  int res=0;
  while(1){
    memset(del,0,sizeof(del));
    for(int i=0;i<H;i++)
      for(int j=0;j<W;j++){
	if(del[i][j])continue;
	if(s[i][j]=='.')continue;
	if(s[i][j]=='O')continue;
	memset(used,0,sizeof(used));
	dfs(i,j,s[i][j]);
	mark();
      }
    mark2();
    if(Del())res++;
    else break;
  }
  return res;
}

int main(){
  int n;
  cin>>n;
  while(n--){
    for(int i=0;i<H;i++)cin>>s[i];
    cout<<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

// 約数を列挙するO(n^-2/1)
template <class T> vector<T> enum_diviser(T n){
    vector<T> ret(0);
    for(T i=1; i*i<=n; i++){
        if(n%i==0){
            ret.push_back(i);
            if(i*i!=n) ret.push_back(n/i);
        } 
    }
    sort(ret.begin(), ret.end());
    return ret;
}


// i: 1 2 3 4 
// b:   1 0 1
// A: 1 0 0 1
// 1
// 1
int main(){
    int n;
    cin >> n;
    vector<int> A(n+1,0);
    vector<int> B(n+1,0);
    REP(i,n) cin >> A[i+1];
    vector<int> C(n+1,0);
    for(int i=n; 1<=i; i--){
        if(A[i]==0){
            if(C[i]%2==0){
                B[i] = 0;
            }
            else if(C[i]%2==1){
                B[i] = 1;
                for(auto x : enum_diviser(i)){
                    C[x]+=1;
                }
            }
        }
        else if(A[i]==1){
            if(C[i]%2==0){
                B[i] = 1;
                for(auto x : enum_diviser(i)){
                    C[x]+=1;
                }
            }
            else if(C[i]%2==1){
                B[i] = 0;
            }
        }
        // cout << "B[" << i << "]:" <<B[i] << endl;
    }
    int m=0;
    for(int i=1; i<=n; i++){
        if(B[i]==1) m++;
    }
    cout << m << endl;
    for(int i=1; i<=n; i++){
        if(B[i]==1)cout << i << " ";
    }
    cout  << endl;

    return 0;
}

Measured memory_bytes: 3200
//コンパイラ最適化用
#pragma GCC optimize("Ofast")

//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

// clang++ main.cc -std=c++11 -stdlib=libc++

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

  if (N == 0)
    cout << X << endl;
  else {
    unordered_map<int, int> hash;
    vector<int> p(N);
    for (int i = 0; i < N; i++) {
      cin >> p[i];
      hash[p[i]] = i;
    }

    int l = X, r = X;
    while (1) {
      if (hash.find(l) != hash.end()) {
        l--;
      } else {
        cout << l << endl;
        break;
      }

      if (hash.find(r) != hash.end()) {
        r++;
      } else {
        cout << r << endl;
        break;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 3648
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

N, K = mi()
Vs = list(mi())

#コードが簡単になるように、全ての宝石の合計価値をとっておく
valuesum = sum(Vs)

maxvalue = -(10**8)
#取らない場合（全てを「取らない」に入れる場合）はobtainedJewelsが空リストになって、sumも0になるだけなので問題ない。スライスに[:0]などと入れるのも、空リストになるだけなので問題なし
#全て取る場合：このループで考慮していないので、別でやる
for l in range(N): #範囲は0~N-1（全て取る場合もあるし、右端1個だけ取る場合もある)
  for r in range(N): #同様
     if l > r: continue #lとrが同値になってもいいが、lのが大きいのはNG
     remain = K-N+r-l+1 #残り手数
     if remain < 0: continue #残り手数マイナスは矛盾なので無視
     #取った宝石のリストを作って昇順に並べる
     obtainedJewels = sorted(Vs[:l] + Vs[r+1:])
     nowvalue = sum(obtainedJewels)
     #0～remain個の宝石を捨てた場合の価値をmaxvalueと比較していく
     for i in range(0, remain+1):
       maxvalue = max(maxvalue, nowvalue-sum(obtainedJewels[:i]))

#全て取る場合
if K>= N: #KがN以上ないと全て取ることは不可能
  remain = K-N
  obtainedJewels = sorted(Vs) #全て取る
   #0～remain個の宝石を捨てた場合の価値をmaxvalueと比較していく
  for i in range(0, remain+1):
   maxvalue = max(maxvalue, valuesum-sum(obtainedJewels[:i]))

#ここまでで、1個でもとると合計価値マイナスになるしかない場合（例えばN=K=1で宝石がマイナスとか）はマイナスになっている
print(max(0, maxvalue))



Measured memory_bytes: 43740
import java.util.Scanner;

public class Main {
    static int[] kachi;
    static int[] cost;
    private static int result;

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int counter = scanner.nextInt();

        kachi = new int[counter];
        cost = new int[counter];

        int maxKachi = 0;
        for (int i = 0; i < counter; i++) {
            kachi[i] = scanner.nextInt();
            maxKachi += kachi[i];
        }

        int maxCost = 0;
        for (int i = 0; i < counter; i++) {
            cost[i] = scanner.nextInt();
            maxCost += cost[i];
        }
        result = maxKachi - maxCost;

        select(0,counter,0);
        System.out.println(result);

    }

    public static void select(int index, final int counter, int tmp) {
        if (index == counter - 1) {
            if (tmp + kachi[index] - cost[index] > result) {
                result = tmp + kachi[index] - cost[index];
            }

            if (tmp > result) {
                result = tmp;
            }

            return;
        }

        select(index + 1, counter, tmp);
        select(index + 1, counter, tmp + kachi[index] - cost[index]);
    }
}


Measured memory_bytes: 23252
import time
t=time.time()
A,B,C=map(int,input().split())
cnt=0
while(A%2==B%2==C%2==0):
    a,b,c=A,B,C
    A=b//2+c//2;B=a//2+c//2;C=a//2+b//2
    cnt+=1
    if(time.time()-t>=1):
        print(-1)
        exit()
print(cnt)

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

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  
  cout << (char)(a.at(0) - 0x20) << (char)(b.at(0) - 0x20) << (char)(c.at(0) - 0x20) << endl;
}


Measured memory_bytes: 256
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,C = map(int,input().split())
XV = [tuple(map(int,input().split())) for _ in range(N)]

# 順方向,逆方向の累積和
VF,VB = [0]*(N+1),[0]*(N+1)
for i in range(N):
    VF[i+1] += VF[i]+XV[i][1]
for i in range(N):
    VB[N-i-1] += VB[N-i]+XV[N-1-i][1]
# 移動距離を減算
for i in range(N):
    VF[i+1] -= XV[i][0]
for i in range(N):
    VB[N-i-1] -= (C-XV[N-1-i][0])
# 食べに行くと損する場合を除くために単調増加に
for i in range(N):
    if VF[i+1] < VF[i]:
        VF[i+1] = VF[i]
for i in range(N):
    if VB[N-1-i] < VB[N-i]:
        VB[N-1-i] = VB[N-i]
 
# 順方向,逆方向で全部食べた場合で初期化
ans = 0
ans = max(ans, VF[N], VB[0])
 
# 反転 : 順方向→逆方向
for i in range(1,N):
    ans = max(ans, VF[i], VF[i]+VB[i]-XV[i-1][0])
 
# 反転 : 逆方向→順方向
for i in range(1,N):
    ans = max(ans, VB[i], VB[i]+VF[i]-(C-XV[i][0]))
 
print(ans)

Measured memory_bytes: 26188
#include <stdio.h>

int main(){
  float mx=-1.0,mn=99999.0,ht;
  while(scanf("%f",&ht)!=EOF){
    mx=(mx>ht)?mx:ht;
    mn=(mn<ht)?mn:ht;
  }
  printf("%.1f\n",mx-mn);
  return 0;
}

Measured memory_bytes: 0
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// hoge hoge hog

fn main() {
    input! {
        mut a: [i64; 5],
        k: i64,
    }

    a.sort();

    let ans = if a[4] - a[0] > k { ":(" } else { "Yay!" };

    println!("{}", ans);
}


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

using namespace std;

const int N = 111;
const int M = 22;
const long long inf = 1e18;

vector<tuple<int, int, int>> g[N][M];

pair<int, int> neutral = make_pair(101, 21);

string s[N];
int cost[N];
int n;

bool is_palindrome(const string &s) {
  int m = (int) s.size();
  for (int i = 0; i + i < m; i++) {
    if (s[i] != s[m - 1 - i]) {
      return false;
    }
  }
  return true;
}

void make() {
  for (int i1 = 0; i1 < 2 * n; i1++) {
    int m1 = (int) s[i1].size();
    for (int j1 = 0; j1 < m1; j1++) {
      if (is_palindrome(s[i1].substr(j1))) {
        g[neutral.first][neutral.second].emplace_back(i1, j1, 0);
      }
      for (int i2 = (i1 < n ? n : 0); i2 < (i1 < n ? 2 * n : n); i2++) {
        int m2 = (int) s[i2].size();
        int p1 = j1;
        int p2 = 0;
        while (p1 < m1 && p2 < m2 && s[i1][p1] == s[i2][p2]) {
          ++p1;
          ++p2;
        }
        if (p1 != m1 && p2 != m2) continue;
        if (p2 != m2) {
          g[i2][p2].emplace_back(i1, j1, cost[i2]);
        } else if (p1 != m1) {
          g[i1][p1].emplace_back(i1, j1, cost[i2]);
        } else {
          g[neutral.first][neutral.second].emplace_back(i1, j1, cost[i2]);
        }
      }
    }
  }
}

long long dist[N][M];

void dijk(pair<int, int> src) {
  memset(dist, -1, sizeof dist);
  dist[src.first][src.second] = 0;
  set<pair<long long, pair<int, int>>> st;
  st.insert({0, src});
  while (!st.empty()) {
    auto v = st.begin()->second;
    st.erase(st.begin());
    int i1 = v.first;
    int j1 = v.second;
    for (auto to : g[i1][j1]) {
      int i2 = get<0>(to);
      int j2 = get<1>(to);
      int cost = get<2>(to);
      if (dist[i2][j2] == -1 || dist[i1][j1] + cost < dist[i2][j2]) {
        if (dist[i2][j2] != -1) {
          st.erase({dist[i2][j2], {i2, j2}});
        }
        dist[i2][j2] = dist[i1][j1] + cost;
        st.insert({dist[i2][j2], {i2, j2}});
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i] >> cost[i];
    s[n + i] = s[i];
    cost[n + i] = cost[i];
    reverse(s[n + i].begin(), s[n + i].end());
  }
  make();
  dijk(neutral);
  long long res = inf;
  for (int i = 0; i < n; i++) {
    if (dist[i][0] != -1) {
      res = min(res, dist[i][0] + cost[i]);
    }
  }
  cout << (res == inf ? -1 : res) << '\n';
  return 0;
}


Measured memory_bytes: 3816
//#pragma GCC optimize(2)
#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<ctime>
#include<queue>
#include<cstdio>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int read(){
    int f=1,x=0;char c=getchar();
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
    while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return f==1?x:-x;
}
#define MAXN 100000
#define INF 0x3f3f3f3f
string S;
map<string,int> Map;
int main(){
	int n=read();
	LL ans=0;
	for(int i=1;i<=n;i++){
		cin>>S;
		sort(S.begin(),S.end());
		ans+=Map[S];
		Map[S]++;
	}
	printf("%lld\n",ans);
    return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

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

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

  vector<int> cnt(100100);
  for(int i = 0; i < 100100; i++){
    cnt[i] = 0;
  }
  int N;
  cin >> N;
  int A;
  for(int i = 0; i < N; i++){
    cin >> A;
    A--;
    cnt[A]++;
  }

  int ans = 0;
  vector<int> vec;
  for(int i = 0; i < 100100; i++){
    if(cnt[i] >= 1){
      ans++;
    }
    if(cnt[i] >= 2){
      vec.push_back(cnt[i]);
    }
  }

  if(vec.size() >= 1){
    sort(vec.begin(), vec.end());

    for(int i = 0; i + 1 < vec.size(); i++){
      vec[i+1] -= (vec[i] - 1);
    }

    ll last = vec[vec.size()-1];

    if(last % 2 == 0){
      ans--;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 768
! 2019.12.8
!
      program answer
      implicit none
      integer,dimension(3) :: A
      integer :: i
!
      read(*,*) (A(i),i=1,3)
      if(A(1)+A(2)+A(3) > 21) then
        write(*,*) 'bust'
      else 
        write(*,*) 'win'
      end if
      end program answer

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

int main() {
  int ans = 0;
  string S, T;
  cin >> S >> T;
  
  for(int i = 0; i < S.size(); i++) {
    if(S[i] != T[i]) {
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3920
#include <iostream>
#include <climits>
#include <algorithm>

#define LL long long
#define INF LONG_LONG_MAX
#define MAXN 1100

LL v[8][MAXN + 1];


LL abs(LL n) {
    if (n < 0)
        return -n;
    return n;
}


int main()
{
    int n, m;
    LL a, b, c;
    std::cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        std::cin >> a >> b >> c;
        for (int j = 0; j <= 1; j++)
            for (int k = 0; k <= 1; k++)
                for (int l = 0; l <= 1; l++) {
                    v[4 * l + 2 * k + j][i] = (2 * j - 1) * a + (2 * k - 1) * b + (2 * l - 1) * c;
                }
    }
    for (int i = 0; i < 8; i++)
        std::sort(v[i] + 1, v[i] + n + 1);
    LL max = -INF/2;
    for (int i = 0; i < 8; i++) {
        LL s = 0;
        for (int j = n; j >= n - m + 1; j--)
            s += v[i][j];
        if (s > max)
            max = s;
    }
    std::cout << max;
}


Measured memory_bytes: 256
for i in range(100):
    a,op,b= input().split()
    a=int(a)
    b=int(b)
    if op=="+":
        print(a+b)
    elif op=="-":
        print(a-b)
    elif op=="*":
        print(a*b)
    elif op=="/":
        print(a//b)
    else:
        break
       


Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int cd(int x){
	int len=0;
	while(x){
		x/=10;
		len++;
	}
	return len;
}
bool prime(ll x){
	for (int i=2;i<=sqrt(x);i++)
		if (x%i==0)return false;
	return true;
}
int main(){
	ll n;
	int i,a,b,ans=11;
	cin>>n;
	if(prime(n)){
		cout<<cd(n);
		return 0;
	}
	
	for (i=sqrt(n);i>=2;i--)
		if(n%i==0){
			a=i;b=n/i;
			//cout<<a<<" "<<b<<" "<<cd(a)<<" "<<cd(b)<<endl;
			ans=min(  max( cd(a), cd(b) ) ,ans);
			break;
		}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256