akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#include <cassert>
#ifdef DEBUG
#include "./Lib/debug.hpp"
#else
#define dump(...)
template<class T>inline auto d_val(T a, T b) { return a; }
#endif

/* (=＾o＾=) */
#define int ll

/* macro */
#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPI2(it,b,e) for(auto it = (b); it != (e); ++it)
#define REPI(it,c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(),(x).end()
#define cauto const auto&
/* macro func */
#define SORT(x) do{sort(ALL(x));}while(false)
#define RSORT(x) do{sort((x).rbegin(),(x).rend());}while(false)
#define UNIQUE(v) do{v.erase( unique(v.begin(), v.end()), v.end() );}while(false)
#define MAX(x,y) do{x = std::max(x,y);}while(false)
#define MIN(x,y) do{x = std::min(x,y);}while(false)
#define BR do{cout<<"\n";}while(false)

/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;
template<class T>
using V = std::vector<T>;

/* using std */
using std::cout;
constexpr char endl = '\n';
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::unordered_multiset;
using std::multiset;
using std::bitset;
using std::priority_queue;

/* constant value */
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;

/* Initial processing  */
struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing;

/* Remove the source of the bug */
signed pow(signed, signed) { assert(false); return -1; }

/* define hash */
namespace std { template <>	class hash<std::pair<ll, ll>> { public:	size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } }; }

/* input */
template<class T> std::istream& operator >> (std::istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }

//=============================================================================================


signed main() {
	ll n;
	cin >> n;

	unordered_map<ll, ll> mp;
	REP(_, n) {
		ll x;
		cin >> x;
		mp[x]++;
	}

	ll m;
	cin >> m;
	REP(_, m) {
		ll x;
		cin >> x;
		mp[x]--;
	}
	REPC(p, mp)if (p.second < 0) { cout << "NO" << endl; return 0; }
	cout << "YES" << endl;
}

Measured memory_bytes: 8520
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <cmath> 
#include <cctype>

using namespace std;

int bsort(int A[], int N) {
    int count = 0;
    bool flag = true;
    for (int i = 0; flag; i++) {
        flag = false;
        for (int j = N - 1; j >= i + 1; j--) {
            if (A[j - 1] > A[j]) {
                swap(A[j - 1], A[j]);
                flag = true;
                count++;
            }
        }
    }

    return count;
}

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

    int count = bsort(A, N);

    for (int i = 0; i < N; i++) {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;

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


Measured memory_bytes: 3092
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
//#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;

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

    ll a,b,c,n,f=0,mini=INF;
    ll sum=0,maxi=0;
    string str,sub;
    ll h,w;
    ll m,k;
    cin>>n;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];
    rep(i,n){
        if(v[i]%2==0) sum++;
        else continue;
        v[i]/=2;
        if(v[i]%2==0) sum++;
    }
    if(n==1){
        if(sum==2) Yes;
        else No;
        return 0;
    }
    //cout<<sum<<endl;
    if(n/2*2<=sum) Yes;
    else No;
    return 0;
}


Measured memory_bytes: 1024
num = gets.to_i
arr = []
num.times do 
  arr << gets.to_i
end

minv = arr[0]
maxv = -20000000000
arr.shift

arr.each do |n|
  maxv = (maxv - ( n - minv )) > 0 ? maxv : n - minv
  minv = minv < n ? minv : n 
end

puts maxv



Measured memory_bytes: 9240
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int N, L;
  cin >> N >> L;
  string C;
  vector<string> vec(N);
  rep(i, N) {
    cin >> C;
    vec.at(i) = C; 
  }
  sort(vec.begin(), vec.end());
  rep(i, N) {
    cout << vec.at(i);
  }
}


Measured memory_bytes: 3596
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    string s;
    cin>>s;
    rep(i,3){
        if(s[i]==s[i+1]){
            cout<<"Bad"<<endl;
            return 0;
        }
    }
    cout<<"Good"<<endl;


    return 0;
}


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

int main(void) {
	int a, b, c, d, e, k,i=0;
	cin >> a >> b >> c >> d >> e >> k;
	if (0 <= a,b,c,d,e,k <= 123) {
		if (a < b < c < d < e) {
			if ((e - a) <= k){
				i = 1;
			}
		}
	}
	cout << ((i == 1) ? "Yay!" : ":(") << endl;
	return 0;
}

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

using namespace std;

#define ll long long
#define endl '\n'
const int N = 2e6 + 5;
ll fact[N];
ll mod = 1e9 + 7;
ll binpow(ll u, ll p){
        if (p == 0) return 1;
        if (p == 1) return u % mod;
        ll t = binpow(u, p / 2);
        if (p & 1) return t * t % mod * u % mod;
        else return t * t % mod;
}
ll nCk(ll k, ll n){
        return fact[n] * binpow(fact[k], mod - 2) % mod * binpow(fact[n - k], mod - 2) % mod;
}
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        if (fopen("GUARDS.INP", "r")){
                freopen("GUARDS.INP", "r", stdin);
                freopen("GUARDS.OUT", "w", stdout);
        }
        ll n;
        cin >> n;
        string s;
        cin >> s;
        n += s.length();
        ll ans = binpow(26, n);
        fact[0] = 1;
        for (int i = 1; i <= n; i++){
                fact[i] = fact[i - 1] * i % mod;
        }
        for (int i = 0; i < s.length(); i++){
                ans = (ans - nCk(i, n) * binpow(25ll, n - i) + mod * mod) % mod;
        }
        cout << ans;
}


Measured memory_bytes: 19796
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var a = new int[n];
        var b = new int[n];
        for (int i = 0; i < n; i++)
        {
            a[i] = int.Parse(Console.ReadLine().Trim());
            b[i] = a[i];
        }
        Array.Sort(a);
        var bmax = a[n - 1]; var bmax2 = a[n - 2];
        for (int i = 0; i < n; i++)
        {
            if (b[i] == bmax) Console.WriteLine(bmax2);
            else Console.WriteLine(bmax);
        }
    }
}


Measured memory_bytes: 17876
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define F first
#define S second
#define M6 3000009
#define M5 500009
#define pi 3.14159265
ll n,m,ar[M5],par[M5];
int  main()
{   ios_base::sync_with_stdio (0), cin.tie (0);
    ll test=1,t,flag,i,j,k,l,a,b,c,x,ans,y;
    string s1,s2;
    //cin>>test;
    while(test--){
        cin>>n;
        ans=200;
        for(i=1;i<n;i++){
            j=i; a=0,b=0;
            while(j) a+=j%10,j/=10;
            j=n-i;
            while(j) b+=j%10,j/=10;
            ans=min(ans,a+b);
        }
        cout<<ans;
    }
    return 0;
} 

Measured memory_bytes: 256
fn main() {
    let ab = read_vec::<usize>();
    println!("{}", ab[0] * ab[1]);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 2136
#include <iostream>
#include <vector>
using namespace std;
typedef long long LL;
int main(int argc, char* argv[])
{
	int N,i;
	cin>>N;
	const LL MAX=1000000000000000000;
	LL S=1;
	vector<LL> B(N);
	for (i=0;i<N;i++){
		cin>>B[i];
		if (B[i]==0){
			cout<<0<<endl;
			return 0;
		}
	}
	for (i=0;i<N;i++){
		LL S1=S*B[i];
		if (S1>MAX || S1<S){
			cout<<-1<<endl;
			return 0;
		}
		S=S1;
	}
	cout<<S<<endl;
	return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int a, b;
    cin >> a >> b;
    cout << max(0, a - b - b) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
    int w,h,n,x[1000],y[1000],ans=0;
    scanf("%d %d %d",&w,&h,&n);
    scanf("%d %d",x,y);
    for(int i=1;i<n;i++){
        scanf("%d %d",x+i,y+i);
        int dx=x[i]-x[i-1];
        int dy=y[i]-y[i-1];
        if(dx*dy<0) ans+=fabs(dx)+fabs(dy);
        else ans+=fmax(fabs(dx),fabs(dy));
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1036
import java.util.Scanner;
class Main{
	public static void main(String[]args) {
	Scanner scan=new Scanner(System.in);
	String a=scan.next();
	//int c=scan.nextInt();
	int ans=0;
	if(a.charAt(6)<'5') {
		ans=1;
	}
	else{
	}
	if(a.charAt(5)=='1') {
		ans=0;
	}
	System.out.println(ans==1?"Heisei":"TBD");
	}
}


Measured memory_bytes: 23764
import sys

n,m,x = map(int,input().split())

a = []
for i in range(n):
  a.append(list(map(int,input().split())))
  
money_min = sys.maxsize
ans = False

for i in range(2 ** n):
  s = bin(i).replace('0b','')
  s = s.zfill(n)
  
  tmp = [0] * (m+1)
  money = 0

  for j in range(len(s)):
    if s[j] == '1':
      money += a[j][0]
      for k in range(1,m+1):
        tmp[k] += a[j][k]
        
  flag = True
  for j in range(1,m+1):
    if tmp[j] < x:
      flag = False
      break
      
  if flag:
    money_min = min(money_min,money)
    ans = True
  
if ans:
  print(money_min)
else:
  print(-1)

Measured memory_bytes: 68688
#include<bits/stdc++.h>
      using namespace std;
      #define ll long long
      #define pb push_back
      #define pll  pair <long long,long long>
      #define mp make_pair
      #define ss second
      #define ff first
      #define maa 1000000007
      #define endl '\n'
      #define ld long double
      #define all(x) x.begin(),x.end()
      ll  power(ll  i,ll  j)
      {
        if(j==0)
        return 1 ;
        ll t=power(i,j/2)%maa ;
        if(j%2==0)
        return (t%maa*t%maa)%maa ;
        else
        return ((t%maa*t%maa)%maa*(i%maa)%maa)%maa ;
      }
      bool is(ll  i)
      {
        if(i==1)
            return 0 ;
        ll  f=0 ;
        for(ll  j=2;j<=sqrt(i);j++)
        {
            if(i%j==0)
            {
                f=1 ;
                break ;
            }
        }
        return !f ;
      }
      string s ;
      ll d ;
      ll dp[10001][101][2] ;
      ll fun(ll i,ll j,ll k)
      {
          if(i==s.length())
          {
              if(j==0)
              return 1 ;
              else
              return 0 ;
          
          }
          else if(dp[i][j][k]!=-1)
          return dp[i][j][k]%maa ;
          else
          {
              ll nj=j ;
              nj%=d ;
              nj+=(ll)(s[i]-'0') ;
              nj%=d ;
              ll ans=fun(i+1,nj,k)%maa ;
              
              for(ll u=0;u<(ll)(s[i]-'0');u++)
              {
                  nj=j ;
                  nj%=d ;
                  nj+=u ;
                  nj%=d ;
                  ans+=fun(i+1,nj,0)%maa ;
                  ans%=maa ;
              }
              if(k==0)
              {
               for(ll u=(ll)(s[i]-'0')+1;u<=9;u++)
              {
                  nj=j ;
                  nj%=d ;
                  nj+=u ;
                  nj%=d ;
                  ans+=fun(i+1,nj,0)%maa ;
                  ans%=maa ;
              }
              }
              
              return dp[i][j][k]=ans%maa ;
              
          }
      }
      int main()
      {

        /// 50-4
        /// freopen("input.txt","r",stdin);
        /// freopen("output.txt","w",stdout);
        cin>>s>>d ;
        for(ll i=0;i<=10000;i++)
        {
            for(ll j=0;j<=100;j++)
            {
                for(ll k=0;k<2;k++)
                dp[i][j][k]=-1 ;
            }
        }
        cout<<(fun(0,0,1)-1+maa)%maa ;
        
       
        
        

      }








Measured memory_bytes: 16768
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n;
    cin>>n;
    REP(i,n){
        int x;
        cin>>x;
        if(x%2){
            cout<<"first"<<endl;
            return 0;
        }
    }
    cout<<"second"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int n = sc.nextInt();
		int ans=102;
		int re=0;
		List<Integer> p = new ArrayList<Integer>();
		for(int i=0;i<n;i++) {
			p.add(sc.nextInt());
		}
		for(int i=101;i>=0;i--) {
			if(!p.contains(i)) {
				if(ans>=Math.abs(x-i)) {
					ans=Math.abs(x-i);
					re = i;
				}
			}
		}
		System.out.println(re);
	}
}

Measured memory_bytes: 35988
package main

import "fmt"

func main() {
	var s, t string
	fmt.Scanf("%s", &s)
	fmt.Scanf("%s", &t)

	if len(s) + 1 != len(t) {
		fmt.Println("No")
		return
	}

	if s != t[:len(t)-1] {
		fmt.Println("No")
		return
	}

	fmt.Println("Yes")
}


Measured memory_bytes: 1816
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vlll = vector<vll>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, LIS, digitDP, treeDP, Rerooting//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA, FordFulkerson//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q, T;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vll flag, D; vector<vpll> path; vs S;

int main() {
	cin >> N;
	vl A(N);
	for (i = 0; i < N; i++) cin >> A[i];
	vl sum(N + 1);
	for (i = 0; i < N; i++) {
		sum[i + 1] = (sum[i] + A[i]) % MOD;
	}
	for (i = 0; i < N; i++) {
		(ans += A[i] * sum[i]) %= MOD;
	}
	co(ans);
}

Measured memory_bytes: 6424
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <vector>
#define ll long long int
#define mp make_pair
#define pb push_back
#define vi vector<int>
using namespace std;
ll solve(){
    ll k,n;
    cin>>k>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans=k+a[0]-a[n-1];
    for(int i=1;i<n;i++){
        ans=max(ans,a[i]-a[i-1]);
    }
    return k-ans;

}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<solve();
}

Measured memory_bytes: 1792
N,T = map(int,input().split())

dic = {}
for i in range(N):
    c,t = map(int,input().split())
    dic[c] = t
list = []
for key, value in dic.items():
    if value <= T:
        list.append(key)

if len(list) > 0:
    print(min(list))
else:
    print('TLE')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a[32]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
	int k;
	cin>>k;
	cout<<a[k-1];
	return 0;
}


Measured memory_bytes: 3576
def show(a):
    print(a[0], a[1], sep = ' ')


l = input().split()
n = int(l[0])                  
q = int(l[1])                  

list_a = []
for i in range(n):
    a = input().split()
    list_a.append(a) 

time = 0          

while len(list_a) != 0:
    if int(list_a[0][1]) > q:
        time += q 
        list_a[0][1] = (int(list_a[0][1]) - q)
        a = list_a.pop(0)
        list_a.append(a)
    else :
        time += int(list_a[0][1])
        list_a[0][1] = time
        a = list_a.pop(0)
        show(a)


Measured memory_bytes: 17116
import qualified Data.ByteString.Char8 as B
import qualified Data.IntMap.Strict as IM
import Data.Maybe (fromJust)
import Data.List (sort)

unsafeReadInt :: B.ByteString -> Int
unsafeReadInt = fst . fromJust . B.readInt

elemToIndex :: [Int] -> IM.IntMap Int
elemToIndex = IM.fromList . flip zip [0 ..]

minOps :: [Int] -> Int
minOps xs = length . filter f $ xs
    where
        raw = elemToIndex xs
        sorted = elemToIndex $ sort xs
        f i = odd (raw IM.! i) && even (sorted IM.! i)

main :: IO ()
main = B.getLine >>
    B.getContents >>= print . minOps . fmap unsafeReadInt . B.lines


Measured memory_bytes: 56700
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import fractions
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N = getN()

num = [1]
sixsta = 6
while sixsta < 100000:
    num.append(sixsta)
    sixsta *= 6

ninesta = 9
while ninesta < 100000:
    num.append(ninesta)
    ninesta *= 9
num.sort()

dp = [float('inf')] * 100001
dp[0] = 0
for i in range(N + 1):
    for k in range(len(num)):
        if i >= num[k]:
            dp[i] = min(dp[i], dp[i - num[k]] + 1)
print(dp[N])


Measured memory_bytes: 70088
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return str;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() { return Long.parseLong(next());  }
    }

    public static void main(String[] args) {
        FastReader sn = new FastReader();
        int N = sn.nextInt();
        int K = sn.nextInt();
        int []arr = new int[N];
        for(int i=0;i<N;i++) {
            arr[i] = sn.nextInt();
        }
        Arrays.sort(arr);
        int sum=0;
        for(int i=0;i<K;i++) {
            sum+=arr[i];
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 25932
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

ll binpow(ll a, ll b) {
    if (b == 0)
    {
        return 1;
    }
    ll res = binpow(a, b / 2);
    res*=res;
    if (b % 2)
    {
        return res * a;
    }
    return res;
}

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

string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    n%=10;
    for (auto i : {2,4,5,7,9})
        if (i==n)
            cout<<"hon";
    for (auto i : {0,1,6,8})
        if (i==n)
            cout<<"pon";
    for (auto i : {3})
        if (i==n)
            cout<<"bon";
    return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int l[n];
    for(int i=0; i<n; i++) cin >> l[i];
    sort(l, l+n);

    int sum=0;
    for(int i=0; i<k; i++) sum += l[n-i-1];

    cout << sum << endl;

    return 0;
}



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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int64_t> H(N);
  for (int i=0; i<N; i++){
    cin >> H.at(i);
  }
  vector<int> A(M), B(M);
  vector<vector<int>> J(N);
  for (int i=0; i<M; i++){
    cin >> A.at(i) >> B.at(i);
    J.at(A.at(i)-1).push_back(B.at(i)-1);
    J.at(B.at(i)-1).push_back(A.at(i)-1);
  }
  
  int s=0;
  bool tembo;
  int ans = 0;
  for (int i=0; i<N; i++){
    s=J.at(i).size();
    tembo=true;
    if (s != 0){
      for (int j=0; j<s; j++){
        if (H.at(i) <= H.at(J.at(i).at(j))){
          tembo=false;
          break;
        }
      }
    }
    if(tembo)  ans++;
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 9860
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;
constexpr ll inf = 2e18;

inline auto primes (ll n)
{
  vector <ll> res = {2, 3};
  for (ll i = 3; i <= n; i += 2)
  {
    if (all_of (ALL (res), [&] (auto && p) { return i % p != 0; }))
    {
      res.push_back (i);
    }
  }
  return res;
}

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

  ll x;
  cin >> x;

  if (x == 2)
  {
    cout << 2 << endl;
    return 0;
  }

  vector <ll> primes = {2};
  ll i = 3;

  while (i < x)
  {
    if (all_of (ALL (primes), [&] (auto && p) { return i % p != 0; }))
    {
      primes.push_back (i);
    }
    ++ i;
  }

  while (true)
  {
    if (all_of (ALL (primes), [&] (auto && p) { return i % p != 0; }))
    {
      primes.push_back (i);
      break;
    }
    ++ i;
  }
  cout << i << endl;
}


Measured memory_bytes: 512
N=int(input())
x=list(map(int, input().split()))
a=0
b=0
for i in range(N):
  a+=x[i]**2
for j in range(N):
  b+=x[j]
def func(p):
  return a-2*p*b+(p**2)*N

q=b//N

print(min(func(q),func(q+1)))

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

int main() {
  int N, pe;
  cin >> N;
  vector<int> l(N, 0), r(N, 0);
  
  for (int i = 0; i < N; i++) {
    cin >> l.at(i);
    cin >> r.at(i);
  }
  
  for (int i = 0; i < N; i++) {
    pe += r.at(i) - l.at(i) + 1;
  }
  
  cout << pe << endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll K = 0;
ll t;
ll ret = 0;
string s;

void input() {
  IN(N);
  IN(s);
}

void solve() {
  ll q = 0;
  REP(i, N-2) {
    char c1 = s[i];
    char c2 = s[i+1];
    char c3 = s[i+2];
    if (c1 == 'A' && c2 == 'B' && c3 == 'C') ret++;
  }
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REV(v) reverse(v.begin(), v.end());
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, start, stop) for (int i = start; i < stop; i++)
#define FORR(i, start, stop) for (int i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<int>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<int>());
#define REMOVE(v,n) remove(vector<int> v,v+v.size(),int n)
#define ERASE(v,n) v.erase(v.begin()+n);
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<int> vint;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
const int MOD = 1000000007;
void chmin(int &a, int b) { if (a > b) a = b; }


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

    ll H,W;
    cin>>H>>W;
    vector< vector<ll> > c (10, vector<ll>(10) );
    FOR(i,0,10)
        FOR(j,0,10)cin>>c[i][j];
    FOR(k,0,10)
        FOR(i,0,10)
            FOR(j,0,10)
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
    
    ll temp;
    ll ans=0;
    FOR(i,0,H*W){
        cin>>temp;
        if(temp!=1 && temp!=-1)ans+=c[temp][1];
    }

    cout<<ans<<endl;
    
}


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

bool isprime(int a)
{
    if (a%2 == 0) return 0;
    for(int i = 3; i <= sqrt(a); i = i + 2)
    {
        if (a%i == 0) return 0; 
    }
    return 1;
}

int main()
{
    int n, count = 0;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i]; 
        if (a[i] == 2) count++;
        if (isprime(a[i]) == 1) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3108
/// However long the night,
///     The dawn will break
/// ICPC next year

#include<bits/stdc++.h>
using namespace std ;
const int N = 1e3+5 ;
int n ,m ,a ,b ;
vector<int> adj[N] ;
vector<int> v ,ans ;
int len = 1e9 ;
int vis[N] ,pos[N] ,vid ;
void dfs(int p,int root,bool work){
    if(work && p==root){
        if(v.size() < len) len = v.size() ,ans = v ;
        return ;
    }
    if(vis[p]==vid) return ;
    vis[p] = vid ;
    pos[p] = v.size() ;
    v.push_back(p);
    for(int ch:adj[p]) dfs(ch,root,1) ;
    v.pop_back();
}
int main(){
    scanf("%d%d",&n,&m);
    while(m--){
        scanf("%d%d",&a,&b);
        adj[a].push_back(b);
    }
    for(int i=1;i<=n;++i){
        ++vid ;
        dfs(i,i,0);
    }
    if(len>n) return cout << -1,0 ;
    cout << len << endl ;
    for(int go:ans)printf("%d\n",go);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define mk make_pair
int main(){
    int h,w;
    while(cin>>h>>w,h||w){
        pair<int,pair<int,int>> in=mk(w*w+h*h,mk(h,w)),ans=mk(1e9,mk(1e9,1e9)),tmp;
        for(int i=1;i<1000;++i){
            for(int j=i+1;j<1000;++j){
                tmp=mk(i*i+j*j,mk(i,j));
                if(tmp>in){
                    ans=min(ans,tmp);
                }
            }
        }
        cout<<ans.second.first<<" "<<ans.second.second<<endl;
    }
}

Measured memory_bytes: 1160
/*
	Copyright: razouq (c)
	Author: Anass BENDARSI
	Date: 12/05/2018 12:03:37
	flamers will **** you
*/
//#include<flamers.h>

#include "bits/stdc++.h"
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define PB push_back
#define POB pop_back

using namespace std;
bool compare(pair<int, int> p1, pair<int, int> p2){
	 if(1) return true;
	 return false;
}

int main(){
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie();
	int a, b, c, d;
	cin>>a>>b>>c>>d;
	if((abs(a-b) <= d && abs(c-b) <= d) || abs(a-c) <= d ) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<algorithm>//min,max,swap,rand,reverse,sort,lower_bound
#include<functional>
#include<vector>
#include<list>
#include<map>
#include<tuple>
#include<cmath>//abs, sin, cos
#include<bitset>
using namespace std;

int main()
{
	int K, N, t;
	vector<int> A,B;
	cin >> K >> N;

	for (int i = 0; i < N; i++) {
		cin >> t;
		A.push_back(t);
	}

	for (int i = 0; i < N-1; i++) {
		t = A[i + 1] - A[i];
		B.push_back(t);
	}

	t = K - A[N-1] + A[0];
	B.push_back(t);
	sort(B.begin(), B.end());
	int distance = 0;
	for (int i = 0; i < B.size() - 1; i++) {
		//cout << B[i] << endl;
		distance += B[i];
	}

	cout << distance << endl;

	return 0;
}

Measured memory_bytes: 5164
n = gets.to_i
t = 1
a = 1

n.times do
  ct, ca = gets.chomp.split.map(&:to_i)
  dt = (t + ct - 1) / ct
  da = (a + ca - 1) / ca
  d = [dt, da].max

  t = d * ct
  a = d * ca
end
puts a + t

Measured memory_bytes: 14260
a, b = map(int, input().split())
if a >= 1:
    print("Positive")
elif a <= 0 and 0 <= b:
    print("Zero")
elif a < 0 and b < 0:
    if (b - a + 1) % 2 == 0:
        print("Positive")
    else:
        print("Negative")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    int n, cnt=1; cin >> n;
    char prv;
    string s; cin >> s;
    prv = s[0];
    for(int i = 1; i < n; i++){
        if(s[i] != prv){
            cnt++; prv = s[i];
        }
    }
    cout << cnt << endl;
    return 0;
}


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

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define int long long

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>

#define vi vector<int>

#define vpi vector< pi >

#define mi map<int,int>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int md = 1e9+7;
const int MX = 2e5+5;
const int INF = 1e18; 


int power_md(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res=(res%md*a%md)%md;
  a=(a%md*a%md)%md;
  n/=2;
}
res%=md;
return res;
}

int power(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a=a*a;
  n/=2;
}
return res;
}

int abst(int a)
{
 return ((a<0)?(-1*a):(a));
}

class cmp_set{
public:
	bool operator() (int a, int b){
		return a > b;
	}
};

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

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

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define NIL NULL

struct Node{
	int key;
	int priority;
	struct Node *r,*l,*p;
}Node;

struct Node *Delete(struct Node **t, int key);
struct Node *_delete(struct Node **t, int key);

void preorder( struct Node *u ){
	
	printf(" %d",u->key);
	if(u->l!=NIL){
		preorder(u->l);
	}
	if(u->r!=NIL){
		preorder(u->r);
	}
	return;
}

void inorder( struct Node *u ){
	
	if(u->l!=NIL){
		inorder(u->l);
	}
	printf(" %d",u->key);
	if(u->r!=NIL){
		inorder(u->r);
	}
	return;
	
}

int find( struct Node *u , int k ){
	while( u != NIL ){
		if( u->key == k ){
			return 1;
		}else if( k < u->key ){
			u = u->l;
		}else{
			u = u->r;
		}
	}
	return 0;
}

struct Node *rightRotate(struct Node *t){
    struct Node *s = t->l;
    t->l = s->r;
    s->r = t;
    return s;
}

struct Node *leftRotate(struct Node *t){
    struct Node *s = t->r;
    t->r = s->l;
    s->l = t;
    return s;
}

struct Node* node( int x , int y ){
	
	struct Node *new = malloc(sizeof(Node));
	new->key = x;
	new->priority = y;
	new->l = NIL;
	new->r = NIL;
	
	return new;
}

struct Node* insert(struct Node **t, int key, int priority){
	
	struct Node *new;
	if( *t == NIL ){
        return new = node(key, priority);
	}
	if( key == (*t)->key ){
        return *t;
	}

	if( key < (*t)->key ){
		(*t)->l = insert(&(*t)->l, key, priority);
		if ( (*t)->priority < (*t)->l->priority ){
            *t = rightRotate(*t);
		}
	}else{
		(*t)->r = insert(&(*t)->r, key, priority);
		if( (*t)->priority < (*t)->r->priority ){
            *t = leftRotate(*t);
		}
	}
	return *t;
}

struct Node *Delete(struct Node **t, int key){
	
	if ((*t) == NIL){
		return NIL;
	}
	if ( key < (*t)->key ){
		(*t)->l = Delete(&((*t)->l), key);
	}else if ( key > (*t)->key ){
		(*t)->r = Delete(&((*t)->r), key);
	}else{
        return _delete(t, key);
	}
    return *t;
}

struct Node *_delete(struct Node **t, int key){                
		if ((*t)->l == NIL && (*t)->r == NIL ){               
        	return NIL;
		}else if ( (*t)->l == NIL ){
        	*t = leftRotate(*t);
		}else if ((*t)->r == NIL){
        	*t = rightRotate(*t);
		}else{
			if ((*t)->l->priority > (*t)->r->priority ){
            	*t = rightRotate(*t);
			}
			else{
            	*t = leftRotate(*t);
			}
		}
    return Delete(t, key);
}

int main( void ){
	int n , i , x , y;
	char com[10];
	struct Node *root = NIL;
	
	scanf( "%d", &n );
	
	for( i=0;i<n;i++ ){
		
		scanf("%s",com );
		if( strcmp(com ,"find") == 0 ) {
			scanf( "%d",&x );
			if( find(root,x) ){
				printf( "yes\n" );
			}else{
				printf("no\n");
			}
		}else if( strcmp(com ,"delete") == 0 ){
			scanf( "%d" , &x );
			root = Delete(&root,x);
		}else if( strcmp(com,"insert") == 0 ){
			scanf("%d %d",&x,&y);
			root = insert(&root,x,y);
		}else if( strcmp(com ,"print") == 0 ){
			inorder(root);
			printf( "\n" );
			preorder(root);
			printf( "\n" );
		}
	}
	
	return 0;
}



Measured memory_bytes: 11144
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
     
template <typename Weight, int MAX_N, Weight INF> class MaxFlow{
private:
	struct E{
		int to, rev;
		Weight lim;
		E(int x, Weight y, int z){
			to = x;
			lim = y;
			rev = z;
		}
	};
     
	vector<E> edge[MAX_N];
	int lev[MAX_N];
	int iter[MAX_N];
     
     
	Weight dfs(int s, int g, Weight f){
		if(s == g)return f;
		for(int &i = iter[s];i < edge[s].size();i++){
			E &e = edge[s][i];
			if(lev[e.to] <= lev[s] || e.lim <= 0)continue;
			Weight tmp = dfs(e.to, g, min(f, e.lim));
			if(tmp<1e-9)continue;
			e.lim -= tmp;
			edge[e.to][e.rev].lim += tmp;
			return tmp;
		}
		return 0;
	}
     
	void bfs(int x){
		queue<int> q;
		q.push(x);
		int p = 0;
		while(!q.empty()){
			for(int i = q.size();i--;){
				int tmp = q.front();q.pop();
				if(lev[tmp] != MAX_N)continue;
				lev[tmp] = p;
				for(int j = 0;j < edge[tmp].size();j++){
					if(edge[tmp][j].lim > 0 && lev[edge[tmp][j].to] == MAX_N)q.push(edge[tmp][j].to);
				}
			}
			p++;
		}
	}
     
public:
	void make_edge(int a, int b, Weight l){
		edge[a].push_back(E(b, l, edge[b].size()));
		edge[b].push_back(E(a, 0, edge[a].size() - 1));
	}
     
	Weight max_flow(int s, int g){
		Weight res = 0;
		bool fin = false;
		while(!fin){
			fill(lev, lev + MAX_N, MAX_N);
			fill(iter, iter + MAX_N, 0);
			bfs(s);
			fin = true;
			while(true){
				Weight p = dfs(s, g, INF);
				if(p < 1e-9)break;
				fin = false;
				res += p;
			}
		}	
		return res;
	}
};
     

int n;
int a[500];

int main(){
	cin >> n;
	MaxFlow <long long, 500, (1LL<<60) > mf;
	long long sum = 0;
	for(int i = 1;i <= n;i++){
		cin >> a[i];
		sum += max(a[i], 0);
	}

	for(int i = 1;i <= n;i++){
		mf.make_edge(0, i, max(a[i], 0));
		mf.make_edge(i, n+1, max(-a[i], 0));
		for(int j = 1;j < i;j++){
			if(i%j)continue;
			mf.make_edge(i, j, (1LL<<40));
		}
	}
	cout << sum - mf.max_flow(0, n+1) << endl;

	
	return 0;
	
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
#define rep(x,y) for(x=0;x<(y);++x)
void in();
void solve();
int bod[14];
int main()
{
	int t;
	cin>>t;
	int ti;
	rep(ti,t)
	{
		in();
		solve();
	} 
	return 0;
}
void in()
{
	int i;
	rep(i,10)
	{
		cin>>bod[i];
	}
}
void solve()
{
	int l=0,r=0,u;
	int le[11],ri[11];
	for(u=0;u<10;++u)
	{
		if(0==l)
		{
			le[0]=bod[u];
			++l;
		}
		else if(bod[u]>le[l-1])
		{
			le[l]=bod[u];
			++l;
		}
		else if(0==r||bod[u]>ri[r-1])
		{
			ri[r]=bod[u];
			++r;
		}
		else
		{
			cout<<"NO\n";
			return;
		}
	}
	cout<<"YES\n";
}

Measured memory_bytes: 1120
#include<iostream>

using namespace std;

int main () {
	int N;
	cin >> N;
	int a,b,c;
	
	if (N % 2 == 0) {
		a = (N / 2) -1;
	}
	else {
		a = (N - 1) / 2;
	}
	cout << a << endl;

}

Measured memory_bytes: 384
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func next() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = nextInt()
	}
	return ints
}

func sum(array []int, start int, end int) int {
	ret := 0
	for i := start; i < end; i++ {
		ret += array[i]
	}
	return ret
}

func main() {
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	weights := nextInts(n)

	var min float64
	min = 10000
	for i := 0; i < n-1; i++ {
		sum1 := sum(weights, 0, i+1)
		sum2 := sum(weights, i+1, n)
		diff := math.Abs(float64(sum1 - sum2))
		if diff < min {
			min = diff
		}
	}

	fmt.Println(int(min))
}


Measured memory_bytes: 640
using System;
using System.Collections.Immutable;
using System.Linq;

namespace AtCoder
{
    public class Solver
    {
        private readonly IInputReader _inputReader;
        private readonly IOutputWriter _outputWriter;

        public Solver(IInputReader inputReader, IOutputWriter outputWriter)
        {
            _inputReader = inputReader;
            _outputWriter = outputWriter;
        }

        public void Solve()
        {
            var numbers = _inputReader.ReadLine().ToIntArray().ToList();
            numbers.Sort();

            var result = numbers[0] == 5 && numbers[1] == 5 && numbers[2] == 7;

            _outputWriter.WriteLine(result ? "YES" : "NO");
        }
    }


    internal class Program
    {
        static void Main(string[] args)
        {
            var reader = new ConsoleInputReader();
            var writer = new ConsoleOutputWriter();
            new Solver(reader, writer).Solve();
        }
    }

    public interface IInputReader
    {
        string ReadLine();
    }

    public interface IOutputWriter
    {
        void WriteLine(string output);
    }

    internal class ConsoleInputReader : IInputReader
    {
        public string ReadLine() => Console.ReadLine();
    }

    internal class ConsoleOutputWriter : IOutputWriter
    {
        public void WriteLine(string output) => Console.WriteLine(output);
    }

    public static class StringExtensions
    {
        public static char ToChar(this string text) => text[0];
        public static int ToInt(this string text) => int.Parse(text);
        public static int[] ToIntArray(this string text) => text.Split(' ').Select(txt => txt.ToInt()).ToArray();
        public static long ToLong(this string text) => long.Parse(text);
        public static long[] ToLongArray(this string text) => text.Split(' ').Select(txt => txt.ToLong()).ToArray();
    }
}

Measured memory_bytes: 28020
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<tgmath.h>
#include<stdbool.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

int c[9][9];

bool hoge(int i, int j, int k){
	return (i == j) && (j == k);
}

int main(){
	for(int i=0; i<3; i++)for(int j=0; j<3; j++)scanf("%d", &c[i][j]);
	if(hoge(c[1][0]-c[0][0], c[1][1]-c[0][1], c[1][2]-c[0][2]) && hoge(c[2][0]-c[1][0], c[2][1]-c[1][1], c[2][2]-c[1][2]) && hoge(c[0][1]-c[0][0], c[1][1]-c[1][0], c[2][1]-c[2][0]) && hoge(c[0][2]-c[0][1], c[1][2]-c[1][1], c[2][2]-c[2][1])){
		puts("Yes");
	}else {
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 128
n = int(input())
t = list(map(int,input().split()))
m = int(input())
p = [0]*m
x = [0]*m
for i in range(m):
    p[i],x[i] = list(map(int,input().split()))
for i in range(m):
    q = sum(t) - t[p[i]-1] + x[i]
    print(q)

Measured memory_bytes: 3064
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	n, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return n
}

type Card struct {
	Suit string
	Rank int
}

var Suits = []string{"S", "H", "C", "D"}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanLines)
	n := nextInt(sc)

	cards := make(map[Card]struct{})
	for i := 0; i < n; i++ {
		sc.Scan()
		s := strings.Split(sc.Text(), " ")
		c := Card{
			Suit: s[0],
			Rank: func() int {
				n, _ := strconv.Atoi(s[1])
				return n
			}(),
		}
		cards[c] = struct{}{}
	}

	for _, s := range Suits {
		for i := 1; i < 14; i++ {
			_, ok := cards[Card{s, i}]
			if !ok {
				fmt.Println(s, i)
			}
		}
	}

}



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

int main(){
    string S,T,U;
    int A,B;

    cin >> S >> T >> A >> B >> U;

    if(S == U) cout << (A-1) << " " << B << endl;
    if(T == U) cout << A << " " << (B-1) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;
int main() {
  ll n, cunt = 0;
  cin >> n;
  vector<int> a(n);
  for (ll i = 1; i <= n; i++) {
    cin >> a[i];
    if (i % 2 == 1) {
      if (a[i] % 2 == 1) {
        cunt++;
        // cout << "i" << i << " a[i] " << a[i] << endl;
      }
    }
  }
  cout << cunt << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#include <vector>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  int total = 0;
  vector<int> l(n);
  rep(i,n){
    cin >> l[i];
    total += l[i];
  }
  rep(i,n){
    for(int j = n - 1; j > i; j--){
      if(l[j] > l[j-1]){
        int temp = l[j];
        l[j] = l[j - 1];
        l[j - 1] = temp;
      }
    }
  }
  if(n/2 > k){
    int ans = 0;
    rep(i, k) ans += l[i];
    cout << ans << endl;
  }else{
    int ans = 0;
    for(int i = n-1; i >= k; i--) ans += l[i];
    cout << total - ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,m,n) for(ll i=m;i<(ll)(n);i++)
typedef pair<int,long long> pint;
typedef long long ll;
const ll mod= 1e9+7;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

ll dp[60][6000];

int main(){
  int n;cin>>n;
  int x;cin>>x;
  int a[n];
  rep(i,n){
    cin>>a[i];
    a[i]-=x;
    }
  dp[0][3000]=1;
  rep(i,n)rep(j,6000){
    if(0<=j-a[i]&&j-a[i]<6000){
      dp[i+1][j]=dp[i][j]+dp[i][j-a[i]];
      }
    else dp[i+1][j]=dp[i][j];
    }
  cout<<dp[n][3000]-1<<endl;
  return 0;
  }

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

int main () {
    int n;
    std::cin >> n;

    std::vector<int> d(n);
    for (int i = 0; i < n; i++)
    {
        std::cin >> d[i];
    }

    std::sort(d.begin(), d.end());

    std::cout << d[d.size() / 2] - d[d.size() / 2 - 1] << std::endl;
}


Measured memory_bytes: 640