akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;
///////////////////////////////////////




int main() {
	int N; cin >> N;
	map<string, int>mp;
	REP(i, N) {
		string a; cin >> a;
		mp[a]++;
	}
	vector<string>ans;
	int MAX = 0;
	for (auto itr = mp.begin(); itr != mp.end();++itr) {
		MAX = max(MAX, itr->second);
	}
	for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
		if (itr->second == MAX) {
			ans.push_back(itr->first);
		}
	}
	sort(ans.begin(), ans.end());
	for (auto a : ans) {
		cout << a << endl;
	}
	return 0;
}

Measured memory_bytes: 26868
N = int(input())
v = list(map(int, input().split()))
v.sort(reverse=True)

def saiki(*v):
    #print(*v)
    if len(v) == 1:
        return v
    elif len(v) == 2:
        return sum(v)/2
    else:
        return (saiki(*v[1:]) + v[0])/2

print(saiki(*v))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<int>> g(10, vector<int>(10));
    for(int i = 0; i < 10; i++)
    {
        for(int j = 0; j < 10; j++)
        {
            int c;
            cin >> c;
            g[i][j] = c;
        }
    }
    for(int k = 0; k < 10; k++)
    {
        for(int i = 0; i < 10; i++)
        {
            for(int j = 0; j < 10; j++)
            {
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            int a;
            cin >> a;
            if(a != -1 && a != 1)
            {
                ans += g[a][1];
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define alpha 26
 
int main(void){
  int i, cnt[alpha] = {0};
  char ch;
 
  while (scanf("%c", &ch) != EOF)
    if ('a' <= ch && ch <= 'z')
      cnt[ch - 'a']++;
    else if ('A' <= ch && ch <= 'Z')
      cnt[ch - 'A']++;
 
  for(i = 0; i < alpha; i++)
    printf("%c : %d\n", 'a' + i, cnt[i]);
 
  return 0;
}


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

using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int len = 1 << n;

    vector<vector<int>> dp(len, vector<int>(n + 1));
    for (int i = 0; i < len; i++)cin >> dp[i][0];

    for (int times = 1; times <= n; times++) {
        for (int i = 0; i < len; i++) {
            int j = i + (1 << (times - 1));
            j %= len;

            int front = dp[i][times - 1], back = dp[j][times - 1];
            dp[i][times] = s[abs(front - back) - 1] == '0' ? min(front, back) : max(front, back);
        }
    }

    for (int i = 0; i < len; i++) cout << dp[i][n] << endl;
    return 0;
}



Measured memory_bytes: 33820
#include<bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define mp make_pair
 
typedef long long ll;
typedef unsigned long long int ull;
typedef long double ld;
 
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef pair<string, string> ss;
typedef pair<int, ss> iss;
 
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<ld> vld;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pair<int, pii>> vpiii;
 
typedef map<string, string> mss;
typedef map<string, int> msi;
typedef map<int, int> mii;
typedef map<int, bool> mib;
typedef map<int, ll> mill;
typedef map<int, vpii> mivpii;

const int MAXN = 3000;
const int UP = 0;
const int LEFT = 1;
const int DIAG = 2;

int dp[MAXN + 1][MAXN + 1];
int p[MAXN + 1][MAXN + 1];

string S, T;
int n, m;

void fast_io() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

void solve() {
	n = S.length(), m = T.length();
	S = '@' + S, T = '*' + T;
	
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++) {		
			if(S[i] == T[j])
				dp[i][j] = 1 + dp[i - 1][j - 1], p[i][j] = DIAG;
			if(S[i] != T[j]) {
				if(dp[i - 1][j] >= dp[i][j - 1]) dp[i][j] = dp[i - 1][j], p[i][j] = UP;
				else dp[i][j] = dp[i][j - 1], p[i][j] = LEFT;
			}
		}
	
	vc ans;
	while(n != -1) {
		if(p[n][m] == DIAG) ans.pb(S[n]);
		if(p[n][m] == LEFT) m--;
		else if(p[n][m] == UP) n--;
		else n--, m--;
	}
	reverse(all(ans));
	for(char c : ans) cout << c;
	cout << '\n';
}

int main() {
	fast_io();
//	freopen("input/dp_f.txt", "r", stdin);
	
	cin >> S >> T;
	solve();
	
	return 0;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<long long> x(n), d(n-1), e(n-1), to(n-1), sw(n-1);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
        if (i) {
            d[i-1] = x[i] - x[i-1], to[i-1] = i-1;
        }
    }
    int m; long long k; cin >> m >> k;
    for (int i = 0; i < m; i++) {
        int a; cin >> a; --a;
        swap(to[a-1], to[a]);
    }
    while (k) {
        if (k & 1) {
            for (int i = 0; i < n-1; i++) e[i] = d[to[i]];
            swap(d, e);
        }
        for (int i = 0; i < n-1; i++) sw[i] = to[to[i]];
        swap(to, sw);
        k /= 2;
    }
    for (int i = 0; i < n; i++) {
        if (i) x[i] = x[i-1] + d[i-1];
        cout << x[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 5248
#include<stdio.h>

//関数プロトタイプ宣言
void diceRoll(int *d,char *r);

int main(){
	int dice[6];	//サイコロ
	int q;			//質問の数
	int up;			//サイコロの上面
	int front;		//サイコロの前面
	
	//サイコロの作成
	for(int i = 0;i < 6;i++){
		scanf("%d",&dice[i]);
	}
	//質問の数の入力
	scanf("%d",&q);
	
	for(int i = 0;i < q;i++){
		//上面と前面の入力
		scanf("%d %d",&up,&front);
		
		//サイコロの上面が入力されたものと違うとき
		if(dice[0] != up){
			//入力された上面が前面にあったとき
			if(dice[1] == up){
				diceRoll(dice,"N");
			}
			//右面にあったとき
			else if(dice[2] == up){
				diceRoll(dice,"W");
			}
			//左面にあったとき
			else if(dice[3] == up){
				diceRoll(dice,"E");
			}
			//後面にあったとき
			else if(dice[4] == up){
				diceRoll(dice,"S");
			}
			//底面にあったとき
			else if(dice[5] == up){
				diceRoll(dice,"NN");
			}
		}
		
		//サイコロの前面が入力されたものと違うとき
		if(dice[1] != front){
				//入力された前面が右面にあったとき
			if(dice[2] == front){
				diceRoll(dice,"R");
			}
			//左面にあったとき
			else if(dice[3] == front){
				diceRoll(dice,"L");
			}
			//後面にあったとき
			else if(dice[4] == front){
				diceRoll(dice,"RR");
			}
		}
		
		//右面を表示
		printf("%d\n",dice[2]);
	}
	
	return 0;
}

void diceRoll(int *d,char *r){
	int x;	//入れ替え用変数
	for(int i = 0;r[i] != '\0';i++){
		switch(r[i]){
			//右に転がす
			case 'E':
				x = d[0];
				d[0] = d[3];
				d[3] = d[5];
				d[5] = d[2];
				d[2] = x;
				break;
			//奥に転がす
			case 'N':
				x = d[0];
				d[0] = d[1];
				d[1] = d[5];
				d[5] = d[4];
				d[4] = x;
				break;
			//手前に転がす
			case 'S':
				x = d[0];
				d[0] = d[4];
				d[4] = d[5];
				d[5] = d[1];
				d[1] = x;
				break;
			//左に転がす
			case 'W':
				x = d[0];
				d[0] = d[2];
				d[2] = d[5];
				d[5] = d[3];
				d[3] = x;
				break;
			//右に９０度回す
			case 'R':
				x = d[1];
				d[1] = d[2];
				d[2] = d[4];
				d[4] = d[3];
				d[3] = x;
				break;
			//左に９０度回す
			case 'L':
				x = d[1];
				d[1] = d[3];
				d[3] = d[4];
				d[4] = d[2];
				d[2] = x;
				break;
		}
	}
}



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

int main() {
    long int n,k,sum=0;
    cin>>n>>k;
    long int i=k;
    while(n--){
    
    //    cout<<i<<" ";
        sum+=i;
        i++;
    }
    i--;
   // cout<<i<<endl;
   // cout<<sum<<" ";
    if(i<0)
        cout<<(sum+abs(i))<<endl;
    else if(k>0)
        cout<<(sum-k)<<endl;
    else
        cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#100c
def check_number_of_devide_by_2(n):
#aiが最大1000000000なので、log_2(1000000000) =　29.897352854　回のループで1つのaiを調べられる。
    count = 0
    while n%2==0:
        count += 1
        n = n/2
    
    return count

N = int(input())

list_a = [check_number_of_devide_by_2(i) for i in list(map(int, input().split()))]
#N<=10000 と check～の ループ数より十分間に合う。

print(sum(list_a))

Measured memory_bytes: 4148
//
// ALDS1_1_D:   Maximum Profit
// implementation-2
//

#include <iostream>
#include <math.h>
#include <climits>
using namespace std;


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

	int x;
	int minv, maxv;

	for(int i=0; i<N; i++) {
		cin >> x;
		if (i==0) {
			minv = x;
			maxv = INT_MIN;
		} else {
//			cout << "x=" << x << " old maxv=" << maxv << " old minv=" << minv;
			maxv = max(maxv, x-minv);
			minv = min(minv, x);
//			cout << " new maxv=" << maxv << " new minv=" << minv << endl;
		}
	}
	cout << maxv << endl;
	return 0;
}



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

template <typename Weight, int MAX_N, Weight INF> 
class MaxFlow{
private:
	struct E{
		int to, rev;
		Weight lim;
		E(int x, Weight y, int z){
			to = x;
			lim = y;
			rev = z;
		}
	};

	vector<E> edge[MAX_N];
	int lev[MAX_N];
	int iter[MAX_N];


	Weight dfs(int s, int g, Weight f){
		if(s == g)return f;
		for(int &i = iter[s];i < edge[s].size();i++){
			E &e = edge[s][i];
				if(lev[e.to] <= lev[s] || e.lim <= 0)continue;
			Weight tmp = dfs(e.to, g, min(f, e.lim));
			if(tmp<1e-9)continue;
			e.lim -= tmp;
			edge[e.to][e.rev].lim += tmp;
			return tmp;
		}
		return 0;
	}

	void bfs(int x){
		queue<int> q;
		q.push(x);
		int p = 0;
			while(!q.empty()){
			for(int i = q.size();i--;){
				int tmp = q.front();q.pop();
				if(lev[tmp] != INF)continue;
				lev[tmp] = p;
				for(int j = 0;j < edge[tmp].size();j++){
					if(edge[tmp][j].lim > 0 && lev[edge[tmp][j].to] == INF)q.push(edge[tmp][j].to);
				}
			}
			p++;
		}
	}

public:
	void make_edge(int a, int b, Weight l){
		edge[a].push_back(E(b, l, edge[b].size()));
		edge[b].push_back(E(a, 0, edge[a].size() - 1));
	}

	Weight max_flow(int s, int g){
		Weight res = 0;
		bool fin = false;
		while(!fin){
			fill(lev, lev + MAX_N, INF);
			fill(iter, iter + MAX_N, 0);
			bfs(s);
			fin = true;
			while(true){
				Weight p = dfs(s, g, INF);
				if(p < 1e-9)break;
				fin = false;
				res += p;
			}
		}	
		return res;
	}
};




char x;
bool c[108][108];
bool corner[108][108];
bool middle[108][108];
int cnt;

typedef pair<int, int> P;
typedef pair<P, P> Q;

bool cross(Q a, Q b){
	int aa = a.first.second;
	int bb = b.second.first;
	return (a.first.first <= bb && bb <= a.second.first
		    && b.first.second <= aa && aa <= b.second.second);
}

void solve(int w, int h){
	int WH = w*h;
	MaxFlow<int, 10800, 1 << 30> mf;
	vector<Q> line[2];
	cnt = 1;	
	memset(corner, false, sizeof(corner));
	memset(middle, false, sizeof(middle));
	for(int i = 0;i < w;i++){
		for(int j = 0;j < h;j++){
			cin >> x;
			c[i][j] = x == '#';
		}
	}
	
	for(int i = 0;i < w - 1;i++){
		for(int j = 0;j < h - 1;j++){
			if(c[i][j] + c[i+1][j] + c[i][j+1] + c[i+1][j+1] == 3){
				corner[i][j] = true;
			}
			if(c[i][j] + c[i+1][j] + c[i][j+1] + c[i+1][j+1] == 4){
				middle[i][j] = true;
			}
		}
	}

	for(int i = 0;i < w-1;i++){
		for(int j = 0;j < h-1;j++){
			if(!corner[i][j])continue;
			cnt++;
			int t;
			t = 1;
			if(c[i+1][j] && c[i+1][j+1]){
				while(middle[i+t][j])t++;
				if(corner[i+t][j])line[0].push_back(Q(P(i, j),P(i+t, j)));
			}
			if(c[i][j+1] && c[i+1][j+1]){
				t = 1;
				while(middle[i][j+t])t++;
				if(corner[i][j+t])line[1].push_back(Q(P(i, j), P(i, j+t)));
			}
		}
	}
	int n0 = line[0].size(), n1 = line[1].size();
	int S = n0+n1;
	int G = S + 1;
	for(int i = 0;i < n0;i++)mf.make_edge(S, i, 1);
	for(int i = 0;i < n1;i++)mf.make_edge(n0 + i, G, 1);
	
	for(int i = 0;i < n0;i++){
		for(int j = 0;j < n1;j++){
			if(cross(line[0][i], line[1][j])){
				mf.make_edge(i, j + n0, 1);
			}
		}
	}
	
	cout << cnt - S + mf.max_flow(S, G) << endl;
}

int main(){
	int w, h;
	while(cin >> w >> h, w | h){
		solve(w, h);
	}
	return 0;
}

Measured memory_bytes: 2088
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007

using namespace std;
typedef long long ll;

ll n, v[20];

map<pair<ll, ll>, ll> mp[20][20];
ll solve(ll st, ll dr, ll xst, ll xdr)
{
    if(dr - st == 1)
        return 0;
    if(mp[st][dr].find({xst, xdr}) != mp[st][dr].end())
        return mp[st][dr][{xst, xdr}];
    ll ans = (1LL<<62);
    for(int i = st + 1; i < dr; ++i)
        ans = min(ans, solve(st, i, xst, xst+xdr) + solve(i, dr, xst+xdr, xdr) + v[i] * (xst+xdr));
    mp[st][dr][{xst, xdr}] = ans;
    return mp[st][dr][{xst, xdr}];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for(int i = 0; i < n; ++i)
        cin >> v[i];
    cout << solve(0, n-1, 1, 1) + v[0] + v[n-1] << '\n';
    return 0;
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<int, int> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  map<ll, ll> mp;
  for (ll i = 1; i <= n; i++) {
    ll tmp;
    cin >> tmp;
    mp[tmp] = i;
  }

  set<ll> used = {0, n+1};
  ll res = 0;
  for (ll i = 1; i <= n; i++) {
    auto it = used.lower_bound(mp[i]);
    ll l = *it;
    ll r = *(--it);
    res += i * (mp[i]-l) * (r-mp[i]);
    used.insert(mp[i]);
  }

  cout << res << endl;
}


Measured memory_bytes: 22144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int MOD = 1e9 + 7;
int main() {
	int N, K;
	cin >> N >> K;
	ll ans = 0;
	for (int b = 1; b <= N; b++) {
		int x = N / b, y = N % b;
		if (b >= K)ans += x * (b - K);
		if (y >= K)ans += y - K + 1;
		if (K == 0)ans--;
	}
  	cout<<ans<<endl;
}

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

int main(){
    string s,t;
    cin >> s >> t;
    cout << t+s << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>

#define MAX_SIZE 100000000
typedef unsigned long long ull;
using namespace std;

int main() {
  int N,T; cin >> N >> T;
  int ans_time = T;
  int ans_cost = 10000;
  for(int i = 0; i < N; i++) {
    int c,t; cin >> c >> t;
    if(T >= t && ans_cost >= c) {
      ans_time = t;
      ans_cost = c;
    }
  }

  if(ans_cost == 10000) cout << "TLE" << endl;
  else cout << ans_cost << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
  int N;
  cin >> N;

  vector<string>word(N);
  for(int i=0;i<N;i++){
    cin >> word[i];
  }

  vector<vector<int> >check(N,vector<int>(26,0));
  for(int i=0;i<N;i++){
    int n = word[i].length();
    for(int j=0;j<n;j++){
      check[i][word[i][j] - 'a']++;
    }
  }

  vector<int>usable(26,0);

  for(int i=0;i<26;i++){
    int min_al = 51;
    for(int j=0;j<N;j++){
      if(check[j][i] < min_al)
        min_al = check[j][i];
    }
    usable[i] = min_al;
  }

  for(int i=0;i<26;i++){
    if(usable[i] == 0)
      continue;
    else{
      for(int j=0;j<usable[i];j++){
        cout << char(i + 'a');
      }
    }
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 256
/*input
vanceknowledgetoad
advance
*/
fn read_line() -> String {
    let mut return_ = format!("");
    std::io::stdin().read_line(&mut return_).ok();
    return_.pop();
    return_
}

fn main() {
    let s = read_line();
    let f = read_line();
    let mut s_: String = String::new();
    s_.push_str(&s);
    s_.push_str(&s);
    println!(
        "{}",
        match s_.contains(&f) {
            true => "Yes",
            false => "No",
        }
    );
}



Measured memory_bytes: 5024
use std::collections::VecDeque;
use std::fmt::{Debug, Display};
use std::io::{self, Read};
use std::str::{self, FromStr};

fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock().bytes());
    let n = sc.next();
    for (i, x) in solve(n, sc.vec(n)).into_iter().enumerate() {
        if i > 0 {
            print!(" ");
        }
        print!("{}", x);
    }
    println!("");
}


fn solve(n: usize, a: Vec<u32>) -> Vec<u32> {
    let mut buf = VecDeque::new();
    for (i, x) in a.into_iter().enumerate() {
        if i % 2 == 0 {
            buf.push_back(x);
        } else {
            buf.push_front(x);
        }
    }
    if n % 2 == 0 {
        buf.into_iter().collect()
    } else {
        buf.into_iter().rev().collect()
    }
}


struct Scanner<R: Read> {
    buf: Vec<u8>,
    bytes: io::Bytes<R>,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(bytes: io::Bytes<R>) -> Self {
        Scanner {
            buf: Vec::with_capacity(256),
            bytes: bytes,
        }
    }

    fn next<T: FromStr>(&mut self) -> T
        where <T as FromStr>::Err: Debug
    {
        self.buf.clear();
        let mut c = self.bytes.next().unwrap().unwrap();
        while c == ' ' as u8 || c == '\n' as u8 {
            c = self.bytes.next().unwrap().unwrap();
        }
        while !(c == ' ' as u8 || c == '\n' as u8) {
            self.buf.push(c);
            c = self.bytes.next().unwrap().unwrap();
        }
        str::from_utf8(&self.buf).unwrap().parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
        where <T as FromStr>::Err: Debug
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<A: FromStr, B: FromStr>(&mut self, n: usize) -> Vec<(A, B)>
        where <A as FromStr>::Err: Debug,
              <B as FromStr>::Err: Debug
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<A: FromStr, B: FromStr, C: FromStr>(&mut self, n: usize) -> Vec<(A, B, C)>
        where <A as FromStr>::Err: Debug,
              <B as FromStr>::Err: Debug,
              <C as FromStr>::Err: Debug
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
        where <T as FromStr>::Err: Debug
    {
        (0..n).map(|_| self.vec(m)).collect()
    }
}


#[allow(dead_code)]
fn print_foreach<T: Display>(answer: &[T]) {
    for x in answer {
        println!("{}", x);
    }
}


#[allow(dead_code)]
fn print_yn(answer: bool, yes: &str, no: &str) {
    println!("{}", if answer { yes } else { no });
}


#[allow(dead_code)]
fn print_or<T: Display>(answer: &Option<T>, or: &T) {
    match *answer {
        Some(ref x) => println!("{}", x),
        None => println!("{}", or),
    }
}


Measured memory_bytes: 9848
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

#[allow(dead_code)]
fn chmin<T>(x: &mut T, y: T) -> bool
where
    T: PartialOrd + Copy,
{
    *x > y && {
        *x = y;
        true
    }
}

#[allow(dead_code)]
fn chmax<T>(x: &mut T, y: T) -> bool
where
    T: PartialOrd + Copy,
{
    *x < y && {
        *x = y;
        true
    }
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input! {
        h:usize,w:usize,d:usize,
        graph:[[usize;w];h],
        q:usize,
        lr:[(usize,usize);q],
    }

    let mut poses = vec![(0i64, 0i64); 90001];
    for y in 0..h {
        for x in 0..w {
            let a = graph[y][x];
            poses[a] = (y as i64, x as i64);
        }
    }

    let mut dist = vec![0i64; 90010];
    for i in d + 1..h * w + 1 {
        dist[i] =
            dist[i - d] + (poses[i].0 - poses[i - d].0).abs() + (poses[i].1 - poses[i - d].1).abs();
    }
    for &(l, r) in lr.iter() {
        let ans = dist[r] - dist[l];
        println!("{}", ans);
    }
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*
 */

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

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

  vi p(n);
  rep(i, 0, n) cin >> p[i];

  int ans = 0, mi = 1e9;
  rep(i, 0, n){
    if(chmin(mi, p[i])) ans++;
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 1792
#include <stdio.h>

int main(){
  int H,N,i,a,g=0;
  scanf("%d",&H);
  scanf("%d",&N);
  for(i=1;i<=N;i++){
    scanf("%d",&a);
    H=H-a;
    
  }
  if(H<=0) printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>

int main(void) {
	int N;
	int i;
	int asumikana = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		int A;
		if (scanf("%d", &A) != 1) return 1;
		if (A % 2 == 0) asumikana++;
	}
	printf("%d\n", asumikana);
	return 0;
}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int  N, L;
  cin >> N >> L;
  int ans;
  if (L > 0){
    for (int i = 2; i <= N; i++){
      ans += L + i - 1;
    }
  } else if (-1*L >= N) {
    for (int i = 1; i <= N-1; i++){
      ans += L + i - 1;
    }
  } else {
    for (int i = 1; i <= N; i++){
      ans += L + i - 1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

fn main() {
    let n: usize = read();
    println! {"{}",n/3}
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
using namespace std;

int main() {

	int N;
	cin >> N;

	int max_first = 1;
	int max_second = 1;
	vector<int> A(N, 0);

	for (int i = 0; i < A.size(); i++) {
		cin >> A[i];
		if (max_first < A[i]) {
			max_second = max_first;
			max_first = A[i];
		}
		else if (max_second < A[i]) {
			max_second = A[i];
		}
	}

	for (int i = 0; i < A.size(); i++) {
		if (A[i] == max_first) {
			cout << max_second << endl;
		}
		else {
			cout << max_first << endl;
		}
	}

	return 0;
}



Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  int n; cin>>n;
  vi a(n);
  rep(i,n) cin>>a[i];
  int ans=0;
  rep(i,n){
    if(i%2==0 && a[i]%2==1){
      ans++;
    }
  }
  out(ans);
}

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


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;
using namespace std;
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

bool vector_find(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
    if (index != vec.size()) {
        return true;
    }
    else {
        return false;
    }
}


int main(void){
    double result;
    ll N;
    cin >> N;
    vector<ll> L;
    rep(i, N){
        ll x;
        cin >> x;
        L.push_back(x);
    }
    ll sum = accumulate(ALL(L), 0.0);
    ll max = *max_element(ALL(L));
    sum -= max;
    if(max < sum){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace AtCoder190804_C
{
    class Program
    {
        static void Main()
        {
            String input1 = Console.ReadLine();
            int n = int.Parse(input1);
            String[] input2 = Console.ReadLine().Split();
            var hList = new List<int>(n);
            for (int i = 0; i < n; i++)
            {
                hList.Add(int.Parse(input2[i]));
            }
            int[] h = hList.ToArray();

            bool res = true;

            int minVal = h[n - 1];
            for (int i = 0; i < n; i++)
            {
                int current = h[n - i - 1];
                if (current > minVal + 1)
                {
                    res = false;
                    break;
                }

                if (current < minVal)
                {
                    minVal = current;
                }
            }

            string resStr = res ? "Yes" : "No";
            Console.WriteLine($"{resStr}");
        }
    }
}


Measured memory_bytes: 29532
#include<bits/stdc++.h>
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long int
#define vi vector<int>
#define vvll vector<ll>
#define vll(a) vector<ll> a(MAXN)
#define pb push_back
#define fo(a) for(auto&a1:(a))
#define fd(a,b) for(int i=(a);i>=(b);i--)
#define fk(a,b) for(int k=(a);k<(b);k++)
#define fj(a,b) for(int j=(a);j<(b);j++)
#define f(a,b) for(ll i=(a);i<(b);i++)
#define forni(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define fdk(a,b) for(int k=(a);k>=(b);k--)
#define fdj(a,b) for(int j=(a);j>=(b);j--)
#define ri(n) scanf("%d",&(n));
#define rll(n) scanf("%lld",&(n));
#define T(t) int t;scanf("%d",&(t));while((t)--)
#define MAXN 10000001
#define MAXN2 10000005
#define pll pair<ll,ll>
#define PI 3.14159265
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const ll mod=1000000007;
int main()
{
    ll n,mw;
    cin>>n>>mw;
    ll w[n+1]={0},v[n+1]={0};
    f(1,n+1)
    cin>>w[i]>>v[i];
    ll dp[n+1][mw+1];
    memset(dp,0,sizeof(dp));
    f(1,n+1)
    {
        fj(0,mw+1)
        {
            if(j-w[i]>=0)
            dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-w[i]]);
            else
            dp[i][j]=dp[i-1][j];
            //cout<<dp[i][j]<<" ";
        }
        //cout<<"\n";
    }
    //ll ans=0;
    //f(1,n+1)
    //ans=max(ans,dp[i][mw]);
    cout<<dp[n][mw]<<"\n";
    return 0;
}


Measured memory_bytes: 82328
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,a) for(int i=start[(a)];i;i=e[i].next)
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
inline int read()
{
    int sum=0,p=1;char ch=getchar();
    while(!(('0'<=ch && ch<='9') || ch=='-'))ch=getchar();
    if(ch=='-')p=-1,ch=getchar();
    while('0'<=ch && ch<='9')sum=sum*10+ch-48,ch=getchar();
    return sum*p;
}

const int maxn=2e5+20;
const int inf=0x3f3f3f3f;

int n;
int p[maxn];

struct node {
    int mx[2];
    node(){ mx[0]=0; mx[1]=-inf;}
    inline void Merge(node lc,node rc){
	mx[0]=max(lc.mx[0],rc.mx[0]);
	mx[1]=max(lc.mx[1],rc.mx[1]);
    }
};
node c[(1<<19)+20];

int val[maxn];

int f[maxn][2];

#define lc (o<<1)
#define rc (o<<1|1)
#define left lc,l,mid
#define right rc,mid+1,r

void update(int x,int *d,int o,int l,int r)
{
    if(l==r)return c[o].mx[0]=d[0],c[o].mx[1]=d[1],void();
    int mid=l+r>>1;
    if(x<=mid)update(x,d,left);
    else update(x,d,right);
    c[o].Merge(c[lc],c[rc]);
}

node query(int ql,int qr,int o,int l,int r)
{
    if(ql>qr)return node();
    if(ql<=l && r<=qr)return c[o];
    int mid=l+r>>1;
    if(qr<=mid)return query(ql,qr,left);
    else if(ql>mid)return query(ql,qr,right);
    else {
	node x; x.Merge(query(ql,qr,left),query(ql,qr,right));
	chkmax(x.mx[0],0);
	return x;
    }
}

/*void make_tree(int o,int l,int r)
{
    c[o].mx[0]=f[l][0]; c[o].mx[1]=f[l][1];
    if(l==r)return;
    int mid=l+r>>1;
    make_tree(left);
    make_tree(right);
    }*/

inline void init()
{
    n=read();
    REP(i,1,n)p[i]=read();
    int mx=0;
    REP(i,1,n)
    {
	val[i]=1;
	if(p[i]>mx)mx=p[i],val[i]=2;
    }
    DREP(i,n,1)
    {
	node t=query(p[i],n,1,1,n);
	f[i][0]=t.mx[val[i]&1]+val[i];
	f[i][1]=t.mx[~val[i]&1]+val[i];
	chkmax(f[i][0],0);
	update(p[i],f[i],1,1,n);
    }
}

int ans[maxn];

inline void doing()
{
    
    int A=0,B=0,Q=0,maxA=0,maxB=0;
    REP(i,1,n)Q+=val[i]==2;

    {
	node t=query(1,n,1,1,n);
	if(t.mx[Q&1]<Q)puts("-1"),exit(0);
    }
	    
    REP(i,1,n)
    {
	int mx[2]={0,0};
	update(p[i],mx,1,1,n);
	int flg0=0,nA,nB,nQ;
	//check0
	{
	    nA=A+(p[i]>maxA),nB=B,nQ=Q-(val[i]==2);
	    {
		int ned=nA+nQ-nB;
		node t=query(maxB+1,n,1,1,n);
		if(ned>=0 && t.mx[ned&1]>=ned)flg0=1;
	    }
	    {
		int ned=nB+nQ-nA;
		node t=query(max(maxA,p[i])+1,n,1,1,n);
		if(ned>=0 && t.mx[ned&1]>=ned)flg0=1;
	    }
	}
	if(flg0)
	{
	    A+=p[i]>maxA; Q-=val[i]==2;
	    ans[i]=0;
	    chkmax(maxA,p[i]);
	}else
	{
	    B+=p[i]>maxB; Q-=val[i]==2;
	    ans[i]=1;
	    chkmax(maxB,p[i]);
	}
    }
    REP(i,1,n)printf("%d",ans[i]);
}

int main()
{

    init();
    doing();
    return 0;
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//---------------------------------------------------------------
#define fastio std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
//--------------------------------------------------------------


int main(int argc,char** argv){ fastio; myio;
  int n;
  cin>>n;
  vi a(n);
  cin>>a;
  int ans = 0;
  rep(i,n){
    while(a[i]%2==0){a[i]/=2;ans++;}
  }
  cout<<ans;
}

Measured memory_bytes: 256
public partial class IntroductionToProgramming{
	public static void Main(){
		string[] line = System.Console.ReadLine().Split(' ');
		int a = int.Parse(line[0]);
		int b = int.Parse(line[1]);
		int c = int.Parse(line[2]);
		
		System.Console.WriteLine(a < b && b < c ? "Yes" : "No");
	}
}

Measured memory_bytes: 15480
from collections import deque
H,W=map(int,input().split())
S=[input() for i in range(H)]
checked=[[0 for i in range(W)] for m in range(H)]

count=0
count2=0
visited=set()
for h1 in range(H):
    for w1 in range(W):
        if S[h1][w1]=="#" and checked[h1][w1]==0:
            checked[h1][w1]=1
            stack=deque([[h1,w1,"#"]])
            kuro=1
            siro=0
            count2+=1
            visited.add(h1*400+w1)
            while stack:
                h,w,iro=stack.popleft()
                for y,x in [[-1,0],[1,0],[0,1],[0,-1]]:
                    Y,X=y+h,x+w
                    visitednum=Y*400+X
                    if 0<=Y<H and 0<=X<W and not visitednum in visited:
                        if iro=="#" and S[Y][X]==".":
                            siro+=1
                            visited.add(visitednum)
                            stack.append([Y,X,"."])
                        elif iro=="." and S[Y][X]=="#" and not visitednum in visited:
                            kuro+=1
                            checked[Y][X]=1
                            visited.add(visitednum)
                            stack.append([Y,X,"#"])
            count+=kuro*siro
print(count)


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

int main(){
  int t[10];
  for(int i = 0; i < 10; i++){
    cin >> t[i];
  }
  sort(t, t + 10, greater<int>());

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

Measured memory_bytes: 1176
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int	i,j,flg;
	double m5,m10;
	double m5t[7]={35.5,37.5,40.0,43.0,50.0,55.0,70.0};
	double m10t[7]={71.0,77.0,83.0,89.0,105.0,116.0,148.0};
	char ran[8][8]={"AAA","AA","A","B","C","D","E"};
	while(scanf("%lf %lf",&m5,&m10)!=EOF){
		flg=0;
		for(i=0;i<=7;i++){
			if(m5<m5t[i] && m10<m10t[i]){
				printf("%s\n",ran[i]);
				flg=1;
				break;
			}
		}
		if(flg==0) printf("NA\n");
	}
	return 0;
}

Measured memory_bytes: 1036
local function gcd(a,b)
    if b>0 then
        return gcd(b,a%b)
    else
        return a
    end
end

local x=gcd(io.read("*n","*n"))

local counter=1
for i=2,math.sqrt(x) do
    if x%i==0 then
        while x%i==0 do
            x=math.floor(x/i)
        end
        counter=counter+1
    end
end
print(x~=1 and counter+1 or counter)

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

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

using namespace std;
using lint=long long;

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

	if(n%2==1) return puts("0"),0;

	lint ans=0,f=5;
	while(n>=f) ans+=n/(2*f), f*=5;
	cout<<ans<<'\n';

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long dp[5050][5050]; //i keystroke, j remain
int N;
const int MOD = 1e9+7;
const int MODINV = (MOD+1)/2;

char s[10101];
int main()
{
    scanf("%d%s", &N, s); int K = strlen(s);
     
    dp[0][0] = 1;
    for(int i=0; i<=N; ++i)
    {
        for(int j=0; j<=i; ++j)
        {
            dp[i][j] %= MOD;
            dp[i+1][max(j-1, 0)] += dp[i][j];
            dp[i+1][j+1] += 2*dp[i][j];
        }
    }
    long long ans = dp[N][K];
    for(int i=0; i<K; ++i) ans = (ans*MODINV)%MOD;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 197120
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    
    int dp[108] = {};
    dp[0] = 1;
    for(int i = 0; i<=100; i++){
        dp[i+4] = max(dp[i], dp[i+4]);
        dp[i+7] = max(dp[i], dp[i+7]);
    }
    if(dp[n]){
        cout << "Yes"<< endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#include <cassert>
#include <chrono>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#define FOR(i,a,n) for (int i=a;i<n;i++)
#define RFOR(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<long long int> vll;
typedef vector<pair<int, int> > vpi;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

void solve() {
    string s;
    cin >> s;
    int num = 0;
    for (auto x : s) {
        num += (x - '0');
        num %= 9;
    }
    cout << (num ? "No" : "Yes") << "\n";
}

int main() {
    #ifdef LOCAL
    auto t1 = std::chrono::high_resolution_clock::now();
    #endif

    io;
    solve();

    #ifdef LOCAL
    auto t2 = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::milliseconds>( t2 - t1 ).count();

    std::cout << "Time Taken: " << duration << "\n";
    #endif

}
// check for edge cases in limits
// printing double may print 1.223232e9 like values, beware of that
// carefully observe simulation of test cases
// multiset erase is does not do what it is supposed to


Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,o,r,b,c,len,p,best,f;
    int x,y,s=0;
    cin>>x>>y;
    if(x*2==y)
        cout<<"Yes";
    else if(x*4==y)
        cout<<"Yes";
    else {
        r=1,k=x-r;
        while(k!=0)
        {
            s=r*2+k*4;
            if(s==y)
            {
                break;
            }
            r++,k=x-r;
        }
        if(s==y)
            cout<<"Yes";
        else cout<<"No";
    }
}






Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const long long MOD = 1000000007;

int main() {
    ll N,M;
    cin >> N >> M;
    vector<ll> a(N+5,0);
    for(int i=0;i<M;i++){
        ll b;
        cin >> b;
        a[b] =1;
    }
    
    ll dp[N+5] = {};
    dp[0] = 1;
    for(int i=0;i<N;i++){
        dp[i] %= MOD;
        if(a[i+1] ==0){
            dp[i+1] += dp[i];
        }
        if(a[i+2] == 0){
            dp[i+2] += dp[i];
        }
    }
    cout << dp[N] % MOD << endl;


    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <map>
 
using namespace std;
typedef long long ll;

ll ans;
int main(){
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for(ll i=0; i<n; i++){
		cin>>a[i];
	}
	sort(a,a+n);
	reverse(a,a+n);
	for(ll i=0; i<n; i++){
		if(k==0) break;
		else {
			a[i]=0;
			k--;
		}
	}
	for(ll i=0; i<n; i++) ans+=a[i];
	cout<<ans<<endl;
} 

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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

int n;
signed main()
{
    cin >> n;
    string s = to_string(n);
    bool flag = false;
    REP(i, 3){
        if (s[i] == '7') flag = true;
    }

    if (flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

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

int main(void){
	int32 H, W;
	cin >> H >> W;
	string f[10];
	REP(i, H){
		cin >> f[i];
	}
	auto in = [&](int32 y, int32 x){
		return 0<=y && y < H && 0 <= x && x < W;
	};
	function<bool(PII, PII)> dfs = [&](PII pos, PII p){
		int32 cnt = 0;
		REP(i, 4){
			int32 yy = pos.fs+dy[i], xx = pos.sc+dx[i];
			if(!in(yy, xx)) continue;
			if(f[yy][xx] == '#') cnt++;
		}
		if((pos == PII(0, 0) || pos == PII(H-1, W-1)) && (cnt == 0 || cnt > 1)){
			return false;
		}else if(cnt > 2){
			return false;
		}
		if(pos == PII(H-1, W-1) && cnt == 1) return true;

		bool res = 0;
		REP(i ,4){
			int32 yy = pos.fs+dy[i], xx = pos.sc+dx[i];
			if(!in(yy, xx) || PII(yy, xx) == p) continue;
			if(f[yy][xx] == '#'){
				if(i <= 1) return false;
				res |= dfs(PII(yy, xx), pos);
			}
		}
		return res;
	};
	if(dfs(PII(0, 0), PII(-1, -1))){
		cout << "Possible" << endl;
	}else{
		cout << "Impossible" << endl;
	}
}

Measured memory_bytes: 256