akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <random>
#include <chrono>
#include <bitset>
#include <string>
#include <iostream>
#include <numeric>
#include <vector>
#include <stack>
#include <cmath>
#include <map>
using namespace std;
#ifdef MANSON
#define BUGO(x) cerr << #x << " = " << (x) << '\n';
#define BUGOARR(a) cerr << #a << ": "; for (auto i: a) cerr << i << ' '; cerr << '\n';
#else
#define BUGO(x)
#define BUGOARR(a)
#endif
using llong = long long;
const llong mod = 1000'000'007;
const int maxN = 200'005;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l, int r) { return uniform_int_distribution<int>(l, r)(rng); }

int cnt[19][19];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; ++i)
    {
        string x;
        cin >> x;
        int j = find(x.begin(), x.end(), '.') - x.begin();
        if (j < x.size()) x += string(9 - (x.size() - j - 1), '0');
        else x += string(9, '0');
        if (j < x.size() && x[j] == '.')
            x.erase(x.begin() + j);
        llong y = stoll(x);
        while (a[i].first < 18 && y % 2 == 0)
        {
            y /= 2;
            ++a[i].first;
        }
        while (a[i].second < 18 && y % 5 == 0)
        {
            y /= 5;
            ++a[i].second;
        }
    }
    llong ans = 0;
    for (int i = 0; i < n; ++i)
    {
        int x = 18 - a[i].first;
        int y = 18 - a[i].second;
        for (int p = x; p <= 18; ++p)
            for (int q = y; q <= 18; ++q)
                ans += cnt[p][q];
        ++cnt[a[i].first][a[i].second];
    }
    cout << ans;
}


Measured memory_bytes: 4816
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <ctime>
#include <cstring>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

int a, b, h;

int main() {
	cin >> a >> b >> h;
	cout << (a + b) * h * 0.5;
	return 0;
}

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

int main(){
    int N=13;
    string s;
    cin>>s;
    
    int dp[s.length()+1][N] = {};
    dp[0][0] = 1;

    for(int i=0; i<s.length(); i++){
        char c = s[i];
        for(int j=0; j<N; j++){
            for(int k=0; k<10; k++){
                if(c != '?' && c-'0' != k) continue;
                dp[i+1][(10*j+k)%N] += dp[i][j];
                dp[i+1][(10*j+k)%N] %= 1000000007;
            }
        }
    }

    cout<<dp[s.length()][5]<<endl;
}

Measured memory_bytes: 5504
using System;


namespace ConsoleApp7
{
    class Program
    {
        static void Main(string[] args)
        {
            var strnums = Console.ReadLine().Split(' ');
            int num1 = int.Parse(strnums[0]);
            int num2 = int.Parse(strnums[1]);
            int num3 = int.Parse(strnums[2]);
            int temp;
            if (num1 > num2) { temp = num1; num1 = num2; num2 = temp; }
            if (num2 > num3) { temp = num2; num2 = num3; num3 = temp; }
            if (num1 > num3) { temp = num1; num1 = num3; num3 = temp; }

            var res = num1 + num2;

            Console.WriteLine(res);

        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int A,B; cin >>A >> B;
    int a,b,c; 
    a=A+B; b=A-B; c=A*B;
    cout << max({a,b,c}) << endl;
}

Measured memory_bytes: 256
def fn(i):
    return (1 <= i and i <= 9) or (100 <= i and i <= 999) or (10000 <= i and i <= 99999)


def main():
    n = int(input())
    x = range(n + 1)[1:]
    x = tuple(filter(fn, x))

    print(len(x))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6712
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int read()
{
	char ch=getchar();int f=0,x=1;
	while(ch<'0'||ch>'9'){if(ch=='-') x=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){f=(f<<1)+(f<<3)+ch-'0';ch=getchar();}
	return f*x;
}
int main()
{
	int n=read();
	for(int i=1;i<=n;i++)
	{
		int x=read();
		if(x%2==1)
		{
			puts("first");
			return 0;
		}
	}
	puts("second");
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<cctype>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define INF 1e6
using namespace std;

int d(string s,int color[3]){
  int red=0,blue=0,green=0;
  if(!isdigit(s[1]))red+=(s[1]-'a'+10)*16;
  else red+=(s[1]-'0')*16;
  if(!isdigit(s[2]))red+=(s[2]-'a'+10);
  else red+=(s[2]-'0');
  if(!isdigit(s[3]))green+=(s[3]-'a'+10)*16;
  else green+=(s[3]-'0')*16;
  if(!isdigit(s[4]))green+=(s[4]-'a'+10);
  else green+=(s[4]-'0');
  if(!isdigit(s[5]))blue+=(s[5]-'a'+10)*16;
  else blue+=(s[5]-'0')*16;
  if(!isdigit(s[6]))blue+=(s[6]-'a'+10);
  else blue+=(s[6]-'0');
  return pow((red-color[0]),2)+pow((green-color[1]),2)+pow((blue-color[2]),2);
}

int cl[8][3]={{0,0,0},{0,0,255},{0,255,0},{0,255,255},{255,0,0},{255,0,255},{255,255,0},{255,255,255}};

int main(){
  string str;
  while(1){
    cin>>str;
    if(str=="0")break;
    int num=INF;
    string ans="";
    rep(i,8){
      if(num>d(str,cl[i])){
	if(i==0)ans="black";
	else if(i==1)ans="blue";
	else if(i==2)ans="lime";
	else if(i==3)ans="aqua";
	else if(i==4)ans="red";
	else if(i==5)ans="fuchsia";
	else if(i==6)ans="yellow";
	else if(i==7)ans="white";
	num=d(str,cl[i]);
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1184
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      aa: [usize; n],
    }
    let mut a2: Vec<_> = aa.iter().enumerate().map(|(i,&v)|(v,i)).collect();
    a2.sort();
    a2.reverse();

    for i in 0..n {
        if a2[0].1 == i {
            puts!("{}\n", a2[1].0);
        } else {
            puts!("{}\n", a2[0].0);
        }
    }
}


Measured memory_bytes: 13820
#include <bits/stdc++.h>
using namespace std;
int main() {
int R,C,K;
  cin >> R >> C >> K;
  vector<int> r(K);
  vector<int> c(K);
  vector<int> v(K);
  vector<vector<int>> B(R,vector<int>(C,0));
  for(int a = 0;a < K;a++){
    cin >> r[a] >> c[a] >> v[a];
    B[r[a] - 1][c[a] - 1] = v[a];
  }
  vector<vector<vector<long long>>> A(R,vector<vector<long long>>(C,vector<long long>(4,-10))); 
  A[0][0][1] = B[0][0];
  A[0][0][0] = 0;
  for(int a = 0;a < R;a++){
    for(int b = 0;b < C;b++){
      for(int c = 0;c <= 3;c++){
        
        
        if(A[a][b][c] != -10){
        
        
        
        if(a < R - 1){
          if(A[a+1][b][0] < A[a][b][c]){
            A[a+1][b][0] = A[a][b][c];
          }
          if(A[a+1][b][1] < A[a][b][c] + B[a+1][b]){
            A[a+1][b][1] = A[a][b][c] + B[a+1][b];
          }
        }
        
        if(b < C - 1){
          if(A[a][b+1][c] < A[a][b][c]){
            A[a][b+1][c] = A[a][b][c];
          }
          if(c < 3){
            if(A[a][b+1][c+1] < A[a][b][c] + B[a][b+1]){
            A[a][b+1][c+1] = A[a][b][c] + B[a][b+1];
            }
          }
          
        }
        
        
      }
        
      }
    }
  }
  long long result = A[R-1][C-1][0];
  if(result < A[R-1][C-1][1])result = A[R-1][C-1][1];
  if(result < A[R-1][C-1][2])result = A[R-1][C-1][2];
  if(result < A[R-1][C-1][3])result = A[R-1][C-1][3];
  cout << result << endl;
  
}


Measured memory_bytes: 673344
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k, c int
	fmt.Scan(&n, &k, &c)
	var s []byte
	fmt.Scan(&s)
	pw := -int(1e6)
	ws := make([]int, 0)
	for i := range s {
		if s[i] == 'o' {
			if i > pw+c {
				pw = i
				ws = append(ws, i)
			}
		}
	}
	if len(ws) > k {
		return
	}
	pw = int(1e6)
	for i := n - 1; i >= 0; i-- {
		if s[i] == 'o' {
			if i < pw-c {
				pw = i
				ws = append(ws, i)
			}
		}
	}
	sort.Sort(sort.IntSlice(ws))
	m := make(map[int]int)
	for _, v := range ws {
		m[v]++
		if m[v] == 2 {
			fmt.Println(v + 1)
		}
	}
}


Measured memory_bytes: 20224
iogetfloats :: IO [Double]
iogetfloats = do
  s <- getLine
  return $ map read $ words s

solve :: Double -> Double -> Double -> Double
solve n m d
	| d == 0 = (m - 1) / n
	| otherwise = 2 * (n - d) * (m - 1) / (n * n)

main :: IO ()
main = do 
	[n, m, d] <- iogetfloats
	print (solve n m d)

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

int main(){
    int num;
    vector <int> n(4);
    vector <char>s(3);

    cin >> num;

    n[3] = num / 1000; num = num % 1000;
    n[2] = num / 100;  num = num % 100;
    n[1] = num / 10;   num = num % 10;
    n[0] = num;
    // cout << n[3] << n[2] << n[1] << n[0] <<  endl;
    int sum = 0;

    for(int i = 0; i < 8; ++i){
        sum = n[3];
        for(int j = 0; j < 3; ++j){
            if((i >> j) & 1){
                sum += n[2 - j]; 
                s[2-j] = '+';
            }else{
                sum -= n[2 - j];
                s[2-j] = '-';
            }
        }
        if(sum == 7){
            cout << n[3] << s[2] << n[2] << s[1] << n[1] << s[0] << n[0] << "=7" <<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3620
#include<stdio.h>
#define NIL -1
#define MAX 10000
typedef struct node {
  int parent;
  int l;
  int r;
} Node;
Node T[MAX];
int n,D[MAX],H[MAX];
void Depth(int u,int d){
  if(u == NIL)return;
  D[u]=d;
  Depth(T[u].l,d+1);
  Depth(T[u].r,d+1);
}
int Height(int u){
  int h1=0,h2=0;
  if(T[u].l!=NIL){
      h1=Height(T[u].l)+1;
  }
  if(T[u].r!=NIL){
      h2=Height(T[u].r)+1;
  }
  if(h1>h2){
    return H[u]=(h1);
  }
  else return H[u]=(h2);
}
int Sibling(int u){
  if(T[u].parent==NIL){
    return NIL;
  }
  if(T[T[u].parent].l != u && T[T[u].parent].l != NIL){
    return T[T[u].parent].l;
  }
  if(T[T[u].parent].r != u && T[T[u].parent].r != NIL){
    return T[T[u].parent].r;
  }
  return NIL;
}
void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",Sibling(u));
  int deg=0;
  if(T[u].l!=NIL)deg++;
  if(T[u].r!=NIL)deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ", H[u]);

  if(T[u].parent==NIL){
    printf("root\n");
  }
  else if(T[u].l==NIL && T[u].r==NIL){
    printf("leaf\n");
  }
  else{
    printf("internal node\n");
  }
}
int main(){
  int v,l,r,root=0;
  scanf("%d",&n);
  int i;
  for(i=0;i<n;i++){
    T[i].parent=NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;
    if(l!=NIL)T[l].parent=v;
    if(r!=NIL)T[r].parent=v;
  }
  for(i=0;i<n;i++){
    if(T[i].parent ==NIL)root=i;
  }
    Depth(root,0);
    Height(root);
    for(i=0;i<n;i++)print(i);
    return 0;

}



Measured memory_bytes: 2104
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
ll gcd(ll a, ll b)
{
	for (;;)
	{
		if (a < b)swap(a, b);
		a %= b;
		if (a == 0)return b;
	}
}
ll a[202020];
int main()
{
	int num;
	scanf("%d", &num);
	ll s = 0;
	for (int i = 0; i < num; i++)scanf("%lld", &a[i]), s += a[i];
	ll n = 0, mini = 1000000000000000000LL;
	for (int i = 0; i < num - 1; i++)
	{
		n += a[i];
		mini = min(mini, abs(s - n - n));
	}
	printf("%lld\n", mini);
}

Measured memory_bytes: 1792
N=int(input())
if N < 10:
    print(N)
if 10 <= N < 100:
    print(9)
if 100 <= N < 1000:
    print(N-90)
if 1000 <= N < 10000:
    print(909)
if 10000 <= N <100000:
    print(N-9090)
if N == 100000:
    print(90909)


Measured memory_bytes: 2940
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
#define sz(v) ((int)v.size())
#define all(v) v.begin(), v.end()
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a,a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ll x, ll y, ll a, ll b){ return sqrt((x - a)*(x - a) + (y - b)*(y - b)); }
void debug(ll* a, ll n) { for ( int k = 0; k < n; k++ ){ cout << a[k] << " ";} cerr << "\n"; }

int main(){
	FASTIO;
	ll n, m; cin >> n >> m;
	ll ac[n + 1], wa[n + 1]; memset(ac, 0, sizeof ac), memset(wa, 0, sizeof wa);
	ll a = 0;
	ll w = 0;
	for ( int k = 0; k < m; k++ ){
		ll x; cin >> x;
		string s; cin >> s;
		if (s == "AC") {
			if (!ac[x]) {
				a++;
				w += wa[x];
			}
			ac[x] = 1;
		}
		else {
			wa[x]++;
		}
	}
	cout << a << " " << w << endl;
	return 0;
}

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

int main(){
    int n,m;cin>>n>>m;
    vl ac(n),pena(n);

    rep(i,m){
        ll p;string s;cin>>p>>s;
        p--;//配列に対応させる
        if(ac.at(p)) continue;//p問題がAC済ならとばす
        if(s=="AC") ac.at(p)=1;
        else pena.at(p)++;
    }


int AC=0;int PENA=0;
  rep(i,n){
      if(ac.at(i)){AC++;PENA+=pena.at(i);}
      else continue;
      
  }

  cout<<AC<<endl;
cout<<PENA<<endl;
}

Measured memory_bytes: 1792
#include<cstdio>
using namespace std;
int A, B, C;
int X;

int solve(){
int ans = 0;
for(int i = 0; i <= A; ++i){
for(int j = 0; j <= B; ++j){
for(int k = 0; k <= C; ++k){
int tmp = i * 500 + j * 100 + k * 50;
if(tmp == X) ans++;
}
}
}
return ans;
}
int main(){
scanf("%d%d%d%d", &A, &B, &C, &X);
int ans = solve();
printf("%d\n", ans);
return 0;
}

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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define _sort(a) sort(a.begin(), a.end())
#define _sortd(a) sort(a.rbegin(), a.rend())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

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

  for (int i = 0; i < 20; ++i) {
    int c = 0;
    if (i == 0) {
      c = 1;
    } else if (i == 1) {
      c = a;
    } else {
      c = (i - 1) * (a - 1) + a;
    }
    if (c >= b) {
      p(i);
      return 0;
    }
  }
}

Measured memory_bytes: 256
from heapq import heapify,heappop,heappush
N,M,s,t=map(int,input().split())
Graph1=[set() for i in range(N)]
Graph2=[set() for i in range(N)]
inf=float("inf")
for i in range(M):
  u,v,a,b=map(int,input().split())
  Graph1[u-1].add((a,v-1))
  Graph1[v-1].add((a,u-1))
  Graph2[u-1].add((b,v-1))
  Graph2[v-1].add((b,u-1))
  
def dijkstra(s,n,links):
  cost=[inf]*n
  visited=[False]*n
  cost[s]=0
  heap=[(0,s)]
  heapify(heap)
  while heap:
    hc,hp=heappop(heap)
    if not visited[hp]:
      visited[hp]=True
      for c,p in links[hp]:
        if not visited[p]:
          if c+hc<=cost[p]:
            cost[p]=c+hc
            heappush(heap,(cost[p],p))
  return cost
 
cost1=dijkstra(s-1,N,Graph1)
cost2=dijkstra(t-1,N,Graph2)

ans=[0]*N
a=inf
for i in range(N)[::-1]:
  a=min(a,cost1[i]+cost2[i])
  ans[i]=10**15-a
for i in ans:
  print(i)

Measured memory_bytes: 131564
// type a
//a...いけそう
//b...自信がない
//c...お試し
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
// ===============================================================
//using系
#pragma region header
using namespace std;
using lint = long long;
using ld = long double;
using ulint = unsigned long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr lint mod = 1000000007;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#define INF (lint)10000000000000000;
#define mod (int)1000000007
#pragma endregion



int main() {
	int n; cin >> n;
	vector<int> d(n);
	vector<pair<int, int>> a(100010);
	vector<pair<int, int>> b(100010);
	for (int i = 0; i < 100010; i++) {
		a[i] = make_pair(0, i);
		b[i] = make_pair(0, i);
	}
	for (int i = 0; i < n; i++) {
		cin >> d[i];
		if (i % 2 == 0) a[d[i]].first++;
		else b[d[i]].first++;
	}
	sort(a.rbegin(), a.rend());
	sort(b.rbegin(), b.rend());
	if (a[0].second != b[0].second) {
		cout << n - a[0].first - b[0].first << endl;
	}
	else {
		cout << min(n - a[0].first - b[1].first, n - a[1].first - b[0].first) << endl;
	}

	return 0;
}

Measured memory_bytes: 5032
Q = int(input())
P = [2]
PF = [False for _ in range(100001)]
PF[2] = True
SUM = [0, 0, 0]
sum_val = 0
for i in range(3, 100001):
	if not i % 2 == 0:
		is_p = True
		for p in P:
			if i % p == 0:
				is_p = False
				break
		if is_p:
			if i < 317:
				P.append(i)
			PF[i] = True
			if PF[(i + 1) // 2]:
				sum_val += 1
	SUM.append(sum_val)
ans = []
for _ in range(Q):
	l, r = map(int, input().split())
	ans.append(SUM[r] - SUM[l - 1])	
[print(i) for i in ans]


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

int main(){
    int sity[4] = {0};

    int road;
    for(int i = 0; i < 6; i++){
        cin >> road;
        if(road == 1)
            sity[0]++;
        else if(road == 2)
            sity[1]++;
        else if(road == 3)
            sity[2]++;
        else
            sity[3]++;     
    }

    for(int j = 0; j < 4; j++){
        if(sity[j] >= 3){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n, k;
    int ans = 0;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i)
    {
        int x;
        cin >> x;
        ans = ans + 2 * min(x, k - x);
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n,k;
  	cin>>n>>k;
  	vector<int> h;
  	for(int i=0; i<n; i++) {
      	int temp;
      	cin>>temp;
      	h.push_back(temp);
    }
  	vector<int> dp(n,INT_MAX);
  	dp[0] = 0;
  	for(int i=0; i<n; i++) {
      for(int j=i+1; j<=i+k; j++) {
        if(j<n) dp[j] = min(dp[j],abs(h[i]-h[j])+dp[i]);
    	}
   	}
  		cout<<dp[n-1];
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const int INF = 1e9;
ll M, N;
vector<string> S;
map<vector<int>, int> dp;
int f(vector<int> v) {
    if(dp.count(v)) return dp[v];
    int cnt = 0;
    for(int i = 0; i < N; i++) {
        bool ok = true;
        for(int j = 0; j < M; j++) {
            if(v[j] == 1 and S[i][j] == '0') ok = false;
            if(v[j] == 2 and S[i][j] == '1') ok = false;
        }
        if(ok) cnt++;
    }
    if(cnt == 0) return dp[v] = -1e9;
    if(cnt == 1) return dp[v] = 0;
    int ret = 1e9;
    for(int q = 0; q < M; q++) {
        if(v[q] != 0) continue;
        v[q] = 1;
        int tmp1 = f(v);
        v[q] = 2;
        int tmp2 = f(v);
        v[q] = 0;
        chmin(ret, max(tmp1, tmp2));
    }
    return dp[v] = ret + 1;
}

void solve() {
    S.resize(N);
    for(int i = 0; i < N; i++) cin >> S[i];
    dp.clear();
    vector<int> v;
    v.resize(M, 0);
    cout << f(v) << endl;
}

int main() {
    while(cin >> M >> N) {
        if(M == 0) break;
        solve();
    }
    return 0;
}


Measured memory_bytes: 21708
#include <iostream>

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	
	int result;
		
	if (a >= b && a >= c) {
		result = a * 10 + b + c;
	} else if (b >= c) {
		result = b * 10 + a + c;
	} else
		result = c * 10 + a + b;
	
	cout << result << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine().GroupBy(c => c).Count();
            Console.WriteLine(S==2?"Yes":"No");
        }
    }
}

Measured memory_bytes: 13280
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>
 
using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
 
 
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
 
//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
 
void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll n,k;
	cin>>n>>k;
	vector<ll> a(n,0);
	REP(i,n) cin>> a[i];

	Array sum(n+1,0);
	REP(i,n) {
		sum[i+1]=sum[i]+a[i];
	}

	Array num;
	REP(i,n){
		for(ll j=i;j<n;j++){
			num.push_back(sum[j+1]-sum[i]);
		}
	}
	//for(auto i:num) cerr<<i<<endl;

	Array flag(num.size(),true);
	
	ll ans=0;

	for(ll i=60;i>=0;i--){
		ll sum=0;
		REP(j,num.size()){
			if(flag[j] && ((1LL<<i)&num[j])!=0){
				sum++;
			}
		}
		if(sum>=k){
			//cerr<<i<<endl;
			REP(j,num.size()){
				if(((1LL<<i)&num[j])==0){
					flag[j]=false;
				}
			}
			ans+=(1LL<<i);
		}
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 8300
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int dist[1100][1100];

int main(){cout<<fixed<<setprecision(10);
		   //bfsしつつchminを5*5にばら撒く
           int h,w;
           cin>>h>>w;
           int ch,cw,dh,dw;
           cin>>ch>>cw>>dh>>dw;
           ch--;cw--;dh--;dw--;
           rep(i,0,1100)rep(j,0,1100)dist[i][j]=inf;
           vst s(h);
           rep(i,0,h)cin>>s[i];
           
           deque<P> que;
           que.push_front(mp(ch,cw));
           dist[ch][cw]=0;
           while(!que.empty()){
             int nowh=que.front().first;
             int noww=que.front().second;
             que.pop_front();
             int nh,nw;
             
             rep(i,0,4){
              rep(j,0,4){//A
                nh=nowh+dx[i];
                nw=noww+dy[i];
                if(nh<0||nw<0||nh>=h||nw>=w)continue;
                if(s[nh][nw]=='#')continue;
                if(dist[nh][nw]>dist[nowh][noww]){
                  dist[nh][nw]=dist[nowh][noww];
                  que.push_front(mp(nh,nw));
                }
              }
             }
             
             rep(i,-2,3){
              rep(j,-2,3){//B
                 nh=nowh+i;
                 nw=noww+j;
                if(nh<0||nw<0||nh>=h||nw>=w)continue;
                if(s[nh][nw]=='#')continue;
                if((i==1&&j==0)||(i==-1&&j==0)||(i==0&&j==-1)||(i==0&&j==1))continue;
                if(dist[nh][nw]>dist[nowh][noww]+1){
                  dist[nh][nw]=dist[nowh][noww]+1;
                  que.push_back(mp(nh,nw));
                }//if
              }//repj
             }//repi
           }//while
           if(dist[dh][dw]==inf)cout<<-1<<endl;
           else
             cout<<dist[dh][dw]<<endl;
}



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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl
inline int ceil10(int n) { n+=(10-n%10)%10; return n; }

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    vector<int> T(5); cin >> T;

    sort(ALL(T),[](int x,int y){x%=10;if(x==0)x+=10;y%=10;if(y==0)y+=10;return x>y;});

    int ans = 0;
    rep(i,5) {
        if (i == 4) ans += T[i];
        else ans += ceil10(T[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------
vector<ll>num;
ll binarysearch(ll m){
    if(siz(num)==1)
        return 0;
    if(num[0]>=m)
        return 0;
    ll left=0,right=num.size();ll mid;
    while(left+1<right){
        mid=(left+right)/2;
        if(num[mid]<m)
            left=mid;
        else
            right=mid;
    }
   // cout<<right<<endl;
    return right;
    
}
//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    vector<ll>a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    int dp[100001];
    
    dp[0]=1;
    ll ans=0;
    num.pb(a[0]);
    for(int i=1;i<n;i++){
       // cout<<a[i]<<" "<<num[ans]<<endl;
        if(a[i]>num[ans]){
            ans++;
            num.pb(a[i]);
        }
        else{
            ll now=binarysearch(a[i]);
          //  cout<<now<<endl;
            num[now]=a[i];
        }
        /*for(int j=0;j<siz(num);j++)
            cout<<num[j]<<" ";
        cout<<endl;*/
    }
    cout<<ans+1<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------




Measured memory_bytes: 4644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

int main() {
    cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(20);

    ll N; cin >> N;

    if(N%2) {
        cout << 0 << endl;
        return 0;
    }

    ll k = N / 2;
    ll c2 = k, c5 = 0;
    
    ll p = 2;
    while(k / p > 0) {
        c2 += k / p;
        p *= 2;
    }
    p = 5;
    while(k / p > 0) {
        c5 += k / p;
        p *= 5;
    }
    cout << min(c2, c5) << endl;
}


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

#define mp make_pair
#define pb push_back
#define int long long

using namespace std;
const int inf = 1e18;
const double EPS = 0.00000001;
const int mod = 1000000007;


signed main(){
	int n;
	cin >> n;
	int mass[n];
	for(int i = 0;i<n;i++) cin >>mass[i];
	sort(mass,mass+n);
	int cnt = 0;
	for(int i = 0;i<n;i++){
        for(int z = i+1;z<n;z++){
            int x = lower_bound(mass,mass+n,mass[i]+mass[z])-mass;
            cnt += max((int)0,x-z-1);
        }
	}
	cout << cnt;
}


Measured memory_bytes: 3620
x = int(input())
for a in range(-300,301):
  if(a<0):
    for b in range(-300,a):
      if(a**5-b**5==x):
        print(a,b)
        break
    else: continue
    break
  else:
    for b in range(-300,a):
      if(a**5-b**5==x):
        print(a,b)
        break
    else: continue
    break

Measured memory_bytes: 65792
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, m, a[100008], c, b;
P cb[100008];
string str;

int main(){
	cin >> n >> m;
	for(ll i = 0; i < n; i++){cin >> a[i];}
	for(ll j = 0; j < m; j++){
		cin >> b >> c;
		cb[j] = P(c, b);
	}
	sort(a, a+n);
	sort(cb, cb+m);
	ll ans = 0;
	ll ai = n-1;
	ll bi = m-1;
	for(ll i = 1; i <= n; i++){
		if(a[ai] > cb[bi].first){
			ans += a[ai];
			ai--;
		}
		else{
			ans += cb[bi].first;
			cb[bi].second--;
			if(cb[bi].second <= 0){bi--;}
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int H = 100 , W = 100;
int A,B;
bool b[H][W];

int main(){
	cin >> A >> B;
	repp(i,0,H/2) repp(j,0,W) b[i][j] = 1;
	int x = 0 , y = 0;
	while(A > 1){
		b[x][y] = 0;
		y += 2;
		if(y >= W){
			y = 0;
			x += 2;
		}
		--A;
	}
	x = H-1 , y = W-1;
	while(B>1){
		b[x][y] = 1;
		y -= 2;
		if(y < 0){
			y = W-1;
			x -= 2;
		}
		--B;
	}
	cout << H << ' ' << W << endl;
	repp(i,0,H){
		repp(j,0,W){
			cout << (b[i][j]?'#':'.');
		}
		cout << endl;
	}
	return 0;
}


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

#define int long long
#define counter(m)     for(int i=0;i<m;i++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int32_t main() {
    nitin;
    int a,b,c;
    cin>>a>>b>>c;
    int cnt=0;
    if(a%2!=0 || b%2!=0 || c%2!=0)
    {
        cout<<0<<endl;
        exit(0);
    }
    if(a==b && b==c && c==a)
    {
        cout<<-1<<endl;
        exit(0);
    }
    while(a%2==0 && b%2==0 && c%2==0)
    {
        if(a==b && b==c && c==a)
        {
            cout<<-1<<endl;
            exit(0);
        }
        int A,B,C;
        A=(c+b)/2;
        B=(a+c)/2;
        C=(b+a)/2;
        a=A;
        b=B;
        c=C;
        cnt++;

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

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

using namespace std;

int calc ( int val, int tax )
{
	return val * ( 100 + tax ) / 100;
}

int main ( void )
{
	int x, y, s;
	while ( cin >> x >> y >> s, x | y | s ) {
		int ans = 0;
		for ( int i = 1; i < 1000; ++i ) {
			for ( int j = 1; j < 1000; ++j ) {
				if ( calc( i, x ) + calc( j, x ) == s ) {
					ans = max( ans, calc( i, y ) + calc( j, y ) );
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

int main(void) {
    multiset<pair<int, int>> albeits;
    priority_queue<int> pq;
    int n, m, i, a, b;
    uint64_t ans = 0;
    cin >> n >> m;
    for (i = 0; i < n; i++) {
        cin >> a >> b;
        albeits.insert({a,b});
    }

    auto it = albeits.begin();
    for (i = 1; i <= m; i++) {
        while (it != albeits.end() && it->first <= i) {
            pq.push(it->second);
            it++;
        }
        if (pq.size()) {
            ans += pq.top();
            pq.pop();
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 5628
N, K = map(int, input().split())

Sum = 0

for i in range(K, (N + 1) + 1):
    a = (((N - (i - 1)) + N) * i // 2) - ((i - 1) * i // 2) + 1
    #print(i,a,(((N  - (i - 1)) + N ) * i // 2),((i - 1) * i // 2))
    Sum = (Sum + a) % 1000000007

print(Sum)

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

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class itr, class func> void array_output(itr start, itr goal, func out = [](itr x) { return x; } ){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr, class func> void nint_output(itr start, itr goal, func out = [](itr x) { return x; } ){ string ans; for(auto i = start; i != goal; i++){ ans += string(out(*i)) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcount(n)

int main(){
    int a, b;
    while(cin >> a && cin >> b){
        cout << to_string(a + b).size() << endl;
    }
}



Measured memory_bytes: 3188
N = int(input())
A = [int(x) for x in input().split()]
ans = sum(A)

rep = dict()
for i in range(N):
    if A[i] in rep:
        rep[A[i]] += 1
    else:
        rep[A[i]] = 1

Q = int(input())
for i in range(Q):
    b, c = map(int, input().split())
    if b in rep:
        ans = ans - rep[b] * (b-c)
        print(ans)
        if c in rep:
            rep[c] += rep[b]
        else:
            rep[c] = rep[b]
        rep[b] = 0
    else:
        print(ans)

Measured memory_bytes: 20500
package main
 
import (
		"fmt"
)
 
func main() {
		var a string
		fmt.Scan(&a)
		ans := "Good"
		for i:=0;i<3;i++{
			if a[i:i+1] == a[i+1:i+2]{
				ans = "Bad"
			}
		}
		fmt.Println(ans)
}

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

int main()
{
	int n,a,max,beforMax=0,posMax=0;
	cin >> n;
	for (int i=0;i<n;i++){
		cin >> a;
		if(a>max){beforMax=max;
					 max = a;
					 posMax = i;
		}
		else if(a>beforMax) beforMax=a;
	}
	for (int i=0;i<n;i++){	
		if(i==posMax){cout <<beforMax<< endl;				
					}
		else cout <<max<< endl;
	}
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>

using namespace std;

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

    int max = 0;

    if (N > 1) {
        for (int k = 1; k < N; ++k) {

            int sum = 0;

            for (int i = 0; i < k; ++i) {
                sum += A1[i];
            }

            for (int i = k - 1; i < N; ++i) {
                sum += A2[i];
            }

            if (sum > max) {
                max = sum;
            }

        }
    } else {
        max = A1[0] + A2[0];
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
/* Author: shivangi0802 */

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define pb push_back
#define ll long long int
#define mod 1000000007
#define f(i,n) for(int i=0;i<n;i++)

using namespace std;

bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b);
 ll gcd(ll a, ll b) ;
 int prime(int n);

/*ll dp(ll k,ll n,vector<vector<ll> > a,vector<vector<ll> > &d){
if(n==0){
    return a[0][k];
}
else {
        if(d[n][k]==-1){
    if(k==0){
        d[n][k]= a[n][k] +max(dp(1,n-1,a,d),dp(2,n-1,a,d));
    }
    else if(k==1){
        d[n][k]= a[n][k] +max(dp(0,n-1,a,d),dp(2,n-1,a,d));
    }
    else if(k==2){
       d[n][k]= a[n][k] +max(dp(0,n-1,a,d),dp(1,n-1,a,d));
    }
}
return d[n][k];
}
}*/

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

    ll n,k;
    cin>>n;
  vector <vector <ll> >a(n,vector<ll> (3)),dp(n,vector<ll> (3));
  for(int i=0;i<n;i++){
    cin>>a[i][0]>>a[i][1]>>a[i][2];
    if(i>0){dp[i][0]= a[i][0]+max(dp[i-1][1],dp[i-1][2]);
     dp[i][1]= a[i][1]+max(dp[i-1][0],dp[i-1][2]);
      dp[i][2]= a[i][2]+max(dp[i-1][1],dp[i-1][0]);}
      else{
        dp[i][0]= a[i][0];
     dp[i][1]= a[i][1];
      dp[i][2]= a[i][2];
      }
  }
  cout<<max(max( dp[n-1][0], dp[n-1][1]), dp[n-1][2]);
}




bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int prime(int n){
    int flag=1;
for(int i=2;i<=sqrt(n);i++){
    if(n%i==0){flag=0;break;}
}
  return flag;
}




Measured memory_bytes: 11264
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
#import math
#import time
import random  # randome is not available at Codeforces
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
#eps=10**(-10)
#ts=time.time()
#sys.setrecursionlimit(10**6)
input=lambda: sys.stdin.readline().rstrip()

show_flg=False
show_flg=True

n=I()
a=sorted(LI())[::-1]

def solve(a):
    s=set()
    for i in a:
        s.add(i)
    s=sorted(list(s))[::-1]
    L=1010
    k=[0]*(L)
    ak=[0]
    for i in a:
        k[i]+=1
    for i in range(L):
        ak.append(ak[-1]+k[i])
    ans,a1,a2,a3,a4=0,0,0,0,0
    un=len(s)
    for i in range(un):
        c=s[i]
        if k[c]>=3:
            a1+=k[c]*(k[c]-1)*(k[c]-2)//6
        if k[c]>=2:
            a2+=ak[c]*k[c]*(k[c]-1)//2
        for j in range(i+1,un):
            sc=s[j]
            a3+=(1 if 2*sc>c else 0)*k[c]*k[sc]*(k[sc]-1)//2
            mm=c-sc+1
            if mm<0:
                continue
            elif mm>sc:
                break
            else:
                a4+=k[c]*k[sc]*(ak[sc]-ak[mm])
            
    ans=a1+a2+a3+a4
    return ans,a1,a2,a3,a4

def naive(a):
    b=sorted(a)[::-1]
    n=len(b)
    ans=0
    for i in range(n):
        for j in range(i+1,n):
            for k in range(j+1,n):
                if b[j]+b[k]>b[i]:
                    ans+=1
    return ans

print(solve(a)[0])


Measured memory_bytes: 4216
#include <stdio.h>
#include <algorithm>

int n,m;

int times(int A, int B, int C, int target)
{
    //printf("%d:%d:%d\n", A, B, C);
    if( B & 1 )
        return times(A>>1, B>>1, C>>1, -target) + 1 + times((A|B|C)>>1, 0, 0, 1);
        //return std::min(times(A>>1,B>>1,C>>1,-1), times(A>>1,B>>1,C>>1,1)) + 1 + times(((A|B|C)>>1) , 0, 0, 1);
    if( A & 1 )
        if( target == -1 )
            return times(A>>1, B>>1, C>>1, -1);
        else
            return times(A>>1, B>>1, C>>1, 1) + 1 + times(0, 0, ((A|B|C)>>1) , -1) + 1 + times(((A|B|C)>>1) , 0, 0, 1);
    if( C & 1 )
        if( target == 1 )
            return times(A>>1, B>>1, C>>1, 1);
        else
            return times(A>>1, B>>1, C>>1, -1) + 1 + times(((A|B|C)>>1), 0, 0, 1) + 1 + times(0, 0, ((A|B|C)>>1), -1);
    return 0;
}



int main(void)
{
    while(true)
    {
        int cups[3] = {0,0,0};

        scanf("%d%d",&n,&m);
        if(!n && !m) break;

        for(int i=0; i < 3; i++)
        {
            int c;
            scanf("%d", &c);
            for(int j=0; j < c; j++)
            {
                int t;
                scanf("%d", &t);
                cups[i] |= 1<<(t-1);
            }
        }

        int res = std::min(times(cups[0], cups[1], cups[2], -1), times(cups[0], cups[1], cups[2],  1));
        printf("%d\n", res <= m ? res : -1);
    }

    return 0;
}

Measured memory_bytes: 1028
#include<stdio.h>
#include<math.h>
int main()
{
    int n,i,j;
    scanf("%d",&n);
    int c=0;
for(i=1;i<=n;i+=2)
{
    int d=0;
    int x=sqrt(i);
    for(j=1;j<=x;j++)
    {
        if(i%j==0) d+=2;
    }
    if(d==8) c++;
}
printf("%d\n",c);
}



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

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

    int A[N];

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

    for(int i = 1; i < N - 1; i++){
        if(A[i - 1] < A[i] && A[i] < A[i + 1]){
            count++;
        }
        if(A[i - 1] > A[i] && A[i] > A[i + 1]){
            count++;
        }
    }
    
    cout << count << endl;
}


Measured memory_bytes: 256