akhauriyash/Code-Regression huggingface dataset:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    n, k = map(int, readline().split())
    h = [int(i) for i in readline().split()]
    #dp[i]:=i番目の柱までの経路によって加算されたコストの総和の最小値
    INF = int(1e9)
    dp = [INF for _ in range(n)]
    def cost(i, j):
        return abs(h[i]-h[j])

    dp[0] = 0 
    for i in range(n): 
        for j in range(1,k+1):
            if i+j < n:
                dp[i+j] = min(dp[i+j], dp[i]+cost(i, i+j)) 
    print(dp[n-1])
if __name__ == '__main__':
    main()


Measured memory_bytes: 52464
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 

ll n,m,x;
ll cost[12];
ll arr[12][12];

ll val[12];

ll solve(ll id)
{
    if(id==n)
    {
        for(ll i=0;i<m;i++)
        {
            if(val[i]<x)
            {
                return 1e18;
            }
        }
        return 0;
    }

    ll mi = solve(id+1);

    for(ll i=0;i<m;i++)
    {
        val[i] += arr[id][i];
    }

    mi = min(mi,cost[id]+solve(id+1));

    for(ll i=0;i<m;i++)
    {
        val[i] -= arr[id][i];
    }

    return mi;

}


int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    cin>>n>>m>>x;

    for(ll i=0;i<n;i++)
    {
        cin>>cost[i];
        for(ll j=0;j<m;j++)
        {
            cin>>arr[i][j];
        }
    }
    
    ll v = solve(0);

    if(v>=1e18 || v<0)
    {
        cout<<-1<<endl;
    }
    else{
        cout<<v<<endl;
    }

}

Measured memory_bytes: 3656
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int pm = 1000000;
    int ans = 0;
    for(int i = 0; i < n; i++) {
      int p = sc.nextInt();
      if(p <= pm) {
        ans++;
        pm = p;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 58628
package main

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

func main() {
	s := IOInitialize()
	N := Int(s)
	nums1, nums2 := scanNums(s, N)

	max := 0
	for i := 0; i < N; i++ {
		row1 := 0
		row2 := 0
		for j := 0; j < N; j++ {
			if j <= i {
				row1 += nums1[j]
			}
			if j >= i {
				row2 += nums2[j]
			}
		}
		sum := row1 + row2
		if sum > max {
			max = sum
		}
	}
	fmt.Println(max)
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}

func scanNums(s *bufio.Scanner, len int) (nums1, nums2 []int) {
	nums1 = []int{}
	nums2 = []int{}
	for i := 0; i < len; i++ {
		num := Int(s)
		nums1 = append(nums1, num)
	}
	for i := 0; i < len; i++ {
		num := Int(s)
		nums2 = append(nums2, num)
	}

	return
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<int,int>
#define INT_MAX 2147483647
#define MOD 1000000007
using namespace std;
typedef long long ll;


int main(void) {
	ll a, b, c,d; cin >> a >> b >> c;
	d = c - a - b;
	if (d > 0 && d*d >4 * a * b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
import sys

def findLCS(X, Y):
    m, n = len(X), len(Y)
    C = [0] * (n + 1)

    for i in range(m):
        prev = C[:]
        for j in range(n):
            if X[i] == Y[j]:
                C[j + 1] = prev[j] + 1
            elif C[j + 1] < C[j]:
                C[j + 1] = C[j]

    return C[-1]

lines = sys.stdin.readlines()
N = int(lines[0])

for i in range(N):
    X = lines[2 * i + 1].strip()
    Y = lines[2 * i + 2].strip()
    print findLCS(X, Y)

Measured memory_bytes: 6492
#include"bits/stdc++.h"
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())

int main() {
	string S, T;
	cin >> S >> T;
	if (S == T.substr(0, S.size())) {
		puts("Yes");
	}
	else {
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 3624
//
//  main.cpp
//
// https://atcoder.jp/contests/abc128/tasks/abc128_d

#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char* argv[]) {
    int N, M;
    cin >> N >> M;
    vector<ll> Ais;
    for (int i = 0; i < N; i++) {
        int Ai;
        cin >> Ai;
        Ais.push_back(Ai);
    }
    std::sort(Ais.begin(), Ais.end());
    unordered_map<ll, int> rewritable_counts;
    vector<ll> numbers;
    for (int i = 0; i < M; i++) {
        int limit;
        ll number;
        cin >> limit >> number;
        if (rewritable_counts.find(number) == rewritable_counts.end()) {
            numbers.push_back(number);
        }
        rewritable_counts[number] += limit;
    }
    std::sort(numbers.begin(), numbers.end());
    ll sum = 0;
    for (ll ai : Ais) {
        sum += ai;
    }
    ll max_sum = sum;
    for (int rewrite_idx = 0; rewrite_idx < Ais.size(); rewrite_idx++) {
        if (numbers.empty()) {
            break;
        }
        sum += numbers.back() - Ais[rewrite_idx];
        max_sum = std::max(max_sum, sum);
        rewritable_counts[numbers.back()] -= 1;
        if (rewritable_counts[numbers.back()] == 0) {
            numbers.pop_back();
        }
    }
    cout << max_sum << endl;
}



Measured memory_bytes: 7284
x = gets
y = x.split

# if y[0].to_i < 0 || y[1].to_i < 0 || y[2].to_i < 0
#   return
# end
#
# if 100 < y[0].to_i || 100 < y[1].to_i || 100 < y[2].to_i
#   return
# end
for w in 0 ... 2 do
  if  y[w].to_i < 0 || 100 < y[w].to_i
    return
  end
end


unless (0 <= y[0].to_i && 0 <= y[1].to_i && 0 <= y[2].to_i )&&
       ( y[0].to_i  <= 100 && y[1].to_i  <= 100 && y[2].to_i  <= 100)
  return
end

if y[0].to_i < y[1].to_i && y[1].to_i < y[2].to_i && y[0].to_i < y[2].to_i
  puts "Yes"
  else
  puts "No"
end


Measured memory_bytes: 8868
# ABC097D - Equals (ARC097D)
class UnionFind:  # O(α(N))
    def __init__(self, N):  # construct a Union-Find tree (1-idx)
        self.parent = [i for i in range(N + 1)]
        self.rank = [0] * (N + 1)

    def find(self, x):  # find the group (root) of a vertex
        if self.parent[x] == x:
            return x
        self.parent[x] = self.find(self.parent[x])
        return self.parent[x]

    def is_same(self, x, y):  # check two vertices are in the same group
        return self.find(x) == self.find(y)

    def unite(self, x, y):  # unite two groups
        x, y = self.find(x), self.find(y)
        if x == y:  # the same group
            return
        # unite a small one to a bigger one to balance trees
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1


def main():
    # check i and Pi are connected components or not
    N, M, *A = map(int, open(0).read().split())
    P, E = A[:N], A[N:]
    U = UnionFind(N)  # construct a Union-Find tree (1-idx)
    for v, u in zip(*[iter(E)] * 2):  # connected components are in the same group
        U.unite(v, u)
    ans = sum(U.is_same(i, p) for i, p in enumerate(P, 1))
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 35324
'use strict';

const receive = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\s/);

const main = input => {
  const S = input[0];
  const counter = (S.match(/o/g) || []).length;
  const ans = 700 + 100 * counter;
  console.log(ans);
};

main(receive);

Measured memory_bytes: 7372
#include <bits/stdc++.h>
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  long long sum = 0;
  int min_ = INF;
  // bool flag_1 = false;
  // bool flag_2 = false;
  rep(i, n) {
    cin >> a.at(i);
    sum += a.at(i);
    min_ = min(a.at(i), min_);
    //  if(a.at(i) == 1) flag_1 = true;
    //  if(a.at(i) == 2) flag_2 = true;
  }
  // if (min_ >= 3)
  ll store = sum - min_ * n;
  string ans = "First";
  if (n % 2 == 0) {
    if (min_ % 2 == 0 && store % 2 == 0) ans = "Second";
    // if (min_ % 2 == 1 && store % 2 == 0) ans = "Second";
  } else {
    if (sum % 2 == 0) {
      ans = "Second";
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;

    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();

            int ans = 0;

            for (int k = 0; k < S.Length; k++)
            {
                if (S[k] == T[k]) 
                {
                    ++ans;
                }
            }

         Console.WriteLine(ans);
        }
    }


Measured memory_bytes: 13140
#include"bits/stdc++.h"
using namespace std;

int main(){
  int k, x, a, b, i;
  cin >> k >> x;
  a = max(x-k+1, -1000000);
  b = min(x+k-1,1000000);
  for(i=a; i<=b; i++) cout << i << " ";
  cout << endl;
  return 0;
}


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

typedef long long ll;
ll n, a, b;

int main() {
    cin >> n >> a >> b;
    if (!((b - a) & 1)) {
        cout << (b - a) / 2 << endl;
    } else {
        cout << min(a - 1, n - b) + (b - a) / 2 + 1 << endl;
    }
    return 0;
}

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

#define rep(i,n) for(int (i)=0; (i)<(int)(n); (i)++)
#define all(x) (x).begin(), (x).end()
#define sqr(x) (x)*(x)
#define CEIL(a,b) ((a)+(b)-1) /(b)

typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;

void sort_second(vector<pair<ll, ll>> &A, int N); //A:array of pair, N:size of array
ll a_n(ll a, ll n); // a^n

int main() {
    int h, w;
    int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
    cin >> h >> w;
    int maze[h][w];
    rep(i, h) rep(j, w) maze[i][j] = 1;
    rep(i, h) {
        string s;
        cin >> s;
        rep(j, w) {
            if(s[j] == '.') maze[i][j] = 0;
        }
    }

    int max = -1, sx, sy, dist[h][w];
    rep(i, h) {
        rep(j, w) {
            if(maze[i][j] == 0) {
                sx = i, sy = j;
                rep(k, h) rep(l, w) dist[k][l] = INF * (-1);
                queue<P> que;
                que.push(P(sx, sy));
                dist[sx][sy] = 0;

                while(que.size()) {
                    P p = que.front();
                    que.pop();

                    rep(k, 4) {
                        int nx = p.first + dx[k], ny = p.second + dy[k];
                        if(0 <= nx && nx < h && 0 <= ny && ny < w \
                        && maze[nx][ny] != 1 \
                        && (dist[nx][ny] == (INF*(-1)) || (dist[nx][ny] != (INF*(-1)) && dist[nx][ny] > dist[p.first][p.second] + 1))) {
                            que.push(P(nx, ny));
                            dist[nx][ny] = dist[p.first][p.second] + 1;
                        }
                    }
                }
                rep(k, h) {
                    rep(l, w) {
                        if(max < dist[k][l]) max = dist[k][l];
                    }
                }
            }
        }
    }

    cout << max << endl;
    return 0;
}

void sort_second(vector<pair<ll, ll>> &A, int N) {
    rep(i, N) swap(A.at(i).first, A.at(i).second);
    sort(all(A));
    rep(i, N) swap(A.at(i).first, A.at(i).second);
}
ll a_n(ll a, ll n) { 
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return ret * a_n(a, n-count) ;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(){
	int n;
	int ac = 0;
	int wa = 0;
	int tle = 0;
	int re = 0;
	char S[4];
	char a[4] = "AC";
	char w[4] = "WA";
	char t[4] = "TLE";
	char r[4] = "RE";

	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%s", S);
		if(strcmp(S,a) == 0)
			ac++;
		if(strcmp(S,w) == 0)
			wa++;
		if(strcmp(S,t) == 0)
			tle++;
		if(strcmp(S,r) == 0)
			re++;
	}

	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", ac, wa, tle, re);
	return 0;
}

Measured memory_bytes: 2144
/**
 * Contest : AtCoder Beginner Contest 160
 * Contest URL : https://atcoder.jp/contests/abc160
 * Problem : D - Line++
 * Problem URL : https://atcoder.jp/contests/abc160/tasks/abc160_d
 */

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair < int, int >;

// This section is for Policy Based Data Structure, more precisely Ordered Set.
// All Functions of set works here, in addition we have order_of_key() and find_by_order() function. find_by_order() returns iterator
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<functional>
using namespace __gnu_pbds;

// 1. Custom Set
template < class T, class COMP >
using custom_set = tree < T, null_type, COMP, rb_tree_tag, tree_order_statistics_node_update >;

// 2. Ordered Set
template < class T >
using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;

// 3. Ordered Multi Set
// For storing multiple occurance of same value we need to use pair. In pair first value is our key and second is useless count variable.
// order_of_key(make_pair(key, 0)) returns first occurance of a value, order_of_key(make_pair(key, INT_MAX)) returns last occurance.
template < class T >
using ordered_multiset = tree < pair < T, int >, null_type, less < pair < T, int > >, rb_tree_tag, tree_order_statistics_node_update >;

// 4. Ordered Map
template < class T, class U >
using ordered_map = tree < T, U, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
// Policy End

void solve() {
	int n, x, y;
	cin >> n >> x >> y;
	vector < int > count (n);
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			int dist = min (j - i, 1 + abs (i - x) + abs (j - y));
			count[dist]++;
		}
	}
	for (int i = 1; i < n; i++) {
		cout << count[i] << endl;
	}
}

int main() {
	ios_base::sync_with_stdio (false);
	cin.tie (0); cout.tie (0);
	int t = 1;
	// cin >> t;
	while (t--) {
	solve();
	}
	return 0;
}



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

int main()
{
    string Str;
    cin>>Str;

    for(int i=0;Str[i]!='\0';i++)
    {
        if(i%2==0)
        {
            cout<<Str[i];
        }
    }
    cout<<endl;
    return 0;
}


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

int main() {
    ll T1, T2, A1, A2, B1, B2;
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
    ll d1 = A1 - B1, d2 = A2 - B2;
    ll once = d1 * T1 + d2 * T2;
    if (once == 0) {
        cout << "infinity" << endl;
        return 0;
    } else if ((d1 > 0 && once > 0) || (d1 < 0 && once < 0)) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = d1 * T1 / (- once);
    if (d1 * T1 % (- once) == 0) {
        ans *= 2;
    } else {
        ans = 2 * ans + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for(int i = 0; i < n; ++i) {
            par[i] = i; rank[i] = 0; diff_weight[i] = SUM_UNITY;
        }
    }

    int find(int x) {
        if(par[x] == x) return x;
        else {
            int r = find(par[x]);
            diff_weight[x] += diff_weight[par[x]];  // 累積和を取る
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        find(x);
        return diff_weight[x];
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    bool unite(int x, int y, Abel w) {
        w += weight(x); w -= weight(y); // xとyそれぞれについて、rootとの重み差分を補正
        x = find(x); y = find(y);
        if(x == y) return false;
        if(rank[x] < rank[y]) swap(x, y), w = -w;   // rank[x] >= rank[y]になるようにswap
        if(rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w; // xがyの親になるので、xとyの差分をdiff_weight[y]に記録
        return true;
    }

    // 重みを取得する
    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

int main() {
    int n, q; cin >> n >> q;
    UnionFind<int> uf(n);
    for(int i = 0; i < q; ++i) {
        int c, x, y, z;
        cin >> c >> x >> y;
        if(c) {
            if(uf.same(x, y)) cout << uf.diff(x, y) << endl;
            else cout << "?" << endl;
        }else {
            cin >> z;
            uf.unite(x, y, z);
        }
    }
}


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

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#define    boost        ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define    nl           "\n"
#define    ll           long long
#define    pb           push_back
#define    mpr          make_pair
#define    fr(i,a,n)    for(ll i=a;i<n;++i)
#define    fr0(i,n)     for(ll i=0;i<n;++i)
#define    pii          pair<int, int>
#define    FO           find_by_order
#define    OK           order_of_key
#define    mem(a)       memset(a,0,sizeof(a))
#define    ff           first
#define    ss           second


typedef tree <
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update >
set_t;


void fio()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


template<typename T> void TIME(T start, T end)
{
#ifndef ONLINE_JUDGE
	double time_taken =  chrono::duration_cast<chrono::nanoseconds>(end - start).count();
	time_taken *= 1e-9;
	cout << "\nExecuted in: " << fixed
	     << time_taken << setprecision(9);
	cout << " sec";
#endif
}

///----------------------------- | FUNCTIONS | --------------------------------------///

/*
const int N = 2e5 + 5;

vector<int> adj[N];
bool visited[N];
//int val[N];
int depth[N];
//int parent[N];

void dfs(int v)
{
	visited[v] = true;
	for (int u : adj[v])
	{
		if (!visited[u])
		{
			//parent[u] = v;
			depth[u] = depth[v] + 1;
			dfs(u);
		}
	}
}
*/

// left shift << multiply by 2
// right shift >> divide by 2

///----------------------------- | START FROM HERE | --------------------------------------///

//#define int long long //change int main to int32_t main


void solve()
{
	int n, k; cin >> n >> k;
	int h[n + 5];
	fr0(i, n) cin >> h[i + 1];
	ll dp[n + 5];
	dp[1] = 0;
	//dp[2] = abs(h[2] - h[1]);
	//dp[3] = abs(h[3] - h[1]);
	fr(i, 2, n + 1)
	{
		dp[i] = INT_MAX;
		//dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
		fr(j, 1, k + 1)
		{
			if (i - j < 1) break;
			dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
		}
	}
	cout << dp[n] << nl;


}





int main()
{
	auto start = chrono::high_resolution_clock::now();
	boost;
	fio();
	int t;
	t = 1;
	//cin >> t;
	while (t--) solve();
	auto end = chrono::high_resolution_clock::now();
	TIME(start, end);
	return 0;
}




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

int main(){
  int n,m,x;
  cin >> n >> m >> x;
  long long ans=99999999999999999;
  vector<vector<int>> data(13,vector<int>(13));
  
  for(int i=0;i<n;i++){
    for(int j=0;j<=m;j++){
      cin >> data.at(i).at(j);
      }
     }
  
  bool over = true;
  
  //bit全探索
  for(int bit=0;bit < (1<<n) ;bit++){
    vector<long long> sum(14,0);
    long long money=0;
    over = true;
    for(int i=0;i<n;i++){
    if(bit & (1<<i)){
      money += data.at(i).at(0);
    
      for(int j=1;j<=m;j++){
        sum[j-1] += data.at(i).at(j);
      
      }
    }
    }
      for(int i=0;i<m;i++){
        if(sum[i]<x) over = false;
       
      }
      
    
    if(over) ans = min(ans,money);

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

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N, std::vector<long long> P)
{
}

int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> P(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &P[i]);
    }
    ll ans = 0;
    vector<ll> dp(N);
    dp.assign(N+10,0);
    for (int i = 0; i < N; i++)
    {
        int p = P[i];
        dp[p] = dp[p-1]+1;
        ans = max(ans,dp[p]);
    }

    cout <<  N -ans << endl;

    return 0;
}


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

#define F first
#define S second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define in(x) insert(x)
#define forr(i, a, b) for(int i = a;i <= b;i++)
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define did_you_calis_enough ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define int long long

using namespace std;

const int INF =  4294967295;
const int  N = 2e6 + 667;
const int mod = 1e9 + 7;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double PI = acos(-1.0);

main() {
	did_you_calis_enough
	for(int i = 0; i < 5;i++){
		int t;cin >> t;
		if(t == 0){
			cout << ++i;
		}
	}
	return 0;
}

//Coded by LoliThief

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <list>
#include <set>
#include <map>
#define F first
#define S second
#define pb push_back
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vLL vector<LL>
#define vpint vector<pair<int, int>>
#define vpLL vector<pair<LL, LL>>
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define fr(n) \
    for (int i = 0; i < n; i++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned long long LU;
const LL mod = 1e9 + 7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k, ans, mx = 0, mn = 1e9;
    cin>>n>>k;
    vint a(k);
    fr(k)
    {
        cin >> a[i];
        mn = min(mn, a[i]);
        mx = max(mx, a[i]);
    }
    ans = n;
    int check = n - (mx - mn);
    for (int i = 1; i < k; i++)
    {
        check = max(check, a[i] - a[i - 1]);
    }
    cout << ans - check << "\n";
    return 0;
}

Measured memory_bytes: 1024
import static java.lang.Integer.parseInt;

public class Main {

    public static void main(String[] args) {
        String line = new java.util.Scanner(System.in).nextLine();
        String[] number = line.split(" ", 0);
        int w = parseInt(number[0]);
        int h = parseInt(number[1]);
        int x = parseInt(number[2]);
        int y = parseInt(number[3]);
        int r = parseInt(number[4]);
        String ans = CircleInRectangle(w, h, x, y, r);
        System.out.println(ans);
    }

    public static String CircleInRectangle(int w, int h, int x, int y, int r) {
        if (r > 0 && r <= 100) {
            if ((x - r >= 0) && (x + r <= 100) && (x + r ) <= w) {
                if ((y - r >= 0) && (y + r <= 100) && (y + r ) <= h) {
                    return "Yes";
                } else {
                    return "No";
                }
            } else {
                return "No";
            }
        }
        else {
            return "No";
        }
    }
}

Measured memory_bytes: 26096
#include<stdio.h>
#define N 102
#define MAX 2001
static const int INFTY = (1<<21);

int main(){
	int n, i, j, e, sum = 0, area = 1, key, r;
	int A[N][N], p[N], q[N];
	scanf("%d", &n);
	for ( i = 0; i < n; i++ ){
		for ( j = 0; j < n; j++ ){
			scanf("%d", &e);
			A[i][j] = (e==-1)?INFTY:e;
		}
		p[i] = -1;
		q[i] = 0;
	}
	q[0] = 1;
	p[0] = 0;
	for(e = 0; e < n - 1; e++){
		key = MAX;
		for(i = 0; i < area; i++){
			for(j = 0; j < n; j++){
				if(q[j] == 0){
					if(A[p[i]][j] < MAX && key > A[p[i]][j]){
						key = A[p[i]][j];
						r = j;
					}
				}
			}
		}
		sum += key;
		area++;
		q[r] = 1;
		p[i] = r;
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
template <typename T>
using V = std::vector<T>;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, Q;
  cin >> N >> Q;
  vector<int> colors(N);
  REP(i, N) cin >> colors[i];

  int bsize = sqrt(N + 1) + 1;
  V<int> bucket(N);
  {
    int i = 0, k = 1;
    for (; i < N; ++k) {
      for (; i < N && i < k * bsize; ++i) {
        bucket[i] = k - 1;
      }
    }
  }

  V<tuple<int, int, int, int, int>> queries(Q);
  REP(i, Q) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    queries[i] = {bucket[l], bucket[r], l, r + 1, i};
  }
  sort(queries.begin(), queries.end());

  V<int> counter(500005);
  int cl = 0, cr = 0, ucount = 0;  //  unique count in [cl, cr).
  V<int> ans(Q);
  REP(i, Q) {
    auto [lb, rb, l, r, q] = queries[i];
    for (; cr < r; cr++) {
      if (counter[colors[cr]]++ == 0) ucount++;
    }
    for (; cl > l;) {
      --cl;
      if (counter[colors[cl]]++ == 0) ucount++;
    }
    for (; cr > r;) {
      --cr;
      if (--counter[colors[cr]] == 0) --ucount;
    }
    for (; cl < l; cl++) {
      if (--counter[colors[cl]] == 0) --ucount;
    }
    ans[q] = ucount;
  }
  REP(q, Q) { cout << ans[q] << '\n'; }
}


Measured memory_bytes: 21376
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=998244353;
const int maxn=5e5+5;
inline int read(){
	char c=getchar();int t=0,f=1;
	while((!isdigit(c))&&(c!=EOF)){if(c=='-')f=-1;c=getchar();}
	while((isdigit(c))&&(c!=EOF)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
int n,k;
inline int ksm(int a,int b){
	int ans=1;
	while(b){
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;b>>=1;
	}
	return ans;
}
int fac[maxn],inv[maxn];
inline int C(int n,int m){
	//printf("%lld %lld\n",n,m);
	if(m<0||m>n)return 0;
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
signed main(){
	n=read(),k=read();
	fac[0]=1;inv[0]=1;
	for(int i=1;i<=k;i++){
		fac[i]=fac[i-1]*i%mod;
		//printf("%lld %lld\n",i,fac[i]);
	}
	inv[k]=ksm(fac[k],mod-2);
	for(int i=k-1;i>=1;i--)inv[i]=inv[i+1]*(i+1)%mod;
	if(k<n){puts("0");return 0;}
	int ans=0;
	for(int r=0;r<=k;r++){
		int b=k-r;
		if(r<b)continue;
		if(r==b)b--;
		ans=(ans+C(b+r,r)-C(b+r,2*r-n+1)+mod)%mod;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
	char str[10],cnt;
	bool sign[10];	
	int idx;
	cin >> str;
	cnt=0; idx=0;
	sign[0] = false; sign[1] = false; sign[2] = false; sign[3]=false;
    for (int i=1; i<4; i++){
	  if (str[0] == str[i]) {
	    cnt = 1;
	    sign[0] = true;
	    sign[i] = true;
	    idx = i;
	    break;
	  }
	}
	if (cnt == 0) {
	  cout << "No" << endl;
	  return 0;
	}
    if (((idx==1) && (str[2]==str[3]) && (str[0]!=str[2])) ||
        ((idx==2) && (str[1]==str[3]) && (str[0]!=str[1])) ||
        ((idx==3) && (str[1]==str[2]) && (str[0]!=str[1]))) {
      cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	return 0;
}

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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__  "YES"
#define FALSE__ "NO"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a
#define lcoutln(a) cout << a << endl
#define lcerr(a) cerr << a
#define lcerrln(a) cerr << a << endl
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007
#define PI 3.141592653589793238462643383

signed main()
{
	init();
	solve();
}

int N;
vector<int> v;

void init()
{
	cin >> N;
	v.resize(N);
	rep(i, N) cin >> v[i];
}

void solve()
{
	int res = 0;
	reps(i, 1, N) {
		if (v[i] == v[i-1]) {
			i++;
			res++;
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 256
def resolve():
    import sys
    input = sys.stdin.readline
    # row = [int(x) for x in input().rstrip().split(" ")]
    # n = int(input().rstrip())
    # s = input().rstrip()

    n = int(input().rstrip())

    ans = 0
    prev = 0
    count = 0
    for h in input().rstrip().split(" "):
        h = int(h)
        if h <= prev:
            count += 1
        else:
            if count > ans:
                ans = count
            count = 0
        prev = h
    if count > ans:
        ans = count

    print(ans)




if __name__ == "__main__":
    resolve()


Measured memory_bytes: 78672
X = int(input())
 
score = 0
half_x = round(X/2)
 
answer = 0
 
if X <= 3:
    print(1)
 
elif X <= 7:
    print(4)
 
else:
    while 1 < half_x:
        half_x -= 1
        
        for p in range(2, 10):
            
            score = pow(half_x,p)
            if score > X:
                continue
        
            if answer < score:
                answer = score
                
    print(answer)

Measured memory_bytes: 3064
N, M = map(int, input().split())
H = [int(a) for a in input().split()]
X = [1] * N
for _ in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    if H[a] <= H[b]:
        X[a] = 0
    if H[b] <= H[a]:
        X[b] = 0
print(sum(X))


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

using namespace std;

int main(){
    int N, d;
    int dan = 0;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N ; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<int>());

    for(int j = 0; j < N ; j++){
        if(a[j] > a[j+1]){
            dan = dan + 1;
        }
    }
    cout << dan << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int a,b,c,poor;
  scanf("%d %d %d",&a,&b,&c);
  if(a==b&&b==c){
    poor=0;
  }
  else if(a==b||b==c||a==c){
    poor=1;
  }
  else poor=0;
  if(poor==1){
    printf("Yes");
  }
  else printf("No");
}

Measured memory_bytes: 128
#include<cstdio>

int main() {


	int	x=1;

	while (1) {
	
		int i;

		scanf("%d", &i);

		if (i == 0) break;  

		printf("Case %d: %d\n",x,i);

		x = x + 1;
	
	}
	return 0;
	}

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

int main() {
    set<char> alphbts;
    string s; cin >> s;
    for (char c : s) alphbts.insert(c);
    for (char c = 'a'; c <= 'z'; c++) {
        if (alphbts.count(c) == 0) {
            cout << c << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}


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

vector<int> v(26,0);

int main(){
	string s;
  cin>>s;
  for(auto a:s){
  	v[a-'a']++;
  }
  for(auto a:v){
  	if(a&1){
      cout<<"No";
      return 0;
    }	
   }
  cout<<"Yes";
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
    function Main(inputString: string) {
        // 1行目がinput[0], 2行目がinput[1], …に入る
        inputString = inputString.trim()
    	let lastChar = inputString.slice(-1)
		let resultString = ''
		if(lastChar == '3'){
			resultString = 'bon'
		}else if(lastChar == '0' || lastChar == '1' || lastChar == '6' || lastChar == '8'){
			resultString = 'pon'
		}else {
			resultString = 'hon'
		};
    	//出力
    	console.log('%s',resultString);
    }
    //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
	Main(require("fs").readFileSync("/dev/stdin", "utf8"));
	// Main("331")

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

using namespace std;

int main ( ) {
    int a, b, mult;

    cin >> a >> b;

    mult = a * b;
    if (mult % 2 == 1) {
        cout << "Odd" << endl;
    } else {
        cout << "Even" << endl;
    }
}

Measured memory_bytes: 256
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define each(i, ctn) for (auto &&i : (ctn))
#define all(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(12);*/ } } pre__;


int main() {
	int N;
	cin >> N;
	vi C(N), S(N), F(N);
	
	REP(i, N - 1) {
		C[i] = IN();
		S[i] = IN();
		F[i] = IN();
	}

	for (int k = 0; k < N - 1; ++k) {
		vi tl(N, 0);
		tl[k] = S[k];
		for (int i = k; i < N - 1; ++i) {
			int tli = S[i];
			while (tl[i] > tli) {
				tli += F[i];
			}
			tl[i + 1] = tli + C[i];
		}
		//OUT(tl[N - 2] + C[N - 2]);
		OUT(tl[N - 1]);
	}
	OUT(0);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(x,b) ((x)>=0&&(x)<(b))
#define Y first
#define X second
#define INF 1 << 30

typedef pair<int, int> pii;
typedef queue<int> qi;
typedef pair<int, int> pi;

int board[51][51], Y, X;
int dx[] = {0,1,0,-1}, dy[] = {1,0,-1,0};

pii nextp(pii now, int i, int d){
  pii next = now;
  next.Y += dy[i] * d;
  next.X += dx[i] * d;
  if(BW(next.Y, Y) && BW(next.X, X) && board[next.Y][next.X] == 0) return next;
  return now;
}
     
int main(){
  while(scanf("%d%d", &X,  &Y) && X+Y){
    int tx, ty, kx, ky;
    scanf("%d%d%d%d", &tx, &ty, &kx, &ky); tx--; ty--; kx--; ky--;
    rep(i, Y) rep(j, X) scanf("%d", &board[i][j]); 

    map<pair<pi,pi>, bool>m; // t k
    queue<pii>tq, kq;
    tq.push(make_pair(ty, tx));
    kq.push(make_pair(ky, kx));
    m[make_pair(make_pair(ty, tx), make_pair(ky, kx))] = 1;
    int res = 1;
    while(!tq.empty()){
      if(res >= 100) break;
      int qsize = (int)tq.size();
      rep(i, qsize){
	pii t = tq.front(); tq.pop();
	pii k = kq.front(); kq.pop();
	rep(j, 4){
	  pii nt = nextp(t, j, 1), nk = nextp(k, j, -1);
	  pair<pi, pi> next = make_pair(make_pair(nt.Y, nt.X), make_pair(nk.Y, nk.X));
	  if(m.count(next) == 1) continue;
	  if(nt == nk){
	    printf("%d\n", res);
	    goto end;
	  }
	  m[next] = 1;
	  tq.push(nt); kq.push(nk);
	}
      }
      res++;

    }
    puts("NA");
  end:;
  }
  return 0;
}

Measured memory_bytes: 12384
#include<bits/stdc++.h>
using namespace std;
#define Long long long
#define fastIO ios::sync_with_stdio(0) , cin.tie(0)

#define all(v) v.begin() ,v.end()
#define rall(v) v.rbegin(),v.rend()
#define forn(i,n) for(__typeof(n) i=0 ;i<n ;++i)
#define pb push_back
#define debug(x) cout << "[ " << #x << " = " << x << " ]\n"

#define PI acos(-1.0)
#define EPS 1e-6
#define MOD 1e9+7

const int MXS = 2e5 + 5 ;
const Long MX = 1e18 + 5 ;

Long po(Long a,Long b){
    if(b==0) return 1;
    Long aux = po(a,b/2);
    if( b%2 == 0) return aux*aux;
    else return a*aux*aux;
}

int main(){
    fastIO;
    Long x;
    cin >> x;
    
    Long l = ceil((double)sqrt(x));
    l = ceil((double)sqrt(l));
    Long r = -1*l;
    //cout << l <<" " << r;

    for(Long i = 1000  ; i >= -1000 ; i--){
        for(Long j = 1000 ; j >= -1000 ; --j){
            if( po(i,5)-po(j,5) == x){
                cout << i << " " << j <<'\n';
                return 0;
            }
        }
    }
    return 0;
}

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

int n,m,box[100007],result;
int x[100007],y[100007];
bool b[1000007];

void prob()
{
    for(int i=0;i<m;++i)
    {
        if(b[x[i]]==true) b[y[i]]=true;
        --box[x[i]]; ++box[y[i]];
        if(box[x[i]]==0) b[x[i]]=false; 
    }

    for(int i=1;i<=n;++i) if(b[i]==true) ++result;
}

void prepare()
{
    scanf("%i%i",&n,&m); result=0;
    for(int i=0;i<m;++i) scanf("%i%i",&x[i],&y[i]);
    for(int i=0;i<100007;++i) box[i]=1; b[1]=true;
}

int main()
{
    prepare();
    prob();
    printf("%i\n",result);
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  string c;
  cin >> c;
  int ans = 0;
  for (int l = 0, r = N - 1; l < r; l++, r--) {
    while (l < r && c[l] == 'R') l++;
    while (l < r && c[r] == 'W') r--;
    if (l == r) break;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3696
# -*- coding: utf-8 -*-
n = int(input())
l = [int(i) for i in input().split()]

l_sum = 0
for i in range(len(l)):
    if i != l.index(max(l)):
        l_sum += l[i]

if max(l) < l_sum:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
constexpr ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

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

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll N;
    cin >> N;
    cout << "ABC" << N << "\n";
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

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


int main(){
	
	int n,sum = 0;cin >> n;
	vector<int> v(n);
	REP(i,n){
		cin >> v[i];
		sum += v[i];
	}
	
	sort(ALL(v), greater<int>());
	
	if(v[0] < sum - v[0]){
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
import sys
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def prime_numbers(n):
    if n < 2:
        return []

    m = (n + 1) // 2
    p = [1] * m
    for i in range(1, int((n ** 0.5 - 1) / 2) + 1):
        if p[i]:
            p[2 * i * (i + 1) :: 2 * i + 1] = [0] * (((m - 1) - 2 * i * (i + 1)) // (2 * i + 1) + 1)

    return {2} | {2 * i + 1 for i in range(1, m) if p[i]}


def main():
    primes = prime_numbers(10 ** 5)
    A = [n in primes and (n + 1) // 2 in primes for n in range(10 ** 5 + 1)]
    A = tuple(accumulate(A))

    Q, *LR = map(int, open(0).read().split())
    ans = []
    for l, r in zip(LR[::2], LR[1::2]):
        ans.append(A[r] - A[l - 1])

    print(*ans, sep='\n')
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 29000
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

int main() {
	long n=0;
	cin >> n;

	long roop = long(sqrt(double(n)));
	long ans = 1 + n -2;
	for (long i = 2; i <= roop; ++i) {
		if ((n % i) == 0) {
			long temp = n / i;
			if (ans > temp + i - 2) {
				ans = temp + i - 2;
			}
		}
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
function gcd(a,b){return b?gcd(b,a%b):a;}

console.log(main());
function main(){
  var n = o.a();
  var k = o.a();
  var a = o.l();
  var x = a[0];
  for(var i = 1; i < n; i++){
    x = gcd(x,a[i]);
  }
  for(i = 0; i < n; i++){
    if(k > a[i])continue;
    if((a[i]-k)%x === 0)return "POSSIBLE";
  }
  return "IMPOSSIBLE";
}

Measured memory_bytes: 17612
#include <iostream>
#include <map>
 
using namespace std;
 
int main(){
    long long n, k;
    cin >> n >> k;
    
    map<int, long long> numbers;
    
    for(int i = 0; i < n; ++i){
        int a, b;
        cin >> a >> b;
        numbers[a] += b;
    }
           
    for(auto p : numbers){
        if(1 <= k && k < 1 + p.second){
            cout << p.first << endl;
            break;
        }
        k -= p.second;
    }
 
    return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;


int main() {
	ll a, b, c, k; cin >> a >> b >> c >> k;
	if (abs(a - b) > 1000000000000000000LL) {
		cout << "Unfair" << endl;
		return 0;
	}
	cout << (k & 1 ? b - a : a - b) << endl;
	return 0;
}


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

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (!a[i]) {
      cout << "0\n";
      return 0;
    }
  }
  const long long MAX = (long long) 1e18;
  long long product = 1;
  for (int i = 0; i < n; i++) {
    if ((long double) product > (long double) MAX / (long double) a[i]) {
      cout << "-1\n";
      return 0;
    }
    product *= a[i];
  }
  cout << product << endl;
  return 0;
}

Measured memory_bytes: 3992