akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

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

typedef complex<long double> co;
struct barrier {
    co c;
    long double r;
};

typedef pair<long double, ll> P;
vector<long double> d;
struct edge {
    ll to;
    long double cost;
};
vector<vector<edge>> G;

void dijkstra (ll s, ll V) {
    priority_queue<P, vector<P>, greater<P>> que;
    d.assign(V, inf);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        ll v = p.second;
        if (d[v] < p.first) continue;
        for (edge e : G[v]) {
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

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

    long double xs, ys, xt, yt;
    cin >> xs >> ys >> xt >> yt;
    co s(xs, ys), t(xt, yt);
    ll N;
    cin >> N;
    vector<barrier> b = {{s, 0}, {t, 0}};
    Rep (i, N) {
        long double x, y, r;
        cin >> x >> y >> r;
        b.push_back({co(x, y), r});
    }

    G.assign(N+2, vector<edge>());

    Rep (i, N+2) {
        for (ll j = i+1; j < N+2; j++) {
            long double dist = abs(b[i].c - b[j].c) - b[i].r - b[j].r;
            if (dist < 0) dist = 0;
            G[i].push_back({j, dist});
            G[j].push_back({i, dist});
        }
    }

    dijkstra(0, N+2);

    cout << fixed << setprecision(10) << d[1] << endl;
}

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

int main(){
    ll k;  cin >> k;
    ll sum=0;
    if(k<=2){
        for(ll i=1; i<=k; i++){
            for(ll j=1; j<=k; j++){
                for(ll p=1; p<=k; p++){
                    sum += gcd(gcd(i, j), p);
                }
            }
        }
    }else{
        for(ll i=1; i<=k; i++){
            for(ll j=i; j<=k; j++){
                for(ll p=j; p<=k; p++){
                    if(i==j && j==p){
                        sum += gcd(gcd(i, j), p);
                    }else if(i==j || j==p)
                        sum += gcd(gcd(i, j), p)*3;
                    else 
                        sum += gcd(gcd(i, j), p)*6;
                }
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

int main() {
    int K;
    cin >> K;

    vector<bool> used(K, false);
    ll a = (7 % K);
    bool ok = true;
    int cnt = 1;
    while (1) {
        if (a == 0) break;

        if (used[a]) {
            ok = false;
            break;
        }

        cnt++;
        used[a] = true;
        a = (a * 10 + 7) % K;
    }

    if (ok) {
        cout << cnt << endl;
    } else {
        cout << -1 << endl;
    }

}

Measured memory_bytes: 3716
function Main(input) {
	var ま = input.split(' ');
	var り = '';
	if (Math.abs(Number(ま[0]) - Number(ま[1])) < Math.abs(Number(ま[0]) - Number(ま[2]))) {
		り = 'A';
	} else {
		り = 'B';
	}
	console.log(り);
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long ll;
typedef pair<ll,ll> P;


int n;
bool use[1010101] = {0};

int main(){
	cin >> n;
	
	int cnt = 0, i;
	for(i = 1; cnt < n; i++){
		cnt += i;
	}
	if(cnt == n){
		for(int j = 1; j < i; j++){
			cout << j << endl;
		}
		return 0;
	}
	for(int j = 1; j < i; j++){
		if(j == cnt - n) continue;
		cout << j << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
<?php

list($s) = explode(' ', trim(fgets(STDIN)));

if (substr($s, 2, 1) !== substr($s, 3, 1)) {
    echo 'No';
} elseif (substr($s, 4, 1) !== substr($s, 5, 1)) {
    echo 'No';
} else {
    echo 'Yes';
}


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

using namespace std;

int main()
{/*main*/
  int n,P[10800],ans,i,PM[10800],h,j,min;
  while(scanf("%d",&n)!=EOF)
    {/*while*/
      ans=0;
      for(i=0;i<n;i++)
	{/*for*/
	  cin >> P[i];
	}/*E_for*/

      for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(P[j]<P[min]){ min=j ;}
    }

    h=P[min];
    P[min]=P[i];
    P[i]=h;
  }



      //     for(i=0;i<)
      //cout << 




      for(i=0;i<n;i++)
	{
	  if(i!=0)
	    {
	      PM[i]=PM[i-1]+P[i];
	      ans+=PM[i];
	    }
	  else
	    {
	      PM[i]=P[i];
	      ans+=PM[i];
	    }
	}
      cout << ans << endl;
    }/*E_while*/
      return 0;
}/*E_main*/

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <stdio.h>
using namespace std;

int main(){
    int A,B,S=1,ans=0;
    cin>>A>>B;
    while(S<B){
        S=S-1+A;
        ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring> 
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s == "SUN"){
		cout<<7;
	}
	else if(s == "MON"){
		cout<<6;
	}
	else if(s == "TUE"){
		cout<<5;
	}
	else if(s == "WED"){
		cout<<4;
	}
	else if(s == "THU"){
		cout<<3;
	}
	else if(s == "FRI"){
		cout<<2;
	}
	else if(s == "SAT"){
		cout<<1;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
namespace aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            int w, n;
            w = int.Parse(Console.ReadLine());
            n = int.Parse(Console.ReadLine());
            List<int> number = new List<int>(Enumerable.Range(0, w));
            for(int i=0; i < n; ++i) {
                int[] input = (from q in Console.ReadLine().Split(',') select int.Parse(q) - 1).ToArray();
                number[input[0]] = number[input[0]] - number[input[1]];
                number[input[1]] = number[input[1]] + number[input[0]];
                number[input[0]] = number[input[1]] - number[input[0]];
            }
            number.ForEach(item => Console.WriteLine(item + 1));
        }
    }
}

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

ll n, k;
int a[200005];
bool C(double x){
 int num = 0;
 for(int i = 0; i < n; i++){
  num += (int)(a[i] / x);
  }
return num <= k;
}

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

double lb = 0;
double ub = 1e9*1.0;
for(int i = 0; i < 1000; i++){
   double mid = (lb+ub) / 2;
   if(C(mid)) ub = mid;
   else lb = mid;
}
cout << (ll)ceil(lb) << endl;
return 0;
}

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

using namespace std;

int a[222222], s[222222];
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		scanf("%d", a + i);
	long c = 0, r = 0;
	for (int i = 0; i < n; i++) {
		if (a[n - i - 1] > n - i - 1 || a[n - i - 1] < a[n - i] - 1) {
			cout << -1 << endl;
			return 0;
		}
		if (!a[n - i - 1]) {
			c -= s[i];
			continue;
		}
		c += 1 - s[i + a[n - i - 1]] - s[i];
		s[i + a[n - i - 1]] = 1;
		r += c;
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

using namespace std;

int main(){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if((x >= r && x <= W-r) && (y >= r && y <= H-r))
		printf("Yes\n");
	else{
		printf("No\n");
	}
}



Measured memory_bytes: 2692
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <array>
#include <valarray>

using namespace std;

int main()
{
    int N;
    scanf("%d\n", &N);
    vector<char> S(N);
    for (int i = 0; i < N; ++i) S[i] = getchar(); getchar();
    vector<char> T(N);
    for (int i = 0; i < N; ++i) T[i] = getchar(); getchar();
    for (int i = 0; i < N; ++i){
        bool continue_flag = false;
        for (int j = 0; i + j < N; ++j){
            if (S[i + j] != T[j]){
                continue_flag = true;
                break;
            }
        }
        if (continue_flag) continue;
        printf("%d\n", N + i);
        return 0;
    }
    printf("%d\n", N * 2);
}


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

int main()
{
    int H,W;
    cin >> H >> W;
    string str[H];

    for(int i=0; i<H; i++) cin >> str[i];

    for(int i=-1; i<=W; i++) cout << '#';
    cout << endl;

    for(int i=0; i<H; i++)
    {
        cout << '#' << str[i] << '#' << endl;
    }

    for(int i=-1; i<=W; i++) cout << '#';
    cout << endl;

    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (long long i = 0; i < N; i++)
using ll = long long;
template <class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INF = 1LL << 60;

int main() {
    ll N, W;
    cin >> N >> W;
    vector<pair<ll, ll>> wv(N + 1);
    vector<vector<ll>> dp(110, vector<ll>(100100));
    for (ll i = 1; i <= N; i++) {
        cin >> wv[i].first >> wv[i].second;
    }

    for (ll i = 1; i <= N; i++) {
        for (ll j = 0; j <= W; j++) {
            if (j - wv[i].first >= 0) {
                chmax(dp[i][j], dp[i - 1][j - wv[i].first] + wv[i].second);
            }
            chmax(dp[i][j], dp[i - 1][j]);
        }
    }
    cout << dp[N][W] << endl;

    return 0;
}


Measured memory_bytes: 87296
a = int(input())
b = 0
for i in range(1,a+1):
    if i % 3 == 0 and i % 5 == 0:
        b += 0
    elif i % 3 == 0:
        b += 0
    elif i % 5 == 0:
        b += 0
    else:
        b += i
print(b)

Measured memory_bytes: 9108
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxm=2e3+5;
const int mod=1e9+7;
int d[maxm][maxm];
int a[maxm];
int b[maxm];
int n,m;
signed main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=m;i++)cin>>b[i];
    //初始化一边为0的情况,因为下面dp的时候不枚举0
    for(int i=0;i<=n;i++)d[i][0]=1;
    for(int i=0;i<=m;i++)d[0][i]=1;
    //dp
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            d[i][j]=(d[i-1][j]+d[i][j-1]-d[i-1][j-1])%mod;
            if(a[i]==b[j])d[i][j]=(d[i][j]+d[i-1][j-1])%mod;
        }
    }
    cout<<(d[n][m]+mod)%mod<<endl;
    return 0;
}
/*
令d[i][j]表示序列a前i个数,序列b前j个数匹配的子序列数,
转移:
1.如果a[i]==b[j],那么d[i][j]=d[i-1][j-1]*2,
如果将a[i]和b[j]加入d[i-1][j-1]的每个匹配的末尾,方案数为d[i-1][j-1],
如果不加,方案数为d[i-1][j-1]
2.如果a[i]!=b[j],那么d[i][j]=d[i-1][j]+d[i][j-1]-d[i-1][j-1]
计算d[i][j]的时候,d[i-1][j]和d[i][j-1]一定已经计算出来了,
方案数为d[i-1][j]加上d[i][j-1],因为d[i-1][j-1]重复计算了,要容斥掉.

*/


Measured memory_bytes: 34824
package main

import (
	"bufio"
	"fmt"
	"sort"
	"strconv"
)

type IntListForSort []int

func (s IntListForSort) Len() int           { return len(s) }
func (s IntListForSort) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s IntListForSort) Less(i, j int) bool { return s[i] < s[j] }

func sortIntList(intList []int) {
	sort.Sort(IntListForSort(intList))
}

type IntListForSortDesc []int

func (s IntListForSortDesc) Len() int           { return len(s) }
func (s IntListForSortDesc) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s IntListForSortDesc) Less(i, j int) bool { return s[i] > s[j] }

func sortIntListDesc(intList []int) {
	sort.Sort(IntListForSortDesc(intList))
}

// ASC前提
func binarySearchInt(intList []int, key int, iMin int, iMax int) int {
	if iMax < iMin {
		return -1
	} else {
		iMid := iMin + (iMax-iMin)/2
		if intList[iMid] > key {
			return binarySearchInt(intList, key, iMin, iMid-1)
		} else if intList[iMid] < key {
			return binarySearchInt(intList, key, iMid+1, iMax)
		} else {
			return iMid
		}
	}
}

func input() string {
	var s string
	_, _ = fmt.Scan(&s)
	return s
}

func inputLn() string {
	var s string
	_, _ = fmt.Scanln(&s)
	return s
}

func inputByScanner(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func convListStrToInt(strList []string) []int {
	intList := make([]int, len(strList))
	for k, v := range strList {
		intV, _ := strconv.Atoi(v)
		intList[k] = intV
	}
	return intList
}

func convListStrToFloat(strList []string) []float64 {
	intList := make([]float64, len(strList))
	for k, v := range strList {
		intV, _ := strconv.Atoi(v)
		intList[k] = float64(intV)
	}
	return intList
}

func main() {
	n, _ := strconv.Atoi(inputLn())
	bList := make([]int, n-1)
	for i := 0; i < n-1; i++ {
		v, _ := strconv.Atoi(input())
		bList[i] = v
	}
	res := bList[0]
	for i := 1; i < n; i++ {
		if i == n-1 {
			res += bList[i-1]
		} else {
			if bList[i] > bList[i-1] {
				res += bList[i-1]
			} else {
				res += bList[i]
			}
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <limits>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#include <cmath>
#include <complex>
// #include "utiltime.hpp"

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

const int INFL = (int)1e9;
const ll INFLL = (ll)1e18;
const double INFD = numeric_limits<double>::infinity();
const double PI = 3.14159265358979323846;
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loopll(i, n) for(ll i = 0; i < (ll)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopll1(i, n) for(ll i = 1; i <= (ll)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = (ll)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define Looprll1(i, n) for(ll i = (ll)n; i >= 1; i--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(i, vector.size()) { cout << vector[i] << " "; } cout << endl;
#define printmx(matrix) Loop(i, matrix.size()) { Loop(j, matrix[i].size()) { cout << matrix[i][j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(double x) { ll m = (ll)sqrt(x); return m + (m * m <= (ll)(x) ? 0 : -1); }
ll ceilsqrt(double x) { ll m = (ll)sqrt(x); return m + ((ll)x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }

/*******************************************************/

void failed() {
	cout << "No" << endl;
	exit(EXIT_SUCCESS);
}

int main() {
	int h, w; cin >> h >> w;
	vi cnt(26, 0);
	Loop(i, h) {
		Loop(j, w) {
			char c; cin >> c;
			cnt[c - 'a']++;
		}
	}
	if (h % 2 == 0 && w % 2 == 0) {
		Loop(i, 26) {
			if (cnt[i] % 4 != 0) failed();
		}
	}
	else if (h % 2 == 0 && w % 2 == 1) {
		int x = (h / 2) * ((w - 1) / 2);
		Loop(i, 26) {
			int p = min(cnt[i] / 4, x);
			cnt[i] -= p * 4;
			x -= p;
		}
		if (x > 0) failed();
		Loop(i, 26) {
			if (cnt[i] % 2 != 0) failed();
		}
	}
	else if (h % 2 == 1 && w % 2 == 0) {
		int x = ((h - 1) / 2) * (w / 2);
		Loop(i, 26) {
			int p = min(cnt[i] / 4, x);
			cnt[i] -= p * 4;
			x -= p;
		}
		if (x > 0) failed();
		Loop(i, 26) {
			if (cnt[i] % 2 != 0) failed();
		}
	}
	else {
		int x = ((h - 1) / 2) * ((w - 1) / 2);
		Loop(i, 26) {
			int p = min(cnt[i] / 4, x);
			cnt[i] -= p * 4;
			x -= p;
		}
		if (x > 0) failed();
		int q = 1;
		Loop(i, 26) {
			if (cnt[i] % 2 != 0) q--;
		}
		if (q != 0) failed();
	}
	cout << "Yes" << endl;
}

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

int main() {
  int n,k,a,b=0;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>a;
    if(a>k-a)
      b+=2*(k-a);
    else
      b+=2*a;
  }
  cout<<b<<endl;
}

Measured memory_bytes: 256
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x
//最大化問題最小化問題
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N = 0;
    cin >> N;

    ll ans = 0;

    FOR(i,1,N){
        ans += (N-1)/i;
    }
    
    //本文
    //出力
    cout << ans << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 3648
def main():
    import sys
    from bisect import bisect_left
    from collections import deque
    input = sys.stdin.buffer.readline

    N, M = map(int, input().split())
    AB = [(0, 0)]
    for _ in range(N):
        a, b = map(int, input().split())
        AB.append((a, b))
    AB.append((10**9+1, 0))
    AB.sort(key=lambda x: x[0])
    A = [AB[i][0] for i in range(N+2)]
    P = [0] * (N+2)
    for i in range(1, N+2):
        if AB[i-1][1] != AB[i][1]:
            P[i] = 1
    if sum(P) == 0:
        print(0)
        exit()
    adj = [[] for _ in range(N+2)]
    E = {}
    for e in range(1, M+1):
        l, r = map(int, input().split())
        i = bisect_left(A, l)
        j = bisect_left(A, r+1)
        if i == j:
            continue
        adj[i].append(j)
        adj[j].append(i)
        E[i*(N+3)+j] = e
        E[j*(N+3)+i] = e

    for i in range(1, N+2):
        if P[i] and len(adj[i]) == 0:
            print(-1)
            exit()

    seen = [0] * (N + 2)
    par = [0] * (N + 2)
    ans = []
    for v0 in range(1, N+2):
        if seen[v0]:
            continue
        que = deque()
        que.append(v0)
        seen[v0] = 1
        seq = []
        while que:
            v = que.popleft()
            seq.append(v)
            for u in adj[v]:
                if seen[u] == 0:
                    seen[u] = 1
                    par[u] = v
                    que.append(u)
        seq.reverse()
        for v in seq[:-1]:
            if P[v]:
                p = par[v]
                ans.append(E[v*(N+3)+p])
                P[p] ^= 1
                P[v] = 0
    if sum(P):
        print(-1)
    else:
        ans.sort()
        print(len(ans))
        print(*ans)


if __name__ == '__main__':
    main()


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

using namespace std;

int AB(int x)
{
    return x < 0? (-x) : x;
}
int ac, ab, bc, a, b, c, d;
int main()
{
    ac = 0; ab = 0; bc = 0;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    if (AB(a-c) <= d) ac = 1;
    if (AB(a-b) <= d) ab = 1;
    if (AB(b-c) <= d) bc = 1;
    if (ac == 1 || (ab == 1 && bc == 1)) cout<<"Yes\n"; else cout<<"No\n";
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	static int H;
	static int W;
	static int c[][];
	static int A[][];
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		H = sc.nextInt();
		W = sc.nextInt();
		c = new int[10][10];
		for(int i=0;i<10;i++) {
			for(int j=0;j<10;j++) {
				c[i][j]=sc.nextInt();
			}	
		}
		A = new int[H][W];
		for(int i=0;i<H;i++) {
			for(int j=0;j<W;j++) {
				A[i][j]=sc.nextInt();
			}	
		}
		sc.close();
			
		
		//Froyd Warshall
		
		for(int k=0;k<10;k++) {
			for(int i=0;i<10;i++) {
				for(int j=0;j<10;j++) {
					c[i][j]=Math.min(c[i][j], c[i][k]+c[k][j]);
				}
			}
		}
		
		int cnt[] = new int[10];
		for(int i=0;i<H;i++) {
			for(int j=0;j<W;j++) {
				if (A[i][j]==-1) continue;
				cnt[A[i][j]]++;
			}	
		}
		int ans = 0;
		for(int i=0;i<10;i++) {
			ans += cnt[i]*c[i][1];
		}
		System.out.println(ans);
//		//for debug
//		for(int i=0;i<10;i++) {
//			for(int j=0;j<10;j++) {
//				System.out.print(c[i][j]+" ");
//			}
//			System.out.println();
//		}
			
		
	}
}



Measured memory_bytes: 46108
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    
    if (S == "Y") {
      cout << "Four" << endl;
      break;
    }
    else if (i == N - 1) {
      cout << "Three" << endl;
    }
  }
}
    

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        long K = sc.nextLong(), A=sc.nextLong(), B=sc.nextLong();
        long ans = help(K,A,B);
        System.out.println(ans);
    }
    static long help(long K, long A, long B){
        if(A<=B) return A>=K?1:-1;
        if(A>=K) return 1;
        long dif = (A-B);
        long t = (K-A)/dif+((K-A)%dif==0?0:1);
        return 2*t+1;
    }
}


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

int main(){
 int a,b,f=0;
 char op;

 while(1){
 cin >> a >> op >> b;

 switch(op){
  case '+':
   cout << a + b << endl ;
   break;
  case '-':
   cout << a-b << endl;
   break;
  case '*':
   cout << a*b << endl;
   break;
  case '/':
   cout << a/b << endl;
   break;
  case '?':
   f = 1;
   break;
  default:
   break;
 }
  if(f==1)break;
 }

 return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
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; }
const int INF = 1000100100;

using Graph = vector<vector<ll>>;
Graph G;

vector<ll> memo(1e6 + 1, INF);
vector<bool> pressed(1e6 + 1, false);

ll min_cnt(ll from, ll cnt) {
    if(from == 1) {
        return cnt;
    }

    if(memo[from] != INF) {
        return memo[from];
    }

    if(G.at(from).empty() || pressed[from]) {
        memo[from] = -1;
    } else {
        pressed[from] = true;

        ll res = INF;
        REP(i, G.at(from).size()) {
            ll n_from = G[from][i];
            ll tmp = min_cnt(n_from, cnt + 1);
            if(tmp != -1) {
                res = min(res, tmp);
            }
        }

        if(res == INF) {
            memo[from] = -1;
        } else {
            memo[from] = res;
        }
    }

    if(memo[from] == -1) {
        pressed[from] = true;
    }

    return memo[from];
}

int main() {
    ll N;
    cin >> N;

    G.resize(N + 1);
    REP(i, N) {
        ll a;
        cin >> a;
        G.at(i).emplace_back(a - 1);
    }

    ll ans = min_cnt(0, 0);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 25864
#!/usr/bin/env python3
import sys, math
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans=count=0

n,t=map(int,input().split())
t-=1
AB=[list(map(int,input().split())) for i in range(n)]
AB.sort(key=lambda tup:tup[1])
dp = [[0]*(t+1) for i in range(n+1)]
prev = [[0]*(t+1) for i in range(n+1)]

for i in range(1, n+1):
    for j in range(0, t+1):
        if j < AB[i-1][0]:
            dp[i][j] = dp[i-1][j]
            prev[i][j] = j
            # prev[i][j] = j - AB[i-1][0]
        else:
            if dp[i-1][j] > dp[i-1][j-AB[i-1][0]]+AB[i-1][1]:
                dp[i][j] = dp[i-1][j]
                prev[i][j] = j
            else:
                dp[i][j] = dp[i-1][j-AB[i-1][0]]+AB[i-1][1]
                prev[i][j] = j - AB[i-1][0]
S=set()
cur=t
for i in range(n-1,-1,-1):
    if (prev[i+1][cur] == cur - AB[i][0]):
        S.add(i)
    cur=prev[i+1][cur]

tmp=0
for i in range(n):
    if i not in S:
        tmp=max(tmp,AB[i][1])
    


# int cur_w = W;
# for (int i=n-1; i >= 0; --i) {
#     // 選んでいた場合
#     if (prev_w[i+1][cur_w] == cur_w - weight[i]) {
#         cout << i << " th item (weight = " << weight[i] << ", value = " << value[i] << ")" << endl;}

#     // 復元テーブルをたどる
#     cur_w = prev_w[i+1][cur_w];

print(dp[n][t]+tmp)
# print(dp[n][t],tmp)
# print(S)
# for di in dp:
#     print(di)



Measured memory_bytes: 176264
use proconio::input;

fn main() {
    input! {
        n: usize,
    }

    let mut ans = 0;
    for i in 1..=n {
        if !(i % 3 == 0 || i % 5==0) {
            ans += i;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2096
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;

const ll MAX = 1000000;
const ll MOD = 1000000007;

ll fac[MAX];

// テーブルを作る前処理
/*
void COMinit() {
    fac[0] = fac[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
    }
}
*/

ll pow_kai(ll a,ll n){//aのn乗を計算します。
  ll x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a%MOD;
    }
    a = a*a%MOD;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    ll tmp=1;
    for(ll i=n;i>=n-k+1;i--) tmp = (tmp*i)%MOD;

    return (tmp * pow_kai(fac[k],MOD-2)) % MOD;
}



int main()
{
    double A,B,N,x;
    cin >> A >> B >>N;

    if(N<B){
        x=N;
    }else{
        x=B-1;
    }

    int R= x/B;

    double r=x/B-R;

    cout << floor(A*r) << endl;
    
 
    return 0;

}

Measured memory_bytes: 3752
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author rahdirigs
 */

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

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

const int mxN = 1e5 + 5;

class TaskG {
public:
	int N, M;
	vector<int> adj[mxN];
	ll dp[mxN];

	void solve(std::istream& in, std::ostream& out) {
		in >> N >> M;
		for (int i = 0; i < M; i++) {
			int u, v;
			in >> u >> v;
			u--, v--;
			adj[u].push_back(v);
		}
		ll ans = 0;
		memset(dp, -1, sizeof(dp));
		for (int i = 0; i < N; i++) {
			s_max(ans, rec(i));
		}
		out << ans;
	}

	ll rec(int u) {
		if (dp[u] != -1) {
			return dp[u];
		}
		ll ret = 0;
		for (int v : adj[u]) {
			s_max(ret, 1 + rec(v));
		}
		return dp[u] = ret;
	}
};


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	TaskG solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 11716
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

const ll m = 1e9+7;
ll sm[1000000];

ll mod_pow(ll x, ll a) {
	ll u = x, an = 1;
	while(a > 0) {
		if (a&1) an = an * u % m;
		u = u * u % m; a >>= 1;
	}
	return an;
}
ll ncr(ll n, ll r) {
  return sm[n] * mod_pow(sm[n-r], m-2) % m * mod_pow(sm[r], m-2) % m;
}

int main(){
  sm[0] = sm[1] = 1;
  for(int i=2; i<1e6; i++) sm[i] = sm[i-1] * i % m;
  
  int x, y; cin >> x >> y; ll nm1=0, nm2=0, an=0;
  while(x >= 0) {
    if (x==y*2) {
      nm2 = y;
      an = (an + ncr(nm1+nm2, nm2))%m;
    }
    x-=1; y-=2; nm1++;
  }
  cout << an << endl;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n; cin >> n;
    string s; cin >> s;
    int counter = 0;
    FOR(i,1,n-1) {
        if (s[i] == 'E') counter++;
    }
    int res = counter;
    FOR(i,1,n-1) {
        if (s[i-1] == 'W') counter++;
        if (s[i] == 'E') counter--;
        res = min(res,counter);
    }
    cout << res << endl;
}

Measured memory_bytes: 900
// #pragma GCC optimize("O3")
#include <iostream>

using namespace std;

using ll = long long;

const ll MOD = 1e9 + 7;
const int MAX = 1e6;

constexpr inline ll powm(ll a, ll n = MOD - 2) {
    ll res = 1;
    for (; n; (a *= a) %= MOD, n >>= 1) {
        if (n & 1) {
            (res *= a) %= MOD;
        }
    }
    return res;
}

ll ft[MAX + 1], fti[MAX + 1];

void cf() {
    ft[0] = fti[0] = 1;
    for (int i = 1; i <= MAX; i++) {
        ft[i] = (i * ft[i - 1]) % MOD;
    }
    fti[MAX] = powm(ft[MAX]);
    for (int i = MAX - 1; i; i--) {
        fti[i] = ((i + 1) * fti[i + 1]) % MOD;
    }
}

inline ll nCr(const ll n, const ll r) {
    if (n == r) return 1;
    if (n < r) return 0;
    ll res = (ft[n] * fti[n - r]) % MOD;
    (res *= fti[r]) %= MOD;
    return res;
}


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

    cf();
    
    int n, k;
    cin >> n >> k;
    n -= k;
    for (int i = 1; i <= k; i++) {
        ll res = 0;
        for (int y = i - 1; y <= n; y++) {
            (res += ((n - y + 1) * nCr(y - 1, i - 2)) % MOD) %= MOD;
        }
        res *= nCr(k - 1, i - 1);
        cout << (res % MOD) << '\n';
    }

}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ll n,i,sum=0,s;
	cin>>n;
	ll a[n];
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	vector<ll> vi;
	for(i=0;i<n;i++){
		s=a[i]-i-1;
		vi.push_back(s);
	}
	sort(vi.begin(),vi.end());
	if(vi.size()%2!=0){
		s=vi[vi.size()/2];
	//	cout<<s<<endl;
		for(i=0;i<vi.size();i++){
			sum+=abs(s-vi[i]);
		}
		cout<<sum;
	}
	else{
		s=(vi[(vi.size()/2)-1]+vi[(vi.size()/2)])/2;
	//	cout<<s<<endl;
		for(i=0;i<vi.size();i++){
			sum+=abs(s-vi[i]);
		}
		cout<<sum;
	}
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;

using namespace std;

int main(){
    string s;
    cin >> s;
    vector<char> vec;
    rep(i,s.length()) vec.push_back(s[i]);
    int a_cnt=0;
    int z_cnt =0;
    rep(i,s.length()) {
        if (vec[i]=='A') {
            a_cnt = i;
            break;
        }
    }
    rep(i,s.length()) {
        if (vec[i]=='Z') z_cnt = i;
    }
    cout << z_cnt -a_cnt + 1 << endl;
}   

Measured memory_bytes: 772
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){
  bool ok=false;
  int N , M,ans=0;
  cin>>N;
  int i=0;
  int ansl=1;
  int ansll=0;
  vector<int> A(N);
  for(i;i<N;i++) cin>>A[i];
  int j=0;
   for(j;j<N;j++){
     if(A[j]==ansl){ansl++;ans=true;}
     else ansll++;
   }
  if(ans) cout<<ansll<<endl;
     else cout<<-1<<endl;
}

Measured memory_bytes: 1024
use proconio::{fastout, input};
use proconio::marker::Chars;

#[fastout]
fn main() {
    input! {
        s: Chars,
        t: Chars,
    }

    let n = s.len();
    let m = t.len();
    let mut ans = std::i64::MAX;

    for i in 0..n-m+1 {
        let mut cnt = 0;
        for j in 0..m {
            if s[i + j] != t[j] {
                cnt += 1;
            }
        }
        if cnt < ans {
            ans = cnt;
        }
    }

    println!("{}", ans);
}


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

int main() {
	long long H,N;
	cin>>H>>N;
	vector<int> A(N,0);
	for(int i=0; i<N; i++){
		long long a; cin>>a;
		A[i]=a;
	}
	sort(A.begin(),A.end());
	int flag=-1,sum=0;
	for(int i=N-1; i>=0; i--){
		sum+=A[i];
		if(sum>=H) break;
		if(i==0) flag=1;
	}
	
	if(flag==1) cout<<"No"<<endl;
	else        cout<<"Yes"<<endl;
}
	
	
	
	

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

using namespace std;

/**
 *  Name: Chris M. Perez
 *  University: Interamerican University Metro Campus
 *
**/

#define endl '\n'
#define MOD 10e18
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define gcd(x , y) __gcd(x , y)
#define all(x) (x).begin() , (x).end()
#define forn(i , a , b) for(int i=(a);i<(b);i++)
#define forrange(j , a , b) for(int j=(a);j<=(b);j++)
#define nestedforn(i , a , b , j , c , d) for(int i=(a);i<=(b);i++) for(int j=(c);j<=(d);j++)
#define sort_all(x) sort(all(x))
#define zeros_at_beginning(x) __builtin_clz(x)
#define zeros_at_end(x) __builtin_ctz(x)
#define ones(x) __builtin_popcount(x)
#define parity_even_or_odd_ones __builtin_parity(x)

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef tuple<int , int , int> tiii;
typedef vector<pii> vpii;
typedef vector<tiii> vtiii;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long long ll;
typedef long long int lli;


//template< typename T1, typename T2 > struct pair {
  //T1 first;
  //T2 second;
//};
               
inline int input(){
  int n;
  scanf("%d" , &n);
  return n;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;

#ifdef LOCAL_DEFINE
  freopen("input.txt" , "rt" , stdin);
#endif

  int n; cin >> n;
  int k; cin >> k;
  int h[100000];
  forn(i , 0 , n) cin >> h[i];
  sort(h , h + n);
  int x = (int) 10e9;
  forrange(i , 0 , n - k) x = min(x , h[i + k - 1] - h[i]);
  cout << x << endl;  
 
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif  
  return 0;
}

Measured memory_bytes: 640
N, M, Q = map(int, input().split())

G = [[0]*(N+1) for _ in range(N+1)]

for _ in range(M):
  L, R = map(int, input().split())
  G[L][R] += 1

for i in range(N+1):
  for j in range(1, N+1):
    G[i][j] += G[i][j-1]

for _ in range(Q):
  p, q = map(int, input().split())
  ans = 0
  for i in range(p, q+1):
    ans += G[i][q]
  print(ans)

Measured memory_bytes: 76964
import           Control.Monad
import           Text.Printf

getLines :: Int -> IO [String]
getLines n = replicateM n getLine

getLinesInt :: Int -> IO [Int]
getLinesInt n = fmap read <$> getLines n

getInts :: IO [Int]
getInts = map (read :: String -> Int) . words <$> getLine

getDoubles :: IO [Double]
getDoubles = map (read :: String -> Double) . words <$> getLine

splitOn :: (Char -> Bool) -> String -> [String]
splitOn p s = case dropWhile p s of
    "" -> []
    s' -> w : splitOn p s'' where (w, s'') = break p s'

toInt :: [String] -> [Int]
toInt = map ((read :: String -> Int) . dropZero)

dropZero :: String -> String
dropZero s = if head s == '0' then drop 1 s else s

main :: IO ()
main = do
    k <- getLine
    putStrLn $ let r = foldl (\t c -> t + if c == 'o' then 1 else 0) 0 k in
        if r + 15 - length k >= 8
            then "YES"
            else "NO"


Measured memory_bytes: 380
B[]={' bh','!%~','!d9','"zX'};char*F=" %d %d %d\n\0pre-meiji\0 taisho\0showa\0 heisei";y,m,d,e;main(){for(;~scanf(F,&y,&m,&d);e?printf(F,y-B[e-1]/1136+1,m,d,printf(F+e*7+8)):puts(F+11))for(e=0;e<4&&y*1136+m*32+d>=B[e];e++);}

Measured memory_bytes: 0
#![allow(non_snake_case)]
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let a:i32 = sc.read();
    let b:i32 = sc.read();
    let mut ans:i32 = -1;

    if (1 <= a) && ( a <= 9) && (1 <= b) && ( b <= 9){
        ans = a*b;
    }
    println!("{}", ans);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
        .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}




Measured memory_bytes: 4352
s = list(map(int, list(input())))

def check(s, ans):
    cnt = 0
    for i, v in enumerate(s):
        if v == ans[i]:
            cnt += 1
    return cnt

ans01 = ([0, 1] * (len(s) // 2 + 1))[:len(s)]
ans10 = ([1, 0] * (len(s) // 2 + 1))[:len(s)]
print(min(check(s, ans01), check(s, ans10)))



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

int N, maks, X;
int a[100100];
int freq[100100];

int main() {
    cin>>N;
    for(int i=1; i<=N; i++) {
        cin>>a[i];
        freq[a[i]]++;
    } for(int i=0; i<=100000; i++) {
        if(freq[i]+freq[i+1]+freq[i+2]>maks) {
            maks = freq[i]+freq[i+1]+freq[i+2];
            X=i+1;
        }
    }
    cout<<maks<<endl;
}


Measured memory_bytes: 4348
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))

x=sorted(x)
y=sorted(y)

if x[-1] < y[0] and X < y[0] and x[-1] < Y:
  print("No War")
else:
  print("War")
  
  

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num1 = sc.nextInt();
        int num2 = sc.nextInt();
        int tap = 0;
        int outlet = 1;

        while (num2 > outlet) {
               outlet += num1 - 1;

               tap++;
        }
        System.out.println(tap);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
int main(){
	int num;
	double wei,hig;
	char x;
	while(cin>>num>>x>>wei>>x>>hig){
		if(wei/(hig*hig)>=25) cout<<num<<endl;
	}
}

Measured memory_bytes: 1232
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC push_options
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>
#include <xmmintrin.h>
#include <immintrin.h>
using namespace::std;
__attribute__((constructor))void init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// typedef mp::number<mp::cpp_dec_float<0>> cdouble;
// typedef mp::cpp_int cint;
template<typename T>using pbds=__gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T>using pbds_map=__gnu_pbds::tree<T,T,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T,typename E>using hash_map=__gnu_pbds::gp_hash_table<T,E>;
template<typename T>using pqueue =__gnu_pbds::priority_queue<T, greater<T>,__gnu_pbds::rc_binomial_heap_tag>;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF (9223372036854775807LL)
#define EPS (1e-10)
#define endl ('\n')
//#define MOD 1000000007LL
#define MOD 998244353LL
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(lint i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(lint i=0;i<t.size();i++)output(t[i]);}
#define rep(i,n) for(lint i=0;i<lint(n);++i)
#define repi(i,a,b) for(lint i=lint(a);i<(lint)(b);++i)
#define rrep(i,n) for(lint i=lint(n)-1;i>=0;--i)
#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)
#define irep(i) for(lint i=0;;++i)
#define all(n) begin(n),end(n)
#define dist(a,b,c,d) sqrt(pow(a-c,2)+pow(b-d,2))
inline lint gcd(lint A,lint B){return B?gcd(B,A%B):A;}
inline lint lcm(lint A,lint B){return A/gcd(A,B)*B;}
// inline cint cgcd(cint A,cint B){return B?cgcd(B,A%B):A;}
// inline cint clcm(cint A,cint B){return A/cgcd(A,B)*B;}
bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
const vector<lint> dx={1,0,-1,0,1,1,-1,-1};
const vector<lint> dy={0,1,0,-1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
auto call=[](auto f,auto... args){return f(f,args...);};

int main(){
    string s;
    cin>>s;
    cout<<min(count(all(s),'0'),count(all(s),'1'))*2<<endl;
}

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

int main() {
	const int n = 13;
	const int m = 4;
	char mark[4] = {'S', 'H', 'C', 'D'};
	
	int q;
	cin >> q;
	bool card[m][n] = {{}};
	while (q--) {
		char c;
		int num;
		cin >> c >> num;
		for (int i = 0; i < 4; i++) {
			if (mark[i] == c) {
				card[i][num - 1] = true;
			}
		}
	}
	
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < n; j++) {
			if (not card[i][j]) {
				cout << mark[i] << ' ' << j + 1 << endl;
			}
		}
	}
	
	return 0;
}


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

int main(){
    long long int n,k;
    cin>>n>>k;
    long long int sum = 0;
    for(int i=k;i<=n+1;i++){
        sum = sum + i*(n-i+1) + 1;
    }
    cout<<sum%(10*10*10*10*10*10*10*10*10+7)<<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const ll MOD=1e9+7;
#define endl '\n'
#define F first
#define S second
const double PI = 3.141592653589793238460;

  void c_p_c()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
    #endif
}

void solve()
{
  ll n;cin>>n;
  if(n<1000)
    cout<<1000-n<<endl;
  else if(n==1000)
    cout<<"0"<<endl;
  else{

  if(n%1000==0)
  {
    cout<<abs(n-1000*(n/1000))<<endl;
  }
  else
    cout<<abs(n-1000*((n/1000)+1))<<endl;
}


}

int main()
{
   
 c_p_c();

 int t=1;
 while(t--)
 {
  solve();
  
 }

  return 0;
}

Measured memory_bytes: 3648
import numpy as np

line_len = int(input())
num_list = []
num_list = input().rstrip().split(' ')
np_num_list = np.array(num_list).astype(int)
div = [2]*line_len
np_div = np.array(div)
counter = 0
flag = False
while True:
    for i in range(line_len):
        if np_num_list[i]%2 != 0:
            flag = True
    if flag:
        print(counter)
        break
    np_num_list =  np_num_list/np_div
    counter = counter + 1

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> m(h, vector<int>(w, 1));
    int a, b;
    cin >> a >> b;
    for (int i = 0; i < a; i++){
        for (int j = 0; j < w; j++){
            m.at(i).at(j) = 0;
        }
    }
    for (int i = 0; i < b; i++){
        for (int j = 0; j < h; j++){
            m.at(j).at(i) = 0;
        }
    }
    
    int count = 0;
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            if (m.at(i).at(j) == 1){
                count++;
            }
        }
    }
    cout << count << endl;
    
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<cstring>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<iterator>
#include<algorithm>
#include<bitset>

#define Filein(N) freopen("N", "r", stdin)
#define Fileout(N) freopen("N", "w", stdout)
#define sci(x) scanf("%d", &x)
#define sci2(x,y) scanf("%d%d", &x,&y)
#define scll2(x,y) scanf("%lld%lld",&x,&y)
#define scll(x) scanf("%lld",&x)
#define scd(x) scanf("%lf", &x)
#define scstr(x) scanf("%s", x)
#define pfi(x) printf("%d", x)
#define pfll(x) printf("%lld", x)
#define pfd(x) printf("%f", x)
#define pfstr(x) printf("%s", x)
#define ps printf(" ")
#define pn printf("\n")
#define pfdt printf("..")

#define For(var,start,end) for(int var=start; var<=end;var++)
#define rFor(var,start,end) for(int var=start; var>=end; var--)
#define TestCase int testcase, cs=1; cin>>testcase;while(testcase--)
#define Trav(var,container) for(auto var:container)

#define mkp make_pair
#define pb push_back
#define fi first
#define se second

#define px(x) cout<<"X -> "<<x<<endl;
#define py(x) cout<<"Y = "<<x<<endl;
#define pz(x) cout<<"Z >> "<<x<<endl;
#define pstr(x) printf("%s\n",x);

using namespace std;
using ll = long long;
using vi = vector <int>;
using mpii = map<int,int>;
using mpll = map<ll,ll>;
using si = set<int>;
using sll = set<ll>;
using sll = set<ll>;
using vll= vector<ll>;

#define INF 1000000000
#define LINF 4000000000000000000
#define pi  (2*acos(0))
#define Mod 1000000007

 int main(){
 int ac = 0,wa=0,tle=0,re=0;
 char str[10];
 TestCase{
  scstr(str);
  if(str[0]=='A') ac++;
   if(str[0]=='T') tle++;
    if(str[0]=='W') wa++;
     if(str[0]=='R') re++;
 }

cout<<"AC x "<<ac<<endl;
cout<<"WA x "<<wa<<endl;
cout<<"TLE x "<<tle<<endl;
cout<<"RE x "<<re<<endl;



    return 0;
}







Measured memory_bytes: 3760