akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long  gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

/*
int struct_ascending_compare(const void *p, const void *q) {
    return ((struct_name*)p)->member_name - ((struct_name*)q)->member_name;
}*/
int long long a[100005];

int main(void){
    long long n;
    long long x;
    long long ans = 0;
    scanf("%lld %lld", &n, &x);
    for (int i = 0; i < n; i++){
        scanf("%lld", &a[i]);
    }

    for (int i = 1; i < n; i++){
        if (a[i] + a[i-1] > x){
            ans += (a[i] + a[i-1]) - x;
            a[i] = a[i] - ((a[i] + a[i-1]) - x) < 0 ? 0:a[i] - ((a[i] + a[i-1]) - x);
        }
    }

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

}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long n;
	vector<char>v;
	cin>>n;
	while(1)
	{
		n--;
		int i = n%26;
		n/=26;
		v.push_back('a'+i);
		if(!n)break;
	}
	reverse(v.begin(),v.end());
	for(char c:v)cout<<c;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;
int a[100005];
int main()
{
    int N, x;
    while(scanf("%d%d", &N, &x)!=EOF)
    {
        for(int i=1; i<=N; i++)
            scanf("%d", &a[i]);
        long long int sum=0;
        int last = 0;
        for(int i=1; i<=N; i++)
        {
            if(last+a[i]<=x)
                last = a[i];
            else
            {
                sum+=last+a[i]-x;
                last=a[i]-(last+a[i]-x);
            }
        }
        printf("%lld\n", sum);
        return 0;
    }
}

/*


#define N 100009
using namespace std;
const int INF = 0x3f3f3f3f;
int a[N];
int main()
{
    int n, x;
    scanf("%d%d", &n, &x);
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
    long long ans, now; ans = now = 0;
    for(int i = 1; i <= n; i++)
    {
        if(now + a[i] <= x)
        now = a[i];
        else
            ans += now + a[i] - x, now = a[i] - (now + a[i] - x);
    }
    printf("%lld\n", ans);
    return 0;
}
*/


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

int main() {
    string S;
    cin >> S;
    if (S == "SSS") {
        cout << 0 << endl;
    } else if (S == "RRR") {
        cout << 3 << endl;
    } else if (S == "RRS" || S == "SRR") {
        cout << 2 << endl;
    } else {
        cout << 1 << endl;
    }

}


Measured memory_bytes: 3588
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		int a;

		Scanner sc = new Scanner(System.in);

		a = sc.nextInt();

		String[] ArrayA = new String[a];
		HashMap<String, Integer> hm = new HashMap<>();

		for(int i = 0; i < ArrayA.length; i++) {
			String b = sc.next();
			char[] c = b.toCharArray();
			Arrays.sort(c);
			hm.put(String.valueOf(c), hm.getOrDefault(String.valueOf(c), 0) + 1);
		}

		long ans = 0;
		for (String s : hm.keySet()) {
			ans += nc2(hm.get(s));
		}

		System.out.println(ans);
	}

	private static long nc2(long x) {
		return (x * (x - 1)) >> 1;
	}


}


Measured memory_bytes: 59932
n, q = map(int, input().split())
s = input()

t = [0 for i in range(len(s))]
count = 0
for j in range(len(s)-1):
    if s[j] == "A" and s[j+1] == "C":
        count += 1
    t[j+1] = count

for k in range(q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])
        
            


Measured memory_bytes: 6180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, m;
string s, t;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> s >> t;
	n = s.size();
	m = t.size();
	string ans = "UNRESTORABLE";
	if(m <= n){
		rep(i, 0, n-m){
			string sd = s;
			bool f = true;
			rep(j, 0, m-1){
				if(sd[i+j] == '?'){
					sd[i+j] = t[j];
				}
				else{
					if(sd[i+j] != t[j]){
						f = false;
					}
				}
			}
			if(f){
				rep(i, 0, n-1){
					if(sd[i] == '?'){
						sd[i] = 'a';
					}
				}
				if(ans == "UNRESTORABLE" || sd < ans){
					ans = sd;
				}
			}
		}
	}
	print(ans)
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
    ll N;
    cin >> N;
    vector<ll> a(N);
    vector<bitset<30>> A(N);
  	cin >> a.at(0);
  	bitset<30> b(a.at(0));
    A.at(0)= b;
  	bitset<30> xo=b;
    for(ll i=1; i<N; i++){
        cin >> a.at(i);
        bitset<30> b(a.at(i));
        A.at(i)= b;
        xo = xo^b;
    }
    vector<bitset<30>> ans(N);
    for(ll i=0; i<30; i++){
        bool which;
        if(xo[i]==1) which = false;
        else which = true;
        for(ll j=0; j<N; j++){
            if(which){
                ans.at(j)[i]=A.at(j)[i];
            }else{
                ans.at(j)[i] = ~A.at(j)[i];
            }
        }
    }
    for(ll i=0; i<N; i++){
        cout << ans.at(i).to_ullong()<<" ";
    }
}


Measured memory_bytes: 7816
import static java.lang.System.*;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int a = sc.nextInt();
			String op = sc.next();
			int b = sc.nextInt();
			if(op.equals("?")){
				break;
			}
			int num = 0;
			switch(op) {
			case "+":
				num = a + b;
				break;
			case "-":
				num = a - b;
				break;
			case "*":
				num = a * b;
				break;
			case "/":
				num = a / b;
				break;
			}
			out.println(num);
		}
		sc.close();
	}
}


Measured memory_bytes: 26212
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	int H,W;
	while(1){
		cin >> H >> W;
		if(H==0&&W==0) break;
		REP(i,H){
			REP(j,W){
				if(i%2==0) {
					if(j%2==0) cout << "#";
					else cout << ".";
				}else{
					if(j%2==1) cout << "#";
					else cout << ".";
				}
			}
			cout << endl;
 		}
 		cout << endl;
	}
}

Measured memory_bytes: 1152
#include<cmath>
#include<stdio.h>
//using namespace std;

int main() {
  int a;
  int b;
  int c;
  scanf("%d%d%d",&a,&b,&c);
  if(a < b && b < c){ 
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  //return 0;
}


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

class Color
{
public:
  Color(int r, int g, int b);
  int get_R();
  int get_G();
  int get_B();
  string near_color();

private:
  int m_R;
  int m_G;
  int m_B;
  double diff( Color col );

  static Color black;
  static Color blue;
  static Color lime;
  static Color aqua;
  static Color red;
  static Color fuchsia;
  static Color yellow;
  static Color white;
};

Color Color::black(   0x00, 0x00, 0x00 );
Color Color::blue(    0x00, 0x00, 0xff );
Color Color::lime(    0x00, 0xff, 0x00 );
Color Color::aqua(    0x00, 0xff, 0xff );
Color Color::red(     0xff, 0x00, 0x00 );
Color Color::fuchsia( 0xff, 0x00, 0xff );
Color Color::yellow(  0xff, 0xff, 0x00 );
Color Color::white(   0xff, 0xff, 0xff );

Color::Color(int r, int g, int b)
{
  m_R = r;
  m_G = g;
  m_B = b;
}

int Color::get_R()
{
  return m_R;
}

int Color::get_G()
{
  return m_G;
}

int Color::get_B()
{
  return m_B;
}

double Color::diff( Color col )
{
  return sqrt( pow(m_R - col.get_R(), 2) + pow(m_G - col.get_G(), 2) + pow(m_B - col.get_B(), 2) );
}

string Color::near_color()
{
  struct Color_name
  {
    string name;
    Color color;
  };
  Color_name colors[8] = {
    "black", black,
    "blue", blue,
    "lime", lime,
    "aqua", aqua,
    "red", red,
    "fuchsia", fuchsia,
    "yellow", yellow,
    "white", white,
  };
  Color_name min = colors[0];
  for (int i=1; i<8; i++)
  {
    if ( diff(colors[i].color) < diff(min.color) )
    {
      min = colors[i];
    }
  }
  return min.name;
}

int main()
{
  while(true)
  {
    string color;
    getline(cin, color);
    if ( color == "0" ) return 0;

    int r = stoi( color.substr(1, 2), 0, 16 );
    int g = stoi( color.substr(3, 2), 0, 16 );
    int b = stoi( color.substr(5, 2), 0, 16 );
    Color c(r, g, b);
    cout << c.near_color() << endl;
  }
}

Measured memory_bytes: 1192
#include "bits/stdc++.h"
using namespace std;
static const int N=100;
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n,M[N][N];
int color[N],d[N],f[N],tt;
int nt[N];

//u?????£??\??????v?????????????????????
int next(int u){
	for (int v = nt[u]; v < n; ++v) {
		nt[u]=v+1;
		if(M[u][v])return v;
	}
	return -1;
}

//?????????????????¨????????±???????????¢?´¢
void dfs_visit(int r){
	for (int i = 0; i < n; ++i) {nt[i]=0;}
	stack<int> S;
	S.push(r);
	color[r]=GRAY;
	d[r]=++tt;
	while(!S.empty()){
		int u=S.top();
		int v=next(u);
		if(v!=-1){
			if(color[v]==WHITE){
				color[v]=GRAY;
				d[v]=++tt;
				S.push(v);
			}
		}else{
			S.pop();
			color[u]=BLACK;
			f[u]=++tt;
		}
	}
}

void dfs(){
	//?????????
	for (int i = 0; i < n; ++i) {
		color[i]=WHITE;
		nt[i]=0;
	}
	tt=0;
	//????¨???????u????§??????¨????????±???????????¢?´¢
	for (int u = 0; u < n; ++u) {
		if(color[u]==WHITE)dfs_visit(u);
	}
	for (int i = 0; i < n; ++i) {
		cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
	}
}


int main(){
	int u,k,v;
	cin>>n;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			M[i][j]=0;
		}
	}
	for (int i = 0; i < n; ++i) {
		cin>>u>>k;
		u--;
		for (int j = 0; j < k; ++j) {
			cin>>v;
			v--;
			M[u][v]=1;
		}
	}
	dfs();
	return 0;
}

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

using namespace std;

using vi = vector<int>;

using uint = unsigned int;

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

	string S_, T;
	cin >> S_ >> T;

	reverse(S_.begin(), S_.end());
	reverse(T.begin(), T.end());
	int matched_index = -1;

	bool matched;

	for (uint i = 0; i < S_.size() - T.size() + 1;) {
		matched = true;

		for (uint j = 0; j < T.size(); ++j) {
			if (S_.at(i + j) == '?') {
				matched = true;
			}
			else if (S_.at(i + j) != T.at(j)) {
				matched = false;
				break;
			}
		}

		if (matched) {
			matched_index = i;
			break;
		}
		else {
			i++;
		}
	}

	if (matched_index == -1) {
		cout << "UNRESTORABLE" << endl;
	}
	else {
		for (uint i = 0; i < S_.size(); ++i) {
			if (S_.at(i) == '?') {
				S_.at(i) = 'a';
			}
		}

		for (uint j = 0; j < T.size(); ++j) {
			S_.at(matched_index + j) = T.at(j);
		}

		reverse(S_.begin(), S_.end());
		cout << S_ << endl;
	}

	return 0;
}

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

int main() {
    
    int a, b, c, k;
    int sum = 0;    
    int i;

    cin >> a >> b >> c >> k;

    for(i=0; i<k; i++){
    	//cout << sum << endl;
    	if(a > 0){
    		sum++;
    		a--;
    		continue;
    	} else if(b > 0){
    		b--;
    		continue;
    	} else{
    		sum--;
    		c--;
    		continue;
    	}
    }

    cout << sum << endl;

    return 0;
}



Measured memory_bytes: 3652
#include <stdio.h>

int main(void){
	char in;
	int count = 0;
	int stack = 0;

	while((in = getchar()) != '\n'){
		if(in == '1'){
			if(stack < 0)count++;
			stack++;
		}else{
			if(stack > 0)count++;
			stack--;
		}
	}
	printf("%d\n", count * 2);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;

int main() {
    
    int n, m; cin >> n >> m;
    vector<vector<int>> v(100, vector<int>(100,0));

    for (int i=0; i<m; i++) {
        int a, b;
        cin >> a >> b;
        v[a-1][b-1] = 1;
        v[b-1][a-1] = 1;
    }

    vector<int> s;
    for (int i=0; i<n; i++) {
        s.emplace_back(i);
    }

    int ans = 0;
    do {
        if (s[0]==0) {
            bool check = true;
            for (int i=0; i<n-1; i++) {
                if (v[s[i]][s[i+1]]==0) check = false;
            }
            if (check) ans += 1;
        }
    } while (next_permutation(s.begin(), s.end()));

    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 256
n,x = map(int, input().split())
a = sorted(list(map(int, input().split())))

ans = 0

for i in range(n):
    x -= a[i]
    if (x < 0):
        print(i)
        break
else:
    if (x != 0):
        print(n - 1)
    else:
        print(n)

Measured memory_bytes: 3064
#include<iostream>
#include<math.h>
#define rep(i,n)for(int i=2;i<n;i++)
typedef long long ll;
using namespace std;
int main()
{
    int x;
    bool flag=false;
    cin>>x;

    while (!flag)
    {
        if(x>3)
        {
            rep(i,sqrt(x))
            {
                if(x%i==0)
                {
                    flag=false;
                    break;
                }
                else flag=true;
            }
        }
        else
        {
            flag=true;
            break;
        }
        if(!flag)x++;
    }
    cout<<x<<endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = []
for i in range(N):
  A.append(int(input()))
  
A.sort()

"""
N : even
a0 < a1 > a2 ... < aN-1
 -> 2(a1-a2+...-aN-2) - a0 + aN-1
a0 > a1 < a2 ... > aN-1
 -> 2(-a1+a2+...+aN-2) + a0 - aN-1
m = N//2 とすると
(a0, aN-1) = A[m-1], A[m]

N : odd
a0 < a1 > a2 ... > aN-1
 -> 2(a1-a2+...+aN-2) - a0 - aN-1
m = N//2とすると
(a0, aN-1) = A[m-1], A[m]

a0 > a1 < a2 ... < aN-1
 -> 2(-a1+a2-...-aN-2) + a0 + aN-1
m = N//2とすると
(a0, aN-1) = A[m], A[m+1]

"""
ans = 0
m = N // 2

if N%2 == 0:
  ans = sum(A[0:m-1]) * (-2) - A[m-1] + A[m] + sum(A[m+1:]) *2
else:
  a = sum(A[0:m-1]) * (-2) - A[m-1] - A[m] + sum(A[m+1:]) *2
  b = sum(A[0:m]) * (-2) + A[m] + A[m+1] + sum(A[m+2:]) *2
  ans = max(a,b)
  
print(ans)


Measured memory_bytes: 7512
#include<bits/stdc++.h>
using namespace std;
int kou,sou=114514,H,W;
int main(){
    cin>>H>>W;
    char HW[H][W];
    for(int i=0;i<H;i++){ for(int o=0;o<W;o++){ scanf(" %c",&HW[i][o]); }}
    for(int i=1;i<H-1;i++){
        for(int j=1;j<H-i;j++){
            kou=0;
            for(int o=0;o<i;  o++){ for(int f=0;f<W;f++){ if(HW[o][f]!='W'){kou++;} } }
            for(int o=i;o<i+j;o++){ for(int f=0;f<W;f++){ if(HW[o][f]!='B'){kou++;} } }
            for(int o=i+j;o<H;o++){ for(int f=0;f<W;f++){ if(HW[o][f]!='R'){kou++;} } }
            if(kou<sou){sou=kou;}
        }
    }
    cout<<sou<<endl;
}

Measured memory_bytes: 3148
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()
 
import itertools

n,m,q = map(int,input().split())
all_num = [i for i in range(1, m+1)]
M = []
ans = []
for _ in range(q):
    a,b,c,d = map(int,input().split())
    M.append([a,b,c,d])


ans = 0
for com in list(itertools.combinations_with_replacement(all_num, n)):
    score = 0
    for m in M:
        if com[m[1]-1]-com[m[0]-1] == m[2]:
            score += m[3]
    
    ans = max(ans,score)

print(ans)

Measured memory_bytes: 21620
#include<iostream>
using namespace std;
int main(void){
    double x1,y1,x2,y2,x3,y3,x,y,a,b,c;
    while(cin >> x1 >> y1 >> x2 >> y2>> x3 >> y3 >> x >> y){
        a=((y-y2)*(x-x1)-(y-y1)*(x-x2))*((y3-y2)*(x3-x1)-(y3-y1)*(x3-x2));
        b=((y-y3)*(x-x2)-(y-y2)*(x-x3))*((y1-y3)*(x1-x2)-(y1-y2)*(x1-x3));
        c=((y-y3)*(x-x1)-(y-y1)*(x-x3))*((y2-y3)*(x2-x1)-(y2-y1)*(x2-x3));
        if(a>0 && b>0 && c>0)   cout << "YES" << endl;
        else                    cout << "NO" <<endl;
    }
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  string s;
  ll k;
  cin >> s >> k;
  ll n = s.size();

  priority_queue<string, vector<string>, greater<string>> pq;
  for (ll i = 0; i < n; i++) {
    for (ll j = i; j < min(n, i + k); j++) {
      string t;
      for (ll l = i; l <= j; l++) {
        t.push_back(s[l]);
      }
      pq.push(t);
    }
  }
  for (ll i = 0; i < k - 1; i++) {
    string t = pq.top();
    while (t == pq.top()) pq.pop();
  }
  cout << pq.top() << endl;
}

Measured memory_bytes: 1660
n = int(input())
lst = [int(i) for i in input().split()]
lst.sort()
#print(lst)

if 1 in lst:
  count = 0
  for i in range(n):
    if lst[i] == 1:
      count += 1
    if count == 2:
      break
  if count == 1:
    print(1)
  else:
    print(0)
else:
  tf_lst = [1] * lst[n - 1]
  count = 0
  if n > 1:
    pre = 0
    for i in range(n):
      tf_lst[pre:lst[i] - 1] = [0] * (lst[i] - pre - 1)
      pre = lst[i]
      if tf_lst[lst[i] - 1] == 0:
        continue
      if i <= n - 2:
        if lst[i] == lst[i + 1]:
          tf_lst[lst[i] - 1] = 0
      for j in range(lst[i] * 2, lst[n - 1] + 1, lst[i]):
        tf_lst[j - 1] = 0
    #print(tf_lst)
    for i in tf_lst:
      count += i
  else:
    count += 1
  print(count)


Measured memory_bytes: 41740
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define nummax 110000
using namespace std;

int main() {
	double ans = 0.0, y, i, N, K, x;
	cin >> N >> K;
	for (i = 1; i <= N; i++)
	{
		x = 0;
		while (1)
		{
			if (i * pow(2, (double)x) >= K)
				break;
			x++;
		}
		x *= -1;
		y = pow(2, (double)x);
		ans += y;
	}
	ans /= N;
	//cout << ans << endl;
	printf("%.12f\n", ans);
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

int main(){
  int n;
  int x[100000];
  int L[100000];
  pair<int,int> x_se[100000];

  cin >> n;
  for(int i = 0; i < n; i++) cin >> x[i] >> L[i];

  // for(int i = 0; i < n; i++) cout << x[i] << L[i] << endl;

  for(int i = 0; i < n; i++){
    // pair (end, start)
    x_se[i] = make_pair(x[i]+L[i],x[i]-L[i]);
    // cout << x_se[i].first << "," << x_se[i].second << endl;
  }

  sort(begin(x_se),begin(x_se) + n);

  for (int i = 0; i < n; i++){
    // cout << x_se[i].first << "," << x_se[i].second << endl;
  }

  int counter = 1;
  int now = x_se[0].first;
  for (int i = 1; i < n; i++){
    // now = x_se[i-1].first;
    if(x_se[i].second >= now){
      counter ++;
      now = x_se[i].first;
      // continue;
    }else{
      // now = x_se[i-1].first;
    }
  }

  cout << counter << endl;

  



  return 0;
}

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

int main() {
  ll x, y;
  cin >> x >> y;
  int cnt = 0;
  while (x <= y) {
    ++cnt;
    x *= 2;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
from math import sqrt, cos, pi, radians

L = list(map(int, input().split()))
A = L[0]
B = L[1]
H = L[2]
M = L[3]

d = abs(30*H - 5.5*M)
c = sqrt(A*A + B*B - 2*A*B*cos(radians(d)))

print(c)

Measured memory_bytes: 9432
#include<stdio.h>
#define N 10000

bool linearSearch(int S[],int n,int key)
{
    S[n] = key;
    int i = 0;
    while(S[i] != key) {
        i++;
    }
    return i != n;
}

int main()
{
    int S[N];
    int n, q;

    scanf("%d",&n);
    for(int i = 0;i < n;i++)
        scanf("%d",&S[i]);

    int m, sum = 0;
    scanf("%d",&q);
    for(int i = 0;i < q;i++) {
        scanf("%d",&m);
        if(linearSearch(S,n,m))
            sum++;
    }

    printf("%d\n",sum);
}



Measured memory_bytes: 2732
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define fast ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define F(i,a,b) for(int i= (int)(a); i<(int)(b);i++)
#define FI(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define what_is(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pii pair<int,int>
#define vi vector<int >
#define vii vector<int,int>
#define pb push_back
#define endl '\n'
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007
const int N = 1e6+7 ;
string s ;
string grid[1001] ;
int dp[1001][1001] ;
int row,col ;
ll ans ;
ll solve(int x,int y){
	if(dp[x][y] != -1)	
		return (dp[x][y]) ;
	if(x>=row || y >= col || grid[x][y] == '#')
		return (dp[x][y] = 0) ;
	
	return (dp[x][y] = (solve(x+1,y)+solve(x,y+1))%MOD) ;
}
int main(){fast ;
	cin >> row >> col ;
	for(int i=0; i<row; i++)
			cin >> grid[i] ;

	ms(dp,-1) ;		
	dp[row-1][col-1] = 1 ;
	cout << solve(0,0)  << endl ;			
}




Measured memory_bytes: 5376
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int total = Integer.parseInt(sc.next());
        List<Integer> list = new ArrayList<>();
        for (int x =1; x <= total ; x++) {
            list.add(Integer.parseInt(sc.next()));
        }
        Collections.sort(list);
        int x = list.get(total/2-1);
        int y = list.get(total/2);
        System.out.println(y-x);
    }
}


Measured memory_bytes: 49388
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int n; 
cin>>n;
int a[100006];
 for(int i = 0; i<n; i++){
    cin>>a[i];
  }
  sort(a,a+n);
  cout<<a[n/2]-a[n/2-1]<<endl;
  return 0;
  }

Measured memory_bytes: 640
n=int(input())
a=list(map(int,input().split()))
clashes=[-1]*20
ans=0
lastclash=-1
for i in range(n):
  binstr='{0:b}'.format(a[i])
  binlist=[]
  t=len(binstr)
  for j in range(t):
    binlist.append(binstr[j])
  binlist.reverse()
  for j in range(20-t):
    binlist.append('0')
  maxclash=-1
  for j in range(20):
    if clashes[j]>maxclash and binlist[j]=='1':
      maxclash=clashes[j]
  for j in range(20):
    if binlist[j]=='1':
      clashes[j]=i
  lastclash=max(maxclash,lastclash)
  ans+=i-lastclash
print(ans)

  

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

int main(){
  
  int N;
  cin >> N;
  vector<int> d(N);
  
  for(int i = 0; i < N; ++i){
  
    cin >> d.at(i);
  
  }
  
  sort(d.begin(),d.end());
  
  int check = 0,count = 0;
  
  for(int i = 0; i < N; ++i){
  
    if(check != d.at(i)){
    
      ++count;
      check = d.at(i);
    
    }
  
  }
  
  cout << count << endl;

  return 0;

}

Measured memory_bytes: 256
n = int(input())
hoge = input().split()

m = {}
for i in range(len(hoge)):
    if not(hoge[i] in m):
        m[hoge[i]] = 0
    m[hoge[i]] += 1

al = 0
for key in m:
    al += ((m[key] * (m[key] - 1)) / 2)

for i in range(len(hoge)):
    num1 = m[hoge[i]]
    if num1 < 2:
        print(int(al))
    else:
        num2 = (num1 * (num1 -1)/2) - ((num1 - 1) * (num1 -2)/2)
        print(int(al - num2))



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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define fi first
#define se second

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int main() {
    int k,a,b;
    cin>>k>>a>>b;
    for (int i=a;i<b+1;i++){
        if (i%k==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;

    return 0;
}

Measured memory_bytes: 3592
def fnc(n):
    if n%2 == 1:
        return 3*n+1
    else:
        return n//2
        
        

s = int(input())

log = set([s])

cnt = 1

while True:
    if fnc(s) in log:
        cnt += 1
        print(cnt)
        break
    else:
        s = fnc(s)
        log.add(s)
        cnt += 1
        

Measured memory_bytes: 9112
N = int(input())
W = list(map(int, input().split()))
ans = 10000
for i in range(N):
    S1 = sum(W[:i + 1])
    S2 = sum(W[i + 1:])
    tmp = abs(S1 - S2)
    ans = min(ans, tmp)


print(ans)

Measured memory_bytes: 3060
/**
 *    author:  math2do
 *    created: 22.01.2020 23:31:59
**/

#include <bits/stdc++.h>

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "1" : "0");
}
string to_string(const char &ch) {
  return string(1, ch);
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  reverse(res.begin(), res.end());
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

//..import matrix, queue, stack

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

vector <char> dp;
bool solve(int k, int n, vector <int> &arr) {
  if (k == 0) return false;
  if (dp[k] != '2') return dp[k] == '1' ? true : false;
  bool ans = true;
  for (int i = 0; i < n; i++) {
    if (arr[i] <= k) {
      ans = solve(k - arr[i], n, arr);
      if (ans == false) {
        break;
      } 
    }   
  }
  if (ans == false) {
    dp[k] = '1';
    return true;
  }
  dp[k] = '0';
  return false;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector <int> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  dp.clear();
  dp.resize(k + 1);
  fill(dp.begin(), dp.end(), '2');
   
  bool ans = solve(k, n, arr);
  if (ans) puts("First");
  else puts("Second");
  return 0;
}

Measured memory_bytes: 6656
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#define check(s) (s<='9'&&s>='0')
using namespace std;
int n;
struct Node{
	int v,num,ans;
};
Node a[200005];
inline int read(){
	char ch;int res;
	for(ch=getchar();!check(ch);ch=getchar());
	res=ch-'0';
	for(ch=getchar();check(ch);ch=getchar())
	res=res*10+ch-'0';
	return res;
}
bool cmp(Node x,Node y){
	return x.v<y.v;
}
bool cmp2(Node x,Node y){
	return x.num<y.num;
}
int main(){
	n=read();
	for(int i=1;i<=n;i++) {
	  a[i].v=read();
	  a[i].num=i; 
	}
	int x1,x2;
	sort(a+1,a+n+1,cmp);
	x1=a[n>>1].v ;
	x2=a[(n>>1)+1].v ;
		for(int i=1;i<=(n>>1);i++)
		  a[i].ans=x2;
		for(int i=(n>>1)+1;i<=n;i++)
		  a[i].ans=x1;
	sort(a+1,a+n+1,cmp2);
	for(int i=1;i<=n;i++) printf("%d\n",a[i].ans);
   return 0;	
	
}

Measured memory_bytes: 4480
#include<iostream>
using namespace std;
int main()
{
    int a,b;
   cin>>a>>b;
   if(a>1&&b>1)
   {
     if(a==b)
     cout<<"Draw\n";
     else
     if(a>b)
     cout<<"Alice\n";  
     else
     cout<<"Bob\n";        
               
               
               }
   else
   {
       if(a==1&&b!=1)
       cout<<"Alice\n";
       else
        if(b==1&&a!=1)
        cout<<"Bob\n";
        else 
        cout<<"Draw\n";
        }
   
    
    
}


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



int main() {
	int m, f, r;
	while (1) {
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1)break;
		if (m == -1 || f == -1) { cout << 'F' << endl; continue; }
		if (m + f >= 80)cout << 'A' << endl;
		if (65 <= m + f&&m + f < 80)cout << 'B' << endl;
		if (50 <= m + f&&m + f < 65)cout << 'C' << endl;
		if (30 <= m + f&&m + f < 50) {
			if (r >= 50)cout << 'C' << endl;
			else cout << 'D' << endl;			
		}
		if (m + f < 30)cout << 'F' << endl;

	}
	return 0;
}

Measured memory_bytes: 1152
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


move = None
tx = None
ty = None


@mt
def slv(N, A):
    mx = max(A)
    mn = min(A)
    ans = []
    if abs(mx) > abs(mn):
        idx = A.index(mx)
        for i in range(N):
            if A[i] < 0:
                ans.append((idx, i))
                A[i] += mx
        for i in range(1, N):
            ans.append((i-1, i))
            A[i] += A[i-1]
    else:
        idx = A.index(mn)
        for i in range(N):
            if A[i] > 0:
                ans.append((idx, i))
                A[i] += mn
        for i in range(N-1, 0, -1):
            ans.append((i, i-1))
            A[i-1] += A[i]

    print(len(ans))
    for x, y in ans:
        print(x+1, y+1)


def main():
    N = read_int()
    A = read_int_n()
    slv(N, A)


if __name__ == '__main__':
    main()


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

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define For(i,a,b) for(int (i)=(a); (i)<(b); (i)++)

int main() {
    int s;
    cin >> s;
    int h = s / 3600;
    int m = s % 3600;
    s = m % 60;
    cout << h << ":" << m / 60 << ":" << s << endl;
    return 0;
}

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

int main() {
  double n,tmp;
  cin>>n;
  tmp=n/1.08;
  int ans=tmp,chkans;
  chkans=ans*1.08;

  //cout<<tmp<<endl;

  if(chkans==n){cout<<ans<<endl;return 0;}
  else{
    chkans=(ans+1)*1.08;
    if(chkans==n){cout<<ans+1<<endl;return 0;}
  }
  cout<<":("s<<endl;
  
  return 0;
}

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

int main() {
  double N;
  cin >> N;
  bool next=true;
  double i=0;
  double j=0;
  int an;
  while(i<3501 && next){
    j=0;
    i++;
    while(j<3501 && next){
      j++;
      double ans=1/(4/N-1/i-1/j);
      an=ans;
      if(abs(an-ans)<0.00000001 && an>0){
        next=false;
        break;
      }
    }
  }
  cout << i << ' ' << j << ' ' << an;
}




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

using namespace std;

#define rip(i,n,s) for (int i=(s);i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> a(n),b(n),c(n);
    rip(i,n,0){
        cin >> a[i];
    }
    rip(i,n,0){
        cin >> b[i];
    }
    rip(i,n-1,0){
        cin >> c[i];
    }
    int ans=0;
    rip(i,n,0){
        ans+=b[a[i]-1];
        if(i!=0){
            if(a[i]-1==a[i-1]){
                ans+=c[a[i]-2];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define Reverse(x) reverse(all(x));
#define Sort(x) sort(all(x));
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli n;
    string a, b, c;
    cin>>n>>a>>b>>c;
    lli ans=0;
    rep(i,n){
        lli e=0;
        if(a[i]!=b[i]){ 
            ans++;
            e++;
        }
        if(a[i]!=c[i]){ 
            ans++;
            e++;
        }
        if(e==2&&b[i]==c[i]){ 
            ans--;
        }
    }
    out(ans);
}

Measured memory_bytes: 3616
"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(input())
f = factorization(n)

#print(n)
#print(f)

ans = 0
for i in range(len(f)):
  if f[i][0] == 1:
    continue
  t = f[i][1]
  #print(t)
  
  for j in range(1, 40):
    if (t - j) < 0:
      break
    ans += 1
    t -= j

print(ans)


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

typedef long long ll;
const ll MOD = 1e9 + 7;




int main()
{
	ios_base::sync_with_stdio(false);


	int n, xorr = 0;
	cin >> n;
	int a[n], b[n];
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		xorr = a[i] xor xorr;
	}
	for (int i = 0; i < n; i++)
		b[i] = xorr xor a[i];
	for (int i = 0; i < n; i++)
		cout << b[i] << " ";
	cout << endl;

	return 0;
}

Measured memory_bytes: 5152
# from math import factorial,sqrt,ceil #,gcd
# from itertools import permutations,combinations,combinations_with_replacement
from collections import deque,Counter
# from bisect import bisect_left
# from heapq import heappush,heappop
# from numba import njit
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from fractions import gcd

# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np    # numpy.lcm()
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb,perm #permはnPk
# import networkx as nx
# G = Graph()

# slist = "abcdefghijklmnopqrstuvwxyz"
N = int(input())
lisA = list(map(int,input().split()))

kv1 = Counter(lisA[0:N:2]).most_common()
kv2 = Counter(lisA[1:N:2]).most_common()

if len(kv1)==len(kv2)==1 and kv1[0]==kv2[0]:
    print(N//2)
    exit()

ans1 = N
ans2 = N
for i in range(0,N//2-1):
    try:
        if kv1[0][0]!=kv2[i][0]:
            ans1 = min(ans1,N-(kv1[0][1]+kv2[i][1]))
        if kv1[i][0]!=kv2[0][0]:
            ans2 = min(ans2,N-(kv1[i][1]+kv2[0][1]))
    except:
        pass

print(min(ans1,ans2))
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 20700
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;

int main() {
    int n = 0;
    cin >> n;
    vector<ll> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }
    ll must = 0;
    for (int i=n-1; i>=0; i--) {
        if (a.at(i) < must) {
            cout << -1 << endl;
            return 0;
        } else {
            must = max(must, a.at(i));
            must--;
        }
    }
    if (must >= 0) {
        cout << -1 << endl;
        return 0;
    }

    ll cnt = a.at(n-1);
    for (int i=n-2; i>=0; i--) {
        if (a.at(i) >= a.at(i+1)) {
            cnt += a.at(i);
        }
    }
    cout << cnt << endl;

    return 0;
}
 

Measured memory_bytes: 1792
a,b,k = map(int, input().split())

ans = []
t = 0
for i in range(a,b+1):
  t += 1
  if t > k: break
  ans.append(i)
  
t = 0
for i in range(b,a-1,-1):
  t += 1
  if t > k: break
  ans.append(i)

for i in sorted(set(ans)): print(i)

Measured memory_bytes: 9188
#include <queue>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <utility>
typedef long long ll;
using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> q[M];
  priority_queue<int> m;
  for(int i = 0; i < N; ++i){
    int a,b;
    cin >> a >> b;
    a--;
    if(a < M){
      q[a].push_back(b);
    }
  }
  ll sum = 0;
  for(int i = 0; i < M; ++i){
    for(auto x: q[i]){
      m.push(x);
    }
    if(!m.empty()){
      sum += m.top();
      m.pop();
    }
  }
  cout << sum << endl;


  
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> vi;

int main(){
   int n;
   scanf("%d",&n);
   for(int i=0;i<n;i++){
    ll s;
    scanf("%lld",&s);
    vi.push_back(s);
   }
   sort(vi.begin(),vi.end(),greater<ll>());
   ll sum=vi[0];
   for(int i=1;i<=(n-2)/2;i++){
    sum+=2*vi[i];
   }
   if((n-2)%2){
    sum+=vi[n/2];
   }
   printf("%lld",sum);
    return 0;
}


Measured memory_bytes: 5408
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main() {
    ll H;
    cin >> H;
    ll sum = 0;
    ll i = 0;
    while(H >= 1){
        sum += pow(2, i);
        i++;
        H = H/2;
    }
    cout << sum << endl;
}

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

int sum(string N){
    int tally = 0;
    for (int i = 0; i < N.size(); ++i){
        tally += (N[i] - '0');
    }
    return tally;
}

void solve (string N){
    if (sum(N) % 9 == 0){
        cout << "Yes" << "\n";
        return;
    }
    cout << "No" << "\n";
}

int main(){
    string N;
    cin >> N;
    solve(N);
}


Measured memory_bytes: 3828
#include <stdio.h>

int main(void){
  int A, B;
  scanf("%d %d", &A, &B);
  if ( A%3 == 0 || B%3 == 0 || (A+B)%3 == 0){
    printf("Possible");
  }else {
    printf("Impossible");
  }
  return 0;
}

Measured memory_bytes: 1708
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>

using namespace std;
const int MAXN = 205;
int n,map[MAXN][MAXN];
char str[MAXN];
int q[MAXN],bl[MAXN],front,rear;

int main()
{
	cin >> n;
	for(int i = 1; i<=n; i++)
	{
        cin >> str+1;
        for(int j = 1; j<=n; j++)
            map[i][j] = str[j]-'0';
	}     
	int ans = -1;
	for(int i = 1; i<=n; i++)
	{
        front = rear = 0;
        memset(bl,0,sizeof(bl));
        bool flag = true;
        q[rear++] = i, bl[i] = 1;
        while(front<rear)
        {
            int u = q[front++];
            for(int j = 1; j<=n; j++)
            {
            	if(!map[u][j])
            	    continue;
                if(bl[j]&&abs(bl[j]-bl[u])!=1)
                    flag = false;
                if(!bl[j])
                {
                    bl[j] = bl[u]+1;
		            q[rear++] = j;
				}
			}
		}
		if(flag)
		{
	        for(int j = 1; j<=n; j++)
	            ans = max(ans,bl[j]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { let mut $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { let $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
use std::cmp::min;
fn main() {
    input! {
        n: u64,
    }
    let mut ret :u64 = 1;
    for i in (1..).take_while(|i| i * i <= n) {
        if n % i == 0 {
            ret = i;
        }
    }
    let a = format!("{}", ret).len();
    let b = format!("{}", n / ret).len();
    println!("{}", std::cmp::max(a, b));
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<(x)<<endl
#define fi first
#define se second

#define INF 2147483600

struct edge {int to; long cost;};

vector<vector<edge> > vec;
vector<int> d;

// dijkstra shortest path O(E logV)
void dijkstra(int from){
  priority_queue<pair<long, int>, vector<pair<long, int> >, greater<pair<long, int> > > que; //pair<dist, idx>
  fill(all(d), INF);
  d[from] = 0;
  que.push(mp(0,from));
  while(!que.empty()){
    pair<long, int> p = que.top(); que.pop();
    int v = p.second;
    long dis = p.first;
    if(d[v] < dis) continue;
    for(edge e : vec[v]){
      long target = dis + e.cost;
      if(d[e.to] > target){
        d[e.to] = target;
	      que.push(mp(d[e.to], e.to));
      }
    }
  }
}
// END dijkstra

bool check_dfs(int from, int n){
  if(from!=-1 && abs(d[from]-d[n])!=1) return false;
  for(auto e : vec[n]) if(e.to != from && e.to!=0){
    if(!check_dfs(n, e.to)) return false;
  }
  return true;
}

int main(){
  int n;
  cin>>n;
  vec = vector<vector<edge> >(n+1, vector<edge>());
  d = vector<int>(n+1);

  rep(i,n-1){
    int a,b;
    scanf("%d %d", &a, &b);
    vec[a].pb(((edge){b,1}));
    vec[b].pb(((edge){a,1}));
  }
  int k; cin>>k;
  vector<int> v(k),p(k);
  rep(i,k){
    int a,b;
    scanf("%d %d", &a, &b);
    vec[0].pb(((edge){a,b}));
    v[i]=a; p[i]=b;
  }
  dijkstra(0);
  if(check_dfs(-1,1)){
    bool flg=true;
    rep(i,k) if(d[v[i]]!=p[i]) flg=false;
    if(flg){
      cout<<"Yes"<<endl;
      repl(i,1,n+1)printf("%d\n", d[i]);
      return 0;
    }
  }
  cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 13628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k;
  string s;
  cin >> n >> k >> s;
  int a = k - 1;
  if(s.at(a) == 'A') s.at(a) = 'a';
  else if(s.at(a) == 'B') s.at(a) = 'b';
  else s.at(a) = 'c';
  cout << s << endl;
}

Measured memory_bytes: 256