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

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << "Line " << __LINE__ << ": " <<  #x << " = " << (x) << "\n";
#define spa << " " <<
#define fi first
#define se second
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()

using ld = long double;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;

template<typename T> using V = vector<T>;
template<typename T> using P = pair<T, T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){os << "(" << v.first << ", " << v.second << ")"; return os;}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<vector<T>> &v){ for(auto &e : v){os << e << "\n";} return os;}
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

template <class T> void UNIQUE(vector<T> &x) {sort(ALL(x));x.erase(unique(ALL(x)), x.end());}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
void fail() { cout << -1 << '\n'; exit(0); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<"\n";}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<"\n";};

const ll INF = (1ll<<62);
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
const ll mod = (int)1e9 + 7;
//const ll mod = 998244353;

int main(){

    ll N;
    cin >> N;
    V<ll> x(N), y(N);
    REP(i, N) cin >> x[i] >> y[i]; 
    V<ll> a(N), b(N);
    REP(i, N){
        a[i] = x[i] + y[i];
        b[i] = x[i] - y[i];
    }
    sort(ALL(a));
    sort(ALL(b));
    ll res = max(a.back()-a[0], b.back()-b[0]);
    cout << res << endl;

    return 0;
}

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

typedef long long ll;

int main()
{
	int n;
	cin >> n;
	vector<vector<int>> arr(n,vector<int>(3,0));
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < 3; j++)
		{
			cin >> arr[i][j];
		}
	}
	vector<vector<int>> dp_arr(n+1,vector<int>(3,0));
	int max_ = 0;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 0; j < 3; j++)
		{
			int temp = 0;
			for(int k = 0; k < 3; k++)
			{
				if(k != j)
				{
					temp = max(temp, dp_arr[i-1][k]);
				}
			}
			dp_arr[i][j] = temp + arr[i-1][j];
			max_ = max(max_,dp_arr[i][j]);
		}
	}
	cout << max_ << endl;
}


Measured memory_bytes: 11136
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string T = Console.ReadLine();
            if(s == T.Substring(0, T.Length - 1))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



Measured memory_bytes: 25872
#include<bits/stdc++.h>
#include<vector>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define CEVCOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void){


    string s;	cin >> s;
    
    for(int i = 0 ; i < s.length() ; i++){
      if(i % 2 == 0){
	  	if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D'){
	    SCOUT("No") << endl;
	    break;
	  	}
      }else{
	  	if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D'){
	    SCOUT("No") << endl;
	    break;
	  	}
      }

      if(i == s.length() - 1) SCOUT("Yes") << endl;

    }

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
ll gcd(ll x,ll y){
  if(x == 0){
    return y;
  }

  return gcd(y%x,x);
}
int main() {
  ll n,m;
  cin >> n >> m;
  vector<ll> vec(n);
  rep(i,n){
    cin >> vec[i];
  }
  ll cou = 0;
  tmp1 = vec[0];
  while(tmp1 % 2 == 0){
    tmp1 /= 2;
    cou++;
  }
  ll tmp = 1 << cou;
  //cout << tmp;
  bool can = true;
  rep(i,n){
    if(vec[i] % tmp == 0 && vec[i] % (tmp*2) != 0){

    }else{
      //cout << vec[i] << endl;
      can = false;
    }
  }
  sort(all(vec));
  ll ans;
  if(can){
    ll sum = 1;
    rep(i,n){
      if(sum % vec[i] != 0){
        if(sum > vec[i]){
          swap(sum,vec[i]);
        }
        sum = sum * (vec[i] / gcd(sum,vec[i]));
        if(sum > m * 2){
          sum = INFLONG;
          break;
        }
      }
    }
    ans = (m + sum / 2) / sum;
  }else{
    ans = 0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;
long long int inf = 1e18;

int main() {
  int n, y;
  cin >> n >> y;

  for(int i=0; i<=n; i++){
    for(int j=0; i+j<=n; j++){
      int k = n - i - j;
      if( k < 0 ) continue;
      if( i*10000 + j*5000 + k*1000 == y ){
        printf("%d %d %d\n", i, j, k);
        return 0;
      }
    }
  }
  printf("%d %d %d\n", -1, -1, -1);

  return 0;
}




//


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#define ll long long int
#define lim 100010
#define INF 1e9
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define ABS(x) ((x)>0?(x):-(x))

int main(void){
	int n;
	scanf("%d",&n);
	int p[n];
	for(int i=0;i<n;i++)scanf("%d",&p[i]);
	int a,b,c;
	int ans=0;
	for(int i=0;i+2<n;i++){
		a = p[i];
		b = p[i+1];
		c = p[i+2];
		if(a<b && b<c)ans++;
		if(c<b && b<a)ans++;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=100010;
const int inf=2147483647;
int n,m,cnt;
int f[maxn];
int find(int x){
	if(x==f[x])return x;
	else return f[x]=find(f[x]);
} 
int main(){
	cin>>n>> m;
	for(int i=1;i<=n;i++)f[i]=i;
	while(m--){
		int x,y,z;
		cin>>x>>y>>z;
		int fatherx=find(x);
		int fathery=find(y);
		if(fatherx!=fathery){
			f[fatherx]=fathery;
			cnt++;
		}
	}
	cout<<n-cnt<<endl;
	return 0;
}


Measured memory_bytes: 640
def main():
    n = int(input())
    t,a = map(int, input().split())
    H = list(map(int, input().split()))

    array = [abs(a-(t-x*0.006)) for x in H]
    minimum = min(array)
    ans = 0
    for i in range(n):
        if array[i] == minimum:
            ans = i + 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38512
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			double[] x = new double[4];
			double[] y = new double[4];
			for(int i = 0; i < 4; i++) {
				x[i] = sc.nextDouble();
				y[i] = sc.nextDouble();
			}
			Vec AB = new Vec(x[1] - x[0], y[1] - y[0]);
			Vec BC = new Vec(x[2] - x[1], y[2] - y[1]);
			Vec CA = new Vec(x[0] - x[2], y[0] - y[2]);

			Vec AP = new Vec(x[3] - x[0], y[3] - y[0]);
			Vec BP = new Vec(x[3] - x[1], y[3] - y[1]);
			Vec CP = new Vec(x[3] - x[2], y[3] - y[2]);
			// 外積
			double d1 = AB.x * BP.y - AB.y * BP.x;
			double d2 = BC.x * CP.y - BC.y * CP.x;
			double d3 = CA.x * AP.y - CA.y * AP.x;
			if((d1 > 0.0 && d2 > 0.0 && d3 > 0.0) || (d1 < 0.0 && d2 < 0.0 && d3 < 0.0)) {
				System.out.println("YES");
			}else {
				System.out.println("NO");
			}
		}
		sc.close();
	}
	static class Vec{
		double x, y;
		public Vec(double x, double y) {
			this.x = x;
			this.y = y;
		}
	}
}


Measured memory_bytes: 32220
n = gets.chomp.to_i
aa = gets.chomp.split.map(&:to_i)
a = []
n.times do |i|
  a[i+1] = aa[i]
end
(n/2).downto(1) do |i|
  k = 2 * i
  while k <= n
    a[i] += a[k]
    k += i
  end
  a[i] %= 2
end
puts a.count(1)
b = []
1.upto(n) do |i|
  if a[i] == 1
    b << i
  end
end
if a.count != 0
  b.length.times do |i|
    if i == 0
      print b[i]
    else
      print " #{b[i]}"
    end
  end
end


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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


int main() {
  //入力
  int K, N;
  cin >> K >> N;
  vector<int> A(N);
  REP(i, N) cin >> A.at(i);

  //一個目のやつを最後にもう一個くっつけます
  A.push_back(A.at(0)+K);

  int ans = 1000000000;

  REP(i, N){
    //こうすると、間だけを考えればいいことになります
    int d = A.at(i+1) - A.at(i);
    chmin(ans, K - d);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4812
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
//  cout<<s.length();
  if(s.length()<=n)
    cout<<s;
  else
  {
    for(int i=0;i<n;i++)
      cout<<s[i];
    cout<<"...";
  }
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <functional>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int n, W;
	scanf("%d%d", &n, &W);
	vector<int> w(n), v(n);
	for (int i = 0; i < n; ++i)
		scanf("%d%d", &w[i], &v[i]);
	vector<vector<ll> > dp(n + 1, vector<ll>(W + 1));
	for (int i = n - 1; i >= 0; --i)
		for (int j = 0; j <= W; ++j) {
			dp[i][j] = dp[i + 1][j];
			if (j >= w[i])
				dp[i][j] = max(dp[i][j], dp[i + 1][j - w[i]] + v[i]);
		}
	printf("%lld\n", dp[0][W]);
	return 0;
}

Measured memory_bytes: 80256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp33 {
    class Program {
        static void Main(string[] args) {
            var s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int H = s[0];
            int W = s[1];
            var t = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int h = t[0];
            int w = t[1];

            int all = H * W;

            int gyou = h * W;
            int retsu = w * H;
            int chohuku = h * w;

            int black = gyou + retsu - chohuku;

            Console.WriteLine(all - black);


        }
    }
}


Measured memory_bytes: 13396
n = int(raw_input())
ss = raw_input()

abc = [x for x in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ']

strs = []
for s in ss:
    idx = (abc.index(s) + n) % len(abc)
    x = abc[idx]
    strs.append(x)
print ''.join(strs)


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

// GCD, LCM
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;}

int main()
{
    int X,Y;
    cin>>X>>Y;

    for(int i=0;i<=X;i++){
        int r = Y-i*2;
        int j = X-i;

        if(r%4==0 && r/4==j){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    
    cout<<"No"<<endl;

    return 0;
}

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


int main(void) {
	long long S, C;
	cin >> S >> C;

	long long ans = 0;
	if (S >= C/2) {
		ans = C/2;
	} else if (S <= C/2) {
		ans = S;
		C -= S*2;
		ans += C/4;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    
    atC();
});

function readline() {
    return inputString[currentLine++];
}

function pi(a) {
    return parseInt(a);
}

function probA(){
    let t = parseInt(readline());
    while(t > 0){
        t--;
        let [n,k] = readline().split(' ');
        n = pi(n);
        k = pi(k);

        if(n < k)
            console.log(k-n);
        else{
            if((n+k) % 2 === 0){
                console.log(0);
            }else{
                console.log(1);
            }
        }
    }
}

function probB(){
    let t = pi(readline());

    while(t > 0){
        t--;
        let a = readline().split(' ');
        let b = readline().split(' ');

        a[0] = pi(a[0]);
        a[1] = pi(a[1]);
        a[2] = pi(a[2]);

        b[0] = pi(b[0]);
        b[1] = pi(b[1]);
        b[2] = pi(b[2]);

        let maxSum = 0;
        if(b[2] - (a[0] + a[2]) > 0){
            b[2] = b[2] - (a[0]+a[2]);
            a[0] = 0;
            a[2] = 0;
        }else if(b[2] - a[0] > 0){
            a[2] = a[2] - (b[2] - a[0]);
            b[2] = 0;
            a[0] = 0;
        }else{
            a[0] -= b[2];
            b[2] = 0;
        }

        if(a[2] > b[1])
            console.log((b[1] - b[2]) * 2)
        else
            console.log((a[2]-b[2]) * 2);

    }
}

function probC(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let n = pi(readline());
        let a = readline().split(' ');
        let x = JSON.parse(JSON.stringify(a));

        x.sort((a,b) => pi(a) - pi(b));
        let res = true;
        for(let i = 0; i < n; i++){
            if(x[i] !== a[i]){
                if(pi(a[i]) % pi(x[0]) !== 0){
                    res = false;
                    break;
                }
            }
        }

        if(res)
            console.log('yes');
        else
            console.log('no');
    }
}

function atA(){
    let [n,x,t] = readline().split(' ');
    n = pi(n);
    x = pi(x);
    t = pi(t);

    if(n < x)
        console.log(t);
    else{
        if(n % x === 0){
            console.log((n/x) * t);
        }else{
            console.log(Math.ceil(n/x) * t);
        }
    }
}

function atB(){
    let n = readline().split('');

    let sum = 0;
    for(let i of n){
        sum += pi(i);
    }

    console.log(sum % 9 === 0 ? 'yes' : 'no');
}

function atC(){
    readline();
    let a = readline().split(' ');
    let max = pi(a[0]);
    let res = 0;
    for(let i = 1; i < a.length; i++){
        let x = pi(a[i]);
        if(x < max){
            res += (max-x);
        }

        max = Math.max(max, x);
    }

    console.log(res);
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define maxs(a,b) a=max(a,b);
#define mins(a,b) a=min(a,b);

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

ll modpow(ll a, ll b){
    ll ans=1;
        while(b>0){
        if(b%2==1)ans=ans*a%MOD;
        a=(a*a)%MOD;
        b/=2;
    }
    return ans;
}
ll combination(int n,int r){
    vl factorial(n+1),inverse(n+1);
    factorial[0]=1;
    inverse[0]=1;
    repa(i,1,n+1){
        factorial[i]=(factorial[i-1]*i)%MOD;
        inverse[i]=modpow(factorial[i],MOD-2)%MOD;
    }
    return (((factorial[n]*inverse[r])%MOD)*inverse[n-r])%MOD;
}

int main(){
   
    int x,y;cin>>x>>y;

    if((x+y)%3!=0 || (x+y)/3 > min(x,y)){
        cout<<0<<endl;
        return 0;
    }

    int n=(x+y)/3,r=min(x,y)-n;

    cout<<combination(n,r)<<endl;
    
    return 0;
}

Measured memory_bytes: 10624
/*
AtCoder Submission
*/

#include<bits/stdc++.h>

using namespace std;

/* Typedefs */
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <string,string> mss;

int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);


    int a, b, c;
    cin >> a >> b >> c;

    int ops = 0;
    if(a % 2 == b % 2 && b % 2 == c % 2){
        // same parity
    } else {
        // two have same parity
        if(a % 2 == b % 2){
            // a and b are same
            ops++;
            a += 1;
            b += 1;
        } else if(b % 2 == c % 2){
            // b and c are asme
            ops++;
            b += 1;
            c += 1;
        } else if(a % 2 == c % 2){
            // a and c are asme
            ops++;
            a += 1;
            c += 1;
        } else cout << "ERROR" << endl;
    }

    // now we can confirm that they have same parity
    // update lowest two unless they equal max
    
    int top = max(a, max(b, c));
    while(a != top){
        a += 2;
        ops++;
    }
    while(b != top){
        b += 2;
        ops++;
    }
    while(c != top){
        c += 2;
        ops++;
    }

    cout << ops << endl;


    return 0;
}


Measured memory_bytes: 256
import sys
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]

N = ri()
a = ri_()
ans = 0
cnt = 0
now = 10000
for i in range(N):
    if a[i] == now:
        cnt += 1
    else:
        ans += -(-cnt//2)
        cnt = 0
        now = a[i]  
ans += -(-cnt//2)
print(ans)

Measured memory_bytes: 38384
#include <iostream>
 
using namespace std;
 
int main(void) {
  int n, a, b;
  int scoreA, scoreB;
 
 
  while(1) {
    scoreA = 0; scoreB = 0;
    cin >> n;
     
    if(n == 0) break;
     
    for(int i = 0; i < n; i++) {
      cin >> a >> b;
      if (a > b) {
    scoreA += a + b;
      } else if (a == b) {
    scoreA += a; scoreB += b;
      } else {
    scoreB += a + b;
      }
    }
 
    cout << scoreA << " " << scoreB << endl;
  }
 
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n;
map<int, int> mp;

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		int j;
		cin >> j;
		mp.insert(make_pair(j, i));
	}

	ll ans = 0;
	int count = 0;
	for (map<int, int>::iterator itr = mp.begin(); itr != mp.end(); itr++) {
		int i = count;
		int j = itr->second;

		count++;

		//cout << i << " " << j << endl;

		if (i == j) continue;
		int k = abs(j - i) + 1;
		if (k == 3) continue;
		if( (k - 3) % 2 == 0) continue;
		
		ans++;
	}

	cout << ans / 2 << endl;

	return 0;
}


Measured memory_bytes: 4992
#include <iostream>

int main() {
    int n, x, t;
    std::cin >> n >> x >> t;

    int res = 0;
    while(n >= x) {
        res += t;
        n -= x;
    }
    if(n != 0)
        res += t;

    std::cout << res;
    return 0;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n, m; read(n, m);
	vector<vi> v(n + 1);
	vi dist(n + 1, 0x3f3f3f3f), vis(n + 1), prev(n + 1);
	rep(i, 0, m) {
		int a, b; read(a, b);
		v[a].push_back(b), v[b].push_back(a);
	}

	queue<int> q;
	q.push(1);
	dist[1] = 0;

	while (!q.empty()) {
		int n = q.front(); q.pop();
		for (int h : v[n]) if (dist[n] + 1 < dist[h]) {
			dist[h] = dist[n] + 1;
			prev[h] = n;
			q.push(h);
		}
	}

	write("Yes");
	rep(i, 2, n + 1) write(prev[i]);
}


Measured memory_bytes: 11052
no = gets.to_i

a = gets.split(' ').map(&:to_i)

puts a.join(' ')
(1..no-1).each do |i|
    key = a[i]
    j = i - 1
    while j >= 0 and a[j] > key
        a[j+1] = a[j]
        j -= 1
    end
    a[j+1] = key
    puts a.join(' ')
end

Measured memory_bytes: 6108
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long int
#define pb push_back
#define mk make_pair
#define flp(i, k, n) for(int i=k; i<n; i++)
#define rev(i, k) for(int i=k; i>=0; i--)
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int dx[4] = {-1,1,0,0};
int dy[4] = {0,0,-1,1};

int32_t main(void)
{
    int n, m;
    cin>>n>>m;
    int a[m];
    int res=0;
    flp(i, 0, m){ 
        cin>>a[i];
        res+=a[i];
        }
    
    if(res>n) cout<<-1<<"\n";
    else cout<<n-res<<"\n";
    return 0;

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+5;
int n;
int a[maxn];

int main()
{
    scanf("%d",&n);
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        ans+=a[i];
    }
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        if(i%2)
        {
            sum+=a[i]*2;
        }
    }
    int t=sum-ans;
    printf("%d",t);
    for(int i=2;i<=n;i++)
    {
        t=2*a[i-1]-t;
        printf(" %d",t);
    }
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
 
int main() {
  ll n;
  cin >> n;
  vl v;
  inputv(v,n);
  ll mx=0,sec=0;
  rep(i,n){
    mx = max(mx,v[i]);
  }
  rep(i,n){
      if(v[i] < mx){
      sec = max(sec, v[i]);
    }
  }
  ll count=0;
  rep(i,n){
    if(v[i] == mx){
      count++;
    }
  }
  vl ans(n);
  if(count == 1){
  rep(i,n){
      if(v[i] == mx){
        ans[i] = sec;
      } else {
        ans[i] = mx;
      }
  }
  }
  if(count > 1){
    rep(i,n){
    ans[i] = mx;
  }
  }
  rep(i,n){
    cout << ans[i] << endl;
  }
 return 0;
}


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

void chmin(int64_t& a, int64_t b){
    a = min(a, b);
}

int main(){
    int N;
    int64_t A, B;
    cin >> N >> A >> B;
    int pos[5001];
    for(int i=0; i<N; i++){
        int p;
        cin >> p;
        pos[p-1] = 2*i+1;
    }

    const int64_t INF = 1e18;
    static int64_t dp[5001][10001];
    for(int i=1; i<=N; i++) for(int j=0; j<=2*N; j++) dp[i][j] = INF;

    for(int i=0; i<N; i++){
        int64_t mn = INF;
        for(int j=0; j<=2*N; j++){
            chmin(mn, dp[i][j]);
            if(pos[i] == j){
                chmin(dp[i+1][j], mn);
            }else if(j%2 == 0){
                int64_t cost = (pos[i] < j ? A : B);
                chmin(dp[i+1][j], mn + cost);
            }
        }
    }

    int64_t ans = INF;
    for(int j=0; j<=2*N; j++) chmin(ans, dp[N][j]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 390912
#include <bits/stdc++.h>
using namespace std;
constexpr auto MOD = 1000000007;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VLL;

string s;
long long n, m;

int main()
{
  cin >> n;
  for (int i = n; i < 9999999; i++)
  {
    int flg = 1;
    for (int j = 2; j < 99999999; j++)
    {
      if(j*j>i){
        break;
      }
      if(i%j==0){
        flg = 0;
        break;
      }
    }
    if(flg){
      cout << i << endl;
      return 0;
    }
  }

}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,M;cin>>N>>M;
  vll a(N),b(N);
  repeat(i,N)cin>>a[i]>>b[i];
  vll c(M),d(M);
  repeat(j,M)cin>>c[j]>>d[j];
  repeat(i,N){
    ll mind=INF;
    ll ans = 0;
    repeat(j,M){
      ll dist = abs(a[i]-c[j])+abs(b[i]-d[j]);
      if(mind>dist){
        mind=dist;
        ans = j+1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

double dot(P a,P b){return real(conj(a)*b);};
double cross(P a,P b){return imag(conj(a)*b);};

int main(){
  double x1,y1,x2,y2,x3,y3,xp,yp;
  while(~scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)){
    P a(x1,y1), b(x2,y2), c(x3,y3), p(xp,yp);
    double cra = cross(b-a,p-a);
    double crb = cross(c-b,p-b);
    double crc = cross(a-c,p-c);
    if(cra<0){
      cra*=-1;
      crb*=-1;
      crc*=-1;
    }
    if(cra>0 && crb>0 && crc>0){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
  }
  return 0;
}

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

int main()
{
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans = 0;
  for (int i = 0; i < 1000; i++)
  {
    string now = to_string(i);
    int digit1 = 0, digit2 = 0;
    if (i < 10)
    {
      for (int j = 0; j < S.size(); j++)
      {
        if (digit1 == 0 && S[j] == '0')
        {
          digit1++;
          continue;
        }
        if (digit2 == 0 && digit1 > 0 && S[j] == '0')
        {
          digit2++;
          continue;
        }
        if (digit2 > 0 && S[j] == now[0])
        {
          ans++;
          break;
        }
      }
    }
    if (i >= 10 && i < 100)
    {
      for (int j = 0; j < S.size(); j++)
      {
        if (digit1 == 0 && S[j] == '0')
        {
          digit1++;
          continue;
        }
        if (digit2 == 0 && digit1 > 0 && S[j] == now[0])
        {
          digit2++;
          continue;
        }
        if (digit2 > 0 && S[j] == now[1])
        {
          ans++;
          break;
        }
      }
    }
    if (i >= 100)
    {
      for (int j = 0; j < S.size(); j++)
      {
        if (digit1 == 0 && S[j] == now[0])
        {
          digit1++;
          continue;
        }
        if (digit2 == 0 && digit1 > 0 && S[j] == now[1])
        {
          digit2++;
          continue;
        }
        if (digit2 > 0 && S[j] == now[2])
        {
          ans++;
          break;
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
# ABC054C - One-stroke Path
# an undirected unweighted graph is given
# -> count up paths which visit all the vertices exactly once
# exhaustive search
from itertools import permutations as perm


def main():
    N, M = tuple(map(int, input().split()))
    E = set(tuple(map(int, input().split())) for _ in range(M))  # edges
    E |= {(j, i) for i, j in E}  # undirected graph -> add reversed paths
    ans = 0
    for path in perm(range(2, N + 1), N - 1):  # check all possible paths (O(N!))
        path = (1,) + path
        if all((i, j) in E for i, j in zip(path, path[1:])):
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<stdio.h>
int main(void) {
	int a[3],max=0,sum=0;
	scanf("%d %d %d", &a[0], &a[1], &a[2]);
	for (size_t i = 0; i < 3; i++)
	{
		if (max<a[i])
		{
			max = a[i];
		}
		sum += a[i];
	}
	if ((sum-max)==max)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>

using namespace std;

struct Info{
	double calorie;
};

int main(){

	int n,a,b,c;
	scanf("%d",&n);

	if(n == 2){
		scanf("%d %d",&a,&b);

		for(int i = 1; i <= max(10000,max(a,b));i++){
			if(a%i == 0 && b % i == 0)printf("%d\n",i);
		}
	}else{
		scanf("%d %d %d",&a,&b,&c);

		for(int i = 1; i <= max(10000,max(a,max(b,c)));i++){
			if(a%i == 0 && b % i == 0 && c % i == 0)printf("%d\n",i);
		}
	}

	return 0;
}

Measured memory_bytes: 2672
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

def main():
    n, k = map(int, input().split())
    count = [0]*(k+1)
    inf = pow(10, 9)+7
    for i in range(k, 0, -1):
        key = make_divisors(i)
        t = pow(k//i, n, inf)
        count[i] += t
        for value in key:
            if value == i:
                continue
            count[value] -= count[i]
    ans = 0
    for i in range(1, k+1):
        ans += ((count[i]%inf)*i)%inf
        ans %= inf
    print(ans)

if __name__ == "__main__":
    main()

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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int k;
  string s;
  cin >> s;
  cin >> k;
  int slen = s.length();
  REP(i,slen-1) {
    if(s[i]=='a') continue;
    int disToA = 'z' + 1 - s[i];
    if(disToA <= k) {
      k -= disToA;
      s[i] = 'a';
    }
    if(k == 0) break;
  }
  
  k %= 26;
  int disToA = 'z' + 1 - s[slen-1];
  if(k < disToA) {
    s[slen-1] = s[slen-1] + k;
  } else {
    s[slen-1] = 'a' + (k - disToA);
  }
  cout << s;
  
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>

using namespace std;

int main()
{
    int b;
    long int ans = 0;

    int N;
    cin >> N;

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

    sort(A.begin(), A.end());

    b = A[N/2];

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

    return 0;
}


Measured memory_bytes: 1024
import Control.Applicative
import Data.Maybe
import qualified Data.Sequence as S
import Data.Sequence (Seq, fromList, (<|), (|>), viewl, viewr, ViewL(..), ViewR(..))

main = getLine >>= print . fromMaybe (-1) . solve . fromList

solve :: Seq Char -> Maybe Int
solve q | S.length q <= 1 = Just 0
solve q
  | l == r    = solve ms
  | l == 'x'  = succ <$> solve (q |> 'x')
  | r == 'x'  = succ <$> solve ('x' <| q)
  | otherwise = Nothing
  where
    (l :< rs) = viewl q
    (ms :> r) = viewr rs


Measured memory_bytes: 7548
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;

void solve()
{
	int n, d, cnt = 0;
	cin>>n>>d;
	vector<vector<int>> vect(n, vector<int>(d));
	REP(i, n)
	{
		REP(j, d)
			cin>>vect[i][j];
	}
	for(int i=0; i<n; i++)
	{
		for(int j = i+1; j<n; j++)
		{
			int sq = 0;
			for(int k = 0; k<d; k++)
			{
				sq += (vect[i][k]-vect[j][k])*(vect[i][k]-vect[j][k]);
			}
			float squareR = sqrt(sq*1.0);
			if(abs(squareR-int(squareR))==0)
				cnt++;
		}
	}
	cout<<cnt<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3668
fun main(args: Array<String>) {
    val (h, n) = readLine()?.split(" ")?.map(String::toInt) ?: return
    val a = readLine()?.split(" ")?.map(String::toInt) ?: return

    val total = a.sum()
    if (total >= h) {
        println("Yes")
    } else {
        println("No")
    }
}


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

const int MOD = 1000000007;
int dp[1005][1005];
int main()
{
  int h,w;
  char a[1005][1005];

  cin>>h>>w;

  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin>>a[i][j];
    }
  }

  dp[0][1]=1;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(a[i][j]!='#'){
	dp[i][j]=dp[i-1][j]%MOD+dp[i][j-1]%MOD;
      }
    }
  }
			
  cout<<dp[h][w]%MOD<<endl;
  return 0;
}


Measured memory_bytes: 5120
#include <stdio.h>
#include<math.h>

int main(){
	int a;
	scanf("%d", &a);
	
	for(int i = 1;i <= 9; i++){
		for(int j = 1; j <= 9; j++){
			if(i * j == a){
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 1644
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<map>
#include<cmath>
#include<queue>
#include<string>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const int N=100010;

int main()
{
    IO;
    int T=1;
    //cin>>T;
    while(T--)
    {
        int x;
        cin>>x;
        cout<<1-x<<endl;
    }
    return 0;
}

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

int main() {
    int N, M;
    int A[10000];

    cin >> N >> M;
    int sum = N;

    for (int i = 0; i < M; i++) {
        cin >> A[i];
        sum -= A[i];
    }

    if (sum >= 0) {
        cout << sum << endl;
    } else {
        cout << "-1" << endl;    
    }

}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
long inf =1000000000;


int main(){
  long A,B,M; cin >> A >> B >> M;
  vector<long> a(A); 
  for(long i=0;i<A;i++){
    cin >> a.at(i);
  }
  vector<long> b(B);
  for(long i=0;i<B;i++){
    cin >> b.at(i);
  }
  vector<long> m(3*M);
  for(long i=0;i<3*M;i++){
    cin >> m.at(i);
  }
  
  long sa = inf;
  for(long i=0;i<A;i++){
    sa = min(a.at(i),sa);
  }
  long sb = inf;
  for(long i=0;i<B;i++){
    sb = min(b.at(i),sb);
  }
  
  
  
  long cost1 = sa + sb;
  
  for(int i = 0;i<M;i++){
     cost1 = min((a.at(m.at(3*i)-1)+b.at(m.at(3*i+1)-1)-m.at(3*i+2)),cost1);
  }
  cout << cost1 << endl;
}
      
  

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+5;
ll sum,ans;
ll a[maxn],b[maxn],n;
int main()
{
    ll min1=1e9+5;
    scanf("%lld",&n);
    for(int i=0;i<n;i++)
        scanf("%lld%lld",&a[i],&b[i]);
    bool flag=true;
    for(int i=0;i<n;i++)
        if(a[i]!=b[i])
        {
            flag=false;
            break;
        }
    if(flag)
        printf("0\n");
    else
    {
        for(int i=0;i<n;i++)
        {
            if(a[i]>b[i])
                min1=min(b[i],min1);
            sum+=b[i];
        }
        printf("%lld\n",sum-min1);
    }
}

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

using namespace std;

int main(int argc, char const *argv[]) {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int dp1[n + 1][k], dp2[n + 1][k];
  for(int j = 0; j < k; j++) {
    dp1[0][j] = 0;
  }
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < k; j++) {
      if (j < a[i]) {
        dp1[i + 1][j] = dp1[i][j];
      } else {
        dp1[i + 1][j] = max(dp1[i][j], dp1[i][j - a[i]] + a[i]);
      }
    }
  }
  for(int j = 0; j < k; j++) {
    dp2[n][j] = 0;
  }
  for(int i = n - 1; i >= 0; i--) {
    for(int j = 0; j < k; j++) {
      if (j < a[i]) {
        dp2[i][j] = dp2[i + 1][j];
      } else {
        dp2[i][j] = max(dp2[i + 1][j], dp2[i + 1][j - a[i]] + a[i]);
      }
    }
  }
  int ans = n;
  for (int i = 0; i < n; i++) {
    for(int j = 0; j < k; j++) {
      int t = dp1[i][j];
      if (t + dp2[i + 1][k - 1 - t] + a[i] >= k) {
        ans--;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int>>
#define MX              200005
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // int t;
    // cin>>t;
    // while(t--){
        
    // }
    int n;cin>>n;
    string s;cin>>s;
    vector<int> r(n,0);
    vector<int> g(n,0);
    vector<int> b(n,0);
    
    if(s[n-1]=='R')r[n-1]=1;
    else if(s[n-1]=='G')g[n-1]=1;
    else if(s[n-1]=='B')b[n-1]=1;
    
    for(int i=n-2;i>=0;i--){
        r[i]=r[i+1];g[i]=g[i+1];b[i]=b[i+1];
        if(s[i]=='R')r[i]+=1;
        else if(s[i]=='G')g[i]+=1;
        else if(s[i]=='B')b[i]+=1;
    }
    int ans=0;
    for(int i=0;i<=n-3;i++){
        for(int j=i+1;j<=n-2;j++){

            char ch1=s[i],ch2=s[j];
            if(ch1!=ch2){
                //cout<<"hey"<<endl;
                int c[3]={0};
                if(ch1=='R'||ch2=='R'){c[0]=1;}
                if(ch1=='G'||ch2=='G'){c[1]=1;}
                if(ch1=='B'||ch2=='B'){c[2]=1;}
                char ch='A';
                //for(int k=0;k<3;k++)cout<<c[k]<<" ";
                if(c[0]==0)ch='R';
                else if(c[1]==0)ch='G';
                else if(c[2]==0)ch='B';
                if(ch=='B'){
                    int ind=(2*(j+1)) - (i+1);
                    if(ind-1<n&&s[ind-1]=='B'){
                        ans+=b[j+1]-1;
                    }else ans+=b[j+1];
                }else if(ch=='G'){
                    int ind=(2*(j+1)) - (i+1);
                    if(ind-1<n&&s[ind-1]=='G'){
                        ans+=g[j+1]-1;
                    }else ans+=g[j+1];
                }else if(ch=='R'){
                    int ind=(2*(j+1)) - (i+1);
                    if(ind-1<n&&s[ind-1]=='R'){
                        ans+=r[j+1]-1;
                    }else ans+=r[j+1];
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3672
import Control.Monad
dist a b c d = abs(a-c)+abs(b-d)

main = do
  [n,m] <- map read.words <$> getLine 
  ab <- replicateM n $ map read . words <$> getLine :: IO [[Int]]
  cd <- replicateM m $ map read . words <$> getLine :: IO [[Int]]
  sequence $  do 
    [a,b] <- ab
    return . print . snd. minimum $  do 
      ([c,d],i) <- zip cd [1..]
      return (dist a b c d,i)
    


Measured memory_bytes: 1020
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include<cstdio>
// #define MOD 1000000007
// #define MOD2 1000000014000000049LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef long long ll;

template<int N, int M>
struct ModFact {
    int inv[N+1];
    int fact[N+1];
    int ifact[N+1];
    constexpr ModFact() : fact(), ifact() {
        ll f = 1;
        fact[0] = f;
        for (int i = 0; i < N; i++) {
            f = f*(i+1)%M;
            fact[i+1] = f;
        }
        f = power(f, M-2);
        ifact[N] = f;
        for (int i = N-1; i >= 0; i--) {
            f = f*(i+1)%M;
            ifact[i] = f;
        }
        for (int i = 0; i < N; i++) {
            f = ll(fact[i])*ll(ifact[i+1])%M;
            inv[i] = f;
        }
    }
    constexpr ll power(ll a, ll b) {
        ll r = 1;
        while (b>0) {
            if((b&1)!=0) r = (r*a)%M;
            a = (a*a)%M;
            b >>= 1;
        }
        return r;
    }
	int operator[](int n) {
		return inv[n];
	}
};

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}

inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int MOD = 1000000007;
const ll MOD2 = 1000000014000000049LL;

ModFact<100000, MOD> fact;

int main() {
    ll ans = 0, d;
    int a, N, prev, now;
    N = getint();
    prev = getint();
    REP(i, N-1) {
        now = getint();
        d = now - prev;
        prev = now;
        a = (a + fact[i]) % MOD;
        // ans += a * d % MOD;
        ans += a * d;
        if(ans > MOD2) ans -= MOD2;
    }
    printf("%lld\n", ((ans%MOD)*fact.fact[N-1])%MOD);
	return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
main()
{
    int n,a[2][110]={0};
    int i,j,k,p,sum=0,max=0;
    scanf("%d",&n);
    for(i=0;i<2;i++)
    {
        for(j=0;j<n;j++)
        {
            scanf("%d",&a[i][j]);
        }
    }
    for(k=0,p=0;k<n;k++,p++)
    {
        p=k;
        sum=0;
        for(i=0,j=0;i<2,j<n; )
        {
            if(i==0 && j==0)
            {
                sum=sum+a[i][j];
            }
            if(j!=n-p-1)
            {
                j++;
                sum=sum+a[i][j];
            }
            else if(j==n-p-1)
            {
                i++;
                p=p+5;
                sum=sum+a[i][j];
            }
        }
        if(sum>max)
        {
            max=sum;
        }
    }
    printf("%d",max);
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#define ll long long int
#define mp(a, b) make_pair(a, b)
using namespace std;
typedef pair<ll, ll> pairs;
typedef pair<ll, pairs> tpl;
string a, b, ans;
ll dp[3001][3001];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	cin >> a >> b;
	for (ll i = 0; i <= a.length(); i++)
	{
		for (ll j = 0; j <= b.length(); j++)
		{
			if (i == 0 || j == 0)
				dp[i][j] = 0;
			else if (a[i - 1] == b[j - 1])
				dp[i][j] = 1 + dp[i - 1][j - 1];
			else
			{
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}

	ans = "";
	ll i = a.length(), j = b.length();
	while (i >= 1 && j >= 1)
	{
		if (a[i - 1] == b[j - 1] && dp[i][j] == dp[i - 1][j - 1] + 1)
		{
			ans += a[i - 1];
			i--;
			j--;
		}
		else if (dp[i][j] == dp[i - 1][j])
			i--;
		else

			j--;
	}
	reverse(ans.begin(), ans.end());
	cout << ans;
}

Measured memory_bytes: 73992
#pragma GCC optimize("Ofast")
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy 2333333
#define bql 2147483647
using namespace std;
int main()
{
	fast;
	int a,b;
	cin>>a>>b;
	cout<<(a*3+b)/2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>



int main(){
	int n, m, cont=0;
	double soma=0, eq2=0, eq=0;
	scanf("%d %d", &n, &m);
	int coisa[n];
	for(int i=0; i < n; ++i){
		scanf("%d", &coisa[i]);
		soma+=coisa[i];
	}
	eq= 4*m;
	eq2= soma/eq;
	for(int i =0; i< n; ++i){
		if(coisa[i]>=eq2)
			++cont;
	} 
	if(cont<m)
		printf("No");
	else
		printf("Yes");
	printf("\n");

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define ui unsigned int
#define ull unsigned long long
using namespace std;
const int N = 1e6+7;
int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    if(a+b==15)
    {
        puts("+");
    }
    if(a*b==15)
    {
        puts("*");
    }
    if(a+b!=15&&a*b!=15)
    {
        puts("x");
    }
	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++)
int main(){
    // Your code here!
    // int n;
    // cin >> n;
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(1){
        c -= b;
        if(c <= 0){
               cout << "Yes" << endl;
               break; 
        } 
        a -= d;
        if(a <= 0) {
            cout << "No" << endl;
            break;
        }
    }
    
}


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

int main(){
int a[5][51];
int b;
int c;
int d;
b=1;
while(b<5){
c=0;
while(c<51){
a[b][c]=0;
c=c+1;}
b=b+1;}

b=0;
while(b<10){
a[1][b]=1;
b=b+1;}

b=2;
while(b<5){
c=0;
while(c<51){
d=0;
while(d<10){
if(c>=d){a[b][c]=a[b][c]+a[b-1][c-d];}
d=d+1;}
c=c+1;}
b=b+1;}
int n;
while(cin >> n){
cout << a[4][n] << endl;}


}

Measured memory_bytes: 1160