akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
ll r[2019];

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int a[n+1],t[n+1],pw=1;
  for(int i=1;i<=n;i++) a[i] = s[i-1] - '0';
  t[n]=0;r[t[n]]++;
  for(int i=n-1;i>=0;i--){
    t[i] = (t[i+1] + pw*a[i+1]) % 2019;
    r[t[i]]++;
    pw = (pw*10)%2019;
  }
  int ans=0;
  rep(i,2019) ans+= r[i]*(r[i]-1)/2;
  cout << ans << endl;
}


Measured memory_bytes: 5292
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, K := sc.nextInt(), sc.nextInt()
	X := sc.nextIntSlice(N)

	ans := 0
	for i := 0; i < N; i++ {
		ans += min(2*X[i], 2*abs(X[i]-K))
	}
	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector <int> a(n + 1);
  int ans = 0;
  REP1(i, n) {
	cin >> a[i];
	if (i % 2 && a[i] % 2) {
		ans++;
	  }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define pans cout<<ans<<endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

int main(){
  	string s;cin>>s;
    bool flag=false;
  	for(int i=0;i<3;i++){
      if(s[i]==s[i+1]){
        flag=true;
      }
    }
  int a=0;
  	for(int i=0;i<10000;i++){
      a+=1;
    }
  	if(flag){
      cout<<"Bad"<<endl;
    }else{
      cout<<"Good"<<endl;
    }
  
	return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    string s, t;
    cin >> s >> t;
    for(int i = 0; i < s.size(); ++i) {
        if(s[i] != t[i]) {
            cout << "No" << endl;
            return 0;

        }
    }

    if(s.size() + 1 == t.size()) cout << "Yes";
    else cout << "No";
    cout << endl;

    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
typedef long long ll;
using namespace std;
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    int n,m;
    int size = 1;
    cin >> n >> m;
    if(m == 0){
        cout << 0 << " " << 0 << endl;
        return 0;
    }
    vector<int> wa(100010,0);
    vector<bool> ac(n + 10,false);
    int ac_cnt = 0;
    int wa_cnt = 0;
    rep(i,m){
        int p;
        string s;
        cin >> p >> s;
        if(s == "WA"){
            if(ac.at(p) == false){
                wa.at(p) += 1;
            }
        }else{
            if(ac.at(p) == false){
                ac.at(p) = true;
                ac_cnt += 1; 
            }
        }
    }

    rep(i,n + 1){
        if(ac.at(i) == true && wa.at(i) > 0){
            wa_cnt += wa.at(i);
        }
    }

    cout << ac_cnt << " " << wa_cnt << endl;

    return 0;
}

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

int main() {
    vector<int> a(3);
    rep(i, 3) cin >> a.at(i);
    sort(a.begin(), a.end());
    if(a.at(0) == 5 && a.at(1) == 5 && a.at(2) == 7) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;
class Unionfind
{
public:
  vector<int>parent;
  Unionfind(int n)
  {
    parent=vector<int>(n,-1);
  }
  int root(int a)
  {
    if(parent[a]<0)return a;
    parent[a]=root(parent[a]);
    return parent[a];
  }
  int size(int a)
  {
    return -parent[root(a)];
  }
  bool connect(int a,int b)
  {
    int pa=root(a),pb=root(b);
    if(pa==pb)return false;
    if(size(pa)>size(pb))swap(pa,pb);
    parent[pb]+=parent[pa];
    parent[pa]=pb;
    return true;
  }
};




int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout<<setprecision(10);
  int n,m;
  cin>>n>>m;
  vector<int>p(n+1);
  Unionfind uni(n+1);
  rep(i,n)cin>>p[i+1];
  rep(i,m)
  {
    int x,y;
    cin>>x>>y;
    uni.connect(x,y);
  }
  multimap<int,int>midx;
  rep(i,n)
  {
    midx.emplace(uni.root(i+1),i+1);
  }
  auto itr=midx.begin();
  int res=0;
  while(itr!=midx.end())
  {
    int key=itr->first;
    auto pai=midx.equal_range(key);
    set<int> s1,s2,s3;
    s1.clear();s2.clear();s3.clear();
    while(itr!=pai.second)
    {
      int a=itr->second;
      s1.insert(a);
      s2.insert(p[a]);
      itr++;
    //  cout<<a<<" "<<p[a]<<" ";
    }
    //cout<<endl;
    set_intersection(all(s1),all(s2),inserter(s3,s3.end()));
    res+=s3.size();

  }
  cout<<res<<endl;
  return 0;

}


Measured memory_bytes: 19840
#include <bits/stdc++.h>
using namespace std;
 
vector<pair<long long, long long>>prime_factorize(long long n){
    vector<pair<long long,long long>> res;
    for(long long p = 2; p * p <= n; p++){
        if(n%p!=0)continue;
        int num = 0;
        while(n%p==0){num++;n/=p;}
        res.push_back(make_pair(p,num));
    }
    if(n!=1)res.push_back(make_pair(n,1));
    return res;
}

long long GCD(long long x, long long y){
    return y ? GCD(y,x%y) : x;
} 

int main(){
    long long A,B;
    cin >> A >> B;
    long long G = GCD(A,B);
    auto pf = prime_factorize(G);
    cout << pf.size() + 1 << endl; 
}


Measured memory_bytes: 3608
<?php
fscanf(STDIN, "%d", $n);
$count=0;
for($i=1; $i<=$n; $i++){
	for($j=1; $j<=$n; $j++){
    	for($k=1; $k<=$n; $k++){
        	$count++;
        }
    }
}
echo $count;

Measured memory_bytes: 3576
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<ll> par;
//     vector<ll> siz;
    
//     UnionFind(ll N): par(N), siz(N,1) {
//         for (ll i=0;i<N;i++) par[i] = i;
//     }

//     ll root(ll x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         if (rx == ry) return;
//         // if (siz[rx] < siz[ry]) swap(rx,ry);
//         par[rx] = ry;
//         siz[ry] += siz[rx];
//     }

//     bool same(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         return rx == ry;
//     }

//     ll size(ll x) {
//         return siz[root(x)];
//     }
// };

//     vector<ll> par;
//     vector<ll> siz;
    
//     UnionFind(ll N): par(N), siz(N,1LL) {
//         for (ll i=0;i<N;i++) par[i] = i;
//     }

//     ll root(ll x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//         siz[ry] += siz[rx];
//     }

//     bool same(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         return rx == ry;
//     }

//     ll size(ll x) {
//         return siz[root(x)];
//     }
// };

int main(void) {
    int N, K;
    vector<int> V(110,0);
    cin >> N >> K;
    for (int i=0;i<K;i++) {
        int x;
        cin >> x;
        for (int j=0;j<x;j++) {
            int y;
            cin >> y;
            V[y]++;
        }
    }
    int res = 0;
    for (int i=1;i<=N;i++) if (V[i]==0) res++;
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define INF 1e+9
using namespace std;

int n,imos[301][301] = {};

int calc(int x1,int x2,int y1,int y2){
	return imos[x2 + 1][y2 + 1] - imos[x1][y2 + 1] - imos[x2 + 1][y1] + imos[x1][y1];
}

int main(){
	int ma = -INF;
	cin >> n;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++) cin >> imos[i + 1][j + 1];
	}
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= n;j++) imos[i][j] += imos[i - 1][j] + imos[i][j - 1] - imos[i - 1][j - 1];
	}
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++){
			for(int k = j;k < n;k++) ma = max(ma,max(calc(i,i,j,k),calc(j,k,i,i)));
		}
	}
	for(int i = 0;i < n;i++){
		for(int j = i + 1;j < n;j++){
			int sum[301] = {},tmp = 0,tma = -INF;
			for(int k = 1;k < n;k++){
				sum[k] = tmp + calc(i,j,k,k);
				if(k != n - 1) tmp += calc(i,i,k,k) + calc(j,j,k,k);
			}
			for(int k = n - 2;k >= 0;k--){
				tma = max(tma,sum[k + 1]);
				ma = max(ma,tma - tmp + calc(i,j,k,k));
				tmp -= calc(i,i,k,k) + calc(j,j,k,k);
			}
		}
	}
	cout << ma << endl;
	return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    //方針
    //毎日満足度は低下し続ける
    //満足度上昇の方法はコンテスト開催のみ
    //開催されてないコンテストを放置すると低下が著しくなる
    //実際にコンテストを開いた時の満足度上昇が最大のものを採用してみる→もしかして根本的にダメだから全部0点になってる？
    //低下をなくせる分を上昇と捉えると、c_i(d-last(d,i)) + s_{d,i} だけペイすると考えられる？→あんまり適当じゃない
    //c_iが大きい順に順番に消化していくとか
    int D;cin>>D;
    int c[26],last[26]={},s[365][26];
    REP(i,26) cin>>c[i];
    REP(i,D) REP(j,26) cin>>s[i][j];
    REP(i,D){
        static int gomi = 0;
        gomi++;
        gomi %= 26;
        cout<<gomi+1<<endl;
    }
}


Measured memory_bytes: 3672
#include <iostream>

using namespace std;

typedef long long   ll;
typedef long double ld;

#define rep(i, n)      for (int i = 0; i < (int)(n); ++i)
#define rep3(i, m, n)  for (int i = (m); i < (int)(n); ++i)
#define rrep(i, n)     for (int i = (int)(n)-1; i >= 0; --i)
#define rrep3(i, m, n) for (int i = (int)(n)-1; i >= (m); --i)

#define endl '\n'
#define INF  0x7f7f7f7f7f7f7f7f
#define INFi 0x7f7f7f7f


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

ll solve(string S) {
  ll res=0;
  if (S[0]=='R' || S[1]=='R' || S[2]=='R') res++;
  if (S[0]=='R' && S[1]=='R') res++;
  if (S[1]=='R' && S[2]=='R') res++;
  return res;
}

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

  string S;
  cin >> S;

  auto ans = solve(S);
  cout << ans << endl;

  return 0;
}


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

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

    int N;
    int ans = 0;

    cin >> N;

    vector<int> V(N);
    vector<int> S(N);

    rep(i, N) cin >> V[i];

    rep(i, N)
    {
        int sum = 0;
        for(int j=0; j<V.size(); ++j)
        {
            if (i != j)
            {
                sum += V[i] * V[j];
            }
        }
        S.emplace_back(sum);
    }

    ans = accumulate(S.begin(), S.end(), 0);

    cout << ans/2;

    return 0;
}

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


#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define ll long long
#define pair < int , int > pii



int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	a += b;
	c += d;
	if(a > c)
		cout << "Left" << endl;
	else if(a < c)
		cout << "Right" << endl;
	else 
		cout << "Balanced" << endl;
}

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

vector<int> G[20];
bool visited[20];

vector<int> od;

void dfs(int v){
    visited[v] = true;
    for(int i = 0; i < G[v].size(); i++){
        if(!visited[G[v][i]]) dfs(G[v][i]);
    }
    od.push_back(v);
}

int main(){
    int m, n;
    cin >> m >> n;
    for(int i = 0; i < m; i++) visited[i] = false;
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        G[--b].push_back(--a);
    }
    dfs(1);
    for(int i = 0; i < od.size(); i++){
        cout << od[i]+1 << "\n";
    }
    return 0;
}

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

int N, M;
vector<vector<int>> G;
vector<int> ans;

void bfs(){
    queue<ll> Q;
    vector<ll> color(N, 0);
    Q.push(0);
    color[0]=1;
    while(!Q.empty()){
        ll u = Q.front();
        Q.pop();
        for(int i=0;i<G[u].size();i++) {
            if(color[G[u][i]]==0) {
                Q.push(G[u][i]);
                color[G[u][i]]=1;
                ans[G[u][i]] = u;
            }
        }
        //cout << u << endl;
    }
    for(int i=0;i<N;i++) {
        if(color[i]==0) {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
    for(int i=1;i<N;i++) cout << ans[i]+1 << endl;
}

signed main(){
    cin >> N >> M;
    G.resize(N);
    ans.resize(N);
    for(int i=0;i<M;i++) {
        int s, t;
        cin >> s >> t;
        s--;
        t--;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    //cout << "OK" << endl;
    bfs();
    return 0;
}

Measured memory_bytes: 13680
#include<iostream>
using namespace std;
int main(){
    int W,a,b;
    cin >> W >> a >> b;
    if((b<=a && a<=b+W) || (b<=a+W && a+W<=b+W)){cout << 0;}
    else{
        if(b<a && b+W<a){cout << a-(b+W);}
        if(a+W<b && a+W<b+W){cout << b-(a+W);}
    }
    cout << endl;
    return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,W; cin>>n>>W;
	int V=0;
	vector<int>w(n),v(n);
	for(int i=0;i<n;++i){
		cin>>w.at(i)>>v.at(i);
		V+=v.at(i);
	}
	vector<vector<int64_t>>dp(n+1,vector<int64_t>(V+1,1e9));
	dp.front().front()=0;
	for(int i=0;i<n;++i){
		for(int j=0;j<=V;++j){
			if(j<v.at(i))dp.at(i+1).at(j)=dp.at(i).at(j);
			else dp.at(i+1).at(j)=min(dp.at(i).at(j),dp.at(i).at(j-v.at(i))+w.at(i));
		}
	}
	int ans=0;
	for(int i=V;i>=0;--i){
		if(dp.back().at(i)<=W){
			ans=i;
			break;
		}
	}
	cout<<ans<<"\n"s;
}


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

int main(){
  int n;
  cin >> n;
  if( n%2 != 0 ){
    cout << 0 << endl;
    return 0;
  }
  vector<int> d(n);
  rep(i,n) cin >> d.at(i);
  sort(d.begin(),d.end());
  int mn,mx;
  rep(i,n){
    if( i == n/2 -1 ) mn = d.at(i);
    if( i == n/2 ) mx = d.at(i);
  }
  cout << mx - mn << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;

int main() {
	int a[32] = { 1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51 };
	int n;
	cin >> n;
	cout << a[n-1];
	return 0;
	
}

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

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  vi32 a(n);
  cin >> a;
  map<int, int> se;
  rep(i, n) {
    a[i] -= i;
    se[a[i]] += 1;
  }
  i64 ans = 0;
  int now = 0;
  rep(i, n) {
    int now = a[i] + i * 2;
    se[a[i]] -= 1;
    ans += se[-now];
  }
  cout << ans << endl;
}


Measured memory_bytes: 21148
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;


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


int main(){
    int M, D;

    cin >> M >> D;

    int res = 0;
    for(int i = 1; i <= M; i++){
        for(int j = 1; j <= D; j++){
            if(j % 10 >= 2 && j / 10 >= 2){
                if((j % 10) * (j / 10) == i){
                    res++;
                }
            }
        }
    }

    cout << res << endl;



    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author c0117321c5
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        double probability = 0.0;
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        for (double i = 1; i <= a; i++) {
            if (i % 2 == 1) {
                probability += 1.0;
            }
        }
        System.out.println(probability / a);

    }

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int N;cin>>N;
    vll A(N);
    for(int i=0;i<N;i++)cin>>A[i];
    sort(ALL(A));
    cout<<A[N-1]-A[0]<<endl;
}

Measured memory_bytes: 3604
// include headers{{{
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*}}}*/
# define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

template<typename T>
string join(vector<T> inputs, string delimiter) {
    string result = inputs.front();
    size_t length = inputs.size();

    for (int i=0; i<length-1; ++i) {
        result += delimiter + (string)inputs[i];
    }

    return result;
}

int main() {
    int d; cin >> d;
    cout << "Christmas";
    for (int i=24-d; i>=0; i--) cout << " Eve";
    cout << endl;
    return 0;
}



Measured memory_bytes: 888
while True:
    H,W=map(int,input().split())
    if H==0:
        break
    else:
        for i in range(H):
            if i%2==0:
                for j in range(W):
                    if j%2==0:
                        print('#',end='')
                        j+=1
                    else:
                        print('.',end='')
                        j+=1
                
                print()
                    
            else:
                for j in range(W):
                    if j%2==0:
                        print('.',end='')
                        j+=1
                    else:
                        print('#',end='')
                        j+=1

                print()
        print()


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

int main(){
  int n, k;
  cin >> k >> n ;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  a.push_back(a[0]+k);
  int l = 0;
  rep(i,n){
    l = max(l,a[i+1]-a[i]);
  }
  int ans = k-l;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;
const double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<int>v(100001);
	for (int i = 0; i < N; i++) {
		cin >> M;
		v[M]++;
	}
	for (int i = 1; i <= 100000; i++)v[i] += v[i - 1];
	for (int i = 1; i <= 100000; i++)K += v[i] * 2 == N;
	cout << K << endl;
}

Measured memory_bytes: 640
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] skewer = new int[2*N];
        for(int n=0;n<2*N;n++) skewer[n]=sc.nextInt();
        Arrays.sort(skewer);
        int ans = 0;
        for(int n=0;n<N;n++){
        	ans += skewer[2*n];
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
//Code By CXY07
#include<bits/stdc++.h>
using namespace std;

//#define FILE
#define int long long
//#define LL long long
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fst first
#define scd second
#define inv(x) ksm((x),mod - 2)
#define lowbit(x) ((x) & (-(x)))

const int MAXN = 2e5 + 10;
const int INF = 2e12;
const double PI = acos(-1);
const double eps = 1e-6;
//const int mod = 1e9 + 7;
//const int mod = 998244353;
//const int G = 3;

int n,ans,mx = -INF,mn = INF;
int x[MAXN],y[MAXN];

template<typename T> inline void read(T &a) {
	a = 0; char c = getchar(); int f = 1;
	while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
	while(c >= '0' && c <= '9') {a = a * 10 + (c ^ 48); c = getchar();}
	a *= f;
}

signed main () {
#ifdef FILE
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	read(n);
	for(int i = 1,a,b;i <= n; ++i) {
		read(a); read(b);
		x[i] = a + b;
		y[i] = a - b;
	}
	for(int i = 1;i <= n; ++i) 
		mx = max(mx,x[i]),mn = min(mn,x[i]);
	ans = abs(mx - mn);
	mx = -INF,mn = INF;
	for(int i = 1;i <= n; ++i)
		mx = max(mx,y[i]),mn = min(mn,y[i]);
	ans = max(ans,abs(mx - mn));
	printf("%lld\n",ans);
	return 0;
}



Measured memory_bytes: 6868
#include<bits/stdc++.h>
#define LL long long
#define L(x) x<<1    //左儿子 x*2
#define R(x) x<<1|1 //右儿子  x*2+1
using namespace std;
int a[10];
int main() {
    int n;
    while(cin>>n)
    {
        memset(a,0,sizeof(a));
        for(int i=1;i<=n;i++)
        {
            int t;
            cin>>t;
            if(t>=1&&t<=399)
                a[0]++;
            else if(t>=400&&t<=799)
                a[1]++;
            else if(t>=800&&t<=1199)
                a[2]++;
            else if(t>=1200&&t<=1599)
                a[3]++;
            else if(t>=1600&&t<=1999)
                a[4]++;
            else if(t>=2000&&t<=2399)
                a[5]++;
            else if(t>=2400&&t<=2799)
                a[6]++;
            else if(t>=2800&&t<=3199)
                a[7]++;
            else if(t>=3200)
                a[8]++;

        }
        int ans=0;
        for(int i=0;i<8;i++)
            if(a[i]!=0)
                ans++;
        if(!a[8])
        {
            cout<<ans<<" "<<ans<<endl;
        }
        else
        {
            cout<<max(1,ans)<<" "<<ans+a[8]<<endl;
        }
    }

    return 0;
}


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


ll knapsack(ll w, ll n, ll weight[], ll value[])
{
	ll dp[n + 1][w + 1];
	memset(dp, 0, sizeof(dp));
	for (ll i = 1; i <= n; i++) {
		for (ll j = 1; j <= w; j++) {
			if (j - weight[i - 1] >= 0)
				dp[i][j] = max(dp[i - 1][j], value[i - 1] + dp[i - 1][j - weight[i - 1]]);
			else
				dp[i][j] = dp[i - 1][j];
		}
	}
	return dp[n][w];
}

int main() {

//#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

	ll n, w;
	cin >> n >> w;

	ll weight[n], value[n];
	for (ll i = 0; i < n; i++)	cin >> weight[i] >> value[i];
	//memset(dp, -1, sizeof(dp));

	cout << knapsack(w, n, weight, value) << endl;

	return 0;
}

Measured memory_bytes: 79104
// https://www.creativ.xyz/chu-liu-edmonds-522

#include <bits/stdc++.h>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
typedef pair<int,int> P;
typedef long long ll;
#define mp make_pair
typedef pair<int, pair<int, int> > Edge;
#define INF 1e17

long long Chu_Liu_Edmonds(vector<Edge> edges, int V, int start) {
	vector<P> mins(V, mp(INF, -1));	// その頂点に入る最小辺の(辺コスト, 始点)
	rep(i, edges.size()) {
		Edge edge = edges[i];
		mins[edge.second.second] = min(mins[edge.second.second], mp(edge.first, edge.second.first));
	}
	mins[start] = mp(-1, -1);	// 始点には辺が入らない

	vector<int> group(V, 0);
	vector<bool> isCycle(V, false);	// 頂点が縮約されたもの（元閉路）かどうか
	int count = 0;	// グループ分けで割り振る番号＝縮約後の頂点数

	vector<bool> used(V, false);
	rep(i, V) {
		if (used[i])continue;
		vector<int> chain;
		int cursor = i;
		while (cursor != -1 && !used[cursor]) {
			// 頂点iから元を辿っていく
			used[cursor] = true;
			chain.push_back(cursor);
			cursor = mins[cursor].second;	// 頂点cursorに入ってくる位置へ移動
		}
		if (cursor != -1) {
			// 閉路発見の可能性あり
			// chainの現cursor以降が閉路
			bool inCycle = false;	// 閉路に突入したかどうかを表すフラグ
			rep(j, chain.size()) {
				group[chain[j]] = count;
				if (chain[j] == cursor) {
					// ここから閉路
					isCycle[count] = true;
					inCycle = true;
				}
				if (!inCycle)count++;	// 閉路内でなければ別グループ扱い
			}
			if (inCycle)count++;
		}
		else {
			// 根で終了した＝閉路見つからず
			// chain内の頂点すべてを単独のグループに分ける
			rep(j, chain.size()) {
				group[chain[j]] = count;
				count++;
			}
		}
	}
	// この時点でグループ分けが終了している

	if (count == V) {
		// 縮約で頂点数が不変＝閉路が無い
		ll ans = 1;	// 根のコスト-1を打ち消すための1
		rep(i, V) {
			ans += mins[i].first;
		}
		return ans;
	}

	// 縮約した閉路のコスト合計を計算
	ll res = 0;
	rep(i, V) {
		if (i != start && isCycle[group[i]]) {
			res += mins[i].first;
		}
	}

	// 閉路が存在するので、新たにグラフを構成
	vector<Edge> newEdges;
	rep(i, edges.size()) {
		Edge edge = edges[i];
		int to = edge.second.second;
		int gfrom = group[edge.second.first];
		int gto = group[edge.second.second];
		if (gfrom == gto) {
			// 始点と終点が同じグループ（同じ閉路）なら、追加せず
			continue;
		}
		else if (isCycle[gto]) {
			// 終点が縮約後の閉路なら、コストを計算し直して追加
			newEdges.push_back(mp(edge.first - mins[to].first, mp(gfrom, gto)));
		}
		else {
			// それ以外は、単純に追加
			newEdges.push_back(mp(edge.first, mp(gfrom, gto)));
		}
	}

	return res + Chu_Liu_Edmonds(newEdges, count, group[start]);
}

int main() {
    int V, E, r;
    cin >> V >> E >> r;
    vector<Edge> es;
    rep(i, E) {
        int s, t, w;
        cin >> s >> t >> w;
        es.push_back(mp(w, mp(s, t)));
    }
 
    cout << Chu_Liu_Edmonds(es, V, r) << endl;
 
    return 0;
}


Measured memory_bytes: 3668
from collections import deque
h, w = map(int, input().split())
que = deque()
data = []

for ln in range(h):
    line = list(input().rstrip())
    data.append(line)
    for r, letter in enumerate(line):
        if letter == '#':
            que.append((ln, r))

count = 0
while len(que) > 0:
    count += 1
    next = deque()
    while len(que) > 0:
        row, col = que.popleft()
        for r, c in [(row - 1, col), (row + 1, col), (row, col - 1), (row, col + 1)]:
            if 0 <= r < h and 0 <= c < w and data[r][c] == '.':
                next.append((r, c))
                data[r][c] = '#'
    que = next

print(count - 1)


Measured memory_bytes: 116444
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>
   
using namespace std;

#define mod 1000000007

int main()
{
    int n;
    cin >> n;
    int p[100001];
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    vector<int> result(100001, mod);
    priority_queue<pair<int, int> > qu;
    qu.push(make_pair(0, 0));
    while(!qu.empty()){
        int nowplace = (qu.top()).second;
        int nowcost = (qu.top()).first;
        // cout << nowplace << " " << -nowcost << endl;
        qu.pop();
        if(nowplace == n - 1){
            cout << -nowcost << endl;
            break;
        }
        if(result[nowplace] < -nowcost) continue;
        result[nowplace] = -nowcost;
        if(p[nowplace] == 0){
            for(int j = 1; j <= 6; j++){
                int nextplace = min(nowplace + j, n - 1);
                if(result[nextplace] > -nowcost + 1){
                    result[nextplace] = -nowcost + 1;
                    qu.push(make_pair(nowcost - 1, nextplace));
                }
            }
        } else {
            int nextplace = min(nowplace + p[nowplace], n - 1);
            if(result[nextplace] > -nowcost){
                result[nextplace] = -nowcost;
                qu.push(make_pair(nowcost, nextplace));
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
int main()
{
  ll n;cin >> n;
  ll res = 0;
  for(ll i = 1;i <= n;++i) {
    if(i % 3 !=0 && i % 5 != 0) {
      res += i;
    }
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vmll;

ll kp01(vmll &dp, vi wei, vi val, int i, int j)
{
    if (i == 0 || j <= 0)
        return 0;

    if (dp[i - 1][j] == -1)
        dp[i - 1][j] = kp01(dp, wei, val, i - 1, j);

    if (j >= wei[i - 1])
    {
        if (dp[i - 1][j - wei[i - 1]] == -1)
            dp[i - 1][j - wei[i - 1]] = kp01(dp, wei, val, i - 1, j - wei[i - 1]);
        return dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - wei[i - 1]] + val[i - 1]);
    }
    else
        return dp[i][j] = dp[i - 1][j];
}

int main()
{
    if (fopen("Test.INP", "r"))
        freopen("Test.INP", "r", stdin);

    int n, k;
    cin >> n >> k;

    vi wei(n), val(n);
    for (int i = 0; i < n; ++i)
        cin >> wei[i] >> val[i];

    vmll dp(n + 1);
    for (int i = 0; i <= n; ++i)
        dp[i].assign(k + 1, -1);

    cout << kp01(dp, wei, val, n, k);
    return 0;
}


Measured memory_bytes: 79488
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int N;cin>>N;
	int A[N],B[N];
    pair<int,int> C[N],D[N];
	rep(i,0,N) cin>>A[i];
    rep(i,0,N) cin>>B[i];
	int ans=inf;
	rep(i,0,(1<<N)){
		deque<pair<int,int>> even,odd;
		rep(j,0,N){
			if(i&(1<<j)){
                if(j%2==0) even.push_back({A[j],j});
                else even.push_back({B[j],j});
            }else{
                if(j%2) odd.push_back({A[j],j});
                else odd.push_back({B[j],j});
            }
		}
		if(odd.size()!=N/2) continue;
		sort(even.begin(),even.end());
		sort(odd.begin(),odd.end());
  		pair<int,int> vp[N];
		rep(j,0,N){
			if(j%2==0) vp[j]=even[j/2];
            else vp[j]=odd[j/2];
		}
        bool flag=false;
        rep(j,0,N-1){
			if(vp[j].first > vp[j+1].first) flag=true;
		}
        if(flag) continue;
		int cnt=0;
		rep(j,0,N)rep(k,0,j){
			if(vp[j].second < vp[k].second) cnt++;
		}
		ans=min(ans,cnt);
	}
	if(ans==inf) cout<<-1<<endl;
	else cout<<ans<<endl;
}

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

const int MAX = 1e5;
vector<int> G[MAX]; // G:頂点数がnのグラフを表す隣接リスト
vector<int> color(MAX);
list<int> topo;

void dfs(int v) {
  color[v] = 1;
  for (int i = 0; i < G[v].size(); i++) {
    if (color[G[v][i]] == 0) dfs(G[v][i]);
  }
  color[v] = 2;
  topo.emplace_front(v);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  // 無向(有向)グラフの隣接リスト
  int n, m; // n:頂点数 m:追加した辺の数
  cin >> n >> m;
  
  vector<bool> rootcheck(n, true);
  for (int i = 0; i < n - 1 + m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    G[u].emplace_back(v);
    // G[v].emplace_back(u); // 有向グラフではこの行をコメントアウト
    rootcheck.at(v) = false;
  }
  
  int begin;
  for (int i = 0; i < n; i++) {
    if (rootcheck.at(i)) begin = i;
  }
  
  dfs(begin);
  
  vector<int> par(n);
  
  for (auto it = topo.begin(); it != topo.end(); it++) {
    for (int i = 0; i < G[*it].size(); i++) {
      par[G[*it][i]] = *it;
    }
  }
  
  par[*topo.begin()] = -1;
  
  for (int i = 0; i < n; i++) cout << par[i] + 1 << '\n';
}

Measured memory_bytes: 14976
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    long long  n;
    cin >> n;
    long long a[90];
    long long money = 1000;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    for(int i = 1; i < n; i++){
        long long kabu = 0;
        if(a[i] < a[i+1]){
            kabu = money / a[i];
            money += (a[i+1]-a[i]) * kabu;
        }
    }
    cout << money << endl;
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    vector<ll> x(3);
    REP(i, 3) cin >> x[i];
    sort(x.begin(), x.end());

    if(x[0]==x[1] && x[1]!=x[2]){
    	cout << "Yes" << endl;
    }else if(x[0]!=x[1] && x[1]==x[2]){
    	cout << "Yes" << endl;
    }else{
    	cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
const int MAXN=1e5+7;
int w[MAXN];
int n,k;
bool check (int p) {
	int pos=0;
	for (int i=0;i<k;i++) {
		int cur=0;
		while (cur+w[pos]<=p) {
			cur+=w[pos++];
			if (pos==n) return true;
		}
	}
	return false;
}
int main () {
	int l=0,r=1e9,mid;
	scanf ("%d%d",&n,&k);
	for (int i=0;i<n;i++) {
		scanf ("%d",&w[i]);
		if (w[i]>l) l=w[i];
	}
	while (r-l>=1) {
		mid=(l+r)>>1;
		if (check(mid)) r=mid;
		else l=mid+1;
	}
	printf ("%d\n",l);
    return 0;
}


Measured memory_bytes: 3120
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
using namespace std;
int x[1000005];
long long int dp[1000005];
int main(){
	int n,e,t;
	scanf("%d %d %d",&n,&e,&t);
	for(int i=0;i<n;i++)
	dp[i]=1e18;
	dp[0]=t;
	scanf("%d",&x[0]);
	for(int i=1;i<n;i++)
	scanf("%d",&x[i]),x[i]-=x[0];
	x[0]=0;
	int last=0,lastt=0;
	for(int i=0;i<n;i++){
		dp[i]=max(t,x[i]*2);
		if(lastt!=0)
		dp[i]=min(dp[i],(x[i]-x[last+1])*2+dp[last]);
		for(int j=lastt;j<i;j++){
			dp[i]=min(dp[i],max(t,(x[i]-x[j+1])*2)+dp[j]);
			if((x[i]-x[j+1])*2<t)
			{	
				lastt=j;
				break;
			}
			if(dp[i]==(x[i]-x[j+1])*2+dp[j])
			last=j;
		}
		//printf("%d %lld\n",i,dp[i]);
	}
	printf("%lld",dp[n-1]+e);
}

Measured memory_bytes: 1408
n, m = gets.split.map(&:to_i)

array = []
m.times do
  ks = gets.split.map { |i| i.to_i - 1 }
  ks.shift
  array << ks
end

p = gets.split.map(&:to_i)


count = 0
whole = 2 ** n
whole.times do |i|
  switch = []
  n.times do
    switch << i % 2
    i /= 2
  end

  is_good = true

  m.times do |k|
    small_count = 0
    array[k].each do |k1|
      if switch[k1] == 1
        small_count += 1
      end

    end

    unless (small_count % 2 ) == p[k]
      is_good = false
    end
  end

  if is_good
    count += 1
  end
end

puts count

Measured memory_bytes: 1916
a,b,c,d,e,f=map(int,input().split())

waterL=[]
ac=0
while a*100*ac<=f:
    bc=0
    while a*100*ac+b*100*bc<=f:
        waterL.append(a*100*ac+b*100*bc)
        bc += 1
    ac += 1
waterL.remove(0)
ma=0
ms=0
mw=0
for w in waterL:
    lim=w/100*e
    cc=0
    while c*cc<=lim and c*cc+w<=f:
        dc=0
        while cc*c+dc*d<=lim and c*cc+d*dc+w<=f:
            s=c*cc+d*dc
            per=s/(w+s)
            if per>=ma:
                ma=per
                ms=s
                mw=w
            dc += 1
        cc += 1
print(int(ms+mw),int(ms))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll n,a,b; cin>>n>>a>>b;
	ll L = a*(n-1)+b;
	ll R = a+b*(n-1);
	cout<<max(R-L+1,0LL)<<'\n';
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)


prime_memo = Dict{Int, Bool}()
like_memo = Dict{Int, Bool}()

function isPrime(n)
    if haskey(prime_memo, n)
        return prime_memo[n]
    end

    if n == 1
        return false
    end
    for i in 2:sqrt(n)
        if n % i == 0
            prime_memo[n] = false
            return false
        end
    end
    prime_memo[n] = true
    return true
end


function isLike(n)
    if haskey(like_memo, n) 
        return like_memo[n]
    end
    like_memo[n] =  isPrime(n) && isPrime((n + 1) ÷ 2)
    return like_memo[n] 
end



function main()
    A = Array{Int}(undef, 10^5)
    for i in 1:10^5 - 1
        if isLike(i)
            A[i + 1] = A[i] + 1
        else
            A[i + 1] = A[i]
        end
    end
    Q = parseInt(readline())
    for _ in 1:Q
        l, r = parseMap(split(readline()))
        if l == 1
            println(A[r])
        else
            println(A[r + 1] - A[l])
        end

    end
end


main()

Measured memory_bytes: 223092
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Sat Dec 22 00:53:43 2018
//
package main

import "fmt"

func main() {
	var N, K int
	fmt.Scan(&N, &K)
	ans := 0
	for a := 1; a <= K; a++ {
		b := K - a
		if b == 0 {
			b = K
		}
		if K-a != K-b {
			continue
		}
		c := K - b
		if c == 0 {
			c = K
		}
		if a > N || b > N || c > N {
			continue
		}
		ans += (1 + (N-a)/K) * (1 + (N-b)/K) * (1 + (N-c)/K)
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
//
// Created by Akifumi Ohata on 2017/10/01.
//


#include<iostream>
#include <vector>
#include <numeric>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>

using namespace std;

using ll =  long long int;

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

    int N;

    ll MOD=1000000007;


    cin >> N ;


    int tim=0;
    std::vector<int> Array;

    for(int i=1;i<=N;i++){

        int tmp;
        cin >>tmp;

        if(tmp==i){
            tim++;

        }else {
            Array.push_back(tim);
            tim = 0;
        }


        if(i==N && tim>0){
            Array.push_back(tim);
        }

    }


    int sum=0;
    for(const int time : Array){

        sum+=(time+1)/2;

    }


    cout  << sum << endl ;

    return 0;
}

Measured memory_bytes: 892
#include <stdio.h>

int main(void)
{
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  int max = a;
  if (b > max)
    max = b;
  if (c > max)
    max = c;
  printf("%d\n", max * 10 + a + b + c - max);
}


Measured memory_bytes: 128
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7
res = 0


def resolve():
    def dfs(v, A):
        global res
        if len(A) == n:
            total = 0
            for a, b, c, d in query:
                if A[b - 1] - A[a - 1] == c:
                    total += d
            res = max(res, total)
        else:
            for i in range(v, m + 1):
                A.append(i)
                dfs(i, A)
                A.pop()

    n, m, q = map(int, input().split())
    query = [list(map(int, input().split())) for _ in range(q)]
    dfs(1, [])
    print(res)


if __name__ == '__main__':
    resolve()


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

int main(void)
{
    int K; cin >> K;
    deque<string> dq;
    int count = 0;
    for(int i=1; i <= 9; i++){
        dq.emplace_back(to_string(i));
    }

    string naw;
    while(count < K){
        naw = dq.front();
        dq.pop_front();
        count++;
        int nawlast = naw.length() - 1;
        int nawlast_r = naw[nawlast] - '0' + 1;
        int nawlast_l = naw[nawlast] - '0' - 1;

        if( nawlast_l >= 0){
            dq.emplace_back( (naw + to_string(nawlast_l)) );
        }
        dq.emplace_back( (naw + naw[nawlast] ));
        if( nawlast_r < 10){
            dq.emplace_back( (naw + to_string(nawlast_r)) );
        }

    }

    cout << naw << endl;
}

Measured memory_bytes: 9728
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N, A, B = lr()
    r = N%(A+B)
    if r <= A:
        print(N//(A+B)*A+r)
    else:
        print(N//(A+B)*A+A)
resolve()

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

int main(){
   int N;
   cin>>N;
   int d[N];
    for(int i=0;i<N;i++){
       cin>>d[i];
    }
    int sum=0;
    for(int i=0;i<N-1;i++){
     for(int j=i+1;j<N;j++){
        sum+=d[i]*d[j];
      }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int a;
	string s;
	cin>>a;
	cin>>s;
	
	if(a >= 3200) cout<<s<<endl;
	else cout<<"red"<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
B = list(map(int, input().split()))

ans = []
for i in range(N):
  flag = True
  for j in range(N-i):
    n = N-i-j
    if B[n-1] == n:
      ans.append(n)
      B.pop(n-1)
      flag = False
      break
  if flag:
    break
    
if flag:
  print(-1)
else:
  ans.reverse()
  for i in range(N):
    print(ans[i])

Measured memory_bytes: 9156