akhauriyash/Code-Regression huggingface dataset:
import sys
import math
# import decimal
# import queue
# import bisect
# import heapq # priolity-queue
# import time
# import itertools
# import collections # queue
# from operator import itemgetter
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def main():
    s = list(input())
    s.sort()
    for i in range(len(s)-1):
        if s[i]==s[i+1]:
            print("no")
            return
    print("yes")
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
int main(){
    int n,i,j,ans=0;
    cin >> n;
    vector<int> h(n);
    for(i=0;i<n;i++) cin >> h.at(i);
    while(true){
        for(i=0;i<n;i++){
            if(h.at(i)==0) continue;
            for(j=i;j<n;j++){
                if(h.at(j)==0) break;
                h.at(j)--;
            }
            ans++;
            break;
        }
        if(i==n) break;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N + 1);
    for (int i = 0; i < N; i++) cin >> A[i];

    long long money = 1000, stock = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] < A[i + 1]) {
            stock += money / A[i];
            money %= A[i];
        } else if (A[i] > A[i + 1]) {
            money += stock * A[i];
            stock = 0;
        }
    }

    cout << money << endl;
}

Measured memory_bytes: 3648
import sys
input = sys.stdin.readline
from itertools import permutations
def main():
    t = [int(input()) for _ in range(5)]
    tp = permutations(t)
    ans = 1000*5
    for p in tp:
        total = 0
        for i,pi in enumerate(p):
            if i == 4:
                total += pi
                break
            a,b = divmod(pi,10)
            if b == 0:
                total += a*10
            else:
                total += a*10+10
        ans = min(ans,total)
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 38512
#include<iostream>

using namespace std;

int main(){
    char a;
    char ans;
    string S ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    cin >> a;
    for(int i = 0;i<52;i++){
        if(a == S[i]){
            if(i <=25){
                ans = 'A';
            }else{
                ans = 'a';
            }
        }
    }
    cout << ans;
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  int n = s.size();
  int ans = n;
  for(int i = 1; i < s.size(); i++){
    if(s[i] != s[i-1]){
      ans = min(ans, max(i, n-i));
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

using P = pair<ll, ll>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<P> kukan(n);
    // set<P> se;
    for(ll i = 0; i < n; i++) {
        ll x, l;
        cin >> x >> l;
        kukan[i] = P(x + l, x - l);
        // se.insert(kukan[i]);
    }
    sort(ALL(kukan));
    ll ans = 0;
    ll t = -LLINF;

    for(ll i = 0; i < n; i++) {
        if(t <= kukan[i].second) {
            ans++;
            t = kukan[i].first;
        }
    }

    cout << ans << endl;
}


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

public class Main{
  public static void main(String[] args) {
     Scanner in = new Scanner(System.in);
     String str = in.nextLine();
     if(str.charAt(2)==str.charAt(3) && str.charAt(4)==str.charAt(5)){
        System.out.println("Yes");
     }
     else 
        System.out.println("No");
  }
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	bool sw=true;
	ll n,a,b;
	cin>>n>>a>>b;
	if(b-a<=2){
		sw=false;
	}
	if(sw==false){
		cout <<n+1;
		return 0;
	}
	ll cnt=0,ans=1;
	while(cnt!=n){
		cnt++;
		if(n-cnt>=1&&ans>=a){
			cnt++;
			ans+=b-a;
		}
		else{
			ans++;
		}
	}
	cout <<ans;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;



int main() {
	while (true) {
		int a,b;cin>>a>>b;
		if(!a&&!b)break;
		int n=(b-a)/100;
		int man=n/10;
		n%=10;
		int go=n/5;
		n%=5;
		int iti=n;
		cout<<iti<<" "<<go<<" "<<man<<endl;
	}
	return 0;
} 

Measured memory_bytes: 3048
#include <iostream>
//#include <iomanip>
#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
//using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	int n ; cin >> n ;
	string s ; cin >> s ;
	int l,r ;
	l = r = 0 ;
	for(int i=0;i<n;i++){
		if(s.at(i)=='('){
			l++ ;
		}else{
			if(l>0) l-- ;
			else r++ ;
		}
	}
	for(int i=0;i<r;i++) cout << '(' ;
	cout << s ;
	l = r = 0 ;
	for(int i=n-1;i>=0;i--){
		if(s.at(i)=='('){
			if(r>0) r-- ;
			else l++ ;
		}else{
			r++ ;
		}
	}
	for(int i=0;i<l;i++) cout << ')' ;
	cout << endl ;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(){
	int N;
	cin >> N;
	char* S = (char*)calloc(N+1, sizeof(char));
	for(int i = 0; i < N; i++){
		cin >> S[i];
	}
	
	int count = 0;
	for(int i = 0; i < N-2; i++){
		if(S[i] == 'A'){
			if(S[i+1] == 'B'){
				if(S[i+2] == 'C'){
					count++;
				}
			}
		}
	}
	cout << count << endl;
	
}


Measured memory_bytes: 3608
#include<stdio.h>

int main(){

    int b,f,r,v,n,i,j,k;
    int house[4][3][10] = {0};

    scanf("%d", &n);
    for(i=0;i <n;i++){
	scanf("%d %d %d %d", &b,&f,&r,&v);
	house[b-1][f-1][r-1] += v;
    }
    for(i =0;i<4;i++){
	for(j=0;j<3;j++){
	    for(k=0;k<10;k++){
		printf(" %d",house[i][j][k]);
	    }
	printf("\n");
	}
	if(i != 3) printf("####################\n");
    }
    return 0;
}




Measured memory_bytes: 2052
a,b,c,d=map(int,input().split())

def gcd(x,y):
  if x<y:
    x,y=y,x
  while x%y!=0:
    x,y=y,x%y
  return y

def lcm(x,y):
  return x*y//gcd(x,y)

a_ans=(a-1)-(a-1)//c-(a-1)//d+(a-1)//lcm(c,d)
b_ans=b-b//c-b//d+b//lcm(c,d)
print(b_ans-a_ans)

Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a)
	fmt.Scan(&b)

	ans := 3
	if a*b == 3 {
		ans = 2
	} else if a*b == 6 {
		ans = 1
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
//ALDS1-1-C: Prime Numbers
//2019.05.24

#include <stdio.h>
#include <math.h>

int main(void){
  int n, number;
  int sqrt_number;
  int num_prime = 0;
  int flag;

  scanf("%d\n", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d\n", &number);
    sqrt_number = sqrt(number);
    flag = 1;
    for (int j = 2; j < sqrt_number+1; j++) {
      if (number%j == 0) {
        flag = 0;
        break;
      }
    }
    if (flag == 1) num_prime++;
  }

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

  return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h> 
#include<iostream>
using namespace std; 
string lcs(string s, string t)
{
	int m = s.size(), n= t.size();
	vector<vector<int> > dp(m+1, vector<int>(n+1));
	for(int i=0;i<= m;i++)
	{
		for(int j=0;j<=n;j++)
		{
			if(i==0|| j==0) dp[i][j] = 0;
			else if(s[i-1]==t[j-1]) dp[i][j] = 1+dp[i-1][j-1];
			else dp[i][j] = max(dp[i][j-1] ,dp[i-1][j]);
		}
	}	
	string res  = "";
	int i = m, j= n;
	while(i>0 && j>0)
	{
		if(s[i-1]==t[j-1])
		{
			res.push_back(s[i-1]);
			i--;
			j--;
		}
		else if(dp[i-1][j] > dp[i][j-1])
		{
			i--;
		}		
		else
		{
			j--;
		}
	}
	reverse(res.begin(),res.end());
	return res;
}
int main()
{
	string s,t;
	cin>>s>>t;
	cout<<lcs(s,t)<<endl; 
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPE(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void chmax(T& a, T b) { if(a > b) a = b; }
template<class T> void chmin(T& a, T b) { if(a < b) b = a; }
typedef long long ll;

int main() {
    int n, m; cin >> n >> m;
    vector<vector<int> > v(m);
    rep(i, m){
        int k; cin >> k;
        v[i].resize(k);
        rep(j, k){
            cin >> v[i][j];
            v[i][j]--;
        }
    }
    vector<int> p(m);
    rep(i, m) cin >> p[i];

    int ans = 0;
    for(int bit = 0; bit < (1 << n); bit++){
        bool flag = true;
        for(int j = 0; j < m; j++){
            int cnt = 0;
            for(int k : v[j]){
                if(bit & (1 << k)) {
                    cnt++;
                }
            }
            cnt %= 2;
            if(cnt != p[j]){
                flag = false;
                break;
            }
        }
        if(flag) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val m = sc.nextInt()

  val ac = mutableMapOf<Int, Int>()
  val wa = mutableMapOf<Int, Int>()
  for (i in 0 until m) {
    val pi = sc.nextInt()
    val si = sc.next()
    if (ac.containsKey(pi)) {
      continue
    } else {
      when (si) {
        "AC" -> ac[pi] = 1
        "WA" -> wa[pi] = wa[pi]?.plus(1) ?: 1
      }
    }
  }
  println("${ac.values.sum()} ${wa.filter { ac.containsKey(it.key) }.values.sum()}")
}

Measured memory_bytes: 71784
N = int(input())
a = list(map(int, input().split()))
a_set = set(a)
if len(a_set) == 1:
    if a_set == {0}:
        print('Yes')
    else:
        print('No')
elif len(a_set) == 2:
    a_set = list(a_set)
    a0 = a.count(a_set[0])
    a1 = a.count(a_set[1])
    if N % 3 == 0 and (a0 == 2 * a1 or a1 == 2 * a0) and 0 in a_set:
        print('Yes')
    else:
        print('No')
elif len(a_set) == 3:
    a_set = list(a_set)
    flag = 0
    if a.count(a_set[0]) == a.count(a_set[1]) and a.count(a_set[0]) == a.count(a_set[2]):
        flag = 1
    if N % 3 == 0 and flag == 1 and a_set[0] ^ a_set[1] == a_set[2]:
        print('Yes')
    else:
        print('No')
else:
    print('No')


Measured memory_bytes: 14212
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		
		if (b - a + 1 <= k * 2) {
			for (int i = a; i <= b; i++) {
				System.out.println(i);
			}
		} else {
			for (int i = a; i < a + k; i++) {
				System.out.println(i);
			}
			
			for (int i = b - k + 1; i <= b; i++) {
				System.out.println(i);
			}
		}
		
	}
}

Measured memory_bytes: 21844
#include <cstdio>

using namespace std;

double max = 0, min = 1000000000;

signed main()
{
    double index;
    while( scanf( "%lf\n", &index ) != EOF )
    {
        if( max < index ) 
        {
            max = index;
        }
        if( index < min )
        {
            min = index;
        }
    }

    printf( "%.1lf\n", max - min );
    return 0;
}


Measured memory_bytes: 2580
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cassert>
#include<random>
#include<fstream>
#include<chrono>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define ld           long double
#define pii          pair<int,int>
#define vi           vector<int>
#define pb           push_back
#define mp           make_pair
#define ff           first
#define ss           second
#define endl         '\n'
#define rep(i,s,e)   for(int i=(s);i<=(e);i++)
#define brep(i,s,e)  for(int i=(s);i>=(e);i--)
#define all(x)       (x).begin(),(x).end()
#define ball(x)      (x).rbegin(),(x).rend()
#define sz(x)        (int)x.size()
#define mem(x,y)     memset(x,y,sizeof(x))
#define VR46         ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);ifstream fin("ip.txt");ofstream fout("op.txt");
#define milf(x)      x.reserve(1LL<<14LL); x.max_load_factor(0.25); // less_equal
#define pbds         tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
mt19937              rng(chrono::steady_clock::now().time_since_epoch().count());
#define int          long long
const int INF = 0x3F3F3F3F3F3F3F3F;
const int MOD = 1e9+7;
ld EPS = 1e-12;

const int N = 1e5 + 5;
int n, k, a[N], dp[N];

int REC(int id)
{
    if( id>=n-1 )
        return 0;
    if( dp[id]!=-1 )
        return dp[id];
    int ans = INF;
    rep(i,1,k)
    {
        if( id+i >= n )
            break;
        ans = min( ans, REC( id+i ) + abs( a[id]-a[id+i] ) );
    }
    dp[id] = ans;
    return ans;
}

signed main()
{
    VR46 // DONT USE DEQUE IF NOT NECESSARY
    // int t;cin>>t;rep(test,1,t)
    {
        cin >> n >> k;
        rep(i,0,n-1)
            cin >> a[i];
        mem( dp, -1 );
        cout << REC( 0 ) << endl;
    }
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

int A, B;

ll GCD(ll x, ll y) {
    if (x > y) swap(x, y);
    while (x) {
        ll z = x;
        x = y%x;
        y = z;
    }
    return y;
}

ll LCM(ll x, ll y) {
    ll g = GCD(x, y);
    return x / g * y;
}
int main() {
    cin >> A >> B;
    cout << LCM(A, B) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <complex>

using namespace std;

#define mod 1000000007

vector<pair<int, int> > place;
vector<vector<int> > x(100010), y(100010);
vector<int> groupnum(40010, -1);
vector<int> groupsize;
vector<vector<bool> > isclosetowall;
vector<bool> ischecked_x(100010, false), ischecked_y(100010, false);

int main()
{
	int n, w, h;
	cin >> n >> w >> h;
	// cout << __LINE__ <<endl;
	for(int i = 0; i < n; i++){
		int tmpx, tmpy;
		cin >> tmpx >> tmpy;
		place.push_back(make_pair(tmpx, tmpy));
		x[tmpx].push_back(i);
		// cout << y.size() << " " << tmpy << endl;
		y[tmpy].push_back(i);
		// cout << __LINE__ << endl;
		// cout << i << endl;
	}
	int cnt = 0;
	for(int i = 0; i < n; i++){
		if(groupnum[i] < 0){
			// cout << i << endl;
			queue<int> qu;
			qu.push(i);
			groupnum[i] = cnt;
			isclosetowall.push_back(vector<bool>(4, false));
			groupsize.push_back(1);
			while(!qu.empty()){
				int now = qu.front();
				int nowx = place[now].first;
				int nowy = place[now].second;
				qu.pop();
				// cout << now << " " << " " << nowx << " " << nowy << " " << ischecked_x[nowx] << " " << ischecked_y[nowy] << endl;
				if(nowx == 1) isclosetowall[cnt][0] = true;
				if(nowx == w) isclosetowall[cnt][1] = true;
				if(nowy == 1) isclosetowall[cnt][2] = true;
				if(nowy == h) isclosetowall[cnt][3] = true;
				if(!ischecked_x[nowx]){
					ischecked_x[nowx] = true;
					for(int j = 0; j < x[nowx].size(); j++){
						int nowindex = x[nowx][j];
						int tmpy = place[nowindex].second;
						if(nowindex == now || ischecked_y[tmpy]) continue;
						groupnum[nowindex] = cnt;
						groupsize[cnt]++;
						qu.push(nowindex);
					}
				}
				// x.erase(x.begin() + nowx);
				if(!ischecked_y[nowy]){
					ischecked_y[nowy] = true;
					for(int j = 0; j < y[nowy].size(); j++){
						int nowindex = y[nowy][j];
						int tmpx = place[nowindex].first;
						if(nowindex == now || ischecked_x[tmpx]) continue;
						groupnum[nowindex] = cnt;
						groupsize[cnt]++;
						qu.push(nowindex);
					}
				}
				// y.erase(y.begin() + nowy);
				// cout << now << " " << groupsize[cnt] << endl;
			}
			cnt++;
		}
		// cout << i << " " << groupnum[i] << " " << groupsize[groupnum[i]] << endl;
	}
	int sum = 0;
	for(int i = 0; i < cnt; i++){
		sum += groupsize[i] - 1;
	}
	if(cnt == 1){
		cout << sum << endl;
		return 0;
	}
	int ans = mod;
	for(int i = 0; i < 4; i++){
		int needtomove = 0;
		for(int j = 0; j < cnt; j++){
			if(!isclosetowall[j][i]) needtomove++;
		}
		// cout << sum + needtomove + cnt - 1 << endl;
		ans = min(ans, sum + needtomove + cnt - 1);
	}
	cout << ans << endl;
}


Measured memory_bytes: 12388
#include<bits/stdc++.h>
#define for_int(i,a,b) for(int i=(a);i<=(b);++i)
#define rep_int(i,a,b) for(int i=(a);i>=(b);--i)
#define for_ll(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i)
#define ull unsigned long long
#define ll long long
#define db double
#define HPMAX 1005
#define KMP_MAX 1005
#define prime_MAX 1e6+5
#define quick_pow_mod 1e9+7
#define PII pair<int,int>
using namespace std;
//快读
int read() {
	char c = getchar();
	int x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (; isdigit(c); c = getchar())
		x = x * 10 + c - 48;
	return x * f;
}
int main() {
	string s;
	cin >> s;
	if (s.size() == 3)
		cout << s << endl;
	else {
		string ss;
		ss.assign(s, 0, 3);
		cout << ss << endl;
	}
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
//int COUNTDIV(int n) 素因数分解して+1してかける奴
int COUNTDIV2(int n) {
	int ans = 0;
	REP(i, n) {
		if (n % i == 0)
			ans++;
	}
	return ans;
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR (int x) {
	if (x ==1)
		return false;
	if (x == 2)
		return true;
	if (x%2==0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}

using namespace std;
#pragma endregion
signed main() {
	int N, K, ans = 1;
	cin >> N >> K;
	rep(i, N) {
		if (ans * 2 > ans + K)
			ans += K;
		else
			ans *= 2;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100005
#define NIL -1
void setDepth(int, int);
void print(int);

struct Node{
  int p;
  int l;
  int r;
};

struct Node T[MAX];
int D[MAX];


int main(){
  int n, i, id, k, j, c, x, r;
  scanf("%d",&n);
  
  for(i=0; i<n; i++){
    T[i].p=NIL;
    T[i].l=NIL;
    T[i].r=NIL;
  }

  for(i=0; i<n; i++){
    scanf("%d%d",&id, &k);

    for(j=0; j<k; j++){
        scanf("%d",&c);
        if(j == 0) T[id].l=c;
        else T[x].r=c;
        x=c;
        T[c].p=id;
    }
  }

  for(i=0; i<n; i++){
    if(T[i].p == NIL) r=i;
  }

  setDepth(r, 0);

  for(i=0; i<n; i++) print(i);

  return 0;
}

void setDepth(int u, int d){
  D[u] = d;
  if(T[u].r != NIL) setDepth(T[u].r, d);
  if(T[u].l != NIL) setDepth(T[u].l, d+1);
}

void print(int u){
  int i;

  printf("node %d: parent = %d, depth = %d, ",u,T[u].p,D[u]);
  
  if(T[u].p == NIL) printf("root, ");
  else if(T[u].l == NIL) printf("leaf, ");
  else printf("internal node, ");
  
  printf("[");

  if(T[u].l == NIL) printf("]\n");
  
  else {
    for(i = T[u].l; T[i].r != NIL; i = T[i].r) printf("%d, ",i);
    printf("%d]\n",i);
  }
}


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

int main() {
  ll N, A, B;
  cin>>N>>A>>B;
  if(N==1) {
    if(A==B) cout<<1<<endl;
    else cout<<0<<endl;
  }
  else {
    if(A<=B) cout<<(N-2)*(B-A)+1<<endl;
    else cout<<0<<endl;
  }
}



Measured memory_bytes: 3568
#include <iostream>
using namespace std;
int main(void){
    int n, k;
    bool u[10];
    cin >> n >> k;
    fill(u, u+10, true);
    for(int i=0;i<k;i++){
        int d;
        cin >> d;
        u[d] = false;
    }
    for(int i=n;;i++){
        int x = i;
        bool flg = true;
        while(x > 0){
            if(!u[x%10]){
                flg = false;
                break;
            }
            x /= 10;
        }
        if(flg){
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cstring>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <cstdlib>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
typedef long long int ll;
#define forn for(int i=0;i<n;i++) 
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define form for(int j=0;j<m;j++) 
#define fora(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define mp make_pair 
#define sc second 
#define f first 
#define kek cout<<"\n" 
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
const ll MOD = 1e9 + 7;
const int N = 1005;
const ll INF = 1e9;
using namespace std;
int main()
{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fast;
	//string al = "abcdefghijklmnopqrstuvwxyz";
	string s;
	cin >> s;
	sort(all(s));
	if (s[0] == s[2]) cout << "No";
	else cout << "Yes";
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
	int n;
	long long m,a,c,res,act;
	cin>>n>>m;
	vector<long long> lista,ele;
	lista.assign(50,0);
	for(int i=0;i<n;i++){
		cin>>a;
		ele.push_back(a);
		c=1;
		for(int j=0;j<50;j++){
			if(a&c) lista[j]++;
			else lista[j]--;
			c=(c<<1);
		}
	}
	int mp=0;
	long long k=1;
	for(int i=0;i<50;i++){
		if(m&(k<<i)) {
			mp=i;
		}
	}
	long long ans=0,aux=0;
	for(int i=mp;i>-1;i--){
		if(lista[i]<0) {
			aux=aux|(k<<i);
			if(aux<=m) ans=aux;
			aux=ans;
		}
	}
	res=0;
	for(int i=0;i<n;i++){
		res+=(ele[i]^ans);
	}
	cout<<res<<endl;
	return 0;
}

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

class Program
{
    public static void Main()
    {
        var val = Console.ReadLine().Split(' ');
        int a, p;
        a = int.Parse(val[0]);
        p = int.Parse(val[1]);
        Console.WriteLine((a * 3 + p) / 2);
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define For(i,a,b) for(ll i=a;i<b;i++)
#define rFor(i,a,b) for(ll i=a;i>b;i--)
#define wFor(i,a,b) for(ll i=a;i<b;i+=2)
#define wrFor(i,a,b) for(ll i=a;i>b;i-=2)
#define sort(a,b) sort(a.begin(),b.end())
#define reverse(a,b) reverse(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//(char-'0') 数字に変換
//vector<vector<int>> data(a,vector<int>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j)  a×b行列の入力
//floor(log10(a)+1) aの10進法での桁数
//ceil(log10(a)) aの10進法での桁数

int main() {
  ll a;
  ci(a);
  vector<string> b(a);
  For(i,0,a){
    ci(b[i]);
    sort(b[i],b[i]);
  }
  sort(b,b);
  ll an=0;
  ll ans=0;
  For(i,1,a){
    if(b[i-1]==b[i]){
      an++;
      ans++;
    }
    else{
      For(j,0,ans)
        an+=j;
      ans=0;
    }
  }
  if(ans>1)
    For(i,0,ans)
      an+=i;
  co(an);
}

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

int main() {
    int n, l;
    cin >> n >> l;
    string s[n];
    rep(i, n) cin >> s[i];
    sort(s, s + n);

    rep(i, n) cout << s[i];
    cout << endl;
    return 0;
}


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

int main()
{
    int a,b;
    cin>>a>>b;
    if(a>=0 && a<=5)
        cout<<0<<endl;
    else if(a>=6 && a<=12)
        cout<<b/2<<endl;
    else
        cout<<b<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;
ll min_r[9] = {1, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200};
ll max_r[9] = {399, 799, 1199, 1599, 1999, 2399, 2799, 3199, 4800};

int main() {
  ll N;
  cin >> N;
  ll a;
  map<int, int> m;
  for (int i = 0; i < N; i++) {
    cin >> a;
    for (int i = 0; i < 9; i++) {
      if (min_r[i] <= a && a <= max_r[i]) m[i]++;
    }
  }
  ll ans = 0;
  for (auto p : m) {
    ans++;
  }
  ll max_ans;
  ll min_ans;
  if (m[8]) {
    ans--;
    min_ans = ans;
    max_ans = ans + m[8];
  } else {
    min_ans = ans;
    max_ans = ans;
  }
  cout << max(min_ans, 1LL) << " " << max_ans << endl;
  return 0;
}

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


int main()
{

string a,b;
cin >> a >> b;
a+=b;
ll val = 0 ;
for(int i=0; i<a.size(); i++)
{
    val  = val*10 + (a[i]-'0');
}
ll v = sqrt(val);
//cout << val;
if(v*v==val)
{
    cout << "Yes" << endl;
}
else cout << "No" << endl;

}


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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

const int MAX = 53;
int W, H;
int field[MAX][MAX];

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


void dfs(int x, int y) {
  field[x][y] = 0;

  rep(i,8) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if (nx < 0 || H <= nx) continue;
    if (ny < 0 || W <= ny) continue;
    if (field[nx][ny] == 0) continue;
    dfs(nx, ny);
  }
}

int main() {
  vector<int> ans;
  while (true) {
    int cnt = 0;
    cin >> W >> H;
    if (W == 0 && H == 0) break;
    rep(i,H) rep(j,W) cin >> field[i][j];
    
    rep(i,H) rep(j,W) {
      if (field[i][j] == 1) {
	dfs(i, j);
	cnt++;
      }
    }
    ans.push_back(cnt);
  }
  rep(i,ans.size()) {
    cout << ans[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 3192
import java.util.*;
import java.lang.*;

public class Main {
	static int n;
	static int m;
	static int[][] result;
	static int count;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			n = sc.nextInt();
			if (n == 0) {
				System.exit(0);
			}
			m = sc.nextInt();
			result = new int[n][n];
			for (int i = 0; i < m; i++) {
				int x = sc.nextInt() - 1;
				int y = sc.nextInt() - 1;
				result[x][y] = 1;
				result[y][x] = -1;
			}
			count = 0;
			dfs(0, 1);
			System.out.println(count);
		}
	}
	static void dfs(int x, int y) {
		if (y == n) {
			int sum = 0;
			for (int i = 0; i < n; i++) {
				sum += result[x][i];
			}
			if (sum == 0) {
				if (x < n - 1) {
					dfs(x + 1, x + 2);
				} else {
					count++;
				}
			}
			return;
		}
		if (x == y || result[x][y] != 0) {
			dfs(x, y + 1);
		} else {
			result[x][y] = 1;
			result[y][x] = -1;
			dfs(x, y + 1);
			result[x][y] = -1;
			result[y][x] = 1;
			dfs(x, y + 1);
			result[x][y] = 0;
			result[y][x] = 0;
		}
	}
}




Measured memory_bytes: 32924
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
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 = 1000000000;

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

    if(a == c){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N 200000
int n;
long long tot;
int l,r;
int a[N+1];
int x[N+1];
long long s[N+1];
int main(int argc,char *argv[]){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		s[i]=s[i-1]+a[i];
		x[i]=x[i-1]^a[i];
	}
	int r=1;
	for(int i=1;i<=n;i++){
		r=max(r,i);
		while(r+1<=n && s[r+1]-s[i-1]==(x[r+1]^x[i-1]))	r++;
		tot+=r-i+1;
	}
	printf("%lld",tot);
	return 0;
}

Measured memory_bytes: 3328
import java.util.*;

public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    Integer[] arr = new Integer[N];
    for (int i = 0; i < N; i++) {
      arr[i] = sc.nextInt();
    }

    Arrays.sort(arr, Comparator.reverseOrder());
    int ans = 0;
    for (int i = 0; i < K; i++) {
      ans += arr[i];
    }

    System.out.println(ans);
  }
}

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

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

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

ll gcd(ll a, ll b)
{
    return (a < b) ? gcd(b, a) : ((a % b) ? gcd(b, a % b) : b);
}

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

ll powmod(ll x, ll p, ll m)
{
    if (p == 0)
        return 1;
    if (p & 1)
        return powmod(x, p - 1, m) * x % m;
    ll r = powmod(x, p / 2, m);
    return r * r % m;
}

constexpr ll MOD = 1000000007;

int main()
{
    ll N, M;
    cin >> N >> M;
    llvv tree(N * 3);
    rep(i, M)
    {
        ll u, v;
        cin >> u >> v;
        ll U = u - 1;
        ll V = v - 1;
        tree[N * 0 + U].push_back(N * 1 + V);
        tree[N * 1 + U].push_back(N * 2 + V);
        tree[N * 2 + U].push_back(N * 0 + V);
    }

    ll S, T;
    cin >> S >> T;

    queue<ll> q;
    q.push(N * 0 + S - 1);
    constexpr ll INF = 1 << 30;
    llv dist(N * 3, INF);
    dist[N * 0 + S - 1] = 0;
    while (0 < q.size())
    {
        ll e = q.front();
        q.pop();
        foreach (f, tree[e])
        {
            if (dist[e] + 1 < dist[f])
            {
                q.push(f);
                dist[f] = dist[e] + 1;
            }
        }
    }
    cout << (dist[N * 0 + T - 1] == INF ? -1 : dist[N * 0 + T - 1] / 3)
         << endl;

    return 0;
}


Measured memory_bytes: 18944
#include <stdio.h>
#include <math.h>

int main(void)
{
  int i, j, n;
  
  scanf("%d", &n);
  
  i = ( n / 10 ) % 10;
  
  j = n / 100;
  
  if( n % 10 == 7 ){
    printf("Yes\n");
    return 0;
  }
  if( i == 7 ){
    printf("Yes\n");
    return 0;
  }
  if( j == 7 ){
    printf("Yes\n");
    return 0;
  }
  
  printf("No\n");
  return 0;
}

Measured memory_bytes: 1640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            char[] s = in.next().toCharArray();
            int n = s.length + 1;

            int[] a = new int[n];
            Arrays.fill(a, -1);
            for (int i = 0, j = 0; i < n - 1; i = j) {
                while (j < n - 1 && s[i] == s[j])
                    j++;

                if (s[i] == '<') {
                    for (int k = i; k <= j; k++) {
                        a[k] = k - i;
                    }
                } else {
                    for (int k = i; k <= j; k++) {
                        a[k] = Math.max(a[k], j - k);
                    }
                }
            }

            long answer = 0;
            for (int x : a) {
                answer += x;
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 29396
X = int(input())
if 400 <= X < 600:
  print(8)
elif 600 <= X < 800:
  print(7)
elif 800 <= X < 1000:
  print(6)
elif 1000 <= X < 1200:
  print(5)
elif 1200 <= X < 1400:
  print(4)
elif 1400 <= X < 1600:
  print(3)
elif 1600 <= X < 1800:
  print(2)
elif 1800 <= X < 2000:
  print(1)

Measured memory_bytes: 9184
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
	ll tmp = 1;
	REP(i, b) tmp *= a;
	return tmp;
}

int N, M;
int A[100010];
priority_queue<int> p;
ll ans = 0;

int main() {
	cin >> N >> M;
	REP(i, N) {
		int tmp;
		cin >> tmp;
		p.push(tmp);
	}
	REP(i, M) {
		p.push(p.top() / 2);
		p.pop();
	}
	REP(i, N) {
		ans += p.top();
		p.pop();
	}
	cout << ans << endl;
}

Measured memory_bytes: 892
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder {
  public class Program {
    public static void Main (string[] args) {
      new Program ().Solve (new ConsoleInput (Console.In, ' '));
    }
    public void Solve (ConsoleInput cin) {
      var n = cin.ReadInt;
      var sequence = cin.ReadIntArray (n);
      var x = new int[0];
      int b = 0;
      for (int i = 0; i < sequence.Length; ++i) {
        if (sequence[i] % 2 == 0) {
          Array.Resize (ref x, i + 1);
          x[i] += sequence[i];
        }
      }

      for (int k = 0; k < x.Length; ++k) {
        if (x[k] % 3 == 0 || x[k] % 5 == 0) {
          b += 0;
        } else {
          b += 1;
        }
      }

      if (b == 0) {
        WriteLine ("APPROVED");

      } else {
        WriteLine ("DENIED");
      }
    }
  }

  public class ConsoleInput {
    private readonly System.IO.TextReader _stream;
    private char _separator = ' ';
    private Queue<string> inputStream;
    public ConsoleInput (System.IO.TextReader stream, char separator = ' ') {
      this._separator = separator;
      this._stream = stream;
      inputStream = new Queue<string> ();
    }
    public string Read {
      get {
        if (inputStream.Count != 0) return inputStream.Dequeue ();
        string[] tmp = _stream.ReadLine ().Split (_separator);
        for (int i = 0; i < tmp.Length; ++i)
          inputStream.Enqueue (tmp[i]);
        return inputStream.Dequeue ();
      }
    }
    public string ReadLine { get { return _stream.ReadLine (); } }
    public int ReadInt { get { return int.Parse (Read); } }
    public long ReadLong { get { return long.Parse (Read); } }
    public double ReadDouble { get { return double.Parse (Read); } }
    public string[] ReadStrArray (long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
    public int[] ReadIntArray (long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
    public long[] ReadLongArray (long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
  }
}

Measured memory_bytes: 13268
#include <cstdio>
#include <set>
#include <map>
#include <queue>

using namespace std;

int main() {
    int n, ans = 0, i;
    map <int, int> mp;
    map <int, set <int>> mp2;
    map <int, int>::iterator it;
    map <int, set <int>>::iterator it2;
    priority_queue <pair<int, int>> q;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        int x;
        
        scanf("%d", &x);
        
        mp[x]++;
    }
    
    for (it = mp.begin(); it != mp.end(); it++) {
        int x = it->first;
        
        for (i = 1; i - x <= 1e9; i *= 2) {
            if (i <= x) continue;
            
            if (mp.count(i - x)) {
                if (x * 2 == i) {
                    if (it->second >= 2) mp2[x].insert(x);
                } else {
                    mp2[x].insert(i - x);
                }
            }
        }
    }
    
    for (it2 = mp2.begin(); it2 != mp2.end(); it2++) {
        if (it2->second.size() == 0) continue;
        
        q.push(make_pair(-it2->second.size(), it2->first));
    }
    
    while (!q.empty()) {
        int x = q.top().second;
        int y = -q.top().first;
        int z;
        
        q.pop();
        
        if (mp2[x].size() != y) continue;
        if (y != 1) continue;
        
        z = *mp2[x].begin();
        
        if (x == z) {
            ans += mp[x] / 2;
        } else {
            int p = min(mp[x], mp[z]);
            
            ans += p;
            mp[z] -= p;
            
            mp2[z].erase(x);
            q.push(make_pair(-mp2[z].size(), z));
        }
    }
    
    printf("%d\n", ans);
    
    return 0;
}


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

int main(void) {
    int a,b;
    char op;
    for (;;) {
        cin >> a >> op >> b;
        if (op=='?') break;
        int r;
        switch (op) {
            case '+':
                r = a + b;
                break;
            case '-':
                r = a - b;
                break;
            case '*':
                r = a * b;
                break;
            case '/':
                r = a / b;
                break;
            default:
                r = 0;
                break;
        }
        cout << r << endl;
    }
    return 0;
}

Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>
#include <cassert>
#include <ctime>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define all(x) (x).begin(), (x).end()

#ifdef LOCAL
#define dbg(x) cerr << #x " = " << x << endl;
#define idbg(x) #x " = " << x
#include "pretty_print.h"
#else
#define dbg(x)
#define idbg(x) ""
#endif

#ifdef _WIN32
#  define LLD "%I64d"
#else
#  define LLD "%lld"
#endif

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

template <typename T> T sqr(T x) { return x * x; }
template <typename T> T abs(T x) { return x < 0? -x : x; }
template <typename T> T gcd(T a, T b) { return b? gcd(b, a % b) : a; }
template <typename T> bool chmin(T &x, const T& y) { if (x > y) { x = y; return true; } return false; }
template <typename T> bool chmax(T &x, const T& y) { if (x < y) { x = y; return true; } return false; }

int main(int /* argc */, char** /* argv */)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef LOCAL
    assert(freopen("inp", "r", stdin));
    assert(freopen("out", "w", stdout));
    #endif

    string s;
    int k;
    while (cin >> s >> k) {
        const int MOD = 998244353;
        int n = s.size();
        vector<vector<vector<int>>> f(n + 2, vector<vector<int>>(n + 2, vector<int>(n + 2, 0)));
        f[0][0][0] = 1;
        k = min(k, n);
        auto addmod = [&](int& x, const int d) {
            x += d;
            if (x >= MOD) {
                x -= MOD;
            }
            if (x < 0) {
                x += MOD;
            }
        };

        vector<int> a(n + 1, 0);
        for (int i = n; i >= 0; --i) {
            a[i] = s[i] == '1'? 1 + a[i + 1] : 0;
        }
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j <= k; ++j) {
                for (int d = 0; d <= k; ++d) {
                    if (!f[i][j][d]) {
                        continue;
                    }

                    addmod(f[i + 1][j][d], f[i][j][d]);
                    if (s[i] == '0') {
                        addmod(f[i][j + 1][d + 1], f[i][j][d]);
                    } else {
                        int x = i + a[i];
                        if (x < n && a[i] <= d) {
                            addmod(f[x + 1][j][d - a[i]], f[i][j][d]);
                        }
                    }
                }
            }
        }
        int ans = 0;
        for (int j = 0; j <= k; ++j) {
            for (int d = 0; d <= k; ++d) {
                if (a[n - d] == d) {
                    addmod(ans, f[n - d][j][d]);
                }
            }
        }
        cout << ans << "\n";
    }

    cerr << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec" << endl;
    return 0;
}


Measured memory_bytes: 114068
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

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;}

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  vector<int> a(3);
  rep(i,3) cin >> a[i];
  sort(a.begin(), a.end());
  int ans = 0;
  REP(i,3){
    ans += abs(a[i] - a[i-1]);
  }
  cout << ans << endl;
}






Measured memory_bytes: 256