akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;

#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=1000002;
 
vector<int>adj[N];
int dp[N];
 
int dfs(int u,int p){
	int sum=0;
	for(auto i:adj[u]){
		if(i!=p){
			sum^=dfs(i,u);
		}
	}
	return dp[u]=sum+1;
}
 
void solve(){
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++){
		int x,y;
		cin>>x>>y;
		x--;y--;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	dfs(0,-1);
	int val=dp[0];
	if(val!=1){
		cout<<"Alice";
	}
	else{
		cout<<"Bob";
	}
}
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


Measured memory_bytes: 32896
/*input
10 6
1000000000 1000000000 1000000000 1000000000 1000000000 0 0 0 0 0
*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef vector<pi> vpi;
typedef vector<vpi> vpii;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<pd> vpd;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef std::string str;
typedef std::vector<str> vs;

#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"

const int MOD = 1000000007;
const ll INF = std::numeric_limits<ll>::max();
const int MX = 100101;
const ld PI = 3.14159265358979323846264338327950288419716939937510582097494L;

template<typename T>
pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x + b.x, a.y + b.y); }
template<typename T>
pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x - b.x, a.y - b.y); }
template<typename T>
T operator*(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.x + a.y * b.y); }
template<typename T>
T operator^(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.y - a.y * b.x); }

template<typename T>
void print(vector<T> vec, string name = "") {
	cout << name;
	for (auto u : vec)
		cout << u << ' ';
	cout << '\n';
}

vl fac(MX);
vl inv(MX);

ll mypow(ll a, ll b)
{
	ll res = 1;
	a %= MOD;

	while (b)
	{
		if (b & 1)
			res = (res * a) % MOD;

		b >>= 1;
		a = (a * a) % MOD;
	}
	return res;
}

void make() {
	fac[0] = fac[1] = 1;
	inv[0] = inv[1] = 1;

	for (int i = 2; i < MX; ++i)
	{
		fac[i] = (fac[i - 1] * i) % MOD;
		inv[i] = (inv[i - 1] * mypow(i, MOD - 2)) % MOD;
	}
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int N, K;
	cin >> N >> K;
	vl sk(N);
	for (int i = 0; i < N; ++i)
		cin >> sk[i];


	make();
	sort(sk.begin(), sk.end());

	ll plus = 0, minus = 0;

	for (int i = K - 1; i < N; ++i)
		plus = (plus + ((((sk[i] * fac[i]) % MOD) * inv[K - 1]) % MOD) * inv[i - K + 1]) % MOD;

	sort(sk.rbegin(), sk.rend());
	for (int i = K - 1; i < N; ++i)
	{
		minus = (minus + ((((sk[i] * fac[i]) % MOD) * inv[K - 1]) % MOD) * inv[i - K + 1]) % MOD;
	}

	ll ats = plus - minus;
	while (ats < 0) ats += MOD;
	ats %= MOD;
	printf("%lld\n", ats);
}

/* Look for:
* special cases (n=1?)
* overflow (ll vs int?)
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* array bounds
*/


Measured memory_bytes: 2560
nk = input()
nk = nk.split()
[n,k] = nk
n, k = int(n), int(k)
ans = 0
for s in range(k, n + 2):
    temp = s*(n-s+1) + 1
    ans += temp
    if(ans > 1000000007):
        ans = ans % 1000000007
print(ans)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define pb push_back
using namespace std;

pair<int, int> point={0,0};
vector<int> adj[200005];

void dfs(int node, int fa, int dist)
{
	point=max(point, {dist, node});
	for(auto i:adj[node])
	{
		if(i==fa) continue;
		dfs(i, node, dist+1);
	}
}

signed main()
{
	int n;
	cin>>n;
	for(int i=1; i<n; i++)
	{
		int u, v;
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	dfs(1, 1, 1);
	dfs(point.second,point.second,1);
	if(point.first%3==2)
	{
		cout<<"Second";
	}
	else
	{
		cout<<"First";
	}
}

Measured memory_bytes: 20608
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const int N = 1e6 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

#define int ll

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


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int x, y, dp[N], ans, f[N * 2];
inline int power(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1) {
            res *= a;
            res %= mod;
        }
        a *= a;
        a %= mod;
        b >>= 1;
    }
    return res;
}
main() {
    file("censor");
    ios;
    cin >> x >> y;
    f[0] = 1;
    fo(i, 1, max(x, y) * 2, 1) f[i] = f[i - 1] * i, f[i] %= mod;
    fo(i, 0, x, 1) {
        int a = i;
        int b = (x - a) / 2;
        if ((x - a) % 2) continue;
        if (a + 2 * b == x and b + 2 * a == y) {
            int add = f[a + b];
            add %= mod;
            add *= power(f[a], mod - 2);
            add %= mod;
            add *= power(f[b], mod - 2);
            add %= mod;
            ans += add;
            ans %= mod;
        }
    }
    cout << ans;
    return 0;
}
/**
x = a + 2*b
y = b + 2*a
*/


Measured memory_bytes: 16640
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		double area = 0.f;
		double sum;
		double sta;
		double dev;
		double dev_w;
		double dev_sum;
		double ave;
		double var;
		boolean Judge = true;
		
		while(Judge){
			int  stu_num = scanner.nextInt();	//学生数
			if( stu_num == 0 ){
				break;
			}
			double stu[] = new double[stu_num];
			sum = 0;
			dev_sum = 0;
			dev_w = 0;
			
			//点数入れる処理
			for( int i = 0; i < stu_num ; i ++ ){
				stu[i] = scanner.nextDouble();
				sum += stu[i];
			}
			ave = sum / stu_num;		//平均
			
			//偏差を求めて2乗
			for( int i = 0; i < stu_num ; i ++ ){
				dev = ave - stu[i];
				dev_w = dev * dev;
				dev_sum += dev_w;
			}
			
			if(dev_sum != 0) {
				var = dev_sum / stu_num;		//分散
			}else {
				var = 0;
			}
			
			sta = Math.sqrt(var);
		
			System.out.println(sta);
		
		}
		
		scanner.close();
	}
}




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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }


void compute() {

}

int main() {
  ll r,D,x;
  cin >> r >> D >> x;
  REP(i,1,11) {
    x = r * x - D;
    cout << x << endl;
  }
  compute();
  return 0;
}


Measured memory_bytes: 256
fn solve(nab: &str) -> i64 {
    let mut nab = nab.split_whitespace().map(|x|x.parse::<i64>().unwrap());
    let n = nab.next().unwrap();
    let a = nab.next().unwrap();
    let b = nab.next().unwrap();
    if a>b || (a<b && n<2) { 0 }
    else { (b-a)*(n-2)+1 }
}
fn main() {
    loop {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right();
        if s=="" { break; }
        println!("{}",solve(&s));
    }
}

Measured memory_bytes: 4352
while (str = $stdin.gets(chomp:true)) != "-"
    tms = $stdin.gets(chomp:true).to_i
    shl_crd = []

    tms.times do
      shl_crd << $stdin.gets(chomp:true).to_i
    end

    shl_crd.each do | num |
      str << str.slice!(0...num)
    end

    puts str

  end



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

const int m = 2019;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    reverse(s.begin(), s.end());
    int x = 1, tot = 0;
    vector<int> cnt(m);
    ll ans = 0;
    rep(i,n) {
        cnt[tot]++;
        tot += (s[i] - '0') * x; // 累積和
        tot %= m; // 累積和のmod
        ans += cnt[tot]; // 今まででてきた累積和の数を加える(右側固定)
        x = x*10%m;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3748
#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()
typedef long long ll;
const int INF (1<<30);

int main() {
  int N; cin >> N;
  map<string, int> mp;
  int sum = 0;
  rep(i, N) {
    string s;
    int t;
    cin >> s >> t;
    sum += t;
    mp.insert(make_pair(s, sum));
  }

  string X;
  cin >> X;

  cout << sum - mp.at(X) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

#define MOD 1000000007

int N;
int a[21][21];
ll dp[(1 << 21)];

ll dfs(int male, int female)
{
    if (male == N) {
        return 1;
    }
    else if (dp[female] != -1) {
        return dp[female];
    }
    else {
        ll count = 0;
        REP(i, N) {
            if ((a[male][i] == 1) && ((female & (1 << i)) == 0) ) {
                int f = (female | (1 << i));
                count = (count + dfs(male + 1, f)) % MOD;
            }
        }
        dp[female] = count;
        return count;
    }
}

int main(int argc, char **argv)
{
    cin >> N;
    REP(i, N) REP(j, N) cin >> a[i][j];
    REP(i, (1 << 21)) dp[i] = -1;

    cout << dfs(0, 0) << endl;

    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector <int> V(N), C(N);
    for(int i = 0;i < N; i++)
        cin >> V[i];

    for(int i = 0;i < N; i++)
        cin >> C[i];

    int ans = 0;
    for(int i = 0; i < N; i++)
    {
        if(V[i] > C[i])
            ans += V[i] - C[i];
    }

    cout << ans << endl;
    return 0;  

}

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

int main(){
  int n;  cin >> n;
  vector<ll> a(n);
  for(int i=0; i<n; i++)  cin >> a.at(i);
  vector<ll> sum(n+1, 0);
  for(int i=1; i<=n; i++)
    sum.at(i) = a.at(i-1)+sum.at(i-1);
  
  ll ans = 1e+15;
  for(int i=1; i<n; i++)
    ans = min(ans, abs(sum.at(i)-(sum.at(n)-sum.at(i))));
  cout << ans << endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF = 2e9
#define LINF = 1e18
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << "=" << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO")
#define Yes(n) cout << ((n) ? "Yes" : "No")
#define PI 3.141592653589793

int main(){
        
    vector<string> s(3);

    rep(i,3)cin >> s[i];

    rep(i,3){
        cout << (char)(s[i][0]-('a'-'A'));
    }
    cout << endl;

}

Measured memory_bytes: 3596
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    let A = read![[i64]];

    let mut X = vec![0; N];

    for _ in 0..2 {
        // x[0] = x
        let mut s = 1;
        let mut t = 0;

        for i in 0..N - 1 {
            // x[i] = s * x + t
            // x[i+1] = 2*A[i] - x[i]
            //        = -s * x + (2*A[i] - t)
            s = -s;
            t = 2 * A[i] - t;
            X[i + 1] = s * X[0] + t;
            debug!((i, s, t));
        }

        // x[0] = 2 * A[N-1] - x[N-1]
        s = -s;
        t = 2 * A[N - 1] - t;

        // x[0] = s * x + t = x
        // s * x + t = x
        X[0] = t / (1 - s);
    }

    println!(
        "{}",
        X.into_iter()
            .map(|l| l.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    )
}


Measured memory_bytes: 14456
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

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

    if(b == 1) {
        cout << 0 << endl;
        return 0;
    }

    int ans = 1;
    int n = a;
    while(n < b){
        n += (a-1);
        ans++;
    }

    cout << ans << endl;
}

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

int a[3002][3002];
int dp[3003][3002][4];

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int r,c,k;
	cin >> r >> c >> k;

	for(int i = 1; i <= k; i++){
		int x,y,c;
		cin >> x >> y >> c;
		a[x][y] = c;
	}
	for(int i = 1; i <= r; i++){
		for(int j = 1; j <= c; j++){
			for(int k = 0; k <= 3; k++){
				dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j][k]);
				dp[i][j][1] = max(dp[i][j][1] , a[i][j] + dp[i - 1][j][k]);
			}
			dp[i][j][0] = max(dp[i][j][0],dp[i][j - 1][0]);
			for(int k = 1; k <= 3; k++){
				dp[i][j][k] = max({dp[i][j][k], a[i][j] + dp[i][j - 1][k - 1],dp[i][j - 1][k]});
			}
		}
	}
	cout << max({dp[r][c][0],dp[r][c][1],dp[r][c][2],dp[r][c][3]});
}


Measured memory_bytes: 355324
import bisect
n,q=map(int,input().split())
s=input()
lr=[[int(i) for i in input().split()] for j in range(q)]

li=[]
for i in range(n-1):
    if s[i]+s[i+1]=='AC':
        li+=[i]
ans=0
for l,r in lr:
    left=bisect.bisect_left(li,l-1)
    right=bisect.bisect_right(li,r-2)
    print(right-left)
    


Measured memory_bytes: 24088
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#define REP(i, N) for(int i = 0; i < N; ++i)
#define REEP(i, N) for(int i = N - 1; i >= 0; --i)
using namespace std;

int main() {
    int x, y;
    cin >> x >> y;
    while(true) {
        if(x >= y) {
            x = x % y;
            if(x == 0) {
                cout << y << endl;
                break;
            }
        } else {
            y = y % x;
            if(y == 0) {
                cout << x << endl;
                break;
            }
        }
        
    }
}

Measured memory_bytes: 3088
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
    int N;
    cin >> N;
    int ans = N % 10;
    string s;
    if (ans == 2 | ans == 4 | ans == 5 | ans == 7 | ans == 9)
    {
        s = "hon";
    }
    else if (ans == 0 | ans == 1 | ans == 6 | ans == 8)
    {
        s = "pon";
    }
    else if (ans == 3)
    {
        s = "bon";
    }

    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define lld long long
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    lld n,a,b; cin>>n>>a>>b;
    lld k=n/(a+b);
    lld gg=n%(a+b);
    lld ans=a*k;
    if(gg>=a)ans+=a;
    else ans+=gg;
    cout<<ans<<endl;

}

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

int main() {
  long long int n,m,sum=0,ave;
  cin >> n;
  for(int i=0;i<n;i++) {
    cin >> m;
    sum += m;
  }
  ave = sum/n;
  ave = floor(ave);
  cout << ave << endl;
}

Measured memory_bytes: 0
n,m = map(int, input().split())
h = list(map(int, input().split()))

from collections import defaultdict
group = defaultdict(int)
for i in range(m):
  a,b = map(int, input().split())
  if h[a-1] > h[b-1]:
    group[b-1] = 1
  elif h[a-1] == h[b-1]:
    group[a-1] = 1
    group[b-1] = 1
  else:
    group[a-1] = 1
cnt = 0
for i in range(n):
  if group[i] == 0:
    cnt += 1
print(cnt)


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

#define ll long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (ll)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 200005
int a[mxn];

int main() {
sp;
int n,k;
cin>>n>>k;
int b[n+1];
for(int i=1; i<=n; ++i)cin>>b[i];
for(int i=1; i<=k; ++i){
    int y=0;
    for(int j=1; j<=n&&b[j]<=i; ++j)
    if(a[i-b[j]]==0){
        y=1;
        break;
    }
    a[i]=y;
}
if(a[k])cout<<"First";
else cout<<"Second";
return 0;}


Measured memory_bytes: 640
#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>;

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

int main() {
    int H, W; cin >> H >> W;
    vector<string> map(H);
    rep(i, H) cin >> map[i];

    int ans = 0;
    rep(i, H) {
        rep(j, W) {
            if (map[i][j] == '#') continue;
            vector<vector<int>> dist(H, vector<int>(W, -1));
            dist[i][j] = 0;
            queue<P> que;
            que.push(make_pair(i, j));
            while (!que.empty()) {
                auto cur = que.front();
                int y = cur.first;
                int x = cur.second;
                que.pop();

                rep(k, 4) {
                    int next_y = y + dy[k];
                    int next_x = x + dx[k];
                    if (next_y < 0 || next_y >= H || next_x < 0 || next_x >= W) continue;
                    if (map[next_y][next_x] == '#') continue;

                    if (dist[next_y][next_x] == -1) {
                        que.push(make_pair(next_y, next_x));
                        dist[next_y][next_x] = dist[y][x] + 1;
                    }
                }
            }

            rep(h, H) rep(w, W) ans = max(ans, dist[h][w]);
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e5+100;
int a[N];
int main()
{
	int n;
	cin>>n;
	ll sum=0,ans=0;
	for(int i=1;i<=n;i++) cin>>a[i],sum+=a[i];
	if(sum%n==0) 
	{
		ll k=sum/n;
		for(int i=1;i<=n;i++) 
		 ans+=abs(a[i]-k)*abs(a[i]-k);
	}
	else
	{
		ll k=sum/n;
		ll ans1=0,ans2=0;
		for(int i=1;i<=n;i++)
		 ans1+=abs(a[i]-k)*abs(a[i]-k);
		k++;
		for(int i=1;i<=n;i++)
		 ans2+=abs(a[i]-k)*abs(a[i]-k);
		ans=min(ans1,ans2);
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 256
/**
  *  Worg
  */
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>

//FILE *fin = freopen("main.in", "r", stdin); FILE *fout = freopen("main.out", "w", stdout);

int main() {
    char s[10]; scanf("%s", s);

    for(int i = 0; i < (int)std::strlen(s) - 1; i++) {
        if(s[i] == 'A' && s[i + 1] == 'C') {
            printf("Yes\n"); return 0;
        }
    }
	printf("No\n"); return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007;
ll INF = 1ll << 60;

int main() {
  int k, s;
  cin >> k >> s;
  ll ans = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      if (i + j <= s && s - i - j <= k) { ans++; }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n,k;
int able[15];

bool ok(int a){
  stringstream ss;ss<<a;
  string s=ss.str();
  for(auto c:s) if(!able[c-'0']) return false;
  return true;
}

int main(){
  cin>>n>>k;
  REP(i,10) able[i]=1;
  REP(i,k){
    int a;cin>>a;
    able[a]=0;
  }
  for(int i=n;;++i){
    if(ok(i)){
      printf("%d\n",i);
      return 0;
    }
  }


  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 100000000;
const int MAX_N = 100;
typedef pair<int , int> P;
typedef long long ll;
 
int main () {
  int N;
  cin >> N;
  ll ans = 0;
  ll max = 0;
  ll A[N+1];
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    if (i == 0) {
      max = A[i];
    }
    if (i > 0) {
      if (max > A[i]) {
        ans += max - A[i];
      } else {
        max = A[i];
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 5256
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn to_bit(a: Vec<usize>) -> usize {
    let mut r = 0;
    for x in a.iter() {
        r |= 1usize << (x - 1);
    }
    r
}

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let m: usize = sc.cin();

    let mut costs = vec![];
    let mut opens = vec![];

    for _ in 0..m {
        let a: i64 = sc.cin();
        let b: usize = sc.cin();
        let o = to_bit( (0..b).map(|_| sc.cin()).collect() );
        costs.push(a);
        opens.push(o);
    }

    let n2 = 1 << n;
    // trace!(&costs, &opens);
    let inf = costs.iter().sum::<i64>() + 10;
    let mut dp = vec![inf; n2];
    dp[0] = 0;
    for i in 0..n2 {
        for j in 0..m {
            dp[i | opens[j]] = min!(
                dp[i | opens[j]],
                dp[i] + costs[j]);
        }
    }
    if dp[n2 - 1] == inf {
        put!(-1);
    } else {
        put!(dp[n2 - 1]);
    }
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    string S,T;cin >> S >> T;
    cout << T << S << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  ull n,m,a,b,cnt[100001]={};
  bool flag=true;
  cin>>n>>m;
  rep(i,0,m){
    cin>>a>>b;
    cnt[a]++;
    cnt[b]++;
  }

  rep(i,1,n+1){
    if(cnt[i]%2!=0)flag=false;
  }
  if(flag){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}


Measured memory_bytes: 1024
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

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

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

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<int> a(n); rep(i, n)cin >> a[i];
	sort(all(a));
	vector<bool> b(1001001);
	int res = 0;
	for (int i = 0; i < n; ++i)
	{
		if (b[a[i]])continue;
		int x = a[i];
		if (i == n - 1)++res;
		else if (a[i] != a[i + 1])++res;
		for (int j = x; j <= 1001000; j += x)
		{
			b[j] = true;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 4312
#include <stdio.h>
#include <stdlib.h>

struct city{
  int num;
  int y;
  int p;
};

int city_compare(const void *a, const void *b){
  struct city *A = (struct city *)a;
  struct city *B = (struct city *)b;
  if(A->p > B->p) return 1;
  if(A->p < B->p) return -1;
  else return A->y - B->y;
}

int
main(int argc, char *argv[])
{
  int n, m; struct city c[100000];
  scanf("%d %d", &n, &m);
  for(int i = 0; i < m; i++){
    scanf("%d %d", &c[i].p, &c[i].y);
    c[i].num = i;
  }

  qsort(c, m, sizeof(struct city), city_compare);

  int k = 1, id[100000][2];
  for(int i = 0; i < m; i++){
    id[c[i].num][0] = c[i].p;
    id[c[i].num][1] = k++;
    if(c[i].p != c[i + 1].p) k = 1;
  }

  for(int i = 0; i < m; i++){
    printf("%06d%06d\n", id[i][0], id[i][1]);
  }

  return 0;
}
      


Measured memory_bytes: 3436
import Control.Applicative
import Data.List
import Control.Monad
strToInt s = (read :: String -> Int) s

main :: IO ()
main = do
    -- 整数の入力
    n <- readLn
    -- kaigyousuuretu
    cs <- map strToInt <$> replicateM n getLine
    -- 出力
    putStrLn . show . length $ qsort cs

qsort :: (Ord a) => [a] -> [a]
qsort [] = []
qsort (x:xs) = qsort sm ++ [x] ++ qsort la
    where
        sm = [a | a <- xs, a < x]
        la = [b | b <- xs, b > x]


Measured memory_bytes: 1020
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;
int main()
{
	string s,t;
	int f=0;
	vector<char> S;
	vector<char> T;
	cin >> s >> t;
	
	for(int i=0;i<s.size();i++){
		S.push_back(s[i]);
		T.push_back(t[i]);
	}

	for(int i=0;i<S.size();i++){
		for(int j=0;j<S.size();j++){
			if(S[j]!=T[j]){break;}
			if(j==S.size()-1){f=1;}
		}
		char tt=*(S.end()-1);
		S.pop_back();
		S.insert(S.begin(),tt);
	}

	if(f==1){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.sort()
cum_A = A[:]
for i in range(N-1):
  cum_A[i+1] += cum_A[i]
t = 0
for i in range(N-1, 0, -1):
  if A[i] <= 2 * cum_A[i-1]:
    t = i-1
  else:
    break

print(N-t)

Measured memory_bytes: 63856
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization("unroll-loops")

#include "bits/stdc++.h"
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl '\n'
#define F first
#define S second
#define IO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define cf ll testcases;cin>>testcases;while(testcases--)
#define prn(x) if(x) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define minel(x) (*min_element(all(x)))
#define maxel(x) (*max_element(all(x)))
#define cou dbg=1;cout
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
typedef vector<ld> vd;
typedef vector<pi> vp;
ll dbg=0;
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p);
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p);
template<typename A> istream& operator>>(istream& cin, vector<A> &v);
int dx[] = {-1, -1, -1,  0, 0,  1, 1, 1};
int dy[] = {-1,  0,  1, -1, 1, -1, 0, 1};

void solve(){
    ll n;
    cin>>n;
    vi arr(n+1);
    for(ll i=1;i<=n;i++) cin>>arr[i];
    vi dp(n+1,0);
    dp[2]=abs(arr[2]-arr[1]);
    for(ll i=3;i<=n;i++){
        dp[i]=min(dp[i-2]+abs(arr[i]-arr[i-2]),dp[i-1]+abs(arr[i]-arr[i-1]));
    }
    cout<<dp[n]<<endl;
}

int main(){
    IO;
    // cf
    solve();
    return 0;
}


template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { 
    if(dbg){
        return cout << "(" << p.F << ", " << p.S << ")"; 
    }else{
        return cout<<p.F<<' '<<p.S;
    }
        dbg=0;}
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
    if(dbg){
        cout << "["; for(ll i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
    }else{
        for(ll i=0;i<v.size()-1;i++) cout<<v[i]<<' ';
        return cout<<v[v.size()-1];
    dbg=0;}
}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
   cin >> p.first;
   return cin >> p.second;
}
template<typename A> istream& operator>>(istream& cin, vector<A> &v) {
   for(ll i=0;i<v.size()-1;i++) cin>>v[i];
   return cin >> v[v.size()-1];
}

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

const string NG = "UNRESTORABLE";

bool check(string T,string str){
  for(int i = 0 ; i < T.size() ; i++){
    if(str[i] == '?')continue;
    if(str[i] != T[i])return false;
  }
  return true;
}

string solve(string S,string T){
  for(int i = S.size() - T.size() ; i >= 0 ; i--){
    string substr = S.substr(i,T.size());
    if(check(T,substr)){
      string res = S;
      for(int j = 0 ; j < T.size() ; j++){
        res[i+j] = T[j];
      }
      for(int j = 0 ; j < S.size() ; j++){
        if(res[j] == '?'){
          res[j] = 'a';
        }
      }
      return res;
    }
  }
  return NG;
}

int main(){
  string S,T;
  cin >> S >> T;
  cout << solve(S,T) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <utility>
using namespace std;
#define REP(I,N) for (I=0;I<N;I++)
#define rREP(I,N) for (I=N-1;I>=0;I--)
#define rep(I,S,N) for (I=S;I<N;I++)
#define rrep(I,S,N) for (I=N-1;I>=S;I--)
#define FOR(I,S,N) for (I=S;I<=N;I++)
#define rFOR(I,S,N) for (I=N;I>=S;I--)
typedef unsigned long long ULL;
typedef long long LL;
const int INF=0x3f3f3f3f;
const LL INFF=0x3f3f3f3f3f3f3f3fll;
const LL M=1e9+7;
const LL maxn=4e5+7;
const double eps=0.00000001;
const double pi=acos(-1);
LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
template<typename T>inline T powMM(T a,T b){T ret=1;for (;b;b>>=1ll,a=a*a%M) if (b&1) ret=1ll*ret*a%M;return ret;}

int n;
int A[maxn];
LL A1,A2;
vector<int> ans;
int main(){
    int i,j,k;
    scanf("%d",&n);
    FOR(i,1,n) scanf("%d",&A[i]);
    j=1;
    FOR(i,1,n) if (A[j]<A[i]) j=i;
    if (A[j]<0){
        printf("%d\n",A[j]);
        printf("%d\n",n-1);
        rFOR(i,j+1,n) printf("%d\n",i);
        FOR(i,1,j-1) printf("1\n");
        return 0;
    }
    FOR(i,1,n){
        if (i&1) A1+=max(0,A[i]);
        else A2+=max(0,A[i]);
    }printf("%lld\n",max(A1,A2));
    if (A1<A2){
        if (n&1) ans.push_back(n),n--;
        ans.push_back(1);
        for (i=2;i<=n&&A[i]<0;i+=2)
            ans.push_back(1),ans.push_back(1);
        for (i+=2;i<=n;i+=2){
            if (A[i]>0) ans.push_back(2);
            else {
                ans.push_back(3);
                if (i==n) ans.push_back(2);
            }
        }
    }else{
        if (!(n&1)) ans.push_back(n),n--;
        for (i=1;i<=n&&A[i]<0;i+=2)
            ans.push_back(1),ans.push_back(1);
        for (i+=2;i<=n;i+=2){
            if (A[i]>0) ans.push_back(2);
            else {
                ans.push_back(3);
                if (i==n) ans.push_back(2);
            }
        }
    }
    printf("%d\n",ans.size());
    for (int v:ans) printf("%d\n",v);
}
/*
5
-1 -2 -3 -4 -5

6
1 2 3 4 5 6
*/


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


class tile{
public:
	int x;
	int y;
	char c;

	tile(int x, int y, char c) : x(x), y(y), c(c){}
};


int h, w;
char map[100][100];
stack<tile> s;
int ans = 0;


void dfs(int x, int y){
	s.push(tile(x, y, map[y][x]));
	while(!s.empty()){
		int dx[4] = { 1, 0, -1, 0 };
		int dy[4] = { 0, 1, 0, -1 };
		tile t = s.top();
		s.pop();
		map[t.y][t.x] = '.';
		for(int i = 0;i < 4;i++){
			int X = t.x + dx[i];
			int Y = t.y + dy[i];
			if(0 <= X && X < w && 0 <= Y && Y < h && t.c == map[Y][X])
				s.push(tile(X, Y, map[Y][X]));
		}
	}
	ans++;
}


void solve(){
	for(int y = 0;y < h;y++){
		for(int x = 0;x < w;x++){
			if(map[y][x] != '.') dfs(x, y);
		}
	}
}


int main(){
	while (cin >> h >> w, h | w){
		for (int y = 0; y < h; y++){
			for (int x = 0; x < w; x++){
				cin >> map[y][x];
			}
		}

		solve();

		cout << ans << endl;
		ans = 0;
	}


	return 0;
}

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

const int mod = 1000000007;

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

    int n;
    cin >> n;

    vector<int> a(n);
    rep(i,n) cin >> a[i];

    int ans = 1;
    int r = 0, g = 0, b = 0;
    for(int i = 0; i < n; i++){
        int cnt = 0;
        if(r == a[i]){
            cnt++;
            r++;
        }
        if(g == a[i]){
            if(cnt != 0) cnt++;
            else {
                cnt++;
                g++;
            }
        }
        if(b == a[i]){
            if(cnt != 0) cnt++;
            else {
                cnt++;
                b++;
            }
        }
        ans *= cnt;
        ans %= mod;
    }
    cout << ans << endl;
}

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

int main(){
	// input
	string S; cin >> S;
	// compute
	int ans = 0;
	for (int i=0; i < 3; i++){
		if(S.at(i) - '0') ans++;
	}
	// output
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
	vector<int> a;
	while (true)
	{
		int n;
		scanf("%d", &n);
		if (n == 0)
		{
			break;
		}
		else
		{
			a.push_back(n);
		}
	}
	for (int i = 0; i != a.size(); i++)
	{
		printf("Case %d: %d\n", (i + 1), a[i]);
	}
	return 0;
}

Measured memory_bytes: 2788
N=int(input())
odds = [i*2+1 for i in range(100)]
cnt=0
for odd in odds:
  #if odd==105: print(odd)
  if odd>N:
    break
  temp_cnt=0
  for lil_odd in odds:
    #if odd==105: print("lil_odd :",lil_odd)
    if lil_odd>odd:
      if temp_cnt==8:
        cnt+=1
      break
    if odd%lil_odd==0:
      #if odd==105: print("True")
      temp_cnt+=1
  #if odd==105: print("temp_cnt :",temp_cnt)
print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin >> n;
    for(int i=0;i<n;i++){
        int a;cin >> a;
        if(a%2==0){
            if(a%3!=0&&a%5!=0){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
(defun solve (s)
  (let ((n (length s))
	(cnt 0)
	(ans 0))
    (dotimes (i n)
      (when (equal (aref s i) #\W)
	(setq ans (+ ans (- i cnt)))
	(incf cnt)))
    ans))


(defun main()
  (let ((s (coerce (concatenate 'list (read-line)) 'vector)))
    (princ (solve s))
    (fresh-line)))


(main)


Measured memory_bytes: 31620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repe(i, n) for(int (i) = 0; i <= (n); (i)++)
#define repr(i, n) for(int (i) = (n); (i) > 0; --(i))
#define repre(i, n) for(int (i) = (n); (i) >= 0; --(i))
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ull N;
    cin >> N;
    cout << static_cast<ull>((N - 1) / 2) << endl;
    return 0;
}


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

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

const string YES = "Yes";
const string NO = "No";

void solve(long long D, long long T, long long S) {
    if (D <= S * T) {
        cout << YES << endl;
    } else {
        cout << NO << endl;
    }
}

int main() {
    long long D;
    scanf("%lld", &D);
    long long T;
    scanf("%lld", &T);
    long long S;
    scanf("%lld", &S);
    solve(D, T, S);
    return 0;
}


Measured memory_bytes: 3656
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>

#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;



int main(int argc, char *argv[]) {
    int i, j;
    int res = 0;
    cin >> i >> j;
    res += max(100000 * (4 - i), 0);
    res += max(100000 * (4- j ), 0);
    if (i == 1 && j == 1)
    	res += 400000;
    cout << res << endl;
}


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

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)

const ll MOD = 1000000007;

using namespace std;

pair<ll, ll> ab[100005];

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

	ll max = 0;
	REP(i, N)
	{
		cin >> ab[i].first >> ab[i].second;
		max = std::max(max, ab[i].first);
	}

	sort(ab, ab + N, [](pair<ll, ll> x, pair<ll, ll> y) {return x.second > y.second; });
	ll ans = 0;
	REP(i, N)
	{
		if (ab[i].second > max && H > 0)
		{
			H -= ab[i].second;
			ans++;
		}
	}

	if (H > 0)ans += (H + max - 1) / max;

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1920
//ABC065B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a.at(i);
	}
	int p = 1;
	int count = 1;
	for(int i=0;i<n;i++){
		p = a.at(p-1);
		if(p == 2){
			cout << count << endl;
			return 0;
		}else{
			count++;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 640
from itertools import groupby


n, m = map(int, input().split())
WA = [0] * (n + 1)
AC = [False] * (n + 1)
wanum = 0
acnum = 0
for i in range(m):
    p, s = input().split()
    if AC[int(p)]:
        continue
    if s == 'AC':
        acnum += 1
        wanum += WA[int(p)]
        AC[int(p)] = True
    elif s == 'WA':
        WA[int(p)] += 1
print(acnum, wanum)


Measured memory_bytes: 4596
import java.util.Scanner;

public class Main {
	
	static long mod = 998244353L;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		
		int []d = new int [n];
		int []p = new int [1000001];
		
		long ans = 1;
		int max = -1;
		
		for(int i = 0 ; i < n ;i++) {
			d[i] = Integer.parseInt(sc.next());
			p[d[i]]++;
			max = Math.max(d[i], max);
		}
		
		if(d[0] != 0 || p[0] != 1) {
			System.out.println(0);
			return;
		}
		
		for(int i = 1 ; i <= max ; i++) {
			ans = ans * Modpow((long)p[i-1],(long)p[i]) % mod ;
		}
		
		System.out.println(ans);	
	}
	
	static long Modpow(long a, long n) {
		long res = 1;
		while(n > 0) {
			if((n & 1) == 1) {
				res = res * a % mod;
			}
			a = a * a % mod;
			n >>= 1;
		}
		return res;
	}
}


Measured memory_bytes: 50944
program piyo
      integer,parameter :: p=8
      integer(p) :: n,m, i,j, offsetR,offsetC
      character(:),allocatable :: a,b
      integer(p),allocatable :: imA(:,:),imB(:,:),tempA(:,:)
      
      read*,n,m
      allocate( character(n)::a )
      allocate( character(m)::b )
      allocate( imA(N,N), imB(M,M), tempA(M,M) )
      do i = 1,n
        read*,a
        do j = 1,n
          if(a(j:j)=='.')then
            imA(i,j) = 1
          else
            imA(i,j) = 0
          end if
        end do
      end do
      do i = 1,m
        read*,b
        do j = 1,m
          if(b(j:j)=='.')then
            imB(i,j) = 1
          else
            imB(i,j) = 0
          end if
        end do
      end do
      
      do offsetR = 0,(N-M)
        do offsetC = 0,(N-M)
          tempA = imA(1+offsetR:M+offsetR,1+offsetC:M+offsetC)
          tempA = abs(tempA(:,:) - imB(:,:))
          if( sum(tempA(:,:))==0 )then
            print*,'Yes'
            stop
          end if
        end do
      end do
      
      print*,'No'
      
      stop
      
      do i = 1,n
        print'(*(i1,x))',ima(i,:)
      end do
      do i = 1,m
        print'(*(i1,x))',imb(i,:)
      end do
      
      
      
      end

Measured memory_bytes: 2888