akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut 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 gcd(x: i64, y: i64) -> i64 {
  if y == 0 {
    x
  } else {
    gcd(y, x % y)
  }
}

fn solve(a: i64, b: i64, c: i64, d: i64) -> bool {
  if a < b || b > d {
    return false;
  }
  if c >= b {
    return true;
  }
  let g = gcd(b, d);
  b - g + a % g <= c
}

fn main() {
  input! {
    t: usize,
    query: [(i64, i64, i64, i64); t],
  }
  for &(a, b, c, d) in query.iter() {
    if solve(a, b, c, d) {
      println!("Yes");
    } else {
      println!("No");
    }
  }
}


Measured memory_bytes: 4352
#include <stdio.h>

int		main()
{
	int		N = 0, R = 0;
	int		r;

	scanf("%d %d", &N, &R);
	if (N > 9)
		r = R;
	else
		r = R + (100 * (10 - N));
	printf ("%d", r);
	return (0);
}


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

int main() {
   string s;
   cin>>s;
   if(s<="2019/04/30"){
       cout<<"Heisei"<<endl;
   }
   else
   {
       cout<<"TBD"<<endl;
   }
   
}



Measured memory_bytes: 256
import java.util.*;
 
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if (A <= 9 && B <= 9) {
            System.out.println(A*B);
        } else {
            System.out.println(-1);
        }
    }
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int num=1,ans=0;
  while(n>=num){
    num*=2;
    ans++;
  }
  cout<<num/2<<endl;

  return 0;
}



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

int main()
{
    while(true){
        char c;
        int line[10],v[2],allLength=0,length=0;;
        double lengthPer,passLength;
        for(int i=0;i<10;i++){
            cin>>line[i]>>c;
            if(cin.eof()){
                return 0;
            }
            allLength += line[i];
        }
        cin>>v[0]>>c>>v[1];
        lengthPer=(double)v[0]/((double)v[0]+(double)v[1]);
        passLength=(double)allLength*lengthPer;
        for(int i=0;i<10;i++){
            length += line[i];
            if(passLength<(double)length){
                cout<<i+1<<endl;
                length=0;
                break;
            }
            if(passLength==(double)length){
                cout<<i+1<<endl;
                length=0;
                break;
            }
        }
    }
}

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

#define MAXN (100010)
#define ll long long

ll ans;
int x, y, z, n;
int a[MAXN], b[MAXN], c[MAXN];
ll pre[MAXN], suf[MAXN];
std::vector<std::pair<int, int> > vec;

int main(){
	scanf("%d%d%d", &x, &y, &z);
	n = x + y + z;
	for(int i = 0; i < n; ++ i){
		scanf("%d%d%d", a + i, b + i, c + i);
		a[i] -= c[i];
		b[i] -= c[i];
		vec.push_back({a[i] - b[i], i});
	}
	std::sort(vec.begin(), vec.end());
	//cal pre
	std::multiset<int> set;
	ll sum = 0;
	for(int i = 0; i < y; ++ i){
		set.insert(b[vec[i].second]);
		sum += b[vec[i].second];
	}
	pre[y - 1] = sum;
	for(int i = y; i < y + z; ++ i){
		sum += b[vec[i].second];
		set.insert(b[vec[i].second]);
		int tmp = *set.begin();
		sum -= tmp;
		set.erase(set.find(tmp));
		pre[i] = sum;
	}
	//cal suf
	set.clear();
	sum = 0;
	for(int i = n - 1; i >= y + z; -- i){
		set.insert(a[vec[i].second]);
		sum += a[vec[i].second];
	}
	suf[y + z] = sum;
	for(int i = y + z - 1; i >= y; -- i){
		sum += a[vec[i].second];
		set.insert(a[vec[i].second]);
		int tmp = *set.begin();
		sum -= tmp;
		set.erase(set.find(tmp));
		suf[i] = sum;
	}
	
	ans = LLONG_MIN;
	for(int i = y; i <= y + z; ++ i){
		ans = std::max(ans, pre[i - 1] + suf[i]);
	}
	for(int i = 0; i < n; ++ i){
		ans += c[i];
	}
	
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 6644
function main(input) {
  const formatted_input = input.split('\n');
  const N =  parseInt(formatted_input[0].split(' ')[0]);
  const M =  parseInt(formatted_input[0].split(' ')[1]);
  const C =  parseInt(formatted_input[0].split(' ')[2]);
  const Bs = formatted_input[1].split(' ').map(x => parseInt(x));

  As=[];
  for(var i=0;i<N;i++){
    var tmp_as = formatted_input[2+i].split(' ').map(x => parseInt(x))
    As.push(tmp_as);
  }

//  console.log(N);
//  console.log(M);
//  console.log(C);
//  console.log(Bs);
//  console.log(As);


  var result = 0;

  for(var i=0;i<N;i++){
    var tmp_sum = C;
    for(var j=0;j<M;j++){
      tmp_sum += Bs[j] * As[i][j];
    }

    if(tmp_sum>0){result++;}
  }

  console.log(result);

}

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



Measured memory_bytes: 7500
# ABC 165 D - Floor Function
# https://atcoder.jp/contests/abc165/tasks/abc165_d

a, b, n = gets.split(/ /).map(&:to_i)

require 'bigdecimal'

def calc(a, b, x)
  x_per_b = BigDecimal((BigDecimal(x.to_s) * 1.0 / b).to_s)
  (a * x_per_b).floor - a * x_per_b.floor
end

if n < b
  puts calc(a, b, n)
elsif a > b
  puts (0..(b - 1)).map { |x| calc(a, b, x) }.max
else
  puts a - 1
end


Measured memory_bytes: 14444
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;

int main(void) {
    int n, i, cnt;
    cin >> n;
    
    if(n%2==0)
        cout << n << endl;
    else
        cout << n*2 << endl;
    
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;


int main(){

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

  int now = A, ans = 1;
  while (now < B){
    now += A - 1;
    ans++;
  }

  if (B == 1) ans = 0;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#参考にしたい解答
S = input() 
i= 0
ans = 0
moji1 = ""
moji2 = ""
while i < len(S):
    if i == 0:
        moji1 = S[i]
        ans += 1
    else:
        moji2 = moji2 + S[i]
        if moji1 != moji2:
            ans += 1
            moji1 = moji2
            moji2 = ""
        else:
            moji2 = moji2 + S[i]
    i += 1
 
print(ans)

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

int main() {
  int a,b;cin>>a>>b;
  if(a+b>=10) cout << "error" << endl;
  else cout << a+b << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static int lcs(String s, String ss){
    int m = s.length()+1;
    int n = ss.length()+1;
    int[][] c = new int[m][n];
    for (int i = 1; i < m; i++) {
      for (int j = 1; j < n; j++) {
        if (s.charAt(i - 1) == ss.charAt(j - 1)){
          c[i][j] = c[i-1][j-1] + 1;
        }else{
          c[i][j] = Math.max(c[i][j-1], c[i-1][j]);
        }
      }
    }
    return c[m-1][n-1];
  }           
  public static void main (String args[]){       
    Scanner in = new Scanner(System.in);
    int pair = in.nextInt();
    int [] res = new int[pair];
    for (int i = 0; i < pair; i++){
      String s1 = in.next();
      String s2 = in.next();
      res[i] = (lcs(s1,s2));
    }
    for (int j = 0; j < res.length; j++){
      System.out.println(res[j]);
    }
  }
}


Measured memory_bytes: 64724
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <numeric>
#include <set>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()
#define ll long long
#define MOD 1000000007

ll n, k, s[110];
bool dp[300000];
int main() {
	cin >> n >> k;
	REP(i, n)cin >> s[i];
	REP(i, k) {
		REP(j, n) {
			if (!dp[i]) dp[i + s[j]] = true;
		}
	}
	cout << (dp[k] ? "First" : "Second") << endl;
}


Measured memory_bytes: 384
#Union Find
#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

#初期化
#根なら-size,子なら親の頂点
n,m = map(int,input().split())
par = [-1]*n
ans = 0
for i in range(m):
  x,y = map(int,input().split())
  unite(x-1,y-1)
for i in range(n):
  ans = max(ans,size(i))
print(ans)

Measured memory_bytes: 14360
def main():
    N = int(input())
    d = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}
    for n in range(N):
        d[input()] += 1

    for k, v in d.items():
        print(k, 'x', v)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9124
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
cost=0
for i in range(x,n+1):
    if i in a:
        cost+=1
ans=cost
cost2=0
for i in range(x,0,-1):
    if i in a:
        cost2+=1
ans=min(ans,cost2)
print(ans)

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

int main() {
    ll x;
    cin>>x;
    ll hap_500 = x/500;
    x %= 500;
    ll hap_5 = x/5;
    ll ans = hap_500*1000 + hap_5*5;
    cout<<ans<<endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &&i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(a) ((int)a.size())
#define pow2(n) (n * n)
#define int ll
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using priority_queuel = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-9;
ll mod = static_cast<ll>(1e9 + 7);
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class F>
class FixPoint : private F {
public:
    explicit constexpr FixPoint(F &&f) : F(std::forward<F>(f)) {}
    template <class... Args>
    constexpr decltype(auto) operator()(Args &&... args) const { return F::operator()(*this, std::forward<Args>(args)...); }
};
template <class F>
constexpr decltype(auto) funcs(F &&f) { return FixPoint<F>{std::forward<F>(f)}; }
template <class T>
std::vector<T> vecs(int n, T &&val) { return std::vector<T>(std::forward<int>(n), std::forward<T>(val)); }
template <class... Args>
decltype(auto) vecs(int n, Args &&... args) { return std::vector<decltype(vecs(std::forward<Args>(args)...))>(std::forward<int>(n), vecs(std::forward<Args>(args)...)); }
template <class V, class T>
void fill(V &x, const T &val) { x = val; }
template <class V, class T>
void fill(vector<V> &vec, const T &val) {
    for (auto &&v : vec)
        fill(v, val);
}

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    rep(i, k) {
        vector<int> cnt(n, 0);
        rep(i, n) {
            cnt[max(0LL, i - a[i])] += 1;
            if (i + a[i] + 1 < n) cnt[i + a[i] + 1] -= 1;
        }

        rep(i, n - 1) cnt[i + 1] += cnt[i];
        bool ok = true;
        rep(i, n) {
            a[i] = cnt[i];
            if (a[i] != n) ok = false;
        }
        if (ok) break;
    }

    rep(i, n) cout << a[i] << (i < n - 1 ? ' ' : '\n');
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout.flush();
    return 0;
}

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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

void solve() {
  string s;
  cin >> s;
  if (s == "zyxwvutsrqponmlkjihgfedcba") {
    cout << "-1" << endl;
    return;
  }
  if (s.size() != 26) {
    vector<int> cnt(256);
    for(int i = 0; i < s.size(); i++) {
      cnt[s[i]]++;
    }
    for(int i = 'a'; i <= 'z'; i++) {
      if (!cnt[i]) {
        cout << s << (char)i << endl;
        return;
      }
    }
  }
  set<string> S;
  for (int i = 0; i < s.size(); i++) {
    for(int j = i + 1; j < s.size(); j++) {
      if (s[i] < s[j]) {
        string ss = s;
        swap(ss[i], ss[j]);
        ss = ss.substr(0, i + 1);
        S.insert(ss);
      }
    }
  }
  cout << *S.begin() << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(16);
  solve();
  return 0;
}

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

int main(){
    int n ;
    cin >> n ;
    vector<int> a(n) ;
    for (size_t i = 0; i < n; i++)
    {
        cin >> a.at(i) ;
    }
    vector<int> c ;
    c.push_back(a.at(0)) ;
    int min = a.at(0) ;
    for (size_t i = 1; i < n; i++)
    {
        bool newcolor = false ;
        if (a.at(i) <= min)
        {
            newcolor = true ;
        }
        
        
            
        
        if (newcolor == true)
        {
            c.push_back(a.at(i)) ;
        }
        else
        {
            for (int j = 0; j < c.size(); j++  )
            {
                if (c.at(j) < a.at(i))
                {
                    c.at(j) = a.at(i) ;
                    newcolor = false ;
                    break ;
                }
            }
           
        }
         min = c.at(c.size() - 1) ;
        
    }
    cout << c.size() << endl ;
    
}

Measured memory_bytes: 1276
#include <iostream>
#include <set>
#include <numeric> 
#include <vector> 
#include <algorithm>
#include <cstring>
#include <map>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int sz = 2e5 + 10;
int k, n;
int ar[sz];

int distance(int x, int y) {
    if (y >= x) {
        return y - x;
    }
    return y + k - x;
}

int next_index(int x) {
    return (x + 1) % n;
}

int main() {

    while (cin >> k >> n) {
       for (int i = 0; i < n; i++) {
           cin >> ar[i];
       }
       int ans = distance(ar[0], ar[n - 1]);
       int s = 0, e = n - 1, nx;
       int h = ans;
       for (int i = 0; i < n; i++) {
           nx = next_index(s);
           h -= distance(ar[s], ar[nx]);
        //    cerr << ar[s] << " " << ar[nx] << ": ";
        //    cerr << distance(ar[s], ar[nx]) << "\n";
           s = nx;
           nx = next_index(e);
           h += distance(ar[e], ar[nx]);
        //    cerr << ar[e] << " " << ar[nx] << ": ";
        //    cerr << distance(ar[e], ar[nx]) << "\n";
           e = nx;
           ans = min(ans, h);
       }
       cout << ans << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pow_mod(ll fi,ll se,ll mod){
  if(se==0){
    return 1;
  }
  if(se%2){
    return pow_mod(fi,se-1,mod)*fi%mod;
  }
  ll t=pow_mod(fi,se/2,mod);
  return t*t%mod;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

vector<pair<int,int>> Dir={{-1,0},{1,0},{0,1},{0,-1}};
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/


int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  if(a>=b&&a>=c){
    op(b+c);
  }else if(b>=a&&b>=c){
    op(a+c);
  }else{
    op(a+b);
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String s = sc.nextLine();
			String t = sc.nextLine();
			Map<Character, Character> map1 = new HashMap<Character, Character>(s.length());
			Map<Character, Character> map2 = new HashMap<Character, Character>(s.length());

			for (int i = 0; i < s.length(); i++) {
				char tmps = s.charAt(i);
				char tmpt = t.charAt(i);
				if (map1.containsKey(tmps)) {
					if (!map1.get(tmps).equals(tmpt)) {
						System.out.println("No");
						return;
					}
				} else {
					map1.put(tmps, tmpt);
				}
				if (map2.containsKey(tmpt)) {
					if (!map2.get(tmpt).equals(tmps)) {
						System.out.println("No");
						return;
					}
				} else {
					map2.put(tmpt, tmps);
				}
			}
			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 32324
#include<cstdio>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<queue>
using namespace std;
#define MAXN 1005
struct node{
    int x,y,step;
    node(int x=0,int y=0,int step=0):x(x),y(y),step(step) {}
};
char mp[MAXN][MAXN];
int vis[MAXN][MAXN];
int w,h,n;
int dir[10][10]={{1,0},{-1,0},{0,1},{0,-1}};
int bfs(node n1,node n2){
   memset(vis,0,sizeof(vis)); 
   queue<node>q;
   q.push(n1);
   while(!q.empty()){
       node tn=q.front();
       q.pop();
       for(int i=0;i<4;i++){
           int tx=tn.x+dir[i][0],ty=tn.y+dir[i][1];
           if(tx<0 || tx>=h || ty<0 || ty>=w) continue;
           if(vis[tx][ty]) continue;
           vis[tx][ty]=1;
           if(tx==n2.x && ty==n2.y) return tn.step+1;
           if(mp[tx][ty]!='X') q.push(node(tx,ty,tn.step+1));
       }
   }
} 
int main(){
    while(~scanf("%d%d%d",&h,&w,&n)){
        node n1,n2;
        for(int i=0;i<h;i++) scanf("%s",mp[i]);
        int ans=0;
        for(int i=0;i<h;i++) 
            for(int j=0;j<w;j++){
                if(mp[i][j]=='S') n1=node(i,j,0);
                if(mp[i][j]-'0'==1) n2=node(i,j,0);
            }
        ans+=bfs(n1,n2);
        for(int i=0;i<n-1;i++){
            for(int j=0;j<h;j++){
                for(int k=0;k<w;k++){
                    if(mp[j][k]-'0'==i+1) n1=node(j,k,0);
                    if(mp[j][k]-'0'==i+2) n2=node(j,k,0);
                }
            }
            ans+=bfs(n1,n2);
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

struct Point{
  double x;
  double y;
};

void koch(int , struct Point , struct Point);

int main(){
  struct Point a, b;
  int n;

  scanf("%d", &n);
  if(n<0 || n>6) exit(1);

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%.8f %.8f\n", a.x, a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);

  return 0;
}

void koch(int n, struct Point a, struct Point b){
  struct Point s, t, u;
  double th = M_PI * 60.0/180.0;
  
  if(n == 0) return ;

  s.x = (2.0 * a.x + 1.0 * b.x)/3.0;
  s.y = (2.0 * a.y + 1.0 * b.y)/3.0;
  t.x = (1.0 * a.x + 2.0 * b.x)/3.0;
  t.y = (1.0 * a.y + 2.0 * b.y)/3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(n-1, a, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n-1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n-1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n-1, t, b);

  return ;
}

  



Measured memory_bytes: 2040
#include<iostream>
#include<sstream>
#include<iomanip>
#include<bitset>
#include<map>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
using namespace std;
int main(){
  string s;
  cin>>s;
  s.at(3)='8';
  ou(s);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>

using namespace std;

int main(){

  string a, b;

  cin>>a>>b;

  a+=b;

  int n=stoi(a);

  for(int i=0;i<1000;i++){
    if(i*i==n){
      cout<<"Yes"<<endl;
      return 0;
    }
  }

  cout<<"No"<<endl;

  return 0;
}


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

const int MAX_ = 60;

int main() {
    ll ans = 0;
    ll N;
    ll mod = pow(10, 9);
    mod += 7;
    cin >> N;
    vector<ll> A(N, 0);
    // i桁目のbitが1の個数
    ll bit1_kazu[MAX_] = {0};
    rep(i, N) {
        cin >> A[i];
    }
    rep(i, N) {
        ll temp_int = A[i];
        ll biti = 0;
        while(temp_int > 0) {
            if (A[i] & (1ll << biti)) {
                // A[i]のbiti桁目が1のとき
                bit1_kazu[biti] += 1;
            }
            temp_int = temp_int >> 1;
            biti += 1;
        }
    }
    rep(i, MAX_) {
        // この桁の単位
        ll unit = pow(2, i);
        ll kazu0 = N-bit1_kazu[i];
        // cout << unit << "  " << bit1_kazu[i] << "  " << kazu0 << endl;
        ans += (unit%mod) * ((bit1_kazu[i] * (N-bit1_kazu[i]))%mod);
    }
    // cout << a << endl;
    // cout << ans << endl;
    ans = ans % mod;
    cout << ans << endl;
    return 0;
}
// 103715602
// 442382131

//2147483648 
//9375105820

/*
10
3 14 159 2653 58979 323846 2643383 27950288 419716939 9375105820

103715602
*/

Measured memory_bytes: 2560
// #pragma comment(linker,"/STACK:1024000000,1024000000")
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b) - 1; i >= (a); --i)
#define reT() int T; cin >> T; rep(t, 0, T)
#define de(x) cout << #x << " = " << x << endl
#define dd(x) cout << #x << " = " << x << " "
#define pw(x) (1ll<<(x))
#define modadd(a,b) {a+=b;a%=MOD;}
#define modmul(a,b) {a*=b;a%=MOD;}
#define LL long long
#define IN freopen("in", "r", stdin)
#define OUT freopen("out", "w", stdout)
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii > vii;
const int inf = 0x3f3f3f3f;

LL N, A, B, C, D;
map<LL, LL> dp;
LL dfs(LL n) {
	if (n == 0) return 0;
	if (n == 1) return D;
	if (dp.count(n)) return dp[n];

	dp[n] = (LL)inf * inf;
	if (dp[n] / D >= n)
		dp[n] = min(dp[n], n*D);

	LL lt, rt;
	lt = n / 2;
	rt = (n + 1) / 2;
	dp[n] = min(dp[n], dfs(lt) + A + (n - lt * 2)*D);
	dp[n] = min(dp[n], dfs(rt) + A + (rt * 2 - n)*D);

	lt = n / 3;
	rt = (n + 2) / 3;
	dp[n] = min(dp[n], dfs(lt) + B + (n - lt * 3)*D);
	dp[n] = min(dp[n], dfs(rt) + B + (rt * 3 - n)*D);

	lt = n / 5;
	rt = (n + 4) / 5;
	dp[n] = min(dp[n], dfs(lt) + C + (n - lt * 5)*D);
	dp[n] = min(dp[n], dfs(rt) + C + (rt * 5 - n)*D);
	return dp[n];
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	reT() {
		cin >> N >> A >> B >> C >> D;
		dp.clear();
		cout << dfs(N) << endl;
	}
	return 0;
}


Measured memory_bytes: 4436
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <queue>
# include <stack>
# include <map>
# include <math.h>
# include <algorithm>
using namespace std;
# define MAXN 55
# define MAXM 100005
# define INF 1000000000
# define MIN(a,b) (a)>(b)?(b):(a)
# define MAX(a,b) (a)<(b)?(b):(a)
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
typedef long long LL;
int _MAX(int a, int b){return a>b?a:b;}
int _MIN(int a, int b){return a>b?b:a;}


int main()
{
    int n, x;
    LL ans=0, sum=0;
    scanf("%d",&n);
    FO(i,0,n) {
        scanf("%d",&x);
        if (x) sum+=x;
        else ans+=sum/2, sum=0;
    }
    ans+=sum/2;
    printf("%lld\n",ans);
    return 0;
}


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

int main()
{
        ll X, N; cin >> X >> N;
        vector<ll> p(102, 0);
        for (int i = 0; i < N; ++i) {
                ll tmp = 0;
                cin >> tmp;
                p[tmp]++;
        }

        ll a = 0;
        ll ans = 0;
        for (int i = 0; i <= 101; ++i) {

                if (p[i] == 0) {

                ll diff = abs(i-X);

                if (i == 0) {
                        a = diff;
                        ans = i;
                }
                else if (a > diff) {
                        a = diff;
                        ans = i;
                }
                }
        }
        cout << ans << endl;

}


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

int main(){
    int n ;
    cin >> n ;
    vector<int> d(n) ;
    rep(i,n) cin >> d.at(i) ;
    int count = 0 ;
    int max_d = 0 ;
    sort(d.begin(),d.end()) ;
    rep(i,n){
        if( max_d < d[i] ){
            count++ ;
            max_d = d[i] ;
        }
    }
    cout << count <<endl ;
}
    


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pci pair<char, int>
#define pic pair<int, char>
#define plvl pair<long long, vector<long long> >
#define pcvc pair<char, vector<char> >


using namespace std;

const int mod = 1e9 + 7;

ll gcd(ll a, ll b) {
	if(b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

template <typename T>
void show1(vector<T> dp) {
	for(auto d : dp) {
		cout << d << " ";
	}
	cout << "\n";
}

template <typename T>
void show2(vector<vector<T> > dp) {
	for(auto d : dp) {
		for(auto dd : d) {
			cout << dd << " ";
		}
		cout << "\n";
	}
}

void executeCode() {
	ll r ,c, k, cnt = 0;
	cin >> r >> c >> k;
	vector<vector<char> > vec(r, vector<char>(c));
	for(ll i = 0 ; i < r ; i++) {
		for(ll j = 0 ; j < c ; j++) {
			cin >> vec[i][j];
		}
	}
	for(ll val1 = 0 ; val1 < pow(2, r) ; val1++) {
		for(ll val2 = 0; val2 < pow(2, c) ; val2++) {
			ll cb = 0;
			for(ll i = 0 ; i < r ; i++) {
				for(ll j = 0 ; j < c ; j++) {
					if(((val1 >> i) & 1) * ((val2 >> j) & 1) * (vec[i][j] == '#') == 1) {
						cb++;
					}
				}
			}
			if(cb == k) {
				cnt++;
			}
		}
	}
	cout << cnt << "\n";
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int tt = 1;
	// cin >> tt;
	while(tt--) {
		executeCode();	
	}
	return 0;
}

Measured memory_bytes: 4060
#include<bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using lint = long long;//
template <typename T>
T sq (T x) {
  return x * x ;
}
signed main () {
  lint X;
  cin >> X;
  int A1,B1;
  int A2,B2;
  // cout << X << endl;
if(X == 1){
cout << 0 << " " << -1 << endl;
return 0;
}
  for(int i = 1; i < sqrt(X); i++){
    if(X%i == 0){
      // cout << "i" << sqrt(X) << endl;
      rep2(j,-100,sqrt(sqrt(5*X))){
        // A1 = j;
        // B1 = A1 - i;
        B2 = j;
        A2 = B2 + i;
          // lint eq1 = sq(sq(A1)) + sq(sq(B1)) 
          lint eq2 = sq(sq(A2)) + sq(sq(B2)) 
          + sq(A2)*sq(B2) + A2*B2*(sq(A2)+ sq(B2)); 
        // if(eq1 == X/i){
        //   cout << A1 << " " << B1 << endl;
        //   return 0;
        // }
        if(eq2 == X/i){
          cout << A2 << " " << B2 << endl;
          return 0;
        }
      }
    }
  }
          return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll h,w;cin>>h>>w;
    for(ll i=1;i<=h;i++){
        for(char ch='A';ch<=char('A'+w-1);ch++){
            string s;cin>>s;
            if(s=="snuke")return cout<<ch<<i , 0;
        }
    }
}

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

int main()
{
    int A, B;
    scanf("%d %d", &A, &B);
    if (B%A == 0)
    {
        printf("%d", A+B);
    }
    else 
    {
        printf("%d", B-A);
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
ll n,m,timer;
const ll MAX = 100000;
vector<ll> vec[MAX];
vector<ll> visited(MAX,0),prenum(MAX),parent(MAX),lowest(MAX);
void dfs(ll current,ll prev){
  prenum[current] = lowest[current] = timer;
  timer++;
  visited[current] = 1;
  for(auto itr:vec[current]){
    if(!visited[itr]){
      //ノードcurrentかたノードnextへ訪問する直前の処理
      parent[itr] = current;
      dfs(itr,current);
      //ノードnextの探索が終了した直後の処理
      chmin(lowest[current],lowest[itr]);
    }else if(itr != prev){
      //エッジcurrent --> next がback-edgeの場合の処理
      chmin(lowest[current],prenum[itr]);
    }
  }
  //ノードcurrentの探索が終了した後の処理
}
void art_points(){
  timer = 1;
  // lowestの計算
  dfs(0,-1); // 0 == root

  set<ll> ap;
  ll np = 0;
  REP(i,1,n){
    ll p = parent[i];
    if(p == 0){
      np++;
    }else if(prenum[p] <= lowest[i]){
      ap.insert(p);
    }
  }

  if(np > 1){
    ap.insert(0);
  }

  for(auto itr:ap){
    cout << itr << endl;
  }
}
int main(){
  cin >> n >> m;
  rep(i,m){
    cin >> t1 >> t2;
    vec[t1].push_back(t2);
    vec[t2].push_back(t1);
  }
  art_points();
}


Measured memory_bytes: 10104
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    sc.next();
    int maxProfit = 0;
    int minPrice = -1;
    int count = 0;
    for (int i = 0; i < n; i++) {
      int a = sc.nextInt();
      if (minPrice == -1 || a < minPrice) {
        minPrice = a;
      } else if (a - minPrice > maxProfit) {
        maxProfit = a - minPrice;
        count = 0;
      }
      if (a - minPrice == maxProfit) {
        count += 1;
      }
    }
    sc.close();

    System.out.println(count);
  }
}


Measured memory_bytes: 48952
#include <stdio.h>

int main()
{
	int W, H, x, y, r;
	scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
	if (x + r <= W && y + r <= H && x - r >= 0 && y - r >= 0)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000000
#define FOR(i, a, b, c) for (int i = (a); i <= (b); i += (c))
#define FORD(i, a, b, c) for (int i = (a); i >= (b); i -= (c))
#define FORl(i, a, b, c) for (ll i = (a); i <= (b); i += (c))
#define FORDl(i, a, b, c) for (ll i = (a); i >= (b); i -= (c))
using namespace std;
ll solve (int n, int k) {
	ll res = 0;
	FOR(i, k + 1, n, 1) {
		int low = (n - i + 1) / i + 1;
		int high = (n - k) / i + 1;
		if (low + 1 < high) {
			res += (ll)(low + 1 + high - 1) * (high - 1 - (low + 1) + 1) / 2;
		}
		if (low == high) {
			int rl = (n - i + 1) % i;
			int rh = (n - k) % i;
			res += (ll)(rh - rl + 1) * low;
		} else {
			int rl = i - ((n - i + 1) % i);
			int rh = ((n - k) % i) + 1;
			res += (ll)rl * low + (ll)rh * high;
		}
	}
	if (k == 0) res -= n;
	return res;
}
int main () {
	int n, k;
	scanf("%d %d", &n, &k);
	printf("%lld\n", solve(n, k));
	return 0;
}

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

class Main {
    static BufferedReader br;

    private static void nextArr(int[] h) throws Exception {
        String[] parts = br.readLine().split(" ");
        for(int i = 0; i < h.length; i++) h[i] = Integer.parseInt(parts[i]);
    }

    private static int nextInt() throws Exception {
        return Integer.parseInt(br.readLine());
    }

    private static void print(Object... vals) {
        for(int i = 0; i < vals.length; i++) {
            if (i != vals.length - 1) {
                System.out.print(vals[i] + ",");
            } else {
                System.out.print(vals[i]);
            }
        }
        System.out.println();
    }

    public static void main(String[] args) throws Exception {
        br = new BufferedReader(new InputStreamReader(System.in));
        int n = nextInt();
        int[] h = new int[n];
        nextArr(h);
        int[] dp = new int[n];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;
        dp[1] = Math.abs(h[1] - h[0]);
        for(int i = 2; i < n; i++)
            for(int j = 1; j <= 2; j++)
                dp[i] = Math.min(dp[i], dp[i - j] + Math.abs(h[i] - h[i - j]));
        print(dp[n - 1]);
    }
}


Measured memory_bytes: 34904
function *main() {
  
  const N = +(yield);
  const A = (yield).split(" ").map(s => +s);
  
  const avg = A.reduce((a, b) => a + b) / N;
  const P = Math.round(avg);
  
  const sum = A.reduce((t, x) => t + (x - P)**2, 0);
  
  console.log(sum);
  
}

const iter = main();
iter.next();
require("readline").createInterface({input: process.stdin}).on("line", s => iter.next(s));


Measured memory_bytes: 30100
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double PI = 3.14159265358979323846;
typedef long long ll;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) for (ll i = 0; i < (n); ++i)

int main() {
  ll n, counter = 0;
  string s;
  cin >> n >> s;
  //   REP(i, n) cin >> v[i];
  for (ll i = 0; i <= 9; ++i) {
    for (ll j = 0; j <= 9; ++j) {
      for (ll k = 0; k <= 9; ++k) {
        ll l = 0;
        for (; l < n; ++l) {
          if (s[l] == i + '0') {
            ++l;
            break;
          }
        }
        for (; l < n; ++l) {
          if (s[l] == j + '0') {
            ++l;
            break;
          }
        }
        for (; l < n; ++l) {
          if (s[l] == k + '0') {
            break;
          }
        }
        if (l < n) counter++;
      }
    }
  }
  cout << counter << endl;
  return 0;
}

Measured memory_bytes: 256
'use strict'

const main = input => {
	const args = input.split('\n')
	const yyyy = args[0].slice(0, 4)
	const mm = args[0].slice(5, 7)
	const dd = args[0].slice(8, 10)
	if (parseInt(`${yyyy}${mm}${dd}`, 10) <= 20190430) console.log('Heisei')
	else console.log('TBD')
}

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


Measured memory_bytes: 7372
import java.util.Scanner;
public class Main{
    
    public void solve(){
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        if(a<b){
            System.out.print("a < b");
        }else if(a>b){
            System.out.print("a > b");
        }else if(a==b){
            System.out.print("a == b");
        }
   
        System.out.println();
    }
    
    public static void main(String[] args){
        Main obj = new Main();
        obj.solve();
    }
}

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

int main(){
  string S, T;
  cin >> S >> T;
  int count = 0;
  
  for (int i = 0; i < 3; i++){
    if (S.at(i) == T.at(i)){
      count++;
    }
  }
  
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int MAXN = 2e5 + 10;
int n;
char s[MAXN];
int v[MAXN];
int p[2][MAXN];
int b[2] , g[2];
int r[MAXN];

int main(){
	cin >> n >> s;
	int cnt = 0;
	for(int i = 0 ; i < n ; ++ i){
		v[i] = s[i] - '0';
		cnt += v[i];
	}
	if(cnt >= 1)
		b[1] = cnt - 1;
	else
		b[1] = -1;
	if(cnt < n)
		b[0] = cnt + 1;
	else
		b[0] = -1;
	for(int i = 0 ; i < 2 ; ++ i){
		if(b[i] > 0){
			p[i][0] = 1 % b[i];
			for(int k = 1 ; k < n ; ++ k)
				p[i][k] = p[i][k - 1] * 2 % b[i];
			g[i] = 0;
			for(int k = 0 ; k < n ; ++ k)
				g[i] = (g[i] * 2 + v[k]) % b[i];
		}
	}
	r[0] = 0;
	for(int i = 1 ; i <= n ; ++ i){
		int t = 0;
		for(int j = 0 ; (1 << j) <= i ; ++ j)
			if(i & (1 << j))
				t ++;
		r[i] = r[i % t] + 1;
	}
	for(int i = 0 ; i < n ; ++ i){
		if(b[v[i]] == 0)
			printf("0\n");
		else{
			int now = g[v[i]];
			if(v[i])
				now = (now + b[v[i]] - p[v[i]][n - i - 1]) % b[v[i]];
			else
				now = (now + p[v[i]][n - i - 1]) % b[v[i]];
			printf("%d\n" , r[now] + 1);
		}
	}
	return 0;
}

Measured memory_bytes: 6976
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
#include<iostream>
#include<cmath>

struct Range {
	int min, max;
	Range intersection(const Range& that) const {
		if (!is_valid() || !that.is_valid()) {
			return *this;
		}
		else {
			return Range{ std::max(min, that.min), std::min(max, that.max) };
		}
	}
	bool is_valid() const {
		return min <= max;
	}
};
struct Point {
	int x, y;
	int manhattan_distance(const Point& that) const {
		return std::abs(x - that.x) + std::abs(y - that.y);
	}
};
int main() {
	int width, height, n; std::cin >> width >> height >> n;
	std::vector<std::vector<Range>> state(height, std::vector<Range>(width, Range{ INT_MIN, INT_MAX }));
	for (auto i = 0; i < n; ++i) {
		int x, y, z; std::cin >> x >> y >> z;
		const Point origin{ x - 1, y - 1};
		for (auto w = 0; w < width; ++w) for (auto h = 0; h < height; ++h) {
			state[h][w] = state[h][w].intersection(Range{ z - origin.manhattan_distance(Point{w, h}), z + origin.manhattan_distance(Point{w, h}) });
		}
	}
	int sum_height = 0;
	for (auto w = 0; w < width; ++w) for (auto h = 0; h < height; ++h) if (!state[h][w].is_valid()) {
		std::cout << "No\n";
		return 0;
	}
	else {
		sum_height += state[h][w].min;
	}
	std::cout << sum_height << '\n';

}


Measured memory_bytes: 3192
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

LLI power(LLI a, LLI b) { LLI res = 1; while (b > 0) { if (b & 1)res = res * a ; a = a * a ; b >>= 1; }return res; }

int main() {
    cout << fixed << setprecision(10);
    int N,K;
    cin >> N >> K;
    REP(i, 1000000000) {
        if (N < power(K, i + 1)) {
            cout << i+1;
            return 0;
        }
    }
    return 0;
}

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

int main() {
  
  int n;
  cin >> n;
  double point[2][n];
  
  double wa = 0;
  double ans;
  
  for(int i=0; i<n; i++){
    cin >> point[0][i] >> point[1][i];
  }
  
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      wa += sqrt((point[0][i]-point[0][j])*(point[0][i]-point[0][j])
                +(point[1][i]-point[1][j])*(point[1][i]-point[1][j]));
     //各ポイントの距離を入れる
    }
  }
  
  ans = wa*2/n;
  cout << std::setprecision(10) << ans << endl;

}
  
      


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;
static const int MAX =200000;

int main(){
    int R[MAX],n;

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

    int maxv = -2000000000;
    int minv = R[0];

    for (int i =1; i < n; i++){
        maxv = max(maxv,R[i]-minv);
        minv = min(minv,R[i]);

    }
    cout << maxv <<endl;

    return 0;

}


Measured memory_bytes: 3884
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main(int argc, char *argv[])
{
    double r;
    cin >> r;

    double l = 2 * M_PI * r;
    double a = (l * r) / 2;
    cout << fixed << setprecision(5) << a << " " << l << endl;

    return 0;
}

Measured memory_bytes: 3292
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.StringTokenizer;

public class Main  implements Runnable {
	int [] ans_ar; 
	public static void main(String[] args) {
		new Thread(null, new Main(), "", 32 * 1024 * 1024).start(); //
	}
	public void run() {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		String str = sc.next();
		char[] c = str.toCharArray();
		int[] ar = new int[n];
		
		int ch = 0;
		
		for (int i = 1; i < n; i++) {
			if(c[i-1] != c[i])
			{
				ch++;
			}
		}
		ch -= 2*k;
		int ans = n - 1 - ch;
		if(ans > n-1)
		{
			ans = n-1;
		}

		out.println(ans);
		out.flush();
	}




    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;
        public FastScanner(String in) {
        	StringReader sr = new StringReader(in);
            reader = new BufferedReader(new BufferedReader(sr));
            tokenizer = null;
        }
        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }
        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
    }
}

Measured memory_bytes: 27216
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



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

  int l, r, d;
  cin >> l >> r >> d;

  int ans = 0;
  FOR(i, l, r + 1) if (i % d == 0) ans++;
  cout << ans << '\n';

  




  
  return 0;
}

Measured memory_bytes: 3608