akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)((n>>m)&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

ll n,k,q,ans=INF;
ll a[2010];
ll temp1[2010];
ll temp2[2010];

int main(){
	scanf("%lld%lld%lld",&n,&k,&q);
	rep(i,0,n)scanf("%lld",a+i);
	a[n]=-1;
	
	while(1){
		ll cnt1=0,cnt2=0;
		rep(i,0,n+1){
			if(a[i]<0){
				if(cnt1>=k){
					sortup(temp1,cnt1);
					rep(j,0,cnt1-(k-1))temp2[cnt2++]=temp1[j];
				}
				cnt1=0;
			}else{
				temp1[cnt1++]=a[i];
			}
		}
		if(cnt2<q)break;
		sortup(temp2,cnt2);
//		rep(i,0,cnt2)printf("%d",temp2[i]);puts("");
		ans=min(ans,temp2[q-1]-temp2[0]);
		rep(i,0,n)if(a[i]==temp2[0])a[i]=-1;
	}
	printf("%lld\n",ans);
	return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

vector<int64_t> eval(const vector<int64_t>& a, int64_t k, int64_t b,
                     int64_t e) {
    if (e - b < k) {
        return {};
    }

    vector<int64_t> t;
    for (auto i : irange(b, e)) {
        t.push_back(a[i]);
    }

    sort(t.begin(), t.end());
    t.resize(t.size() - k + 1);

    return t;
}

int64_t eval(const vector<int64_t>& a, int64_t k, int64_t q,
             const vector<bool>& u) {
    int64_t n = a.size();

    vector<int64_t> t;
    int64_t b = 0;
    for (auto i : irange(0L, n + 1)) {
        if (!u[i]) {
            if (b != i) {
                auto tmp = eval(a, k, b, i);
                t.insert(t.end(), tmp.begin(), tmp.end());
            }

            b = i + 1;
        }
    }

    if (t.size() < q) {
        return numeric_limits<int64_t>::max();
    }

    sort(t.begin(), t.end());

    return t[q - 1] - t[0];
}

int main() {
    int64_t n, k, q;
    cin >> n >> k >> q;

    vector<int64_t> a(n);
    vector<pair<int64_t, int64_t>> b(n);
    for (auto i : irange(0L, n)) {
        cin >> a[i];
        b[i].first = a[i];
        b[i].second = i;
    }

    sort(b.begin(), b.end());

    int64_t ans = numeric_limits<int64_t>::max();
    vector<bool> u(n + 1, true);
    u[n] = false;
    for (auto i : irange(0L, n - k + 1)) {
        ans = min(ans, eval(a, k, q, u));
        u[b[i].second] = false;
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>





using namespace std;
int main() {

	int t, x;
	cin>>t >> x;

	cout << setprecision(20);
	cout << (double)(t) / (double)(x) << endl;

	

	return 0;
}


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

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

int main() {
  int n;
  cin >> n;
  vector<double> a(n);
  rep(i, n) cin >> a[i];

  double div = 0;
  rep(i, n) { div += (double)1.0 / a[i]; }

  printf("%.5f\n", (double)1.0 / div);
  // cout << (double)1.0 / div << endl;

  return 0;
}

Measured memory_bytes: 256
n = int(input())
lst = []

for i in range(n):
	tmp = input().split()
	lst.append(tmp)
	
d = {}

for i in range(n):
	if lst[i][0] == 'insert':
		d[lst[i][1]] = d.get(lst[i][1], 0) + 1
	elif lst[i][0] == 'find':
		print('yes') if lst[i][1] in d else print('no')


Measured memory_bytes: 303788
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int n;
    ll a[212345], b[212345];

    cin >> n;
    REP(i, n)
    cin >> a[i];
    REP(i, n)
    cin >> b[i];

    sort(b, b + n);

    ll res = 0;

    for (ll i = 0; i <= 28; i++)
    {
        ll cnt = 0;

        ll b_[212345], a_[212345];

        for (int j = 0; j < n; j++)
        {
            a_[j] = a[j] % (1ll << (i + 1));
            b_[j] = b[j] % (1ll << (i + 1));
        }

        sort(b_, b_ + n);

        for (int j = 0; j < n; j++)
        {
            cnt += (lower_bound(b_, b_ + n, (1ll << i) * 2 - a_[j]) - lower_bound(b_, b_ + n, (1ll << i) - a_[j]));
            cnt += (b_ + n) - lower_bound(b_, b_ + n, (1ll << i) * 3 - a_[j]);
        }

        res += (1ll << i) * (cnt % 2);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 6784
package main

import "fmt"

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

	ans := 0
	ans += min(a, k)
	k -= a
	if k <= 0 {
		fmt.Println(ans)
		return
	}

	k -= b
	if k <= 0 {
		fmt.Println(ans)
		return
	}

	ans -= k
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 1756
#include<iostream>
#include<tuple>
#include<set>
#include<algorithm>
using namespace std;
int main(){
	int n, m, a;set<int> s;
	cin>>n;
	for(int i = 0; i < n; i++){
		cin>>a;
		s.insert(a);
	}
	cin>>n;
	for(int i = 0; i < n; i++){
		cin>>a;
		s.erase(a);
	}
	for(int y : s) cout<<y<<endl;
}


Measured memory_bytes: 12408
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
struct LOG {
	int type;
	int value;
	int idx;
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	int N = S.size();
	int offset = 2 * N;
	vector<int> C(4 * N, 0);
	int cur = 0;
	C[0 + offset] = 1;
	int res = 0;
	vector<vector<LOG> > a;
	vector<LOG> e;
	for (int i = 0; i < N; i++) {
		if (S[i] == '(') {
			a.push_back(e);
			
			a.back().push_back(LOG{ 0,cur,0 });
			cur++;
			
			a.back().push_back(LOG{ 1,C[offset + cur],offset + cur });
			C[offset + cur]++;
		}
		else if(S[i] == ')'){
			a.push_back(e);
			
			a.back().push_back(LOG{ 1,C[offset + cur],offset + cur });
			C[offset + cur] = 0;

			a.back().push_back(LOG{ 0,cur,0 });
			cur--;

			a.back().push_back(LOG{ 2, res, 0 });
			res += C[offset + cur]; 

			a.back().push_back(LOG{ 1,C[offset + cur],offset + cur });
			C[offset + cur]++;
		}
		else {
			
			for (int i = a.back().size() - 1; i >= 0; i--) {
				if (a.back()[i].type == 0) {
					cur = a.back()[i].value;
				}
				else if (a.back()[i].type == 1) {
					C[a.back()[i].idx] = a.back()[i].value;
				}
				else {
					res = a.back()[i].value;
				}
			}
			a.pop_back();
		}

		cout << res << endl;
	}


}


Measured memory_bytes: 35828
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int main(){
  int n,m;
  while(scanf("%d",&n), n >= 0){
    string ans;
    char buff[8];

    if(getchar() == '.'){
      scanf("%s",buff);
      sscanf(buff,"%d",&m);
      for(int len = strlen(buff); len < 4; len++)
	m *= 10;
    }
    else m = 0;

    if( n > 255 ) ans = "NA";
    else{
      REP(i,8){
	if(n & (1 << i))
	  ans = "1" + ans;
	else
	  ans = "0" + ans;
      }

      ans += ".";

      REP(i,4){
	m *= 2;
	if( m >= 10000 ){
	  ans = ans + "1";
	  m -= 10000;
	}else{
	  ans = ans + "0";
	}
      }
      if( m != 0 ) ans = "NA";
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
n = gets.to_i

impossible = false
prev_time, px, py = 0, 0, 0
n.times do |i|
  time, x, y = gets.split.map(&:to_i)
  dist = (x - px).abs + (y - py).abs
  trav = time - prev_time
  if trav < dist || trav % 2 != dist % 2
    impossible = true
  end
  prev_time, px, py = time, x, y
end

puts impossible ? "No" : "Yes"

Measured memory_bytes: 1788
s = input()

def check(s):
    num = int(s)
    
    if (1 <= num <= 12):
        return True
    else:
        return False

pre = s[0:2]
post = s[2:]

if (check(pre) and check(post)):
    print('AMBIGUOUS')
elif (not check(pre) and check(post)):
    print('YYMM')
elif (check(pre) and not check(post)):
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 3064
n = int(input())
al = list(map(int,input().split()))

pos = ""
max_abs = 0
value = ""
for idx, a in enumerate(al):
    if abs(a) >= max_abs:
        pos = idx + 1 
        max_abs = abs(a)
        value = a

print(2*n - 2)
if value >= 0:
    print(pos)
    print(2)
    print(pos)
    print(2)
    for i in range(2, n):
        print(i)
        print(i+1)
        print(i)
        print(i+1)

else:
    print(pos)
    print(n-1)
    print(pos)
    print(n-1)
    for i in range(n-1, 1, -1):
        print(i)
        print(i-1)
        print(i)
        print(i-1)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include<set>
using namespace std;

int main()
{
	int K;
	cin >> K;
	int x = 7%K;
	set<int> s;
	int i = 1;
	while (s.count(x) == 0)
	{
		if (x == 0)
		{
			cout << i << endl;
			return 0;
		}
		s.insert(x);
		x = (x * 10 + 7) % K;
		++i;
	}
	cout << -1 << endl;
}

Measured memory_bytes: 50464
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

const int MAX_E = 1000000;
typedef pair<int, int> P;
struct edge{int u, v, cost;};

int par[MAX_E], Rank[MAX_E];

void init(int n){
    for(int i=0; i<n; i++){
        par[i] = i;
        Rank[i]=0;
    }
}

int find(int x){
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
}

void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(Rank[x] < Rank[y]) par[x] = y;
    else {
        par[y] = x;
        if(Rank[x] == Rank[y]) Rank[x]++;
    }
}

bool same(int x, int y){
    return find(x) == find(y);
}

bool comp(const edge& e1, const edge& e2){
    return e1.cost < e2.cost;
}

edge es[MAX_E];
int n, E;

int kruskal() {
    sort(es, es+E, comp);
    init(n);
    int res =0;
    for(int i=0; i<E; i++){
        if(!same(es[i].u, es[i].v)){
            unite(es[i].u, es[i].v);
            res += es[i].cost;
        }
    }
    return res;
}

int main(){
    cin >> n;
    E = 2 * n;
    P px[n], py[n];
    for(int i=0; i<n; i++){
        int x, y;
        cin >> x >> y;
        px[i].first = x;
        px[i].second = i;
        py[i].first = y;
        py[i].second = i;
    }
    sort(px, px+n);
    sort(py, py+n);
    for(int i=0; i<n-1; i++){
        es[2*i] = {px[i].second, px[i+1].second, (int)fabs(px[i].first - px[i+1].first)};
        es[2*i+1] = {py[i].second, py[i+1].second, (int)fabs(py[i].first - py[i+1].first)};
    }
    cout << kruskal() << endl;
}

Measured memory_bytes: 9984
#include <stdio.h>
#include <math.h>
#include <string.h>

int main(void){

  int a, b;
  scanf("%d %d",&a,&b);
  
  int c, d=0;
  c = b;
  while(c!=0){
    c = c / 10;
    d = d + 1;
  }
  int e;
  e = pow(10, d);
  int x, y;
  x = a*e + b;
  y = sqrt(x);
  if(y*y == x) printf("Yes");
  else printf("No");
  
  return 0;
}




Measured memory_bytes: 2436
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
 int i,c=0;
 for(i=0;i<s.size();i+=2)
 {
     if(s[i]!='R'&& s[i]!='U' && s[i]!='D'){
        c++;
        break;
     }

 }
 for(i=1;i<s.size();i+=2)
 {
     if(s[i]!='L' && s[i]!='U' && s[i]!='D'){
     c++;
     break;}

 }
 if(c>0) cout<<"No"<<endl;
 else cout<<"Yes"<<endl;
}


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

using namespace std;

struct Node {
	vector<Node> children; // いくつあるかわからない子ノード
	int minvote; // この選挙区で勝つために必要な最小限の得票数
	
	Node() {
		minvote = 0;
	}
};

int vote(Node node) {
	if (node.children.empty()) {
		return node.minvote;
	}
	vector<int> nums;
	for (int i = 0; i < (int)node.children.size(); i++) {
		if (node.children[i].minvote == 0) {
			nums.push_back(vote(node.children[i]));
		} else {
			nums.push_back(node.children[i].minvote);
		}
	}
	sort(nums.begin(), nums.end());
	int minvote = 0;
	for (int i = 0; i < ((int)nums.size() + 1) / 2; i++) {
		minvote += nums[i];
	}
	node.minvote = minvote;
	
	return node.minvote;
}

Node parse(string s) {
	/*
	木を作って再帰
	プロジェクトでやった、XMLパーサと似ているかもしれない
	*/
	Node root;
	//root.parent = NULL;
	//root.minvote = 0;
	stack<Node> tmp;
	//Node currentnode = root;
	int num = 0;
	for (int i = 0; i < (int)s.length(); i++) {
		if (s.at(i) == '[') {
			// startElement
			Node node;
			tmp.push(node);
		} else if (s.at(i) == ']') {
			// endElement
			// 得票数を計算した後、numを0にリセット
			num = (num + 1) / 2;
			Node child;
			child = tmp.top();
			tmp.pop();
			child.minvote = num;
			//cout << child.minvote << endl;
			if (!tmp.empty()) {
				Node parent;
				parent = tmp.top();
				tmp.pop();
				parent.children.push_back(child);
				tmp.push(parent);
			} else {
				root = child;
			}
			
			num = 0;
		} else {
			// characters
			// ここは数字を読んだ時にしか呼び出されないはず
			if (!('0' <= s.at(i) && s.at(i) <= '9')) {
				cout << "入力がおかしいようです。" << endl;
			}
			num *= 10;
			num += s.at(i) - '0';
		}
	}
	
	return root;
}

int main() {
	int n;
	cin >> n;
	
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		Node node = parse(s);
		cout << vote(node) << endl;
		//cout << node.children.size() << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1588
n = int(input())
a = [0] + list(map(int,input().split()))

info = [0] * (n+1)

for i in range(0,n):
    count = 0
    for j in range(2,n//(n-i) + 1):
        count += info[(n-i)*j]
    if count % 2 != a[n-i]:
        info[n-i] = 1

ans = []

for k in range(1,n+1):
    if info[k] == 1:
        ans.append(k)

print(len(ans))
print(" ".join(map(str,ans)))

Measured memory_bytes: 19884
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip> 

using namespace std;

#define mp make_pair
#define pb push_back
#define forn(i, n) for(int i = 0; i < (int)(n); ++i)
#define for1(i, n) for(int i = 1; i < (int)(n); ++i)
#define nfor(i, n) for(int i = int(n) - 1; i >= 0; --i)
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define correct(x, y, n, m) (0 <= x && x < n && 0 <= y && y < m)
#define all(x) (x).begin(), (x).end()
#define fst first
#define snd second
#define endl "\n"

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef tuple<int,int,int> iii;

template<typename T> inline T abs(T a){ return ((a < 0) ? -a : a); }
template<typename T> inline T sqr(T a){ return a * a; }
template<class T> T gcd(T a, T b) { return a ? gcd (b % a, a) : b; }
template<class T> T lcm(T a, T b) { return a / gcd (a, b) * b; }
template<class T> T sign(T a) { return a > 0 ? 1 : (a < 0 ? -1 : 0); }

string to_string(string s) {
    return '"' + s + '"';
}
    
string to_string(const char* s) {
    return to_string((string) s);
}
    
string to_string(bool b) {
    return (b ? "true" : "false");
}
    
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
    
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;
}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

void fastIO() {
    cin.sync_with_stdio(false);
    cin.tie(0);
}

template<typename T>
vector<T> make_unique(vector<T> v) {
    sort(all(v));
    return v.resize(unique(all(v)) - v.begin());
}

int nxt() {
    int x;
    cin >> x;
    return x;
}

const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
const int dxKn[8] = {-2, -1, 1, 2,  2,  1, -1, -2};
const int dyKn[8] = { 1,  2, 2, 1, -1, -2, -2, -1};
const int dxK[8] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dyK[8] = {1, -1, 0, 0, 1, -1, 1, -1};

const int MOD = int(1e9) + 7;
const int INF = int(1e9) + 100;
const ll INF64 = 2e18;
const ld PI = ld(3.1415926535897932384626433832795);
const ld e = ld(2.7182818284590452353602874713527);
const ld EPS = 1e-9;

//#############################
const int MAXN = 1000005;

int main() {
    fastIO(); 
    int ans = 0;
    string s, t;
    cin >> s >> t;

    forn(i,s.size())
        ans += (s[i] != t[i]);

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

Measured memory_bytes: 3760
#include<bits/stdc++.h>
#include<string>
#define FAST_IO   ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define Relocate freopen("./in.txt","r",stdin);freopen("./out.txt","w",stdout)
#define up(mi,a,b) for(mi=a;mi<=b;++mi)
#define down(mi,b,a) for(mi=b;mi>=a;--mi)
#define mfill(a,v) memset(a,v,sizeof(a))
#define MAX 50005
#define v_n 5005
#define e_n 5000005
#define eps 0
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define LL long long
using namespace std;
map<char, int> hh;
int main(void)
{
	int i, j, k;
	FAST_IO;
	//Relocate;
	int n;
	cin >> n;
	string a;
	cin >> a;
	up(i, 0, a.size() - 1)
	{
		if (!hh.count(a[i]))
			hh[a[i]] = 0;
		hh[a[i]]++;
	}
	LL ans = 1;
	for (auto one : hh)
	{
		//cout << one.second << endl;
		ans = (ans*(one.second+1)) % MOD;
	}
	cout << (ans+MOD-1)%MOD << endl;
	return 0;
}

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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }


/*
--------------------------------------------

	type

--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

/*
--------------------------------------------

	container

--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

/*
--------------------------------------------

	repetition

--------------------------------------------
*/
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

/*
--------------------------------------------

	constant

--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

/*
--------------------------------------------

	Optimizer

--------------------------------------------
*/
//#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*
--------------------------------------------
 
	Utility Algorithm

-------------------------------------------- 
*/

template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}
 
template <typename T1>
T1 euclideanAlgorithm(T1 a, T1 b) {
    T1 a_tmp = a;
    T1 b_tmp = b;
 
    if (a_tmp > b_tmp) {
        swapAlgorithm<T1>(a_tmp, b_tmp);
    }
 
    T1 r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

template <typename T2>
T2 getLCM(T2 a, T2 b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    LL H;
    cin >> H;
    int N;
    cin >> N;
    vector<LL> A(N);
    REP(N) cin >> A[i];

    sort(ALL(A));

    LL ans = 0;
    REP(N) {
        ans += A[i];
        if(ans >= H) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;

    return 0;
}


Measured memory_bytes: 1024
n = int(input())
A = list(map(int, input().split()))
from collections import Counter
import math
c = Counter(A)
most = 0
s = 0
for v in c.values():
    if v > 1:
        s += v - 1
        most = max(most, v-1)
if s // 2 >= most:
    result = n - math.ceil(s / 2)*2
else:
    result = max(n - most * 2, 1)
print(result)


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

#define int long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;
const long long INF = 1LL << 60;

signed main()
{

    double d, t, s;
    cin >> d >> t >> s;

    double k = d / s;

    if (t >= k)
    {
        cout << "Yes" << endl;
    }
    else
    {

        cout << "No" << endl;
    }

    return 0;
}


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

using namespace std;

using ll = long long;
const ll INF = 4e18, N = 1e5 + 15;

ll n, c, w[ 101 ], v[ 101 ], dp[ 101 ][ N ];

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

    cin >> n >> c;
    ll t = 0;
    for(ll i = 1; i <= n; i += 1) {
        cin >> w[ i ] >> v[ i ];
        t += v[ i ];
    }
    for(int i = 0; i <= n; i += 1 ) {
        for(int j = 0; j <= t; j += 1) {
            dp[ i ][ j ] = INF;
        }
    }

    for(int i = 0; i <= n; i += 1)
        dp[ i ][ 0 ] = 0;

    for(int i = 1; i <= n; i += 1) {
        for(int j = 1; j <= t; j += 1) {
            dp[ i ][ j ] = dp[ i - 1 ][ j ];
            if( j >= v[ i ] ) dp[ i ][ j ] = min(dp[ i - 1 ][ j - v[ i ] ] + w[ i ], dp[ i ][ j ] );
        }
    }
    for(int i = t; i >= 0; i -= 1) {
        if( dp[ n ][ i ] <= c ) {
            cout << i << '\n';
            exit(0);
        }
    }
    return 0;
}


Measured memory_bytes: 79232
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    g = []
    for i in range(n):
        s,p = input().split()
        p = int(p)
        g.append((s,-p,i+1))
    g.sort()
    for a,b,i in g:
        print(i)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 39152
import java.util.Scanner;

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

        while (true) {
            String a = sc.next();
            int sum = 0;
            if (a.equals("0"))
                break;
            for (int i = 0; i < a.length(); i++) {
                sum += Character.getNumericValue(a.charAt(i));
            }

            System.out.println(sum);
        }

    }
}


Measured memory_bytes: 26176
import io.StdIn.{readInt, readLine}
object Main extends App {
  val n = readInt
  val ss = for (_ <- 1 to n) yield readLine
  val m = readInt
  val ts = for (_ <- 1 to m) yield readLine

  val cards = (ss ++: ts).distinct
  val counts = cards.map(card => ss.count(_ == card) - ts.count(_ == card))
  println(math.max(0, counts.max))

}

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

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

  if (a <= b) {
      int i = 1;
  		while (i <= b) {
    		cout << a;
    		i++;
  		}
  }
  else {
      int i = 1;
  		while (i <= a) {
    		cout << b;
    		i++;
  		}
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
static const int MAX = 200000;

int main()
{
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;

	char dif = 'A' - 'a';

	cout << char(s1[0] + dif) << char(s2[0] + dif) << char(s3[0] + dif) << endl;

    return 0;
}

Measured memory_bytes: 256
/* 
 Author:N_o_o_B 
 Created:September 27 2019 20:24:18
*/
#include <bits/stdc++.h>
using namespace std;

#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define endl '\n'
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
const ll mod=1e9+7;
const ll INF=1e18;
const int maxn=2e5;
vector<ll> tree(4*maxn);
void upd(ll v,ll l,ll r,ll pos,ll val){
    if(pos<l or pos>r) return;
    if(l==r and l==pos){
        tree[v]+=val;
        return;
    }
    ll mid=(l+r)>>1;
    upd(2*v,l,mid,pos,val);
    upd(2*v+1,mid+1,r,pos,val);
    tree[v]=max(tree[2*v],tree[2*v+1]);
}
ll rec(ll v,ll l,ll r,ll ql,ll qr){
    if(qr<l or ql>r) return 0;
    if(l>=ql and r<=qr) return tree[v];
    ll mid=(l+r)>>1;
    return max(rec(2*v,l,mid,ql,qr),rec(2*v+1,mid+1,r,ql,qr));
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;
    int n;
    cin >> n;
    vl h(n);
    fori(i,n) cin >> h[i];
    vl a(n);
    fori(i,n) cin >> a[i];
    ll val=0;
    vl buff=h;
    sort(all(buff));
    map<ll,ll> m;
    fori(i,n) m[buff[i]]=val++;
    fori(i,n) h[i]=m[h[i]];
    vl dp(n);
    dp[n-1]=a[n-1];
    upd(1,0,n-1,h[n-1],a[n-1]);
    ll ans=dp[n-1];
    ford(i,n-1){
        dp[i]=a[i]+rec(1,0,n-1,h[i]+1,n-1);
        upd(1,0,n-1,h[i],dp[i]);
        ans=max(ans,dp[i]);
    }

    cout << ans << endl;
    time_taken();
    return 0;
}

Measured memory_bytes: 25216
#include<stdio.h>
#include<string.h>
#include<algorithm>
int N,W,dp[105][20005],v[105],w[105],i;

int dfs(int d,int nw)
{
	int r;
	if(dp[d][nw]>=0)return dp[d][nw];
	if(d==N)r=0;
	else if(w[d]>nw)r=dfs(d+1,nw);
	else r=std::max(dfs(d+1,nw),dfs(d+1,nw-w[d])+v[d]);
	return dp[d][nw]=r;
}

int main()
{
	memset(dp,-1,sizeof(dp));
	scanf("%d%d",&N,&W);
	for(i=0;i<N;i++)scanf("%d%d",&v[i],&w[i]);
	printf("%d\n",dfs(0,W));
	return 0;
}

Measured memory_bytes: 9240
import math
import sys
input = sys.stdin.readline


def main():
    short, loong, h, m = map(int, input().split())
    long_rad = math.radians(360 * m / 60)
    short_rad = math.radians(360 * h / 12 + (30 * m / 60))

    long_x = loong * math.cos(long_rad)
    long_y = loong * math.sin(long_rad)
    short_x = short * math.cos(short_rad)
    short_y = short * math.sin(short_rad)
    ans = math.sqrt((long_x - short_x) ** 2 + (long_y - short_y) ** 2)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9580
#include<iostream>
using namespace std;
int main(){
	int w, h;
	while (true){
		cin >> h >> w;
		if (h == 0 && w == 0){
			break;
		}
		for (int i = 0; i < w; i++){
			cout << '#';
		}
		cout << endl;
		for (int i = 0; i < h - 2;i++){
			cout << '#';
			for (int j = 0; j < w - 2; j++){
				cout << '.';
			}
			cout << '#'<<endl;
		}
		for (int i = 0; i < w; i++){
			cout << '#';
		}
		cout << endl<<endl;
	}
}


Measured memory_bytes: 3012
#include <iostream>
#include <vector>
#include <algorithm>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using ll = long long;
using namespace std;
int main() {
    int n; cin >> n;
    vector<int> a(n); repeat (i,n) cin >> a[i];
    whole(sort, a);
    ll acc = 0;
    int l = 0, r = 0;
    while (true) {
        if (r == l) {
            acc += a[l];
            ++ r;
        }
        while (r < n and a[r] <= 2*acc) {
            acc += a[r];
            ++ r;
        }
        if (r == n) break;
        ++ l;
    }
    cout << r - l << endl;
    return 0;
}

Measured memory_bytes: 640
### subroutines

def parse_name(name)
  return name.split('_') if ! name.index('_').nil?

  name[0] = name[0].upcase
  name.scan(/[A-Z][a-z]*/).map{|s| s.downcase}
end

### main

loop do
  name, type = gets.strip.split
  break if type == 'X'
  #p [name, type]

  words = parse_name(name)

  case type
  when 'U'
    puts words.map{|s| s[0] = s[0].upcase; s}.join('')
  when 'L'
    cc = words.map{|s| s[0] = s[0].upcase; s}.join('')
    cc[0] = cc[0].downcase
    puts cc
  when 'D'
    puts words.join('_')
  end
end

Measured memory_bytes: 6124
#include <stdio.h>
 
int main()
{
  int n, a, b;
  scanf("%d", &n);
  scanf("%d", &a);
  scanf("%d", &b);
  if (n*a < b)
  {
    printf("%d\n", n*a);
  }
  else
  {
    printf("%d\n", b);
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string s;
    cin >> s;
    if(s == "RRR") {
        cout << 3 << endl;
    } else if(s == "SRR" || s == "RRS") {
        cout << 2 << endl;
    } else if(s == "SSS") {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
}


Measured memory_bytes: 3644
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <tuple>
#include <vector>
#include <map>
#include <iterator>
#include <cmath>

using namespace std;
using lint = long long int;

class Route {
public:
	Route() {
		step = -1;
		last2step[0] = -1;
		last2step[1] = -1;
 	}
	int step;
	int last2step[2];
};

int move(char r_or_l) {
	if (r_or_l == 'R')
		return +1;
	else
		return -1;
}

int main() {
	string s;
	cin >> s;
	int n = s.length();

	Route* route = new Route[n];
	bool* did = new bool[n];
	for (int i = 0; i < n; i++)
		did[i] = false;

	int step = 0;
	vector<int> log;
	for (int i = 0; i < n; i++) {
		if (did[i])
			continue;
		int now = i;
		log.clear();
		log.push_back(now);

		Route* met = nullptr;
		while (true) {
			now = now + move(s[now]);
			// 過去に経路開拓済み
			if (did[now]) {
				met = &route[now];
				break;
			}

			// loopに入った
			if (log.size() >= 2 && log.at(log.size() - 2) == now) {
				break;
			}
			log.push_back(now);
		}

		if (met != nullptr) {
			for (int i = 0; i < log.size(); i++) {
				int now = log.at(i);
				route[now].step = log.size() - i + met->step;
				route[now].last2step[0] = met->last2step[0];
				route[now].last2step[1] = met->last2step[1];
				did[now] = true;
			}
		}
		else
		{
			for (int i = 0; i < log.size(); i++) {
				int now = log.at(i);
				route[now].step = log.size() - i - 2;
				route[now].last2step[0] = log.at(log.size() - 2);
				route[now].last2step[1] = log.at(log.size() - 1);
				did[now] = true;
			}
		}
		
	}

	int* children = new int[n];
	for (int i = 0; i < n; i++) {
		children[i] = 0;
	}

	for (int i = 0; i < n; i++) {
		int hoge = 1.0e+5 - route[i].step;
		if (hoge % 2 == 0)
			children[route[i].last2step[0]]++;
		else
			children[route[i].last2step[1]]++;
	}

	cout << children[0];
	for (int i = 1; i < n; i++) {
		cout << " ";
		cout << children[i];
	}

	delete[] route;
	return 0;
}


Measured memory_bytes: 2680
import java.util.*;

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

    int[] sumOfEast = new int[ N ];

    sumOfEast[ 0 ] = S.charAt( 0 ) == 'E' ? 1 : 0 ;
    for(int i = 1 ; i < sumOfEast.length; i++){
      if( S.charAt( i ) == 'E' ){
        sumOfEast[ i ] = sumOfEast[ i - 1 ] + 1;
      } else{
        sumOfEast[ i ] = sumOfEast[ i - 1 ] ;
      }
    }
    for(int i = 0 ; i < sumOfEast.length ; i ++){
//      System.out.println(sumOfEast[i]);
    }

    //端点リーダの場合　
    int countMin = sumOfEast[ N - 1 ] - sumOfEast[ 0 ]  ;
    int count    = 0;


//      System.out.println( "i = " + 0  );
//      System.out.println( "sumOfEast[ N - 1 ] - sumOfEast[ 0 ] = " + ( sumOfEast[ N - 1 ] - sumOfEast[ 0 ] ) );

    for(int i = 1; i < S.length() ; i ++){

      int West0_i = i  - sumOfEast[ i - 1 ]  ;
      int Easti1_N_1 = sumOfEast[ N - 1 ] - sumOfEast[ i ] ;
//      System.out.println( "i = " + i  );
//      System.out.println( "West0_i = " + West0_i  );
//      System.out.println( "Easti1_N_1 = " + Easti1_N_1  );

      count =  West0_i +  Easti1_N_1 ;

      if( countMin > count  ){
        countMin = count;
      }
    }
    System.out.println(countMin);


  }
}


Measured memory_bytes: 29472
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
 
#define rp(i, k, n) for (int i = k; i < n; i++)
using ll = long long;
using ld = double;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int q; cin >> q;
    vector<vector<int>> sum(n+1, vector<int>(30));
    rp(i, 0, n) {
        sum[i+1] = sum[i];
        sum[i+1][s.at(i)-'a']++;
    }
    vector<tuple<int, int, int>> q1;
    while(q--) {
        int t; scanf("%d", &t);
        if(t == 1) {
            int i; char c; cin >> i >> c; i--;
            if(s.at(i) != c) {
                q1.emplace_back(make_tuple(i, s.at(i)-'a', c-'a'));
                s.at(i) = c;
            }
        }
        if(t == 2) {
            int l, r;
            scanf("%d%d", &l, &r); l--; r--;
            vector<int> cnt(30);
            rp(i, 0, 30) {
                cnt[i] = sum[r+1][i] - sum[l][i];
            }
            for(auto x: q1) {
                if(l <= get<0>(x) and get<0>(x) <= r) {
                    cnt[get<1>(x)] --;
                    cnt[get<2>(x)] ++;
                }
            }
            int res = 0;
            rp(i, 0, 30) {
                if(cnt[i] > 0) res++;
            }
            cout << res << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 78564
#include<stdio.h>
int main(void){
    long i,c,M,N,k=0,l;
    int a[20];
    scanf("%ld",&N);
    while(N>0){
        a[k]=N%10;
        N/=10;
        k++;
    }
        M=753-(a[k-1]*100+a[k-2]*10+a[k-3]);
        if(M<0)M=-M;
        for(int j=k-2;j>=2;j--){
            c=753-(a[j]*100+a[j-1]*10+a[j-2]);
            if(c<0)c=-c;
            if(c<M)M=c;
        }
    printf("%ld\n",M);
    return 0;
}




Measured memory_bytes: 128
import sys

sys.setrecursionlimit(100000)


def dfs(cur, dep=0):
    if cur == -1:
        x = l - dep
        return x & -x
    return dfs(trie[cur][0], dep + 1) ^ dfs(trie[cur][1], dep + 1)


n, l = map(int, input().split())
trie = [[-1, -1] for _ in range(100001)]
idx = 1
for s in (input() for _ in range(n)):
    cur = 0
    for c in map(int, s):
        if trie[cur][c] == -1:
            trie[cur][c] = idx
            idx += 1
        cur = trie[cur][c]

xor = dfs(trie[0][0]) ^ dfs(trie[0][1])
print('Alice' if xor else 'Bob')


Measured memory_bytes: 118704
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI2(A, B);
  A--;
  B--;
  vector<string> ans(100);
  FOR(i, 50) ans[i] = string(100, '#');
  FORIN(i, 50, 100) ans[i] = string(100, '.');
  FOR(i, A) { ans[2 * (i / 50)][2 * (i % 50)] = '.'; }
  FOR(i, B) { ans[51 + 2 * (i / 50)][2 * (i % 50)] = '#'; }
  cout << 100 << " " << 100 << endl;
  FOR(i, 100) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		int INF = Integer.MAX_VALUE/2;
		StringBuilder ans = new StringBuilder();
		Scanner sc = new Scanner(System.in);
		int D = Integer.parseInt(sc.next());
		int[] c = new int[26];
		Arrays.setAll(c, i -> Integer.parseInt(sc.next()));
		int[][] s = new int[D][26];
		for(int i = 0; i < D; i++)
			Arrays.setAll(s[i], x -> Integer.parseInt(sc.next()));
		int[] con = new int[D];
		TreeSet<Integer>[] used = new TreeSet[26];
		for(int i = 0; i < 26; i++) {
			used[i] = new TreeSet<>();
			used[i].add(-1);
		}
		int sat = 0;
		for(int d = 0; d < D; d++) {
			int max = -INF, now = 0;
			for(int i = 0; i < 26; i++) {
				int temp = 0;
				temp += s[d][i];
				for(int j = 0; j < 26; j++)
					if(i != j)
						temp -= c[j] * (d - used[j].last());
				if(max < temp) {
					max = temp;
					now = i;
				}
			}
			con[d] = now;
			used[now].add(d);
			sat += max;
		}
		for(int i = 0; i < 26; i++)
			used[i].add(D);
		Random r = new Random();
		while(System.currentTimeMillis() - start < 1850) {
			int temp = 0;
			int d = r.nextInt(D);
			int q = r.nextInt(26);
			temp -= s[d][con[d]];
			temp += s[d][q];
			temp -= c[con[d]] * (used[con[d]].ceiling(d) - d) * (d - used[con[d]].lower(d));
			temp += c[q] * (d - used[q].lower(d)) * (used[q].ceiling(d) - d);
			if(temp > 0) {
				sat += temp;
				con[d] = q;
				used[con[d]].remove(d);
				used[q].add(d);
			}
		}
		for(int i : con)
			ans.append((i+1) + "\n");
		System.out.println(ans);
	}

}


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

int main() {
    ll n, C, a, b, c;
    cin >> n >> C;
    vector<vector<pair<ll,ll>>> channels(C+1);
    for (ll i=0; i<n; i++) {
        cin >> a >> b >> c;
        channels[c].push_back(make_pair(a,b));
    }
    for (ll i=1; i<=C; i++) sort(channels[i].begin(),channels[i].end());
    vector<ll> cumsum(100001, 0);
    for (ll i=1; i<=C; i++) {
        for (ll j=0; j<channels[i].size(); j++) {
            cumsum[channels[i][j].first-1]++;
            cumsum[channels[i][j].second]--;
            if (j>0 && channels[i][j].first==channels[i][j-1].second) {
                cumsum[channels[i][j].first]++;
                cumsum[channels[i][j].first-1]--;
            }
        }
    }
    ll res = 0;
    ll temp = 0;
    for (auto i : cumsum) {
        temp+=i;
        res = max(res,temp);
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n;
  R n;
  int a[n];
  rep(i,n) R a[i];
  int ans=0,c=1;
  REP(i,1,n) {
    if(a[i-1]==a[i]) c++;
    else {
      ans+=c/2;
      c=1;
    }
  }
  ans+=c/2;
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu) FUNC(printe) FUNC(printe0);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    string n; cin >> n;
    int sum = 0;
    for(auto& e : n){
        sum += e - '0';
    }
    cout << (sum % 9 == 0 ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 3272