akhauriyash/Code-Regression huggingface dataset:
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

const int MAX_N = 400;
int H, W;
char table[MAX_N][MAX_N];
bool visited[MAX_N][MAX_N];

int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, 1, -1};

void dfs(int y, int x, P &counter) {
    visited[y][x] = true;
    if (table[y][x] == '.') counter.first++;
    else counter.second++;

    for (int i = 0; i < 4; i++) {
        int yy = y + dy[i];
        int xx = x + dx[i];
        if (yy < 0 || xx < 0 || yy >= H || xx >= W) continue;
        if (visited[yy][xx] || table[yy][xx] == table[y][x]) continue;
        dfs(yy, xx, counter);
    }
}

signed main() {
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        string line;
        cin >> line;
        for (int j = 0; j < W; j++) {
            table[i][j] = line[j];
        }
    }

    int cnt = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (visited[i][j]) continue;
            P counter = P(0, 0);
            dfs(i, j, counter);
            cnt += counter.first * counter.second;
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
 
using namespace std;
 
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
 
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).end()) i=(c).end(); i!=(c).begin(); --i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
 
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())
 
#define PB(a) push_back(a)
 
#define FS first
#define SE second
 
#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
//Greatest Common Devider
LL gcd(LL a,LL b){
  if(b == 0) return a;
  return gcd(b,a%b);
}
//------------------------------------------
//Least Common Multiple
//Must be used with GCD
LL lcm(LL a,LL b){
  LL g = gcd(a,b);
  return a / g * b;
}

struct UnionFind {
    vector<int> par; 
 
    UnionFind(int N) : par(N,-1) {} 
 
    int root(int x) { 
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
 
    int size(int x){
      return -par[root(x)];
    }

    bool unite(int x, int y) { 
        x = root(x); 
        y = root(y); 
        if (x == y) return false; 
        if(size(x) < size(y))  swap(x,y);
        par[x] += par[y];
        par[y] = x; 
        return true;
    }
    bool same(int x, int y) { 
        return root(x) == root(y);
    }
    
};
//grobal var
//------------------------------------------


 
int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------
  int N,M;
  while(cin >> N >> M ){
    UnionFind tree(N);
    REP(i,M){
      int x,y,z;
      cin >> x >> y >> z;
      x--;
      y--;
      tree.unite(x,y);
    }
    set<int> count;
    REP(i,N){
      count.insert(tree.root(i));
    }
     
    cout << count.size() << endl;
  }
  return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<math.h>
#include<algorithm>
#define PI 3.14159265358979323846264338327950L
using namespace std;

int main(){
    long double a,b,h,m;
    cin >> a >> b >> h >> m;
    /**/
    long double ans,dans,angle,cangle;
    /*角度*/
    angle = PI*abs(h/6.0 - (11.0*m)/360.0);
  
    cangle = cosl(angle);
    /**/
    dans = a*a + b*b - 2*a*b*cangle;
    
    ans = sqrtl(dans);
    printf("%20.20Lf\n", ans);
    return 0;
}


Measured memory_bytes: 4088
n, k = map(int, input().split())
mod = 10 ** 9 + 7
ans = 0
for i in range(k, n + 2):
    mn = (i - 1) * i // 2
    mx = (n + n - i + 1) * i // 2
    ans += mx - mn + 1
    ans %= mod
print(ans)


Measured memory_bytes: 63716
import sys
MAX_INT = int(10e9)
MIN_NUM = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

a,b = IL()

num = (b-a+1)//2
if a%2 != 0 and b%2 ==0:
  num -= 1
if num%2 == 0:
  c = 0
else:
  c = 1

if a%2 == 0:
  if b%2 == 0:
    print(b^c)
  else:
    print(c)
else:
  if b%2 == 0:
    print(a^b^c)
  else:
    print(a^c)

"""
10 14
10 13
9 14
9 13
"""

Measured memory_bytes: 38256
#include<iostream>
using namespace std;
int main()
{ 
int a,b,e,f,g,j,k,l,m,n;
cin >> a >> b;
e = (a%1000-a%100);
f = (a%10000-a%1000);
g = (a%100000-a%10000);
j = (b%1000-b%100);
k = (b%10000-b%1000);
l = (b%100000-b%10000);
if(g+f+e+f/100+g/10000-a >=0){m=(g+f+e)/100-100;}
else{m=(g+f+e)/100-99;}
if(b-(l+k+j+k/100+l/10000) <0){n=1000-(l+k+j)/100;}
else{n=999-(l+k+j)/100;}
printf ("%d",900-m-n);
}

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

using namespace std;

typedef long long LL;

LL l;
LL r;

int main()
{
	LL Ans = 0;
	int N;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> l >> r;
		Ans += ((r - l) + 1);
	}
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 256
X, N = map(int, input().split(' '))
if N == 0:
    print(X)
else:
    P_ls = list(map(int, input().split(' ')))
    diff = -1
    for i in range(101, -1, -1):
        if i not in P_ls:
            if diff == -1:
                diff = abs(X - i)
                rst = i
            else:
                diff = min(diff, abs(X - i))
                if diff == abs(X - i):
                    rst = i
    print(rst)

Measured memory_bytes: 9108
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

const M = 1e9 + 7

func (con *contest) main() error {
	var N int
	con.Scan(&N)
	A := make([]int, N)
	for i := 0; i < N; i++ {
		var a int
		con.Scan(&a)
		A[a]++
	}
	ok := true
	if N%2 == 0 {
		for i := 0; i < N; i++ {
			if i%2 == 0 {
				if A[i] != 0 {
					ok = false
				}
			} else {
				if A[i] != 2 {
					ok = false
				}
			}
		}
	} else {
		if A[0] != 1 {
			ok = false
		}
		for i := 1; i < N; i++ {
			if i%2 == 0 {
				if A[i] != 2 {
					ok = false
				}
			} else {
				if A[i] != 0 {
					ok = false
				}
			}
		}
	}
	a := 0
	if ok {
		a = 1
		for i := 0; i < N/2; i++ {
			a = a + a
			a = a % M
		}
	}
	con.Println(a)
	return nil
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

using P = pair<int, int>;

bool check(const map<P, int>& mp, const int x, const int y, ll h) {
  for (auto& p : mp) {
    if (max(0LL, h - abs(p.first.first - x) - abs(p.first.second - y)) != p.second) {
      return false;
    }
  }
  return true;
}

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

  int n;
  cin >> n;
  map<P, int> mp;
  ll high = 0;
  int hx, hy;
  rep(i, n) {
    int x, y;
    ll h;
    cin >> x >> y >> h;
    mp[{x, y}] = h;
    if (chmax(high, h)) {
      hx = x;
      hy = y;
    }
  }

  for (int i = 0; i <= 100; i++) {
    for (int j = 0; j <= 100; j++) {
      ll h = abs(i - hx) + abs(j - hy) + high;
      if (check(mp, i, j, h)) {
        cout << i << " " << j << " " << h << endl;
      }
    }
  }

  return 0;
}


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

using namespace std;
using ll=long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (n); i < (a); i++)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<(a-c)*(b-d)<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  cin >> s;
  int n=s.length();
  int win;
  for(int i=0;i<n;i++){
    win+=s[i]=='o'?1:0;
  }
  string ans=(win+15-n) >= 8 ? "YES" : "NO";
  cout << ans;
  return 0;
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a != 0 ? gcd (b % a, a) : b; }

const int N = 100000;

int n;
int m;
int p[N];
int q[N];
int pp[N];
int qq[N];
int e[N];
int h[N];
int g[N];

int main () {
	scanf ("%d%d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf ("%d", &p[i]);
		p[i]--; 
		pp[p[i]] = i;
	}
	for (int i = 0; i < n; i++) {
		scanf ("%d", &q[i]);
		q[i]--; 
		qq[q[i]] = i;
	}
	if (m == 1) {
		for (int i = 0; i < n; i++) e[i] = p[i];
	} else {
		for (int i = 0; i < n; i++) e[i] = i;

		for (int i = 0; i < n; i++) g[i] = q[pp[qq[p[i]]]];
		int k = (m + 1) / 6;
		while (k) {
			if (k & 1) {
				for (int i = 0; i < n; i++) h[i] = e[g[i]];
				for (int i = 0; i < n; i++) e[i] = h[i];
			}
			for (int i = 0; i < n; i++) h[i] = g[g[i]];
			for (int i = 0; i < n; i++) g[i] = h[i];
			k /= 2;
		}
//		for (int i = 0; i < n; i++) printf ("%d ", e[i] + 1);
//		printf ("\n");
/*  2: (-2, 1, 2, -1) x   0 |  2 | (1, -2, -1, 2) x   0
  3: (-2, 1, 2, -1) x   0 | -1  2 | (1, -2, -1, 2) x   0
  4: (-2, 1, 2, -1) x   0 | -2 -1  2 | (1, -2, -1, 2) x   0
  5: (-2, 1, 2, -1) x   0 | -2 | (1, -2, -1, 2) x   1
  6: (-2, 1, 2, -1) x   0 | -2  1 | (1, -2, -1, 2) x   1
  7: (-2, 1, 2, -1) x   0 | -2  1  2 | (1, -2, -1, 2) x   1*/

		if (m % 6 == 2) {
			for (int i = 0; i < n; i++) g[i] = q[i];
		} else
		if (m % 6 == 3) {
			for (int i = 0; i < n; i++) g[i] = q[pp[i]];
		} else
		if (m % 6 == 4) {
			for (int i = 0; i < n; i++) g[i] = q[pp[qq[i]]];
		} else
		if (m % 6 == 5) {
			for (int i = 0; i < n; i++) g[i] = qq[i];
		} else
		if (m % 6 == 0) {
			for (int i = 0; i < n; i++) g[i] = p[qq[i]];
		} else
		if (m % 6 == 1) {
			for (int i = 0; i < n; i++) g[i] = q[p[qq[i]]];
		}
		for (int i = 0; i < n; i++) h[i] = e[g[i]];
		for (int i = 0; i < n; i++) e[i] = h[i];
//		for (int i = 0; i < n; i++) printf ("%d ", e[i] + 1);
//		printf ("\n");
//		for (int i = 0; i < n; i++) printf ("%d %d\n", e[i] + 1, g[i] + 1);

		for (int i = 0; i < n; i++) g[i] = pp[q[p[qq[i]]]];
		k = (m - 2) / 6;
		while (k) {
			if (k & 1) {
				for (int i = 0; i < n; i++) h[i] = e[g[i]];
				for (int i = 0; i < n; i++) e[i] = h[i];
			}
			for (int i = 0; i < n; i++) h[i] = g[g[i]];
			for (int i = 0; i < n; i++) g[i] = h[i];
			k /= 2;
		}
	}
	for (int i = 0; i < n; i++) printf ("%d ", e[i] + 1);
	printf ("\n");
	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#define REP(i, n) for(long long i = 0; i < n; i++)
#define SHOWVEC(v, n) for(int _i = 0; _i < n; _i++) cerr << v[_i] << ' '; cerr << endl;

using namespace std;

int main()
{
  int K, X;
  cin >> K >> X;
  for (int i = X - (K-1); i <= X + (K-1); i++) cout << i << ' ';
  cout << endl;
  return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <set>

using namespace std ;

const int N=1e5+100 ;

int a[N] ;
char s[N] ;
int n , m , k ;

int main ()
{
    int i ;
    scanf("%d %d ",&n,&m);
    gets(s+1);
    for ( i=1 ; i<n ; i++ ) 
        if ( s[i]=='A' && s[i+1]=='C' ) a[i]++;
    for ( i=1 ; i<=n ; i++ ) a[i]+=a[i-1];
    while ( m-- )
    {
        int l , r ;
        scanf("%d%d",&l,&r);
        printf("%d\n",a[r-1]-a[l-1]);
    }
    return 0 ;
}

Measured memory_bytes: 1280
N=int(input())
ans=0
for i in range(N//2):
  s=0
  a=i+1
  b=N-i-1
  while a>0 or b>0:
    s+=a%10+b%10
    a=a//10
    b=b//10
  if ans==0 or ans>s:
    ans=s
print(ans)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

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

		for(int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}

		int q = sc.nextInt();

		for(int i = 0; i < q; i++) {
			int key = sc.nextInt();

			if(array[n-1] < key) System.out.println(n);  //クラスで弾いてもよいが...
			else {
				BinarySearch3 bi3 = new BinarySearch3();
				bi3.binarySearch3(array, key);
			}
		}
	}
}

//BinarySeachをLowerBoundを返すように改良したクラス
class BinarySearch3 {
	public void binarySearch3(int[] array, int key) {
		int pLeft = 0;
		int pRight = array.length - 1;
		int center;
		int temp = -1;

		do {
			center = (pLeft + pRight) / 2;
			if(center == temp) break;

			if (array[center] >= key) {  //key以上の数がarray[center]より前にある可能性がある
				pRight = center;
			} else {
				pLeft = center + 1;  //ここはok
			}
			temp = center;
		} while (pLeft <= pRight);

		System.out.println(center);
	}
}


Measured memory_bytes: 108376
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)

long int gcd(long long int a, long long int b) {
    if (a%b==0) {
        return(b);
    } else {
        return (long long int)(gcd(b, a%b));
    }
}

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


int main(){
    long long int A, B;
    cin >> A >> B;

    cout << lcm(A, B) << endl;

    return 0;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */


int main(void){
    int n, m, x;
    cin >> n >> m >> x;

    vector<int> c;
    vector< vector<int> > a(n);
    for(int i=0; i<n; i++){
        int tmp_c; cin >> tmp_c;
        c.push_back(tmp_c);
        for(int j=0; j<m; j++){
            int tmp_a; cin >> tmp_a;
            a[i].push_back(tmp_a);
        }
    }

    int ans = 1000000000;
    for(int bit=0; bit < (1<<12); bit++){
        vector<int> rikaido(m); 
        for(int i=0; i<m; i++) rikaido[i] = 0;
        int tmp_ans = 0;
        for(int i=0; i<n; i++){
            if(bit & (1 << i)){
                tmp_ans += c[i];
                for(int j=0; j<m; j++){
                    rikaido[j] += a[i][j];
                }
            }
        }
        // 購入後
        int flag = 0;
        for(int i=0; i<m; i++){
            if(rikaido[i] < x) flag = 1;
        }
        if(flag == 0) ans = min(ans, tmp_ans);
    }
    if(ans == 1000000000) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
import java.util.Scanner;

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

        String revNum = "";

        for (int i = num.length() - 1; i >= 0; i--) {
            revNum = revNum + num.charAt(i);
        }

        if(revNum.equals(num)){
            System.out.print("Yes");
        } else {
            System.out.print("No");
        }
    }
}


Measured memory_bytes: 23764
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<iomanip>
#include<sstream>
#include<cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
typedef long long int ll;
typedef long double ld;
const ll INF = 1LL << 60;
const int inf = (1 << 30);
const int MOD = 1000000007;
ll n,ans = 0, sum = 0, p;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
struct Corr {
    int x;
    int y;
    int depth;
};
queue<Corr> q;
ll bfs(vector<vector<char>> grid,int i,int j) {
    Corr sta = { j,i,0 };
    vector<vector<int>> ispassed(grid.size(), vector<int>(grid[0].size(), false));
    int dx[8] = { 1, 0, -1, 0 };
    int dy[8] = { 0, 1, 0, -1 };
    int sd = 0; q.push(sta);
    ispassed[i][j] = true;
    while (!q.empty()) {
        Corr now = q.front(); q.pop();
        sd = max(sd, now.depth);
        for (int k = 0; k < 4; k++) {
            int nextx = now.x + dx[k],nexty = now.y + dy[k];
            if (nextx >= grid[0].size() || nextx < 0) continue;
            if (nexty >= grid.size() || nexty < 0) continue;
            if (ispassed[nexty][nextx]) continue;
            if (grid[nexty][nextx] == '#') continue;
            ispassed[nexty][nextx] = true;
            Corr next = { nextx, nexty, now.depth + 1 };
            q.push(next);
        }
    }return sd;
}
int main() {
    int h, w; cin >> h >> w;
    vector<vector<char>> s(h, vector<char>(w));
    rep(i, h) {
        rep(j, w) {
            cin >> s[i][j];
        }
    }
    rep(i, h) {
        rep(j, w) {
            if (s[i][j] == '.') {
                ans = max(bfs(s, i, j), ans);
            }
        }
    }cout << ans << endl;
}

Measured memory_bytes: 256
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys

sys.setrecursionlimit(10**7)
mod = 10**9+7
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def counter_top(c,exclude):
    for a in c.most_common():
        if a[0]!=exclude:
            return a
    return (object(),0)

def conv_seq(seq,exclude = None):
    c = collections.Counter(seq)
    mc = counter_top(c,exclude)
    return sum(c.values()) - mc[1],mc[0]

N = I()
V = LI()

s1,a = conv_seq(V[::2])
s2,b = conv_seq(V[1::2])


if s1!=s2:
    print(s1+s2)
else:
    s1_new,_ = conv_seq(V[::2],exclude=b)
    s2_new,_ = conv_seq(V[1::2],exclude=a)
    print(min(s1_new+s2,s1+s2_new))


Measured memory_bytes: 18776
#include<bits/stdc++.h>
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main() {

    jaldi

    long long int n;
    cin>>n;
    long long int d;
    cin>>d;
    long long int x;
    long long int y;
    long long int ans =0;
    while(n--) {
        cin>>x;
        cin>>y;
            long long int dist = (x * x) + (y * y);
            long long int lim = d * d;
            if (dist <= lim) {
                ans++;
            }
        }

    cout<<ans<<'\n';
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <set>

using namespace std;

bool solve(int N, const vector<long long> &a)
{
	for (int k = 0; k < 40; ++k) {
		int z = 0;
		set<long long> p;
		for (int i = 0; i < N; ++i) {
			if (!(a[i] & (1LL << k))) {
				++z;
				p.insert(a[i] & ((1LL << k) - 1));
			}
		}
		if (z != N) {
			if (z * 3 != N) {
				return false;
			}
			if (p.size() != 1) {
				return false;
			}
		}
	}
	return true;
}

int main()
{
	int N;
	cin >> N;
	vector<long long> a(N);
	for (auto &x : a) {
		cin >> x;
	}

	if (solve(N, a)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  deque<ll> a, b, c;
  string q, w, e;std::cin >> q >> w >> e;
  re(i, q.size()) a.push_back(q[i]-'a');
  re(i, w.size()) b.push_back(w[i]-'a');
  re(i, e.size()) c.push_back(e[i]-'a');
  ll now = 0;
  while(true){
    if(now==0){
      if(a.size()==0){
        std::cout << "A" << '\n';
        return 0;
      }
      now = a.front();
      a.pop_front();
    }else if(now==1){
      if(b.size()==0){
        std::cout << "B" << '\n';
        return 0;
      }
      now = b.front();
      b.pop_front();
    }else{
      if(c.size()==0){
        std::cout << "C" << '\n';
        return 0;
      }
      now = c.front();
      c.pop_front();
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N, K;
    string S;
    cin >> N >> K >> S;
    
    vector<int> s;
    int cnt = 1;
    REP(i, N) {
        if (S[i - 1] == S[i]) {
            ++cnt;
        } else {
            s.push_back(cnt);
            cnt = 1;
        }
    }
    s.push_back(cnt);
    vector<int> v(s.size());
    if (S[0] == '0') {
        rep(i, v.size()) v[i] = !(i % 2);
    } else {
        rep(i, v.size()) v[i] = i % 2;
    }
    
    int right = 0;
    int k = 0;
    int sum = 0;
    int ans = 0;
    rep(left, s.size()) {
        while (right < s.size() && k + v[right] <= K) {
            sum += s[right];
            k += v[right];
            ++right;
        }
        ans = max(ans, sum);
        if (right == left) {
            ++right;
        } else {
            sum -= s[left];
            k -= v[left];
        }
    }
    cout << ans << endl;
    return 0;
}


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

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);
ll fact(ll n){
    if(n==0)return 1;
    else return n*fact(n-1)%MOD;
}
ll calc(ll n,ll k){
    if(k==0)return 1;
    ll m=n*n%MOD;
    if(k%2)return n*calc(m,k/2)%MOD;
    else return calc(m,k/2)%MOD;
}
ll comb(ll n,ll k){
    ll ret=fact(n);
    ret=ret*calc(fact(k),MOD-2)%MOD;
    ret=ret*calc(fact(n-k),MOD-2)%MOD;
    return ret;
}

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

    map<string,ll> m;

    rep(i,n){
        string ss;
        cin>>ss;
        sort(ss.begin(),ss.end());
        m[ss]++;
    }
    ll ans=0;


    for(auto &&a:m){
        if(a.second>=2){
            ll b=a.second;
           ans+=b*(b-1)/2ll;
        }

    }
    cout<<ans<<endl;



    return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var temp = ReadLine();
            var a = temp[0];
            var b = temp[1];
            var c = temp[2];
            var result = 0;

            while (a != b || b != c)
            {
                result++;

                if (b < a && c < a)
                {
                    b += 1;
                    c += 1;
                }
                else if (a < b && c < b)
                {
                    a += 1;
                    c += 1;
                }
                else if (a < c && b < c)
                {
                    a += 1;
                    b += 1;
                }
                else if (a < b && b == c)
                {
                    a += 2;
                }
                else if (b < a && a == c)
                {
                    b += 2;
                }
                else if (c < a && a == b)
                {
                    c += 2;
                }
            }

            Console.WriteLine(result);
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

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

typedef long long ll;

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt","r",stdin);
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a){
        cout<<k<<'\n';
    }else if(k<=(a+b)){
        cout<<a<<'\n';
    }else{
        k-=(a+b);
        cout<<(a-k)<<'\n';
    }
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define MOD 1000003
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int f[2000010];
int quick_pow(int x,int y){
	int out=1;
	int p=x%MOD;
	while(y){
		if(y&1)out=out*p%MOD;
		p=p*p%MOD;
		y>>=1;
	}
	return out;
}
signed main(){
	int T;
	cin>>T;
	f[0]=1;
	for(int i=1;i<=2000000;i++)f[i]=f[i-1]*i%MOD;
	while(T--){
		int x,d,n,ans=1;
		cin>>x>>d>>n;
		if(!d)ans=quick_pow(x,n);
		else if(n>MOD)ans=0;
		else{
			x=x*quick_pow(d,MOD-2)%MOD;
			ans=f[x+n-1]*quick_pow(f[x-1],MOD-2)%MOD*quick_pow(d,n)%MOD;
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 16512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApp14
{
    class Program
    {
        static void Main(string[] args)
        {
            var solver = new Solver();
            solver.Calc();
        }
    }

    public class Solver
    {


        bool IsPrime(int x)
        {
            for (var i = 2; i < x; i++)
            {
                if (x % i == 0)
                {
                    return false;
                }

            }

            return true;

        }

        public void Calc()
        {

            var X = int.Parse(Console.ReadLine());

            while (true)
            {
                if (IsPrime(X))
                {
                    Console.WriteLine(X);
                    return;
                }
                else
                {
                    X++;
                }

            }


        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

LL mod = 1000000007;

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

  LL x;
  cin >> x;
  cout << x * x * x << endl;
}



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

string s;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int ans=0;
    cin>>s;
    for(char &c:s)ans+=c-'9';
    cout<<(ans%9==0?"Yes":"No")<<endl;

    return 0;
}

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

int main() {
  long long n, m, k;
  cin >> n >> m >> k;
  long long a[n], b[m];
  long long dp_a[n+1], dp_b[m+1];
  dp_a[0] = 0; dp_b[0] = 0;
  for ( int i = 0; i < n; i++ ) { cin >> a[i]; dp_a[i+1] = a[i] + dp_a[i]; }
  for ( int i = 0; i < m; i++ ) { cin >> b[i]; dp_b[i+1] = b[i] + dp_b[i]; }

  long long mx_a = -1;
  long long mx_b = -1;
  for ( int i = 0; i <= n; i++ ) {
    if ( dp_a[i] > k ) { break; }
    mx_a = i;
  }
  for ( int i = 0; i <= m; i++ ) {
    if ( dp_b[i] > k ) { break; }
    mx_b = i;
  }

  int ans = 0;
  if ( dp_a[n]+dp_b[m] <= k ) { cout << mx_a + mx_b << endl; return 0; }
  if ( dp_a[1] > k && dp_b[1] > k ) { cout << 0 << endl; return 0; }

  int ia = mx_a;
  int ib = 0;
  for ( ; ia >= 0; ia-- ) {
    while ( ib < mx_b && dp_a[ia]+dp_b[ib+1] <= k ) { ib++; }
    if ( dp_a[ia]+dp_b[ib] <= k ) {
      ans = ( ia+ib > ans ) ? ia+ib : ans;
    }
  }

  cout << ans << endl;
  return 0;
}


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

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

    int res = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
            int length = 1;
            i++;
            while (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
                length++;
                i++;
            }
            res = max(res, length);
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define D(a) (double)(a)
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define vb vct<bool>
#define vs vector<string>
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define print(v) for(auto it:v)cout<<it<<' '; cout<<endl;
#define PI acos(-1.0)
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
#define rt return true
#define rf return false
///................function.....................///
#define siz(s) (int)(s.size())
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mod 1000000007
int main()
{
    FIO;
    string s;
    cin>>s;
    int r = count(all(s),'R');
    if(r==1||r==3||r==0)
        cout<<r<<endl;
    else
    {
        if((s[0]=='R'&&s[1]=='R')||(s[1]=='R'&&s[2]=='R'))
            cout<<2<<endl;
        else cout<<1<<endl;
    }
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,enable_if_t<iterable<T>::value,int> =0>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}
template<class T,enable_if_t<is_integral<T>::value,int> =0>T mod(T a, T b){if(a>0)return a%b;return b-(-a%b);}
template<class T,enable_if_t<is_floating_point<T>::value,int> =0>T mod(T a, T b){if(a>0)return a%b;return b-fmod(-a,b);}
bool solve(){
    int x;
    cin>>x;
    // 100-105
    // 200-210
    // 300-315
    // 1000-1050
    // 2000-2100
    // 2100-2205
    // ...
    if(x>=2000)return true;
    return x/100*5>=x%100;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    cout<<setprecision(10);
    cout<<solve();
}


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

public class Main{

	public static void main(String[] args) throws IOException {

		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		String Triangle_line = input.readLine();

		String[] Triangle_line_array = Triangle_line.split(" ");

		// ??????a
		double base_a = Double.parseDouble(Triangle_line_array[0]);

		// ???b
		double side_b = Double.parseDouble(Triangle_line_array[1]);

		// ?§????C
		int angle_C = Integer.parseInt(Triangle_line_array[2]);

		// ??¢??????????????????????§????C???????§???¢??°????±???????
		double trigonometric_function_sin = Math.sin(Math.toRadians(angle_C));

		// ????????????????????????
		double trigonometric_function_cos = Math.cos(Math.toRadians(angle_C));

		double area_S = base_a * side_b * trigonometric_function_sin / 2;

		// ????????????
		double side_c_square = base_a * base_a + side_b * side_b - 2 * base_a * side_b * trigonometric_function_cos;

		// ??????
		double side_c = Math.sqrt(side_c_square);

		// ????§???¢???????????????,??¨
		double three_sum_L = base_a + side_b + side_c;

		// ??????
		double height_h = 2 * area_S / base_a;



		System.out.println(area_S);



		System.out.println(three_sum_L);



		System.out.println(height_h);


	}

}

Measured memory_bytes: 24236
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	if s == "SUN" {
		fmt.Println(7)
	} else if s == "MON" {
		fmt.Println(6)
	} else if s == "TUE" {
		fmt.Println(5)
	} else if s == "WED" {
		fmt.Println(4)
	} else if s == "THU" {
		fmt.Println(3)
	} else if s == "FRI" {
		fmt.Println(2)
	} else if s == "SAT" {
		fmt.Println(1)
	}
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>
#include<iomanip>
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const ll INF = 1000000007;
double dp[110000];

int main() {
	int n, k;
	cin >> n >> k;
	vector<int>a(n);
	rep(i,n)cin >> a[i];
	dp[0] = 0;
	rep(i, k+1)rep(j, n) {
		if (i == 0)continue;
		if (i - a[j] >= 0 && dp[i - a[j]] == 0)dp[i] = 1;
	}
	if (dp[k])cout << "First";
	else cout << "Second";

	return 0;
}

Measured memory_bytes: 4412
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define lp(i,N) for(int i=0;i<N;i++)

int main(){
  ll H;
  cin>>H;
  if(H==1){
    cout<<1<<endl;
    return 0;
  }
  int L=-1;
  while(H!=1){
    L++;
    H/=2;
  }
  ll HI=3;
  lp(i,L){
    HI*=2;
    HI++;
  }
  cout<<HI<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
main(){
    int N[3];
    cin >> N[0] >> N[1] >> N[2];
    sort(N,N+3);
    if(N[0]+N[1]==N[2])cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
package main
 
import (
	"fmt"
)

func main() {
  var n, sum int
  fmt.Scan(&n)
  for i := 1; i <= n; i++ {
    if !(i % 3 == 0 || i % 5 == 0) {
      sum += i
    } 
  }

  fmt.Println(sum)
}


Measured memory_bytes: 1756
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  string s;
  ll k;
  cin >> s >> k;
  rep(i, k){
    if(s[i] != '1'){
      cout << s[i] << endl;
      return 0;
    }
  }
  cout << 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <cassert>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS * max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x * x + y * y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;

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

	vector <ll> a(N);
	vector <ll> b(N);
	vector <pair <ll, int> > c(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> a[i] >> b[i];

		c[i] = make_pair(a[i] + b[i], i);
	}
	sort(c.rbegin(), c.rend());

	ll ans = 0;

	ll sum_a = 0;
	ll sum_b = 0;
	for (int i = 0; i < N; ++i)
	{
		if (i%2==0)
		{
			sum_a += a[c[i].second];
		}
		else
		{
			sum_b += b[c[i].second];
		}
	}

	cout << sum_a - sum_b << endl;

	return 0;
}


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

int n, dist[2][100005];

vector<int> adj[100005], v, a, p1, p2;

void calc (int I, int C, int P) {
	for(auto &T : adj[C]) {
		if(T == P) continue;
		dist[I][T] = dist[I][C] + 1;
		calc(I, T, C);
	}
}

bool getp (int C, int P, int O) {
	if(C == O) {v.push_back(C); return true;}
	for(auto &T : adj[C]) {
		if(T == P) continue;
		if(getp(T, C, O)) {v.push_back(C); return true;}
	}
	return false;
}

void solve (vector<int> &A) {
	A.push_back(1);
	int S = 1;
	for(int i=0;i<(int)a.size();i++) {
		for(int j=1;j<=a[i];j++) A.push_back(S+j+1);
		A.push_back(S+1);
		S += a[i]+1;
	}
	A.push_back(n);
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++) {
		int A, B;
		scanf("%d%d",&A,&B);
		adj[A].push_back(B);
		adj[B].push_back(A);
	}
	int x = 0, y = 0;
	calc(0, 1, 0);
	for(int i=1;i<=n;i++) if(dist[0][i] > dist[0][x]) x=i;
	calc(1, x, 0);
	for(int i=1;i<=n;i++) if(dist[1][i] > dist[1][y]) y=i;
	getp(x, 0, y);
	int S = (int)v.size()-1;
	for(int i=1;i+1<(int)v.size();i++) {
		int T = (int)adj[v[i]].size()-2;
		a.push_back(T);
		S += T;
	}
	if(S != n-1) {puts("-1"); return 0;}
	solve(p1);
	reverse(a.begin(), a.end());
	solve(p2);
	bool F = false;
	for(int i=0;i<n;i++) {
		if(p1[i] > p2[i]) {F = true; break;}
		if(p1[i] < p2[i]) break;
	}
	if(F) swap(p1,p2);
	for(int i=0;i<n;i++) {
		printf("%d ",p1[i]);
	}
	puts("");
}


Measured memory_bytes: 16632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String sx = scanner.next(), sy = scanner.next();
		long x = Long.parseLong(sx), y = Long.parseLong(sy);
		
		long ans = 0;
		long min = x;
		
		
		while (true) {
			if (min>y) {
				break;
			}
			ans++;
			min *= 2;
		}
		
		System.out.println(ans);
		scanner.close();
	}
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication3
{
class Program
{
    static void Main(string[] args)
    {
          
        while (true)
        {
            string[] str = Console.ReadLine().Split(' ');
            int tate = int.Parse(str[0]);
            int yoko = int.Parse(str[1]);

            if ((tate == 0) && (yoko == 0))
            {
                break;
            }
            for (int i = 1; i <= tate; ++i)
            {
                if (i % 2 == 0)
                {
                    for (int j = 1; j <= yoko; ++j)
                    {
                        if (j % 2 == 0)
                        {
                            Console.Write("#");
                        }
                        else
                        {
                            Console.Write(".");
                        }
                    }
                }
                else
                {
                    for (int j = 1; j <= yoko; ++j)
                    {
                        if (j % 2 == 0)
                        {
                            Console.Write(".");
                        }
                        else
                        {
                            Console.Write("#");
                        }
                    }
                }
                    Console.WriteLine();
            }
                Console.WriteLine(); 
            } 
        }
    }
}

Measured memory_bytes: 5292
from math import factorial

def comb(n, r):
    if n < r:
        return 0
    return factorial(n) // (factorial(n-r) * factorial(r))

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

for i in range(1, K+1):
    print(comb(N-K+1, i) * comb(K-1, i-1) % (10**9+7))

Measured memory_bytes: 3444