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

using namespace std;

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

  int N; cin>>N;
  std::vector<std::pair<int, int>> datas[N];
  for (int i = 0; i < N; i++) {
    int A; cin>>A;
    auto& conds = datas[i];
    for (int j = 0; j < A; j++) {
      int x, y; cin>>x>>y;
      conds.emplace_back(x, y);
    }
  }
  int ans = 0;
  for (int m = 0; m < (1u<<N); m++) {
//    cerr<<m<<endl;
    auto check = [m](int i) -> bool {
      return ((unsigned int)m & (1u << i)) != 0;
    };
    bool skip = false;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
      if (not check(i))
        continue;
      cnt++;
      auto &conds = datas[i];
      for (int j = 0; j < conds.size(); j++) {
//        cerr << conds[j].first <<" "<< (bool)conds[j].second<<endl;
        if (check(conds[j].first-1) != (bool)conds[j].second){
          i = N;
          skip = true;
          break;
        }
      }
    }
    if (not skip)
      ans = max(ans, cnt);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import Data.Char
import Control.Monad
main = do
  n <- getLine
  if n == "-" then return ()
  else do
    m <- readLn :: IO Int
    h <- replicateM m $ (readLn :: IO Int)
    putStrLn $ foldl f n h
    main
    
f n h = take (length n) $ drop h $ cycle n


Measured memory_bytes: 4760
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include <algorithm> 
using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;



int main()
{
    int n;cin >> n;
    vector<int> v1(n);
    vector<int> v2(n);

    for(int i=0;i<n;i++){
        cin >> v1[i];
        v2[i] = v1[i];
    }
    sort(v1.begin(),v1.end());

    for(int i=0;i<n;i++){
        if(v1[n/2-1]<v2[i]) p(v1[n/2-1])
        else p(v1[n/2])
    }
} 

Measured memory_bytes: 3712
n, k = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

s = []
ord = Array.new(n + 1, -1)

c = 1
l = 0
v = 1

while ord[v] == -1
  ord[v] = s.size
  s << v
  v = as[v - 1]
end

c = s.size - ord[v]
l = ord[v]

if k < l
  puts s[k]
else
  puts s[l + ((k - l) % c)]
end


Measured memory_bytes: 30556
#include<stdio.h>

typedef struct
{
  int num;
  char mark;
} card;

void ScanCards();
void BubbleSort();
void SelectionSort();
void PrintSortedCards();
void JudgeStable();

int length;
int i, j;
card orig_n[36];
card sort_n[36];
card tmp;


int main()
{
  ScanCards();

  BubbleSort();

  PrintSortedCards();

  JudgeStable();

  SelectionSort();

  PrintSortedCards();

  JudgeStable();

  return 0;
}

void ScanCards()
{
  char c;

  scanf("%d", &length);
  for(i = 0; i < length; i++)
    {
      while(1)
	{
	  c = getchar();
	  if(c != ' ' && c != '\n') break;
	}
      orig_n[i].mark = c;
      scanf("%d", &orig_n[i].num);
      orig_n[i] = orig_n[i];
    }
  return;
}


void BubbleSort()
{
  int flag;

  for(i = 0; i < length; i++) sort_n[i] = orig_n[i];

  for(i = 0; i < length; i++)
    {
      flag = 0;
      for(j = length - 1; j > i; j--)
	{
	  if(sort_n[j - 1].num > sort_n[j].num) 
	    {
	      tmp = sort_n[j];
	      sort_n[j] = sort_n[j - 1];
	      sort_n[j - 1] = tmp;
	      flag = 1;
	    }
	}
      if(flag == 0) break;
    }
  return;
}


void SelectionSort()
{
  int min_i;

  for(i = 0; i < length; i++) sort_n[i] = orig_n[i];

  for(i = 0; i < length; i++)
    {
      min_i = i;
      for(j = i; j < length; j++)
	{
  	  if(sort_n[j].num < sort_n[min_i].num) min_i = j;
 	}
      tmp = sort_n[i];
      sort_n[i] = sort_n[min_i];
      sort_n[min_i] = tmp;
    }
  return;
}


void PrintSortedCards()
{
  for(i = 0; i < length - 1; i++)
    {
      printf("%c%d ", sort_n[i].mark, sort_n[i].num);
    }
  printf("%c%d\n", sort_n[length - 1].mark, sort_n[length - 1].num);
}


void JudgeStable()
{
  int s1,s2;
  int flag = 0;

  for(i = 0; i < length; i++)
    {
      if(sort_n[i].num == sort_n[i + 1].num)
	{
	  for(j = 0; j < length; j++)
	    {
	      if(sort_n[i].num == orig_n[j].num &&
                 sort_n[i].mark == orig_n[j].mark) s1 = j;
	      if(sort_n[i + 1].num == orig_n[j].num &&
                 sort_n[i + 1].mark == orig_n[j].mark) s2 = j;
	    }
	  if(s1 > s2) flag = 1;
	}
      if(flag == 1) break;
    }
  if(flag == 0) printf("Stable\n");
  else printf("Not stable\n");

  return;
}

Measured memory_bytes: 612
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define MAX 100

int main() {
  int n;
  int A[MAX];
  int count = 0;

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

  for (int i = 0; i < n - 1; i++) {
    int min_key = i;
    for (int j = i; j < n; j++) {
      if (A[j] < A[min_key]) min_key = j;
    }
    if (min_key != i) {
      int t = A[i]; A[i] = A[min_key]; A[min_key] = t;
      count++;
    }
  }

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


Measured memory_bytes: 3092
# include<bits/stdc++.h>
using namespace std;
const int maxn = 3e5+7;
typedef long long ll;
const ll mod = 1e9+7;
ll a[maxn];
ll p[64] = {1};
ll b[64] = {0};
int main(void){
    int n;
    for(int i = 1; i < 63; ++i){
         p[i] = (p[i-1]*2ll)%mod;
    }
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    ll ans = 0;
    for(int j = n-1; j >= 0; --j){
        ll x = a[j];
        for(int i = 0; i < 63; ++i){
            if((x&1) == 0) ans = (ans+(b[i]*p[i])%mod)%mod;
            else ans = (ans+((n-1-j-b[i])*p[i])%mod)%mod, b[i]++;
            x>>=1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int64_t GCD(int64_t a, int64_t b) {
	if (!b) return a;
	else return GCD(b, a % b);
}

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

	int64_t gcd = GCD(A, B);
	vector<pair<int64_t, int64_t>> v;

	int64_t rt = sqrt(gcd), n = gcd;
	for (int64_t i = 2; i <= rt; i++) {
		int64_t c = 0;
		while (n % i == 0) {
			if (n / i == 0) break;
			else {
				c++;
				n /= i;
			}
		}
		if (c) {
			pair<int64_t, int64_t> p = { i,c };
			v.push_back(p);
		}
	}
	if (n>1) {
		pair<int64_t, int64_t> p = { n,1 };
		v.push_back(p);
	}

	cout << v.size() + 1 << endl;
}

Measured memory_bytes: 3724
H,W=map(int,input().split())
N=int(input())
A=list(map(int,input().split()))
a=[[0]*W for i in range(H)]
r,c=0,0
x=1
for i in range(H*W):
    a[r][c]=x
    A[x-1]-=1
    if A[x-1]==0:
        x+=1
    if (r%2==0 and c==W-1 or r%2==1 and c==0) and r<H-1:
        r+=1
    elif r%2==0:
        c+=1
    else:
        c-=1
for l in a:
    print(' '.join(map(str,l)))

Measured memory_bytes: 3560
#include <stdio.h>
int main(void){
	int x[3000],y[3000];
	int w=0;
	while(1){
		scanf("%d %d",&x[w],&y[w]);
		if(x[w]==0 && y[w]==0)break;
		if(x[w]<y[w])printf("%d %d\n",x[w],y[w]);
		else printf("%d %d\n",y[w],x[w]);
		w++;
	}
	return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
const long double EPS = 1e-14;
const int maxn = 100500;
const int mod = 1e9 + 7;

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vector < int > a(n);
    for(auto &x : a) cin >> x;
    vector < int > v, st;
    for(int i = 0 ; i < n ; ++i){
        v.push_back(a[i]);
        if(a[i]){
            st.push_back(1);
            continue;
        }
        int j = i;
        while(j < n && !a[j]) ++j;
        st.push_back(j - i);
        i = j - 1;
    }
    int ans = 0;
    for(int i = 0 ; i < sz(v) ; ++i){
        int sm = v[i], xr = v[i];
        ans += st[i] * (st[i] + 1) / 2;
        for(int j = i + 1 ; j < min(sz(v), i + 500); ++j){
            sm += v[j];
            xr ^= v[j];
            ans += (sm == xr) * st[i] * st[j]; 
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 5220
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

 int ans = num % 10;

 if(ans == 3)
 {
   cout << "bon" << endl;
   return 0;
 }
 else if(ans == 0 || ans == 1 ||ans == 6 ||ans == 8 )
 {
   cout << "pon" << endl;
   return 0;
 }
 else
 {
   cout << "hon" << endl;
   return 0;
 }
}

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(c, b / a) << endl;
}


Measured memory_bytes: 256
d = int(input())
c = tuple(map(int, input().split()))
s = [
    tuple(map(int, input().split()))
    for _ in range(d)
]

m = 0
ans = []
last = [0] * 26
for i in range(d):
    # for all contest
    mdmax = -10000000000000000
    mdi = 0
    for j, ss in enumerate(s[i]):
        md = 0
        # choose one contest to open
        for k in range(26):
            if j == k:
                md += ss
            else:
                md -= (i + 1 - last[k]) * c[k]
        if md > mdmax:
            mdi = j
            mdmax = md

    ans.append(mdi + 1)
    m += mdmax

    last[mdi] = i + 1

for a in ans:
    print(a)

Measured memory_bytes: 9352
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}

ll count(ll n){
	ll cnt = 0;
	
	while(n){
		cnt++;
		n /= 10;
	}
	
	return cnt;
}

signed main(){
	
	ll n,ans = 0;
	cin >> n;
	rep(i,0,n){
		if(count(i+1) % 2) ans++;
	}
	cout << ans << endl;
	
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| min!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| max!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();

    let xs: Vec<usize> = (0..n).map(|_| sc.cin()).collect();

    if xs.iter().all(|&x| x == 0) {
        put!("Yes");
        return;
    }

    use std::collections::HashSet;
    let s: HashSet<usize> = xs.iter().map(|&x| x).collect();

    if n % 3 == 0 && s.len() == 3 {
        let a: Vec<usize> = s.iter().map(|&x| x).collect();
        let c0 = xs.iter().filter(|&x| *x == a[0]).count();
        let c1 = xs.iter().filter(|&x| *x == a[1]).count();
        let c2 = xs.iter().filter(|&x| *x == a[2]).count();
        if a[0] ^ a[1] ^ a[2] == 0 && c0 == c1 && c1 == c2 {
            put!("Yes");
            return;
        }
    }

    if n % 3 == 0 && s.len() == 2 {
        let mut a: Vec<usize> = s.iter().map(|&x| x).collect();
        a.sort();
        if a[0] == 0 {
            let c0 = xs.iter().filter(|&x| *x == a[0]).count();
            let c1 = xs.iter().filter(|&x| *x == a[1]).count();
            if n % 3 == 0 && c1 == c0 * 2 {
                put!("Yes");
                return;
            }
        }
    }

    put!("No")

}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 11508
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
//#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int N;
	cin >> N;
	vector<int>A(N);
	vector<vector<pair<int, int>>>p(N);
	rep(i, N)
	{
		cin >> A[i];
		rep(j, A[i])
		{
			int x, y;
			cin >> x >> y;
			p[i].push_back(make_pair(x, y));
		}
	}
	int ans = 0;
	vector<bool>v(N);
	for (int i = 0; i < (1 << N); i++)
	{
		bool judge = true;
		int num = 0;
		for (int j = 0; j < N; j++)
		{
			v[j] = (i >> j) & 1;
		}

		for (int j = 0; j < N; j++)
		{
			if (judge == false)break;
			if (v[j] == 1)
			{
				for (int k = 0; k < A[j]; k++)
				{
					if (v[p[j][k].first - 1] != p[j][k].second)
					{
						judge = false;
						break;
					}
				}
			}
		}
		if (judge == true)
		{
			rep(k, N)num += v[k];
			ans = max(ans, num);
		}
	}
	cout << ans;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  cin >> N;
  unordered_map<ll, int> count;
  ll a;
  REP(i, N) {
    cin >> a;
    if (count.find(a) == count.end()) {
      count.insert(make_pair(a, 1));
    } else {
      ++count.at(a);
    }
  }

  vector<ll> availables;
  for (const auto &it : count) {
    if (it.second >= 2) {
      availables.push_back(it.first);
    }
  }

  if (availables.size() < 2) {
    cout << 0 << endl;
    return 0;
  }

  sort(availables.begin(), availables.end(), greater<ll>());

  ll ans = 0;
  ll longest = availables.at(0);
  for (const ll &v : availables) {
    if (count.at(v) >= 4) {
      ans = max(ans, v * v);
    }
    if (v != longest) {
      ans = max(ans, longest * v);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4388
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

#define POS(i,j) ((i)*w+(j))

void run(void){
  int h,w;
  scanf("%d%d",&h,&w);
  char *board=(char *)malloc(sizeof(char)*(h*w+1));
  int i,j;
  for(i=0;i<h;i++){
    scanf("%s",board+POS(i,0));
  }
  int cnt=0;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(board[POS(i,j)]=='.') cnt++;
    }
  }
  int x[10001];
  int y[10001];
  int d[10001];
  x[0]=0;
  y[0]=0;
  d[0]=1;
  int ans=-1;
  int first=0;
  int last=1;
  while(first<last){
    int a=x[first];
    int b=y[first];
    int depth=d[first];
    first++;
    if((!(0<=a && a<h && 0<=b && b<w)) || board[POS(a,b)]=='#') continue;
    if(a==h-1 && b==w-1){
      ans=depth;
      break;
    }
    board[POS(a,b)]='#';
    int dx[]={1,0,-1,0};
    int dy[]={0,1,0,-1};
    for(i=0;i<4;i++){
      x[last]=a+dx[i];
      y[last]=b+dy[i];
      d[last]=depth+1;
      last++;
    }
  }
  if(ans!=-1){
    printf("%d\n",cnt-ans);
  } else {
    printf("-1\n");
  }
  return;
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int h, m, s;
		
		
		
		h = S / 3600;
		S = S % 3600;
		m = S / 60;
		s = S % 60;
		System.out.println(h + ":" + m + ":" + s);
	}
}

Measured memory_bytes: 26088
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
#include<iomanip>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef vector<string> vstring;
typedef vector<vector<string>> vvstring;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<long double> vdouble;
typedef vector<vector<long double>> vvdouble;
typedef vector<vector<vector<long double>>> vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define LLONG_MAX 9223372036854775807
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define DIVIDER 1000000007


//
// struct Node{
//   vint children;
//   ll index;
//   ll prop;
// };
// struct edge{ll to; ll cost;};



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

// ll X,Y,Z,K;
// ll pmax = 30000000000;
// vint A,B,C;




struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};




int main() {
  cout<<fixed<<setprecision(10);

  ll N;cin>>N;
  vpint x(N),y(N);
  rep(i,N){
    ll xx,yy;
    cin>>xx>>yy;
    x[i] = mp(xx, i);
    y[i] = mp(yy, i);
  }
  vsort(x); vsort(y);
  vector<tuple<ll,ll,ll>> stock(2*(N-1));
  rep(i,N-1){
    stock[i] = mt(x[i+1].fi-x[i].fi, x[i+1].se, x[i].se);
    stock[i+N-1] = mt(y[i+1].fi-y[i].fi, y[i+1].se, y[i].se);
  }
  vsort(stock);
  UnionFind tree(N);

  ll ans = 0;
  rep(i,2*(N-1)){
    ll cost, p1, p2;
    tie(cost, p1, p2) = stock[i];
    if(tree.same(p1,p2)) continue;
    tree.unite(p1,p2);
    ans += cost;
  }


  cout << ans << endl;
}

















//


Measured memory_bytes: 8448
N = int(input())
XL = [tuple(map(int,input().split())) for _ in range(N)]
#print(XL)
X = []
for x,l in XL:
  X.append((x-l,x+l))
X.sort(key=lambda x:x[1])
#print(X)
ans = 0
p = -(10**10)
for a,b in X:
  if p <= a:
    ans += 1
    p = b
print(ans)

Measured memory_bytes: 69720
#[allow(dead_code)]
fn main() {
    let n = i::u();
    let mut a = i::uv(n);

    let mut ans: usize = 0;
    for i in 0..n - 1 {
        if a[i] > 1 {
            ans += a[i] / 2;
            a[i] %= 2;
        }
        if a[i] == 1 && a[i + 1] > 1 {
            ans += 1;
            a[i + 1] -= 1;
        }
    }
    println!("{}", ans + a[n - 1] / 2);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 4352
//Binary Trees

#include<stdio.h>
#define N 10000
#define NILL -1

struct Node
{
  int parent,left,right;
};

struct Node tree[N];
int n,de[N],he[N];

void dep(int u,int d)
{
  if(u == NILL) return;

  de[u] = d;

  dep(tree[u].left, d + 1);
  dep(tree[u].right, d + 1);

}

int hei(int u)
{
  int h1 = 0, h2 = 0;

  if(tree[u].left != NILL) h1 = hei(tree[u].left)+1;
  if(tree[u].right != NILL) h2 = hei(tree[u].right)+1;

  if(h1 >= h2) return he[u] = h1;
  if(h2 > h1)return he[u] = h2;
}

int sibling(int u)
{
  if(tree[u].parent == NILL) return NILL;
  if(tree[tree[u].parent].left != u && tree[tree[u].parent].left != NILL)
    {
      return tree[tree[u].parent].left;
    }
  if(tree[tree[u].parent].right != u && tree[tree[u].parent].right != NILL)
    {
      return tree[tree[u].parent].right;
    }
  return NILL; 
}

void worktime(int u)
{
  int degree = 0;
  printf("node %d: ",u);
  printf("parent = %d, ",tree[u].parent);
  printf("sibling = %d, ",sibling(u));

  if(tree[u].left != NILL) degree++;
  if(tree[u].right != NILL) degree++;

  printf("degree = %d, ",degree);
  printf("depth = %d, ",de[u]);
  printf("height = %d, ",he[u]);

  if(tree[u].parent == NILL)
    {
      printf("root\n");
    }
  else if(tree[u].left == NILL && tree[u].right == NILL)
    {
      printf("leaf\n");
    }
  else{
    printf("internal node\n");
  }
  
}

int main()
{
  int a,b,c,i, root = 0;
  scanf("%d",&n);

  for(i = 0; i < n; i++)
    {
      tree[i].parent = NILL;
    }

  for(i = 0; i < n; i++)
    {
      scanf("%d %d %d",&a,&b,&c);
      tree[a].left = b;
      tree[a].right = c;
      if(b != NILL) tree[b].parent = a;
      if(c != NILL) tree[c].parent = a;
    }

  for(i = 0; i < n; i++)
    {
      if(tree[i].parent == NILL) root = i;
    }

  dep(root,0);
  hei(root);

  for(i = 0; i < n; i++) worktime(i);
    
  return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
using namespace std;
 
int main() {
    //input
    int n;cin >> n;
    int m;cin >> m;
    vector<int> x(m + 1,0);for(int i = 1; i < m + 1;i++) cin >> x[i];
    x[0] = -100000000;

    if(n >= m){
        cout << 0 << endl;
        return 0;
    }

    //compute
    vector<int> b(m,0);
    b[0] = 100000000;
    long sum = 0;

    sort(x.begin(),x.end());
  
    for(int i = 1; i < m;i++){
        b[i] = x[i + 1] - x[i];
        sum += b[i];
    }
    
    sort(b.rbegin(),b.rend());

    for(int i = 1; i < n;i++){
        sum -= b[i];
    }

    //output
    cout << sum << endl;
}

Measured memory_bytes: 3868
open Printf
open Scanf

let (++) = Int64.add
let (--) = Int64.sub
let ( ** ) = Int64.mul
let (//) = Int64.div
let (%%) = Int64.rem
let landl = Int64.logand
let lorl = Int64.logor
let lnotl = Int64.lognot
let lxorl = Int64.logxor
let lsll = Int64.shift_left
let lsrl = Int64.shift_right_logical
let long = Int64.of_int
let succl = Int64.succ
let predl = Int64.pred

let read_int _ = scanf " %d " (fun x -> x)
let read_long _ = scanf " %Ld " (fun x -> x)
let read_str _ = scanf " %s " (fun x -> x)
let read_double _ = scanf " %f " (fun x -> x)

let m = 1_000_000_007L

let rec gcd a b = if b = 0L then a else gcd b (a %% b)

let rec mod_pow a = function
  | 0L -> 1L
  | b -> (if b %% 2L = 0L then 1L else a) ** mod_pow (a ** a %% m) (b//2L) %% m


let () =
  let a,b = scanf " %d %d " (fun x y -> x,y) in
  let ans = if a <= 8 && b <= 8 then "Yay!" else ":(" in
  printf "%s\n" ans


Measured memory_bytes: 384
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
const ll BIGMOD = 1e9 + 7;
using namespace std;

bool check(string str) {
  for (int i = 0; i < str.size() / 2; ++i) {
    if (str[i] != str[str.size() - i - 1]) return false;
  }
  return true;
}

int main() {
  string str;
  cin >> str;
  string second = str.substr(0, (str.size() - 1) / 2);
  string third = str.substr((str.size() + 3) / 2 - 1);
  // cout << str << endl << second << endl << third << endl;
  if (check(str) && check(second) && check(third))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

vector<int> g[100005];
int dp[100005];

int dfs(int i) {
    if (g[i].size() == 0) {
        return dp[i] = 0;
    }
    if (dp[i] != 0) {
        return dp[i];
    }
    int ma = 0;
    for (auto c : g[i]) {
        ma = max(ma, dfs(c));
    }
    return dp[i] = ma + 1;
}

int main() {
    int n, m, x, y;
    cin >> n >> m;
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < m; i++) {
        cin >> x >> y;
        x--; y--;
        g[y].push_back(x);
    }
    int ma = 0;
    for (int i = 0; i < n; i++) {
        dp[i] = dfs(i);
    }
    for (int i = 0; i < n; i++) {
        ma = max(ma, dp[i]);
    }
    cout << ma;
    return 0;
}


Measured memory_bytes: 10624
//
// UVA 1627
// 思路：
// 每一个人都可以讲所有人分为两组，认识的和不认识的。
// 认识的可能不在一个组中，但不认识的必然不在一组中。
//
// 所以第一步，如果可以生成二分图，则统计每部分的数量，求差。
// 利用差，转换为 0 1 背包问题，进行计算。
//
// 类似的问题可以看一下 Uva 323（更难）
//
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <vector>
#include <set>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxx = 200005;


int main() {
    //freopen("../input.txt", "r", stdin);
    //freopen("../output.txt", "w", stdout);
    string s1, s2;
    set<int> position[130];
    while (cin >> s1 >> s2) {
        int s1size = s1.size(), s2size = s2.size();
        ll st = 0, as = 0;
        for (int i = 0; i < s1size; ++i) {
            position[(int) s1[i]].insert(i);
        }
        bool has_ans = true;
        while (st < s2size) {
            if (position[(int) s2[st]].empty()) {
                has_ans = false;
                break;
            }
            auto a = position[(int) s2[st]].upper_bound(as % s1size - 1);
            if (a == position[(int) s2[st]].end()) {
                as = as - as % s1size + s1size + *position[(int) s2[st]].upper_bound(0) + 1;
            } else {
                as += *a + 1 - as % s1size;
            }
            ++st;
        }
        if (!has_ans) as = -1;
        cout << as << endl;

    }
    return 0;
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define md 1000000007
#define mx 1e18
#define pb push_back
#define endl '\n'
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pii pair<ll int,ll int>
#define ff first
#define ss second

ll int n;
ll int h[200001],b[200001];
ll int dp[200001];
ll int tree[600001];

void update(ll int i,ll int v,ll int s,ll int e,ll int index)
{
	if(i<s||i>e)
	{
		return ;
	}

	if(s==e && s==i)
	{
		tree[index]=v;
		return;
	}

	ll int mid=(s+e)/2;

	update(i,v,s,mid,2*index);
	update(i,v,mid+1,e,2*index+1);

	tree[index]=max(tree[2*index],tree[2*index+1]);
}

ll int query(ll int l,ll int r,ll int s,ll int e,ll int index)
{
    if(r<s||l>e)
    {
        return INT_MIN;
    }

    if(s>=l&&e<=r)
    {
        return tree[index];
    }

    ll int mid=(s+e)/2;

    return max(query(l,r,s,mid,2*index),query(l,r,mid+1,e,2*index+1));
}

int main()
{
// 	fastio
// 	#ifndef ONLINE_JUDGE
// 	freopen("input.txt" , "r" , stdin);
// 	freopen("output.txt" , "w" , stdout);
// 	#endif

	cin>>n;
	for(ll int i=0;i<n;i++)
		cin>>h[i];
	for(ll int i=0;i<n;i++)
		cin>>b[i];

	memset(dp,0,sizeof(dp));
	memset(tree,0,sizeof(tree));

	ll int ans=0;

	for(ll int i=0;i<n;i++)
	{
		ll int ht = h[i];

		ll int q = query(0,ht-1,0,n-1,1);

		dp[ht] = q + b[i];

		ans=max(ans,dp[ht]);

		update(ht , q+b[i] , 0 , n-1 , 1);
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 9600
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#define MAX_NUM_CHILDREN 5000

int comp_ints(const void* a, const void* b) { return *(int*)a - *(int*)b; }

int solve()
{
    char ch;

    if((ch = getchar()) == '[')
    {
        int res;

        if(isdigit((int)(ch = getchar())))
        {
            int t;
            ungetc(ch, stdin);
            scanf("%d", &t);
            res = (t + 1) / 2;
        }
        else
        {
            int cost[MAX_NUM_CHILDREN], count = 0, t;
            ungetc(ch, stdin);
            while((t = solve()) != -1)
                cost[count++] = t;
            qsort(cost, count, sizeof(int), comp_ints);
            for(res = t = 0, count = (1 + count) / 2; t < count; t++)
                res += cost[t];
        }

        getchar();              /* pop ']' */
        return res;
    }

    ungetc(ch, stdin);
    return -1;
}

int main(void)
{
    int t;

    scanf("%*d%*c");

    while((t = solve()) != -1)
        printf("%d\n", t), getchar();

    return 0;
}

Measured memory_bytes: 712
#pragma region ALL(include define etc)
#include <iostream>   // swap(a, b)
#include <string>
#include <cmath>      // abs(絶対値) sin cos tan(角度 / 180.0 * 3.141592)
#include <vector>     // vec.push_back(a) vec.pop_back()
#include <algorithm>  // max(a, b) min(a, b) reverse() sort()
#include <functional> // sort(a, a + N, greater<型>());
#include <math.h>
#define int long long
#define ll long long
using namespace std;
#pragma endregion

signed main()
{
	int n;
	int all = 100;
	int a = 0;

	string str;

	//cin >> n;
	cin >> str;

	//cout << a;

	if (str=="ABC")
	{
		cout << "ARC\n";
	}
	else
	{
		cout << "ABC\n";
	}
}

Measured memory_bytes: 3596
#include<stdio.h>
#include<stdlib.h>

int compare(const void* a, const void*b){
    return *(int*)a - *(int*)b;
}

int main(void){
    int n;
    scanf("%d", &n);
    int s[n];
    int sum = 0;
    int flag = 1;
    for(int i=0; i<n; i++){
        scanf("%d", &s[i]);
        sum += s[i];
        if(s[i]%10 != 0){
            flag = 0;
        }
    }

    if(flag){
        printf("0\n");
    }else if(sum%10 != 0){
        printf("%d\n", sum);
    }else{
        qsort(s, n, sizeof(int), compare);
        for(int i=0; i<n; i++){
            if(s[i]%10 != 0){
                sum -= s[i];
                break;
            }
        }
        printf("%d\n", sum);
    }
    
    return 0;
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String line[] = br.readLine().split(" ");
        int intArray[] = new int[n];
		long longArray[] = new long[n];
        for (int i=0; i<n; i++){
            intArray[i] = Integer.parseInt(line[i]);
			longArray[i] = Long.parseLong(line[i]);
        }

        int mi = Integer.MAX_VALUE;
        for (int i=0; i<n; i++){
            mi = Math.min(mi,intArray[i]);
        }
        
        int ma = Integer.MIN_VALUE;
        for (int i=0; i<n; i++){
            ma = Math.max(ma,intArray[i]);
        }
        
        long sum = 0;
        for (int i=0; i<n; i++){
            sum += longArray[i];
        }
        System.out.printf("%s %s %s\n", mi , ma, sum);
    }
}

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

// グラフクラス
struct Graph {
    // 辺クラス
    // rev: 逆辺 (to, from) が G[to] の中で何番目の要素か
    // cap: 辺 (from, to) の容量
    struct Edge {
        int rev, from, to, cap;
        Edge(int r, int f, int t, int c) :
            rev(r), from(f), to(t), cap(c) {}
    };

    // 隣接リスト
    vector<vector<Edge>> list;

    // N: 頂点数
    Graph(int N = 0) : list(N) { }

    // グラフの頂点数取得
    size_t size() {
        return list.size();
    }
    
    // Graph インスタンスを G として，
    // G.list[v] を G[v] と書けるようにしておく
    vector<Edge> &operator [] (int i) {
        return list[i];
    }

    // 辺 e = (u, v) の逆辺 (v, u) を取得する
    Edge& redge(const Edge &e) {
        return list[e.to][e.rev];
    }

    // 辺 e = (u, v) に流量 f のフローを流す
    // e = (u, v) の流量が f だけ減少する
    // このとき逆辺 (v, u) の流量を増やす
    void run_flow(Edge &e, int f) {
        e.cap -= f;
        redge(e).cap += f;
    }

    // 頂点 from から頂点 to へ容量 cap の辺を張る
    // このとき to から from へも容量 0 の辺を張っておく
    void addedge(int from, int to, int cap) {
        int fromrev = (int)list[from].size();
        int torev = (int)list[to].size();
        list[from].push_back(Edge(torev, from, to, cap));
        list[to].push_back(Edge(fromrev, to, from, 0));
    }
};

struct FordFulkerson {
    static const int INF = 1 << 30; // 無限大を表す値を適切に
    vector<int> seen;

    FordFulkerson() { }

    // 残余グラフ上で s-t パスを見つける (深さ優先探索)
    // 返り値は s-t パス上の容量の最小値 (見つからなかったら 0)
    // f: s から v へ到達した過程の各辺の容量の最小値
    int fodfs(Graph &G, int v, int t, int f) {
        // 終端 t に到達したらリターン
        if (v == t) return f;

        // 深さ優先探索
        seen[v] = true;
        for (auto &e : G[v]) {
            if (seen[e.to]) continue;

            // 容量 0 の辺は実際には存在しない
            if (e.cap == 0) continue;

            // s-t パスを探す
            // 見つかったら flow はパス上の最小容量
            // 見つからなかったら f = 0
            int flow = fodfs(G, e.to, t, min(f, e.cap));

            // s-t パスが見つからなかったら次辺を試す
            if (flow == 0) continue;

            // 辺 e に容量 flow のフローを流す
            G.run_flow(e, flow);

            // s-t パスを見つけたらパス上最小容量を返す
            return flow;
        }

        // s-t パスが見つからなかったことを示す
        return 0;
    }

    // グラフ G の s-t 間の最大流量を求める
    // ただしリターン時に G は残余グラフになる
    int solve(Graph &G, int s, int t) {
        int res = 0;

        // 残余グラフに s-t パスがなくなるまで反復
        while (true) {
            seen.assign((int)G.size(), 0);
            int flow = fodfs(G, s, t, INF);

            // s-t パスが見つからなかったら終了
            if (flow == 0) return res;

            // 答えを加算
            res += flow;
        }

        // no reach
        return 0;
    }
};

int main() {
    // グラフの入力
    // N: 頂点数、M: 辺数
    int N, M;
    cin >> N >> M;
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int u, v, c;
        cin >> u >> v >> c;

        // 容量 c の辺 (u, v) を張る
        G.addedge(u, v, c);
    }

    // Ford-Fulkerson 法
    FordFulkerson ff;
    int s = 0, t = N - 1;
    cout << ff.solve(G, s, t) << endl;
}



Measured memory_bytes: 3172
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define LL long long
using namespace std;
int f[55][105], g[55][105], v[105];
int main(){
    ios::sync_with_stdio(false);
    int n, k; cin>>n>>k;
    for(int i = 1; i <= n; i++) cin>>v[i];
    for(int i = 0; i <= 51; i++){
        for(int j = 0; j <= 101; j++)
            f[i][j] = g[i][j] = -1e9;
    }
    f[0][k] = 0;
    for(int i = 0; i <= n - 1; i++){
        for(int j = k; j >= 1; j--){
            f[i + 1][j - 1] = max(f[i + 1][j - 1], f[i][j] + v[i + 1]);
            if(j >= 2) f[i + 1][j - 2] = max(f[i + 1][j - 2], f[i][j]);
        }
    }
    g[n + 1][k] = 0;
    for(int i = n + 1; i >= 2; i--){
        for(int j = k; j >= 1; j--){
            g[i - 1][j - 1] = max(g[i - 1][j - 1], g[i][j] + v[i - 1]);
            if(j >= 2) g[i - 1][j - 2] = max(g[i - 1][j - 2], g[i][j]);
        }
    }
    int ans = 0;
    for(int i = 0; i <= n; i++){
        for(int j = i + 1; j <= n + 1; j++){
            for(int K = i; K <= k && K <= 2 * i; K++){
                for(int t = n - j + 1; t + K <= k; t++){
                    ans = max(f[i][k - K] + g[j][k - t], ans);
                }
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		int diceO[][];
		int diceC[][];
		int n = 0;
		int num1;
		int num2 = 1;
		String str = "";
		Boolean breakp = null;
		
		n = as.nextInt();
		
		diceO = new int[n][6];
		diceC = new int[n][6];
		
		for(int i=0;i<n;i++){
			for(int j=0;j<6;j++){
				
				diceO[i][j] = as.nextInt();
				
			}
		}
		diceC = diceO;
		for(num1=0;num1<n;num1++){
			for(num2=num2+num1;num2<n;num2++){
				
				breakp = Spin.DoubleCheck(diceO, diceC, num1, num2);
				
				if(breakp){
					
					str = "No";
					break;
					
				}
				else{
					
					str = "Yes";
					
				}
				
				
			}
			if(breakp){
				
				break;
				
			}
		}
		
		
		
		
		System.out.println(str);

	}

}

class Spin{
	
	public static int[][] diceSpin(int[][] dice,String spn,int num2) {
	
		int tre = 0;	
			
		switch (spn){
		case "x":
			tre = dice[num2][4];
			dice[num2][4] = dice[num2][0];
			dice[num2][0] = dice[num2][1];
			dice[num2][1] = dice[num2][5];
			dice[num2][5] = tre;
			break;
			
		case "y":
			tre = dice[num2][3];
			dice[num2][3] = dice[num2][0];
			dice[num2][0] = dice[num2][2];
			dice[num2][2] = dice[num2][5];
			dice[num2][5] = tre;
			break;
			
		case "z":
			tre = dice[num2][2];
			dice[num2][2] = dice[num2][1];
			dice[num2][1] = dice[num2][3];
			dice[num2][3] = dice[num2][4];
			dice[num2][4] = tre;
			break;
					
		}
			
		return dice;
		
	  }
	
	public static Boolean Samecheck(int[][] dice1,int[][] dice2,int num1,int num2){
		
		Boolean flag = null;
		
		for(int i=0;i<6;i++){
			
			if(dice1[num1][i] != dice2[num2][i]){
				
				flag = false;
				break;
			}
			else{
				
				flag = true;
				
			}
			
		}
		
		return flag;
		
	}
	
	public static Boolean Check(int[][] dice1,int[][] dice2,int sp,int num1,int num2){
		
		Boolean flag = null;
		String spn = null;
		
		switch (sp){
		case 0:
			spn = "x";
			break;
			
		case 1:
			spn = "y";
			break;
			
		case 2:
			spn = "z";
			break;
			
		}
		
		for(int j=0;j<4;j++){		
			
			dice2 = Spin.diceSpin(dice2, spn,num2);
			if(Spin.Samecheck(dice1, dice2,num1,num2)){
				
				flag = true;
				break;
			
			}
			
			flag = false;
			
		}
		
		return flag;
		
	}
	
	public static Boolean DoubleCheck(int[][] dice1,int[][] dice2,int num1,int num2){
		
		Boolean breakp = null;
		
		for(int i=0;i<3;i++){
			
			for (int j=0;j<4;j++){
				
				for(int k=0; k<j; k++){
					
					dice2 = Spin.diceSpin(dice2, "x",num2);
					
				}
				
				breakp = Spin.Check(dice1, dice2, i,num1,num2);
				
				if(breakp == true){
					
					break;
					
				}
				
			}
			
			if(breakp == true){
				
				break;
				
			}
		
		}
		
		return breakp;
		
	}
	
}

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

namespace AtCoder
{
    class Program
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            Score[] scores = new Score[n];
            for (int i = 0; i < n; i++)
            {
                int[] row = Console.ReadLine().Split(' ').Select(inp => int.Parse(inp)).ToArray();
                scores[i] = new Score(row[0], row[1]);
            }

            double a = 0;
            double b = 0;
            var sorted = scores.OrderByDescending(s => s.Sum);
            int cnt = 0;
            foreach(var s in sorted)
            {
                if (cnt++ % 2 == 0)
                    a += s.A;
                else
                    b += s.B;
            }

            Console.WriteLine(a - b);
        }

        private class Score
        {
            public int A { get; }
            public int B { get; }
            public int Sum { get; }

            public Score(int a, int b)
            {
                A = a;
                B = b;
                Sum = A + B;
            }
        }
    }
}

Measured memory_bytes: 22836
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1e9 + 10;//10^9
ll MOD  = 1000000007;
int dy[] = {0,0,1,-1};
int dx[] = {1,-1,0,0};

int main(void){
    int N, M, X;
    cin >> N >> M >> X;
    int left = 0, right = 0;
    for(int i = 0; i < M; i++){
        int a;
        cin >> a;
        if(a < X){
            left++;
        }else{
            right++;
        }
    }
    cout << min(left, right) << endl;
}

Measured memory_bytes: 256
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import collections
import math

#### START
N, A, B = map(int,input().split())

cnt = 0
for i in range(1, N+1):
  t = sum([ int(i) for i in str(i) ])
  if A <= t and t <= B:
    cnt+=i

print(cnt)

Measured memory_bytes: 3444
/* template.cpp [[[ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)s)
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)s)
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
ll in(){ ll x; cin >> x; return x; }
vector<ll> in(size_t n){ vector<ll> v(n); each(x, v) cin >> x; return v; }
/* ]]] */

int a[100000], b[100000];

int main(){
  int n, m;
  cin >> n >> m;
  rep(i, n) a[i] = 1;
  b[0] = 1;
  rep(i, m){
    int x, y;
    cin >> x >> y, x--, y--;
    if (a[x] == 1 && b[x] == 1){
      b[x] = 0;
      b[y] = 1;
    }
    else b[y] |= b[x];
    a[x]--;
    a[y]++;
  }
  cout << accumulate(b, b + n, 0) << endl;
}


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

def main():
    N = int(input())
    result = 0
    for n in range(1, N+1, 2):
        div = get_divisors(n)
        if len(div) == 8:
            result += 1

    print(result)


main()

Measured memory_bytes: 3060
#include <stdio.h>

struct Dice{
    int num1;
    int num2;
    int num3;
    int num4;
    int num5;
    int num6;
};

int main(){

    int n[6];
    int i,count,top,side,ans;
    char c;
    for (i = 0; i < 6; i++) {
        scanf("%d", &n[i]);
    }
    struct Dice dice1 = {n[0],n[1],n[2],n[3],n[4],n[5]};
    struct Dice dice2;

    scanf("%d",&count);

    for (i = 0; i < count; i++) {
        scanf("%d %d", &top,&side);
        if (top == dice1.num1) {
            if (side == dice1.num2) {
                ans = dice1.num3;
            }else if(side == dice1.num3){
                ans = dice1.num5;
            }else if(side == dice1.num5){
                ans = dice1.num4;
            }else if(side == dice1.num4){
                ans = dice1.num2;
            }
        }else if (top == dice1.num2) {
            if (side == dice1.num6) {
                ans = dice1.num3;
            }else if(side == dice1.num3){
                ans = dice1.num1;
            }else if(side == dice1.num1){
                ans = dice1.num4;
            }else if(side == dice1.num4){
                ans = dice1.num6;
            }
        }else if (top == dice1.num3) {
            if (side == dice1.num1) {
                ans = dice1.num2;
            }else if(side == dice1.num2){
                ans = dice1.num6;
            }else if(side == dice1.num6){
                ans = dice1.num5;
            }else if(side == dice1.num5){
                ans = dice1.num1;
            }
        }else if (top == dice1.num4) {
            if (side == dice1.num1) {
                ans = dice1.num5;
            }else if(side == dice1.num2){
                ans = dice1.num1;
            }else if(side == dice1.num6){
                ans = dice1.num2;
            }else if(side == dice1.num5){
                ans = dice1.num6;
            }
        }else if (top == dice1.num5) {
            if (side == dice1.num1) {
                ans = dice1.num3;
            }else if(side == dice1.num3){
                ans = dice1.num6;
            }else if(side == dice1.num6){
                ans = dice1.num4;
            }else if(side == dice1.num4){
                ans = dice1.num1;
            }
        }else if (top == dice1.num6) {
            if (side == dice1.num2) {
                ans = dice1.num4;
            }else if(side == dice1.num3){
                ans = dice1.num2;
            }else if(side == dice1.num5){
                ans = dice1.num3;
            }else if(side == dice1.num4){
                ans = dice1.num5;
            }
        }
        printf("%d\n", ans);
    }


    //printf("%d\n", dice1.num1);
    return 0;
}



Measured memory_bytes: 1996