akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int f = sc.nextInt();
		
		// 計算
		//int result = 0;
		HashSet<Integer> wset = new HashSet<Integer>();
		for(int i = 0; i <= f/100; i++){
		    for(int j = 0; j <= f/100; j++){
		        int w = 100*a*i + 100*b*j;
		        if(w <= f) wset.add(w); 
		    }
		}
		HashSet<Integer> sset = new HashSet<Integer>();
		for(int i = 0; i <= f; i++){
		    for(int j = 0; j <= f; j++){
		        int s = c*i + d*j;
		        if(s <= f) sset.add(s); 
		    }
		}
		int maxWS = 0;
		int maxS = 0;
		double r = -1;
		for(Integer w : wset){
		    for(Integer s : sset){
		        if(w+s <= f && s <= w/100 * e){
		            double tmp = (double)100*s/(w+s);
		            if(r < tmp){
		                r = tmp;
		                maxWS = w+s;
		                maxS = s;
		            }
		        }
		    }
		}
		
		// 出力
		System.out.println(maxWS + " " + maxS);
	}
}


Measured memory_bytes: 24996
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int X = sc.nextInt();
      int T = sc.nextInt();
      if(N%X==0){
        System.out.println(N/X*T);
      }else{
        System.out.println((N/X+1)*T);
      }
    }
}

Measured memory_bytes: 35628
//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <stdio.h>
//end of libraries ;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
// ll lmax(ll o , ll w) {if(o>w)return o; return w;}
// ll lmin(ll o , ll w) {if(o<w)return o; return w;}
#define INF 3999999999999999999
#define N 3000003
#define PI 3.14159265359
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
int n , m , x , sum;
int main(){
fcin;	
	cin>>n>>m;
	for(int i = 0 ; i< m ; i++) {
		cin>>x;
		sum += x;
	}
	if(sum > n) {cout<<-1; return 0;}
	cout<<n - sum<<endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_set>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x,y,z,k;
  cin>>x>>y>>z>>k;
  vector<ll>a(x),b(y),c(z);
  rep(i,x)cin>>a[i];
  rep(i,y)cin>>b[i];
  rep(i,z)cin>>c[i];
  a.push_back(-(ll)1e17);
  b.push_back(-(ll)1e17);
  c.push_back(-(ll)1e17);
  sort(all(a),greater<ll>());
  sort(all(b),greater<ll>());
  sort(all(c),greater<ll>());
  priority_queue<pair<ll,ll>>q;
  unordered_set<ll> ma;
  q.push({a[0]+b[0]+c[0],0});
  rep(i,k)
  {
    auto tq=q.top();q.pop();
    if(ma.count(tq.second)){i--;continue;}
    ma.insert(tq.second);
    ll x[3]={tq.second>>20,(tq.second>>10)%(1024),tq.second%1024};
    rep(j,3)
    {
      x[j]++;
      q.push({a[x[0]]+b[x[1]]+c[x[2]],(x[0]<<20)+(x[1]<<10)+x[2]});
      x[j]--;
    }
    cout<<tq.first<<"\n";
  }
  cout<<flush;
  return 0;

}


Measured memory_bytes: 640
// Aizu 1110: Patience
// 2017.9.14 bal4u@uu

#include <stdio.h>

int pair [20][5] = {
	{1,4,5}, {2,4,5,6}, {3,5,6,7}, {6,7}, {5,8,9},
	{6,8,9,10}, {7,9,10,11}, {10,11}, {9,12,13}, {10,12,13,14},
	{11,13,14,15}, {14,15}, {13,16,17}, {14,16,17,18}, {15,17,18,19},
	{18,19}, {17}, {18}, {19} };

int ans;

int combi(long long cd, int n)
{
	int i, a, b, p, q;
	long long nc, b1, b2, b3;

	if (n < ans) ans = n;
	if (n == 0) return 1;
	for (p = 0; p < n; p++) {
		a = (cd >> (p*3)) & 7;
		for (i = 0; q = pair[p][i]; i++) {
			if ((b = (cd >> (q*3)) & 7) != a) continue;
			b1 =  cd             & ((1ULL << (p*3))-1);
			b2 = (cd >> (p+1)*3) & ((1ULL << (q-p-1)*3)-1);
			b3 = (cd >> (q+1)*3) & ((1ULL << (n-q-1)*3)-1);
			nc = b1 | (b2 << (p*3)) | (b3 << (q-1)*3);
			if (combi(nc, n-2)) return 1;
		}
	}
	return 0;
}

int main()
{
	int n, i, k[20];
	long long card;

	scanf("%d", &n);
	while (n-- > 0) {
		for (i = 0; i < 20; i++) scanf("%d", k+i);
		for (card = 0, i = 19; i >= 0; i--) card = (card << 3) | k[i];
		ans = 20, combi(card, 20);
		printf("%d\n", ans);
    }
	return 0;
}

Measured memory_bytes: 1764
#include <stdio.h>
#define N 101

int main() {

  int n,i,k,l,j,u,a[N][N],v[N];
  scanf("%d",&n);
  for(i=1;i<=n;i++) {
    for(j=1;j<=n;j++){
      a[i][j] = 0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    while(k>0){
      scanf("%d",&l);
      a[u][l] = 1;
      k--;
    }
  }

  for(i=1;i<=n;i++) {
    for(j=1;j<=n;j++){
      if(j == n) {
	printf("%d",a[i][j]);
      }else{
	printf("%d ",a[i][j]);
      }
    }
    printf("\n");
  }

  
  return 0;
}

Measured memory_bytes: 2696
#include <stdio.h>
int main(void)
{
    int i,j,k,p[4],x=0,y=0,z=0,w=0;

for(i=0;i<4;i++){
    scanf("%d",&p[i]);
}

for(j=0;j<4;j++){
    if(p[j]==1){
        x=x+1;
    }
}
for(j=0;j<4;j++){
    if(p[j]==9){
        y=y+1;
    }
}
for(j=0;j<4;j++){
    if(p[j]==7){
        z=z+1;
    }
}
for(j=0;j<4;j++){
    if(p[j]==4){
        w=w+1;
    }
}

if(x==1&&y==1&&z==1&&w==1){
    printf("YES\n");
}else{
    printf("NO\n");
}

return 0;
}

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

using namespace std;

int main() {
	constexpr Int MOD = 1e9 + 7;
	int N;
	cin >> N;
	vector<int> x(N);
	for (int i = 0; i < N; ++i) { cin >> x[i]; }

	Int ans = 1;
	Int ready = 0;
	for (int i = 0; i < N; ++i) {
		++ready;
		if (x[i] >= 2 * ready - 1) { continue; }
		(ans *= ready) %= MOD;
		--ready;
	}
	for (Int i = 1; i <= ready; ++i) {
		(ans *= i) %= MOD;
	}
	cout << ans % MOD << "\n";

	return 0;
}


Measured memory_bytes: 3768
/*
	Created by Rahul Goel.
*/
 
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
 
using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1000000000;
 
#define pii pair < int, int >
#define vi vector < int >
#define vb vector < bool >
#define vvi vector < vector < int > >
#define vvb vector < vector < bool > >
#define vpii vector < pair < int, int > >
#define vvpii vector < vector < pair < int, int > > >
#define pb push_back
#define f first
#define s second
#define mp make_pair

int main(){
    string str;
    cin >> str;
    if(str[5] == str[4] && str[3] == str[2])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n;
ll a[MAX_N];

unordered_map<ll, int> amp;
ll arr[MAX_N];

bool hoge() {
  do {

    bool flg = true;

    for (int i = 0; i < n; ++i) {
      int lhs = (i - 1); if (lhs < 0) lhs += n;
      int rhs = (i + 1); rhs %= n;

      if ((a[lhs] ^ a[rhs]) != a[i]) {
        for (int i = 0; i < n; ++i) {
          printf("%lld ", a[i]);
        }
        printf(": ");
        printf("%lld, %d %d %d\n", a[lhs] ^ a[rhs], lhs, rhs, i);
        flg = false;
        break;
      }
    }

    if (flg) {
      for (int i = 0; i < n; ++i) {
        printf("%lld ", a[i]);
      }
      printf("\n");
      return true;
    }

  } while (next_permutation(a, a + n));

  return false;
}

int main(void) {
  // Here your code !
  scanf("%d", &n);

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

  // if (hoge()) {
  //   printf("PermYes\n");
  // } else {
  //   printf("PermNo\n");
  // }

  for (int i = 1; i < n; ++i) {
    amp[a[i]] += 1;
  }

  arr[0] = a[0];

  bool not_found = true;

  for (int i = 1; i < n; ++i) {
    amp[a[i]] -= 1;
    ll tmp = arr[0] ^ a[i];

    if (amp[tmp] > 0) {
      arr[1] = a[i];
      not_found = false;
      break;
    }

    amp[a[i]] += 1;
  }

  if (not_found) {
    printf("No\n");
    return 0;
  }

  for (int i = 2; i < n; ++i) {
    ll tmp = arr[i - 2] ^ arr[i - 1];

    if (amp[tmp] <= 0) {
      printf("No\n");
      return 0;
    }

    amp[tmp] -= 1;
    arr[i] = tmp;
  }

  if (arr[n - 2] ^ arr[0] == arr[n - 1]) {
    printf("Yes\n");
  }
  else {
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 5284
#include<bits/stdc++.h>
#define ll long long int
using  namespace std;
 
int main()
{
    ll a;
    double b;
    cin>>a>>b;
    ll ans = (b*100) + 0.5;
    ll result  = (a*ans) / 100;
    cout<<(result)<<endl;
 
    return 0;
}

Measured memory_bytes: 3712
N, M = map(int, input().split())
Nlist, Mlist = [], []
res = []

for i in range(N):
    ab = list(map(int, input().split()))
    Nlist.append(ab)

for i in range(M):
    cd = list(map(int, input().split()))
    Mlist.append(cd)

for i in range(N):
    res = 0
    mini = float('inf')
    for j in range(M):
        calc = abs(Nlist[i][0] - Mlist[j][0]) + abs(Nlist[i][1] - Mlist[j][1])
        if calc < mini:
            mini = calc
            res = j+1
    print(res) 

Measured memory_bytes: 9224
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
signed main(){
	int n,m=1;
	cin>>n;
    for(int i=1;i<=n;i++){
        if(n%i!=0)continue;
        if(n/i<10 && m*i<10){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
s = [list(input()) for i in range(H)]
n = [[0]*(W+2) for i in range(H+2)]
dxy = [(-1,-1),(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1)]

for h in range(H):
  for w in range(W):
    if s[h][w] == '#':
      for i in dxy:
        n[h + 1 + i[0]][w + 1 + i[1]] += 1

for i in range(H):
  for j in range(W):
    if s[i][j] == '#':
      n[i + 1][j + 1] = '#'
    else:
      n[i + 1][j + 1] = str(n[i + 1][j + 1])

for a in n[1:H+1]:
    print(''.join(a[1:W+1]))

Measured memory_bytes: 3188
//include
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

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

//change
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

//math
template <class T>
inline T sqr(T x) { return x * x; }

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())

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

//constant
constexpr double EPS = 1e-10;
const double PI = acos(-1.0);
constexpr LL INF = 1e10;

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

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

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    for (int &x : p)
    {
        cin >> x;
    }
    int cnt = 0, min_p, max_p;
    for (int i = 1; i < n - 1; ++i)
    {
        min_p = min({p[i - 1], p[i], p[i + 1]});
        max_p = max({p[i - 1], p[i], p[i + 1]});
        if (min_p < p[i] && p[i] < max_p)
        {
            ++cnt;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
// Aaradhya Beri
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define w(x) int x; cin>>x; while(x--)
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}
 

signed main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    string s;
    cin >> s;
    string sr = s;
    reverse(sr.begin(), sr.end());
    cout << (s.size() - sr.find('Z')) - s.find('A') << endl;
    return 0;
}

Measured memory_bytes: 788
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

#define PI 3.14159265358979323846264338327950L

ll res;

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

    ll X,K,D;
    cin >> X >> K >> D;
    X = abs(X);

    ll straight = min(K, X / D);
    K -= straight;
    X -= straight * D;

    if (K % 2 == 0){
        cout << X << endl;
    } else {
        cout << D - X << endl;
    }
    return 0;
}

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

template <typename T> void chmin(T&x,const T &y)
{
	if(x>y)x=y;
}
template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
typedef long long s64;
typedef unsigned long long u64;
typedef unsigned int u32;
typedef pair<int,int> pii;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define rep0(i,l,r) for(int i=l;i<r;++i)
#define gc (c=getchar())
int read()
{
	char c;
	while(gc<'-');
	if(c=='-')
	{
		int x=gc-'0';
		while(gc>='0')x=x*10+c-'0';
		return -x;
	}
	int x=c-'0';
	while(gc>='0')x=x*10+c-'0';
	return x;
}
#undef gc

const int N=1000+5;
s64 sum[N];

int main()
{
#ifdef kcz
	freopen("1.in","r",stdin);//freopen("1.out","w",stdout);
#endif
	int n=read(),k=read();
	rep(i,1,n)sum[i]=sum[i-1]+read();
	s64 ans=0;
	per(i,60,0)
	{
		ans+=1LL<<i;
		int cnt=0;
		rep(l,1,n)
		rep(r,l,n)cnt+=((sum[r]-sum[l-1])&ans)==ans;
		if(cnt<k)ans-=1LL<<i;
	}
	cout<<ans;
}


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

using namespace std;

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

	int alf[30] = { };
	for(int i = 0; i < 26; i++) alf[i] = 110000000;
	
	for(int i = 0; i < n; i++) {
		string S;
		cin >> S;
		int tmp[30] = { };
		for(int j = 0; j < S.size();j ++) tmp[S[j] - 'a']++;
		for(int j = 0; j < 26; j++) alf[j] = min(alf[j], tmp[j]);
	}
	for(int i = 0; i < 26; i++) {
		for(int j = 0; j < alf[i]; j++) printf("%c", 'a'+i);
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    matrix = [[int(num) for num in input().split()] for _ in range(2)]

    candies = [sum(matrix[0][:d+1]) + sum(matrix[1][d:]) for d in range(n)]
    print(max(candies))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,i,ans=0;cin>>N;
  vector<ll>A(N);
  REP(i,N)cin>>A.at(i);
  sort(ALL(A));reverse(ALL(A));
  REP(i,N-1)ans+=A.at((i+1)/2);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4840
import core.bitop;
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.format;
import std.math;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
  int k = readln.chomp.to!int;
  int[] done = new int[](k);
  done[] = int.max;
  done[1] = 1;
  int[] queue = [1];
  while (queue.length)
  {
    int node = queue.front;
    queue = queue[1 .. $];
    int next10 = (node * 10) % k;
    if (done[node] < done[next10])
    {
      done[next10] = done[node];
      queue = next10 ~ queue;
    }
    int next1 = (node + 1) % k;
    if (done[node] + 1 < done[next1]) {
      done[next1] = done[node] + 1;
      queue ~= next1;
    }
  }
  done[0].writeln;
}


Measured memory_bytes: 5244
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const ll inf=1e18+7 ;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll a,b;
    cin>>a>>b;
    cout<<max(a-2*b,0LL)<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << (#x) << ": " << (x) << endl
#define DEBUG_VEC(v)            \
    cerr << #v << ": ";         \
    REP(__i, (v).size())        \
    cerr << ((v)[__i]) << ", "; \
    cerr << endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main()
{
    ios::sync_with_stdio(false);
    string s;
    cin >> s;

    int cnt = 0;
    REP(i, s.size()) if (s[i] == '0') cnt++;
    cout << 2 * min(cnt, (int)s.size() - cnt) << endl;

    return 0;
}


Measured memory_bytes: 512
var
  n,k,i,m,j,t,ans,b,c,d:longint;
  p,q,o,x,y:real;
  s:string;
begin
  readln(s);
  for i:=1 to length(s) do
  if s[i]='2' then inc(n);
  writeln(n);
end.

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
int main(){
  char b[2];

  scanf("%s", b);

  if(b[0] == 'A'){
    printf("T");
  }else if(b[0] == 'T'){
    printf("A");
  }else if(b[0] == 'C'){
    printf("G");
  }else if(b[0] == 'G'){
    printf("C");
  }
  
  printf("\n");


}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mod 1000000007
#define PI 3.1415926535
#define maxn 100005
#define all(x) x.begin(),x.end()
#define speedUp ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
void CyBerForCe()
{
    int n;
    cin>>n;
    map <int,int> mp;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        mp[a]++;
    }
    int ans=0;
    for(auto i: mp)
    {
        if(i.second >= i.first)
        ans+= (i.second-i.first);
        else
        ans+=(i.second);
    }
    cout<<ans<<"\n";
}
signed main()
{
    speedUp
    /*int t;
    cin>>t;
    while(t--)*/
    CyBerForCe();
    return 0;
}

Measured memory_bytes: 9612
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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() {
    string s; cin >> s;
    bool ok = true;
    if (s[2] != s[3] || s[4] != s[5]) ok = false;
    cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

int main() {
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll sum = 0;
    const ll mod = 1e9+7;

    rep(i,60) {
        int cnt = 0;
        rep(j,n) {
            if (a[j] & (1ll<<i)) cnt++;
        }
        (sum += (1ll<<i)%mod*cnt%mod*(n-cnt)) %= mod;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

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

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt(),k=nxt(),c=nxt();
    string s;
    cin>>s;
    set <int> s2;
    map <int,set <int> ,greater<int> > m2;
    set <int> r;
    vector <int> ans(n);
    map <int,int> m3,m4;
    for(int i=n-1;i>=0;i--)
    {
        if(s[i]=='o')
        {
            auto it=s2.lower_bound(i+c+1);
            int val=1;
            if(it!=s2.end())
                val+=ans[*it];
            if(val>k)
                val=k;
            if(m2.find(val)==m2.end())
                m2[val]=r;
            m2[val].insert(i);
            ans[i]=val;
            if(m3.find(k-val+1)==m3.end())
            	m3[k-val+1]=i;
            s2.insert(i);
        }
    }
 
    int p2=-1e6;
    int cur2=0;
    for(int i=0;i<=n-1;i++)
    {
        if(s[i]=='o')
        {
            if(i>=p2+c+1)
            {
            	cur2++;
            	m4[cur2]=i;
            	p2=i;
            }
        }
    }
    
    
    vector <int> test;
    for(auto it=m3.begin();it!=m3.end();it++){
    	if(it->second==m4[it->first])
    		test.push_back(it->second+1);
    	//cout<<it->first<<" "<<it->second<<" "<<m4[it->first]<<endl;
    }
   

    for(int i=0;i<test.size();i++)
        cout<<test[i]<<endl;
   
    
    return 0;   
}




 
 


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

int getNextTurn(int currentTurn, string decks[]){
    if(decks[currentTurn].length() == 0){
        return -1;
    }
    int nextTurn = decks[currentTurn][0] - 'a';
    decks[currentTurn] = decks[currentTurn].substr(1);
    return nextTurn;
}

int main(){
    string decks[3];
    for(int i=0; i<3; i++){
        cin >> decks[i];
    }

    int currentTurn = 0;
    while(true){
        int nextTurn = getNextTurn(currentTurn, decks);
        if(nextTurn < 0){
            cout << ((char)('A'+currentTurn)) << '\n';
            break;
        }
        currentTurn = nextTurn;
    }
}


Measured memory_bytes: 3036
n=int(input())
A=list(map(int,input().split()))
for i in range(n):
  if A[i]==0:
    print(0)
    exit()
ans=1
for i in range(n):
  ans*=A[i]
  if ans>1e18:
    print(-1)
    exit()
print(ans)

Measured memory_bytes: 21604
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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 cnt[100010];
int a[100010];

int main () {
  int N; cin >> N;
  vi a(N); REP(i,N) cin >> a[i];

  int ans = 0;
  REP(i,N) {
    if (a[i] > N) {
      ans++;
    }
    else {
      cnt[a[i]]++;
    }
  }

  REPS(i,N) {
    if (cnt[i] < i) {
      ans += cnt[i];
    }
    else {
      ans += cnt[i] - i;
    }
  }
  
  cout << ans << endl;
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;

struct UnionFind {
  vector<int> par;
  UnionFind(int n) : par(n, -1) { }
  
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if(x==y)return false;
    if(par[y]<par[x])swap(x,y);
    par[x]+=par[y];par[y]=x;
    return true;
  }
  
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  
  int size(int x) {
    return -par[root(x)];
  }
  int root(int x) {
    return par[x] < 0 ? x : par[x] = root(par[x]);
  }
};;

map<ll,ll>mama;
signed main(){
  ll n,k,l;
  cin>>n>>k>>l;
  UnionFind uni(n);
  UnionFind uni2(n);
  for(int i=0;i<k;i++){
    int p,q;cin>>p>>q;p--;q--;
    uni.unite(p,q);
  }
  for(int i=0;i<l;i++){
    int p,q;cin>>p>>q;p--;q--;
    uni2.unite(p,q);
  }
  vector<pair<int,int> >num1(n);
  vector<pair<int,int> >num2(n);
  for(int i=0;i<n;i++){
    num1[i]=mp(uni.root(i),uni2.root(i));
    num2[i]=num1[i];
  }
  sort(num1.begin(),num1.end());
  
  int cnt=1;
  for(int i=0;i<n-1;i++){
    while(num1[i].F==num1[i+1].F&&num1[i].S==num1[i+1].S&&i!=n-2){
      cnt++;
      i++;
    }
    if(i==n-2&&num1[i].F==num1[i+1].F&&num1[i].S==num1[i+1].S)
      mama[num1[i].F*(1e6)+num1[i].S]=(cnt+1);
    else {
      mama[num1[i].F*(1e6)+num1[i].S]=(cnt);
      mama[num1[i+1].F*(1e6)+num1[i+1].S]=1;
    }
    cnt=1;
  }
  for(int i=0;i<n;i++){
    cout<<mama[num2[i].F*(1e6)+num2[i].S];
    if(i!=n-1)
      cout<<" ";
  }
  cout<<endl;

  return 0;
}

Measured memory_bytes: 16640
/********************/
/* K B G D E L T A */
/*     DA-IICT      */
/********************/
 
#include<bits/stdc++.h>
using namespace std;
using   ll=long long;
using   ld=long double;
#define fast           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl           "\n"
#define F(i,n)         for(ll i=0;i<n;i++)
#define rep(i,a,b)     for(ll i=a;i<b;i++)
#define repp(i,a,b)    for(ll i=a;i>=b;i--)
#define pb             push_back
#define mp             make_pair
#define vll            vector<ll>
#define f              first
#define s              second
#define pll            pair<ll,ll>
#define ALL(v)         v.begin(),v.end()
#define ALLR(v)        v.rbegin(),v.rend()
#define pii            3.14159265358979323
#define mod            1000000007

void dfs(vector<vll> & a,ll node,vll & val,vll & vis)
{
    vis[node]=1;

    for(auto u:a[node])
    {
        if(!vis[u])
        {
            val[u]+=val[node];

            dfs(a,u,val,vis);
        }
    }
}
 
void solve()
{
    ll n,q,x,y;

    cin>>n>>q;

    vector<vll> a(n+1);
    
    F(i,n-1)
    {
        cin>>x>>y;

        a[x].pb(y);

        a[y].pb(x);
    }

    vll vis(n+1,0);

    vll val(n+1,0);

    while(q--)
    {
        cin>>x>>y;

        val[x]+=y;
    }

    dfs(a,1,val,vis);

    for(int i=1;i<=n;i++)
    {
        cout<<val[i]<<" ";
    }
}
 
signed main(){
 
    fast;
 
    ll t=1;
 
    //cin>>t;
 
    while(t--)
    {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 28928
n,a,b=map(int,input().split())
L=list(input())
Ans=["No" for _ in range(n)]
cnt=0
cnt_b=0
for i in range(n):
    if L[i]=="a" and cnt<a+b:
        Ans[i]="Yes"
        cnt+=1
    elif L[i]=="b" and cnt<a+b and cnt_b<b:
        Ans[i]="Yes"
        cnt+=1
        cnt_b+=1
for i in range(n):
    print(Ans[i])

Measured memory_bytes: 5480
import java.util.Arrays;
import java.util.Scanner;

class Main {

  public static void reverse(int[] A) {
    for (int i = 0; i < A.length / 2; i++) {
      int tmp = A[i];
      A[i] = A[A.length - i - 1];
      A[A.length - i - 1] = tmp;
    }
  }

  private static final int[] num = { 999999, 2, 5, 5, 4, 5, 6, 3, 7, 6 };

  private static final int INF = Integer.MAX_VALUE / 4;

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N = Integer.parseInt(scanner.next());
    int M = Integer.parseInt(scanner.next());
    int[] A = new int[M];
    for (int i = 0; i < M; i++) {
      A[i] = Integer.parseInt(scanner.next());
    }
    Arrays.sort(A);
    reverse(A);
    int[] dp = new int[10010];
    Arrays.fill(dp, -INF);
    dp[0] = 0;
    for (int i = 0; i <= N; i++) {
      for (int j = 0; j < M; j++) {
        if (i - num[A[j]] >= 0) {
          dp[i] = Math.max(dp[i], dp[i - num[A[j]]] + 1);
        }
      }
    }
    String ans = "";
    int goal = dp[N];
    for (int k = 0; k < goal; k++) {
      for (int i = 0; i < M; i++) {
        if (N - num[A[i]] >= 0 && dp[N] != 0 && dp[N - num[A[i]]] == dp[N] - 1) {
          ans += A[i];
          N -= num[A[i]];
          break;
        }
      }
    }
    System.out.println(ans);
  }

}


Measured memory_bytes: 59732
<?php

[$S] = fscanf(STDIN, "%s");

$s = str_split($S);
$max = 0;
$ans = 0;
foreach($s as $value){
    if($value === "R"){
        $ans++;
    }else{
        $max = max($max, $ans);
        $ans = 0;
    }

}
$max = max($max, $ans);
echo $max;

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

using namespace std;

using ll = long long;

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

    int x, y, z;
    cin >> x >> y >> z;

    int n = x / (y + z);
    if (z <= x - n * (y + z)) cout << n << endl;
    else cout << n - 1 << endl;

    return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int ma = abs(a[0]), id = 0;
    REP(i, 1, n) if(abs(a[i]) > ma) {
        ma = abs(a[i]);
        id = i;
    }
    if(a[id] == 0) {
        cout << 0 << endl;
        return 0;
    }

    vector<pii> ans;
    rep(i, n) if(id != i) ans.emplace_back(id, i);


    if(a[id] > 0) {
        REP(i, 1, n) ans.emplace_back(i-1, i);
    }
    else {
        for(int i = n-2; i>= 0; --i) ans.emplace_back(i+1, i);
    }
    cout << ans.size() << endl;
    rep(i, ans.size()) {
        cout << ans[i].fi+1 << " " << ans[i].se+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef map<int,int> mi;
typedef set<int> si;
typedef queue<int> qi;
typedef stack<int> sti;

#define  mod 1000000007 
#define  endl '\n'
#define  F first
#define  S second
#define  pb push_back
#define  mp make_pair
#define  mt make_tuple
#define f(i,a,b) for(int i=a;i<n;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)

template <typename T> void debug(T x) {  cout<<x<<endl;}
template <typename T> void debug(T x,T y) { cout<<x<<" "<<y<<endl;}
template <typename T> void debug(T a[]) { for(int i=0;i<a.size();i++) { cout<<a[i]<<" ";} cout<<endl; }
template <typename T> void debug(vector<T> a) { for(int i=0;i<a.size();i++) { cout<<a[i]<<" ";} cout<<endl; }
template <typename T> void debug(set<T> s) { for(T x:s) {  cout<<x<<" ";} cout<<endl;}
template <typename T> void debug(map<T,T> m) { for(auto i=m.begin();i!=m.end();i++) { cout<<i->first<<" "<<i->second;cout<<endl; }}
template <typename T> void debug(set<pair<T,T>> p) {for(auto x:p){     cout<<x.first<<" "<<x.second; cout<<endl; } }
template<typename T>  void debug(stack<T> s) { while(!s.empty()) {cout<<s.top()<<" "; s.pop();} cout<<endl; }
template <typename T> void debug(queue<T> q) {  while(!q.empty()) { cout<<q.front()<<" "; q.pop();}  cout<<endl; }

//                                        ****modulo operation****

inline ll add(ll a,ll b) { a+=b; if(a>=mod) return a-mod; return a; }
inline ll sub(ll a,ll b) { a-=b;  if(a-b<0)   return a+mod;  return a; }
inline ll mul(ll a,ll b)  {  return (a*b)%mod; }
inline ll divide(int a,int b) {  b=pow(b,mod-2); return (a*b)%mod; }
inline ll power(ll x,ll y) { ll ans=1; while(y) { if(y&1) ans*=x; x=x*x; y>>=1;} return ans;}
inline ll inv(ll x) {  return power(x,mod-2); }  

//*****************************************  code starts from here   ********************************************


void solve()
{
    ll a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
  
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
    for(int i=1;i<=t;i++)
    {
        solve();
    }
    
}

Measured memory_bytes: 3608
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int a, b, c;
    cin >> a >> b >> c;
    int mx = max(a, max(b, c));
    cout << (a + b + c - mx) << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 256
use std::collections::VecDeque;
use std::cmp;

fn main() {
    proconio::input! {
        mut k: usize,
    }
    let mut que = VecDeque::new();
    for i in 1..10 {
        que.push_back((i as i64, i as i64));
    }
    while k > 0 {
        k -= 1;
        let t = que.pop_front().unwrap();
        if k == 0 {
            println!("{}", t.0);
        }
        for i in cmp::max(0, t.1 - 1)..=cmp::min(9, t.1 + 1) {
            que.push_back((10 * t.0 + i, i));
        }
    }
}


Measured memory_bytes: 6064
#include <vector>
#include <algorithm>
#include <climits>

class segment_tree
{
private:
	std::vector<int>treedat;
	int treesiz;
	static const int inf = INT_MAX;
	int rawqry(int a, int b, int k, int l, int r)
	{
		if (r <= a || b <= l)return inf;
		if (a <= l && r <= b)return treedat[k];
		int m = (l + r) / 2;
		return std::min(rawqry(a, b, k * 2 + 1, l, m), rawqry(a, b, k * 2 + 2, m, r));
	}
public:
	void update(int k, int a)
	{
		k += (treesiz - 1);
		treedat[k] = a;
		while (k > 0)
		{
			k = (k - 1) / 2;
			treedat[k] = std::min(treedat[k * 2 + 1], treedat[k * 2 + 2]);
		}
	}
	int query(int a, int b) { return rawqry(a, b, 0, 0, treesiz); }
	segment_tree(int n)
	{
		treesiz = 1;
		while (treesiz < n)treesiz *= 2;
		treedat.resize(2*treesiz+1);
		std::fill(treedat.begin(), treedat.end(), inf);
	}
};

segment_tree* st;

int n, q;

int main()
{
	scanf("%d %d", &n, &q);
	st = new segment_tree(n);
	for (int i = 0; i < q; ++i)
	{
		int com, x, y;
		scanf("%d %d %d", &com, &x, &y);
		if (com == 0)
		{
			st->update(x, y);
		}
		else
		{
			printf("%d\n", st->query(x, y + 1));
		}
	}
	return 0;
}

Measured memory_bytes: 3772
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


from collections import defaultdict
n = int(input())
ns = defaultdict(set)
uvs = [None]*(n-1)
for i in range(n-1):
    u,v = map(int, input().split())
    u -= 1
    v -= 1
    ns[u].add(v)
    ns[v].add(u)
    uvs[i] = (u,v)

s = [(0, -1)]
cs = {(0,-1): -1}
seen = [False]*n
seen[0] = True
while s:
    u,prev = s.pop()
    val = 0
    cc = cs[u,prev]
    for v in ns[u]:
        if seen[v]:
            continue
        if val==cc:
            val += 1
        cs[v,u] = val
        val += 1
        seen[v] = True
        s.append((v,u))
ans = []
for u,v in uvs:
    if (u,v) in cs:
        ans.append(cs[u,v]+1)
    else:
        ans.append(cs[v,u]+1)
print(max(ans))
write("\n".join(map(str, ans)))

Measured memory_bytes: 138404
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()

left = 0
right = 100
while right > left + 1:
    mid = (left + right) // 2
    if N < K ** mid:
        right = mid
    else:
        left = mid

print(right)


Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func main() {
	sc := NewScanner()
	K, X := sc.nextInt(), sc.nextInt()
	nums := []int{}
	for i := X - K + 1; i < X+K; i++ {
		nums = append(nums, i)
	}
	for i, v := range nums {
		if i != 0 {
			fmt.Print(" ")
		}
		fmt.Print(v)
	}
	fmt.Println()
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
	
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		
		int n=Integer.parseInt(scan.next());
		char[][]s=new char[n][10];
		String tmp;
		for (int i=0;i<n;++i) {
			tmp=scan.next();
			for (int k=0;k<10;++k) {
				s[i][k]=tmp.charAt(k);
			}
		}
		for (int i=0;i<n;++i) {
			Arrays.parallelSort(s[i]);
		}
		
		String[] s_sort =new String[n];
		
		for (int i=0;i<n;++i) {
			s_sort[i]=String.valueOf(s[i]);
		}
		Arrays.parallelSort(s_sort);

		long ans=0;
		long count=1;
		for (int i=0;i<n-1;++i) {
			if (s_sort[i].equals(s_sort[i+1])) { 
				++count;				
			}else {
				if (count>1) {
					ans+=count*(count-1)/2;
					
				}count=1;

			}
		}
		if (count>1) {
			ans+=count*(count-1)/2;
		}
		
		System.out.print(ans);
		

		
}
}
//end

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

int main(){
    long long n;
    cin>>n;
    if(n==1){
        cout<<"0";
        return 0;
    }
    long long a,count=0,i;
    a=sqrt(n)+1;
    map<int,int> mp;
    for(i=2;i<=a;i++){
        while(n%i==0){
            n/=i;
            mp[i]++;
            a=sqrt(n)+1;
        }
    }
    if(n!=1){
        mp[n]++;
    }
    // for(auto a:mp){
    //     cout<<a.first<<" "<<a.second<<endl;
    // }
    int ans=0;
    for(auto a:mp){
        for(int i=1;a.second-i>=0;i++){
            a.second-=i;
            ans++;
        }
    }
    cout<<ans;
}


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

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define mod (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vb vector<bool>
#define vs vector<string>
#define vii vector<vector<int>>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()

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

void print(bool f)
{
    cout << (f ? "Yes" : "No") << endl;
}

void Print(bool f)
{
    cout << (f ? "YES" : "NO") << endl;
}

int main(void)
{
    ll n, a, b;
    cin >> n >> a >> b;
    vll x(n);
    rep(i, 0, n) cin >> x[i];

    ll ans = 0;
    rep(i, 1, n)
        ans += ((x[i] - x[i - 1]) * a <= b) ? (x[i] - x[i - 1]) * a : b;
    cout << ans << endl;
}

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

namespace HABIT{
    #define f(a,b,c,d) for(register int a=b,c=d;a<=c;a++)
    #define g(a,b,c,d) for(register int a=b,c=d;a>=c;a--)
    #define LOCAL
    typedef int i32;
    typedef unsigned int u32;
    typedef long long int i64;
    typedef unsigned long long int u64;
    typedef pair<i32,i32> pii;
    const i32 MAXN=1024;
    typedef i32 ar[MAXN];
    
    template<typename T> inline T Max(T a) { return a; }
    template<typename T,typename... Args> inline T Max(T a,Args... args){
        T b=Max(args...);
        return (a>b)?a:b;
    }
    template<typename T> inline T Min(T a) { return a; }
    template<typename T,typename... Args> inline T Min(T a,Args... args){
        T b=Min(args...);
        return (a<b)?a:b;
    }

    #ifdef LOCAL
        inline char gc() { return getchar(); }
    #else
        inline char gc() {
            static char s[1<<20|1]={0},*p1=s,*p2=s;
            return (p1==p2)&&(p2=(p1=s)+fread(s,1,1<<20,stdin),p1==p2)?EOF:*(p1++);
        }
    #endif
    inline i64 read(){
        register i64 ans=0;register char c=gc();register bool neg=0;
        while(c<48||c>57) neg^=!(c^'-'),c=gc();
        while(c>=48&&c<=57) ans=(ans<<3)+(ans<<1)+(c^48),c=gc();
        return neg?-ans:ans;
    }

    char Output_Ans[1<<20|1],*Output_Cur=Output_Ans;
    inline void output() { Output_Cur-=fwrite(Output_Ans,1,Output_Cur-Output_Ans,stdout); }
    inline void print(char c){
        if(Output_Cur-Output_Ans+1>>20) output();
        *(Output_Cur++)=c;
    }
    inline void print(char *s) { while(*s) print( *(s++) ); }
    inline void print(u64 x){
        if(!x) { print('0'); return ; }
        char buf[30]={0},*p=buf+28;
        while(x) *(p--)=x%10+48,x/=10;
        print(p+1);
    }
    inline void print(u32 x) { print( (u64)x ); }
    inline void print(i64 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
    inline void print(i32 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
}
using namespace HABIT;

char s[200010];

int main(){
    char c;
    while(c=gc(),c!=EOF)
        print((c=='?')?'D':c);
    output();
    return 0;
}

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

int N,K;
string s;
int cnt;
int ans;
int main()
{
    cin>>N>>K;
    cin>>s;
    cnt=1;
    for(int i=1;i<s.length();i++)
    {
        if(s[i]!=s[i-1])
            cnt++;
        else
            ans++;
    }
    ans+=K*2;
    ans=min(N-1,ans);
    cout<<ans;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
int L[2005];
int temp[2005];

void merge(int low,  int mid, int high)
{
	int l1,l2,i;
	for(l1=low, l2=mid+1, i=low; l1 <=mid && l2 <=high; i++) 
	{
		if(L[l1] <= L[l2])
			temp[i]=L[l1++];
		else
			temp[i]=L[l2++];
	}
	while(l1 <= mid)
		temp[i++] = L[l1++];

	while(l2 <= high)
		temp[i++] = L[l2++];

	for(i = low; i<=high; i++)
		L[i]=temp[i];
}

void sort(int low, int high)
{
	int mid;
	if(low<high){
		mid = (low+high)/2;
		sort(low,mid);
		sort(mid+1,high);
		merge(low,mid,high);
	}else{
		return;
	}
	return;
}

int main()
{
	int N;
	int i;
	int j;
	int k;
        int set;
	int count=0;

	scanf("%d",&N);
	for(i=0;i<N;i++) scanf("%d",&L[i]);
        sort(0,N-1);
	for(i=0;i<N-2;i++)
	{
		for(j=i+1;j<N-1;j++)
		{
			for(k=j+1;k<N;k++)
			{
				if ( L[k]<(L[i]+L[j]) ) 
					count++;
				else
					break;
			}
		}
	}
	printf("%d\n",count);

	return 0;
}


Measured memory_bytes: 128