akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;

const int INF = 1001001001;
const ll INFLL = 1001001001001001001LL;


template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }


int main() {


	
	int N;

	scanf("%d", &N);


	//A:0 [1 2 3 ... N-1 N] 0
	vector<int> A;
	A.push_back(0);
	
	for (int i = 1; i <= N; i++) {
		int tmp;
		scanf("%d", &tmp);
		A.push_back(tmp);
	}

	A.push_back(0);

	ull ans = 0;

	//TotalCost

	for (int i = 0; i <= N; ++i) {
		ans += abs(A[i] - A[i + 1]);
	}

	for (int i = 1; i <= N; ++i) {
		ull pans = 0;
		if (A[i - 1] <= A[i] && A[i] <= A[i + 1]) {
			pans = ans;
		}
		else if (A[i + 1] <= A[i] && A[i] <= A[i - 1]) {
			pans = ans;
		}
		else if (A[i - 1] <= A[i + 1] && A[i + 1] <= A[i]) {
			pans = ans - 2 * abs(A[i + 1] - A[i]);
		}
		else if (A[i - 1] >= A[i + 1] && A[i + 1] >= A[i]) {
			pans = ans - 2 * abs(A[i + 1] - A[i]);
		}
		else if (A[i - 1] <= A[i] && A[i - 1] >= A[i + 1]) {
			pans = ans - 2 * abs(A[i - 1] - A[i]);
		}
		else if (A[i - 1] >= A[i] && A[i - 1] <= A[i + 1]) {
			pans = ans - 2 * abs(A[i - 1] - A[i]);
		}
		else {
			assert(true);
		}
		printf("%llu\n", pans);
	}





	return 0;
}

Measured memory_bytes: 1784
arr = list(map(int,input().split()))
ans = 0
arr.sort()
while arr[2] - arr[0] >= 2:
    arr[0] += 2
    ans += 1

while arr[2] - arr[1] >= 2:
    arr[1] += 2
    ans += 1
arr.sort()
if arr[0] != arr[1]:
    ans += 2
else:
    if arr[0] != arr[2]:
        ans += 1
print(ans)

Measured memory_bytes: 3064
s=gets.chomp
h = Hash.new(-3)
s.size.times{|i|
  if h[s[i]]+2 >= i then
    puts [h[s[i]]+1, [h[s[i]]+3,i+1].min]*' '
    exit
  else
    h[s[i]] = i
  end
}
puts [-1, -1]*' '

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,h;
  long a,r = 0;
  cin >> n >> h;
  
  if(n <= h){
    cout << 0 << endl;
    return 0;
  }
  
  vector<long> vec(n);
  for(int i = 0; i < n; i++){
    cin >> a;
    vec.at(i) = a;
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());

  for(int i = h; i < n; i++){
    r += vec.at(i);
  }

  cout << r << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>

using namespace std;

int book[12][13];

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

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


    bool exist = false;
    int price = 100100100;
    for(int bit=0; bit < (1<<N); ++ bit){
        int tmp_price = 0;
        vector<int> status(M) ;

        for(int i=0; i<N; ++i){
            if(bit & (1<<i)){
                tmp_price += book[i][0];
                for(int j=0; j<M; ++j){
                    status[j] += book[i][j+1];
                }

            }
        }

            //hantei
            bool flag = true;
            for(int k=0; k<M; ++k){
                if( status[k] < X){
                    flag = false;
                }
            }
            if(flag){
                exist = true;
                price = min(price, tmp_price);

            }
    }

    if(exist){
        cout << price << endl;
    }else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 3540
{-# LANGUAGE BangPatterns               #-}
{-# LANGUAGE DerivingStrategies         #-}
{-# LANGUAGE FlexibleContexts           #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE RankNTypes                 #-}
{-# LANGUAGE ScopedTypeVariables        #-}
{-# LANGUAGE TypeApplications           #-}
{-# LANGUAGE UndecidableInstances       #-}
import           Control.Monad.State
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import qualified Data.Vector.Algorithms.Heap as V
import qualified Data.Vector.Unboxing        as VU

main :: IO ()
main = do
  n <- readLn @Int
  av <- readLnAsUVecWith unconsInt n

  av' <- VU.thaw av
  V.sortBy (flip compare) av'
  avec <- VU.freeze av'

  print $ case solve n avec of
    Just x  -> x
    Nothing -> 0


solve :: Int -> VU.Vector Int -> Maybe IntMod
solve = go 1
  where go :: IntMod -> Int -> VU.Vector Int -> Maybe IntMod
        go a 0 _ = Just a
        go a 1 w = if w VU.! 0 == 0 then Just a else Nothing
        go a m w = let fs = VU.take 2 w
                   in if fs VU.! 0 == m-1 && fs VU.! 1 == m-1
                      then go (a*2) (m-2) (VU.drop 2 w)
                      else Nothing


modulus :: Int
-- modulus = 10^9 + 7
modulus = 1000000007

newtype IntMod = IntMod Int deriving Eq deriving newtype VU.Unboxable

fromIntegralIntIntMod :: Int -> IntMod
fromIntegralIntIntMod n = IntMod (n `mod` modulus)
{-# RULES
"fromIntegral/Int->IntMod"
    fromIntegral = fromIntegralIntIntMod
#-}

instance Show IntMod where
  show (IntMod x) = show x

instance Num IntMod where
  IntMod x + IntMod y = IntMod ((x + y) `mod` modulus)
  IntMod x - IntMod y = IntMod ((x - y) `mod` modulus)
  IntMod x * IntMod y = IntMod ((x * y) `mod` modulus)
  fromInteger n = IntMod (fromInteger (n `mod` fromIntegral modulus))
  abs = undefined
  signum = undefined

unconsInt :: StateT BS.ByteString Maybe Int
unconsInt = StateT $ BS.readInt . BS.dropWhile isSpace

readLnAsUVecWith :: VU.Unboxable a => StateT BS.ByteString Maybe a -> Int -> IO (VU.Vector a)
readLnAsUVecWith !st !n = VU.unfoldrN n (runStateT st) <$> BS.getLine


Measured memory_bytes: 10600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int sort(const void *a, const void *b){
    if( *(long long int*)a - *(long long int*)b < 0 )
        return -1;
    if( *(long long int*)a - *(long long int*)b > 0 )
        return 1;
    return 0;
}

int main(void){
    int n,ans=1;
    scanf("%d",&n);
    long long a[n];
    for (int i=0; i<n; i++){
        scanf("%lld",&a[i]);
    }
    qsort (a,n,sizeof(long long),sort);
    long long sum[n];
    sum[0]=a[0];
    for (int i=1; i<n; i++){
        sum[i]=a[i]+sum[i-1];
    }
    for (int i=n-2; i>=0; i--){
        if (sum[i]*2>=a[i+1]){
            ans++;
        } else {
            break;
        }
    }
    printf("%d\n",ans);
	return 0 ;
}

Measured memory_bytes: 1788
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int n,x;
    while(true){
        scanf("%d %d",&n, &x);
        if(n==0&&x==0)break;
        int ans = 0;
        for(int i = 1; i<n; ++i){
            for(int j = i+1; j<n; ++j){
                if(x-i-j>j && x-i-j<=n)ans++;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}



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

int H, W;
vector<vector<int>> space;

int dp[300][300][599];

int move(int E869120_y, int square1001_y, int progress){
    if(dp[E869120_y][square1001_y][progress] != -1){
        return dp[E869120_y][square1001_y][progress];
    }else{
        vector<int> E869120_can_move_y;
        if(E869120_y != H - 1){
            E869120_can_move_y.push_back(E869120_y + 1);
        }
        if(progress - E869120_y != W - 1){
            E869120_can_move_y.push_back(E869120_y);
        }
        vector<int> square1001_can_move_y;
        if(square1001_y != H - 1){
            square1001_can_move_y.push_back(square1001_y + 1);
        }
        if(progress - square1001_y != W - 1){
            square1001_can_move_y.push_back(square1001_y);
        }
        int ans = 0;
        for(int i = 0; i < E869120_can_move_y.size(); i++){
            for(int j = 0; j < square1001_can_move_y.size(); j++){
                ans = max(ans, move(E869120_can_move_y[i], square1001_can_move_y[j], progress + 1));
            }
        }
        if(E869120_y == square1001_y){
            return dp[E869120_y][square1001_y][progress] = space[E869120_y][progress - E869120_y] + ans;
        }else{
            return dp[E869120_y][square1001_y][progress] = space[E869120_y][progress - E869120_y] + space[square1001_y][progress -  square1001_y] + ans;
        }
    }
}

int main(){
    cin >> H >> W;
    space.resize(H);
    for(int i = 0; i < H; i++){
        space[i].resize(W);
        for(int j = 0; j < W; j++){
            cin >> space[i][j];
        }
    }
    for(int i = 0; i < 300; i++){
        for(int j = 0; j < 300; j++){
            for(int k = 0; k < 599; k++){
                dp[i][j][k] = -1;
            }
        }
    }
    cout << move(0, 0, 0) << endl;
}



Measured memory_bytes: 211072
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <tuple>
#include <iomanip>

using namespace std;

template< typename T >
struct edge {
    int src, to;
    T cost;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}

    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    edge &operator=(const int &x) {
        to = x;
        return *this;
    }

    operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;

template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
    vector< T > dist(g.size(), numeric_limits< T >::max());
    dist[s] = 0;

    using Pi = pair< T, int >;
    priority_queue< Pi, vector< Pi >, greater< Pi > > que;
    que.emplace(dist[s], s);

    while(!que.empty()) {
        T cost;
        int idx;
        tie(cost, idx) = que.top();
        que.pop();
        if(dist[idx] < cost) continue;
        for(auto &e : g[idx]) {
            auto next_cost = cost + e.cost;
            if(dist[e.to] <= next_cost) continue;
            dist[e.to] = next_cost;
            que.emplace(dist[e.to], e.to);
        }
    }
    return dist;
}

int main(void) {
    long double sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int N;
    cin >> N;
    vector<long double> x(N+2), y(N+2), r(N+2);
    for(int i=1; i<=N; i++) {
        cin >> x[i] >> y[i] >> r[i];
    }
    x[0] = sx;
    x[N+1] = tx;
    y[0] = sy;
    y[N+1] = ty;

    WeightedGraph<long double> g(N+2);
    for(int i=0; i<N+2; i++) {
        for(int j=0; j<N+2; j++) {
            if(i == j) continue;
            g[i].emplace_back(j, max(0.0L, hypotl(x[j]-x[i], y[j]-y[i]) - r[i] - r[j]));
        }
    }

    cout << setprecision(15);
    cout << dijkstra(g, 0).back() << endl;
    return 0;
}


Measured memory_bytes: 42604
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
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; }

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

    int N; cin >> N;
    int A[N][15][15];

    REP(i, N) {
        int a; cin >> a;
        A[i][0][0] = a;
        int x, y;
        REP (j, a) {
            cin >> x >> y;
            A[i][1][j] = x - 1;
            A[i][2][j] = y;
        }
    }

    int ans = 0;
    REP(bit, (1<<N)) {
        bool is_break = false;
        REP(i, N) {
            if (!(bit & (1<<i))) continue;
            REP(j, A[i][0][0]) {
                ll ti = A[i][1][j];
                ll t = A[i][2][j];
                if (t && !(bit & (1<<ti))) {
                    is_break = true;
                    break;
                } else if (!t && (bit & (1<<ti))) {
                    is_break = true;
                    break;
                }
            }
        }
        if (is_break) continue;
        // cout << "here!" << bit << endl;
        chmax(ans, __builtin_popcount(bit));
    }
    cout << ans << endl;

    return 0;
}


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

typedef long long ll;

int n;

vector<ll> a;

ll ldp[100010];
ll rdp[100010];



int main()
{
	cin >> n;

	a.resize(n * 3);

	for(ll& x : a)
	{
		cin >> x;
	}
	
	//left
	{
		priority_queue<ll,vector<ll>,greater<ll>> left;
		for(int i = 0;i < n;i++)
		{
			left.push(a[i]);
			ldp[0] += a[i];
		}

		for(int i = 0;i < n;i++)
		{
			if(a[n + i] > left.top())
			{
				left.push(a[n + i]);
				ldp[i + 1] = ldp[i] - left.top() + a[n + i];
				left.pop();
			}
			else
			{
				ldp[i + 1] = ldp[i];
			}
		}
	}

	//right

	{
		priority_queue<ll> right;
		for(int i = 0;i < n;i++)
		{
			right.push(a[2 * n + i]);
			rdp[0] += a[2 * n + i];
		}

		for(int i = 0;i < n;i++)
		{
			int ind = 2 * n - 1 - i;
			if(a[ind] < right.top())
			{
				right.push(a[ind]);
				rdp[i + 1] = rdp[i] - right.top() + a[ind];
				right.pop();
			}
			else
			{
				rdp[i + 1] = rdp[i];
			}
		}
	}

	ll result = -1 * (1LL<< 60);

	for(int i = 0;i <= n;i++)
	{
		result = max(result , ldp[i] - rdp[n - i]);
	}

	cout << result << endl;
	return 0;
}


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

signed main() {
  int x, y;
  cin >> x >> y;
  if (x == 2 || y == 2) cout << "No" << endl;
  else {
    int a = 0, b = 0;
    if (x == 4 ||x == 6 ||x == 9 ||x == 11) a++;
    if (y == 4 ||y == 6 ||y == 9 ||y == 11) b++;
    if (a == b) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

int n,f[300005][8];
char s[300005];
const int Mp[8][2]={3,1,5,2,2,2,4,7,3,3,6,1,5,5,3,1},p=1000000007;
inline void Add(int &a,const int b){if((a+=b)>=p)a-=p;}

int main()
{
    scanf("%s",s),n=strlen(s),f[n][1]=f[n][2]=1;
    for(int i=n-1;i>=0;--i)
        for(int j=0;j<8;++j)
        {
            if(s[i]!='0')Add(f[i][j],f[i+1][Mp[j][1]]);
            if(s[i]!='1')Add(f[i][j],f[i+1][Mp[j][0]]);
        }
    return printf("%d\n",f[0][0]),0;
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 
int main() {
 	int N, M, sum=0;
  	cin >> N;
  	M = N;
  
  	while(N != 0){
      sum += N%10;
      N /= 10;
    }
  
	if(M%sum == 0)
  	  cout << "Yes" << endl;
  	else
      cout << "No"  <<endl;
}

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

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;



//abc062_c
//TとAの数比
int main()
{
    ll N;
    cin >> N;

    ll t[N];
    ll a[N];

    ll res;

    REP(i,N)
    {
        cin >> t[i] >> a[i];
    }

    //票数を1とする
    ll T = 1;
    ll A = 1;

    REP(i,N)
    {
        //bai,T : i-1番目までに投票した票数
        ll bai = max((T+t[i]-1) / t[i], (A+a[i]-1) / a[i]);

        //T : i番目までに投票した票数
        T = bai * t[i];
        A = bai * a[i]; 
    }

    cout << T+A << endl;


    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <stdio.h> 
#include <map>
#include <cmath>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <sstream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
		int n,m;
  	cin>>n>>m;
    map<int, pair<int,int> > mp;
  	int one = 0;
  	int second = 0;
  	map<int, set<string> > used;
  	for (int i=0; i<m; i++) {
      	int p;
      	char s[3];
    	  scanf("%d %s", &p, s);
      	string w = string(s);
      	if(used[p].find("AC")!=used[p].end()) {
        	continue;
        } else {
          	if(w=="AC") {
            		used[p].insert("AC");
            		one++;
              	second+=mp[p].second;
            } else {
            		mp[p].second++;
            }
          	
        }
    }
  	cout << one <<" "<<second;
	return 0;
}


Measured memory_bytes: 25216
from sys import stdin
from itertools import combinations
from math import factorial
import numpy as np

li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(3)]

a1 = 0
b1 = li[0][0]-a1
b2 = li[0][1]-a1
b3 = li[0][2]-a1
a2 = li[1][0]-b1
a3 = li[2][0]-b1

lin = [[a1,a2,a3],[b1,b2,b3]]

for i in range(3):
    for j in range(3):
        if li[i][j] != lin[0][i]+lin[1][j]:
            print("No")
            exit()

print("Yes")

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

struct BIT{
    int N;
    vector<int> dat;
    public:
    BIT(int n):N(n),dat(n+1,0){}
    void add(int pos,int val){
        pos++;
        while(pos<=N){
            dat[pos]+=val;
            pos+=pos&-pos;
        }
    }
    //sum of [0,pos) (dat[1..pos])
    int sum(int pos){
        int res=0;
        while(pos>0){
            res+=dat[pos];
            pos-=pos&-pos;
        }
        return res;
    }
    void debug(){
        for(int i=0;i<dat.size();i++){
            cout<<"#"<<i<<": "<<dat[i]<<endl;
        }
        return;
    }
};

int main(){
    int n,m;
    cin>>n>>m;
    BIT bit(2*m+10);
    vector<pair<int,int>> lr(n);
    for(int i=0;i<n;i++){
        cin>>lr[i].first>>lr[i].second;
        lr[i].second++;
        bit.add(lr[i].second,1);
    }
    sort(lr.begin(),lr.end());
    vector<vector<int>> events(2*m+10);
    for(int i=0;i<m;i++) events[0].push_back(i);
    vector<int> ans(m,n);
    int inde=0;
    for(int i=0;i<=m;i++){
        while(inde<n && lr[inde].first<=i){
            bit.add(lr[inde].second,-1);
            inde++;
        }
        for(int j=0;j<events[i].size();j++){
            int l=i+1,r=i+events[i][j]+1;
            ans[events[i][j]]-=(bit.sum(r+1)-bit.sum(l));
            events[r].push_back(events[i][j]);
        }
    }
    for(int i=0;i<m;i++) cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 18808
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] p = new long[n];
    for(int i = 0;i<n;i++){
      p[i] = sc.nextLong();
    }
    int count = 0;
    for(int i=1;i<n-1;i++){
      if(p[i-1]<p[i]&&p[i]<p[i+1]||p[i-1]>p[i]&&p[i]>p[i+1])count++;
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 35544
#include <stdio.h>

int main( void ) {

  while( 1 ) {
    int i, n;
    char card[ 200 ];
    int x;
    int turn = 1, cont = 1;
    int tcn, hcn;
    int count = 0;

    scanf( "%d", &n );
    if( !n )
      break;

    tcn = n;
    hcn = n;

    for( i = 0; i < n * 2; i++ )
      card[ i ] = 2;

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

    while( cont ) {
      for( i = 0; i < n * 2; i++ ) {
        if( turn == 1 ) {
          if( card[ i ] == 1 ) {
            card[ i ] = 0;
            turn = 2;
            tcn--;
          }
        } else {
          if( card[ i ] == 2 ) {
            card[ i ] = 0;
            turn = 1;
            hcn--;
          }
        }
        if( !tcn || !hcn ) {
          cont = 0;
          break;
        }
      }

      if( turn == 1 )
        turn = 2;
      else
        turn = 1;
    }

    for( i = 0; i < n * 2; i++ )
      if( card[ i ] )
        count++;

    if( !tcn )
      printf( "%d\n0\n", count );
    else
      printf( "0\n%d\n", count );
  }

  return( 0 );
}

Measured memory_bytes: 0
// AtcoderTemplate.cpp : アプリケーションのエントリ ポイントを定義します。
//

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

int main()
{
	int n, m,x,y;
	cin >> n >> m>>x>>y;
	vector<int> vx(n), vy(m);
	for (auto & x : vx) {
		cin >> x;
	}
	vx.push_back(x);
	for (auto &y : vy) {
		cin >> y;
	}
	vy.push_back(y);
	int x_max = *max_element(vx.begin(), vx.end());
	int y_min = *min_element(vy.begin(), vy.end());
	bool res = x_max < y_min;

	cout << (res ? "No War" : "War") << endl;
    return 0;
}



Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int,input().split()))
    if (max(a) - min(a)) > 1:
        print("No")
        return 0
    minor = a.count(min(a))
    if n != minor:
        major = n-minor

        mini = minor+1
        maxi = minor + (major//2)
        if mini <= max(a) and max(a) <= maxi:
            print("Yes")
        else:
            print("No")
    else:
        mini = 1
        maxi = minor//2
        if mini <= max(a) and max(a) <= maxi or max(a) == n-1:
            print("Yes")
        else:
            print("No")


main()


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


int main() {
	const double BTCJPY = 380000.0;
	int N;
	cin >> N;

	double total = 0;
	for(int i=0;i<N;i++) {
		double x;
		string u;
		cin >> x >> u;

		if(u == "JPY") {
			total += x;
		}else {
			total += BTCJPY * x;
		}
	}
	printf("%.10f\n", total);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>

using namespace std;

long long nilai[100005];
long long benar[100005];
long long salah[100005];
int main(){
   long long n,m,nomor,hayo,silih,i;
   char hurufpertama, hurufkedua;
   scanf("%lld %lld", &n,&m);
   getchar();
   for(i=0;i<m;i++){
      scanf("%lld %c%c", &nomor, &hurufpertama, &hurufkedua);
      getchar();
      if(nilai[nomor]==0){
         if(hurufpertama=='A'|| hurufpertama=='a'){
            benar[nomor]=1;
            nilai[nomor]=1;
         }
         else{
            salah[nomor]++;
         }
      }
   }
   hayo=0;
   silih=0;
   for(i=1;i<n+1;i++){
      if(benar[i]==1){
         hayo++;
         silih=silih+salah[i];
      }
      
   }
   cout<<hayo<<" "<<silih<<endl;
}  

Measured memory_bytes: 2432
#include <iostream>
#include<iomanip>
using namespace std;
int main(){
    long long int n,a,b,ans,zentai,kaisu,amari;
    cin >> n >> a >> b;
    zentai = a+b;
    kaisu = n / zentai;
    ans = a * kaisu;
    amari = n - kaisu * zentai;
    if(amari < a){
        ans = ans + amari;
    }else{
        ans = ans + a;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using i64 = int64_t;

const int INF = 0x7fffffff;

struct edge {
    int to, cap, rev;
    edge(int to, int cap, int rev): to(to), cap(cap), rev(rev) {}
};

struct ford_fulkerson {
    int N;
    vector<vector<edge>> graph;
    vector<char> visited;

    ford_fulkerson() {}
    ford_fulkerson(int _N) {
        init(_N);
    }
    void init(int _N) {
        N = _N;
        graph.resize(N);
        visited.resize(N);
    }

    void add_edge(int u, int v, int cap) {
        graph[u].emplace_back(v, cap, graph[v].size());
        graph[v].emplace_back(u, 0, (int)graph[u].size()-1);
    }

    int max_flow(int s, int t) {
        int flow = 0;
        for (;;) {
            fill(visited.begin(), visited.end(), 0);
            int acc = dfs(s, t, INF);
            if (acc == 0) break;
            flow += acc;
        }
        return flow;
    }

private:
    int dfs(int v, int t, int f) {
        if (v == t) return f;
        visited[v] = 1;
        for (int i = 0; i < graph[v].size(); ++i) {
            edge& e = graph[v][i];
            if (!visited[e.to] && e.cap > 0) {
                int ff = dfs(e.to, t, min(f, e.cap));
                if (ff > 0) {
                    e.cap -= ff;
                    graph[e.to][e.rev].cap += ff;
                    return ff;
                }
            }
        }
        return 0;
    }
};

int V, E;
ford_fulkerson F;

int main() {
    cin >> V >> E;
    F.init(V);
    for (int j = 0; j < E; ++j) {
        int u, v, c;
        cin >> u >> v >> c;
        F.add_edge(u, v, c);
    }
    cout << F.max_flow(0, V-1) << endl;
    return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

#define access(i) a[i/3][i%3]
int gcd(int x, int y)
{
    if(y==0)
        return x;
    return gcd(y, x%y);
}

 long long numbers[500005];

//int a[100005];

 ll lcm(ll a,ll b){

  ll g = a*b;
  ll gg = gcd(a,b);

  return g/gg;

 }

 int main(){

  long long a,b;
  cin>>a>>b;

  cout<<lcm(a,b)<<endl;


 return 0;
 }

Measured memory_bytes: 3604
import sys

def w_f(dp):
    for k in range(v):
        for i in range(v):
            for j in range(v):
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])
    
    for i in range(v):
        for j in range(v):
            if dp[i][i] < 0:
                print('NEGATIVE CYCLE')
                sys.exit()
            
            if dp[i][j] == float('inf'):
                dp[i][j] = 'INF'
    return dp

v,e = map(int, input().split())
dp = [[float('inf')]*v for _ in range(v)]
for i in range(e):
    s,t,d = map(int, input().split())
    dp[s][t] = d
    
for i in range(v):
    dp[i][i] = 0
    
res = w_f(dp)
for i in range(v):
    print(*res[i])


Measured memory_bytes: 6284
long d[1<<18]={0,0,1,6,19,65},M=998244353,m;b,c,N,s[4];
main(f){
	for(m=M-3;read(0,&c,1),c-10;s[c-97]++,f&=b!=c,b=c)
		m=!N|N++%3?m:(m+m)%M,
		d[N+5]=(5*d[N+4]-6*d[N+3]+2*d[N+2]-10*d[N+1]+12*d[N])%M;
	printf("%d\n",!*s+!s[1]+!s[2]>1?:N<3?N:(d[N]+(N%3|*s%3-s[2]%3?f:N>3?m+f:m)+M)%M);
}

Measured memory_bytes: 1664
import java.util.*;
import java.lang.*;

class Main {

    public static void main(String[] a) {

        Scanner sc = new Scanner(System.in);

        String strA = sc.next();
        String strB = sc.next();
        String strC = sc.next();

        // System.out.println(strA.substring( strA.length()-1 ));
        // System.out.println(strB.substring(0,1));


        // 判定
        boolean isShiritori = (strA.substring( strA.length()-1 )).equals(strB.substring(0,1)) &&
                              (strB.substring( strB.length()-1 )).equals(strC.substring(0,1));

        if (isShiritori) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}




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

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int h, w;
    cin >> h >> w;
    char a[h][w];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < w + 2; i++) {
        cout << "#";
    }
    cout << endl;
    for (int i = 0; i < h; i++) {
        cout << "#";
        for (int j = 0; j < w; j++) {
            cout << a[i][j];
        }
        cout << "#\n";
    }
    for (int i = 0; i < w + 2; i++) {
        cout << "#";
    }
    cout << endl;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution
}


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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
const int MOD = 1e9 + 7;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main() {
    string s;
    cin >> s >> s;
    cout << 'A' << s[0] << 'C' << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define mm map<ii>
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 

/*
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
#define si short int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

    int n;
    cin>>n;

    vi v(n);

    int x = 0;
    forn(i,0,n)
    {
        cin>>v[i];
        x = x^v[i];
    }
    if(x == 0) 
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 640
#include <cstdio> 
#include <cstdlib> 
#include <cmath> 
#include <cstring> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <numeric>
#include <cassert>

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

map<ll, ll> ROOT5;

ll pow5(int a) {
    return (ll)a*a*a*a*a;
}

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

    for (int i = 0; pow5(i+1)-pow5(i) <= X; i++) {
        ROOT5[pow5(i)] = i;
        ROOT5[pow5(i+1)] = i+1;
    }

    // A^5 + B^5 = X
    for (int a = 0; pow5(a) <= X; a++) {
        ll b5 = X - pow5(a);
        if (ROOT5.count(b5)) {
            cout << a << " " << -ROOT5[b5] << endl;
            return 0;
        }
    }

    // A^5 - B^5 = X
    for (int b = 0; pow5(b+1)-pow5(b) <= X; b++) {
        ll a5 = X + pow5(b);
        if (ROOT5.count(a5)) {
            cout << ROOT5[a5] << " " << b << endl;
        }
    }


    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int L; cin >> L;
    double dl = double(L) / 3;
    cout << pow(dl, 3) << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using li = unsigned long long int;
using namespace std;

int main() {
    fastIO;
    int n, k;
    cin >> n >> k;
    vector<int> length(n);
    rep(i, n) cin >> length.at(i);
    sort(length.rbegin(), length.rend());

    int sum = 0;
    for (size_t i = 0; i < k; i++) {
        sum += length.at(i);
    }
    cout << sum << endl;
}

Measured memory_bytes: 3616
import java.io.PrintWriter;
import java.util.*;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc  = new Scanner(System.in);

    public static void main(String[] args){
        String str = sc.next();

        Set<String> set = new HashSet<>();
        set.addAll(Arrays.asList(str.split("")));

        println(set.size() == 2 ? "Yes" : "No");
    }

    static int nextInt(){
        return Integer.parseInt(sc.next());
    }
    static Long nextLong(){
        return Long.parseLong(sc.next());
    }
    static void println(Object o){
        PrintWriter out = new PrintWriter(System.out);
        out.println(o);
        out.flush();
    }
   static void print(Object o){
       PrintWriter out = new PrintWriter(System.out);
       out.print(o);
       out.flush();
    }
}


Measured memory_bytes: 21716
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <bitset>

#define REDIRECT(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)
#define CLOSEALL() fclose(stdin), fclose(stdout)

using namespace std;

const int MAXN = 1e5 + 10;

int N;
vector <int> tmp;
vector <int> Adj[MAXN];
int dep[MAXN], answer;

inline void addEdge(int u, int v)
{
	Adj[u].push_back(v);
	Adj[v].push_back(u);
}

void DFS(int cur, int fa)
{

	for(vector<int>::iterator itr = Adj[cur].begin(); itr != Adj[cur].end(); ++itr)
	{
		const int & to = *itr;
		if(to == fa)
			continue;
		DFS(to, cur);
	}

	tmp.clear();
	for(vector<int>::iterator itr = Adj[cur].begin(); itr != Adj[cur].end(); ++itr)
		if(fa != *itr)
			tmp.push_back(dep[*itr]);
	
	if(tmp.empty())
		return;
	
	sort(tmp.begin(), tmp.end());

	dep[cur] = tmp.front() + 1;
	for(vector<int>::iterator itr = tmp.begin() + 1; itr != tmp.end(); ++itr)
		dep[cur] = max(dep[cur], *itr) + 1;
}

int main()
{
	//REDIRECT("selection");

	scanf("%d", &N);
	for(int i = 2; i <= N; i++)
	{
		int fa;
		scanf("%d", &fa);
		addEdge(i, fa);
	}

	DFS(1, 0);

	printf("%d\n", dep[1]);
	CLOSEALL();
	return 0;
}


Measured memory_bytes: 12288
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#define PB push_back
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x)
{
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=getchar();}
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=1e4+10;
vector<int> ans;
int n,a[N];
int gcd(int a,int b) { return b?gcd(b,a%b):a; }
int pri[N],flg[N],num;
void getpri(int n) {
	for(int i=2;i<=n;++i) {
		if(!flg[i]) pri[num++]=i;
		for(int j=0;j<num&&pri[j]*i<=n;++j) {
			flg[i*pri[j]]=1;
			if(i%pri[j]==0) break;
		}
	}
}

int main() {
	rd(n);
	int g=0;
	for(int i=n;i>=0;--i) rd(a[i]),g=gcd(a[i],g);
	if(g<0) g=-g;
	for(int i=2;i*(ll)i<=g;++i) if(g%i==0) {
		while(g%i==0) g/=i;
		ans.PB(i);
	}
	if(g>1) ans.PB(g);
	getpri(n);
	for(int j=0;j<num;++j) {
		if(a[0]%pri[j]) continue;
		int p=pri[j],p1=pri[j]-1,flg=1;
		for(int j=0;j<p1;++j) {
			int tmp=0;
			for(int i=j;i<=n;i+=p1)
				tmp=(tmp+a[i])%p;
			if(tmp!=0) { flg=0; break; }
		}
		if(flg) ans.PB(pri[j]);
	}
	sort(ans.begin(),ans.end());
	int m=unique(ans.begin(),ans.end())-ans.begin();
	for(int i=0;i<m;++i) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
		public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			if (a <= b && b <= c)
				System.out.printf("%d %d %d\n", a, b, c);
			else if (a <= c && c <= b)
				System.out.printf("%d %d %d\n", a, c, b);
			else if (b <= a && a <= c)
				System.out.printf("%d %d %d\n", b, a, c);
			else if (b <= c && c <= a)
				System.out.printf("%d %d %d\n", b, c, a);
			else if (c <= a && a <= b)
				System.out.printf("%d %d %d\n", c, a, b);
			else if (c <= b && b <= a)
				System.out.printf("%d %d %d\n", c, b, a);
		}
}

Measured memory_bytes: 26176
N=int(input())
A=[int(s) for s in input().split(" ")]

Ans=[]
Ans2=[]
for i in range(N):
    Ans=[A[i],i+1]
    Ans2.append(Ans)
    Ans=[]

Ans2.sort()

Ans3=[]
for i in range(N):
    Ans3.append(str(Ans2[i][1]))
    

print((" ").join(Ans3))

Measured memory_bytes: 28712
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::{max, min};

fn main() {
    let h = read();
    let mut cnt = 0;
    let mut val: i64 = 1;
    if h == 1 {
        println!("{}", 1);
        return
    }

    while val < h {
        cnt += 1;
        val *= 2;
        if val == h {
            cnt += 1;
            break;
        }
    }
    println!("{}", 2_i64.pow(cnt) - 1);
}


Measured memory_bytes: 4352
if __name__ == '__main__':
    n = int(input())
    h = list(map(int, input().split()))
    c = [0] * n
    c[1] = abs(h[1] - h[0])

    for i in range(2, n):
        c[i] = min(c[i-1] + abs(h[i] - h[i-1]), c[i-2] + abs(h[i] - h[i-2]))

    print(c.pop())


Measured memory_bytes: 13980
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
int rnd(int x) { return mrand() % x; }
ll powmod(ll a, ll b)
{
	ll res = 1;
	a %= mod;
	assert(b >= 0);
	for (; b; b >>= 1)
	{
		if (b & 1)
			res = res * a % mod;
		a = a * a % mod;
	}
	return res;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

static uint MD = mod;
struct ModInt
{
	using M = ModInt;
	uint v;
	ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
	M &set_v(uint _v)
	{
		v = (_v < MD) ? _v : _v - MD;
		return *this;
	}
	explicit operator bool() const { return v != 0; }
	M operator-() const { return M() - *this; }
	M operator+(const M &r) const { return M().set_v(v + r.v); }
	M operator-(const M &r) const { return M().set_v(v + MD - r.v); }
	M operator*(const M &r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
	M operator/(const M &r) const { return *this * r.inv(); }
	M &operator+=(const M &r) { return *this = *this + r; }
	M &operator-=(const M &r) { return *this = *this - r; }
	M &operator*=(const M &r) { return *this = *this * r; }
	M &operator/=(const M &r) { return *this = *this / r; }
	bool operator==(const M &r) const { return v == r.v; }
	M pow(ll n) const
	{
		M x = *this, r = 1;
		while (n)
		{
			if (n & 1)
				r *= x;
			x *= x;
			n >>= 1;
		}
		return r;
	}
	M inv() const { return pow(MD - 2); }
	friend ostream &operator<<(ostream &os, const M &r) { return os << r.v; }
};
using Mint = ModInt;
//head
// cin >> t;
// for (int cas = 1; cas <= t; ++cas)
// {
// 	cout << "Case #" << cas << ": ";
// }
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	string s;
	cin>>n;
	cin>>s;
	ll a[3]={0,0,0};
	rep(i,0,n) {
		if(s[i]=='R') a[0]++;
		else if(s[i]=='G') a[1]++;
		else a[2]++;
	}

	ll ans = a[0]*a[1]*a[2];
	rep(d,1,n) {
		rep(i,0,n) {
			int j=i+d;
			int k=i+2*d;
			if(j>=n || k>=n) break;
			if(s[i]!=s[j]&&s[i]!=s[k]&&s[j]!=s[k])
				ans--;
		}
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3672
#include<stdio.h>
int main(){
  int N,i,j,a=0,b;
  char c[10000],d;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%s",c);
    j=0;
    a=0;

    while(1){
 
      if(c[j]=='0'){
	b=j-a;
	d=c[a];
	if(d=='2'){
	  if(b%3==1)printf("a");
	  else if(b%3==2)printf("b");
	  else if(b%3==0)printf("c");
	  
	}

	if(d=='3'){
	  if(b%3==1)printf("d");
	  if(b%3==2)printf("e");
	  if(b%3==0)printf("f");
	  
	}
	if(d=='4'){
	  if(b%3==1)printf("g");
	  else if(b%3==2)printf("h");
	  else if(b%3==0)printf("i");
	  
	}

	if(d=='5'){
	  if(b%3==1)printf("j");
	  if(b%3==2)printf("k");
	  if(b%3==0)printf("l");
	  
	}
	if(d=='6'){
	  if(b%3==1)printf("m");
	  else if(b%3==2)printf("n");
	  else if(b%3==0)printf("o");
	  
	}

	if(d=='8'){
	  if(b%3==1)printf("t");
	  if(b%3==2)printf("u");
	  if(b%3==0)printf("v");
	  
	}
	if(d=='7'){
	  if(b%4==1)printf("p");
	  else if(b%4==2)printf("q");
	  else if(b%4==3)printf("r");
	  else if(b%4==0)printf("s");
	}
	if(d=='9'){
	  if(b%4==1)printf("w");
	  else if(b%4==2)printf("x");
	  else if(b%4==3)printf("y");
	  else if(b%4==0)printf("z");
	}
	if(d=='1'){
	  if(b%5==1)printf(".");
	  else if(b%5==2)printf(",");
	  else if(b%5==3)printf("!");
	  else if(b%5==4)printf("?");
	  else printf(" ");
	}

	a=j+1;
      }
      
      if (c[j]=='\0'){
	printf("\n");
	break;
	
      }
      j++;
    }
 
  }
  return 0;
}

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

const long long MOD = (1e9)+7;
int n, f[1001];
vector<int> primes;
bool mark[1001];
int main() {
	cin >> n;
	for(int i = 2; i <= n; i++) if(!mark[i]) {
		for(int j = i; j <= n; j += i) mark[j] = true;
		primes.push_back(i);
	}
	for(int i = 2; i <= n; i++) {
		for(int p: primes) if(!(i%p)) {
			int tmp = i;
			while(!(tmp%p)) tmp /= p, f[p]++;
		}
	}
	long long res = 1;
	for(int p: primes) res = (1ll*res*(f[p]+1))%MOD;
	cout << res;
}


Measured memory_bytes: 256
;; -*- coding:utf-8 -*-

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 1))
    #-swank '(optimize (speed 3) (safety 0) (debug 0))))

(defmacro println (obj &optional (stream '*standard-output*))
  `(prog1 (princ ,obj ,stream) (terpri ,stream)))


;; Hauptteil

(defun split-by-one-space (str size)
  (declare (optimize (speed 3) (safety 1))
           (simple-string str))
  (loop with dest-arr = (make-array size :element-type 'fixnum)
        for idx below size ; fix me
        for pos1 = 0 then (1+ pos2)
        for pos2 = (position #\space str :start pos1 :test #'char=)
        do (setf (aref dest-arr idx)
                 (parse-integer str :start pos1 :end pos2))
        finally (return dest-arr)))

(deftype uint nil `(integer 0 ,(expt 10 9)))
(defun main ()
  (let* ((n (read))
         (k (read))
         (arr (split-by-one-space (read-line) n)))
    (labels ((get-time (xmin xmax)
               (cond ((<= 0 xmin) xmax)
                     ((<= xmax 0) (abs xmin))
                     (t (let ((absxmin (abs xmin))
                              (absxmax (abs xmax)))
                          (min (+ (* 2 absxmin) absxmax)
                               (+ absxmin (* 2 absxmax))))))))
      (loop for i from 0
            for j from (- k 1) below n
            minimize (get-time (aref arr i) (aref arr j))
              into minima
            finally (println minima)))))

#-swank(main)


Measured memory_bytes: 25060
# AOJ 1019: Vampirish Night
# Python3 2018.7.4 bal4u

while True:
	n, k = map(int, input().split())
	if n == 0: break
	s = list(map(int, input().split()))
	b = [0]*k
	for i in range(n):
		a = list(map(int, input().split()))
		for j in range(k): b[j] += a[j]
	ans = True
	for i in range(k):
		if b[i] > s[i]:
			ans = False
			break
	print("Yes" if ans else "No")


Measured memory_bytes: 5612
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>

#define ll long long
#define f first 
#define s second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>

using namespace std;

void IO(){
    #ifndef ONLINE_JUDGE
        freopen("test.txt","r",stdin);
    #endif
}

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

const int N = 1e6 + 7, K = 26, M = 3e3 + 5, mod = 1e9 + 7;

int tc,n,m,c,k,x,deg[N],ans[N];

int a[M][M];

ll dp[M][M][4];

bool valid(int x, int y){
    return x >= 0  && x < n && y >= 0 && y < m;
}

ll solve(int x = 0, int y = 0, int cur = 0){
    if (!valid(x,y))
        return 0;
    ll& r = dp[x][y][cur];
    if (~r)
        return r;
    if (cur < 3)
        r = a[x][y] + max(solve(x + 1, y, 0), solve(x, y + 1, cur + 1));
    r = max({r, solve(x + 1, y, 0), solve(x, y + 1, cur)});
    return r;
}

int main(){
    memset(dp, -1, sizeof dp);
    scanf("%d %d %d",&n,&m,&k);
    while(k--){
        int x,y,d;
        scanf("%d %d %d" ,&x,&y,&d);
        a[--x][--y] = d;
    }
    printf("%lld\n", solve());
}

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

using namespace std;
using ll = long long int;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    cout << fixed << setprecision(16);

    ll n, m, p;
    cin >> n >> m >> p;
    vector<tuple<ll,ll,ll>> es(m);
    for(auto &e: es) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        c = p - c;
        e = make_tuple(a, b, c);
    }

    vector<ll> d(n, 1e15);
    d[0] = 0;

    for(ll i=0; i<n; i++) {
        for(auto &e: es) {
            ll a, b, c;
            tie(a, b, c) = e;
            if(d[a] + c < d[b] && d[a] < 1e15)
                d[b] = d[a] + c;
        }
    }

    bitset<3000> s, t;
    {
        auto dfs = [&](auto dfs, ll x) {
            if(s[x]) return;
            s[x] = 1;
            for(auto &e: es) {
                ll a, b, c;
                tie(a, b, c) = e;
                if(a == x)
                    dfs(dfs, b);
            };
        };
        dfs(dfs, 0);
    }
    {
        auto dfs = [&](auto dfs, ll x) {
            if(t[x]) return;
            t[x] = 1;
            for(auto &e: es) {
                ll a, b, c;
                tie(a, b, c) = e;
                if(b == x)
                    dfs(dfs, a);
            };
        };
        dfs(dfs, n-1);
    }
    s &= t;

    for(ll i=0; i<n; i++) {
        for(auto &e: es) {
            ll a, b, c;
            tie(a, b, c) = e;
            if(d[a] + c < d[b] && d[a] < 1e15) {
                if(s[b]) {
                    cout << -1 << endl;
                    return 0;
                }
                d[b] = d[a] + c;
            }
        }
    }

    cout << max(0ll, -d[n-1]) << endl;
}


Measured memory_bytes: 3880
fun main(args : Array<String>) { 
  readLine()!!.split(" ").map { it.toInt() }.let {
    if ((it[1] - it[0]) / 2 >= it[2]) {
      (it[0] until it[0] + it[2]).forEach { println(it) }
      (it[1] - it[2] + 1..it[1]).forEach { println(it) }
    } else (it[0]..it[1]).forEach { println(it) }
  }
}

Measured memory_bytes: 37620
def solve():
    N, *a = map(int, open(0).read().split())
    
    if 1 not in a:
        print(-1)
        exit()
    
    ans = 0
    target = 1
    i_tmp = -1
    for i, x in enumerate(a):
        if x == target:
            ans += i - i_tmp - 1
            i_tmp = i
            target += 1
    ans += N - i_tmp - 1
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 25116