akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
use proconio::input;
use proconio::marker::*;
use std::collections::HashSet;

fn main() {
  input! {
    a: usize,
    b: usize,
    c: usize,
  }
  
  let mut memo = vec![a,b,c];
  memo.sort();
  let a = memo[0];
  let b = memo[1];
  let c = memo[2];
  
  let cb = (c - b) % 2;
  let ca = (c - a) % 2;
  
  if cb == 0 && ca == 0 {
    println!("{}", (c - b) / 2 + (c - a) / 2);
  } else if (cb == 1 && ca == 0) || cb == 0 && ca == 1 {
    let v = (b - (a + 1)) / 2;
    let vv = c + 1 - b;
    println!("{}", 1 + v + vv);
  } else {
    println!("{}", 1 + ((c - b) / 2) + ((c - a) / 2));
  }
}

Measured memory_bytes: 2164
n, m = map(int, input().split())

max_check = (m**(1/2))//1
ans = 0
for i in range(1, int(max_check)+1):
    if m % i == 0:
        josuu = i
        shou = int(m//i)
        if josuu >= n:
            ans = max(ans, shou)
        if shou >= n:
            ans = max(ans, josuu)
print(ans)



Measured memory_bytes: 3060
/*
@Date    : 2019-10-05 13:07:36
@Author  : Adscn (adscn@qq.com)
@Link    : https://www.cnblogs.com/LLCSBlog
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IL inline
#define RG register
#define gi geti<int>()
#define gl geti<ll>()
#define gc getchar()
#define File(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
template<typename T>IL bool chkmax(T &x,const T &y){return x<y?x=y,1:0;}
template<typename T>IL bool chkmin(T &x,const T &y){return x>y?x=y,1:0;}
template<typename T>
IL T geti()
{
	RG T xi=0;
	RG char ch=gc;
	bool f=0;
	while(!isdigit(ch))ch=='-'?f=1:f,ch=gc;
	while(isdigit(ch))xi=xi*10+ch-48,ch=gc;
	return f?-xi:xi;
}
template<typename T>
IL void pi(T k,char ch=0)
{
	if(k<0)k=-k,putchar('-');
	if(k>=10)pi(k/10);
	putchar(k%10+'0');
	if(ch)putchar(ch);
}
typedef pair<ll,ll> pll;
int n;
const int N=2e5+7,P=1e9+7;
ll ksm(ll a,int b,ll c=1)
{
	for(;b;b>>=1,a=a*a%P)if(b&1)c=c*a%P;
	return c;
}
ll inv(ll x){return ksm(x,P-2);}
struct edge{int v,nxt;}e[N];
int head[N],cnt;
inline void add(int u,int v){e[++cnt]=(edge){v,head[u]},head[u]=cnt;}
inline void init(){memset(head,cnt=-1,sizeof head);}
vector<pll>dp[N];
ll All[N],Zero[N],One[N];
int id[N],num,d[N];
#define mp make_pair
#define fi first
#define se second
#define For_tree(x) for(int _i=head[x],v=e[_i].v;~_i;_i=e[_i].nxt,v=e[_i].v)
inline void dfs(int x)
{
	int hson=n+1,tot=0;
	For_tree(x)
	{
		dfs(v);++tot;
		if(d[v]>d[hson])hson=v;
	}
	if(hson!=n+1)id[x]=id[hson],d[x]=d[hson]+1;
	else id[x]=++num;
	dp[id[x]].push_back(mp(1,1));
	if(tot==1)return;
	for(int i=0;i<d[x];++i)All[i]=1,Zero[i]=1,One[i]=0;
	int dep;
	For_tree(x)
		for(int i=0;i<=d[v];++i)
		{
			dep=d[hson]-d[v]+i;
			pll t=dp[id[v]][i];
			(All[dep]*=(t.fi+t.se))%=P,(Zero[dep]*=t.fi)%=P;
		}
	For_tree(x)
		for(int i=0;i<=d[v];++i)
		{
			dep=d[hson]-d[v]+i;
			pll t=dp[id[v]][i];
			(One[dep]+=Zero[dep]*inv(t.fi)%P*t.se%P)%=P;
		}
	for(int i=0;i<d[x];++i)
	{
		pll &t=dp[id[x]][i];
		t.fi=(All[i]-One[i]+P)%P,t.se=One[i];
	}
}
int dep[N],tot[N],fa[N];
int main(void)
{
	n=gi;init();
	for(int i=1;i<=n;++i)fa[i]=gi,add(fa[i],i),dep[i]=dep[fa[i]]+1,++tot[dep[i]];
	d[n+1]=-1,++tot[0];
	dfs(0);
	ll ans=0;
	for(int i=0;i<=d[0];++i){
		pll t=dp[id[0]][i];
		(ans+=t.se*ksm(2,n+1-tot[d[0]-i])%P)%=P;
	}
	pi(ans);
	return 0;
}

Measured memory_bytes: 34032
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      String S = sc.next();
      
      if(S.equals("ABC"))
      {
      System.out.println("ARC");
      }
      else if(S.equals("ARC")){
      System.out.println("ABC");
      }
   }
}

Measured memory_bytes: 35424
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    char X[2], Y[2];

    scanf("%s%s", X, Y);

    if(X[0] < Y[0]){
        printf("<\n");
    }else if(X[0] == Y[0]){
        printf("=\n");
    }else{
        printf(">\n");
    }

    return 0;
}

Measured memory_bytes: 1640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_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;

signed main(){
    ll a,b,x; cin >> a >> b >> x;
    ll ans=b/x-a/x;
    if(a%x==0) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;
const double EPS = 1e-8;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    int ans = 1;
    if(n < m) swap(n, m);
    if(n - m > 1) ans = 0;
    rep(i, 0, n) (ans = ans * (i + 1)) %= mod; 
    rep(i, 0, m) (ans = ans * (i + 1)) %= mod; 
    if(n == m) ans *= 2;
    cout << ans % mod << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (ll NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (ll NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (ll NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll LINF = 1e18;
const int INF = 1e9;
const int mod = 1e9+7;

int main(){
  int x,a;
  cin >> x >> a;
  if(x < a)cout<<0<<endl;
  else cout<<10<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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 int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


int main(void){
  ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
  int n;
  cin >> n;
  vi w(n);
  vi sum(n);
  int ans=INF;
  rep(i,n){
    cin >> w[i];
    if(i==0){
      sum[0] = w[i];
    }else{
      sum[i] = sum[i-1] + w[i];
    }
  }
  rep(i,n){
    ans = min(ans,abs((sum[n-1]-sum[i])-sum[i]));
  }
  cout << ans << endl;
//////////////////////////////////////////////////////
return 0;
}

Measured memory_bytes: 256
(let ((a (read))
      (b (read))
      (c (read))
      (d (read))
      (e (read)))
  (if (eq a e)
    (progn
      (princ (1- c))
      (princ #\space)
      (princ d))
    (progn
      (princ c)
      (princ #\space)
      (princ (1- d)))))


Measured memory_bytes: 10212
import java.util.*;

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

        S = S.replaceAll("eraser", "0");
        S = S.replaceAll("erase", "0");
        S = S.replaceAll("dreamer", "0");
        S = S.replaceAll("dream", "0");
        S = S.replaceAll("0", "");

        if (S.isEmpty()) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

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

//?????????????????¨????§???????-------------------
typedef struct{
	int top;
	int front;
	int right;
	int left;
	int back;
	int bottom;
}Dice;
//---------------------------------------
void roll_n(Dice *dice);
void roll_e(Dice *dice);
void roll_s(Dice *dice);
void roll_w(Dice *dice);

//---------------------------------------

int main(void)
{
	Dice dice;
	string rolling;
	
	cin >> dice.top;
	cin >> dice.front;
	cin >> dice.right;
	cin >> dice.left;
	cin >> dice.back;
	cin >> dice.bottom;
	
	cin >> rolling;
	
	for(int i = 0; i < rolling.size(); i++){
	
		switch(rolling[i]){
		case 'N' :
			 roll_n(&dice);
			 break;
		case 'E' :
			 roll_e(&dice);
			 break;
		case 'S' :
			 roll_s(&dice);
			 break;
		case 'W' :
			 roll_w(&dice);
			 break;
		}
	}
	
	cout << dice.top << endl;
	
	
	return 0;
	
}
//-------------------------------------
void roll_n(Dice *dice)
{
	Dice copy = *dice;
	
	dice -> back   = copy.top;
	dice -> bottom = copy.back;
	dice -> front  = copy.bottom;
	dice -> top    = copy.front;
}

//--------------------------------------
void roll_e(Dice *dice)
{
	Dice copy = *dice;
	
	dice -> top    = copy.left;
	dice -> right  = copy.top;
	dice -> bottom = copy.right;
	dice -> left   = copy.bottom;
}

//--------------------------------------
void roll_s(Dice *dice)
{
	Dice copy = *dice;
	
	dice -> front  = copy.top;
	dice -> bottom = copy.front;
	dice -> back   = copy.bottom;
	dice -> top    = copy.back;
}

//--------------------------------------
void roll_w(Dice *dice)
{
	Dice copy = *dice;
	
	dice -> left   = copy.top;
	dice -> bottom = copy.left;
	dice -> right  = copy.bottom;
	dice -> top    = copy.right;
}
/*
Top  [0]
Front [1]
Right [2]
Left [3]
Back [4]
Bottom [5]
*/

Measured memory_bytes: 3168
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#define clr(x) memset((x), 0, sizeof((x)))
#define endl "\n"
#define fe(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define fn(i, st, ed) for (int i = (st); i < (ed); ++i)
const int INF = 0x3f3f3f3f;

int read() {
	int x = 0, f = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9') {
		if (ch == '-') f = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9') {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x;
}
    ll dp[101000][2];
ll a[101000];
int main(){
	#ifdef LOCAL
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
		#if __cplusplus >= 201103L
		auto start = steady_clock::now();
		#endif
	#endif
	int n = read();
	fn(i, 0, n) {
		// a[i] = read();
		cin >> a[i];
	}
	dp[0][0] = dp[0][1] = 0;
	dp[1][0] = a[0];
	dp[1][1] = -a[0];
	fn(i, 1, n - 1) {
		dp[i + 1][0] = max(dp[i][0] + a[i], dp[i][1] - a[i]);
		dp[i + 1][1] = max(dp[i][0] - a[i], dp[i][1] + a[i]);
	}
	cout << max(dp[n - 1][0] + a[n - 1], dp[n - 1][1] - a[n - 1]) << endl;
	#ifdef LOCAL
		#if __cplusplus >= 201103L
		auto end = steady_clock::now();
		duration<double> time_span = duration_cast<duration<double>>(end - start);;
		printf("Total time: %.6fs\n", time_span.count());
		#endif
	#endif
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

ll mod_pow(ll x, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % mod;
		x = x * x % mod; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n % mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a * a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 17;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}



void solve(){
	int n; cin >> n;
	vector<int> ans(n + 1);
	Rep1(x, 1, 200)Rep1(y, 1, 200)Rep1(z, 1, 200) {
		int val = x * x + y * y + z * z + x * y + y * z + z * x;
		if (val <= n)ans[val]++;
	}
	rep1(i, n)cout << ans[i] << "\n";
}




signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init_f();
	//cout << grandy(2, 3, false, false) << "\n";
	//int t; cin >> t; rep(i, t)
	solve();
	return 0;
}

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

using namespace std;

int main() {

	string s;
	cin >> s;

	int zerocount = 0;
	int onecount = 0;
	for (int i = 0; i <s.size(); i++) {
		if (s[i] == '0') { zerocount++; }
		if (s[i] == '1') { onecount++; }
	}
	cout << min(zerocount, onecount) * 2 << endl;
	
}

Measured memory_bytes: 512
// 　　＿＿
// 　／　<＠ﾌ
//  ｜(ﾉﾉハ))
//  ﾉ从ﾟヮﾟ从
// 　ﾉ｜ｿﾉГ|つ author:hotarunx
// 〈_ﾉ^^^ヽ|
// 　~~tｧtｧ~
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long
constexpr int MOD = 1000000000 + 7;

// https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#3-%E5%89%B2%E3%82%8A%E7%AE%97-a--b
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    const int sum = accumulate(a.begin(), a.end(), 0LL);

    int ans = 0;

    for (int i = 0; i < n; i++) {
        ans += a[i] % MOD * ((sum - a[i]) % MOD);
        ans %= MOD;
    }

    ans %= MOD;
    ans = ans * modinv(2, MOD) % MOD;

    cout << ans << endl;
}

// hint
// https://www.wolframalpha.com/input/?i=a(b%2Bc%2Bd)+%2Bb(a%2Bc%2Bd)+%2B+c(a%2Bb%2Bd)+%2B+d(a%2Bb%2Bc)&lang=ja


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

int main(){
  long long N;
  cin >> N;
  double ans = 0.0, den = 0.0, A;
  for(int i = 0; i < N; i++){
    cin >> A;
    den += 1.0 / A;
  }
  
  ans = 1.0 / den;
  cout << setprecision(16) << ans << endl;
}


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

int main()
{
  string str;
  string buf;
  string ans[200];
  int m;
  int x;
  int count=0;

  cin >> str;
  while(str!="-")
    {
      cin >> m;

      for(int i=0;i<m;i++)
	{
	  cin >> x;
	  buf=str.substr(0,x);
	  // cout << buf << endl;
	  str.replace(0,x,"");
	  // cout << str << endl;
	  str+=buf;
	  // cout << str << endl;
	  ans[count]=str;
	}
      cin >> str;
      count++;
    }

  for(int i=0;i<count;i++)
    {
      cout << ans[i] << endl;
    }

  return 0;
}

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

int main() {
  string s;
  cin >> s;
  int cnt=0;
  int64_t ans=0;
  rep(i,s.length()){
    if(s[s.length()-i-1]=='B'){
      ans+=cnt;
    }
    else cnt++;
  }
  cout << ans << endl;

}

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

int main()
{
    int n,m,i,c=0;
    double h,k=0.0;
    scanf("%d %d",&n,&m);
    int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        k+=a[i];
    }
    h=k/(4.0 *(double)(m));
    //printf("%f\n",h);
    for(i=0;i<n;i++)
    {
        if(a[i]>=h)
            c++;
    }
    if(c>=m)
        printf("Yes\n");
    else
        printf("No\n");
}


Measured memory_bytes: 256
/**
    And in the end, the love you take is equal to the love you make.

        I LOVE YOU LAURA.
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_DISABLE_PERFCRIT_LOCKS

#define findOrder find_by_order
#define orderKey order_of_key

#define isOn(mask, i) (mask & (1 << i))
#define turn(mask, i) (mask |= (1 << i))
#define switch(mask, i) (mask &= ~(1 << i))
#define change(mask, i) (mask ^= (1 << i))
#define lowbit(mask) (mask & (-mask))
#define turnAll(mask, n) (mask = (1 << n) - 1)
#define switchLastBit(mask) (mask & (mask - 1))
#define turnLastZero(mask) (mask | (mask + 1))
#define modulo(x, mod) ((x) & (mod - 1))
#define log2(x) (31 - __builtin_clz(x))

#define mkp make_pair
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define ins insert
#define rsz resize
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define debug(x) (cerr << x << " ")

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdb;
typedef pair<int, ii> tri;
typedef complex<ld> cd;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vdb;
typedef vector<cd> vcd;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vll> matrix;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_tree;

const ll mod = 1e9+7;
const int maxn = 1e5+2;
const int pi = 2 * acos(0.0);
const db eps = 1e-9;

ll dp[maxn][2];
vi tre[maxn];

void dfs (int u, int parent){
    dp[u][0] = dp[u][1] = 1;

    for (auto v: tre[u]){
        if (v == parent) continue;
        dfs(v, u);
        dp[u][0] = (dp[u][0] * (dp[v][0] + dp[v][1]) % mod) % mod;
        dp[u][1] = (dp[u][1] * dp[v][0]) % mod;
    }
}

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

    int n; cin >> n;

    for (int i = 1; i < n; i++){
        int a, b; cin >> a >> b;

        tre[a].pb(b);
        tre[b].pb(a);
    }

    dfs(1, 0);

    cout << (dp[1][0] + dp[1][1]) % mod << "\n";

    return 0;
}


Measured memory_bytes: 14208
#!/bin/ruby
require 'complex'
def cross(a,b)
  return a.real*b.imag-a.imag*b.real
end
until (n=gets.to_i)==0
  xyr=n.times.map{gets.split.map(&:to_i)}
  p=xyr.map{|e|Complex(e[0],e[1])}
  cp=(n-1).times.map{|x|
    c=(p[x+1]-p[x]).abs
    theta=Math.acos((1.0*xyr[x][2]**2+c**2-xyr[x+1][2]**2)/(2*xyr[x][2]*c))
    alpha=(p[x+1]-p[x]).arg
    [
     Complex.polar(xyr[x][2],alpha+theta)+p[x],
     Complex.polar(xyr[x][2],alpha-theta)+p[x]
    ]
  }
  dp=[[0,0,p[0]]]
  list=(0...cp.size).reduce([]){|r,x|
    r+[[x+1,cp[x][0]],[x+1,cp[x][1]]]
  } << [p.size,p[-1]]
  list.each do |e|
    d=1e99
    c=nil
    dp.each do |f|
      if (f[0]..e[0]-2).all?{|g|
          cross(f[2]-e[1],cp[g][0]-e[1])*cross(f[2]-e[1],cp[g][1]-e[1])<0&&
          cross(cp[g][1]-cp[g][0],f[2]-cp[g][0])*cross(cp[g][1]-cp[g][0],e[1]-cp[g][0])<0
        }then
        cd=(e[1]-f[2]).abs+f[1]
        if cd<d then
          d=cd
          c=[e[0],d,e[1]]
        end
      end
    end
    dp << c
  end
  puts dp[-1][1]
end

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

typedef long long ll;

static const int MAX = 1e6;
static const int NIL = -1;
static const ll INF = 1<<21;
static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

int main(void) {
    string S, T;
    cin >> S >> T;

    int A, B;
    cin >> A >> B;

    string U;
    cin >> U;

    if(S==U) A--;
    else B--;

    cout << A <<" " << B;

    return 0;
}


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

int main()
{
    int S;
    cin >> S;
    cout << S/3600 << ":" << (S - (S/3600*3600))/60 << ":" << S - ((S/3600*3600) + (S-S/3600*3600)/60*60) << endl;  
}



Measured memory_bytes: 3092
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		int Q = Integer.parseInt(sc.next());

		int[][] C = new int[N + 1][N + 1];

		for(int i = 0; i < M; i++) {
			int l = Integer.parseInt(sc.next());
			int r = Integer.parseInt(sc.next());
			C[l][r]++;
		}

		for(int i = 1; i <= N; i++) {
			for(int j = 1; j <= N; j++) {
				C[i][j] += C[i][j - 1];
			}
		}
		for(int i = 1; i <= N; i++) {
			for(int j = 1; j <= N; j++) {
				C[i][j] += C[i - 1][j];
			}
		}

		for(int i = 0; i < Q; i++) {
			int p = Integer.parseInt(sc.next());
			int q = Integer.parseInt(sc.next());
			System.out.println(C[q][q] - C[p - 1][q] - C[p][p - 1] + C[p - 1][p - 1]);
		}
	}
}

Measured memory_bytes: 95672
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

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

long long int INF = 3e18;
long long int mod = 4294967296;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

ll n,m,num,sum,ans,a,b,c,d,e,f,g,h,i,j,k,w,ok,ng;
ll t[500005],l[500005],r[500005];
ll dp[5005][5005][3];
char s[500005];
bool flag,dame;

int main(){
    cin >> n;
	double ans = 0;
	double a;
	for(i=0;i<n;i++){
		cin >> a >> s;
		if(s[0] == 'J'){
			ans += a;
		}else{
			ans += (double)(a * 380000.0f);
		}
	}
	ps(ans);
	
	return 0;
}

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

int main() {
  int a, b;
  string s;
  cin >> a >> b >> s;
  
  bool ok = true;
  rep(i,a) if (s[i]=='-') ok = false;
  if (s[a] != '-') ok = false;
  rep(i,b) if (s[i+a+1]=='-') ok = false;
  
  if (ok)
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
}

Measured memory_bytes: 256
L = []
p = "No"
for i in range(3):
  a, b, c = map(str, input().split())
  L.append(a)
  L.append(b)
  L.append(c)
n = int(input())
for i in range(n):
  d = input()
  for j in range(9):
    if d == L[j]:
      L[j] = "×"
if (L[0] == "×" and L[8] == "×" and L[4] == "×") or (L[1] == "×" and L[7] == "×" and L[4] == "×") or (L[2] == "×" and L[6] == "×" and L[4] == "×") or (L[3] == "×" and L[5] == "×" and L[4] == "×"):
  p = "Yes"
elif (L[0] == "×" and L[1] == "×" and L[2] == "×") or (L[2] == "×" and L[5] == "×" and L[8] == "×") or (L[0] == "×" and L[3] == "×" and L[6] == "×") or (L[6] == "×" and L[7] == "×" and L[8] == "×"):
  p="Yes"
print(p)

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

int main() {
  vector<int> prime(100010,-1);
  for(int i=2;i<prime.size();i++){
    if(prime[i]==-1){
      prime[i]=1;
      for(int j=i+i;j<prime.size();j+=i){
        prime[j]=0;
      }
    }
  }
  prime[0]=0;prime[1]=0;
  vector<int> like(100010,0);
  for(int i=1;i<prime.size();i++){
    like[i]=like[i-1]+(prime[i]==1&&prime[(i+1)/2]==1&&i%2==1?1:0);
  }
  int Q;cin>>Q;
  for(int i=0;i<Q;i++){
    int l,r;cin>>l>>r;
    cout<<like[r]-like[l-1]<<endl;
  }
}

Measured memory_bytes: 1408
import numpy as np
H,W,K = map(int, input().split())
C = np.array([list(map(int, input())) for _ in range(H)])
C = np.hstack([np.zeros([H,1]),C])
np.cumsum(C, axis=1, out=C)
ans = 10**5
for s in range(1<<(H-1)):
	ind = 0
	A = np.zeros([1,W+1])
	for i in range(H):
		if s >> i & 1 == 1:
			A = np.vstack([A,C[ind:i+1,:].sum(axis=0)])
			ind = i+1
	A = np.vstack([A,C[ind:].sum(axis=0)])

	ind = 0
	cnt = 0
	while True:
		cut = 10**3+2
		for a in A:
			cut = min(cut, np.searchsorted(a,a[ind]+K,side='right'))
		if cut == W+1:
			break
		if ind == cut-1:
			cnt = 10**4+2
			break
		else:
			ind = cut-1
		cnt += 1

	h_cnt = 0
	for i in range(H):
		if s >> i & 1 == 1:
			h_cnt += 1

	ans = min(ans, cnt+h_cnt)

print(ans)

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

bool kaibun(string s) {
  string s_r;
  for (int i=s.size()-1; i>=0; i--) {
    s_r.push_back(s.at(i));
  }
  if (s == s_r) {
    return true;
  }
  else {
    return false;
  }
}


int main() {
  string s;
  cin >> s;
  
  if (kaibun(s) && kaibun(s.substr(0,(s.size()-1)/2)) && kaibun(s.substr((s.size()+3)/2-1,s.size()-(s.size()+3)/2+1)) ) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
}

Measured memory_bytes: 256
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = []

sum = 0
count = 0

for i in range(n):
    array = list(map(int, input().split()))
    a.append(array)

for i in range(n):
    for j in range(m):
        sum += a[i][j] * b[j]
    sum += c
    if sum > 0:
        count += 1
        sum = 0
    else:
        sum = 0


print(count)

Measured memory_bytes: 3064
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define node(a,b,c)   mp(mp(a,b),c)

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
 main()

{
    fast
    int x;
    cin>>x;
    if(x==2)
    {
        cout<<"2 2"<<endl;
        cout<<"1 2 0"<<endl;
        cout<<"1 2 1"<<endl;
        return 0;
    }
    x--;
    int cur=0;
    while(1)
    {
        int val=(1LL<<(cur+1));
        if(val<=x)cur++;
        else break;
    }
    vector<pair<pi,int>>vec;
    f(i,1,cur)
    {
        vec.pb(node(i,i+1,0));
        int val=(1LL<<(i-1));
        vec.pb(node(i,i+1,val));
    }
    int now=(1LL<<cur);
    int baki=x-(now-1);
    int n=cur+1;
    while(1)
    {
        for(int i=n-1;i>=1;i--)
        {
            int rgt=now+(1LL<<(i-1))-1;
            if(rgt<=x)
            {
               vec.pb(node(i,n,now));
               now=rgt+1;
               break;
            }
        }
        if(now>x)break;
    }
    cout<<cur+1<<" "<<vec.size()<<endl;
    for(auto z:vec)
    {
        cout<<z.fi.fi<<" "<<z.fi.si<<" "<<z.si<<endl;
    }
    return 0;

}





































Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> s(M), c(M);
  REP(i, M) cin >> s[i] >> c[i];
  REP(i, 1000) {
    int a = i;
    string S = to_string(i);
    if (S.size() != N) continue;
    bool t = true;
    REP(j, M) {
      if (s[j] > S.size()) {
        t = false;
        break;
      }
      if (S[s[j] - 1]-'0' != c[j]) {
        t = false;
        break;
      }
    }
    if (!t) continue;
    cout << i << endl;
    return 0;
  }
  cout << -1 << endl;
}

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

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

  vll a(n);
  for (ll i = 0; i < n; i++) cin >> a[i];
  sort(all(a));

  priority_queue<ll> b;
  for (ll i = 0; i < n - 1; i++) {
    if (a[i] == a[i + 1]) {
      b.push(a[i]);
      i++;
    }
  }

  if (b.size() < 2) cout << 0 << endl;
  else {
    ll c = b.top();
    b.pop();
    cout << c * b.top() << endl;
  }
}

Measured memory_bytes: 1660
#include<stdio.h>
int main(){
   
   int h[100]={0};
   int w[100]={0};
   int i,j,k;
   int a=0;
   
   while(1){
      
      for(i=0;i<100;i++){
         scanf("%d",&h[i]);
         scanf("%d",&w[i]);
         a++;
   
         if(h[i]==0 && w[i]==0) break;
      }
      
      for(i=0;i<a-1;i++){
         for(j=0;j<h[i];j++){
            for(k=0;k<w[i];k++){
               printf("#");
            }
            printf("\n");
         }
         printf("\n");
      }
      
      break;
   }
   
   return 0;
}


Measured memory_bytes: 1924
/*input
3 5
5
1 2 3 4 5
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=105;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
vector<pii> v;
int g[maxn][maxn];
int main()
{
	IOS;
	int n,m;
	cin>>n>>m;
	REP(i,n){
		if(i%2) REP(j,m) v.pb(MP(i,j));
		else for(int j=m-1;j>=0;j--) v.pb(MP(i,j));
	}
	int q;
	cin>>q;
	int pt=0;
	for(int i=1;i<=q;i++){
		int cnt;cin>>cnt;
		while(cnt){
			g[v[pt].F][v[pt].S]=i;
			cnt--;
			pt++;
		}
	}
	REP(i,n) REP(j,m) cout<<g[i][j]<<" \n"[j==m-1];
}



Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    sc.nextLine();

    int acCnt = 0;
    int waCnt = 0;
    int tleCnt = 0;
    int reCnt = 0;

    for(int i = 0;i<n;i++) {
      switch(sc.nextLine()) {
        case "AC":
          acCnt++;
          break;
        case "WA":
          waCnt++;
          break;
        case "TLE":
          tleCnt++;
          break;
        case "RE":
          reCnt++;
          break;
      }
    }
    sc.close();

    System.out.println("AC x  " + acCnt);
    System.out.println("WA x  " + waCnt);
    System.out.println("TLE x  " + tleCnt);
    System.out.println("RE x  " + reCnt);

  }

}


Measured memory_bytes: 60168
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
int main() {
  int n;
  ll ans=0;
  cin>>n;
  for(int i=1;i<=n;i++){
    for(int j=1;i*j<=n;j++){
      ans+=i*j;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 3540
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int m = (int)((double)n /1.08);
    bool f = false;
    for(int i = m; i<m+2; i++){
        if((int)(1.08*i) == n){
            cout << i << endl;
            f = true;
            break;
        }
    }
    if(f == false)
        cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int f = 0;
		String ns = String.valueOf(n);
		for(int i=0; i<ns.length(); i++){
			f += Character.getNumericValue(ns.charAt(i));
		}
		System.out.println(n%f==0 ? "Yes" : "No");
	}
}

Measured memory_bytes: 21460
#include<iostream>
#include<algorithm>
#define int long long
using namespace std;
int a[1010], n, m, p, ans;
signed main() {
	while (cin >> n >> m, n) {
		for (int j = 1; j <= n; j++)a[j] = 0; ans = 0;
		for (int i = 1; i <= m; i++) {
			for (int j = 1; j <= n; j++) {
				cin >> p; a[j] += p;
				if (i == m)ans = max(ans, a[j]);
			}
		}cout << ans << endl;
	}
}


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

import math

def is_prime(n):
  n_=math.floor(n**0.5)
  for i in range(2,n_):
    if n%i==0:
      return False
  return True

for k in range(n,200000):
  if is_prime(k)==True:
    print(k)
    break

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }

bool visited[10010];
vector<vector<int>> g;
stack<int> st;

void topological_sort(int i) {
    visited[i] = true;
    for (int j: g[i]) {
        if (!visited[j]) topological_sort(j);
    }
    st.push(i);
}

int main() {
    int V, E; cin >> V >> E;
    g.resize(V);
    rep(i, E) {
        int u, v; cin >> u >> v;
        g[u].pb(v);
    }

    rep(i, V) {
        if (!visited[i]) topological_sort(i);
    }

    while (!st.empty()) {
        cout << st.top() << endl;
        st.pop();
    }
}



Measured memory_bytes: 3568
#include <cstdio>
#include <cstring>

#include <algorithm>

#define MAX_LEN 20000

char buffer[MAX_LEN + 1];
int heights[MAX_LEN + 1];

int from_left[MAX_LEN + 1];
int from_right[MAX_LEN + 1];

int water_count = 0;
int waters[MAX_LEN + 1];

int get_diff(int pos){
	return (buffer[pos] == '/' ? 1 : buffer[pos] == '_' ? 0 : -1);
}

void bottom_up(int* array, int len){
	int array_min = 0;
	
	for(int pos = 0; pos < len; pos++){
		array_min = std::min(array_min, array[pos]); 
	}
	for(int pos = 0; pos < len; pos++){
		array[pos] -= array_min;
	}
}

int main(int argc, char* argv[]){
	std::scanf("%s", buffer);
	const int len = std::strlen(buffer);
	
	for(int pos = 0; pos < len; pos++){
		heights[pos + 1] += heights[pos] + get_diff(pos);
	}
	
	bottom_up(heights,  len + 1);
	for(int i = 0; i <= len; i++){
		from_left[i] = std::max((i == 0 ? 0 : from_left[i - 1]), heights[i]);
	}
	for(int i = len; i >= 0; i--){
		from_right[i] = std::max((i == len ? 0 : from_right[i + 1]), heights[i]);
	}

	int sum = 0;
	
	for(int i = 1, prev_height = 0; i <= len; i++){
		const int h = std::min(from_left[i], from_right[i]) - heights[i];
		if(h > 0){ waters[water_count] += h; sum += h; }

		if(prev_height != 0 && h == 0){
			water_count++;
		}

		prev_height = h;
		
		//std::printf("%d", std::min(from_left[i], from_right[i]) - heights[i]);
	}

	std::printf("%d\n", sum);
	std::printf("%d", water_count);
	for(int i = 0; i < water_count; i++){
		std::printf(" %d", waters[i]);
	}
	std::printf("\n");

	return 0;
}

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

int main(){
	int a,b;
	cin >> a >> b;
	if(b==1) cout << "0" << endl;
	else if(a>=b) cout << "1" << endl;
	else {
		b -= a;
		a--;
		if(b%a==0) cout << b/a+1 << endl;
		else cout << b/a+2 << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;
template<class T>void sort(vec<T> &v){sort(v.begin(),v.end());}
template<class T>void rsort(vec<T> &v){sort(v.rbegin(),v.rend());}
const ll mod = 1e9+7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k; cin >> n >> k;
    vec<ll> c(n);
    rep(i,k){
        ll d; cin >> d;
        rep(j,d){
            ll a; cin >> a; --a;
            ++c[a];
        }
    }
    ll ans = 0;
    rep(i,n)if(c[i] == 0)ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <string.h>

int main(void) {
	int i,j,n,req,tmp;
	int c[101],p[101],rank[100];
	
	i = 0;
	while(1){
		scanf("%d,%d",&c[i],&p[i]);
		if(c[i] == 0 && p[i] == 0) break;
		i++;
	}
	n = i;
	
	memset(rank,0,sizeof(rank));
	
	for(i = 0;i < n-1;i++){
		for(j = i;j < n;j++){
			if(p[i] < p[j]){
				p[i] ^= p[j] ^= p[i] ^= p[j];
				c[i] ^= c[j] ^= c[i] ^= c[j];
			}
		}
	}
	
	rank[0] = 1;
	tmp = 0;
	for(i = 1;i < n;i++){
		if(p[tmp] == p[i]){
			rank[i] = rank[tmp];
		}else{
			rank[i] = rank[tmp]+1;
			tmp = i;
		}
	}
	
	while(~scanf("%d",&req)){
		for(i = 0;i < n;i++){
			if(c[i] == req){
				printf("%d\n",rank[i]);
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 596
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
 
/*
javac Main.java
java Main
*/
 
class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        System.out.println((a*b) + " " + (2*(a + b)));
    }
}


Measured memory_bytes: 26252
#include <stdio.h>

int main()
{
  int i,n,k,h;
  int ans=0;
  scanf("%d%d", &n,&k);
  for (i = 0; i < n; i++) {
    scanf("%d", &h);
    if(h>=k) ans++;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

struct UnionFind{
    std::vector<int> data;

    UnionFind(int size):
        data(size, -1){}

    void init() {
        fill(data.begin(), data.end(), -1);
    }

    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }

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

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y) return false;

        if(data[y] < data[x]) std::swap(x, y); // yの方が気が深いなら交換
        data[x] += data[y];
        data[y] = x;

        return true;
    }

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> X(M), Y(M), Z(M);
    for(int i = 0; i < M; i++) {
        cin >> X[i] >> Y[i] >> Z[i];
        X[i]--, Y[i]--;
    }

    UnionFind uf(N);
    for(int i = 0; i < M; i++) {
        uf.unite(X[i], Y[i]);
    }

    set<int> s;
    for(int i = 0; i < N; i++) {
        s.insert(uf.root(i));
    }

    cout << s.size() << endl;

    return 0;
}

Measured memory_bytes: 6400
#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;

void Main(){
  int a,b,c;
  cin>>a>>b>>c;
  int k,sum;
  cin>>k;
  (a>b && a>c) ? sum=a*pow(2,k)+b+c : (b>a && b>c) ? sum=a+b*pow(2,k)+c : sum=a+b+c*pow(2,k);
  cout<<sum<<endl;
}

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  Main();
}

Measured memory_bytes: 256
"use strict";

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }

function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

function main(input) {
  var lines = input.split('\n');
  var N = parseInt(lines[0]);

  var _splitNum = splitNum(lines[1]),
      _splitNum2 = _slicedToArray(_splitNum, 2),
      A = _splitNum2[0],
      B = _splitNum2[1];

  var ps = splitNum(lines[2]).slice(0, N);
  var ac = 0,
      bc = 0,
      cc = 0;
  var _iteratorNormalCompletion = true;
  var _didIteratorError = false;
  var _iteratorError = undefined;

  try {
    for (var _iterator = ps[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
      var p = _step.value;

      if (p <= A) {
        ac++;
      } else if (p <= B) {
        bc++;
      } else {
        cc++;
      }
    }
  } catch (err) {
    _didIteratorError = true;
    _iteratorError = err;
  } finally {
    try {
      if (!_iteratorNormalCompletion && _iterator.return != null) {
        _iterator.return();
      }
    } finally {
      if (_didIteratorError) {
        throw _iteratorError;
      }
    }
  }

  console.log(Math.min(ac, bc, cc));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function splitNum(line) {
  return line.split(/\s+/).map(function (n) {
    return parseInt(n);
  });
}


Measured memory_bytes: 21064
#include<iostream>
using namespace std;
int main(){
	long long int n;
	cin>>n;
	long long int a[n];
	long long  int x = 0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		x^=a[i];
	}
	for(auto i : a){
		cout<<(x^i)<<" ";
	}
	return 0;
}

Measured memory_bytes: 4980
#include<stdio.h>
int main(void){
  int c1,c5,c10,c50,c100,c500,sum;
  scanf("%d",&c1);
  scanf("%d",&c5);
  scanf("%d",&c10);
  scanf("%d",&c50);
  scanf("%d",&c100);
  scanf("%d",&c500);

  sum=c1*1+c5*5+c10*10+c50*50+c100*100+c500*500;

  if(sum>=1000)
    printf("1\n");

  else
    printf("0\n");

  return 0;
}

Measured memory_bytes: 584