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

#define PI 3.141592653589793238462643383279
typedef long long ll;
const long double EPS = 1e-9;
const ll MOD = 1e9+7;
#define N 100100
ll a[N], dp[50][N], any_sum[50];

int get_bits(ll n) {
    int res = 0;
    while(n > 0){
        res ++;
        n >>= 1;
    }
    return res;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << setprecision(20);
    #ifdef LOCAL_TEST
    freopen("input.txt","r",stdin);
    #endif
    ll n, k; cin >> n >> k;
    for(int i=0;i<n;i++) cin >> a[i];
    const int MX = 45;
    for(int p=0;p<MX;p++) {
        ll one = 0;
        for(int i=0;i<n;i++) if(a[i] & (1LL << p)) one++;
        dp[p][0] = one * (1LL << p);
        dp[p][1] = (n - one) * (1LL << p);
    }

    ll prev = 0;
    for(int i=0;i<MX;i++) {
        prev += max(dp[i][0], dp[i][1]);
        any_sum[i] = prev;
    }

    int bits = get_bits(k);

    prev = 0;
    ll ans = 0;
    for(int i=MX-1;i>=bits;i--) prev += dp[i][0];
    for(int i=bits-1;i>=0;i--) {
        if(k & (1LL << i)){
            ans = max(ans, prev + dp[i][0] + (i == 0 ? 0 : any_sum[i-1]));
            prev += dp[i][1];
        }else prev += dp[i][0];
    }
    ans = max(ans, prev);
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 33792
#include <iostream>
using namespace std;
int main(void){
    int n,x,i,j,cards[4][13] = {{0}};
    char ch;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> ch >> x;
        if(ch=='S'){
            cards[0][x-1]=1;
        }else if(ch=='H'){
            cards[1][x-1]=1;
        }else if(ch=='C'){
            cards[2][x-1]=1;
        }else if(ch=='D'){
            cards[3][x-1]=1; 
        }
    }
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            if(cards[i][j]==0){
                if(i==0){
                    cout << "S"<< " " <<j+1;
                    cout << endl;
                }else if(i==1){
                    cout << "H" << " " << j+1;
                    cout << endl;
                }else if(i==2){
                    cout << "C" << " " << j+1;
                    cout << endl;
                }else if(i==3){
                    cout << "D" << " " << j+1;
                    cout << endl;
                }
            }
        }
    }
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n,k;
  cin>>n>>k;
  vector<int> h(n);
  rep(i,n)cin>>h[i];
  sort(h.begin(),h.end());
  int ans=h[k-1]-h[0];
  rep(i,n-k+1) {
    ans=min(ans,h[i+k-1]-h[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

signed main() {
	int N;
	cin >> N;
	int num = 1;
	int sum = 0;
	while (1) {
		sum += num;
		if(sum==N){
			for (int i = 1; i <= num; i++)cout << i << endl;
			return 0;
		}
		else if (sum > N) {
			for (int i = 1; i <= num; i++) {
				if (i == sum - N)continue;
				else cout << i << endl;
			}
			return 0;
		}
		num++;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
typedef int64_t ll;

int main() {
    int64_t N, K;
    cin >> N >> K;
    N %= K;
    cout << min(N, K - N) << endl;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	string s;
	cin >> s;
	int N = s.size();

	bool AC = true;
	if(s[0] != 'A') AC = false;

	int cnt = 0;
	for(int i = 2; i < N - 1; i++){
		if(s[i] == 'C') cnt++;
	}
	if(cnt != 1) AC = false;

	cnt = 0;
	for(int i = 0; i < N; i++){
		if(islower(s[i])) cnt++;
	}
	if(cnt != N - 2) AC = false;

	if(AC) cout << "AC" << endl;
	else cout << "WA" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back
#define N 998244353
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;


signed main()
{ 
    speed
    int n;cin>>n;
    std::vector<int> d(n);
    map<int,int>freq;
    for (int i = 0; i < n; ++i)
    {
        cin>>d[i];
        ++freq[d[i]];
    }
    if(d[0]!=0){cout<<0;return 0;}
    int ans=1;
    for(int i=1;i<n;++i){
        ans*=freq[d[i]-1];
        ans%=N;
    }
    cout<<ans;
}

Measured memory_bytes: 7296
def main():

    A, B, C, D = map(int, input().split())
    while A >0 and B >0:
        C -= B
        if C <=0:
            return "Yes"
        A -= D
        if A <= 0:
            return "No"
    return ""

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 9172
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char
import qualified Data.ByteString.Char8 as BS

readIntPair :: BS.ByteString -> (Int, Int)
readIntPair s = let Just (a, s') = BS.readInt s
                    Just (b, _) = BS.readInt $ BS.dropWhile isSpace s'
                in (a, b)

main = do
  (n,m) <- readIntPair <$> BS.getLine
  let loop !maxL !minR 0 = print $ max 0 (minR - maxL + 1)
      loop !maxL !minR i = do
        (l,r) <- readIntPair <$> BS.getLine
        loop (max l maxL) (min r minR) (i - 1)
  loop minBound maxBound m


Measured memory_bytes: 1020
process.stdin.resume();
process.stdin.setEncoding('utf8');
var input_string = '';

process.stdin.on('data', function (chunk) {
    input_string += chunk;
});
const space_input = function (line) {
    var arr = line.replace(/(^\s+)|(\s+$)/g, "").split(" ");
    for (var i = 0; i < arr.length; ++i) {
        arr[i] = +arr[i];
    }
    return arr;
};
const space_input_char = function (line) {
    var arr = line.replace(/(^\s+)|(\s+$)/g, "").split(" ");
    for (var i = 0; i < arr.length; ++i) {
        arr[i] = arr[i];
    }
    return arr;
};

process.stdin.on('end', function () {
    const lines = input_string.split('\n');
    const abc = space_input(lines[0]);
    if(abc[0]==abc[2]){
        console.log(abc[1])
    }
    if(abc[0]==abc[1]){
        console.log(abc[2])
    }
    if(abc[1]==abc[2]){
        console.log(abc[0])
    }
    
});

Measured memory_bytes: 21320
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
  int x,y;
  scanf("%d%d",&x,&y);
  printf((x==4)+(x==6)+(x==9)+(x==11)+(x==2)*2==(y==4)+(y==6)+(y==9)+(y==11)+(y==2)*2?"Yes":"No");
}


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

int main(){
  string S;cin >> S;
  int N = S.size();
  if(N==2){
    if(S[0]==S[1]){
      cout << "1 2" << endl;
    }else{
      cout << "-1 -1" << endl;
    }
    return 0;
  }
  for(int i=0;i<N-2;i++){
    char x = S[i],y = S[i+1],z = S[i+2];
    if(x==y||y==z||z==x){
      cout << i+1 << " " << i+3 << endl;
      return 0;
    }
  }
  cout << "-1 -1" << endl;
}

Measured memory_bytes: 3700
x1,y1,x2,y2 = gets.split.map(&:to_i)
xdis = x2 - x1
ydis = y2 - y1

x3 = x2 - ydis
y3 = y2 + xdis

x4 = x1 - ydis
y4 = y1 + xdis

puts [x3,y3,x4,y4].join(" ")

Measured memory_bytes: 1788
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j,k,l;
  int a[100000];
  a[0]=2;
  k=1;
  for(i=3;k<100000;i+=2){
    l=(int)sqrt(i)+1;
    for(j=3;j<l;j+=2){
      if(i%j==0)
	break;
    }
    if(j>=l){
      a[k]=i;
      k++;
    }
  }
  int n;
  while(cin>>n&&n){
    for(i=0;a[i]<n;i++);
    if(a[i]==n)
      cout<<0<<endl;
    else
      cout<<a[i]-a[i-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pa;
const ll MOD = 1e9 + 7;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r)-1; i >= (l); i--)

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}
//-----------------------------------------------------------//

int main() {
    init();
    int N;
    cin >> N;
    vector<ll> v(N);
    rep(i, N) cin >> v[i];
    ll ans = v[0] / 2;
    v[0] %= 2;
    repe(i, 1, N) {
        if (v[i - 1] && v[i]) {
            ans++;
            v[i]--;
        }
        ans += v[i] / 2;
        v[i] %= 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <string>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,h[100005];
ll dp[100005];
 
int main()  {

  signed int N,M,C;
  std::cin >> N >> M >> C;
  
  std::vector<signed int> B(M);
  std::vector<signed int> A(M);
  for (int i = 0; i < M; i++) {
  	std::cin >> B[i];
  }
  signed int sum;
  sum=0;
  int ans;
  ans=0;
  for (int j = 0; j < N; j++) {	
  	for (int i = 0; i < M; i++) {
    	std::cin >> A[i];
   	}
   	for (int i = 0; i < M; i++) {
			sum+=B[i]*A[i];
		}
		if(sum+C>0){
			ans++;
		}
		sum=0;
	
  }
  printf("%d\n",ans);
  
}

Measured memory_bytes: 256
import math
h = int(input())

def func_ans(x):
  sum = 0
  if x == 1:
    return 1
  else:
    return func_ans(x//2) + func_ans(x//2) + 1

ans = 0

x = int(math.log2(h))
print(2 **(x + 1) - 1)


#print(func_ans(h))


    


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

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;

  string X, Y;
  int max = 0;
  for (int i = 1; i < S.size(); i++)
  {
    X = S.substr(0, i);
    Y = S.substr(i);
    set<char> same_list;

    same_list.clear();
    for (auto c : X){      
      for (int j = 0; j < Y.size(); j++)
      {
        if (c == Y.at(j)){
          same_list.insert(c);
        }
      }
      if (max < same_list.size()){
        max = same_list.size();
      }
    }
  }

  cout << max << endl;
  
}

Measured memory_bytes: 3640
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static int[] array;
    public static void main(String[] args) {
        read();
        solve();
    }

    static void read(){
        array = new int[10];
        for(int i = 0; i < 10; i++){
            array[i] = sc.nextInt();
        }
    }

    static void solve(){
        Arrays.sort(array);
        System.out.println(array[9]);
        System.out.println(array[8]);
        System.out.println(array[7]);
    }

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PLL, PLL> PP;
typedef pair <PII, int> PPI;
typedef unsigned int ui;
typedef vector <int> vi;
const ll mod = 1e9+7;
const int inf = 1e9+9;
const ll MOD = 1e9+696969;
const ll INF = 1e18;

#define maxn 1000100
ll a, b, c, d;
int n;

PLL MAX[maxn];

int main()
{
	boost;
	cin >> n >> a >> b >> c >> d;
	MAX[1] = mp(a, a);
	for (int i=2; i<=n; ++i)
	{
		MAX[i].e1 = MAX[i-1].e1 + d;
		MAX[i].e2 = MAX[i-1].e2 + c;
		//now lets try to minus only
		ll rest = n - i;
		ll dol = MAX[i].e2 - d * rest, gora = MAX[i].e1 - c * rest;
		if (dol <= b && gora >= b) OUT("YES");
	}
	
	cout << "NO";

}


Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(NULL)
#define PI acos(-1.0)
#define TEST(n) cout<<"dhukse"<<n<<'\n'
#define endl '\n'
#define FILEREAD freopen("input.txt","r",stdin)
#define FIXED(n) cout << fixed << setprecision(n);
#define CASE(n) cout<<"Case " << n << ": ";
long long Set(long long N,long long pos){ return N=N | (1<<pos);}
long long reset(long long N,long long pos){return N= N & ~(1<<pos);}
bool check(long long N,long long pos){return (bool)(N & (1<<pos));}
long long min(long long a, long long b){if(a<b)return a;else return b;}
long long max(long long a, long long b){if(a>b)return a;else return b;}

/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////In the name of almighty ALLAH/////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////Coded By: pranonrahman////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////

vector<pair<long long,long long> > arr;
long long n;
long long memo[10045];
long long dp(long long rem)
{
    if(rem<=0)   return 0;
    long long mn=INT_MAX;
    if(memo[rem]!=-1)   return memo[rem];
    for(long long i=0;i<n;i++)
    {
        long long cnt = arr[i].second+dp(rem-arr[i].first);
        mn=min(mn,cnt);
    }
    return memo[rem]=mn;
}

int main()
{
    FAST;
    long long t=1;
   // cin >> t;
    long long T = t;
    while(t--)
    {
        memset(memo,-1,sizeof(memo));
        long long h;
        cin >> h >>  n;
        for(long long i=0;i<n;i++)
        {
            long long x,y;
            cin >> x >> y;
            arr.push_back({x,y});
        }
        cout << dp(h) << endl;
    }
    return 0;
}



Measured memory_bytes: 896
import sys
from math import sin, cos, radians
input = sys.stdin.readline
deg = radians(60)

def Koch(n, p1_x, p1_y, p2_x, p2_y):
    if n != 0:
        s_x = (2 * p1_x + p2_x) / 3
        s_y = (2 * p1_y + p2_y) / 3
        t_x = (p1_x + 2 * p2_x) / 3
        t_y = (p1_y + 2 * p2_y) / 3
        u_x = (t_x - s_x) * cos(deg) - (t_y - s_y) * sin(deg) + s_x
        u_y = (t_x - s_x) * sin(deg) + (t_y - s_y) * cos(deg) + s_y
        Koch(n - 1, p1_x, p1_y, s_x, s_y)
        print('{:.8f} {:.8f}'.format(s_x, s_y))
        Koch(n - 1, s_x, s_y, u_x, u_y)
        print('{:.8f} {:.8f}'.format(u_x, u_y))
        Koch(n - 1, u_x, u_y, t_x, t_y)
        print('{:.8f} {:.8f}'.format(t_x, t_y))
        Koch(n - 1, t_x, t_y, p2_x, p2_y)
    else:
        return

n = int(input())
p1_x, p1_y = 0, 0
p2_x, p2_y = 100, 0
print('{:.8f} {:.8f}'.format(p1_x, p1_y))
Koch(n, p1_x, p1_y, p2_x, p2_y)
print('{:.8f} {:.8f}'.format(p2_x, p2_y))



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

typedef long long ll;

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

	vector<int> c(2,0);
	for (int i = 0; i < N; i++) {
		if(a[i]%2==0 && a[i]%4!=0) c[1]++;
		else if(a[i]%4==0) c[0]++;
	}

	int n4=N/2;
	bool ans=false;
	
	for (int i = n4, j=N, k=0; i >=0; i--,j-=2,k++) {
		//cout << k <<" "<< j << endl;
		if(c[0]>=k && c[1]>=j) ans=true;
	}
	if(c[0]>=n4) ans=true;

	cout << (ans?"Yes":"No") << endl;
}


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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
template<class T>
T LCM(T a, T b) {
	return a / GCD(a, b) * b;
}
template<class T>
inline T round_int(T a, T b) {return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	int a, b, c;
	cin >> a >> b >> c;

	if (b - a == c - b) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define cpp mp::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
	int to;
	ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
int main() {
	// COME_LET_THE_GAMES_BEGIN();
	int w, h, x, y;
	scanf("%d%d%d%d", &w, &h, &x, &y);
	if ((w&1)&&(h&1)) {
		printf("%lld.5 ", (ll)w * h / 2);
	}
	else {
		printf("%lld ", (ll)w * h / 2);
	}
	if (x + x == w && y + y == h) {
		puts("1");
	}
	else {
		puts("0");
	}
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int[,] x = new int[N, N];
        int[,] y = new int[N, N];
        for (int i = 0; i < N; i++)
        {
            int num = int.Parse(Console.ReadLine());
            for(int j = 0; j < num; j++)
            {
                string[] input = Console.ReadLine().Split();
                x[i,j] = int.Parse(input[0]);
                y[i, j] = int.Parse(input[1]);
            }
        }
        int[] temp = new int[N];
        for (int i = 0; i < N; i++)
        {
            temp[i] = 0;
        }
        int ans = 0;
        for (int loop = 0; loop < Math.Pow(2, N); loop++)
        {
            bool flag = true;
            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < N; j++)
                {
                    if (temp[i] == 1)
                    {
                        if (x[i,j]!=0&&temp[x[i, j] - 1] != y[i, j]) { flag = false; }
                    }
                }
            }
            if (flag == true) { ans = Math.Max(ans,temp.Sum() ); }
            temp[0] += 1;
            for (int i = 0; i < N; i++)
            {
                if (i != N - 1 && temp[i] == 2) { temp[i + 1] += 1; temp[i] = 0; }
            }
        }
        Console.WriteLine(ans);
    }
}

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

int main(){
  int n, m, l;
  cin >> n >> m >> l;
  vector<vector<int> > mtr1(n, vector<int>(m));
  vector<vector<int> > mtr2(m, vector<int>(l));
  vector<vector<long long int> > mtr3(n, vector<long long int>(l, 0));
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      cin >> mtr1.at(i).at(j);
    }
  }

  for(int i = 0; i < m; i++){
    for(int j = 0; j < l; j++){
      cin >> mtr2.at(i).at(j);
    }
  }

  for(int i = 0; i < n; i++){
    for(int j = 0; j < l; j++){
      for(int k = 0; k < m; k++){
        mtr3.at(i).at(j) += mtr1.at(i).at(k) * mtr2.at(k).at(j);
      }
    }
  }


  for(int i = 0; i < n; i++){
    for(int j = 0; j < l; j++){
      cout << mtr3.at(i).at(j);
      if(j == l - 1){
        cout << endl;
      }
      else{
        cout << " " ;
      }
    }
  }
}


Measured memory_bytes: 3200
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

template<long long Mod>
struct mint{
    long long x;
    mint(long long x=0) :x((x% Mod+Mod)%Mod){}

    mint operator-() const { return mint(-x); }

    mint& operator+=(const mint a) {
        if((x += a.x) >= Mod) x -= Mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if((x += Mod-a.x) >= Mod) x -= Mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= Mod;
        return *this;
    }

    mint operator^(long long t) const {
        mint ret(1);
        mint a = *this;
        while(t){
            if(t&1){
                ret *= a;
            }
            a *= a;
            t >>= 1;
        }
        return ret;
    }
    mint inv() const { return *this ^ (Mod-2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }

    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint operator/(const mint a) const { return mint(*this) /= a; }

    friend istream& operator>>(istream& is, mint& a) { return is >> a.x; }
    friend ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
};

int N;
mint<MOD> A[200000];

signed main(){
    cin >> N;
    rep(i, N) cin >> A[i];

    mint<MOD> sum = 0;
    mint<MOD> ans = 0;
    rep(i, N){
        ans += sum * A[i];
        sum += A[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 5212
N, K, Q, *A = map(int, open(0).read().split())

ans = float("inf")
for Y in set(A):
    C = []
    tmp = []
    for a in A:
        if a >= Y:
            tmp.append(a)
        else:
            if len(tmp) >= K:
                C += sorted(tmp)[:len(tmp) - K + 1]
            tmp = []
    if len(tmp) >= K:
        C += sorted(tmp)[:len(tmp) - K + 1]

    if len(C) >= Q:
        C.sort()
        X = C[Q - 1]
        ans = min(ans, X - Y)

print(ans)


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int r,n;
    while(cin>>r>>n,r||n){
        int h[40]={0};
        while(n--){
            int xl,xr,hh;
            cin>>xl>>xr>>hh;
            xl+=20;xr+=20;
            for(int i=xl;i<xr;i++)chmax(h[i],hh);
        }

        double ans=1001001001;
        for(int i=0;i<40;i++){
            int x=abs(i-20)+(i-20>=0?0:-1);
            if(x>=r)continue;
            double tmp=r-sqrt(1.0*(r*r-x*x));
            chmin(ans,h[i]+tmp);
        }
        printf("%.20f\n",ans);
    }
    return 0;
}

Measured memory_bytes: 3108
import java.io.PrintWriter
import java.util.*
import kotlin.math.floor

val pw = PrintWriter(System.out)
val sc = Scanner(System.`in`)

fun main(args: Array<String>) {
    val a = sc.nextLong()
    val b = sc.nextLong()
    val n = sc.nextLong()

    abc000a(a, b, n)
}

fun abc000a(a:Long, b:Long, n:Long) {
    var maxi = -10000000000L
    if(b - 1 <= n){
        maxi = (a*(b-1))/b - a*((b-1)/b)
    }else{
        maxi = (a*n)/b - a*(n/b)
    }
    println(maxi)
}


fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextListOfString() = next().split(" ")
fun nextListOfInt() = nextListOfString().map { it.toInt() }
fun nextListOfLong() = nextListOfString().map { it.toLong() }
fun nextListOfDouble() = nextListOfString().map { it.toDouble() }



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

int main(){
 int n;
 cin >> n;
 vector<int> a(n);
 rep(i,n) cin >> a[i];
 int nxt = 1, ans = 0;
 rep(i,n){
     if(nxt == a[i]){
         ++nxt;
     }
     else{
         ++ans;
     }
     if(ans == n) ans = -1; 
 }
  cout << ans << endl;
}




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

using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int>>;
using VVL = vector<vector<ll>>;
using PII = std::pair<int, int>;
using PLL = std::pair<ll, ll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, s, n, d) for (int i = (s); i < (int)(n); i += (d))
#define allpt(v) (v).begin(), (v).end()
#define allpt_c(v) (v).cbegin(), (v).cend()
#define allpt_r(v) (v).rbegin(), (v).rend()

const int mod = 1e9 + 7;

const string wsp = " ";
const string tb = "\t";
const string rt = "\n";

template <typename T>
void show1dvec(const vector<T> &v)
{
    if (v.size() == 0)
        return;
    int n = v.size() - 1;
    rep(i, n) cout << v[i] << wsp;
    cout << v[n] << rt;
    return;
}

template <typename T>
void show2dvec(const vector<vector<T>> &v)
{
    int n = v.size();
    rep(i, n) show1dvec(v[i]);
}

template <typename T, typename S>
void show1dpair(const vector<pair<T, S>> &v)
{
    int n = v.size();
    rep(i, n) cout << v[i].first << wsp << v[i].second << rt;
    return;
}

template <typename T, typename S>
void pairzip(const vector<pair<T, S>> &v, vector<T> &t, vector<T> &s)
{
    int n = v.size();
    rep(i, n)
    {
        t.push_back(v[i].first);
        s.push_back(v[i].second);
    }
    return;
}

template <typename T>
void maxvec(vector<T> &v)
{
    T s = v[0];
    int n = v.size();
    rep(i, n - 1)
    {
        if (s > v[i + 1])
        {
            v[i + 1] = s;
        }
        s = v[i + 1];
    }
}

template <typename T, typename S>
bool myfind(T t, S s)
{
    return find(t.cbegin(), t.cend(), s) != t.cend();
}

bool check(int y, int x, int h, int w)
{
    return 0 <= y && y < h && 0 <= x && x < w;
}

VI cumsum(VI &v)
{
    int s = 0;
    VI ret = {0};

    rep(i, v.size())
    {
        s += v[i];
        ret.push_back(s);
    }
    return ret;
}

void shuffle(VI &v, int t)
{
    int temp = v[t - 1];
    rep(i, t - 1) v[t - 1 - i] = v[t - 2 - i];
    v[0] = temp;
}



int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    VI p_list(a), q_list(b), r_list(c);
    priority_queue<int> apple;
    rep(i, a) cin >> p_list[i];
    rep(i, b) cin >> q_list[i];
    rep(i, c) cin >> r_list[i];
    sort(allpt(p_list));
    sort(allpt(q_list));
    rep(i, x) apple.push(p_list[a - 1 - i]);
    rep(i, y) apple.push(q_list[b - 1 - i]);
    rep(i, c) apple.push(r_list[c - 1 - i]);



    ll ans = 0;
    rep(i, x + y)
    {
        ans += apple.top();
        apple.pop();
    }
    cout << ans << rt;

    return 0;
}


Measured memory_bytes: 3572
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

a, b = map(int, input().split())


if a * b < 0:
    print("Zero")
elif a == 0 or b == 0:
    print("Zero")
elif a > 0 and b > 0:
    print('Positive')
else:
    minus = abs(b - a) + 1
    if minus % 2 == 0:
        print('Positive')
    else:
        print('Negative')



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

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

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc178/tasks/abc178_e
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

// https://naoyat.hatenablog.jp/entry/k-dimension-manhattan-distance
void solve() {
    int N;
    cin >> N;
    vector<int> v1(N), v2(N);
    REP(i, N) {
        int a, b;
        cin >> a >> b;
        v1[i] = a - b;
        v2[i] = a + b;
    }
    sort(ALL(v1));
    sort(ALL(v2));
    cout << max(v1.back() - v1.front(), v2.back() - v2.front()) << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 6304
package main

import (
	"fmt"
)

func sum(g [][]int32) {
	n := len(g)
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if i > 0 {
				g[i][j] += g[i-1][j]
			}
			if j > 0 {
				g[i][j] += g[i][j-1]
			}
			if i > 0 && j > 0 {
				g[i][j] -= g[i-1][j-1]
			}
		}
	}
}

func check(g [][]int32, sx, sy int, k int) int32 {
	k2 := k * 2

	k -= 1
	k2 -= 1
	a := g[sx+k2][sy+k2] - g[sx+k2][sy+k] - g[sx+k][sy+k2] + g[sx+k][sy+k]
	b := g[sx+k][sy+k]
	if sx > 0 {
		b -= g[sx-1][sy+k]
	}
	if sy > 0 {
		b -= g[sx+k][sy-1]
	}
	if sx > 0 && sy > 0 {
		b += g[sx-1][sy-1]
	}
	return a + b
}

func main() {
	var N, K int
	fmt.Scanf("%d %d", &N, &K)
	K2 := K * 2

	w := make([][]int32, 4*K)
	for i := 0; i < len(w); i++ {
		w[i] = make([]int32, 4*K)
	}
	b := make([][]int32, 4*K)
	for i := 0; i < len(b); i++ {
		b[i] = make([]int32, 4*K)
	}

	for i := 0; i < N; i++ {
		x, y, s := 0, 0, ""
		fmt.Scanf("%d %d %s", &y, &x, &s)
		c := s[0]

		if c == 'B' {
			b[x%K2][y%K2] += 1
			b[x%K2+K2][y%K2] += 1
			b[x%K2+K2][y%K2+K2] += 1
			b[x%K2][y%K2+K2] += 1
		} else {
			w[x%K2][y%K2] += 1
			w[x%K2+K2][y%K2] += 1
			w[x%K2+K2][y%K2+K2] += 1
			w[x%K2][y%K2+K2] += 1
		}
	}

	//for _, t := range w {
	//	fmt.Println(t)
	//}

	sum(b)
	sum(w)

	//fmt.Println("----")
	//for _, t := range w {
	//	fmt.Println(t)
	//}

	ans := 0
	for i := 0; i < K; i++ {
		for j := 0; j < K; j++ {
			nw := check(w, i, j, K)
			nb := check(b, i+K, j, K)
			if int(nw+nb) > ans {
				ans = int(nw + nb)
			}
		}
	}

	for i := 0; i < K; i++ {
		for j := 0; j < K; j++ {
			nb := check(b, i, j, K)
			nw := check(w, i+K, j, K)
			if int(nw+nb) > ans {
				ans = int(nw + nb)
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 145408
#include<iostream>
#include<cstdio>
#include<cstring>
#include <fstream>
#include<string>
#include<sstream>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
#include <math.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const long long int MOD = 1000000007;
const int INF = 1000000007;
const double EPS = 1e-10;
const double PI = 3.14159265359;
const int N = 200005;
//cout << fixed << std::setprecision(9)
//--------------------------

int n;
ll a[N], h[N], dp[N];
P flowers[N];

ll BIT[N];
void set_val(ll *bit, int ind, ll val)
{
	ind++;
	while (ind < N) {
		bit[ind] = max(bit[ind], val);
		ind += ind & -ind;
	}
}
ll max_val(ll *bit, int ind)
{
	ll res = 0;
	ind++;
	while (ind) {
		res = max(res, bit[ind]);
		ind -= ind & -ind;
	}
	return res;
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		flowers[i].first = h[i];
		flowers[i].second = i;
	}
	for (int i = 0; i < n; i++)
		cin >> a[i];

	sort(flowers, flowers + n);

	ll ans = 0;
	for (int i = 0; i < n; i++) {
		int ind = flowers[i].second;
		dp[ind] = max_val(BIT, ind - 1) + a[ind];
		set_val(BIT, ind, dp[ind]);
		ans = max(ans, dp[ind]);
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 8064
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <deque>
#include <bits/stdc++.h>
//#include "D:\C++\test_lib_projects\testlib.h"
using namespace std;
#define ll long long
#define pii pair<int,int>

bool debug=true;
/*
   Write In New Computer
    By XiaoGeNintendo
	     gwq2017
	Type:
*/
template<typename T1,typename T2>ostream& operator<<(ostream& os,pair<T1,T2> ptt){
	os<<ptt.first<<","<<ptt.second;
	return os;
}
template<typename T>ostream& operator<<(ostream& os,vector<T> vt){
	os<<"{";
	for(int i=0;i<vt.size();i++){
		os<<vt[i]<<" ";
	}
	os<<"}";
	return os;
}

int a,b;
int main(int argc,char* argv[]){
	cin>>a>>b;
	if(a+b==15){
		cout<<"+";
		return 0;
	}
	if(a*b==15){
		cout<<"*";
		return 0;
	}
	cout<<"x";
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int ans = 0;
  string S;
  cin >> S;
  for(int i=0;i<S.size();i++){
     if(S.at(i)=='+'){
     ans++;
     }
     if(S.at(i)=='-'){
     ans--;
     }
  }
  cout << ans << endl;
}
  


  

Measured memory_bytes: 256
import bisect
from collections import defaultdict

s = input()
t = input()
if set(s) & set(t) != set(t):
    print(-1)
    exit()
cnt = defaultdict(list)
for i, c in enumerate(s, 1):
    cnt[c].append(i)
loop = 0
prev = 0
for w in t:
    l = cnt[w]
    idx = bisect.bisect_right(l, prev)
    if idx < len(l):
        prev = l[idx]
    else:
        prev = l[0]
        loop += 1
ans = loop*len(s) + prev
print(ans)


Measured memory_bytes: 13760
#include<stdio.h>

int main(void){

	int a,b;
	int d,r;
	double f;

	scanf("%d %d",&a,&b);

	d=a/b;
	r=a%b;
	f=(double)a/(double)b;

	printf("%d %d %.5lf\n",d,r,f);

	return 0;

}
	

Measured memory_bytes: 640
n=int(input())
a_b=[int(i) for i in input().split()]
p=[int(i) for i in input().split()]
#n=7
#a_b=[5,15]
#p=[1,10,16,2,7,20,12]

level1=[]
level2=[]
level3=[]

for i in range(len(p)):
    if p[i]<=a_b[0]:
        level1.append(p[i])
    elif p[i]>a_b[0] and p[i]<=a_b[1]:
        level2.append(p[i])
    else:
        level3.append(p[i])

m=min(len(level1), len(level2), len(level3))

print(m)

Measured memory_bytes: 3064
#ABC116_C
N=int(input())
H=list(map(int,input().split()))
ans=0

while 1:
    for i in range(N):
        if H[i]!=0:
            H_left=i
            ans+=1
            H[i]-=1
            break
    else:
        break
    
    for i in range(H_left+1,N):
        if H[i]!=0:
            H[i]-=1
        elif H[i]==0:
            break
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int n, k;
int a[110];
int dp[100010];

int grundy(int t) {
	if (dp[t] != -1) return dp[t];

	set<int> s;
	rep(i, n) {
		if (t - a[i] >= 0) s.insert(grundy(t - a[i]));
	}
	int res = 0;
	while(s.count(res)) res++;
	return dp[t] = res;
}

int main(int argc, char const *argv[])
{
	cin >> n >> k;
	rep(i, n) cin >> a[i];
	rep(i, 100010) dp[i] = -1;

	if (grundy(k) == 0) printf("Second\n");
	else printf("First\n");

	return 0;
}

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

#define lint int64_t
const lint MOD = 1e9 + 7;

const int di[] = {0, -1, -1, -1, 0, 1, 1, 1},
    dj[] = {1, 1, 0, -1, -1, -1, 0, 1};

void dfs(int i, int j, vector<vector<int> >& f, int h, int w) {
    f[i][j] = 0;
    for (int k = 0; k < 8; k++) {
        int ni = i + di[k], nj = j + dj[k];
        if (0 <= ni and ni < h and 0 <= nj and nj < w and f[ni][nj] == 1) {
            dfs(ni, nj, f, h, w);
        }
    }
}

int main() {
    while (true) {
        int h, w;
        cin >> w >> h;
        if (h == 0 and w == 0) {
            break;
        }
        vector<vector<int> > f(h, vector<int>(w));
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                cin >> f[i][j];
            }
        }

        int ans = 0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (f[i][j] == 1) {
                    dfs(i, j, f, h, w);
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }
    

    return 0;
}


Measured memory_bytes: 3312
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;

void chmin(long long int &a,long long int b){
  if(a>b){
    a=b;
  }
}

int main(){
  int N;
  cin>>N;
  
  int h[N];
  for(int i=0;i<N;i++)cin>>h[i];
  
  long long int dp[N];
  for(int i=0;i<N;i++)dp[i]=1000000010;
  
  dp[0]=0;
  
  for(int i=1;i<N;i++){
    chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
    if(i>1)chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout <<dp[N-1]<<endl;
    
  
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    LL n,m;
    vector<vector<int>> g;
    vector<LL> vis;
    Problem(LL n, LL m):n(n),m(m),g(n),vis(n){};
    bool dfs(int c, int p = -1){ //odd loop?
        DBG(c,p)
        if(vis[c]>0 and (vis[p]-vis[c])%2==0){
            return true;
        }else if(vis[c]>0){
            return false;
        }
        if(vis[c] ==0 and c>0){
            vis[c]=vis[p]+1;
        }else if(vis[c]==0){
            vis[c]=1;
        }
        bool ret =false;
        for(auto x:g[c]){
            if(x!=p){
                ret|=dfs(x,c);
            }
        }
        return ret;
    }
    void solve(){
        for(int i=0; i<m; ++i){
            int a,b; cin >> a >> b;
            --a;--b;
            g[a].push_back(b);
            g[b].push_back(a);
        }

        if(!dfs(0)){
            DBG(vis)
            LL d=0,e=0;
            for(int i=0; i<n; ++i){
                if(vis[i]%2)d++;
                else e++;
            }
            cout << d*e-m <<"\n";
        }else cout << n*(n-1)/2-m <<"\n";
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0,m;
    cin >> n >> m;
    Problem p(n,m);
    p.solve();
    return 0;
}



Measured memory_bytes: 6784
// AOJ Volume 0 Problem 0051

#include <stdio.h>
#include <string.h>

int main(void)
{
    int n;
    int i, j, k;
    char str[100];
    int max, min;
    int freq[10];
    
    scanf("%d", &n);

    for (i = 0; i < n; i++){
        scanf("%s", str);
        
        memset(freq, 0, sizeof(freq));
        for (j = 0; j < 8; j++){
            freq[str[j] - '0']++;
        }
        
        if (freq[0] == 8){
            min = max = 0;
        }
        else {
            min = max = 0;

            for (j = 0; j < 10; j++){
                for (k = 0; k < freq[j]; k++){
                    min = min * 10 + j;
                }
            }
            for (j = 9; j >= 0; j--){
                for (k = 0; k < freq[j]; k++){
                    max = max * 10 + j;
                }
            }
        }
        printf("%d\n", max - min);
    }

	return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int dx = x2-x1;
  int dy = y2-y1;
  int x3 = x2-dy;
  int y3 = y2+dx;
  int x4 = x3-dx;
  int y4 = y3-dy;
  printf("%d %d %d %d\n", x3, y3, x4, y4);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <cmath>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair
#define EPS 1e-8
#define equals(a,b) fabs((a) - (b)) < EPS

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct Point {
	double x, y;

	Point(double x=0, double y=0) : x(x), y(y) {}

	Point operator+(const Point &o) const { return Point(x+o.x, y+o.y); }

	Point operator-(const Point &o) const { return Point(x-o.x, y-o.y); }

	Point operator*(const double m) const { return Point(x*m, y*m); }

	Point operator/(const double d) const { return Point(x/d, y/d); }

	bool operator<(const Point &o) const { return x != o.x ? x < o.x : y < o.y; }

	bool operator==(const Point &o) const { return fabs(x-o.x) < EPS && fabs(y-o.y) < EPS; }
};

ostream& operator << (ostream& os, const Point& p) {
	os << "(" << p.x << ", " << p.y << ")";
	return os;
}

double dot(Point a, Point b) { return a.x * b.x + a.y * b.y; }
double cross(Point a, Point b) { return a.x * b.y - a.y * b.x; }
double atan(Point p) { return atan2(p.y, p.x); }
double norm(Point p) { return p.x * p.x + p.y * p.y; }
double distancePP(Point p, Point o) { return sqrt(norm(o - p)); }

int ccw(Point a, Point b, Point c) {
	b = b-a;
	c = c-a;

	if(cross(b, c) > 0.0) return +1;	//conter clockwise
	if(cross(b, c) < 0.0) return -1;	//clockwise
	if(dot(b, c) < 0.0) return +2;	//a on Seg(b,c)
	if(norm(b) < norm(c)) return -2;	//b on Seg(a,c)
	return 0;	//c on Seg(a,b)
}

int main() {
	Point a, b, c;
	cin >> a.x >> a.y >> b.x >> b.y;

	int q;
	cin >> q;

	rep(i, q) {
		cin >> c.x >> c.y;

		int d = ccw(a, b, c);
		if(d == +1) {
			cout << "COUNTER_CLOCKWISE" << endl;
		} else if(d == -1) {
			cout << "CLOCKWISE" << endl;
		} else if(d == +2) {
			cout << "ONLINE_BACK" << endl;
		} else if(d == -2) {
			cout << "ONLINE_FRONT" << endl;
		} else if(d == 0) {
			cout << "ON_SEGMENT" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>
#include <stack>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator<< (ostream &out, const vector<int> &b) {
    for (auto k : b) out << k << " ";
    return out;
}

istream& operator>> (istream& in, pii& b) {
    in >> b.first >> b.second;
    return in;
}

ostream& operator<< (ostream& out, const pii& b) {
    out << "{" << b.first << ", " << b.second << "}";
    return out;
}

template <typename T1, typename T2> inline bool chkmin(T1 &x, const T2 &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T1, typename T2> inline bool chkmax(T1 &x, const T2 &y) {if (x < y) {x = y; return 1;} return 0;}


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 10;
#else
    #define dbg(x) 57
    const int INF = 1e18;
    // const int mod = 2600000069;  
    // const int p = 179;
#endif

const ld PI = acos(-1);

#define time clock() / (double) CLOCKS_PER_SEC

// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,sse3,sse4")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("avx2")  
// #pragma GCC optimize("section-anchors")
// #pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
// #pragma GCC optimize("vpt")
// #pragma GCC optimize("rename-registers")
// #pragma GCC optimize("move-loop-invariants")
// #pragma GCC optimize("unswitch-loops")
// #pragma GCC optimize("function-sections")
// #pragma GCC optimize("data-sections")

mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> h;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (i & 1) {
            h.pb(a[i]);
        }
    }
    vector<int> b = a;
    sort(all(b));
    multiset<int> s;
    for (int i = 0; i < n; i++) {
        if (i & 1) {
            s.insert(b[i]);
        }
    }
    int ans = 0;
    for (auto k : h) {
        if (s.count(k)) {
            s.erase(s.lower_bound(k));
        } else {
            ans++;
        }
    }
    cout << ans << "\n";
}
/*

*/

Measured memory_bytes: 7476
#include<cstdio> 
using namespace std;
int i,j;
char a[10][10];
int main()
{
	for (i=1;i<=2;i++)
	  scanf("%s",a[i]);
	bool flag=1;
	for (i=0;i<3;i++)
	  if (a[1][i]!=a[2][2-i])
	  {
	  	flag=0;
	  }
	printf("%s\n",flag?"YES":"NO");
}

Measured memory_bytes: 128
S=list(input())

dp=[[0 for i in range(13)]for j in range(len(S)+1)]
dp[0][0]=1

for i in range(len(S)):
    if S[i]=="?":
        for j in range(13):
            
            for k in range(10):
                dp[i+1][(10*j+k)%13]+=dp[i][j]
                dp[i+1][(10*j+k)%13]%=(10**9+7)
    else:
        for j in range(13):
            dp[i+1][(10*j+int(S[i]))%13]+=dp[i][j]
            dp[i+1][(10*j+int(S[i]))%13]%=(10**9+7)
print(dp[-1][5])

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n, tt = 0, xx = 0, yy = 0;

  cin >> n;
  vector<int> t(n + 1), x(n + 1), y(n + 1);
  t[0] = x[0] = y[0] = 0;
  for (int i = 1; i <= n; ++i) cin >> t[i] >> x[i] >> y[i];

  bool flg = true;
  for (int i = 1; i <= n; ++i)
    if (!(t[i] - t[i - 1] >= abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]) &&
          (t[i] - t[i - 1] - abs(x[i] - x[i - 1]) - abs(y[i] - y[i - 1])) % 2 ==
              0))
      flg = false;

  cout << (flg ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 1408