akhauriyash/Code-Regression huggingface dataset:
/*
    author: kartik8800
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(a,b) for(ll i = a; i < b; i++)
#define mod 1000000007
#define inf (1LL<<60)
#define all(x) (x).begin(), (x).end()
#define prDouble(x) cout << fixed << setprecision(10) << x 
#define triplet pair<ll,pair<ll,ll>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

struct line
{
    ll slope;
    ll intercept;
    line(ll m, ll k)
    {
        slope = m;
        intercept = k;
    }
    ll valAtX0(ll x0)
    {
        return slope*x0 + intercept;
    }
    ll x_intersect(line& l2)
    {
        return ceil(1.0*(l2.intercept - intercept)/(slope - l2.slope));
    }
};

class CHT
{
    deque<pair<line,ll>> dq;
    public:
        void insert(line l)
        {
            if(dq.empty())
            {
                dq.push_back({l, 0});
                return;
            }
            while(!dq.empty())
            {
                ll x0 = l.x_intersect(dq.back().first);
                if(x0 <= dq.back().second)
                    dq.pop_back();
                else break;
            }
            ll x0 = l.x_intersect(dq.back().first);
            dq.push_back({l, x0});
        }

        ll query(ll x0)
        {
            while(dq.size() > 1)
            {
                if(dq[1].second <= x0)
                    dq.pop_front();
                else break;
            }
            return dq[0].first.valAtX0(x0);
        }
};

ll solve(vector<ll>& v, ll n, ll c)
{
    vector<ll> dp(n);
    CHT minimaDS;
    dp[0] = 0; 
    minimaDS.insert({-2*v[0], v[0]*v[0]});

    for(int i = 1; i < n; i++)
    {
        dp[i] = v[i]*v[i] + c + minimaDS.query(v[i]);
        minimaDS.insert({-2*v[i], dp[i] + v[i]*v[i]});
    }

    return dp[n-1];
}

int main() {
   ll n,c;
   cin >> n >> c;
   vector<ll> v(n);
   for(int i =0; i < n; i++)
        cin >> v[i];
   cout << solve(v, n, c);
   return 0;
}


Measured memory_bytes: 6656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line[] = br.readLine().split(" ");
			int a = Integer.parseInt(line[0]);
			int b = Integer.parseInt(line[1]);
			if(a==0){break;}

			int road[][] = new int[a+1][b+1];
			road[1][1] = 1;

			int n = Integer.parseInt(br.readLine());
			for(int i=0; i<n; i++){
				String cons[] = br.readLine().split(" ");
				road[Integer.parseInt(cons[0])][Integer.parseInt(cons[1])] = -1;
			}

			for(int i=1; i<=a; i++){
				for(int j=1; j<=b; j++){
					if(road[i][j]!=-1 && i*j!=1){
						road[i][j] = Math.max(0,road[i-1][j]) + Math.max(0, road[i][j-1]) ;
					}
				}
			}

			System.out.println(road[a][b]);
		}
	}
}

Measured memory_bytes: 24212
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

void solve() {

	ll N;
	cin >> N;
	double d = 0;

	rep(i, N) {
		double tmp;
		cin >> tmp;
		d += (1.0 / tmp);
	}

	cout << setprecision(15) << 1.0 / d;

}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	cout << endl;
	return 0;
}


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

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

    int ans = 0, cnt = 0;
    for (int i = 0; i < s.length(); i++) {
        if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') cnt++;
        else cnt = 0;
        ans = max(ans, cnt);
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 3592
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int Cin()
{
    int n;
    cin >> n;
    return n;
}

int main()
{
    int A = Cin(), B = Cin();
    if (A > B)
    {
        int hoge = A;
        A = B;
        B = hoge;
    }
    if (A == 1 && B == 2) cout << 3 << endl;
    else if (A == 1 && B == 3) cout << 2 << endl;
    else cout << 1 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int c = sc.nextInt();

		int rc[][] = new int[r+1][c+1];


		for(int i=0; i<r; i++) {
			for(int j=0; j<c; j++) {
				rc[i][j] = sc.nextInt();
				rc[i][c] += rc[i][j];
				rc[r][c] += rc[i][j];
			}
		}

		for(int i=0; i<c; i++) {
			for(int j=0; j<r; j++) {
				rc[r][i] += rc[j][i];
			}
		}


		for(int i=0; i<r+1; i++) {
			for(int j=0; j<c+1; j++) {
				if(j != 0) System.out.print(" ");
				System.out.print(rc[i][j]);
			}
			System.out.println();
		}
	}

}



Measured memory_bytes: 42028
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = Math.min(a, b);
        for (int i = 0 ; i < Math.max(a, b) ; i++) {
            System.out.print(Math.min(a, b));
        }
    }

}


Measured memory_bytes: 21712
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int X,A,B;
    cin >> X >> A >> B;
    if(A >= B){
        cout << "delicious" << endl;
    }
    else {
        if((B-A) <= X){
            cout << "safe" << endl;
        }
        else cout << "dangerous" << endl;
    }
}

Measured memory_bytes: 3616
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main(){
  int x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  
  int x3,y3,x4,y4,d;
  
  x3=x2+y1-y2;
  y3=y2+x2-x1;
  x4=x3+x1-x2;
  y4=y3+y1-y2;
  cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
  
  return 0;
}

Measured memory_bytes: 3636
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().replace(/W/g, "0").replace(/B/g, "1").replace(/R/g, "2").split("\n");
var nm = arr.shift().split(" ").map(Number);
var n = nm[0];
var m = nm[1];
var wbr = arr.map(function(v) {
   var color = [m, m, m];
   for (var i = 0; i < m; i++) color[v[i]]--;
   return color;
});
var min = 2500;
for (var i = 0; i < n ; i++) {
   for (var j = 0; j < n ; j++) {
      var flag  = [0,0,0];
      var cost = 0;
      var a = 0;
      while(a<i){
         flag[0] = 1;
         cost += wbr[a][0];
         a++;
      }
      while(a<j){
         flag[1] = 1;
         cost += wbr[a][1];
         a++;
      }
      while(a<n){
         flag[2] = 1;
         cost += wbr[a][2];
         a++;
      }
      if (flag[0] + flag[1] + flag[2] == 3)min = Math.min(cost,min);
   }
}
console.log(min);

Measured memory_bytes: 17044
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x,h,w) (y) < 0 || (h) <= (y) || (x) < 0 || (w) <= (x)
#define line cout << "------------------------\n" 
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int n, m;
    vector<VI> g;
    VI dis;
    queue<int> bfs;
    while (cin >> n >> m && n) {
        g.clear();
        g.resize(n);
        FOR(i, 0, m) {
            int a, b; cin >> a >> b;
            --a, --b;
            g[a].push_back(b);
            g[b].push_back(a);
        }
        dis.clear();
        dis.resize(n, INF);
        dis[0] = 0;
        bfs.push(0);
        while (!bfs.empty()) {
            int now = bfs.front(); bfs.pop();
            for (int to : g[now]) {
                if (chmin(dis[to], dis[now] + 1)) {
                    bfs.push(to);
                }
            }
        }
        int ans = -1;
        FOR(i, 0, n)if (dis[i] <= 2)++ans;
        cout << ans << "\n";
    }
}



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

int main() {

  int n;
  cin >> n;

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

  for (int i = n - 1; 0 <= i; i--) {
    cout << a[i];
    if (i != 0) {
      cout << " ";
    }
  }
  cout << endl;

  return 0;

}


Measured memory_bytes: 3088
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <random>
#include <algorithm>
using namespace std;
int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */
    int l,r,d,count=0;
    cin>>l>>r>>d;
    for(int i=l;i<=r;i++){
        if(i%d==0) count++;
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 3620
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] W = new int[M];
		boolean[] floors = new boolean[N + 1];
		Arrays.fill(floors, true);
		for(int i = 0; i < M; i++) {
			W[i] = sc.nextInt();
			floors[W[i]] = false;
		}
		sc.close();
		
		long mod = (long) 1e9 + 7;
		long[] dp = new long[N + 1]; 
		dp[0] = 1;
		int brokenSteps = 0;
		long answer = 0;
		
		for (int now = 0; now < N; now++) {
            if (floors[now + 1]) {
                dp[now + 1] += dp[now];
                dp[now + 1] %= mod;
            }
            if (now == N - 1) {
                break;
            }
            if (floors[now + 2]) {
                dp[now + 2] += dp[now];
                dp[now + 2] %= mod;
            }
        }
        System.out.println(dp[N]);
	}
}


Measured memory_bytes: 50280
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

template <ll mod> class ModInt {
    ll a;
public:
    constexpr ModInt(const ll a = 0) noexcept : a((a % mod + mod) % mod) {}
    constexpr ll &value() noexcept { return a; }
    constexpr ModInt operator + (const ModInt &rhs) const noexcept { return ModInt(*this) += rhs; }
    constexpr ModInt operator - (const ModInt &rhs) const noexcept { return ModInt(*this) -= rhs; }
    constexpr ModInt operator * (const ModInt &rhs) const noexcept { return ModInt(*this) *= rhs; }
    constexpr ModInt operator / (const ModInt &rhs) const noexcept { return ModInt(*this) /= rhs; }
    constexpr ModInt &operator += (const ModInt &rhs) noexcept {
        a += rhs.a;
        if (a >= mod) a -= mod;
        return *this;
    }
    constexpr ModInt &operator -= (const ModInt &rhs) noexcept {
        a += mod - rhs.a;
        if (a >= mod) a -= mod;
        return *this;
    }
    constexpr ModInt &operator *= (const ModInt &rhs) noexcept {
        a = a * rhs.a % mod;
        return *this;
    }
    constexpr ModInt pow(ll t) const noexcept {
        if (t == 0) return 1;
        auto ret = pow(t >> 1);
        ret *= ret;
        if (t & 1) ret *= *this;
        return ret;
    }
    constexpr ModInt inv() const noexcept { return pow(mod - 2); }
    constexpr ModInt operator /=(const ModInt &rhs) { return (*this) *= rhs.inv(); }
    constexpr bool operator == (const ModInt &rhs) const noexcept { return this->a == rhs.a; }
    constexpr bool operator != (const ModInt &rhs) const noexcept { return this->a != rhs.a; }
    friend constexpr ostream &operator << (ostream &os, const ModInt &rhs) noexcept { return os << rhs.a; }
    friend constexpr istream &operator >> (istream &is, ModInt &rhs) {
        is >> rhs.a;
        return is;
    }
};
using mint = ModInt<MOD>;

class Combination {
public:
    vector <mint> fac, inv, fiv;
    Combination(int N) : fac(N + 1), inv(N + 1), fiv(N + 1) {
        fac[0] = inv[0] = fiv[0] = fac[1] = inv[1] = fiv[1] = 1;
        for (ll i = 2; i <= N; i++) {
            fac[i] = fac[i - 1] * i; // n!
            inv[i] = inv[MOD % i] * (MOD - MOD / i); // n^-1
            fiv[i] = fiv[i - 1] * inv[i]; // (n!)^-1
        }
    }
    mint C(ll n, ll k) {
        if (k < 0 || n < k) return 0;
        return fac[n] * fiv[k] * fiv[n - k];
    }
    mint P(ll n, ll k) {
        if (k < 0 || n < k) return 0;
        return fac[n] * fiv[n - k];
    }
    mint H(ll n, ll k) {
        if (n == 0 && k == 0) return 1;
        return C(n + k - 1, k - 1);
    }
};

int main() {
    ll n, k;
    cin >> n >> k;
    Combination com(1005);
    cout << com.C(n - 1, k - 1) << endl;
    return 0;
}


Measured memory_bytes: 3136
from functools import reduce
from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))

r = reduce(lambda x,y : x^y , A[2:],0)

a,b = A[:2]

def answer(ta,tb,tr):
    for i in range(ta):
        if (ta-i)^(tb+i) == tr:
            ans = i
            break
    else:
        ans = -1
    return ans

def solve(a,b,r):
    orga = a

    ans = 0
    l = max(map(lambda x : len(bin(x)), [a,b,r])) - 2
    cand = {(a,b,r):0}
    for i in range(l):
        temp = defaultdict(lambda : 10**20)
        for (a,b,r),s in cand.items():
            x,y,z = a%2,b%2,r%2
            if not x^y == z:
                continue
            else:
                if s < temp[(a//2,b//2,r//2)]:
                    temp[(a//2,b//2,r//2)] = s
                a -= 1
                b += 1
                if a < 0:
                    continue
                s += (1<<i)
                if s < temp[(a//2,b//2,r//2)]:
                    temp[(a//2,b//2,r//2)] = s
        cand = temp

    if not (0,0,0) in cand:
        ans = -1
    else:
        ans = cand[(0,0,0)]
        if ans == orga:
            ans = -1
    return ans

print(solve(a,b,r))


Measured memory_bytes: 67936
#include<iostream>

using namespace std;

int main() {
	int InputS;
	int h, m, s;

	cin >> InputS;

	s = InputS % 60;
	m = InputS % 3600 / 60;
	h = InputS / 3600;

	cout << h << ":" << m << ":" << s << endl;

	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N = 0,i;

  string S,T;
  
  cin >> S >> T;
  for(i=0;i<3;i++){
      if(S[i] == T[i] )
        N++;
  }

  cout << N << endl;
  

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int A[100],i,j,v,N; 
  scanf("%d",&N);
  for(i=0 ; i<N ; i++)  scanf("%d",&A[i]);
  for(i=0 ; i<N-1 ; i++)  printf("%d ",A[i]);
  printf("%d",A[N-1]);
   printf("\n");
   
  for(i=1 ; i<=N-1 ; i++){
    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
      
    }
    A[j+1] = v;
       
    for(j=0 ; j<N-1 ; j++) printf("%d ",A[j]);
    printf("%d",A[N-1]);
    printf("\n");
    
  }

  
return 0;
}
  
  



Measured memory_bytes: 2144
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
using namespace std; 
int main()
{
	string a; cin>>a;
	int ma = -1,sum = 0;
	for(int i=0;i<a.size();i++){
		if(a[i]=='A'||a[i]=='T'||a[i]=='C'||a[i]=='G'){
			sum++;
		}else {
			if(sum>ma){
				ma = sum;
			}
			sum = 0;
		}
	}
	if(sum>ma){
		ma = sum;
	}
	cout<<ma<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#define rep(i,a,b) for(int i=(a);i<b;i++)
#define INF 1000000000
using namespace std;
bool debug=false;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(b-a==c-b)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))
b = [0]*N
bina = 0
M = 0
for i in reversed(range(1,N+1)):
    next_num = i+i
    while(next_num <= N):
        bina ^= b[next_num-1]
        next_num += i
    b[i-1] = bina^a[i-1]
    bina = 0
M = sum(b)
print(M)
for i in range(N):
    if(b[i] == 1):
        print(i+1)

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

int main()
{
	string A, B;

	cin >> A >> B;

	if (A == B) {
		cout << "EQUAL" << endl;
	}
	else {
		if (A.size() != B.size())
		{
			cout << ((A.size() > B.size()) ? "GREATER" : "LESS") << endl;
		}
		else {
			int i = 0;
			while (true)
			{
				if (i == A.size())
				{
					cout << "EQUAL" << endl;
					break;
				}
				if (A[i] == B[i])
				{
					i++;
				}
				else {
					cout << (((int)A[i] > (int)B[i]) ? "GREATER" : "LESS") << endl;
					break;
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func min(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func max(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func maxs(xs []int) int {
	var ans int
	for _, x := range xs {
		if ans < x {
			ans = x
		}
	}
	return ans
}

func abs(x int) int {
	if x < 0 {
		return -x
	} else {
		return x
	}
}

func main() {
	var n int
	fmt.Scanf("%d", &n)

	a := make([]int, n)
	b := make([]int, n)
	c := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d %d %d", &a[i], &b[i], &c[i])
	}

	dp := make([][]int, n)
	for i := 0; i < n; i++ {
		dp[i] = make([]int, 3)
	}
	dp[0] = []int{a[0], b[0], c[0]}

	for i := 1; i < n; i++ {
		// aを選んだ場合
		dp[i][0] = max(dp[i][0], dp[i-1][1]+a[i]) // 1つ前でbを選んだ場合
		dp[i][0] = max(dp[i][0], dp[i-1][2]+a[i]) // 1つ前でcを選んだ場合
		// bを選んだ場合
		dp[i][1] = max(dp[i][1], dp[i-1][0]+b[i]) // 1つ前でaを選んだ場合
		dp[i][1] = max(dp[i][1], dp[i-1][2]+b[i]) // 1つ前でcを選んだ場合
		// cを選んだ場合
		dp[i][2] = max(dp[i][2], dp[i-1][0]+c[i]) // 1つ前でaを選んだ場合
		dp[i][2] = max(dp[i][2], dp[i-1][1]+c[i]) // 1つ前でbを選んだ場合
	}

	fmt.Println(maxs(dp[len(dp)-1]))
}


Measured memory_bytes: 11172
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n; cin >> n;
  vector<ll> count(n+1,1);
  for(int i = 2; i <= n; ++i){
    int t = i;
    while(t <= n){
      ++count[t];
      t+= i;
    }
  }
  ll s = 0;
  for(ll i = 1; i <= n; ++i){
    s += i*count[i];
  }
  cout<<s;
}


Measured memory_bytes: 81344
def read():
    N, X, Y = list(map(int, input().split()))
    return N, X, Y

def solve(N, X, Y):
    INF = N + N
    X -= 1
    Y -= 1
    e = [[INF for j in range(N)] for i in range(N)]
    for i in range(N-1):
        e[i][i+1] = 1
        e[i+1][i] = 1
    e[X][Y] = 1
    e[Y][X] = 1

    c = [0 for i in range(N)]

    for i in range(N):
        for j in range(i+1, N):
            if j <= X or Y <= i:
                e[i][j] = j - i
            else:
                e[i][j] = min(abs(j-i), abs(X-i) + 1 + abs(Y-j))
    
    for i in range(N):
        for j in range(i+1, N):
            if e[i][j] < INF:
                c[e[i][j]] += 1

    for i in range(1, N):
        print(c[i])

if __name__ == '__main__':
    inputs = read()
    solve(*inputs)


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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  string ans = "No";
  if (n%2 != 0) {
    cout << ans << endl;
    return 0;
  }
  rep(i,n/2) {
    if (s[i] != s[n/2 + i]) {
      cout << ans << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n, m, k;
    cin >> n >> m >> k;

    constexpr auto M = 998244353L;

    // (m-1)^l
    vector m1p(n + 1, 1L);
    for (auto i : irange(1L, n + 1)) {
        m1p[i] = m1p[i - 1] * (m - 1) % M;
    }

    vector fact(1L << 20, 1L), inv_fact(1L << 20, 1L), inv(1L << 20, 1L);
    for (auto i : irange(2L, 1L << 20)) {
        fact[i] = fact[i - 1] * i % M;
        inv[i] = M - inv[M % i] * (M / i) % M;
        inv_fact[i] = inv_fact[i - 1] * inv[i] % M;
    }

    int64_t ans = 0;
    for (auto l : irange(0L, k + 1)) {
        auto nn = n - l;

        auto t = m * m1p[nn - 1] % M;
        auto tt = fact[nn - 1 + l] * inv_fact[nn - 1] % M * inv_fact[l] % M;

        ans += t * tt % M;
        // cerr << t << "," << tt << endl;
        ans %= M;
    }

    cout << ans << endl;
}

Measured memory_bytes: 29292
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define inf 1000000000000000000
#define ff first
#define ss second
void checkpoint1()
{
	/******think more code less******/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif*/
}
bool comp(const pair< pair<ll,ll>,ll > &a,const pair< pair<ll,ll>,ll > &b)
{
	if(a.ff.ff!=b.ff.ff)
		return a.ff.ff<b.ff.ff;
	if(a.ff.ss!=b.ff.ss)
		return b.ff.ss<a.ff.ss;
	else
		return a.ss>b.ss;
}
int main()
{
	checkpoint1();
	ll l,r;
	cin>>l>>r;
	ll d;cin>>d;
	ll ans=0;
	for(ll i=l;i<=r;i++)
	{
		if(i%d==0)
			ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3620
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [0]*(10**6+1)
    for a in A:
        B[a] += 1

    for a in set(A):
        v = 2*a
        while v <= 10**6:
            B[v] += 1
            v += a

    ans = 0
    for a in A:
        if B[a] == 1:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39796
#include<iostream>
#include<algorithm>

using namespace std;

string Card;
int pk[10] = {0};
int N;
int field;

int main(){
	while(1){
		int cnt = 0;
		cin >> N;
		if(N == 0)break;
		cin >> Card;
		while(cnt < 100){
			for(int j=0;j<N;j++,cnt++){
				if(cnt >= 100)break;
				if(Card[cnt] == 'M'){
					pk[j]++;
				}
				else if(Card[cnt] == 'S'){
					field += (1 + pk[j]);
					pk[j] = 0;
				}
				else {
					pk[j] += field + 1;
					field = 0;
				}
			}
		}
		sort(pk,pk+N);
		for(int i=0;i<N;i++){
			cout << pk[i] << " ";
			pk[i] = 0;
		}	
		cout << field << endl;
		Card = '\0';
		field = 0;
	}
	return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
const double EPS = 1e-8;
#define Scan(a) int a;scanf("%d", &a);
#define ScanS(a) char a[500];scanf("%s", a);
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
class Graph {
public:
	int vn;
	int sumcost = 0;
	vector<vector<pii>> g;

	Graph(int n) {
		vn = n;
		g.resize(n);
	}
	virtual void con(int a, int b, int w) = 0;
	int getWeight(int f, int t) {
		auto itr = lower_bound(ALL(g[f]), make_pair(t, INT_MIN));
		if (itr != g[f].end())
			return itr->second;
		return INT_MIN;
	}
	int Costsum() {
		return sumcost;
	}
	void scan(int edcount, bool oindexed, bool w) {
		REP(i, edcount) {
			int a, b, c = 1;
			scanf("%d %d", &a, &b);
			if (w)scanf("%d", &c);
			con(a - oindexed, b - oindexed, c);
		}
	}
};
class BiDGraph : public Graph {//無向
public:
	BiDGraph(int n) : Graph(n) {}

	void con(int a, int b, int w = 1) {
		g[a].push_back({ b,w });
		g[b].push_back({ a, w });
		sumcost++;
	}
};


struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) { //ｘの入ってる集合と yの入ってる集合を併合
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) { //xとyが同じ集合に入っているかどうかを判定
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	bool isroot(int x) {
		return data[x] < 0;
	}
	int size(int x) {
		return -data[root(x)];
	}
};

signed main() {
	int n;
	cin >> n;
	int num[100001] = {};
	REP(i, n) {
		int a;
		scanf("%d", &a);
		num[a]++;
	}

	int ans = 0;

	rep(i, 1, 100000){
		ans = max(ans, num[i-1] + num[i] + num[i + 1]);
	}

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int a, b;
	cin>>a>>b;
	if(a>b) swap(a, b);
	for(int i=0; i<b; i++) cout<<a;
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };
int expr(string& s, int& i);
int number(string& s, int& i){
	int val=0;
	do {
	val*=10;
	val += s[i] - '0';
	i++;
	} while ('0'<=s[i]&&s[i]<='9');
return val;
}
int factor(string& s, int& i){
	if (s[i] >= '0'&&s[i] <= '9')return number(s, i);

	i++;
	int val = expr(s, i);
	i++;
	return val;

}
int term(string& s, int& i){
	int val1 = factor(s, i);
	while (s[i] == '*' || s[i] == '/'){
		char c = s[i];
		i++;
		int val2 = factor(s, i);
		if (c == '*')
			val1 *= val2;
		else
			val1 /= val2;
	}
	return val1;

}
int expr(string& s, int& i){
	int val1 = term(s, i);
	while (s[i] == '+' || s[i] == '-'){
		char c = s[i];
		i++;
		int val2 = term(s, i);
		if (c == '+')
			val1 += val2;
		else
			val1 -= val2;
	}
	return val1;
}


int main() {
	int n;
	cin >> n;
	while (n--){
		string s;
		cin >> s;
		int i = 0;
		if (s[s.length()-1]=='=')
			s=s.substr(0,s.length()-1);
		cout << expr(s, i) << endl;
	}
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

// ax+by=gcd(a,b) 返り値はgcd(a,b)
ll extgcd(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
    return d;
}

ll modinv(ll a, ll m) {
    ll x, y;
    extgcd(a, m, x, y);
    ll u = x % m;
    if (u < 0) return u += m;
    return u;
}


ll prime[1000010];
const ll mod = 1000000007;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        ll p = a[i];
        for (int j = 2; j * j <= a[i]; ++j) {
            ll cnt = 0;
            while(p % j == 0){
                cnt++;
                p /= j;
            }
            prime[j] = max(prime[j], cnt);
        }
        if(p != 1) prime[p] = max(prime[p], 1LL);
    }

    ll lcm = 1;
    for (ll i = 1; i <= 1000000; ++i) {
        for (int j = 0; j < prime[i]; ++j) {
            lcm *= i;
            lcm %= mod;
        }
    }

    ll res = 0;
    for (int i = 0; i < n; ++i) {
        res += lcm * modinv(a[i], mod);
        res %= mod;
    }
    cout << res << endl;
}

Measured memory_bytes: 6656
package main
 
// ABC160C - Travelling Salesman around Lake (解説回答)
// https://atcoder.jp/contests/abc160/tasks/abc160_c
 
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
 
func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	K := nextInt(sc)
	N := nextInt(sc)
	A := make([]int, N)
	for i := range A {
		A[i] = nextInt(sc)
	}
	A = append(A, K+A[0])
	L := 0
	for i := 0; i < N; i++ {
		L = max(L, A[i+1]-A[i])
	}
	fmt.Println(K - L)
}
func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

char al[26]= "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
   int n,i=0;
   scanf("%d ", &n);
   char str[10004];
   for(int j=0;j<10004;j++){ str[j]='2';}
   scanf("%s",str);
   //printf("%d\n", ii);
  while(str[i+1]!='2'){
    printf("%c", str[i]+n<91?str[i]+n:str[i]+n-26);
    i++;
   }
  // printf("%c\n",al[25]);
	return 0;
 
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
void solve()
{
	ll n,a,b;
	cin>>n>>a>>b;
	ll ab=a+b;
	ll times=n/ab;
	ll rest=n%ab;
	ll blue=a*times;
	blue+=min(rest,a);
	cout<<blue<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
}


Measured memory_bytes: 256
f = list(map(int, input().split()))
a = list(map(int, input().split()))
b = 0
for i in range(4):
	t = a[0]
	a[0] = a[2]
	a[2] = a[5]
	a[5] = a[3]
	a[3] = t
	for j in range(4):
		t = a[1]
		a[1] = a[2]
		a[2] = a[4]
		a[4] = a[3]
		a[3] = t
		if a == f:
			b = 1
for i in range(4):
	t = a[0]
	a[0] = a[1]
	a[1] = a[5]
	a[5] = a[4]
	a[4] = t
	for j in range(4):
		t = a[1]
		a[1] = a[2]
		a[2] = a[4]
		a[4] = a[3]
		a[3] = t
		if a == f:
			b = 1
if b:
	print("Yes")
else:
	print("No")



Measured memory_bytes: 5608
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

int main(){
    int w,h,x,y;
    float area;
    int res=0;

    cin  >> w >> h >> x >> y;

    area = 0.5 * w * h;
    if(x*2==w && y*2 == h)res=1;

    cout << area << " " << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const ll INF = numeric_limits<ll>::max();
int main()
{
    string s, t; cin >> s >> t;
    ll n = 0;
    rep(i, s.size()){
        if (s[i] != t[i]) ++n; 
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll i,j,k,n,m;
void read(int &x){
	char c;x=0;int b=1;do{c=getchar();if(c==45)b=-1;}while(c>57||c<48);
	do x=x*10+c-48,c=getchar();while(c<=57&&c>=48);x*=b;
}
void read(ll &x){
	char c;x=0;int b=1;do{c=getchar();if(c==45)b=-1;}while(c>57||c<48);
	do x=x*10+c-48,c=getchar();while(c<=57&&c>=48);x*=b;
}
ll G[50];
void make(ll now){
	for(ll i=sqrt(now);i>=1;i--){
		while(now%i==0){
			ll g=i+now/i;
			cout<<g-2<<endl;
			exit(0);
		}
	}
}
int main() {
	cin>>n;
	make(n);
	//cerr << 1.0*clock()/CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int arr[2000005];
int main()
{
    int i,j,m,n,t,ans,tem;
    cin>>n>>m;
    for(i=1; i<=n; i++)
        cin>>arr[i];

    sort(arr+1,arr+n+1);
    ans=1000000007;
    for(i=m; i<=n; i++)
    {
        if((arr[i]-arr[i-m+1])<ans)
            ans=arr[i]-arr[i-m+1];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
  int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && b != c) cout << "Yes" << endl;
    else if(a == c && c != b) cout << "Yes" << endl;
    else if(b == c && b != a) cout<< "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
n,m = map(int,input().split())
f = [False for _ in range(n)]
a = [[] for _ in range(n)]
res = 0

def dfs(k):
    f[k] = True
    for g in a[k]:
        if not f[g]:
            dfs(g)

for _ in range(m):
    x,y,z = map(int,input().split())
    a[x-1].append(y-1)
    a[y-1].append(x-1)

for i in range(n):
    if not f[i]:
        res += 1
        dfs(i)
print(res)


Measured memory_bytes: 104680
var g=[1,2,4,8,16,32,64,128,256,512];
process.stdin.on("data",function(c){
	(c+"").trim().split("\n").some(function(n){
		var a=[],l=10;
		while(l--){
			(n>=g[l])&&(n-=g[l],a.unshift(g[l]));
		}
		console.log(a.join(" "));
	});
}).resume();

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


int main()
{
	long long int K;
	long long int A[114514];
	memset(A, 0, sizeof(A));
	cin >> K;
	for (long long int i = 0; i < K; i++) {
		cin >> A[i];
	}
	long long int min = 2;
	long long int max = 2;
	bool flag = false;
	for (long long int i = K - 1; i >= 0; i--) {
		long long int ind = min / A[i];
		if(min % A[i] != 0 && (ind + 1) * A[i] > max){
			flag = true;
			break;
		}
		if (min % A[i] == 0) {
			min = min;
			max = (max / A[i]) * A[i] + A[i] - 1;
		}
		else {
			min = (ind + 1) * A[i];
			max = (max / A[i])*A[i] + A[i] - 1;
		}
	}
	if (flag) cout << -1 << endl;
	else {
		cout << min << " " << max << endl;
	}
}



Measured memory_bytes: 1152
#include<iostream>
using namespace std;
int main()
{
    string N;
    cin >> N;
    int stk = 0;
    char temp;
    for(int i=0; i < 4; ++i){
      if(i==0){
        temp = N[i];
        stk = 1;
      }else{
        if(temp == N[i]){
          stk += 1;
        }else{
          if(stk == 3){
            break;
          }else{
            stk = 1;
          }
        }
        temp = N[i];
      }
    }
    cout << (stk >= 3 ? "Yes" : "No") << endl;

    return 0;
}


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

int main(){
    string s[3];
    cin>>s[0] >>s[1] >>s[2];
    int turn = 0;
    while(1){
        if(s[turn].empty()){
            char ans = 'A' + turn;
          	cout<<ans<<endl;
            return 0;
        }
        int tmp = s[turn][0]-'a';
        s[turn].erase(s[turn].begin());
        turn = tmp;
    }
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using ld=long double;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

template<typename T> bool chmin(T &a,const T b){if(a>b){a=b; return true;}return false;}
template<typename T> bool chmax(T &a,const T b){if(a<b){a=b; return true;}return false;}


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

    int ans=INF, cnt=0;
    int num=0;
    for(int i=0; i<(int)s.size(); i++){
        if(s[i]-'0' != num) cnt++;
        num^=1;
    }
    chmin(ans, cnt);
    cnt=0, num=1;
    for(int i=0; i<(int)s.size(); i++){
        if(s[i]-'0' != num) cnt++;
        num^=1;
    }
    chmin(ans, cnt);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3760
from collections import defaultdict
from heapq import heappush, heappop


N, M = map(int, input().split())

jobs = defaultdict(list)
for _ in range(N):
    A, B = map(int, input().split())
    jobs[A].append(-B)

available_jobs = []
total_pay = 0
for day in range(1, M + 1):
    for pay in jobs[day]:
        heappush(available_jobs, pay)
    if available_jobs:
        total_pay -= heappop(available_jobs)
print(total_pay)


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

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

    int count=0;

    for(int i=0; i<N-1; i++){
        if( p[i]!=i+1 ){
            count++;
        }
    }

    if(count<=2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

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

#define pi 2*acos(0.00)
#define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl '\n'
#define null '\0'

using namespace std;

int main()
{
    fastio;

    ll n,i,sum=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        if(i%3!=0&&i%5!=0)
        sum+=i;
    }    
    cout<<sum;
}

Measured memory_bytes: 3648
MOD = 10**9 + 7
N,M = map(int,input().split(' '))
broken_list = set([int(input()) for i in range(M)])

ans = [0,1]

for n in range(1,N+1):
  if n in broken_list:
    ans.append(0)
  else:
    ans.append((ans[-2]+ans[-1]) % MOD)

print(ans[-1] % MOD)               

Measured memory_bytes: 13216
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char c0 = s.charAt(0), c1 = s.charAt(1),
             c2 = s.charAt(2), c3 = s.charAt(3);
        String ans = "No";
        if((c0 == c1 || c2 == c3) && (c1 == c2)) ans = "Yes";
        System.out.print(ans);
    }
}

Measured memory_bytes: 23380
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll lcm(ll a, ll b) {
  ll v0=a, v1=b, v2=v0%v1;
  while(v2>0) {
    v0 = v1;
    v1 = v2;
    v2 = v0%v1;
  }
  return v1;
}

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

int main() {
  ll N, M;
  cin>>N>>M;
  string S, T;
  cin>>S>>T;
  ll L = gcd(N, M);
  map<int, char> amap;
  map<int, int> bmap;
  for(int i=0;i<N;++i) {
    amap[L/N*i] = S[i];
    bmap[L/N*i]++;
  }
  bool can = true;
  for(int i=0;i<M;++i) {
    if(bmap[L/M*i]>0 && amap[L/M*i]!=T[i]) can = false;
  }
  if(can) cout<<L<<endl;
  else cout<<-1<<endl;
}



Measured memory_bytes: 14968
S = input()

import string
lst = list(string.ascii_lowercase)
d = {lst[i]:i for i in range(len(lst))}
cnt = [0]*len(lst)

for ch in S:
  cnt[d[ch]] = 1
  
idx = -1
for i in range(len(cnt)):
  if cnt[i] == 0:
    idx = i
    break

if idx == -1:
  print("None")
else:
  print(lst[idx])
    

Measured memory_bytes: 9780
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();

    if(k%2==0||k%5==0){
      System.out.println(-1);
      return;
    }

    if(k%7==0){
      k = k / 7;
     } 
    int loop = 1;
    int surp = 10 % (9 * k);
   

    while(surp != 1){
      loop++;
      surp = surp * 10 % (9 * k);
    }

    System.out.println(loop);
    return;
  }
}

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

#define ALL(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0, __##i##_length = (n); i < __##i##_length; i++)
#define rep_reverse(i, n) for (ll i = (n)-1; 0 <= i; i--)
#define FOR(i, from, to) for (ll i = (from), __##i##_end = (to); i < __##i##_end; i++)
#define FOR_REVERSE(i, from, to) for (ll i = (to)-1, __##i##_end = (from); __##i##_end <= i; i--)
#define foreach(e, v) for (const auto e : (v))
#define vfree(v) std::vector<int>().swap(v)
#define DEBUG(x) cout << #x << " = " << (x) << endl

using namespace std;
typedef int64_t ll;
typedef vector<ll> llv;
typedef vector<llv> llvv;

int main()
{
    ll N, X;
    cin >> N >> X;
    ll d = 0;
    rep(i, N)
    {
        if (X < d)
        {
            cout << i << endl;
            return 0;
        }

        ll L;
        cin >> L;
        d += L;
    }
    cout << N + (d <= X) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846
#define fi first
#define se second
 
ll mod = 1e9+7;
 
ll max(ll a, ll b ) {
	if(a>b)
		return a;
	else return b;
}
ll min(ll a, ll b ) {
	if(a<b)
		return a;
	else return b;
}
 
ll gcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = gcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}
ll inv(ll a) {
	ll x, y;
	ll g = gcd(a, mod, x, y);
	x = (x % mod + mod) % mod;
	return x;
}
ll binpow(ll a, ll b, ll m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a%m;
        a = a * a%m;
        b >>= 1;
    }
    return res;
}
vector<vector<char>> a;

/*
void dfs(int x, int y) {
	vector<pair<int,int>> arr = {{-1,0},{1,0},{0,-1},{0,1}};
	if(vis[x][y] == 1) return -1;
	//else if(vis[x][y] == 2) return ans;
	vis[x][y] = 1;
	int ct = 0;
	for(auto v : arr) {
		if(x+v.first>=0 && x+v.first<n && y+v.second>=0 && y+v.second<m) {
			/*if(a[x+v.first][y+v.second] == cc && vis[x+v.first][y+v.second] == 1 ) {
				//cout<<x+v.first<<" "<<y+v.se<<" "<<u<<"\n";
				return -1; 
			}
			else if(a[x+v.first][y+v.second] == cc) {
				ct++;
			}
		}
	}
}
*/
int main() {
	ll ttt;
	//cin>>ttt;
	ttt = 1;
	while(ttt--) {
		int n,m;
		cin>>n>>m;
		ll row[n+1],col[m+1];
		memset(row,0,sizeof(row));
		memset(col,0,sizeof(col));
		multiset<ll> cl;
		//set<pair<ll,ll>> st;
		ll z; cin>>z;
		vector<vector<ll>> cc(n+1);
		for(int i=0; i<z; i++) {int x,y; cin>>x>>y; row[x]++; cc[x].pb(y); col[y]++;}
		for(int i=1; i<=m; i++) cl.insert(col[i]);
		ll ans = 0;
		//for(auto it = cl.begin(); it!=cl.end(); it++) cout<<*it<<" ";
		for(int i=1; i<=n; i++) {
			ll temp = row[i];
			//cout<<temp<<" ";
			for(ll u : cc[i]) {
				int b = col[u];
				auto pos = cl.find(b);
				cl.erase(pos);
				cl.insert(b-1);
			}
			auto it = --cl.end();
			//cout<<*it<<" ";
			temp += *it;
			for(ll u : cc[i]) {
				int b = col[u];
				auto pos = cl.find(b-1);
				cl.erase(pos);
				cl.insert(b);
			}
			//cout<<i<<" ";
			ans = max(temp,ans);
		}
		cout<<ans;
 	}	
	return 0;
}


Measured memory_bytes: 38376
#include<iostream>

using namespace std;

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

    int l = 0;

    for(int i = 0;p[i];i++)
    {
        l += p[i]-'0';
        l = l%9;

    }
    if(l==0)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }

}


Measured memory_bytes: 3716
import itertools
N, M, Q = map(int, input().split())
a_b_c_d = [list(map(int, input().split())) for i in range(Q)]

M = [i for i in range(1, M+1)]
A_possible = list(itertools.combinations_with_replacement(M, N))

A_score = 0
for A in A_possible:
    A_sum = 0
    for i in range(Q):
        A_test = A[a_b_c_d[i][1]-1] - A[a_b_c_d[i][0]-1]
        if A_test == a_b_c_d[i][2]:
            A_sum += a_b_c_d[i][3]
    if A_score < A_sum:
        A_score = A_sum
print(A_score)

Measured memory_bytes: 21612
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
#include <math.h>
#include <iomanip>
#include <limits>
#include <functional>

using namespace std;
using ll = long long;
const ll res = 1000000007;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define PI 3.14159265358979323846264338327950L


int main(void) {
	long double a, b;
	cin >> a >> b;
	ll ans = ll(floorl(a*b));
	cout << ans << endl;
}

Measured memory_bytes: 3756