akhauriyash/Code-Regression huggingface dataset:
use std::cmp;

const INF: f64 = 1e15;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let v: Vec<usize> = sc.vec(n);
    let u: Vec<f64> = sc.vec(n);
    let mut v_limit = vec![];
    for i in 0..n {
        let t = v[i];
        let u = u[i];
        for _ in 0..t {
            v_limit.push(u);
        }
    }

    let t = v_limit.len();
    let mut speed = vec![INF; t + 1];
    speed[0] = 0.0;
    speed[t] = 0.0;
    for i in 0..t {
        ch_min(&mut speed[i], v_limit[i]);
        ch_min(&mut speed[i + 1], v_limit[i]);
    }

    for i in 0..t {
        let x = speed[i] + 1.0;
        ch_min(&mut speed[i + 1], x);
    }
    for i in (0..t).rev() {
        let x = speed[i + 1] + 1.0;
        ch_min(&mut speed[i], x);
    }

    let mut ans = 0.0;
    for i in 0..t {
        let from = speed[i];
        let to = speed[i + 1];
        let limit = v_limit[i];
        if from == to && from < limit {
            ans += to + 0.25;
        } else {
            ans += (to + from) / 2.0;
        }
    }

    //    eprintln!("{:?}", speed);
    println!("{}", ans);
}

fn ch_min<T: PartialOrd>(a: &mut T, b: T) {
    if *a > b {
        *a = b;
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string A;
    cin >> A;
 
    if(A == "RRR"){
      cout << 3 << endl;
    }else if(A == "RRS"||A == "SRR"){
      cout << 2 << endl;
    }else if(A == "SSS"){
      cout << 0 << endl;
    }else{cout << 1 << endl;}
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <string>

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;
typedef pair<int,int> pii;

int main () {
    int N;
    while (cin >> N, N) {
        vector<vector<int>> tme(N, vector<int>(N, 0));
        REP (i, 0, N) {
            int temp;
            cin >> temp;
            REP (j, 0, N) {
                cin >> tme[i][j];
            }
            tme[i][i] = temp;
        }
        const int inf = 1 << 30;
        vector<int> dp(1 << N, inf);
        dp[0] = 0;
        REP (i, 0, 1 << N) {
            REP (j, 0, N) {
                if (((i >> j) & 1) == 1) continue;
                int m = tme[j][j];
                REP (k, 0, N) if (((i >> k) & 1) == 1) m = min(m, tme[j][k]);
                dp[i + (1 << j)] = min(dp[i + (1 << j)], dp[i] + m);
            }
        }
        cout << dp[(1 << N) - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 3356
#include<iostream>
#include<vector>

using namespace std;

enum class Status {
    Default, Bad, Good
};

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> height = vector<int>(n);
    for (int i=0; i<n; ++i) {
        int h;
        cin >> h;
        height[i] = h;
    }
    vector<vector<int>> graph = vector<vector<int>>(n, vector<int>());
    for (int i=0; i<m; ++i) {
        int a, b;
        cin >> a >> b;
        graph[a-1].push_back(b-1);
        graph[b-1].push_back(a-1);
    }
    vector<Status> status = vector<Status>(n, Status::Default);
    for (int i=0; i<n; ++i) {
        if (status[i] != Status::Default) continue;
        vector<int> node = graph[i];
        bool flag = true;
        for (auto& index : node) {
            if (height[i] <= height[index]) {
                status[i] = Status::Bad;
                flag = false;
                break;
            }
        }
        if (flag) {
            status[i] = Status::Good;
            for (auto& index : node) {
                status[index] = Status::Bad;
            }
        }
    }
    int count = 0;
    for (auto& e : status) {
        if (e == Status::Good) ++count;
    }
    cout << count << endl;
}


Measured memory_bytes: 9068
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.Monoid
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS

main = do
  n <- readLn
  tasks <- fmap (mergeSortBy (\(a,b) (a',b') -> compare b b' <> compare a a')) $ U.replicateM n $ do
    [a,b] <- map read . words <$> getLine
    return (a,b :: Int)
  let (as,bs) = U.unzip tasks
  let xs = U.tail $ U.scanl' (+) 0 as
  putStrLn $ if U.and $ U.zipWith (<=) xs bs
             then "Yes"
             else "No"

---

mergeSortBy :: (U.Unbox a) => (a -> a -> Ordering) -> U.Vector a -> U.Vector a
mergeSortBy !cmp !vec = doSort vec
  where
    doSort vec | U.length vec <= 1 = vec
               | otherwise = let (xs, ys) = U.splitAt (U.length vec `quot` 2) vec
                             in merge (doSort xs) (doSort ys)
    merge xs ys = U.create $ do
      let !n = U.length xs
          !m = U.length ys
      result <- UM.new (n + m)
      let loop !i !j
            | i == n = U.copy (UM.drop (i + j) result) (U.drop j ys)
            | j == m = U.copy (UM.drop (i + j) result) (U.drop i xs)
            | otherwise = let !x = xs U.! i
                              !y = ys U.! j
                          in case cmp x y of
                               LT -> do UM.write result (i + j) x
                                        loop (i + 1) j
                               EQ -> do UM.write result (i + j) x
                                        UM.write result (i + j + 1) y
                                        loop (i + 1) (j + 1)
                               GT -> do UM.write result (i + j) y
                                        loop i (j + 1)
      loop 0 0
      return result


Measured memory_bytes: 17788
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DecimalFormat;

public class Main {
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        double f , x , h;
        	String list = br.readLine();
        	x = Double.parseDouble(list);
        	DecimalFormat df = new DecimalFormat("0.000000");
        	f = x * x * Math.PI;
        	h = 2 * x * Math.PI;
            System.out.println(df.format(f) + " " + df.format(h));
	}

}

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

bool between(int n){
    return (0 <= n) && (n <= 3);
}

int main(){
    while( true ){
        int dx[4], dy[4];
        cin >> dx[0];
        if( dx[0] > 4 ) break;
        cin >> dy[0] >> dx[1] >> dy[1] >> dx[2] >> dy[2] >> dx[3] >> dy[3];
        queue< vector<int> > que;
        for(int i = 0; i < 4; i++){
            vector<int> a(16, 0);
            a[0] = 1;
            if(dx[i] >= 0 && dy[i] >= 0 && !a[ dx[i] + 4*dy[i] ]){
                a[ dx[i] + 4*dy[i] ] = 1;
                que.push( a );
            }
        }
        que.push( vector<int>(1, 100) );
        int count = 0, m = 2;
        while( !que.empty() ){
            int i = 0;
            vector<int> b = que.front();
            que.pop();
            if( b[0] == 100 ){
                if( m > 8 ) break;
                m++;
                que.push( vector<int>(1, 100) );
                continue;
            }
            for(; i < 16; i++){
                if( !b[i] ) break;
            }
            if(i == 16){
                count++;
                continue;
            }
            b[i] = m;
            int x = i%4, y = i/4;
            for(int j = 0; j < 4; j++){
                int s = (x+dx[j])+4*(y+dy[j]);
                if( between( x+dx[j] ) && between( y+dy[j] ) && !b[ s ] ){
                    b[ s ] = m; 
                    que.push( b );
                    b[ s ] = 0;
                }
            }
        }
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
 
#define cinsc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i,k,n)  for(int64 i=k;i<(int64)n;i++)
#define FORr(i,k,n)  for(int64 i=(int64)k;i>=n;i--)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define FOREACHr(it, l) for (auto it = l.rbegin(); it != l.rend(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SQ(x) ((x)*(x))
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
const int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddx[4] = {1,0,-1,0};
const int ddy[4] = {0,1,0,-1};
//ONLINE_JUDGE   LOCAL
 
int64 powr(int64 x,int64 y,int64 p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0;
    while (y > 0){   
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 
 
void  in_o(){
#ifndef LOCAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	cinsc;
}

int main(){
	//in_o();
	int n,m;
	cin>>n>>m;
	set<PII >s;
	FOR(i,0,m){
		int x,y;
		cin>>x>>y;
		s.insert(MP(x,y));
	}
	FOR(i,2,n){
		if(s.count(MP(1,i)) && s.count(MP(i,n)))
			return cout<<"POSSIBLE"<<endl,0;
	}
	cout<<"IMPOSSIBLE"<<endl;
	return 0;
}

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

int main() {
  int n;
  int count = 0;
  cin >> n;
  char s[n];
  for(int i = 0; i < n; i++) {
    cin >> s[i];
  }
  for(int i = 0; i < n; i++) {
    if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
      count++;
    }
  }
  cout << count << endl;
}

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

int main() {
  int a,b;
  double c;
  cin >> a >> b;

  c = (a+(b+1))/2;
  cout << c << endl;

}




Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(false);cin.tie(0);

int main() {
	optimizar_io
	int n;

	cin >> n;
	vector<int> l(n), used(n);
	for (int i = 0; i < n; i++) cin >> l[i];
	if (n < 3) return cout << 0 << "\n", 0;
	int cnt = 0;
	for (int i = 0; i < l.size(); i++) {
		for (int j = i + 1; j < l.size(); j++) {
			for (int k = j + 1; k < l.size(); k++) {
				if (l[i] + l[j] > l[k] and l[i] + l[k] > l[j] and l[j] + l[k] > l[i]) {		
					if (l[i] != l[j] and l[j] != l[k] and l[i] != l[k])
						cnt++;
				}
			}
		}
	}
	cout << cnt << "\n";
	return 0;
}

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

using namespace std;
typedef long long ll;
//ループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//コンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

vector<int> a, b, c, d;
int n, m, q;
int ans = 0;

void dfs(vector<int> A){
    if(A.size()==n+1){
        int now=0;
        REP(i,q){
            if(A.at(b.at(i)) - A.at(a.at(i)) == c.at(i))
                now += d.at(i);
        }
        ans = max(now,ans);
        return;
    }

    A.push_back(A.back());
    while(A.back()<=m){
        dfs(A);
        A.back()++;
    }
}

int main(){
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);

    REP(i,q) cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);

    dfs(vector<int>(1,1));
    cout << ans;
}

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

N, M, K = map(int, readline().split())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))

a = [0]
b = [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])

max = 0
j = M
for i in range(N+1):
  t = K - a[i]
  if t < 0:
    break
  while b[j] > t:
    j -= 1
  if i + j > max:
    max = i + j
print(max)

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

void Main()
{
    int n, m, x;
    cin >> n >> m >> x;
    int c[n], a[n][m];
    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
        for (int j = 0; j < m; j++)
        {
            cin >> a[i][j];
        }
    }

    // n : book
    // m : algorithm
    long min_money = 10000000000000;
    for (int i = 0; i < 1<<n; i++)
    {
        long money = 0;
        long r[m] = {0};
        for (int j = 0; j < n; j++)
        {
            if((i >> j) & 1){
                money += c[j];
                for (int k = 0; k < m; k++)
                {
                    r[k] += a[j][k];
                }
            }
        }
        if(min_money < money){
            continue;
        }
        int rikaishita = 1;
        for (int i = 0; i < m; i++)
        {
            if(r[i] < x){
                rikaishita = 0;
            }
        }
        if(rikaishita){
            min_money = money;
        }
    }
    
    if(min_money == 10000000000000){
        min_money = -1;
    }
    cout << min_money << endl;
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


Measured memory_bytes: 3596
n = int(input())
num = input()
 
password_list = []
initial_list = []
initial_list2 = []
initial_list3 = []
 
for i in range(len(num)-2):
    initial_list2 = []
    if num[i] in initial_list:
        continue
    elif len(initial_list) == 10:
        break
    else:
        initial_list.append(num[i])
        for j in range(i+1,len(num)-1):
            initial_list3 = []
            if num[j] in initial_list2:
                continue
            elif len(initial_list2) == 10:
                break
            else:
                initial_list2.append(num[j])
                for k in range(j+1,len(num)):
                    if num[k] in initial_list3:
                        continue
                    elif len(initial_list3) == 10:
                        break
                    else:
                        initial_list3.append(num[k])
                        target = num[i] + num[j] + num[k]
                        if target not in password_list:
                            password_list.append(target)
                            
print(len(password_list))

Measured memory_bytes: 9324
using System;
using System.Linq;

namespace abc096_c
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            char[,] c = new char[x[0] + 2, x[1] + 2];
            for (int i = 0; i < x[0]; i++)
            {
                string s = Console.ReadLine();
                for (int j = 0; j < x[1]; j++)
                {
                    c[i + 1, j + 1] = s[j];
                }
            }
            bool flag = true;
            int[] movex = new int[] { 1, -1, 0, 0 };
            int[] movey = new int[] { 0, 0, 1, -1 };
            for (int i = 0; i < x[0] + 2; i++)
            {
                for (int j = 0; j < x[1] + 2; j++)
                {
                    if (c[i, j] == '#')
                    {
                        bool now = false;
                        for(int k=0;k<4;k++)
                        {
                            if (c[i + movex[k], j + movey[k]] == '#') now = true;
                        }
                        if (!now) flag = false;
                    }
                }
            }
            Console.WriteLine(flag ? "Yes" : "No");
        }
    }
}

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

int main(){
  int N,M,C,sum,res;
  cin >> N >> M >> C;
  vector<int> A(M),B(M);
  for(int i=0;i<M;i++){
    cin >> B.at(i);
  }
  res = 0;
  for(int j=0;j<N;j++){
    sum = C;
    for(int i=0;i<M;i++){
      cin >> A.at(i);
      sum += A.at(i)*B.at(i);
    }
    if(sum > 0){
      res++;
    }
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long ll;

int read() {
	char ch;
	for(ch=getchar();ch<'0'||ch>'9';ch=getchar());
	int x=ch-'0';
	for(ch=getchar();ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

const int N=25005,K=405,Mo=1e9+7;

int pwr(int x,int y) {
	int z=1;
	for(;y;y>>=1,x=(ll)x*x%Mo)
		if (y&1) z=(ll)z*x%Mo;
	return z;
}

void inc(int &x,int y) {x=x+y>=Mo?x+y-Mo:x+y;}

int n,k,m,a[N],f[N][K],g[N][K],fac[N],inv[N],vis[K];

void pre(int N) {
	fac[0]=1;fo(i,1,N) fac[i]=(ll)fac[i-1]*i%Mo;
	inv[N]=pwr(fac[N],Mo-2);fd(i,N-1,0) inv[i]=(ll)inv[i+1]*(i+1)%Mo;
}

int main() {
	n=read();k=read();m=read();
	pre(k);
	fo(i,1,m) a[i]=read();
	int ans=(ll)(n-m+1)*pwr(k,n-m)%Mo;
	bool ok=1;
	fo(i,1,m) {
		if (vis[a[i]]) {ok=0;break;}
		vis[a[i]]=1;
	}
	f[0][0]=1;
	fo(i,1,n) {
		int sf=0,sg=0; 
		fd(j,k-1,1) {
			inc(sf,f[i-1][j]);f[i][j]=sf;
			inc(f[i][j],(ll)f[i-1][j-1]*(k-j+1)%Mo);
			inc(sg,g[i-1][j]);g[i][j]=sg;
			inc(g[i][j],(ll)g[i-1][j-1]*(k-j+1)%Mo);
			if (j>=m) inc(g[i][j],f[i][j]);
		}
	}
	int mx=0,now=0;
	fo(i,1,m) {
		now=min(now+1,i-vis[a[i]]);
		vis[a[i]]=i;mx=max(mx,now);
	}
	if (mx==k) {printf("%d\n",ans);return 0;}
	if (ok) {
		int ret=0;
		fo(j,1,k-1) inc(ret,g[n][j]);
		ret=(ll)ret*fac[k-m]%Mo*inv[k]%Mo;
		printf("%d\n",(ans-ret+Mo)%Mo);
	} else {
		int pr=0,sf=0;
		fo(i,1,k) vis[i]=0;
		fo(i,1,m) {
			if (vis[a[i]]) break;
			pr++;vis[a[i]]=1;
		}
		fo(i,1,k) vis[i]=0;
		fd(i,m,1) {
			if (vis[a[i]]) break;
			sf++;vis[a[i]]=1;
		}
		int ret=0;
		fo(i,1,n-m+1) {
			int r1=0,r2=0;
			fo(j,pr,k-1) inc(r1,f[i+pr-1][j]);
			fo(j,sf,k-1) inc(r2,f[n-m-i+1+sf][j]);
			r1=(ll)r1*fac[k-pr]%Mo*inv[k]%Mo;
			r2=(ll)r2*fac[k-sf]%Mo*inv[k]%Mo;
			inc(ret,(ll)r1*r2%Mo);
		}
		printf("%d\n",(ans-ret+Mo)%Mo);
	}
	return 0;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using st = string;
using P = pair<int, int>;
using bl = bool;
using ch = char;
#define mrep(i, m, n) for(int i = m; i < (n); i++)
#define rep(i, n) mrep(i, 0, n)
#define chmax(x, y) { x = max(x, y); }
#define chmin(x, y) { x = min(x, y); }
#define INF 1e7

vector<int> a(INF);

int main() {
    int k;
    cin >> k;
    a.at(0) = 7 % k;
    mrep(i, 1, k){
        a.at(i) = (a.at(i - 1) * 10 + 7) % k;
    }
    rep(i, k){
        if(a.at(i) == 0){
            cout << i + 1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    /*while(true){
        if(k % 2 == 0 || k % 5 == 0){
            ans = -1;
            break;
        }
        if(seven % k == 0){
            break;
        }
        seven = seven * 10 + 7;
        ans++;
    }*/
}

Measured memory_bytes: 42176
import java.util.Scanner;

public class Main{
    Main(){
	Scanner sc = new Scanner(System.in);

	while(sc.hasNext()){
	    int n = sc.nextInt();
	    if(n == 0) break;
	    int[][] ary = new int[n+1][];
	    for(int i = 0; i < n; i++){
		ary[i] = new int[n+1];
		for(int j = 0; j < n; j++){
		    ary[i][j] = sc.nextInt();
		    ary[i][n] += ary[i][j];
		}
	    }

	    ary[n] = new int[n+1];
	    for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
		    ary[n][i] += ary[j][i];


	    for(int i = 0; i < n; i++)
		ary[n][n] += ary[n][i];

	    for(int i = 0; i <= n; i++){
		for(int j = 0; j <= n; j++)
		    System.out.printf("%5d", ary[i][j]);
		System.out.println();
	    }
	}
    }

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

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

void Main()
{
	string S; cin >> S;
	reverse(S.begin(), S.end());
	char prev = '#';
	ll cnt = 0;
	rep(i,S.size()) {
		if (prev == S[i]) {
			prev = '#';
			i++;
			cnt++;
		}
		else prev = S[i];
	}
	cout << S.size() - cnt << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define floop(i,a,n) for (int i=a;i<n;i++)
#define rfloop(i,a,n) for (int i=n-1;i>=a;i--)
#define mloop(it,x) for(it=x.begin();it!=x.end();it++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((ll)(x).size())
#define cases ll t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef unsigned long long int ull;
typedef vector<ll> vec;
typedef pair<ll,ll> pll;
typedef double db;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const ll mod=1000000007;
ll pm(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=((result%mod)*(x%mod))%mod; x=((x%mod)*(x%mod))%mod; n/=2;} return result;}
ll p(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=result*x; x=x*x; n/=2;} return result;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ncr(ll n,ll r) { ll p=1,k=1; if(n-r<r) r=n-r; if(r!=0) {while(r!=0) {p*=n; k*=r; ll temp=gcd(p,k); p/=temp; k/=temp; n--; r--;} } else p=1; return p;}
ll factorial[300000+1];
void fact(ll n) { factorial[0]=1; factorial[1]=1; floop(i,2,n+1) factorial[i] = (i * factorial[i-1]%mod) % mod; }
ll d,coeff1,coeff2; 
void euclid(ll a, ll b) { if(b==0) { d=a; coeff1=1; coeff2=0; } else { euclid(b,a%b); ll temp=coeff1; coeff1=coeff2; coeff2=temp-(a/b)*(coeff2); } }
ll modinv(ll a) { euclid(a,mod); return (coeff1%mod+mod)%mod; }
int prime[1000001]={};
int spf[1000001]={};
void sieve(ll n)
{
	prime[0]=1;
	prime[1]=1;
	for(ll i=2;i*i<=n;i++)
	{
		if(prime[i]==0)
		{
			for(ll j=i*i;j<=n;j+=i)
			{
				prime[j]=1;	
				if(spf[j]==j)
				spf[j]=i;	
			}		
		}
	}
}
/*
vec s(300000,0);
vec si(300000,1);
ll root(ll a)
{
	while(s[a]!=a)
	a=s[a];
	return a;
}
void uni(ll a,ll b)
{
	ll r1=root(a);
	ll r2=root(b);
	if(si[r1]<si[r2])
	{
		s[r1]=s[r2];
		si[r2]+=si[r1];
	}
	else
	{
		s[r2]=s[r1];
		si[r1]+=si[r2];
	}
}
vector<vec > adj(300000);
vec vis(300000,0);
vec dist(300000,0);
void dfs(ll t,ll n)
{
	vis[t]=1;
	floop(i,0,sz(adj[t]))
	{
		if(vis[adj[t][i]]==0)
		{
			dist[adj[t][i]]=dist[t]+1;
			vis[adj[t][i]]=1;
		//	sum[adj[t][i]]=sum[t]+c[t][adj[t][i]];
			dfs(adj[t][i],n);
		}
	}
}*/
struct my_comp
{
	bool operator()(pair<ll,pll> p1, pair<ll,pll> p2)
	{
		if(p1.fi!=p2.fi)
		return p1.fi>p2.fi;
		return p1.se.fi<p2.se.fi;
	}
};
int main()
{
	ll l,r,d;
	cin>>l>>r>>d;
	ll ans=0;
	floop(i,l,r+1)
	{
		if(i%d==0)
		ans++;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


ll x;

void solve()
{
    cin >> x;
    ll a = 100, ans=0;
    while (a<x) {
        a += a/100;
        ans++;
    }nout(ans);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <utility>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;

int main(void) {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b + c >= 22) {
    cout << "bust" << endl;
  }
  else {
    cout << "win" << endl;
  }
 
  return 0;
}

Measured memory_bytes: 256
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];


int main()
{
   ll w,s;
   cin>>s>>w;
   if(w>=s)cout<<"unsafe"<<endl;
   else cout<<"safe"<<endl;
return 0;
}


Measured memory_bytes: 8312
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;

int main() {
  string s;
  int cnt =0;

  cin >> s;

  for(int i=0; i< 3; i++){
    if(s[i]=='1'){
      cnt++;
    }
  }

  cout << cnt << endl;
}


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

using namespace std;
using ll = long long;

int main() {
    while(true) {
        int n;
        cin>>n;
        if(n==0)break;
        vector<int> c(2*n,1);
        for(int i = 0;i < n;++i) {
            int a;
            cin>>a;
            --a;
            c[a]=0;
        }
        bool taro=true;
        int tn=-1;
        while(true) {
            bool ttaro=taro;
            for(int i = tn+1;i < 2*n;++i) {
                if(c[i]==-1)continue;
                if(taro&&c[i]==0){
                    taro=false;
                    tn=i;
                    c[i]=-1;
                    break;
                }
                else if(!taro&&c[i]==1){
                    taro=true;
                    tn=i;
                    c[i]=-1;
                    break;
                }
            }
            if(taro==ttaro){
                tn=-1;
                taro=!taro;
            }
            int t=0,h=0;
            for(int i = 0;i < 2*n;++i) {
                if(c[i]==0)++t;
                else if(c[i]==1)++h;
            }
            if(t==0||h==0)break;
        }
        int ta=0,ha=0;
        for(int i = 0;i < 2*n;++i) {
            if(c[i]==0)++ha;
            else if(c[i]==1)++ta;
        }
        cout<<ta<<endl;
        cout<<ha<<endl;
    }
    return 0;
}



Measured memory_bytes: 3048
#include<bits/stdc++.h>
const long long INF = INT_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, cnt = 0, w, h;
string s;
vector<ll> v;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
set<ll> st;
map<char, ll> mp;

/*--------------------template--------------------*/

int main()
{
	REP(i,10)
	{
		cin >> n;
		v.push_back(n);
	}
	sort(RALL(v));
	REP(i,3)
	{
		cout << v[i] << endl;
	}
}

Measured memory_bytes: 3176
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    string s;
    while(cin >> s && s != "-")
    {
        int m;
        cin >> m;
        for(int i = 0;i  < m;i++)
        {
            int h;
            cin >> h;
            s = s.substr(h,s.size() - h) + s.substr(0,h);
        }
        cout << s << "\n";
    }

    return 0;
}


Measured memory_bytes: 3128
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{

static long k = long.Parse(Console.ReadLine());//int.Parseは文字列を整数に変換。
static long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);

	static void Main()
	{
		
    long minAnswer = SearchMin(0, 1000000000000000000);
		long maxAnswer = Search(0, 1000000000000000000); 
    if(minAnswer > maxAnswer) Console.WriteLine(-1);
    else Console.WriteLine(minAnswer + " " + maxAnswer);
	}

  static long Search(long min, long max)//二分探索法で最大値を求める
  {
    while (true)
    {
      long mid = min + (max - min) / 2;
      if(CheckMin(mid)) min = mid;//さらに大きくても成り立つかも
      else max = mid;

      if(max - min <= 1)
      {
        if(CheckMin(max)) 
        {
          return max;//最大値で成り立つかの確認を優先
        }
        else
        {
          return min;
        }
      break;
      }  
    }
  }

  static long SearchMin(long min, long max)//二分探索法で最小値を求める
  {
    while (true)
    {
      long mid = min + (max - min) / 2;
      if(Check(mid)) max = mid;//さらに小さくても成り立つかも
      else min = mid;

      if(max - min <= 1)
      {
        if(Check(min)) 
        {
          return min;//最小値で成り立つかの確認を優先
        }
        else
        {
          return max;
        }
      break;
      }  
    }
  }

  static bool Check(long testNum)
  {
    for(long i = 0; i < k; i++)
    {
      if(testNum < nums[i]) return false;
      long memo = testNum % nums[i];
      testNum -= memo;
    }
    if(testNum < 2) return false;
    return true;
  }

  static bool CheckMin(long testNum)
  {
    for(long i = 0; i < k; i++)
    {
      if(testNum < nums[i]) return true;
      long memo = testNum % nums[i];
      testNum -= memo;
    }
    if(testNum <= 2) return true;
    return false;
  }

  
}


Measured memory_bytes: 25308
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <sstream>

#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
#define ll long long
#define bl bool
#define nn printf("\n");
#define mod 1000000007

using namespace std;

int w, h, cnt;
void srch(int x, int y, vector<vector<char>> &inp, vector < vector <bool>> &hit)
{
	if (x < 0 || w <= x || y < 0 || h <= y || inp[x][y] == '#') { return; }
	if (hit[x][y]) return;
	hit[x][y] = true;
	cnt += 1;
	srch(x + 1, y, inp, hit);
	srch(x - 1, y, inp, hit);
	srch(x, y + 1, inp, hit);
	srch(x, y - 1, inp, hit);
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	while (1)
	{
		cin >> w >> h;
		if (w == 0 && h == 0) { break; }
		cnt = 0;
		vector<vector<char>> inp(w, vector<char>(h, 0));
		vector<vector<bool>> hit(w, vector<bool>(h, false));
		int x = 0, y = 0;
		rep(i, h)
		{
			rep(j, w)
			{
				cin >> inp[j][i];
				if (inp[j][i] == '@'){ x = j; y = i; }
			}
		}
		srch(x, y, inp, hit);
		printf("%d\n", cnt);
	}
	return 0;
}

Measured memory_bytes: 3184
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define sort(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

unsigned int randxor()
{
	static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned int t;
	t = (x ^ (x << 11)); x = y; y = z; z = w; return(w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}






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

	vector<ll> a0(m), b0(m), ax(n);

	rep(i, m) {
		cin >> a0[i] >> b0[i];
		a0[i]--;
		b0[i]--;
	}

	vector<ll> ans;

	vector<ll> x;
	vector<vector<ll>> y;
	rep(i, n) {
		ax[i] = -1;
	}

	ans.push_back((n*(n - 1)) / 2);
	for (ll i = m - 1; i > 0; i--) {
		ll a = a0[i];
		ll b = b0[i];
		if (ax[a] == -1 && ax[b] == -1) {
			ans.push_back(ans[ans.size() - 1] - 1);
			ax[a] = x.size();
			ax[b] = x.size();
			x.push_back(2);
			vector<ll> z;
			z.push_back(a);
			z.push_back(b);
			y.push_back(z);
		}
		else if (ax[a] == -1) {
			ans.push_back(ans[ans.size() - 1] - x[ax[b]]);
			x[ax[b]]++;
			ax[a] = ax[b];
			y[ax[b]].push_back(a);
		}
		else if (ax[b] == -1) {
			ans.push_back(ans[ans.size() - 1] - x[ax[a]]);
			x[ax[a]]++;
			ax[b] = ax[a];
			y[ax[a]].push_back(b);
		}
		else if(ax[a]!=ax[b]){
			ans.push_back(ans[ans.size() - 1] - x[ax[a]]* x[ax[b]]);
			ll yas = y[ax[a]].size();
			ll ybs = y[ax[b]].size();
			if (yas > ybs) {
				ll axb = ax[b];
				x[ax[a]] += x[axb];
				x[axb] = -1;
				rep(j, y[axb].size()) {
					ll q = y[axb][j];
					ax[q] = ax[a];
					y[ax[a]].push_back(q);
				}
			}
			else {
				ll axa = ax[a];
				x[ax[b]] += x[axa];
				x[axa] = -1;
				rep(j, y[axa].size()) {
					ll q = y[axa][j];
					ax[q] = ax[b];
					y[ax[b]].push_back(q);
				}
			}
		}
		else {
			ans.push_back(ans[ans.size() - 1]);
		}
	}
	rrep(i, m) {
		std::cout << ans[i] << endl;
	}
	return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int a, b, c;

int main() {
	cin >> a >> b >> c;
	if (a==b) cout << c << ln;
	else if (b==c) cout << a << ln;
	else cout << b << ln;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

vector<ll> ret(101);

//素因数分解行列作成
void prime_factor(ll N){
  ll i;
  for(i=2;i*i<=N;i++){
    while(N%i==0){
      ret[i]++;
      N/=i;
    }
  }
  if(N!=1) ret[N]++;
}


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

  ll ans = 0;
  repn(i,N){
    prime_factor(i);
  }

  // check
  ll ni = 0, yon = 0, zg = 0, ng = 0, nng = 0;
  repn(i,N){
    if(ret[i] >= 2) ni++;
    if(ret[i] >= 4) yon++;
    if(ret[i] >= 14) zg++;
    if(ret[i] >= 24) ng++;
    if(ret[i] >= 74) nng++;
  }
  // cout<<ni<<" "<<yon<<" "<<zg<<" "<<ng<<" "<<nng<<endl;
  if(ni > 0 and yon > 1){
    ans = 1;
    ans *= yon*(yon-1)/2;
    ans *= ni-2;
  }
  if(ans > 0){
    ll tmp = 1;
    tmp *= zg;
    tmp *= yon-1;
    ans += tmp;
  }
  // cout<<ans<<endl;
  if(ans > 0){
    ll tmp = 1;
    tmp *= ng;
    tmp *= ni-1;
    ans += tmp;
  }
  // cout<<ans<<endl;
  if(ans > 0){
    ll tmp = 1;
    tmp *= nng;
    ans += tmp;
  }
  cout<<ans<<endl;
}


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

int main(){
    long long n,k;
    cin>>n>>k;
    k--;
    vector<long> a(n);
    rep(i,n)cin>>a[i];
    
        for(int i=k;i<n-1;i++){
        if(a[i-k]<a[i+1])
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
        }
    }


Measured memory_bytes: 4836
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
int main()
{
	int n,x[100005],y[100005],t[100005],flag=1;
	cin >> n;
	for(int i=1;i<=n;i++)
	{
		cin >> t[i] >> x[i] >> y[i];
		if(t[i]<x[i]+y[i])
			flag=0;
		else
		{
			if((x[i]+y[i])%2==0&&t[i]%2!=0)
				flag=0;
			else if((x[i]+y[i])%2!=0&&t[i]%2==0)
				flag=0;
		}
		
	}
		if(flag)
			cout << "Yes";
		else
			cout << "No";
	return 0;
}

Measured memory_bytes: 1408
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

typedef long long int ll;
typedef vector<int> vi;

#define FOR(i, a, b) for (int i = a; i < b; i++)

void print(vi &A) {
	FOR(i, 0, (int)A.size())
		printf("%d ", A[i]);
	cout << endl;
}

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

	ll f = floor(log2(h));
	ll p = pow(2, f + 1) - 1;

	// cout << f << endl;	
	cout << p << endl;

	return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main()
{
    long long int a,b;
    cin >> a >> b;
    if(a+b>=a-b && a+b>=a*b){
        cout << a+b ;
    }
    else if(a-b>=a+b && a-b>=a*b){
        cout << a-b;
    }
    else if(a*b>=a+b && a*b>=a-b){
        cout << a*b ;
    }
    return 0;
}

Measured memory_bytes: 3596
str = chomp(readline())
n = length(str)
xs = zeros(Int, n)

for (i, s) in enumerate(str)
    xs[i] = parse(Int, s)
end

s0 = zeros(Int, n)
s1 = zeros(Int, n)

for i = 1:n
    d2 = i % 2
    s0[i] = d2
    s1[i] = 1 - d2
end

d0 = s0 - xs
d1 = s1 - xs

n0 = sum(abs(d0))
n1 = sum(abs(d1))
minn = min(n0, n1)
print(minn)

Measured memory_bytes: 167840
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/



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


int main(){
    string s;cin>>s;int len=s.size();
    ll ans=0;
    int last=1<<(len-1);
    for(int i=0;i<=last-1;i++){
        ll p=1;ans+=s[len-1]-'0';
        for(int j=0;j<=len-2;j++){
            if(i>>j&1){
                p*=10;
                ans+=p*(s[len-2-j]-'0');
            }else{
                p=1;
                ans+=p*(s[len-2-j]-'0');
            }
        }
    }
    
    cout<<ans<<endl;
    return 0;
}


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

int main(){
    // H is monster health, N is how many moves Raccoon can make
	int H, N;
    cin >> H >> N;
    
    // initialize an array
    int moves[N];
    
    // user input numbers, effectiveness of attack
    int i;
    for (i=0; i<N; i++){
      cin >> moves[i];
    }
  
    // add up all of the numbers in the array
    int sum = 0;
    for (i=0; i<N; i++){
      sum += moves[i];
    }
    
    // check if the sum is bigger or smaller than the enemy's health
    if (H <= sum){
      cout << "Yes";
    }
    else{
      cout << "No";
    }
}

Measured memory_bytes: 640
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007

int main() {
    int K, T;
    cin >> K >> T;
    vector<int> V;
    rep(i, T) {
        int x;
        cin >> x;
        V.push_back(x);
    }

    sort(all(V), greater<int>());

    if (V.size() == 1) {
        cout << V[0] - 1 << endl;
        return 0;
    }

    while (true) {
        if (V[1] == 0)
            break;
        int i = 1;
        while (i < T) {
            if (V[0] > V[i]) {
                V[0] -= V[i];
                V[i] = 0;
            } else {
                V[i] -= V[0];
                V[0] = 0;
                break;
            }
            i++;
        }

        sort(all(V), greater<int>());
    }

    int res = V[0] - 1;
    if (res < 0)
        res = 0;
    cout << res << endl;
}

Measured memory_bytes: 256
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {
    /////////////////////
    // Write code below /
    /////////////////////
    int parkingTime;
    int dynamicParkingFee;
    int staticParkingFee;
    cin >> parkingTime >> dynamicParkingFee >> staticParkingFee;
    
    int sumOfPlan1 = dynamicParkingFee * parkingTime;
    
    if (sumOfPlan1 < staticParkingFee) {
        cout << sumOfPlan1 << endl;
    } else {
        cout << staticParkingFee << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N, K;
    cin >> N >> K;

    if (K > (N-1)*(N-2)/2) {
        cout << -1 << "\n";
        return 0;
    }

    vector<pair<ll, ll>> co;
    for (ll i = 1; i <= (N-1); i++) {
        for (ll j = i + 1; j <= N - 1; j++) {
            co.push_back(make_pair(i, j));
        }
    }
    for (ll i = 1; i <= N - 1; i++) co.push_back(make_pair(i, N));

    reverse(co.begin(), co.end());

    ll M = N * (N-1) / 2 - K;
    cout << M << "\n";
    Rep (i, M) {
        cout << co[i].first << " " << co[i].second << "\n";
    }
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define pb push_back
#define rint register int
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=1010;
const int inf=0x3f3f3f3f;

int n,m,ans;
bool mp[maxn][maxn],vis[maxn][maxn];
char l[maxn];
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
int dis[maxn][maxn];
queue<pii> q;

void bfs(){
	while(!q.empty()){
		int x=q.front().first,y=q.front().second;
		q.pop();
		for(rint i=0;i<4;++i){
			int kx=x+dx[i],ky=y+dy[i];
			if(kx<1||kx>n||ky<1||ky>m||vis[kx][ky]||mp[kx][ky]) continue;
			q.push(make_pair(kx,ky));
			vis[kx][ky]=true;
			dis[kx][ky]=dis[x][y]+1;
			ans=max(ans,dis[kx][ky]);
		}
	}
}

int main(){
	scanf("%d%d",&n,&m);
	for(rint i=1;i<=n;++i){
		scanf("%s",l);
		for(rint j=0;j<m;++j){
			if(l[j]=='#') mp[i][j+1]=true;
		}
	}
	for(rint i=1;i<=n;++i){
		for(rint j=1;j<=m;++j){
			if(mp[i][j]) q.push(make_pair(i,j)),vis[i][j]=true,dis[i][j]=0;
		}
	}
	bfs();
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 14352
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cstdlib>
#include <iostream>

using namespace std;

#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int H, W;

int main()
{
	scanf("%d%d", &H, &W);
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			char s[10];
			scanf("%s", s);
			string w = s;
			if (w == "snuke") {
				printf("%c%d\n", 'A' + j, i + 1);
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define ip pair<ll,ll>
#define vii vector<ll>
#define vpp vector<ip>
#define vdd vector<ld>
#define vb vector<bool>
#define pi  pair<ll,ip>
#define sc(x) scanf("%lli",&x)
#define c(x) cin >> x
#define fo(i,k,n) for( int i=k;i<n;i++)
#define hu 200010
#define pq priotity_queue<ll>
#define pqs priority_queue<ll,vii,greater<ll>>
#define ppq priority_queue<ip,vpp,greater<ip>>
#define INF INT_MAX
#define ff first
#define ss second
using namespace std;
const ll M = 1000000000+7;
//Grid Movement
ll dx[] = {-1, 0, 1, 0};
ll dy[] = {0, -1, 0, 1};

ld Pi= acos(-1);

ll lcm(ll a,ll b)
{
    return (a*b)/(__gcd(a,b));
}

ll mex(ll x, ll y) 
{ 
	ll res = 1;	  
	x = x % M; 
	if (x == 0) return 0; 
	while (y > 0) 
	{ 
		if (y & 1) 
		res = (res*x) % M; 
		y = y>>1; 
		x = (x*x) % M; 
	} 
	return res; 
} 

bool comp(ll comp1,ll comp2)
{
    return comp1>comp2;
}

void yes()
{
    printf("YES\n");
}

void no()
{
    printf("NO\n");
}

ll inv(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
 
    if (m == 1)
      return 0;
 
    while (a > 1)
    {
        int q = a / m;
        int t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
 
    if (x < 0)
       x += m0;
 
    return x;
}

void sieve(ll n)
{
    vii primes(n+1);
    vb is_prime(n+1);
	is_prime.resize(n+1);
	primes.resize(n+1);
 
	is_prime[0] = is_prime[1] = false;
	for(int i = 2; i<=n; i++)
	{
	    if(is_prime[i])
	    {
	    	primes.pb(i);
	        for (int j = i*i; j<=n; j+=i)
	            is_prime[j] = false;
	    }
	}
}

void solve()
{
    ll a;
    sc(a);
    ll x= a*(1+a+a*a);
    printf("%lli",x);
}

int main()
{
    string s1,s2;
    cin >> s1;
    cin>>s2;
    ll ans=0;
    fo(i,0,s1.size())
    {
        if(s1[i]!=s2[i]) ans++;
    }
    
    cout << ans;
}

Measured memory_bytes: 3924