akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(s: chars);
    let mut apos = vec![];
    let mut bc = vec![];
    let mut pres = vec![false];
    for i in 0..s.len() {
        if s[i] == 'A' {
            apos.push(bc.len());
            pres[bc.len()] = true;
        } else {
            bc.push(s[i]);
            pres.push(false);
        }
    }
    let n = bc.len();
    if n == 0 {
        puts!("0\n");
        return;
    }
    let mut dp = vec![0i64; n + 1];
    dp[n] = 0;
    for i in (0..n - 1).rev() {
        if bc[i] == 'B' && bc[i + 1] == 'C' && !pres[i + 1] {
            dp[i] = dp[i + 2] + 1;
        }
    }
    let mut tot: i64 = 0;
    for &p in &apos {
        tot += dp[p];
    }
    puts!("{}\n", tot);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

int area(int d){
    int x, y, sum, i;
    x = 600;
    y = d * d;
    sum = 0;
    i = 1;
    while(d * i <= 600 - d){
        sum += y * d;
        i++;
        y = (d * i) * (d * i);
    }
    return sum;
}

int main(void){
    int d;
    while(cin >> d) {
       cout << area(d) << endl;
    }
    return 0;
    
}



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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

const int N = 1e5+5;

int n, m;
vector<int> al[N];
int down[N], up[N];

void dfs1(int u, int p) {
    down[u] = 1;
    FOR(i,0,SZ(al[u])-1) {
        int v = al[u][i];
        if (v == p) continue;

        dfs1(v, u);
        down[u] = (int) (((ll)down[u] * (down[v] + 1)) % m);
    }
    //cout << u << " " << down[u] << endl;
}

void dfs2(int u, int p) {
    //cout << u << " " << up[u] << endl;

    ll prod = 1;
    FOR(i,0,SZ(al[u])-1) {
        int v = al[u][i];
        if (v == p) continue;

        up[v] = (int) (((ll)prod * up[u]) % m);
        prod = (int) (((ll)prod * (down[v] + 1)) % m);
        //cout << '\t' << i << " " << prod << endl;
    }

    prod = 1;
    RFOR(i,SZ(al[u])-1,0) {
        int v = al[u][i];
        if (v == p) continue;

        up[v] = (int) ( ((ll)up[v] * prod + 1) % m);
        prod = (int) (((ll)prod * (down[v] + 1)) % m);

        dfs2(v,u);
    }
}

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> m;
    FOR(i,1,n-1){
        int x, y; cin >> x >> y;
        al[x].pb(y);
        al[y].pb(x);
    }

    dfs1(1,0);
    up[1] = 1;
    dfs2(1,0);

    FOR(i,1,n){
        cout << ((ll)up[i] * down[i]) % m << '\n';
    }
}



Measured memory_bytes: 13056
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
    long long x;
    mint(long long x=0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n, k;
    cin >> n >> k;
    mint ans = 0;
    for (ll i = k; i <= n+1; ++i) {
        ans += i * (n - i + 1) + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int D = scan.nextInt();
		int b = N;
		int count=0;
		for(int i=1;b>0;i++) {
			if(i-D>=0) {
				b = b - ((i+D)-(i-D)+1);
				count++;
			}
		}
		System.out.println(count);
	}

}

Measured memory_bytes: 21844
#include <stdio.h>

int main(void)
{
    int a,b,c,t,i;
    scanf("%d%d%d",&a,&b,&c);
    t=a;
    for(i=1;i<b;i++){
        if(t%b==c)break;
        t+=a;
    }
    if(i==b)puts("NO");
    else puts("YES");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    const int mod=1000000007;
    int k,n;
    cin>>k>>n;
    vector<int>v;
    map<int,int>inv;
    for(int i=1;i<k;i=k/(k/(i+1))){
        inv[i]=v.size();
        v.push_back(i);
    }
    inv[k]=v.size();
    v.push_back(k);
    int x=v.size();
    vector<vector<long long>>dp(n+1,vector<long long>(x));
    dp[0][0]=1;
    vector<long long>wa(x,1);
    for(int i=1;i<=n;i++){
        for(int j=0;j<x;j++){
            //dp[i][j]=dp[i-1][0]+dp[i-1][1]+...+dp[i-1][inv[k/v[j]]]
            dp[i][j]+=wa[inv[k/v[j]]]%mod;
        }
        wa[0]=dp[i][0]%mod;
        for(int j=1;j<x;j++)wa[j]=(wa[j-1]+dp[i][j]*(v[j]-v[j-1]))%mod;
    }
    cout<<wa[x-1]<<endl;
    return 0;
}

Measured memory_bytes: 56964
n= int(input())
ab=[list(map(int,input().split())) for i in range(n)]
ans=0
for i in range(n-1,-1,-1):
    ab[i][0]+=ans
    if ab[i][0]%ab[i][1]!=0:
        ans+=ab[i][1]-(ab[i][0]%ab[i][1])
print(ans)


Measured memory_bytes: 31348
for(c=a=[],m=l=n=j=0;i=require("fs").readFileSync("/dev/stdin","utf8").split(/\s/)[j++];)a[i]?++a[i]>m?m=a[n=i]:0:a[i]=1,i.length>c.length?c=i:0;console.log(n+' '+c)

Measured memory_bytes: 9032
#include <iostream>

int main(){
	int n,nums[100];
	std::cin >> n;
	for(int i=0;i<n;i++){
		std::cin >> nums[i];
	}
	unsigned long long int dp[100][21] = {0};
	dp[0][nums[0]] = 1;
	for(int j=1;j<n-1;j++){
		for(int k=0;k<21;k++){
			if(dp[j-1][k] > 0){
				if(k+nums[j] <= 20)
					dp[j][k+nums[j]] += dp[j-1][k];
				if(k-nums[j] >= 0)
					dp[j][k-nums[j]] += dp[j-1][k];
			}
		}
	}
	std::cout << dp[n-2][nums[n-1]] << std::endl;
}

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

int main() {
  int H,W;
  cin >> H >> W;
  
  vector<char> a(H*W);
  
  //入力
  for(int k=0; k< H*W; k++){
    cin >> a.at(k);        
  }
  
  //出力
  
  for(int k=0; k<W+2;k++){
    cout << "#";
  }
  cout<< endl; //1行目終わり
  
  for(int i=0;i<H;i++){
    cout << "#";//左端
    
   for(int j=0;j<W;j++){
    cout << a.at(i*W + j);
   }
    
    cout << "#" <<endl;//右端
  } //残り1行
  
  for(int k=0; k<W+2;k++){
    cout << "#";
  }
  cout<< endl; //終わり
  
}

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

int main() {
    int a, ans;
    cin >> a;
    ans = a + a * a + a * a * a;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <algorithm>
#include <functional>
#include <utility>
#include <tuple>
#include <ctime>
#include <cmath>
#include <fstream>
#include <sstream>
using namespace std;
#define INF 1000000007
#define PB push_back
#define MP make_pair
#define X first
#define Y second

typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<char> VC;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef queue<int> QI;
typedef queue<PII> QII;
typedef map<int,int> MII;
typedef map<string,int> MSI;
typedef set<int> SI;
typedef set<PII> SII;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(0);
	int N,K;
	cin >> N >> K;
	if((N-1)%(K-1)==0)
		cout << (N-1)/(K-1) << endl;
	else
		cout << (N-1)/(K-1)+1 << endl;
return 0;
}


Measured memory_bytes: 256
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
		 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
	    public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        int X = sc.nextInt();
	        
	        for(long i=0;i<200;i++) {
	        	for(long j=-200;j<200;j++) {
	        		if(i*i*i*i*i-j*j*j*j*j==X) {
	        	        System.out.print(i);
	        	        System.out.print(" ");
	        	        System.out.println(j);	
	        	        return;
	        		}
	        	}
	        }
	        
	        
	    }
	}

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

int main(){
  int a,b,c,d,n;
  cin >> n;
  
  a = n/1000;
  b = (n - a*1000)/100;
  c = (n - a*1000 - b*100)/10;
  d = n - a*1000 - b*100 - c*10;
  
  if(a == b && b == c){
    cout << "Yes" << endl;
  }else if (b == c && c == d){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
// Last Change: 07/12/2019 03:47:29.
/////////////////////////////////////////////////////////////////////////////
//単一始点最短経路長問題
//以下のプログラムは有向グラフ
/////////////////////////////////////////////////////////////////////////////
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

const ll INF = numeric_limits<ll>::max();

struct Node {
  ll cost;
  ll pos;
  Node(ll a, ll b) : cost(a), pos(b) {
  }
  bool operator<(const Node &another) const {
    return cost < another.cost;
  }
  bool operator>(const Node &another) const {
    return cost > another.cost;
  }
};

int main() {
  // n:頂点数
  ll n;
  cin >> n;
  vector<vector<pair<ll, ll>>> edge(n);
  for (ll i = 0; i < n; ++i) {
    ll u, k, v, c;
    cin >> u >> k;
    for (ll j = 0; j < k; ++j) {
      cin >> v >> c;
      edge[u].push_back(make_pair(v, c));
    }
  }

  vector<ll> dist(n, INF);
  //独自関数ならdecltype(func)?
  priority_queue<Node, vector<Node>, greater<Node>> q;
  ll cnt = 0;
  q.push(Node(0, 0));
  while (cnt < n) {
    Node cur = q.top();
    q.pop();
    if (dist[cur.pos] > cur.cost) {
      dist[cur.pos] = cur.cost;
      ++cnt;
      for (auto &&e : edge[cur.pos]) {
        q.push(Node(cur.cost + e.second, e.first));
      }
    }
  }

  for (ll i = 0; i < n; ++i) {
    cout << i << " " << dist[i] << endl;
  }
}



Measured memory_bytes: 3332
#include <algorithm>
#include <functional>
#include <iostream>
using namespace std;
 
int main() {

  string S;
  string T;

  int Count=0;

  cin >> S;
  cin >> T;

  if (S[0]==T[0]) Count++;
  if (S[1]==T[1]) Count++;
  if (S[2]==T[2]) Count++;

  cout << Count << endl;


  return 0;
}

Measured memory_bytes: 256
abc=sorted(list(map(int,input().split())))
pabc=abc[:]
ans=0
while True:
    if abc[0]%2==1 or abc[1]%2==1 or abc[2]%2==1:
        print(ans)
        exit()
    ans+=1
    abc[0]=pabc[1]//2+pabc[2]//2
    abc[1]=pabc[0]//2+pabc[2]//2
    abc[2]=pabc[0]//2+pabc[1]//2
    abc=sorted(abc)
    if abc[0]==pabc[0] and abc[1]==pabc[1] and abc[2]==pabc[2]:
        print(-1)
        exit()
    pabc=abc[:]

Measured memory_bytes: 3064
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
#include<bits/stdc++.h>
//#include <bits/extc++.h>
#define fi first
#define se second
#define db double
#define mp make_pair
#define pb push_back
#define mt make_tuple
//#define pi acos(-1.0)
#define ll long long
#define vi vector<int>
#define mod 1000000007
#define ld long double
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define ull unsigned long long
#define bpc __builtin_popcount
#define base 1000000000000000000ll
#define fin freopen("a.txt","r",stdin)
#define fout freopen("a.txt","w",stdout)
#define mr mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline void sub(ll &a,ll b){a-=b;if(a<0)a+=mod;}
inline void add(ll &a,ll b){a+=b;if(a>=mod)a-=mod;}
inline ll mul(ll a,ll b,ll c){return (a*b-(ll)((ld)a*b/c)*c+c)%c;}
inline ll qp(ll a,ll b){ll ans=1;while(b){if(b&1)ans=ans*a%mod;a=a*a%mod,b>>=1;}return ans;}
inline ll qp(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=mul(ans,a,c);a=mul(a,a,c),b>>=1;}return ans;}

using namespace std;
//using namespace __gnu_pbds;

const ld pi = acos(-1);
const ull ba=233;
const db eps=1e-8;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int N=200+10,maxn=1000000+10,inf=0x3f3f3f3f;

int a[N][N],co[N],n;
void dfs(int u)
{
    for(int i=1;i<=n;i++)if(a[u][i])
    {
        if(!co[i])co[i]=3-co[u],dfs(i);
        else if(co[i]+co[u]!=3)
        {
            puts("-1");
            exit(0);
        }
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)
        scanf("%1d",&a[i][j]);
    co[1]=1;dfs(1);
    for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)
        if(!a[i][j])a[i][j]=inf;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            for(int k=1;k<=n;k++)
                a[j][k]=min(a[j][k],a[j][i]+a[i][k]);
    int ma=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            if(a[i][j]!=inf&&i!=j)
                ma=max(ma,a[i][j]);
    printf("%d\n",ma+1);
    return 0;
}
/********************

********************/


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp

signed main(){
	const double pi = 3.141592653589793;
	long double a,b,h,m; cin>>a>>b>>h>>m;
	long double k=m*6;
	//cout<<k<<endl;
	long double l=(30*h)+(0.5*m);
	//cout<<l<<endl;
	if(k==l){
		cout<<max(a,b)-min(a,b);
		return 0;
	}
	if(k==0 && l>=30) k=360;
	if(l==0 && k>=30) l=360;
	long double ang=max(k,l)-min(k,l);
	if(ang==180){
		cout<<a+b;
		return 0;
	}
	//cout<<ang<<endl;
	long double c=cos(pi/(180/ang));
	//cout<<c<<endl;
	long double a2=a*a;
	long double b2=b*b;
	long double ans=a2+b2-(2*a*b*c);
	cout << fixed << setprecision(15);
	cout<<sqrt(ans);
	
	return 0;
}


Measured memory_bytes: 4136
#include<bits/stdc++.h>
#include<string.h>
#define pb push_back
#define all(v) v.begin(),v.end()
#define see(x) cout<<#x<<" : "<<x<<endl;
#define ya cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
typedef long long ll;
using namespace std;
double h,c,t;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    //freopen("test.txt","r",stdin);
    int h1,h2,m1,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int a=h1*60+m1,b=h2*60+m2;
    int c=b-a;
    cout<<c-k<<endl;
    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#define N 100
int main(void){
  int i,j,v,n,m,x,t;
  int a[N];
  scanf("%d",&n);
  m=0;
  while(m<n){
    scanf("%d",&a[m]);
    m++;
  }
  i=1;
  while(i<n){
    for(v=0;v<n-1;v++){
      printf("%d ",a[v]);
    }
    printf("%d\n",a[n-1]);
    t=a[i];
    j=i;
    i++;
    while(j>0&&a[j-1]>t){
      a[j]=a[j-1];
      j--;
    }
    a[j]=t;
  }
  x=0;
  while(x<n-1){
    printf("%d ",a[x]);
    x++;
  }
  printf("%d\n",a[n-1]);
  return 0;
}


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

using namespace std;
int main() {
    int x, y, z;
    int num;
    int rem;

    cin >> x >> y >> z;

    num = 1;
    rem = x - (y + 2*z);

    for (;;) {
        rem -= y + z;
        if (rem >= 0) {
            num++;
        } else {
            break;
        }
    }


    cout << num << endl;
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    public static void Main()
    {
        int N = NextInt();
        int A = NextInt();
        int B = NextInt();
        int C = NextInt();
        int[] l = new int[N];
        for (int i = 0; i < N; i++) { l[i] = NextInt(); }

        int M = (int)Math.Pow(4, N);
        int min_cost = INF;
        for (int n = 0; n < M; n++)
        {
            int num = n;
            string bit = "";
            while (num != 0)
            {
                bit = (num % 4).ToString() + bit;
                num /= 4;
            }
            bit = bit.PadLeft(N, '0');
            int cost = 0;
            int A_l = A, A_c = -1;
            int B_l = B, B_c = -1;
            int C_l = C, C_c = -1;
            for (int i = 0; i < N; i++)
            {
                char c = bit[i];
                if (c == '0')
                {
                    //使わない
                }
                else if (c == '1')
                {
                    //Aで使う
                    A_c++;
                    A_l -= l[i];
                }
                else if (c == '2')
                {
                    //B
                    B_c++;
                    B_l -= l[i];
                }
                else if (c == '3')
                {
                    //C
                    C_c++;
                    C_l -= l[i];
                }
            }
            if (A_c == -1 || B_c == -1 || C_c == -1) continue;
            cost += Math.Abs(A_l) + Math.Abs(B_l) + Math.Abs(C_l)
                + A_c * 10 + B_c * 10 + C_c * 10;
            min_cost = Math.Min(min_cost, cost);
        }
        Console.WriteLine(min_cost);
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

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

int main(){

string str;
cin >> str;

int answer = 0;

for(int i = str.length()-1;i > 0;i--){

int a = (i/2)-1;
int j = i-1;

while(i % 2 == 0){

if(str[a] == str[j]){
if(a == 0) {
answer = i;
break;
}

else {
a--;
j--;
}

}

else{
break;
}

}

if(answer != 0){
break;
}

}

cout << answer << endl;

return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int N, P[200010], i, min, count;

	scanf("%d", &N);
	for(i = 1; i <= N; i++) {
		scanf("%d", &P[i]);
	}

	min = P[1];		count = 1;

	for(i = 2; i <= N; i++) 
		if (min > P[i]) {
			min = P[i]; count++;
		}
	
	printf("%d", count);
	
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    private static int n;
    private static int q;
    private static int[] id;
    private static int[] sz;

    private static boolean find(int x, int y) {
        return root(x) == root(y);
    }

    private static void union(int x, int y) {
        int i = root(x);
        int j = root(y);

        if (i == j)
            return;
        if (sz[i] > sz[j]){
            id[j] = id[i];
            sz[i] += sz[j];
            sz[j] = 0;
        }
        else {
            id[i] = id[j];
            sz[j] += sz[i];
            sz[i] = 0;
        }
    }

    private static int root(int i) {
        while (i != id[i]){
            id[i] = id[id[i]];
            i = id[i];
        }
        return i;
    }

    private static void init() {
        id = new int[n];
        sz = new int[n];

        for (int i = 0; i < n; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }


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

        init();
        for (int i = 0; i < q; i++) {
            int com = scanner.nextInt();
            int x = scanner.nextInt();
            int y = scanner.nextInt();

            if (com == 0){
                union(x, y);
            }
            if (com == 1){
                if (find(x, y))
                    System.out.println(1);
                else
                    System.out.println(0);
            }

        }

    }
}

Measured memory_bytes: 98484
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        Integer[] list = new Integer[3];
        for(int i = 0;i < 3;i ++) list[i] = scanner.nextInt();
        Arrays.sort(list, Collections.reverseOrder());
        int a = list[0] * 10;
        int b = list[1];
        int c = list[2];
        System.out.println(a + b + c);
    }
}

Measured memory_bytes: 20948
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	inputs := scanIntNums()
	H := inputs[0]
	A := inputs[1]

	t := H / A
	if A*t >= H {
		fmt.Println(t)
	} else {
		fmt.Println(t + 1)
	}
}

func scanIntNums() (nums []int) {
	sc.Scan()
	numString := strings.Split(sc.Text(), " ")

	nums = make([]int, len(numString))
	var err error

	for i := 0; i < len(nums); i++ {
		nums[i], err = strconv.Atoi(numString[i])
		if err != nil {
			panic(err)
		}
	}
	return nums
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair
using namespace std;
int mod = 1e9+7;
int inf = 1e18;
const int N = 5e5+999;
int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
       string s,t;
       cin>>s>>t;
       int a,b;
       cin>>a>>b;
       string u;
       cin>>u;
       if(u==s)
        a--;
       else
        b--;
       cout<<a<<" "<<b<<el;

    }
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
string int2string(int x){
        stringstream ss;
        ss << x;
        string tmp;
        ss >> tmp;
        return tmp;
    }
int string2int(string s){
    stringstream ss;
    ss << s;
    int x;
    ss >> x;
    return x;
}
long long power(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
long long bigpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    else return gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
    ll r= a/gcd(a,b)*b;
    return r;
}
//***********************CODE*****************
int main(){
    
cin.tie(NULL);
cout.tie(NULL);
ios_base::sync_with_stdio(false);
	string s;
	cin>>s;
	int q;
	cin>>q;
	bool flag=0;
	while(q--)
	{
		int t;
		cin>>t;
		if(t==1)
			flag=!flag;
		else
		{
			int fi;
			char c;
			cin>>fi>>c;
			if(flag==0)
			{
				if(fi==1)
				{
					s.insert(s.begin(),c);
				}
				else
					s.push_back(c);
			}
			else
			{
				if(fi==2)
				{
					s.insert(s.begin(),c);
				}
				else
					s.push_back(c);
			}
		}	
	}
	if(flag==1)
	{
		reverse(s.begin(),s.end());
	}
	cout<<s<<endl;    return 0;
}

Measured memory_bytes: 912
n, k = [int(x) for x in input().split()]
hs = []
for _ in range(n):
  hs.append(int(input()))
hs.sort()

min_diff = 10**9 + 1

for i in range(n - k + 1):
  x = hs[i+k-1] - hs[i]
  if x < min_diff:
    min_diff = x

print(min_diff)


Measured memory_bytes: 7384
n, w = list(map(int,input().split()))
things=[]
for i in range(n):
    thing = list(map(int, input().split()))
    things.append(thing)

#print(n, w)
#print(things)
#n=6
#w=8
#things = [[2,3],[1,2],[3,6],[2,1],[1,3],[5,85]]

dp = [[0 for _ in range(w+1)] for _ in range(n+1)]

#for i in range(n+1):
#    for j in range(w+1):
#        dp[i][j]=0

for i in range(n):
    for j in range(w+1):
        if things[i][1] <= j:
            dp[i+1][j] = max(dp[i][j-things[i][1]]+things[i][0],dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]

print(dp[n][w])


Measured memory_bytes: 42468
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int A,B,C,X,Y,a,b,c,d,e,ans;
    cin>>A>>B>>C>>X>>Y;
    a=A*X+B*Y;
    b=max(X,Y)*2*C;
    ans=min(a,b);
    c=min(X,Y)*C*2;
    if(X<Y){
        d=(Y-X)*B;
        c=c+d;
    }else{
        e=(X-Y)*A;
        c=c+e;
    }
    cout<<min(ans,c)<<endl;
    
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	void run() {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			Set<String> set = new HashSet<String>();
			for (int i = 0; i < n; i++) {
				set.add(sc.next());
			}

			System.out.println(set.size());
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

}


Measured memory_bytes: 78664
n = int(input())
a = list(map(int, input().split()))

table = [0 for i in range(10**6 + 1)]
ans = 0
a.sort()
a.append(10**7)
for i in range(n):
    el = a[i]
    if table[el] != 0:
        continue
    else:
        if el != a[i + 1]:
            ans += 1
    idx = el
    while idx <= 10**6:
        table[idx] += 1
        idx += el

print(ans)

Measured memory_bytes: 32368
#include<bits/stdc++.h>
using namespace std;
int n,p[23],ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&p[i]);
	for(int i=2;i<n;i++){
		if(p[i]>p[i-1]&&p[i]<p[i+1]||p[i]<p[i-1]&&p[i]>p[i+1])ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
	int ret, a, b, h, m;
	double len;
	double x,y;
	double hour,min;
	double angleA, angleB, diff;
	
	ret = scanf("%d %d %d %d", &a, &b, &h, &m);

	hour = h+(double)m/60.0;
	min  = (double)m/60.0;

	angleA = hour/12.0*360.0/180.0*M_PI;
	angleB = min/1.0*360.0/180.0*M_PI;
	diff = (angleA < angleB )?angleB - angleA: angleA - angleB;
	x = (double)b*cos(diff);
	y = (double)b*sin(diff);
	len = sqrt( (x - a)*(x-a) + y*y);
	printf("%20.16lf\n",len);
	fflush(stdout);
	return EXIT_SUCCESS;
}

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

int main()
{
    int a[3];
    char s[1000];
    cin  >> a[0] >> a[1] >> a[2];
    cout << a[0]+a[1]+a[2]+*max_element(a,a+3)*9 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;
import java.util.AbstractMap.SimpleEntry;

public class Main {

    static final int modnum = 1000000000 + 7;

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

        boolean[] stair = new boolean[N+5];
        int[] dp = new int[N+5];

        for (int i = 0; i < M; i++) {
            int broken = sc.nextInt();
            stair[broken] = true;
        }
        dp[1] = stair[1] ? 0 : 1;
        dp[2] = stair[2] ? 0 : dp[1]+1;
        for (int i = 3; i <= N; i++) {
            dp[i] = stair[i] ? 0: (dp[i-1]+dp[i-2])%modnum;
        }
        System.out.println(dp[N]);
        // for (int i = 0; i < N; i++) {
        //     System.out.println(stair[i]);
        // }
    }
}

Measured memory_bytes: 52752
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        int count = 0;
        for(int i = 0; i < N-2; i++) {
            if(S.substring(i, i+3).equals("ABC")) {
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 21844
eval'K,*X='+`dd`.split*?,
j=l=1
x,y,*s=X.map &:abs
d=x+y
x,y=y,x if f=x<y
K%2-d%2<0&&p(-1)+exit
d!=K&&(l+=[~-d/K,1].max
l+=1&d-K*l
v=K>(t=K*l-d>>1)?0:t-t=K
a=K-t
2.upto(l){s<<(u=f ?-t:a)<<a-t-u
a+=q=[x+v-a,K].min
t-=K-q})
p l,*s.map{_1.*X[j^=1]<=>0.1}+X

Measured memory_bytes: 29876
#include<stack>
#include<cstdio>
inline int in();
inline void wr(int);
const int N=(int)1e5+5;
int ju[N][N/100],_in[N],sum[N];
inline int dfs(int);
inline int mx(int,int);
int main(int argc,char**argv){
	register int n=in(),m=in();
	for(register int i=1;i<=m;++i){
		register int u=in(),v=in();
		ju[u][++ju[u][0]]=v,++_in[v];
	}
	register int ans=0;
	for(register int i=1;i<=n;++i)
		ans=mx(ans,dfs(i));
	wr(ans);
}
inline int dfs(int u){
	if(sum[u])return sum[u];
	for(register int i=1;i<=ju[u][0];++i)
		sum[u]=mx(sum[u],dfs(ju[u][i])+1);
	return sum[u];
}
inline int mx(int x,int y){
	return x>y?x:y;
}
inline int in(){
	register char c=getchar();
	register int x=0,f=1;
	for(;c<'0'||c>'9';c=getchar())
		if(c=='-')f=-1;
	for(;c>='0'&&c<='9';c=getchar())
		x=(x<<1)+(x<<3)+(c&15);
	return x*f;
}
inline void wr(int x){
	if(x<0)putchar('-'),x=-x;
	if(x/10)wr(x/10);
	putchar(x%10+'0');
}

Measured memory_bytes: 392960
#include<stdio.h>
#include<math.h>
int min(int a, int b)
{
    if (a < b)
        return a;
    else
        return b;
}
int main()
{
    int n;
    scanf("%d", &n);
    int i;
    int h[100005];
    for (i = 0; i < n; i++)
        scanf("%d", &h[i]);
    int dp[100005];
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    for (i = 2; i < n; i++)
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    printf("%d\n", dp[n - 1]);
    return 0;
}

Measured memory_bytes: 896
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using namespace std;

using ll = long long;

  
struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int N, M;
int p[100010];
std::map<int, int> vs[100010];

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

  rep( i, N )
    scanf( "%d", p+i ), --p[i];

  UnionFind uf( N+10 );

  rep( i, M )
  {
    int x, y;
    scanf( "%d%d", &x, &y );
    --x; --y;

    uf.unite( x, y );
  }

  rep( i, N )
  {
    int root = uf.find(i);

    ++vs[root][i];
    ++vs[root][p[i]];
  }

  int ans = 0;

  rep( i, N )
  {
    for( auto it = vs[i].begin(); it != vs[i].end(); ++it ) if( it->second >= 2 )
      ++ans;
  }

  printf( "%d\n", ans );

  return 0;
}

Measured memory_bytes: 15104
def solve():
  S=input()
  K=int(input())
  if len(S)==1:
    return K//2
  count=1
  L=[]
  for i in range(len(S)):
      try:
          if S[i] == S[i+1]:
             count = count + 1
          else:
              L.append(count)
              count = 1
      except:
          # 最後の文字セットがOutOfRangeになるので結果に出力
          L.append(count)

  if S[-1]==S[1]:
    flag=0
    if len(L)==1:
      return len(S)*K//2
    else:
      if L[-1]%2==1 and L[0]%2==1:
        flag=1
      L[0]=(L[0]+L[-1])//2*2
      L[-1]=0
    return sum([x//2 for x in L])*K-flag
  else:
    return sum([x//2 for x in L])*K

print(solve())


Measured memory_bytes: 38256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        aa: [u32;n]
    }
    let mut s = aa.clone();
    s.sort();
    s.reverse();
    let m1 = s[0];
    let m2 = s[1];
    for a in aa {
        if a == m1 {
            println!("{}", m2);
        } else {
            println!("{}", m1);
        }
    }
}


Measured memory_bytes: 9724
s = gets.chomp
if s.count("S") > 0 && s.count("N") == 0
  puts :No
elsif s.count("N") > 0 && s.count("S") == 0
  puts :No
elsif s.count("W") > 0 && s.count("E") == 0
  puts :No
elsif s.count("E") > 0 && s.count("W") == 0
  puts :No
else
  puts :Yes
end

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

vector<string> F;
vector<int> adj[200];
int dist[200], depth[200];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, ans=0, c;
	queue<int> Q;
	cin>>N; F.resize(N);
	for(int i=0;i<N;i++) {
		cin>>F[i];
		for(int j=0;j<N;j++) if(F[i][j]=='1') adj[i].push_back(j);
	}
	for(int i=0;i<N && ans>=0;i++) {
		memset(dist,0x7f,sizeof(dist));
		dist[i]=1;
		Q.push(i);
		while(!Q.empty()) {
			c=Q.front();
			Q.pop();
			for(auto n: adj[c]) {
				if(dist[n]>dist[c]+1) {
					dist[n]=dist[c]+1;
					Q.push(n);
				}
				else if(abs(dist[n]-dist[c])!=1) {
					ans=-1;
					while(!Q.empty()) Q.pop();
					break;
				}
			}
		}
		if(ans==-1) break;
		ans=max(ans,dist[c]);
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 512
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

l = I()
print(l*l*l/27)

Measured memory_bytes: 63468
#include<map>
#include<cmath>
#include<stack>
#include<cstdio>
#include<queue>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int n,m,a[55],ans;
bool cmp(int x,int y){
	return x>y;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=m;i++)ans+=a[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
if (a>0 and b<=0) or (a<=0 and b>0):
  print("Zero")
  exit()
if a>0:
  print("Positive")
  exit()
if (b-a)%2 == 0:
  print("Negative")
else:
  print("Positive")
  

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

public class Main {
    public static void main (String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder builder = new StringBuilder();
        int i = 1;
        while(true) {
            int data = Integer.parseInt(reader.readLine());
            if(data==0)
                break;
            builder.append("Case ").append(Integer.toString(i++)).append(": ").append(Integer.toString(data)).append("\n");
        }
        System.out.print(builder);
    }
}

Measured memory_bytes: 30964
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}

	vector<int> b(n + 1), ans;
	for (int i = n; i > 0; i--) {
		if (b[i] % 2 != a[i]) {
			ans.emplace_back(i);
			for (int j = 1; j <= sqrt(i); j++) {
				if (i % j == 0) {
					b[j]++;
					if (i / j != j) {
						b[i / j]++;
					}
				}
			}
		}
	}

	cout << ans.size() << endl;
	for (int i = ans.size() - 1; i >= 0; i--) {
		cout << ans[i] << (i != 0 ? " " : "\n");
	}

	return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;}


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

int N, K; cin >> N >> K;
vector<bool> sun(N+1, false);
rep(i, 0, K) {
    int d; cin >> d;
    rep(j, 0, d) {
        int a; cin >> a;
        sun[a] = true;
    }
}


cout << N - accumulate(RANGE(sun, 1, N+1), 0) << "\n";

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 問題文から考える。自分ができることから考える。
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索。逆から考える。
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, N, A;
  cin >> H;
  cin >> N;
  for (int i=0; i < N; i++){
      cin >> A;
      H-=A;
  }
  if (H<=0){
      cout << "Yes" << endl;\
  }
  else{
      cout << "No" << endl;
  }
  }

Measured memory_bytes: 768
// ARC094D.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 2e5 + 200, mod = 998244353;

int n, dp[MAX_N][3][3][2], str[MAX_N];
char org[MAX_N];

int main()
{
    scanf("%s", org + 1), n = strlen(org + 1);
    int oddity = 0, tot[3] = {0, 0, 0};
    bool flag = true;
    for (int i = 1; i <= n; i++)
        str[i] = org[i] - 'a', oddity = (oddity + str[i]) % 3, tot[str[i]]++;
    for (int i = 1; i < n; i++)
        flag &= (str[i] != str[i + 1]);
    if (tot[0] == n || tot[1] == n || tot[2] == n)
        puts("1"), exit(0);
    if (n <= 3)
    {
        map<string, bool> mp;
        string org_str = org + 1;
        mp[org_str] = true;
        int delta = 0;
        do
        {
            delta = 0;
            for (auto x : mp)
                for (int i = 0; i < n - 1; i++)
                    if (x.first[i] != x.first[i + 1])
                    {
                        string nxt = x.first;
                        nxt[i] = nxt[i + 1] = ('a' ^ 'b' ^ 'c') ^ (x.first[i] ^ x.first[i + 1]);
                        if (mp[nxt] == false)
                            mp[nxt] = true, delta++;
                    }
        } while (delta);
        printf("%lld\n", 1LL * mp.size());
    }
    else
    {
        int ans = (flag == true);
        dp[1][0][0][0] = dp[1][1][1][0] = dp[1][2][2][0] = 1;
        for (int i = 2; i <= n; i++)
            for (int sum = 0; sum < 3; sum++)
                for (int pre = 0; pre < 3; pre++)
                    for (int curt = 0; curt < 3; curt++)
                        if (pre == curt)
                            dp[i][(sum + curt) % 3][curt][1] = (0LL + dp[i][(sum + curt) % 3][curt][1] + dp[i - 1][sum][pre][0] + dp[i - 1][sum][pre][1]) % mod;
                        else
                        {
                            dp[i][(sum + curt) % 3][curt][0] = (0LL + dp[i][(sum + curt) % 3][curt][0] + dp[i - 1][sum][pre][0]) % mod;
                            dp[i][(sum + curt) % 3][curt][1] = (0LL + dp[i][(sum + curt) % 3][curt][1] + dp[i - 1][sum][pre][1]) % mod;
                        }
        for (int i = 0; i < 3; i++)
            ans = (0LL + ans + dp[n][oddity][i][1]) % mod;
        printf("%d\n", ans);
    }

    return 0;
}

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

int main()
{
  string s;
  cin >> s;
  
  if (( (s[0] == s[1]) && (s[1] == s[2]) ) || ( (s[1] == s[2]) && (s[2] ==s[3]) )){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  } 
  }


Measured memory_bytes: 256
n;main(r,i){
for(scanf("%d",&n),r=n,i=2;i*i<=n;i++)if(n%i==0)for(r=1LL*r*(i-1)/i;n%i==0;n/=i);
if(--n)r=1LL*r*n/++n;
n=!printf("%d\n",r);
}

Measured memory_bytes: 592
use proconio::input;

fn main() {
    input! {
      a: [[u32; 3]; 3],
      n: u32,
      b: [u32; n],
    }

    let mut oa = [[false, false, false], [false, false, false], [false, false, false]];

    for bi in b.iter() {
        for (i, a_row) in a.iter().enumerate() {
            for (j, a_row_j) in a_row.iter().enumerate() {
                if a_row_j == bi {
                    oa[i][j] = true
                }
            }
        }
    }

    match oa {
        [[true, true, true], [_, _, _], [_, _, _]] |
        [[_, _, _], [true, true, true], [_, _, _]] |
        [[_, _, _], [_, _, _], [true, true, true]] |
        [[true, _, _], [true, _, _], [true, _, _]] |
        [[_, true, _], [_, true, _], [_, true, _]] |
        [[_, _, true], [_, _, true], [_, _, true]] |
        [[true, _, _], [_, true, _], [_, _, true]] |
        [[_, _, true], [_, true, _], [true, _, _]]
        => println!("Yes"),
        _ => println!("No"),
    };

}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF 1000000000 //
#define LINF (ll)4000000000000000000 //
#define MOD (ll)1000000007
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898
#define NP(v) next_permutation(v.begin(),v.end())

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

ll calc(string s) {
    if (s.length() == 1) return stoll(s);

    ll subsum = 0;

    rep2(i, s.length() - 1) {
        string f = s.substr(0, i);
        string b = s.substr(i);
        subsum += stoll(f) * (ll) pow(2, b.length() - 1) + calc(b);
    }
    subsum += stoll(s);
    return subsum;
}

int main() {
    string n;
    cin >> n;
    cout << calc(n) << endl;

    return 0;
}

Measured memory_bytes: 256