akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int N;
    cin >> N;
    while(N>=1000){
        N = N - 1000;
    }   
    if(N == 0) cout << N << endl;
    else cout << 1000 - N << endl;
}

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

using Int = int;
using namespace std;

#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; };
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; };
template<class T> T th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

int main(){
	Int a, b;
	cin >> a >> b;
	Int ans = a - b * 2;
	if(ans < 0) ans = 0;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

#define N 100001

int han(int n){
	int i,f=0;
	for(i=2;i*i<=n;i++){
		if(n%i==0){
			f=1;
			break;
		}
	}
	if(f==1)return 0;
	//if(han((n+1)/2))return 0;
	return 1;
}

int main(){
	int q,i,j,su[N]={0},lr[N][2];
	for(i=3;i<N;i++){
		su[i]=su[i-1];
		//printf("%d\n",han(i));
		if(han(i)==1&&han((i+1)/2)==1)su[i]++;
	}
	scanf("%d",&q);
	for(i=0;i<q;i++)scanf("%d%d",&lr[i][0],&lr[i][1]);
	for(i=0;i<q;i++)printf("%d\n",su[lr[i][1]]-su[lr[i][0]-1]);
	//for(i=0;i<10;i++)printf("%d\n",su[i]);
	return 0;
}

Measured memory_bytes: 1664
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    N, M = input_nums()
    L = 1
    R = N
    for i in range(M):
        l, r = input_nums()
        L = max(L, l)
        R = min(R, r)
        if L > R:
            print(0)
            exit(0)
    print(R-L+1)







if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
    int dice[6]={};
    int i, tmp1, tmp2, tmp3, tmp4;
    char x;
    
    for(i=1; i<=6; i++){
        scanf("%d", &dice[i]);
    }
    
    while(scanf("%c", &x)!=EOF){
        if(x=='S'){
            tmp1=dice[1];
            tmp2=dice[2];
            tmp3=dice[5];
            tmp4=dice[6];
            dice[1]=tmp3;
            dice[2]=tmp1;
            dice[5]=tmp4;
            dice[6]=tmp2;
        }
        else if(x=='W'){
            tmp1=dice[1];
            tmp2=dice[3];
            tmp3=dice[4];
            tmp4=dice[6];
            dice[1]=tmp2;
            dice[3]=tmp4;
            dice[4]=tmp1;
            dice[6]=tmp3;
        }
        else if(x=='N'){
            tmp1=dice[1];
            tmp2=dice[2];
            tmp3=dice[5];
            tmp4=dice[6];
            dice[1]=tmp2;
            dice[2]=tmp4;
            dice[5]=tmp1;
            dice[6]=tmp3;
        }
        else if(x=='E'){
            tmp1=dice[1];
            tmp2=dice[3];
            tmp3=dice[4];
            tmp4=dice[6];
            dice[1]=tmp3;
            dice[3]=tmp1;
            dice[4]=tmp4;
            dice[6]=tmp2;
        }
    }
    printf("%d\n", dice[1]);
    return 0;
}
    


Measured memory_bytes: 2104
#include <stdio.h>
 
int main(){
  int i, j, n, u, k, v, a[101][101]={0};

  scanf("%d",&n);
  
  for(i=0; i<n; i++){
    scanf("%d %d",&u,&k);
    for(j=0; j<k; j++){
      scanf("%d", &v);
      a[u-1][v-1]=1;
    }
  }
  
  for(i=0;i<n;i++){
    for(j=0;j<n-1;j++){  
      printf("%d ",a[i][j]);
    }
    printf("%d\n",a[i][n-1]);
  }
  
  return 0;
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
#define lli long long int 
#define N 2e5 + 5
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;


int main(){
	IOS;
string s;
cin>>s;
if(s=="ARC")
cout<<"ABC";
else cout<<"ARC";
	




}
	


Measured memory_bytes: 3648
require 'set'

class ForbiddenList
  def run
    x, n = gets.scan(/\d+/).map(&:to_i)

    if n == 0
      puts x
    else
      st = Set.new(gets.scan(/\d+/).map(&:to_i))

      (0..100).each do |i|
        if ! st.member?(x - i)
          puts (x - i)
          break
        elsif ! st.member?(x + i)
          puts (x + i)
          break
        end
      end
    end
  end
end

if $0 == __FILE__
  ForbiddenList.new.run
end


Measured memory_bytes: 14452
#include <iostream>
 
using namespace std;
 
int main() {
  int n; cin >> n;
  long long sum = 0;
  long long max = 0;
  for (int i = 0; i < n; i++) {
    long long a; cin >> a;
    if (a > max) max = a;
    else sum += max - a;
  }
  cout << sum << endl;
  
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x, t;
  cin >> x >> t;
  cout << max(x-t, 0) << endl;
  return 0;
}

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

signed main(){

  int n;
  cin>>n;
  vector<vector<int>> mask(n);
  for(int i=0;i<n;++i){
    int k;
    cin>>k;
    mask[i].resize(k);
    for(int j=0;j<k;++j)cin>>mask[i][j];
  }

  bitset<64> b;
  auto set = [](auto& b,auto const& m){
    for(auto i:m)b.set(i);
  };
  auto clear = [](auto& b,auto const& m){
    for(auto i:m)b.reset(i);
  };
  auto flip = [](auto& b,auto const& m){
    for(auto i:m)b.flip(i);
  };
  auto all = [](auto const& b,auto const& m){
    bool res = 1;
    for(auto i:m)res&=b.test(i);
    return res;
  };
  auto any = [](auto const& b,auto const& m){
    bool res = 0;
    for(auto i:m)res|=b.test(i);
    return res;
  };
  auto none = [](auto const& b,auto const& m){
    bool res = 1;
    for(auto i:m)res&=!b.test(i);
    return res;
  };
  auto count = [](auto const& b,auto const& m){
    int cnt = 0;
    for(auto i:m)cnt += b[i];
    return cnt;
  };
  auto val = [](auto const& b,auto const& m){
    bitset<64> bb;
    for(auto i:m)bb[i]=b[i];
    return bb.to_ullong();
  };
  int q;
  cin>>q;
  while(q--){
    int c;
    cin>>c;
    if(c==0){
      int i;cin>>i;
      cout<< b.test(i) <<endl;
      continue;
    }
    int m;
    cin>>m;
    if(c==1){
      set(b,mask[m]);
    }
    if(c==2){
      clear(b,mask[m]);
    }
    if(c==3){
      flip(b,mask[m]);
    }
    if(c==4){
      cout<< all(b,mask[m]) <<endl;
    }
    if(c==5){
      cout<< any(b,mask[m]) <<endl;
    }
    if(c==6){
      cout<< none(b,mask[m]) <<endl;
    }
    if(c==7){
      cout<< count(b,mask[m]) <<endl;
    }
    if(c==8){
      cout<< val(b,mask[m]) <<endl;
    }
  }

}


Measured memory_bytes: 3104
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

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

    if (abs(a - x) > abs(b - x))
    {
        cout << 'B' << endl;
    }
    else
    {
        cout << 'A' << endl;
    }
}


Measured memory_bytes: 256
fn main() {
    let _:String = read();
    let s:String = read();
    let mut max = 0;
    s.chars().fold(0, |m,c| {
        let m = m + if c == 'I' { 1 } else { -1 };
        if m > max { max = m }
        m
    });
    println!("{}", max);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


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

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define fff ff
#define sss ss.ff
#define ttt ss.ss
#define INF (1 << 30)
#define LLF (1ll << 60)
#define PRIME (1000000007)
#define FASTIO std::ios::sync_with_stdio(false)
#ifdef DEBUG
#define debug(x) cerr << #x << " = " << x << endl
#else
#define debug(x)
#endif
#define rep(i, begin, end)                            \
  for (__typeof(end) i = (begin) - ((begin) > (end)); \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define FILE_INPUT                  \
  freopen("input.txt", "r", stdin); \
  freopen("output.txt", "w", stdout)

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
typedef pair<ll, ii> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<string> vs;

/*-----------------END TEMPLATE-----------------*/

int main() {
  FASTIO;
  string s;
  string t;
  cin >> s >> t;
  ll count = 0;
  rep(i, 0, 3) {
    if (s[i] == t[i]) count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define ll unsigned long long
using namespace std;
int main(){
    int N,R;cin>>N>>R;
    if(N>=10){
        cout<<R<<endl;
    } else {
        cout<<R+(100*(10-N))<<endl;
    }
}

Measured memory_bytes: 256
let n, m = Scanf.scanf " %d %d" @@ fun a b -> a, b
let ab_s = Array.init n @@ fun _ -> Scanf.scanf " %d %d" @@ fun a b -> a, b
let cds = Array.init m @@ fun _ -> Scanf.scanf " %d %d" @@ fun a b -> a, b
let f (a, b) = let m = ref (max_int, -1) in Array.iteri (fun i (c, d) -> m := min !m @@ (abs (a - c) + abs (b - d), i + 1)) cds; Printf.printf "%d\n" @@ snd !m
let _ = Array.iter f ab_s

Measured memory_bytes: 512
def a_ddcc_finals():
    X, Y = [int(i) for i in input().split()]
    prizes = {1: 300000, 2: 200000, 3: 100000}
    ans = 0
    for rank in (X, Y):
        if rank in prizes.keys():
            ans += prizes[rank]
    ans += 400000 if X == 1 and Y == 1 else 0
    return ans

print(a_ddcc_finals())

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using lint = long long;//
template <typename T>
T sq (T x) {
    return x * x;
}

signed main () {
    lint  R;
    cin >> R;
 cout <<   2. * M_PI *R << endl;


    return 0;
}



Measured memory_bytes: 3804
n = int(input())
x = []
ans = 0
for i in range(n):
  array = list(map(str,input().split()))
  x.append(array)
  if x[i][1] == "JPY":
  	ans += int(x[i][0])
  else:
  	ans += float(x[i][0]) * 380000
print(ans)


Measured memory_bytes: 2940
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

std::string S;
int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    in >> S;
    if (S[1] == 'B') {
        out << "ARC" << endl;
    }
    else {
        out << "ABC" << endl;
    }


    return 0;
}
#endif


Measured memory_bytes: 3036
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  bool asd=true;
  for(int i=0;i<S.size();i++){
  if(i%2==0&&S.at(i)=='L')asd=false;
  if(i%2!=0&&S.at(i)=='R')asd=false;
  }
  if(asd==false)cout<<"No"<<endl;
  if(asd==true)cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a[5], b[5], min = 10, late_idx, i, ans = 0;
	for (i = 0; i < 5; i++) {
		scanf("%d", &a[i]);
		b[i] = a[i] % 10;
		if (b[i] < min && b[i] != 0) {
			min = b[i];
			late_idx = i;
		}
	}
	for (i = 0; i < 5; i++) {
		if (i == late_idx || a[i] % 10 == 0) ans += a[i];
		else ans += (a[i] + 10) / 10 * 10;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int
#define ar array
#define pb push_back
#define forf(i,a,b) for(i = a; i< b; i++)
#define forb(i,a,b) for(i = b; i>=a; i--)
using namespace std;
const int mod = 1e9+7;
ll power(ll a,ll b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,m;
	cin>>n>>m;
	if(n>=3 && m>=3)
		cout<<m*n-(2*m+2*n-4)<<endl;
	else
	{
		if(m==1 && n==1)
			cout<<1<<endl;
		else if(m==1 || n==1)
			cout<<max(m,n)-2<<endl;
		else cout<<0<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

struct UnionFind{
  vector<int> par; //par[i]:iの親番号
  vector<int> siz;

  UnionFind(int N) : par(N),siz(N,1){
    for(int i=0;i<N;i++)par[i]=i;
  }

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

  void unite(int x,int y){
    int rx=root(x);
    int ry=root(y);
    if(rx==ry)return;
    if(siz[rx]<siz[ry])swap(rx,ry);
    siz[ry]+=siz[rx];
    par[rx]=ry;
  }

  bool same(int x,int y){
    int rx=root(x);
    int ry=root(y);
    return rx==ry;
  }

  int size(int x){
    return siz[root(x)];
  }
};

int main(){
    int n,q;cin>>n>>q;
    UnionFind uf(n);
    REP(i,q){
        int c,x,y;
        cin>>c>>x>>y;
        if(!c)uf.unite(x,y);
        else if(uf.same(x,y))cout<<1<<endl;
        else cout<<0<<endl;
    }
}



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

using namespace std;
using ll = long long;

const long long INF = 1LL << 60;
const int MOD = 1000000007;

ll dp[1001][1001] = {};

int main() {
    #ifdef MYLOCAL
        ifstream in("input.txt");
        cin.rdbuf(in.rdbuf());
    #endif

    int h, w;
    cin >> h >> w;

    vector<string> a(h);
    for(int i = 0; i < h; ++i){
        cin >> a[i];
    }

    dp[0][0] = 1;

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (i + 1 < h && a[i + 1][j] == '.'){
                dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
            }
            if (j + 1 < w && a[i][j + 1] == '.') {
                dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % MOD;
            }
        }
    }
    cout << dp[h-1][w-1] << endl;

    return 0;
}

Measured memory_bytes: 9088
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        if(x ==0) {
            System.out.println(0);
            return;
        }
        long a500 = x / 500;
        if(a500 == 0) {
            System.out.println(x / 5 * 5);
            return;
        }
        long b = x % (a500 * 500);
        long b5 = b / 5;
        System.out.println(a500 * 1000 + b5 * 5);
    }
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

#define ssID(l, r) substr((l), (r) - (l))

string s, k = "keyence";

int main() {
	cin >> s;
	
	bool f = false;
	incII(i, 0, s.size()) {
	incII(j, 0, s.size()) {
		if(! (i <= j)) { continue; }
		if(s.ssID(0, i) + s.ssID(j, s.size()) == k) { f = true; }
	}
	}
	
	cout << (f ? "YES" : "NO") << endl;
	
	return 0;
}


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

using namespace std;

#define pii pair<int, int>
#define fi first
#define se second
#define REP(i, a, n) for (register int i = a, _n = n; i <= _n; ++i)
#define DREP(i, a, n) for (register int i = a, _n = n; i >= _n; --i)
#define FOR(i, a, n) for (register int i = a, _n = n; i < _n; ++i)
#define EREP(i, a) for (register int i = first[a]; i; i = edge[i].nxt)
#define debug(x) cout << #x << " = " << x << endl

char IO;
inline int rd () {
	int res = 0;
	while ((IO = getchar()) && (IO < '0' || IO > '9'));
	while (IO >= '0' && IO <= '9') 
		res = (res << 1) + (res << 3) + (IO ^ 48), IO = getchar();
	return res;
}

int n;
int a[200005], x[200005];

int main () {
	n = rd();
	REP (i, 1, n)
		a[i] = rd();

	int m = 0;
	DREP (i, n, 1) {
		int now = 0;
		for (int j = i + i; j <= n; j += i)
			now ^= x[j];
		x[i] = now ^ a[i];
		if (x[i]) ++m;
	}

	printf ("%d\n", m);
	REP (i, 1, n) if (x[i])
		printf ("%d ", i);

	return 0;
}


Measured memory_bytes: 2432
import java.util.Scanner;

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

        String t = sc.next();
        for (int i = 0; i < t.length(); i++) {
            char c = t.charAt(i);
            if (c == '?') {
                System.out.print('D');
            } else {
                System.out.print(c);
            }
        }

    }
}

Measured memory_bytes: 57712
n=int(input())
h=list(map(int,input().split()))
p=0
for i in range(1,101):
    a=False
    for j in h:
        if i<=j and not(a):
            p+=1
            a=True
        if a and i>j:
            a=False
        #print(i,j,a)
print(p)

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

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    if(n < 10){
        ans = n;
    }else if(n < 100){
        ans = 9;
    }else if(n < 1000){
        ans = 9 + n - 99;
    }else if(n < 10000){
        ans = 9 + 900;
    }else if(n < 100000){
        ans = 9 + 900 + n - 9999;
    }else{
        ans = 9 + 900 + 90000;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100005
#define NIL -1
  
struct Node{
    int p;
    int l;
    int r;
};
struct Node np[MAX];
int depth = 0;
int hileft = 0;
int hiright = 0;
  
  
int get_depth(int u){
  
    if(np[u].p == NIL) return 0;
    if(np[u].p != NIL){
        depth++;
        get_depth(np[u].p);
    }
    return depth;
}
  
int degree(int u){
    if (np[u].l == NIL && np[u].r == NIL) return 0;
    else if(np[u].l != NIL && np[u].r != NIL)  return 2;
    else  return 1;
}
  
int sibling(int u){
  
    if(np[u].p == NIL) {
        return NIL;
    }
    else if(np[np[u].p].l == u) {
        return np[np[u].p].r;
    }
    else {
        return np[np[u].p].l;
    }
}
  
int hight(int u){
  
    int hileft = 0;
    int hiright = 0;
  
    if(np[u].l != -1) {
        hileft = hight(np[u].l) + 1;
    }
    if(np[u].r != -1){
        hiright = hight(np[u].r) + 1;
    }
    if(hileft < hiright){
        return hiright;
    }
    else {
        return hileft;
    }
}
  
void print(int u){
  
    printf("node %d: ",u);
    printf("parent = %d, ",np[u].p);
    printf("sibling = %d, ",sibling(u));
    printf("degree = %d, ",degree(u));
  
    depth = 0;
  
    printf("depth = %d, ",get_depth(u));
    printf("height = %d, ",hight(u));
  
    if(np[u].p == NIL)printf("root\n");
    else if(np[u].l == NIL && np[u].r == NIL) {
        printf("leaf\n");
    }
    else {
        printf("internal node\n");
    }
}
  
  
int main(){
    int i, j;
    int d, v, c, l;
    int n,tmp;
  
    scanf("%d", &n);
  
    for (i = 0; i < n; i++) {
        np[i].p = np[i].l = np[i].r = NIL;      // ?????????
    }
    for (i = 0; i <n ; i++){
        scanf("%d %d %d", &v, &d, &c);
        np[d].p = np[c].p = v;
        np[v].l = d;
        np[v].r = c;
    }
  
    for (i = 0; i < n; i++ ) {
        print(i);
    }
    return 0;
}

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

int main() {
  ll n, m;
  cin >> n >> m;

  ll a, b;
  vector<vector<ll>> g(n);
  for (ll i = 0; i < m; i++) {
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  vector<ll> ans(n, -1);
  queue<pair<ll, ll>> q;
  q.push(make_pair(0, -1));

  while (!q.empty()) {
    auto now = q.front(); q.pop();
    if (ans[now.first] != -1) continue;
    ans[now.first] = now.second;

    for (auto next : g[now.first]) {
      if (next == now.second) continue;
      q.push(make_pair(next, now.first));
    }
  }

  cout << "Yes" << endl;
  for (ll i = 1; i < n; i++) {
    cout << ans[i] + 1 << endl;
  }
}


Measured memory_bytes: 15380
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=998244353;
int modP(int a,int b)
{
	if(a==1)
		return 1;
	if(b==0)
		return 1;
	if(b%2==0)
	{
		a*=a;
		a=a%mod;
		return modP(a,b/2)%mod;
	}

	return a*modP(a,b-1)%mod;

}
int add(int a,int b)
{
	return (a+b)%mod;
}
int inv(int a,int b)
{
	return a*modP(b,mod-2)%mod;
}
int fact[(int)1e5];
int fac(int n)
{
    if(n<=1)
        return fact[n]=1;
    if(fact[n]!=0)
        return fact[n];
    return fact[n]=n*fac(n-1);

}
int Cnk(int n,int k)
{
    return fac(n)/fac(k)/fac(n-k);
}
vector<int> g[(int)2e5];
void dfs(int s,vector<bool>& vis,int p)
{
    vis[s]=true;
    for(int i:g[s])
    {
        if(i==p || vis[i])
            continue;
        dfs(i,vis,s);

    }
}
signed main()
{
   int n,m;
   cin>>n>>m;
   for(int i=0;i<m;i++)
   {
       int a,b;
       cin>>a>>b;
       a--,b--;
       g[a].push_back(b);
       g[b].push_back(a);

   }
   int cnt=0;
   vector<bool> vis(n,false);
   for(int i=0;i<n;i++)
   {
       if(!vis[i])
       {
           dfs(i,vis,-1);
           cnt++;
       }
   }
   cout<<cnt-1<<endl;
}


Measured memory_bytes: 13436
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(){
	char Ns[11];
	int N;
	int S=0;
	
	scanf("%s",Ns);
	for(int i=0;i<strlen(Ns);i++)
		S+=Ns[i]-'0';
	
	N=atoi(Ns);
	if(N%S==0)
		printf("Yes\n");
	else
		printf("No\n");
		
	return 0;
	
}

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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

int32_t main(){
   fast;
   int n,m,k;
   cin >> n >> m >> k;

   string s[n];
   f(i,0,n) cin >> s[i];


   int ans = 0;
   f(i,0,1<<n){
      f(j,0,1<<m){
         string a[n];
         f(i0,0,n)   a[i0] = s[i0];

         f(i0,0,n) if((i & (1<<i0))){
            f(j0,0,m)   a[i0][j0] = 'R';
         }
         f(j0,0,m) if((j & (1<<j0))){
            f(i0,0,n) a[i0][j0] = 'R';
         }

         int tot = 0;
         f(i0,0,n)  f(j0,0,m) tot += (a[i0][j0] == '#');
         ans += (tot == k);
      }
   }
   cout << ans << "\n";
}

Measured memory_bytes: 3640
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()


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



//Combination MOD
const ll MOD = INF + 7;

int main(){
    int n;
    string s;
    cin >> n >> s;
    ll res = 0;
    REP(num, 0, 999){
        string t = to_string(num);
        if(t.size() == 1)t = "00" + to_string(num);
        else if(t.size() == 2)t = "0" + to_string(num);
        int now = 0;
        
        rep(i, n){
            if(t[now] == s[i]){
                now++;
            }
        }
        if(now == 3)res++;
    }
    cout << res << endl;
}


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

const int mod = 998244353;

const int base = 26;

const int max_N = 600 + 21;

char a[max_N][max_N];

int n, hash_x[max_N][max_N], hash_y[max_N][max_N];

int pw[max_N], _pw[max_N], inv[30];

int get_hash_x(int x, int l, int r){
	if(!l) return hash_x[x][r];
	int res = (hash_x[x][r] - hash_x[x][l-1] + mod)%mod;
	return 1ll*res*_pw[l]%mod;
}

int get_hash_y(int y, int l, int r){
	if(!l) return hash_y[r][y];
	int res = (hash_y[r][y] - hash_y[l-1][y] + mod)%mod;
	return 1ll*res*_pw[l]%mod;
}

bool check(int x, int y){
	for(int i=0;i<n;++i)
		if(get_hash_x(x+i, y+i, y+n-1) != get_hash_y(y+i, x+i, x+n-1))
			return false;
	return true;
}

int main(){
	scanf("%d", &n);
	inv[1] = 1;
	for(int i=2;i<=base;++i){
		inv[i] = 1ll*(mod/i)*inv[mod%i]%mod;
		if(inv[i]) inv[i] = mod - inv[i];	
	}
	pw[0] = _pw[0] = 1;
	for(int i=1;i<=2*n;++i){
		pw[i] = 1ll*pw[i-1]*base%mod;
		_pw[i] = 1ll*_pw[i-1]*inv[base]%mod;
	}
	for(int i=0;i<n;++i){
		scanf("%s", a[i]);
		for(int j=0;j<n;++j) a[i][j+n] = a[i][j];
		for(int j=0;j<2*n;++j) a[i+n][j] = a[i][j];
	}
	for(int i=0;i<2*n;++i)
		for(int j=0;j<2*n;++j){
			hash_x[i][j] = ((j ? hash_x[i][j-1] : 0) + 1ll*pw[j]*(a[i][j] - 'a'))%mod;
		}
	for(int j=0;j<2*n;++j)
		for(int i=0;i<2*n;++i){
			hash_y[i][j] = ((i ? hash_y[i-1][j] : 0) + 1ll*pw[i]*(a[i][j] - 'a'))%mod;
		}
	int ans = 0;
	for(int i=0;i<n;++i)
		for(int j=0;j<n;++j){
			ans += check(i, j);
		}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin, s;
    int mod = 0;
    int n = s.size();
    REP(i, 0, n) {
        mod += (s[i] - '0');
    }
    mod %= 9;
    print((mod == 0) ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 3772
use std::collections::HashSet;

fn main() {
    let mut set = HashSet::<i32>::new();

    let n = read::<i32>();
    for _ in 0..n {
        set.insert(read::<i32>());
    }

    println!("{}", set.len());
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
n = int(input())

abc=list()
for i in range(n):
    abc.append([int(e) for e in input().split()])

A=[]
B=[]
C=[]

A.append(abc[0][0])
B.append(abc[0][1])
C.append(abc[0][2])

for i in range(1,n):
    a = abc[i][0] + max(B[-1],C[-1])
    b = abc[i][1] + max(A[-1],C[-1])
    c = abc[i][2] + max(A[-1],B[-1])
    A.append(a)
    B.append(b)
    C.append(c)

print(max(A[-1],B[-1],C[-1]))

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

int main()
{
    string S;
    cin >> S;
    vector<bool> v(26);

    for (int i = 0; i < S.size(); i++)
    {
        v.at(S.at(i) - 'a') = true;
    }

    for (int i = 0; i < v.size(); i++)
    {
        if (!v.at(i))
        {
            cout << (char)('a' + i) << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


Measured memory_bytes: 3652
#include<algorithm>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(void){
	int n,k,ans=1;
	cin>>n>>k;
	for(int i=0;i<n;i++) ans+=min(ans,k);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using  namespace std;
int t;
int main()
{
	cin>>t;
	if(t%1000==0)
	{
		cout<<0<<endl;
	}
	else
	{
		int ans=t/1000;
		cout<<(ans+1)*1000-t<<endl;
	}
	return 0;
 } 

Measured memory_bytes: 3632
H,W = map(int,input().split())
s = []

for i in range(H):
    s.append(list(input()))

flag = 0
for i in range(H):
    for j in range(W):
        if s[i][j] == ".":
            pass
        else:
            if i > 0 and s[i-1][j] == "#":
                pass
            elif i < H-1 and s[i+1][j] == "#":
                pass
            elif j > 0 and s[i][j-1] == "#":
                pass
            elif j < W-1 and s[i][j+1] == "#":
                pass
            else:
                flag = 1

if flag != 1:
    print("Yes")
else:
    print("No")

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

using namespace std;
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.12lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define mod 1000 * 1000 * 1000 + 7
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;

const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265359;

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

map<int,int>mp; 

int main()
{
    int n;
    cin>>n;
    for(int i=2;i<=n;++i){
        int j=2,mx=i;
        while(mx>1){
            if(mx%j==0){
                mp[j]+=1;
                mx/=j;
            }
            else 
                j+=1;
            
        }
    }
    ll ans=1;
    for(auto C:mp){
        ans*=(C.S+1);
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
s = gets.chomp.split("")

if s[0] == s[1] && s[1] == s[2] && s[2] == s[3] then
  puts "No"
elsif s[0] == s[1] && s[2] == s[3] then
  puts "Yes"
elsif s[0] == s[2] && s[1] == s[3] then
  puts "Yes"
elsif s[0] == s[3] && s[1] == s[2] then
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 1788
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	S = inputStr()

	if S.isupper() == True:
		print("A")
	else:
		print("a")


#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 77204
#include<iostream>
#include<vector>
using namespace std;
int main(){
  bool num[300001] = {true,true,false};
  for(int i=0; i<300001; i++){
    if(i%7 != 1 && i%7 != 6){num[i] = true;}
    if(num[i] == false){
      for(int j=i*2; j<300001; j+=i){
	num[j] = true;
      }
    }
  }
  int n;
  while(cin >>n){
    vector<int> ans;
    if(n == 1){break;}
    for(int i=0; i<=n; i++){
      if(!num[i]){if(!(n%i)){ans.push_back(i);}}
    }
    cout <<n<<":";
    for(int i=0; i<ans.size(); i++){
      cout <<" "<<ans[i];
    }
    cout <<endl;
  }
  return 0;
}

Measured memory_bytes: 1196
/***********************************************************
	When you are inspired by passion 
	and you want to live for the current moment

	When your every thought and action
	has the power to become the story of your future

	When difficulties stand to demolish your Glory
	Just remember that Life is a 'Golden adverse Story'

	Withstand it to acheive your passion and dreams
	more amazingly more easily.

	Why then? When writing the story of your Life
	You want to Let someone else hold your pen

					huzaifa242©

***********************************************************/
#include <bits/stdc++.h>
using namespace std;
#define int int32_t
#define MAX 100005
#define x first 
#define y second

int seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l=0,int r=INT_MAX)
{return uniform_int_distribution<int>(l,r)(rng);}

template <typename T,typename G>
ostream& operator << (ostream& out, const pair<T,G> &a) 
{return out<<"( "<<a.x<<", "<<a.y<<")";}

template <typename T>
ostream& operator << (ostream& out, const vector<T> &a) 
{out<<"[ ";for(const auto &i:a)out<<i<<", ";return out<<"]"<<endl;}

template <typename T>
ostream& operator << (ostream& out, const set<T> &a) 
{out<<"{ ";for(const auto &i:a)out<<i<<", ";return out<<"}"<<endl;}

template <typename T,typename G>
ostream& operator << (ostream& out, const map<T,G> &a) 
{out<<"< ";for(const auto &i:a)out<<i<<", ";return out<<">"<<endl;}

template<typename T, size_t N>
typename enable_if<!is_same<typename remove_cv<T>::type, char>::value,
ostream&>::type operator<<(ostream& out, T(&a)[N])
{out<<"[ ";for(size_t i=0;i<N;++i)out<<a[i]<<", ";out <<"]"<<endl;return out;}

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

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n,i;
	long long sum=0;
	cin>>n;
	vector<int> count(MAX,0);
	for(i=0;i<n;i++){
		int x;
		cin>>x;
		sum+=x;
		count[x]++;
	}
	int q;
	cin>>q;
	while(q--){
		int b,c;
		cin>>b>>c;
		sum-=(1ll*b*count[b]);
		sum+=(1ll*c*count[b]);
		count[c]+=count[b];
		count[b]=0;
		cout<<sum<<"\n";
	}
	return 0;
}


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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    int n, p;
    cin >> n >> p;
    bool exists_odd = false;
    int a;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a % 2 == 1) {
            exists_odd = true;
            break;
        }
    }

    if (exists_odd) {
        cout << (ll)pow(2, n - 1) << endl;
    } else {
        if (p == 0) {
            cout << (ll)pow(2, n) << endl;
        } else {
            cout << 0 << endl;
        }
    }
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N;
int A[200005];
signed main(){
	cin>>N;
	int sum=0;
	rep(i,N){
		cin>>A[i];
		sum+=A[i];
	}
	int ans=inf,now=0;
	rep(i,N){
		now+=A[i];
		chmin(ans,max(now,sum-now)-min(now,sum-now));
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 5152
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
using namespace std;

const int INF=1e9+7;
const int MOD=1e9+7;

ll modpow(ll a,ll b){
    ll ret=1;
    while(b>0){
        if(b&1)(ret*=a)%=MOD;
        (a*=a)%=MOD;
        b>>=1;
    }
    return ret;
}

vector<ll> kaijo;
vector<ll> gyaku;
void prepair(ll n){
    kaijo.PB(1);
    FOR(i,1,n+1){
        kaijo.PB((kaijo[i-1]*i)%MOD);
    }
    FOR(i,0,n+1){
        gyaku.PB(modpow(kaijo[i],MOD-2));
    }
}

//AtCoder Regular Contest 067 - Grouping
int main(){
    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    ll C[1001][1001]={};
    C[0][0]=1;
    FOR(i,1,n+1){
        FOR(j,0,i+1){
            if(j==0) C[i][j]=1;
            else C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;
        }
    }
    prepair(n+1);
    //dp[x][y]:x人以下のグループで全体y人のやつ
    //dp[x][y]=Sum(dp[x-1][y-kx])(k=0,c,c+1,...,min(d,y/x))
    ll dp[1001][1001]={};
    FOR(i,0,1001) dp[i][0]=1;
    FOR(x,a,b+1) FOR(y,0,n+1){
        dp[x][y]=dp[x-1][y];
        ll C2[1001]={}; C2[0]=1;
        FOR(j,1,min(d,y/x)+1){
            (C2[j]=C2[j-1]*C[n-y+j*x][x])%=MOD;
        }
        FOR(j,c,min(d,y/x)+1){
            (C2[j]*=gyaku[j])%=MOD;
            ll kari=(dp[x-1][y-j*x]*C2[j])%MOD;
            (dp[x][y]+=kari)%=MOD;
        }
    }
    /**
    FOR(i,0,10){
        FOR(j,0,10){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }
    **/
    co(dp[b][n]);
}


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

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)
#define SCANFD(x) scanf("%d",&x)

int main()
{
    int N,A,B;
    
    scanf("%d%d%d",&N,&A,&B);

    if(A*N>B)
        printf("%d\n",B);
    else
        printf("%d\n",A*N);            
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {
  int N;
  bool four = false;

  scanf("%d", &N);

  char c;
  for (int i = 0; i < N; i++) {
    if (four) continue;
    scanf("%c", &c);
    if (c == 'Y') four = true;
  }

  if (four) printf("Four\n");
  else printf("Three\n");

  return 0;
}


Measured memory_bytes: 128
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i
count = 0
(a + 1).times do |i|
  (b + 1).times do |j|
    (c + 1).times do |k|
      if 500 * i + 100 * j + 50 * k == x
        count += 1
      end
    end
  end
end
puts count

Measured memory_bytes: 1788
print(' '.join(list(map(str,((lambda n:[["-1"],["0 0 1 1"]][not n[1]]if n[0]==1 else([n[1]]+list(range(n[1]))+list(range(n[1]+1,(1<<n[0])))+[n[1]]+list(range((1<<n[0])-1,n[1],-1))+list(range(n[1]-1,-1,-1))if n[1]<(1<<n[0])else["-1"]))(list(map(int,input().split()))))))))


Measured memory_bytes: 31980
#include <bits/stdc++.h>
using namespace std; 
int gcd_[205][205];
int main()
{
	int a;
	long long sum = 0;
	scanf("%d", &a);
	for(int i = 1; i <= a; i++)
		for(int j = 1; j <= a; j++)
			gcd_[i][j] = __gcd(i, j);
	for(int i = 1; i <= a; i++)
		for(int j = 1; j <= a; j++)
			for(int k = 1; k <= a; k++)
				sum += gcd_[gcd_[i][j]][k];
	printf("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 3968
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define mod 1000000007
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;

ll inv[1001000];
ll fac[10001000];
ll invfac[1001000];

ll getcon(ll a, ll b) {
    return fac[a] * invfac[b] % mod * invfac[a - b] % mod;
}

int main() {
    ll n;
    cin >> n;
    inv[1] = 1;
    fac[0] = 1;
    invfac[0] = 1;
    for (ll i = 1; i < n + 10; i++) {
        if (i > 1) {
            inv[i] = (mod - (mod / i) * inv[mod % i] % mod) % mod;
        }
        fac[i] = (fac[i - 1] * i) % mod;
        invfac[i] = invfac[i - 1] * inv[i] % mod;
    }
    ll a[100100];
    fill(a, a + n + 1, -1);
    ll lef, rig;
    imfor(i, n + 1) {
        ll tmp;
        cin >> tmp;
        if (a[tmp] != -1) {
            lef = a[tmp];
            rig = n - i;
        }
        else {
            a[tmp] = i;
        }
    }
    for (ll i = 1; i <= n + 1; i++) {
        ll ans = getcon(n + 1, i);
        if (i - 1 <= lef + rig) {
            ans -= getcon(lef + rig, i - 1);
        }
        ans %= mod;
        if (ans < 0) {
            ans += mod;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 11008
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

typedef long long ll;
typedef pair<ll, ll> P;

//const int MAX = 700000;
//static const ll MOD = 1000000007;
//static const ll INF = 100000000;

int main() {
    string S;
    ll ans = 0;

    // input
    cin >> S;

    // process
    for (ll i = 0; i < S.size()/2; i++) {
        if (S[i] != S[S.size() - i - 1]) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#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 = 1e2 + 10;
int a[N][N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
			cin >> a[i][j];
		for (int j = 1; j < i; j++)
		{
			int sum = 0;
			for (int k = 1; k <= m; k++)
			{
				int delta = a[i][k] - a[j][k];
				sum += delta * delta;
			}
			int d = sqrt(sum) + 0.5;
			if (d * d == sum)
				ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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


def quotient(a, b):
    return a // b


def remainder(a, b):
    return a % b


def decimal_point(a, b):
    return round(a / b, 5)


d = quotient(a, b)
r = remainder(a, b)
f = decimal_point(a, b)

print(d, r, f)



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

int main(){
    int n;
    string s;
    cin>>n>>s;
    int cnt=0;
    for(int i=2; i<n; i++){
        if(s.at(i)=='C'){
            if(s.at(i-1)=='B' and s.at(i-2)=='A')cnt++;
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  char s[2];
  scanf("%s",&s);
  switch(s[0]){
    case 'A':
      printf("T");
      break;
    case 'C':
      printf("G");
      break;
    case 'T':
      printf("A");
      break;
    case 'G':
      printf("C");
      break;
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

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

	const double PI = 3.14159265358979323846;
	cout << fixed << setprecision(5) << R * 2 * PI << endl;

	return 0;
}

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

using namespace std;

int A,B;

int main() {
    cin>>A>>B;
   
    
    
   if (A==B) {
    cout << "Draw" << endl;
} else if (A==1) {
    cout << "Alice" << endl;
} else if (B==1) {
    cout << "Bob" << endl;
} else if (A>B) {
    cout << "Alice" << endl;
} else {
    cout << "Bob" << endl;
}

    
}



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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  map<char,ll> m;
  rep(i,s.size()){
    m[s[i]]++;
  }
  ll ans=min(m['0'],m['1'])*2;
  cout<<ans<<endl;
}

Measured memory_bytes: 512