akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

int main()
{
  int W, H, N, count=0;
  cin >> W >> H >> N;
  int x[N]={0}, y[N]={0}, a[N]={0};
  int p[W][H] = {0};

  for (int i = 0; i < N; ++i) {
    cin >> x[i] >> y[i] >> a[i];
  }

  // 色塗り
  for (int i = 0; i < N; ++i) {
    switch(a[i]){
    case 1:
      for (int j = 0; j < x[i]; ++j) {
        for (int k = 0; k < H; ++k) {
          p[j][k] = 1;
        }
      }break;

    case 2:
      for (int j = x[i]; j < W; ++j) {
        for (int k = 0; k < H; ++k) {
          p[j][k] = 1;
        }
      }break;

    case 3:
      for (int j = 0; j < W; ++j) {
        for (int k = 0; k < y[i]; ++k) {
          p[j][k] = 1;
        }
      }break;

    case 4:
      for (int j = 0; j < W; ++j) {
        for (int k = y[i]; k < H; ++k) {
          p[j][k] = 1;
        }
      }break;
    }
  }

  for (int i = 0; i < W; ++i) {
    for (int j = 0; j < H; ++j) {
      if(p[i][j]==0) ++count;
    }
  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
// abc129_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int N, M;
    cin >> N >> M;

    vector<bool> A(N+1, false);
    REP(i, M) {
        int p;
        cin >> p;
        A[p] = true;
    }

    vector<int> dp(N+1);

    dp[0] = 1;
    dp[1] = A[1] ? 0 : 1;
    REPN(i, 2, N+1){
        if (A[i]){
            dp[i] = 0;
        } else {
            dp[i] = dp[i-1] + dp[i-2];
            dp[i] %= MOD;
        }
    }

    print(dp[N]);

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define loop(i,L,R) for(int i=(L);i<=(R);i++)
#define rept(i,L,R) for(int i=(L);i<(R);i++)
#define isc(n) scanf("%d",&n)
#define llsc(n) scanf("%lld",&n)
#define dsc(n) scanf("%lf",&n)
#define enl cout<<endl
#define pb(x) push_back(x)
#define xx first
#define yy second
typedef long long ll;
typedef pair<int,int>PI;
typedef pair<pair<int,int>,int>PII;

int main()
{
	int a,b,n;
	cin>>n>>a>>b;
	int k=abs(b-a)-1;
	if(k%2==0)cout<<"Borys"<<endl;
	else cout<<"Alice"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main{
    
    static final int MAX = (int)1e9+1;
    
    /*
    이문제는 도시를 여행하는데,
    도시를 여행할때마다 L이라는 연료가 소모되고 각 도시를 지나갈때마다 연료를 충전할 수 있다.
    우리가 찾고자 하는것은 최소한의 연료충전으로 도시를 까지 여행할 수 있는 충전 횟수를 구하는것이 목표이다.
    Q로 여러개의 질답이 나오기 때문에 미리 행렬에 최단거리 ( L을 거리로 친다.)를 기록하는것이 더 유리하다.
    
    */
    public static int[][] maps=new int[301][301];
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n,m,l,a,b,c,q,s,t;
        n=sc.nextInt();
        m=sc.nextInt();
        l=sc.nextInt();
        for(int i=0;i<n;i++) {
        	for(int j=0;j<n;j++) {
        		maps[i][j]=MAX;
        	}
        }
        for(int i=0;i<n;i++) {
        	maps[i][i]=0;
        }
        for(int i=0;i<m;i++) {
        	a=sc.nextInt()-1;
        	b=sc.nextInt()-1;
        	c=sc.nextInt();
        	maps[a][b]=c;
        	maps[b][a]=c;
        }
        
        //첫번째 floyd
        for(int i=0;i<n;i++) {
        	for(int j=0;j<n;j++) {
        		for(int k=0;k<n;k++) {
        			int sum=maps[j][i]+maps[i][k];
        			maps[j][k]=Math.min(sum, maps[j][k]);
        		}
        	}
        }
        
        //걸러낸다 !
        for(int i=0;i<n;i++) {
        	for(int j=0;j<n;j++) {
        		if(maps[i][j]<=l)
        			maps[i][j]=1;
        		else
        			maps[i][j]=MAX;
        	}
        }
        
        //다시한번 floyd
        for(int i=0;i<n;i++) {
        	for(int j=0;j<n;j++) {
        		for(int k=0;k<n;k++) {
        			int sum=maps[j][i]+maps[i][k];
        			maps[j][k]=Math.min(sum, maps[j][k]);
        		}
        	}
        }
        
        
        q=sc.nextInt();
        for(int i=0;i<q;i++) {
        	s=sc.nextInt()-1;
        	t=sc.nextInt()-1;
        	int ans=maps[s][t];
        	if(ans==MAX)
        		System.out.println(-1);
        	else
        		System.out.println(ans-1);
        }
        
    }
}


Measured memory_bytes: 91812
import bisect,collections,copy,itertools,math,numpy,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
A,B,C = LI()
B,A = A,B
C,A = A,C
print(A,B,C)


Measured memory_bytes: 12596
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long LL;
typedef pair<int,int> PII;
#define X first
#define Y second
inline int read()
{
    int x=0,f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c)){x=x*10+c-'0';c=getchar();}
    return x*f;
}
const int maxn=3010;
int n,m,K,x,y,v,a[maxn][maxn];
LL dp[maxn][maxn][4];
int main()
{
    n=read();m=read();K=read();
    for(int i=1;i<=K;i++)
    {
        x=read();y=read();v=read();
        a[x][y]=v;
    }
    dp[1][1][0]=0;
    if(a[1][1])dp[1][1][1]=a[1][1];
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            for(int k=0;k<=3;k++)
            {
                if(i+1<=n)
                {
                    dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][k]);
                    if(a[i+1][j])dp[i+1][j][1]=max(dp[i+1][j][1],dp[i][j][k]+a[i+1][j]);
                }
                if(j+1<=m)
                {
                    dp[i][j+1][k]=max(dp[i][j+1][k],dp[i][j][k]);
                    if(a[i][j+1] && k<=2)dp[i][j+1][k+1]=max(dp[i][j+1][k+1],dp[i][j][k]+a[i][j+1]);
                }
//                printf("%d %d %d %lld\n",i,j,k,dp[i][j][k]);
            }
    printf("%lld\n",max(max(dp[n][m][1],dp[n][m][0]),max(dp[n][m][2],dp[n][m][3])));
    return 0;
}
/*

*/

Measured memory_bytes: 320580
class SegmentTree
  def initialize(size, default:, value: nil, update: -> (nv, _) { nv }, merge:)
    n = 1
    while n < size
      n *= 2
    end
    @size = n
    @default = default
    @update_proc = update
    @merge_proc = merge
    @data = Array.new(n * 2 - 1, default)
    init_by_value(value) if value
  end

  # 0-origin
  def update(k, a)
    k += @size - 1
    @data[k] = @update_proc.call(a, @data[k])
    while k > 0
      k = (k - 1) / 2
      @data[k] = @merge_proc.call(@data[k * 2 + 1], @data[k * 2 + 2])
    end
    nil
  end

  # [a, b)
  # 0-origin
  def query(a, b)
    execute_query(a, b, 0, 0, @size)
  end

  private

  def execute_query(a, b, k, l, r)
    return @default if r <= a || b <= l
    return @data[k] if a <= l && r <= b
    vl = execute_query(a, b, k * 2 + 1, l, (l + r) / 2)
    vr = execute_query(a, b, k * 2 + 2, (l + r) / 2, r)
    @merge_proc.call(vl, vr)
  end

  def init_by_value(value)
    value.each.with_index do |v, i|
      @data[i + @size - 1] = v
    end
    (@size - 2).downto(0) do |i|
      @data[i] = @merge_proc.call(@data[i * 2 + 1], @data[i * 2 + 2])
    end
  end
end

N = gets.to_i
S = gets.chomp.chars.map { |ch| ch.ord - 97 }
st_value = Array.new(N, 0)
S.each.with_index do |o, i|
  st_value[i] = 1 << o
end
st = SegmentTree.new(N, default: 0, value: st_value, merge: lambda do |a, b|
  a | b
end)
Q = gets.to_i
Q.times do
  k, a, b = gets.chomp.split
  a = a.to_i - 1
  k = k.to_i
  if k == 1
    b = b.ord - 97
    st.update(a, 1 << b)
  else
    b = b.to_i
    x = st.query(a, b)
    ans = 0
    26.times do |i|
      ans += 1 if x[i] == 1
    end
    puts ans
  end
end

Measured memory_bytes: 48924
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))


def f(n):
    if n == 0:
        return n
    elif n & 1:  # nが奇数
        return ((n // 2) & 1) ^ (n - 1) ^ n
    else:
        return ((n // 2) & 1) ^ n


a, b = MI()
print(f(a - 1) ^ f(b))


Measured memory_bytes: 65644
#include <stdio.h>

int f[8] = {1,2,6,24,120,720,5040};

int perm(int *p, int l) {
	int u[8] = {0}, r = 0, t, i, j;
	for(i = 0; i < l - 1; i++) {
		for(j = 0, t = 0; 1; j++) {
			if(!u[j])
				t++;
			if(p[i] - 1 == j) {
				r += (t - 1)*f[l - i - 2];
				u[j] = 1;
				break;
			}
		}
	}
	return r;
}
int main() {
	int n, p[8], q[8], r, i;
	scanf("%d", &n);
	for(i = 0; i < n; i++)
		scanf("%d", &p[i]);
	for(i = 0; i < n; i++)
		scanf("%d", &q[i]);
	r = perm(p, n) - perm(q, n);
	printf("%d", r>0?r:-r);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,a,b,c,k;
    cin>>a>>b>>c>>k;
    while(k--)
    {
        if(c<=a||c<=b)
        {
            c=c*2;
        }
        else if(b<=a&&(b*2<c))
        {
            b=b*2;

        }
        else
        {
            c=c*2;
        }
    }
    if(a<b&&b<c)
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;


}



Measured memory_bytes: 3632
#include<bits/stdc++.h> 
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
typedef long long ll;
using namespace std;
inline int read(){
	int n=0,f=1;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if (c=='-') c=getchar(),f=-1;
	for(;c>='0'&&c<='9';c=getchar()) n=n*10+c-48;
	return n*f;
}
const int maxn=2e5+5;
int i,j,n,k,now,l[maxn],r[maxn];ll ans,sum,f[maxn];
int v[maxn],m,bz[maxn<<2];
void ch(int k,int l,int r,int x,int y){
	if (x>y) return;
	if (l==x&&r==y) {bz[k]=i;return;}
	int m=(l+r)>>1,lk=k<<1,rk=lk+1;
	if (bz[k]) bz[lk]=bz[rk]=bz[k],bz[k]=0;
	if (y<=m) ch(lk,l,m,x,y);else
	if (x>m) ch(rk,m+1,r,x,y);else
	ch(lk,l,m,x,m),ch(rk,m+1,r,m+1,y);
}
int find(int k,int l,int r,int x){
	if (bz[k]||l==r) return bz[k];
	int m=(l+r)>>1,lk=k<<1,rk=lk+1;
	return (x<=m)?find(lk,l,m,x):find(rk,m+1,r,x);
}
ll Ans(int x){
	int y=find(1,1,m,x);
	return y?f[y]+(v[l[y]]-v[x]+k)%k:0;
}
int main(){
	n=read(),k=read();
	sum=now=0;
	fo(i,1,n){
		int a=read(),b=read();
		a<<=1,sum+=a;
		if (b==1&&a>k)return puts("-1"),0;
		a=(now-a%k+k)%k;
		if (b==1) l[i]=now,r[i]=a;else l[i]=0,r[i]=k-1;
		now=a;
	}
	fo(i,1,n) v[++m]=l[i],v[++m]=r[i];
	sort(v+1,v+m+1);
	m=unique(v+1,v+m+1)-v-1;
	fd(i,n,1){
		l[i]=lower_bound(v+1,v+m+1,l[i])-v;
		r[i]=lower_bound(v+1,v+m+1,r[i])-v;
		f[i]=Ans(l[i]);
		if (l[i]>r[i]) ch(1,1,m,r[i]+1,l[i]-1);
		else ch(1,1,m,1,l[i]-1),ch(1,1,m,r[i]+1,m);
	}
	ans=f[1];
	fo(i,1,m) ans=min(ans,Ans(i));
	printf("%lld\n",sum+ans);
} 

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

public class Main {
	static final int mod = (int) 1e9 + 7;
	static final int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;
	static final String nextLine = "\n";

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		int x[][] = new int[n][2];
		for(int i=0;i<n;i++) {
			int t = fs.nextInt();
			x[i][0] = t;
			x[i][1] = i;
		}
		Arrays.sort(x, (x1,x2)->x2[0] - x1[0]);
		int cl = n/2-1;
		int cr = cl + 1;
		int xc = x[cl][0];
		
		int ans[] = new int[n];
		for(int i=0;i<n;i++) {
			if(x[i][0]>=xc) ans[x[i][1]] = x[cr][0];
			else ans[x[i][1]] = x[cl][0];
		}
		for(int i=0;i<n;i++) System.out.println(ans[i]);
		
	}

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

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

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 84052
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;

string S;

void solve() {
    bool flag = true;
    int L = S.size();
    FOR(S.size()) {
        if (S[i] != S[L - i - 1])
            flag = 0;
    }
    int N = L / 2;
    FOR(N) {
        if (S[i] != S[N - i - 1])
            flag = 0;
    }
    Yes(flag);
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> S;


    solve();
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i, 0, n) cin >> l[i];
  int ans = 0;
  rep(i, 0, n) rep(j, 0, n) rep(k, 0, n) {
    if (!(i < j && j < k)) continue;
    if (l[i] == l[j]) continue;
    if (l[i] == l[k]) continue;
    if (l[j] == l[k]) continue;
    if ((ll)l[i] + l[j] + l[k] <= max({l[i], l[j], l[k]}) * 2) continue;
    ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3628
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long int;

int main() {
  ll n, k;
  cin >> n >> k;
  string s;
  cin >> s;

  vector<ll> smile;

  char pre = s[0];
  ll cnt = 1;

  for (size_t i = 1; i < n; i++) {
    if (pre == s[i]) {
      cnt++;
    } else {
      smile.push_back(cnt);
      cnt = 1;
      pre = s[i];
    }
  }
  smile.push_back(cnt);

  cout << min((ll)(n - smile.size() + k * 2), n - 1) << endl;
}

Measured memory_bytes: 1528
import os,re,sys,operator
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate,combinations,groupby
from sys import stdin,setrecursionlimit
from copy import deepcopy
import heapq

setrecursionlimit(10**6)
def xor(n):
    if n%2==1:
        if (n//2+1)%2==0:
            return 0
        return 1
    else:
        return xor(n-1)^n
a,b=map(int,stdin.readline().rstrip().split())
if a==0:
    print(xor(b))
else:
    print(xor(a-1)^xor(b))

Measured memory_bytes: 38512
[<EntryPoint>]
let main argv =
    //printfn "Make it!"
    let n = System.Console.ReadLine() |> int
    let b = System.Console.ReadLine().Split() |> Array.map int
    let ans =
        (List.sumBy (fun i -> if b.[i-1] < b.[i] then b.[i-1] else b.[i]) [1 .. n-2])
        |> (+) (b.[0] + b.[n-2])
    printfn "%d" ans
    0


Measured memory_bytes: 14160
X, K, D = map(int, input().split())

X = abs(X)

n = X // D
m = K - n

A1 = abs(X - n*D)
A2 = abs(X - (n+1)*D)

Ans = A2

if m > 1:
    if A1 <= A2:
        if m % 2 == 0:
            Ans = A1
    else:
        if m % 2 == 0:
            Ans = A1
else:
    Ans = abs(X - K*D)

print(Ans)
 

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    string s;
    cin >> s;
    
    vector<int> cnt(2);
    rep(i, s.size()){
        ++cnt[s[i] - '0'];
    }

    cout << min(cnt[0], cnt[1]) * 2 << endl;

    return 0;
}

Measured memory_bytes: 512
S = str(input())
T = str(input())
s = len(S)
t = len(T)
ans = []
for i in range(s-t+1):
    count = 0
    U = S[i:i+t]
    for j in range(t):
        if U[j] != T[j]:
            count += 1
    ans.append(count)
print(min(ans))

Measured memory_bytes: 9104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r,D,t;
  cin>>r>>D>>t;
  
  int p=t;
  int i=0;
  while (i<10) {
    p=r*p-D;
    cout<<p<<endl;
    i++;
  }
  
  
  
}


Measured memory_bytes: 256
s = input()
s = list(s)

ans = []

for i in range(len(s)):
    if s[i] == "0":
        ans.append("0")
    elif s[i] == "1":
        ans.append("1")
    elif s[i] == "B":
        if len(ans) != 0:
            ans.pop()
print("".join(ans))


Measured memory_bytes: 2940
#include<stdio.h>
int main(void)
{
	int a[101], temp = 0, ruio = 0;
	for (int i = 1; i <= 5; i++) {
		scanf("%d", &a[i]);
	}
	while (a[2] > 0 || a[3] > 0) {
		a[2]-=a[4];
		a[3] -= a[5];
		ruio++;
	}
	printf("%d\n", a[1]-ruio);
	return 0;
}

Measured memory_bytes: 2724
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

const ll INF = 1e12;
signed main(){
    string s; cin >> s;
    vector<char>v;
    rep(i,s.size()){
        if(s[i]=='0')v.pb('0');
        else if(s[i]=='1')v.pb('1');
        else if(v.size()!=0)v.ppb;
    }
    for(auto u:v)cout<<u;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

def main():
    N, K = map(int, readline().rstrip().split())
    S = list(map(int, list(readline().rstrip())))

    cnt = []
    pre = S[0]
    S.append(-1)
    c = 1
    for s in S[1:]:
        if s == pre:
            c += 1
        else:
            cnt.append(c)
            pre = s
            c = 1
    
    if S[0] == 0:
        cnt = [0] + cnt
    if S[-2] == 0:
        cnt.append(0)
    
    K = K * 2 + 1
    ans = sum(cnt[:K])
    sc = ans
    for i in range(2, len(cnt)-K+1, 2):
        sc = sc - cnt[i-1] - cnt[i-2] + cnt[i+K-1] + cnt[i+K-2]
        ans = max(ans, sc)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 5400
#!/usr/bin/env python3
#ABC110 D

import math
from collections import Counter
N,M = map(int,input().split())
mod = 10**9 + 7

def factorize(n):
    b = 2
    fct = []
    while b**2 <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b += 1
    if n > 1:
        fct.append(n)
    return fct

def fast(x,n):
    if n == 0:
        return 1
    elif n % 2 == 0:
        return fast(x**2 % mod,n//2) % mod
    elif n % 2:
        return x*fast(x**2 % mod,n//2) % mod
fact = [0]*(200001)
fact[0] = 1
for i in range(200000):
    fact[i+1] = fact[i]*(i+1)
    fact[i+1] %= mod

cnt = list(Counter(factorize(M)).items())
ans = 1
for i,j in cnt:
    ans *= fact[j+N-1]
    ans %= mod
    ans *= fast(fact[j],mod-2)
    ans %= mod
    ans *= fast(fact[N-1],mod-2)
    ans %= mod
print(ans)


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

int main() {
  int N;
  cin >> N;
  
  int count=0;
  rep(i,N) {
    int first;
    int second;
    cin >> first >> second;
    
    if (first==second) count++;
    else count=0;
    
    if (count==3) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;  
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  string ans = "None";
  
  rep(i, 0, 26) {
    if(s.find('a' +i) == string::npos) {
      ans = 'a' +i;
      break;
    }
  }
  
  cout << ans << "\n";

}


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

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main() {
    ll N;
    cin >> N;
    unsigned long dig = 10;

    for(ll A = 1; A <= pow(N, 0.5); A++){
        if(N % A == 0){
            dig = min(dig, max(to_string(A).size(), to_string(N / A).size()));
        }
    }
    cout << dig << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,data[100][101],x;
  while(cin>>n&&n){
    int cnt[100]={},num,ans=0;
    for(int i=0;i<n;++i){
      cin>>data[i][0];
      for(int j=1;j<=data[i][0];++j) cin>>data[i][j];
    }
    cin>>k;
    for(int i=0;i<k;++i){
      cin>>x;
      for(int j=0;j<n;++j){
	for(int l=1;l<=data[j][0];++l){
	  if(data[j][l]==x){
	    ++cnt[j];
	  }
	}
      }
    }
    for(int i=0;i<n;++i) {
      if(cnt[i]==k){
	num=i+1;
	++ans;
      }
    }
    if(ans==1) cout<<num<<endl;
    else cout<<"-1"<<endl;
  }
  return 0;
}
  



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

int main()
{
    //A
    int n;
    cin>>n;
    if(n==2)
    {
        cout<<8<<endl;
    }
    else if(n==1)
    {
        cout<<1<<endl;
    }
    else
    {
        cout<<pow(n,3)<<endl;
    }

    
    
    return 0;
}

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

int main ( void )
{
	string S, T, U;
	int A, B, x;
	cin >> S >> T;
	cin >> A >> B;
	cin >> U;

	size_t len_s, len_t;
	len_s = S.length ( );
	len_t = T.length ( );

	if ( ( len_s < 1 ) || ( 10 < len_s ) ){
		cout << "ERROR!\n";
		return 0;
	}
	if ( ( len_t < 1 ) || ( 10 < len_t ) ){
		cout << "ERROR!\n";
		return 0;
	}
	if ( S == T ){
		cout << "ERROR!\n";
		return 0;
	}

	if ( U == S ){
		x = A - 1;
		cout << x << " " << B << "\n";
	} else if ( U == T ){
		x = B - 1;
		cout << A << " " << x << "\n";
	}

	return 0;

}

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

int main() {
  
  string S;
  cin >> S;
  int N = S.size();

  int res1=0;
  bool bol1=false;
  for(int i=0; i<N; i++){ 
    if( S.at(i)-'0'!=bol1 ){ res1++; }
    bol1=!bol1;
  }
  
  int res2=0;
  bool bol2=true;
  for(int i=0; i<N; i++){ 
    if( S.at(i)-'0'!=bol2 ){ res2++; }
    bol2=!bol2;
  }

  
//  cout << res1 << " " << res2  << endl;
  cout << min(res1, res2) << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<vector>
#include<string>
#define int long long
using namespace std;
main()
{
	//freopen("input.txt","rt",stdin);
	int n;
	cin>>n;
	int arr[n];
	int ans[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	for(int i=0;i<n;i++)
	{
		arr[i] *= 2;
	}
	int p =0;
	for(int i=0;i<n;i++)
	{
		if(i%2 == 0)
		{
			p += arr[i];
		}
		else
		{
			p -= arr[i];
		}
	}
	p /= 2;
	ans[0] = p;
	for(int i=1;i<n;i++)
	{
		ans[i] = arr[i-1] - ans[i-1];
	}
	for(int i=0;i<n;i++)
	{
		cout<<ans[i]<<" ";
	}
	cout<<endl;
}

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

using ll=long long; 

using P=pair<int,int>;

void solve(){
	int n,u,v;
	cin>>n>>u>>v;
	u--;
	v--;
	vector<int> to[n];
	int a,b;
	for(int i=0; i<n-1; i++){
		cin>>a>>b;
		a--;b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	vector<int> distao(n);
	for(int i=0; i<n; i++)distao[i]=-1;
	distao[v]=0;
	queue<int> Q;
	Q.push(v);
	while(!Q.empty()){
		int x=Q.front();Q.pop();
		for(int i=0; i<to[x].size(); i++){
			if(distao[to[x][i]]==-1){
				Q.push(to[x][i]);
				distao[to[x][i]]=distao[x]+1;
			}
		}
	}

	//cout<<"aoowari"<<endl;

	vector<P> distaka(n);
	for(int i=0; i<n; i++){
		distaka[i].first=-1;
		distaka[i].second=i;
	}
	distaka[u].first=0;
	queue<int> Q1;
	Q1.push(u);
	while(!Q1.empty()){
		int x=Q1.front();Q1.pop();
		for(int i=0; i<to[x].size(); i++){
			if(distaka[to[x][i]].first==-1){
				Q1.push(to[x][i]);
				distaka[to[x][i]].first=distaka[x].first+1;
			}
		}
	}
	vector<P> zdist(n);
	for(int i=0; i<n; i++){
		zdist[i].first=distao[i];
		zdist[i].second=distaka[i].second;
	}
	sort(zdist.rbegin(), zdist.rend());
	for(int i=0; i<zdist.size(); i++){
		int a=zdist[i].first, b=zdist[i].second;
		//cout<<a<<" "<<distaka[b].first<<" "<<distao[b]<<" "<<b<<endl;
		if(a<=distaka[b].first)continue;
		cout<<distao[b]-1<<endl;
		return;
	}
	//cout<<"hello"<<endl;
	cout<<0<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 7808
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
int a,b,c;

int main()
{
    cin>>a>>b>>c;
    if (a<b && b<c)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}




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

#define INFTY 1000000001

long long merge(long long A[], long long left, long long mid, long long right)
{
  long long n1 = mid - left, n2 = right - mid;
  long long L[n1 + 1], R[n2 + 1];
  for (long long i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }
  for (long long i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }
  L[n1] = INFTY;
  R[n2] = INFTY;
  long long i = 0, j = 0, count = 0;
  for (long long k = left, p = (-1) * n1; k < right; k++, p++) {
    if (L[i] < R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j];
      count += j - p;
      j++;
    }
  }
  return count;
}

long long mergeSort(long long A[], long long left, long long right)
{
  long long count = 0;
  if ((left + 1) < right) {
    long long mid = (left + right)/2;
    count += mergeSort(A, left, mid);
    count += mergeSort(A, mid, right);
    count += merge(A, left, mid, right);
  }
  return count;
}

int main() {
  long long n;
  cin >> n;
  long long S[n], count;
  for (long long i = 0; i < n; i++) cin >> S[i];
  count = mergeSort(S, 0, n);
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 6188
'use strict';

function Main(INPUT) {
    const N = INPUT.split("\n")[0];
    if (N == 7 || N == 5 || N == 3) {
        console.log("YES");
    } else {
        console.log("NO");
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main() {

int a,b=0;
  cin>>a;
  if(a==1){cout<<1<<endl;}
  else{
  for(int i=2;i<=sqrt(a);i++){
    int j=i;
    while(j*i<=a){j*=i;}
    
    if(b<j&&j!=i){b=j;}}
  cout<<b<<endl;
  }
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

typedef long long ll;

//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};

// const int C ;
// const int M = 1000000007;

typedef tuple<int, int, int> rail; // now, src, cost
typedef tuple<int, int> station; // now, src
typedef tuple<int, int, int> state; // cost, src, now

int N;
int M;
priority_queue<state, vector<state>, greater<state> > Q;
set<station> visited;
map<station, vector<rail> > W;

int main () {
  cin >> N >> M;
  int p, q, c;
  for (auto i = 0; i < M; i++) {
    cin >> p >> q >> c;
    p--; q--; c--;
    W[make_tuple(p, -1)].push_back(make_tuple(q, c, 1));
    W[make_tuple(q, -1)].push_back(make_tuple(p, c, 1));
    W[make_tuple(p, c)].push_back(make_tuple(q, c, 0));
    W[make_tuple(q, c)].push_back(make_tuple(p, c, 0));
  }
  for (auto x : W) {
    if (get<1>(x.first) != -1) {
      W[x.first].push_back(make_tuple(get<0>(x.first), -1, 0));
    }
  }
  Q.push(make_tuple(0, -1, 0));
  while(!Q.empty()) {
    int cost = get<0>(Q.top());
    int src = get<1>(Q.top());
    int now = get<2>(Q.top());
    station s = make_tuple(now, src);
    Q.pop();
    if (visited.find(s) == visited.end()) {
      //cerr << "now = " << now << ", src = "
      //     << src << ", cost = " << cost << endl;
      visited.insert(s);
      if (now == N-1) {
        cout << cost << endl;
        return 0;
      }
      for (auto x : W[s]) {
        int dst = get<0>(x);
        int rosen = get<1>(x);
        int newcost = cost + get<2>(x);
        //cerr << "dst = " << dst << ", rosen = "
        //     << rosen << ", newcost = " << newcost << endl;
        station t = make_tuple(dst, rosen);
        if (visited.find(t) == visited.end()) {
          Q.push(make_tuple(newcost, rosen, dst));
        }
      }
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 74800
#include<stdio.h>
#define MAX 10000
#define NIL -1

int kansu(int i){
  if(i==25964)
    return 0;
    else return i;
}
struct Node{
  int p, l, r;
};

struct Node T[MAX];
int n;

void preParse(int u){
  if ( u == NIL ) return;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}
void inParse(int u){
  if ( u == NIL ) return;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}
void postParse(int u){
  if ( u == NIL ) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}

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

  for ( i = 0; i < n; i++ ){
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if ( l != NIL ) T[l].p = v;
    if ( r != NIL ) T[r].p = v;
  }

  for ( i = 0; i < n; i++ ) if ( T[i].p == NIL ) root = i;
  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}


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

// @author: pashka

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

    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    vector<int> cnt(n);
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        x--;
        a[i] = x;
        cnt[x]++;
    }

    vector<int> b(n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < cnt[i]; j++) {
            b[max(i - j, 0)]++;
        }
    }
    int s = 0;
    for (int i = 0; i < n; i++) {
        s += max(b[i] - 1, 0);
    }

    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        cnt[a[x]]--;
        int q = max(a[x] - cnt[a[x]], 0);
        b[q]--;
        if (b[q] > 0) s--;
        a[x] = y;
        q = max(a[x] - cnt[a[x]], 0);
        cnt[a[x]]++;
        b[q]++;
        if (b[q] > 1) s++;
        cout << s << "\n";
    }

    return 0;
}

Measured memory_bytes: 3840
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll N, M;
ll dp[310][310][310];

ll mod_pow(ll x, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return res;
}

ll mod_inverse(ll x) {
    return mod_pow(x, mod-2);
}
const int max_n = 310;
ll fact[max_n];
ll fact_inv[max_n];
void calc_fact() {
    fact[0] = 1;
    for (ll i = 1; i < max_n; i++)
        fact[i] = (fact[i-1] * i) % mod;
    fact_inv[max_n-1] = mod_inverse(fact[max_n-1]);
    for (ll i = max_n-2; i >= 0; i--)
        fact_inv[i] = (fact_inv[i+1] * (i+1)) % mod;
}


ll calc(ll n, ll k, ll m) {
    if (n == N && k ==0 && m == 0) return 1;
    if (!(n+k <= N && m >= 0)) return 0;
    if (dp[n][k][m] < 0) {
        dp[n][k][m] = (n * calc(n+k, 0, m-1) + calc(n, k+1, m-1)) % mod;
        dp[n][k][m] = (dp[n][k][m] + k * calc(n, k, m-1)) % mod;
    }
    return dp[n][k][m];
}

ll solve() {
    calc_fact();
    memset(dp, -1, sizeof(dp));
    return calc(1, 0, M) * fact[N-1] % mod;
}

void input() {
    cin >> N >> M;
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 232960
def checkTrans(s, t):
    ms = {}
    mt = {}
    for sc, tc in zip(s, t):
        if sc in ms:
            if ms[sc] != tc:
                return False
        else:
            ms[sc] = tc

        if tc in mt:
            if mt[tc] != sc:
                return False
        else:
            mt[tc] = sc

    return True

s = input()
t = input()

if checkTrans(s, t):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3632
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 5e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string s;
	cin >> s;
	int n = s.length();
	int c = count(s.begin(), s.end(), '0');
	cout << min(c, n - c) * 2 << endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
int main(){
  std::vector <int>a(5,0);
  
  for(int i=0;i<5;i++){
    std::cin>>a[i];
  }
  
  for(int i=0;i<5;i++){
    
    if(a[i]==0){
      std::cout<<i+1<<std::endl;
    break;
    }
  }
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,a,b;
int32_t main(){
CODE_START;
cin>>a;
cin>>b;
ll s=1,ans=0;
while(s<b){
    s=s+a;
    s--;
    ans++;
}
cout<<ans<<endl;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int LL;
typedef LL ll;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;
 
#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (int i=a;i<b;i++)
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); } 
const ll M=2e5+5,LG=19,SM=4000+5,inf=1e18+1;
ll mod=924844033;

ll n,e,t;
ll dp[M];
ll x[M];

ll seg[2*M];

void upd(ll p,ll v)
{
    //ER(p);ER(v);
    for (p+=2*n;p>0;p/=2) smin(seg[p],v);
}

ll get(ll l,ll r)
{
    //ER(l);ER(r);
    ll res=inf;
    for (l+=2*n,r+=2*n;l<r;l/=2,r/=2)
    {
        if (l&1) smin(res,seg[l++]);      
        if (r&1) smin(res,seg[--r]);
    }
    //ER(res);
    return res;
}

int main()
{
	ios::sync_with_stdio(0);
	cin >> n >> e >> t;
	//if (n>2000) return 0;
	For(i,0,n)
	{
	    cin >> x[i];
	}
	/*For(i,1,n+1)
	{
	    dp[i]=(-x[0])*3+max(0LL,t-2*(x[i-1]-x[0]))+x[0];
	    For(j,1,i)
	    {
	        smin(dp[i],(-x[j])*3+
	            max(0LL,t-2*(x[i-1]-x[j]))+
	            dp[j]+x[j]-x[j-1]);
	    }
	    dp[i]+=x[i-1]*3;
	    //ER(i);ER(dp[i]);
	}//*/
	memset(seg,127,sizeof seg);
	For(i,1,n+1)
	{
	    dp[i]=(-x[0])*2+max(0LL,t-2*(x[i-1]-x[0]));
	    ll lo=0,hi=i-1;
	    while (hi-lo>1)
	    {
	        ll mid=(hi+lo)>>1;
	        if (t>2*(x[i-1]-x[mid])) hi=mid; else lo=mid;
	    }
	    if (hi>0)
	        smin(dp[i],-x[hi]*2+t-2*(x[i-1]-x[hi])+dp[hi]-x[hi-1]);
        smin(dp[i],get(0,hi));
	    dp[i]+=x[i-1]*3;
	    upd(i,-x[i]*2+dp[i]-x[i-1]);
	    //ER(i);ER(dp[i]);
	}
	cout << dp[n]+e-x[n-1];
}    

Measured memory_bytes: 6400
n = int(input())
x = int(input())


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


for i in range(n - 1):
    x = lcm(x, int(input()))
print(x)


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){

			String[] imputarray = br.readLine().split(" ");
			int a = Integer.parseInt(imputarray[0]);
			int b = Integer.parseInt(imputarray[2]);
			if(  imputarray[1].equals("+") ){
				System.out.println(a+b);
			}else if( imputarray[1].equals("-")){
				System.out.println(a-b);
			}else if( imputarray[1].equals("*")){
				System.out.println(a*b);
			}else if( imputarray[1].equals("/")){
				System.out.println(a/b);
			}else break;
		}
	}
}

Measured memory_bytes: 24340
#include<stdio.h>
int main()
  { 
    char s[4];
    scanf("%s",s);
    if(s[0]==s[1]&&s[1]!=s[2]&&s[2]==s[3])
      { printf("Yes"); }
   else if(s[0]==s[2]&&s[2]!=s[3]&&s[1]==s[3])
      { printf("Yes"); } 
    else if(s[0]==s[3]&&s[3]!=s[2]&&s[2]==s[1])
      { printf("Yes"); }
  else 
   { printf("No"); }
  return 0;
  }


Measured memory_bytes: 128
# include <bits/stdc++.h>
#define flash ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define ll long long int
#include <tr1/unordered_map>
#define ld long double
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define f(i,a,b)  for(long long i=a;i<b;i++)
#define all(c) (c).begin(),(c).end()
#include <map>

using namespace std;

int main()
{



     flash;
     ///////////////////////////////////////////////////////////////////////////////////////

ll n;
cin>>n;
ll dir[4][2]={{1,1},{1,-1},{-1,1},{-1,-1}};
ll maxi[4]={INT_MIN,INT_MIN,INT_MIN,INT_MIN};
ll mini[4]={INT_MAX,INT_MAX,INT_MAX,INT_MAX};
for(ll i=0;i<n;i++)
{
    ll x,y;
    cin>>x>>y;
    for(ll j=0;j<4;j++)
    {
    maxi[j]=max(maxi[j],x*dir[j][0]+y*dir[j][1]);
    mini[j]=min(mini[j],x*dir[j][0]+y*dir[j][1]);
}

}
ll ans=INT_MIN;
for(ll i=0;i<4;i++)
{
    ans = max(ans,maxi[i]-mini[i]);

}
cout<<ans<<endl;









    ///////////////////////////////////////////////////////////////////////////////////////

     return 0;

}


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

namespace _073A_September9
{
    class Program
    {
        static void Main(string[] args)
        {
            String n; //文字列型変数
            n = Console.ReadLine();//
            if (n[0] == '9' || n[1] == '9')//キーボードから文字列を読み込む
                Console.WriteLine("Yes");//1文字目が'9'または2文字目が'9'なら”Yes”
            else
                Console.WriteLine("No");//それ以外は"No"
            Console.ReadKey();//キー入力待
          
        }
    }
}


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

using ll = long long;
using pii = pair<int, int>;

constexpr int INF = 1e9;

int main() {
    int N, W;
    cin >> N >> W;
    vector<vector<int>> dp(N + 1, vector<int>(10001, INF + 1));
    dp[0][0] = 0;
    vector<int> v(N), w(N);
    for(int i = 0; i < N; ++i) {
        cin >> v[i] >> w[i];
    }
    for(int i = 0; i < N; ++i) {
        dp[i + 1] = dp[i];
        for(int j = 0; j + v[i] <= 10000; ++j) {
            dp[i + 1][j + v[i]] = min(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
        }
    }
    for(int i = 10000; i >= 0; --i) {
        if(dp[N][i] <= W) {
            cout << i << endl;
            return 0;
        }
    }
}

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

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

unsigned euclidean_lcm(unsigned a, unsigned b) {
	unsigned g;
	g = euclidean_gcd(a, b);
	return a*b/g;
}

int main() {
	long long n = 0;
	double mother, child = 0;
	cin >> n;
	vector<double> a(n);
	vector<double> b(n);
	for (long long i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	for (long long j = 1; j < n; j++) {
		a[j] = euclidean_lcm(a[j], a[j-1]);
		mother = a[j]; //最小公倍数
	}
	for (long long k = 0; k < n; k++) {
		child += mother/b[k]; //最小公倍数÷配列[i] 
	}
	cout << setprecision(12) << mother/child << endl;
	return 0;
}


Measured memory_bytes: 256
bmi :: Double -> Double -> Double
bmi w h = w / (h*h)

ans :: [String] -> (Int, Double)
ans (s:w:h:_) =
  let s' = read s :: Int
      w' = read w :: Double
      h' = read h :: Double
  in
    (s', bmi w' h')


split :: String -> [String]
split text =
  let i = lookup ',' $ zip text [0..]
  in
    case i of
      Just j  -> (take j text):(split $ drop (j+1) text)
      Nothing -> [text]

main = do
  c <- getContents
  let l = map ans $ map split $ lines c
      o = filter (\(i,b) -> b >= 25) l
  mapM_ (\(i,b) -> print i) o

Measured memory_bytes: 4024
import sys
input = sys.stdin.readline

N = int(input())
L = [list(map(int, input().split())) for _ in range(2)]
counter = [[0] * N for _ in range(2)]

def bfs(index, row, point):
    if index >= 2 or row >= N:
        return
    
    if counter[index][row] > point:
        return
    
    counter[index][row] =  point
    
    if index + 1 < 2:
        bfs(index + 1, row, L[index + 1][row] + point)
        
    if row + 1 < N:
        bfs(index, row + 1, L[index][row + 1] + point)
    
    return

bfs(0, 0, L[0][0])
print(counter[1][N - 1])

Measured memory_bytes: 3064