akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 10000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

struct Info{
	Info(int arg_node_id,int arg_cost_sum){
		node_id = arg_node_id;
		cost_sum = arg_cost_sum;
	}
	int node_id,cost_sum;
};

int main(){

	int N,M,start,goal;
	scanf("%d %d %d %d",&N,&M,&start,&goal);

	ll* from_start_Dist = new ll[N+1];
	ll* from_goal_Dist = new ll[N+1];
	ll *Dist_num_from_start = new ll[N+1];
	ll *Dist_num_from_goal = new ll[N+1];

	vector<int> V[N+1];

	for(int i = 1; i <= N; i++){
		from_start_Dist[i] = BIG_NUM;
		from_goal_Dist[i] = BIG_NUM;
		Dist_num_from_start[i] = 0;
		Dist_num_from_goal[i] = 0;
	}

	from_start_Dist[start] = 0;
	from_goal_Dist[goal] = 0;
	Dist_num_from_start[0] = 0;
	Dist_num_from_goal[0] = 0;

	int from,to;

	for(int i = 0; i < M; i++){
		scanf("%d %d",&from,&to);
		V[from].push_back(to);
		V[to].push_back(from);
	}

	queue<Info> Q;

	for(int i = 0; i < V[start].size(); i++){
		from_start_Dist[V[start][i]] = 1;
		Q.push(Info(V[start][i],1));
	}

	int min_index;

	while(!Q.empty()){
		if(Q.front().cost_sum > from_start_Dist[Q.front().node_id]){
			Q.pop();
			continue;
		}else{
			min_index = Q.front().node_id;
			Q.pop();
		}

		for(int i = 0; i < V[min_index].size();i++){
			if(from_start_Dist[V[min_index][i]] > from_start_Dist[min_index] + 1){
				from_start_Dist[V[min_index][i]] =from_start_Dist[min_index] + 1;
				Q.push(Info(V[min_index][i],from_start_Dist[V[min_index][i]]));
			}
		}
	}

	for(int i = 1; i <= N; i++){
		if(from_start_Dist[i] != BIG_NUM){
			Dist_num_from_start[from_start_Dist[i]]++;
		}
	}
	int length = from_start_Dist[goal];


	for(int i = 0; i < V[goal].size(); i++){
		from_goal_Dist[V[goal][i]] = 1;
		Q.push(Info(V[goal][i],1));
	}

	while(!Q.empty()){
		if(Q.front().cost_sum > from_goal_Dist[Q.front().node_id]){
			Q.pop();
			continue;
		}else{
			min_index = Q.front().node_id;
			Q.pop();
		}

		for(int i = 0; i < V[min_index].size();i++){
			if(from_goal_Dist[V[min_index][i]] > from_goal_Dist[min_index] + 1){
				from_goal_Dist[V[min_index][i]] =from_goal_Dist[min_index] + 1;
				Q.push(Info(V[min_index][i],from_goal_Dist[V[min_index][i]]));
			}
		}
	}

	for(int i = 1; i <= N; i++){
		if(from_goal_Dist[i] != BIG_NUM){
			Dist_num_from_goal[from_goal_Dist[i]]++;
		}
	}

	ll ans = 0;

	for(int i = 0; i <= length-2; i++){
		ans += Dist_num_from_start[i]*Dist_num_from_goal[(length-2)-i];
	}

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

	return 0;
}

Measured memory_bytes: 12308
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let x:u64 = procon_read()[0];
	let c500 = x/500;
	let r500 = x%500;
	let c5 = r500/5;
	println!("{}", c500*1000+c5*5);
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int K;

vector<ll> V[12];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>K;
	
	for(i=1;i<=9;i++) V[1].push_back(i);
	if(K<=9) return _P("%lld\n",V[1][K-1]);
	K-=9;
	for(i=1;i<=9;i++) {
		FORR(v,V[i]) {
			x=v%10;
			if(x) V[i+1].push_back(v*10+x-1);
			V[i+1].push_back(v*10+x);
			if(x<9) V[i+1].push_back(v*10+x+1);
		}
		if(K<=V[i+1].size()) return _P("%lld\n",V[i+1][K-1]);
		K-=V[i+1].size();
	}
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 1976
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    string s;
    cin >> s;

    int cnt = 0;
    FOR(i, 1, s.size()) {
        if (s[i] != s[i - 1])
            cnt++;
    }

    std::cout << cnt << '\n';

    return 0;
}

Measured memory_bytes: 512
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<endl
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")

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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 2e18;


void solve() {
	int M; cin >> M;
	ll N = 0;
	ll sum = 0;
	REP(i, M) {
		int d, c; cin >> d >> c;
		N += c;
		sum += d * c;
		while (sum >= 10) {
			int r = sum % 10;
			sum /= 10;
			N += sum;
			sum += r;
		}
	}
	print(N - 1);
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
 int N, A[3][3], b[10];

 int main() {
      bool appear[3][3];
 for(int i = 0; i < 3; i++) {
 for(int j = 0; j < 3; j++) cin >> A[i][j];
 }
 cin >> N;
 for(int i = 0; i < N; i++) cin >> b[i];
 for(int i = 0; i < N; i++) {
    for(int j = 0; j < N; j++) {
 appear[i][j] = false;
 for(int k = 0; k < N; k++) {
 if(A[i][j] == b[k]) appear[i][j] = true;
 }
 }
 }
 string ANS = "No";
 for(int i = 0; i < 3; i++) {
 if(appear[i][0] and appear[i][1] and appear[i][2]) ANS = "Yes";
 }
 for(int i = 0; i < 3; i++) {
 if(appear[0][i] and appear[1][i] and appear[2][i]) ANS = "Yes";
 }
 if(appear[0][0] and appear[1][1] and appear[2][2]) ANS = "Yes";
 if(appear[0][2] and appear[1][1] and appear[2][0]) ANS = "Yes";
 cout << ANS << endl;
 return 0;
 }


Measured memory_bytes: 256
main = do
  s <- getContents
  let t = get2 . lines $ s
  let v = map ( map (map (read::String->Int) . words) ) t
  mapM_ (putStrLn . unwords . map show . solve)  v
  where
    get2 :: [String] -> [[String]]
    get2 [] = []
    get2 xs = (take 2 xs) : get2(drop 2 xs)

solve::[[Int]] -> [Int]
solve [s,t] = [hit,blow]
  where
    hit = length . filter id $ zipWith (\x y->x == y) s t
    blow = (flip (-) hit) . length . filter id $ [elem c t|c <- s]

Measured memory_bytes: 4108
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const double EPS = 1e-10;
const int INF = 1001001001;

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

int w, h;
int board[7][7];
int conn[7][7];
int gy, gx, white;

bool isok(int y, int x)
{
	int able[7][7] = {{0}};
	stack<pii> S;
	S.push(pii(y, x));
	while(!S.empty()){
		pii pos = S.top();
		S.pop();
		able[pos.first][pos.second] = 1;
		rep(i, 4){
			int py = pos.first + dy[i];
			int px = pos.second + dx[i];
			if(py<0 || h<=py || px<0 || w<=px)
				continue;
			
			if(py==gy && px==gx)
				able[gy][gx] = 1;
			if(board[py][px] == 0 && able[py][px] == 0)
				S.push(pii(py, px));
		}
	}
	
	if(able[gy][gx] == 0)
		return false;
	
	rep(i, h) rep(j, w){
		if(board[i][j]==0 && able[i][j]==0)
			return false;
	}
	return true;
}

bool dfs(int y, int x, int cnt)
{
	if(!isok(y, x))
		return false;
	
	/*
	rep(i, h){
		rep(j, w)
			printf("%d ", board[i][j]);
		puts("");
	}
	getchar();
	*/
	
	int two = -1;
	rep(i, 4){
		int py = y + dy[i];
		int px = x + dx[i];
		if(py<0 || h<=py || px<0 || w<=px || board[py][px])
			continue;
		if(conn[py][px] == 1)
			return false;
		if(conn[py][px] == 2){
			if(two == -1)
				two = i;
			else
				return false;
		}
	}
	
	board[y][x] = 2;
	rep(i, 4){
		int py = y + dy[i];
		int px = x + dx[i];
		if(py<0 || h<=py || px<0 || w<=px || board[py][px])
			continue;
		conn[py][px]--;
	}
	
	int index[4] = {0, 1, 2, 3};
	if(two != -1){
		index[0] = two;
		index[1] = -1;
	}
	rep(i, 4){
		if(index[i] == -1)
			break;
		
		int py = y + dy[index[i]];
		int px = x + dx[index[i]];
		if(py<0 || h<=py || px<0 || w<=px)
			continue;
		
		if(cnt == white && py == gy && px == gx)
			return true;
		
		conn[py][px]++;
		if(board[py][px] == 0 && dfs(py, px, cnt+1))
			return true;
		conn[py][px]--;
	}
	
	rep(i, 4){
		int py = y + dy[i];
		int px = x + dx[i];
		if(py<0 || h<=py || px<0 || w<=px || board[py][px])
			continue;
		conn[py][px]++;
	}
	board[y][x] = 0;
	
	return false;
}

int main()
{
	while(scanf("%d%d", &w, &h), w){
		rep(i, h) rep(j, w)
			scanf("%d", &board[i][j]);
		
		gy = -1;
		rep(i, h) rep(j, w){
			if(board[i][j] == 0){
				if(j<w-1 && board[i][j+1]==0){
					gy = i;
					gx = j;
				}
				goto next;
			}
		}
next:
		white = 0;
		rep(i, h) rep(j, w)
			white += board[i][j] == 0;
		
		rep(i, h) rep(j, w){
			conn[i][j] = 0;
			rep(k, 4){
				int py = i + dy[k];
				int px = j + dx[k];
				if(py<0 || h<=py || px<0 || w<=px || board[py][px])
					continue;
				++conn[i][j];
			}
		}

		bool ok = false;
		if(gy != -1){
			board[gy][gx] = 2;
			conn[gy][gx]--;
			ok = dfs(gy, gx+1, 2);
		}
		puts(ok ? "Yes" : "No");;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main() {
	int N, K;
	cin >> N >> K;
	if (K > (N - 1) * (N - 2) / 2) {
		cout << -1 << endl;
	}
	else {
		int u = N * (N - 1) / 2 - K;
		cout << u << endl;
		for (int i = 0; i < N; ++i) {
			for (int j = i + 1; j < N; ++j) {
				if (u > 0) {
					cout << i + 1 << ' ' << j + 1 << endl;
					--u;
				}
			}
		}
	}
	return 0;
}

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

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define debug(x) cerr << "x is "<<x <<" "

using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
const int MOD = 1e9+7, N = 1e5 + 10;

int32_t main(){
	ios::sync_with_stdio(NULL);
	cin.tie(NULL);
	int n,m;
	cin >> n >> m;
	vi g[m+1];
	f(i,0,m){
		int k ; cin >> k;
		f(j,0,k){
			int y; cin >> y;
			y--;
			g[i].pb(y);
		}
	} 
	vi p(m);
	f(i,0,m) cin >> p[i];

	int ans=0;
	f(i,0,(1<<n)){
		bool ok=true;
		f(j,0,m){
			int c=0;
			for(int id : g[j]){
				if((i >> id) & 1){
					++c;
				}
			}
			c%=2;
			if(c != p[j]){
				ok=false;
			}
		}
		if(ok){
			++ans;
		}
	}
	cout << ans << "\n";
	return 0;
}

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;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}

int main() {
    int N;
    ll C;
    cin >> N >> C;
    ll *x = new ll[N + 2] + 1;
    vector<ll> v(N);
    x[-1] = 0;
    x[N] = C;
    REP(i, N) cin >> x[i] >> v[i];

    vector<ll> accl_v(N + 1), accr_v(N + 1), accl_max_cal(N + 1), accr_max_cal(N + 1);
    accl_v[0] = accr_v[0] = accl_max_cal[0] = accr_max_cal[0] = 0;
    REP(i, N) {
        accl_v[i + 1] = accl_v[i] + v[i];
        accr_v[i + 1] = accr_v[i] + v[N - 1 - i];
        accl_max_cal[i + 1] = max(accl_max_cal[i], accl_v[i + 1] - x[i]);
        accr_max_cal[i + 1] = max(accr_max_cal[i], accr_v[i + 1] - (C - x[N - 1 - i]));
    }

    ll cal_max = 0;
    REP(l, N + 1) {
        ll cal = accl_v[l] - 2 * x[l - 1] + accr_max_cal[N - l];
        amax(cal_max, cal);
    }
    REP(r, N + 1) {
        ll cal = accr_v[r] - 2 * (C - x[N - r]) + accl_max_cal[N - r];
        amax(cal_max, cal);
    }
    cout << cal_max << endl;

    --x;
    delete [] x;
    return 0;
}

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

using namespace std;

int main()
{
    string s; cin >> s;

    string ss = "AKIHABARA";
    if (s.size() > ss.size()) return cout << "NO\n", 0;

    for (int i = 0; i <= 1 << s.size() + 1; i++) {
        string t;
        for (int j = 0; j <= s.size() + 1; j++) {
            if ((i >> j) & 1) t += "A";
            if (j >= s.size()) continue;
            t += s[j];
        }
        if (t == ss) return cout << "YES\n", 0;
    }
    cout << "NO\n";

    return 0;
}


Measured memory_bytes: 256
let () =
  Scanf.scanf "%d\n" @@ fun n ->
  let arr = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun d -> d in
  let () = Array.fast_sort (fun x y -> y-x) arr in
  let ans = ref 0 in
  for i = 0 to n - 2 do
    if i mod 2 = 0 then ans := !ans + arr.(i/2)
    else ans := !ans + arr.(i/2+1)
  done;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 8344
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

struct Node {
    int key;
    int left;
    int right;
};

int n;
char command[7];

Node tree[500000];
int tree_num;
int root = -1;

inline int create_node(int key) {
    Node& node = tree[tree_num];
    node.key = key;
    node.left = -1;
    node.right = -1;
    return tree_num++;
}

inline void insert(int key) {

    int node = root, parent = -1;

    while (node != -1) {
        parent = node;
        if (key < tree[node].key) {
            node = tree[node].left;
        }
        else {
            node = tree[node].right;
        }
    }
    if (parent == -1) {
        root = create_node(key);
    }
    else if (key < tree[parent].key) {
        tree[parent].left = create_node(key);
    }
    else {
        tree[parent].right = create_node(key);
    }
}

void pre_order(int root) {
    Node& node = tree[root];
    printf(" %d", node.key);
    if (node.left != -1) {
        pre_order(node.left);
    }
    if (node.right != -1) {
        pre_order(node.right);
    }
}

void in_order(int root) {
    Node& node = tree[root];
    if (node.left != -1) {
        in_order(node.left);
    }
    printf(" %d", node.key);
    if (node.right != -1) {
        in_order(node.right);
    }
}

int main(void) {

    scanf("%d", &n);

    for (int i = 0, key; i < n; ++i) {
        scanf("%s", command);
        if (command[0] == 'i') {
            scanf("%d", &key);
            insert(key);
        }
        else {  // print 
            if (root == -1) { continue; }
            in_order(0);
            printf("\n");
            pre_order(0);
            printf("\n");
        }
    }

    return 0;
}

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

int main () {
  int n, k;
  cin >> n >> k;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  sort(l.begin(), l.end(), greater<int>());
  int ans = 0;
  rep(i,k) ans += l[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
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; }

int main(){
    int n, k;
    string s;
    cin >> n >> s >> k;
    char c = s[k-1];
    rep(i,n){
        if (s[i] != c) s[i] = '*';
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>

using namespace std;

int main(){
  
  int H,N;
  cin>>H >> N;
  int damage  = 0;
  int x = 0;
  for(int i=0;i<N;i++){
  	cin >> x;
    damage += x;
  }
  
  if(damage >= H){
  	cout << "Yes"<<endl;
  }else{
  	cout<< "No"<<endl;
  }
  
  return 0;
}	

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

namespace AtCoder.AGC024
{
    class a
    {
        static Dictionary<int, long> fact = new Dictionary<int, long>();

        static void Main(string[] args)
        {
            var line = Console.ReadLine().Trim();
            var spl = line.Split(' ');
            var A = long.Parse(spl[0]);
            var B = long.Parse(spl[1]);
            var C = long.Parse(spl[2]);
            var K = long.Parse(spl[3]);
            Console.WriteLine(K % 2 == 0 ? A - B : B - A);
        }
    }
}


Measured memory_bytes: 13152
package main
 
import (
  "os"
  "fmt"
  "math"
  "bufio"
  "strconv"
)

func nextInt(sc *bufio.Scanner) int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

func main() {
  var n, d, cnt int
  //cache := make(map[int]map[int]bool, 128)
  
  fmt.Scanf("%d %d", &n, &d)
  d2 := d * d
  
  var sc = bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)
  for i := 0; i < n; i++ {
    x, y := nextInt(sc), nextInt(sc)
    if x > y {
      tmp := x
      x = y
      y = tmp
    }
    //if _, ok := cache[x]; !ok {
    //  cache[x] = make(map[int]bool, 128)
    //}
    /*c, ok := cache[x][y]
    if ok {
      if c {
        cnt++
      }
      continue
    }*/
    if math.Abs(float64(x)) > float64(d) || math.Abs(float64(y)) > float64(d) {
      //cache[x][y] = false
      continue
    }
 
    //cache[x][y] = d2 >= x*x + y*y
    //if cache[x][y] {
    //  cnt++
    //}
    if d2 >= x*x + y*y {
      cnt++
    }
  }
  fmt.Printf("%d\n", cnt)
}

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

int main() {
  string S;
  cin >> S;
  if (S=="hi" || S=="hihi" || S=="hihihi" || S=="hihihihi" || S=="hihihihihi" || S=="hihihihihihi" || S=="hihihihihihihi" || S=="hihihihihihihihi" || S=="hihihihihihihihihi" || S=="hihihihihihihihihihi"){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
  return 0;
}

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


int main()
{
	stringstream ss;
    // 入力
    int Q;
    cin>>Q;
    int l[Q],r[Q];
    int maxr=0;
    for(int i=0;i<Q;i++){
    	cin>>l[i]>>r[i];
    	if(maxr<r[i]) maxr=r[i];
    }
    bool prime[maxr+1];
    //list the prime numbers below maxr
    for(int i=1;i<=maxr;i++){
    	prime[i]=true;
    		for(int j=2;j<i;j++){
    			if(i%j==0) {
    				prime[i]=false;
    				break;
    			}
    		}
    }
    prime[1]=false;
    prime[2]=true;
    int numsimilar[maxr+1];
    numsimilar[0]=0;
    for(int i=1;i<=maxr;i++){
    	numsimilar[i]=numsimilar[i-1];
		if(prime[i]){
			if(prime[(i+1)/2]){
				 numsimilar[i]++;
			}
		}    	
    }


    for(int i=0;i<Q;i++){
    	cout<<(numsimilar[r[i]]-numsimilar[l[i]-1])<<endl;
    }
    return 0;
}

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

#define int long long
int dp[123456][10],tdp[123456][10];

void fin(int i,int j,int n){
  if(!n){
    cout<<endl;
    exit(0);
  }
  cout<<j;
  if(i==1){
    cout<<endl;
    exit(0);
  }
  int now=0;
  for(int k=j-1;k<=j+1;k++){
    if(k>=0&&k<=9){
      if(now+dp[i-1][k]>=n){
        fin(i-1,k,n-now);
      }
      now+=dp[i-1][k];
    }
  }
}

signed main(){
  for(int i=0;i<10;i++)dp[1][i]=1;
  for(int i=2;i<123456;i++){
    for(int j=0;j<10;j++){
      for(int k=j-1;k<=j+1;k++){
        if(k>=0&&k<=9)dp[i][j]+=dp[i-1][k];
      }
    }
  }
  int n;cin>>n;int now=0;
  for(int i=1;i<123456;i++){
    for(int j=0;j<10;j++){
      int pi,pj;
      if(j==0){
        pi=i-1,pj=9;
        now+=dp[i][j];
      }
      else pi=i,pj=j-1;
      if(tdp[pi][pj]+dp[i][j]>=now+n)fin(i,j,n+now-tdp[pi][pj]);
      tdp[i][j]=dp[i][j]+tdp[pi][pj];
    }
  }
}


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

signed main(){
    int N;
    cin >> N;
    vector<int>A(N);
    vector<int>B(N);
    vector<int>C(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for(int i = 0; i < N; i++) {
        cin >> B[i];
    }
    for(int i = 0; i < N; i++) {
        cin >> C[i];
    }
    int ans = 0;
    sort(A.begin(),A.end());
    sort(C.begin(),C.end());
    for(int i = 0; i < N; i++) {
        int cnt = 0;
        cnt += lower_bound(A.begin(),A.end(),B[i])-A.begin();
        cnt *= C.end()-(upper_bound(C.begin(),C.end(),B[i]));
        ans += cnt;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;

ll n, m, a[100005], s[100005];
ll lt, rt=1e9, md, ans, cnt, sum, fcnt, fsum;

ll f(ll p) {
	ll i, j = n;
	cnt = sum = 0;
	for(i=1; i<=n; i++) {
		for(; j>0 && a[i]+a[j] >= p; j--);
		cnt += n-j;
		sum += a[i] * (n-j) + s[n] - s[j];
	}
	return cnt>=m;
}

int main() {
	ll i;
	cin >> n >> m;
	for(i=1; i<=n; i++) scanf("%lld", &a[i]);
	sort(a+1, a+n+1);
	for(i=1; i<=n; i++) s[i] = s[i-1] + a[i];
	while(lt <= rt) {
		md = lt + rt >> 1;
		if(f(md)) {
			ans = md, fsum = sum, fcnt = cnt;
			lt = md + 1;
		} else rt = md - 1;
	}
	cout << fsum - (fcnt-m) * ans;
	return 0;
}

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

int main(){
  int W,a,b;
  cin>>W>>a>>b;
  
  if(b-a-W>0){
    cout<<b-a-W<<endl;
  }else if(a-b-W>0){
    cout<<a-b-W<<endl;
  }else{
    cout<<0<<endl;
  }
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
hmax = max(h)
count = 0
while hmax > 0:
    maxindex = [i for i,x in enumerate(h) if x == hmax]
    continueNumberCount = 0
    for i in range(len(maxindex)-1):
        if maxindex[i] == maxindex[i+1] - 1:
            continueNumberCount += 1
    count += len(maxindex) - continueNumberCount
    for i in maxindex:
        h[i] -= 1
    hmax -= 1
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i <= n; i++)
template<class T> inline int chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline int chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<29;
const ll LINF = 1LL<<58;
const int mod = 1000000007;

int n;
string table[310];

int check(int i){
    for (int y = 1; y < n; y++) {
        for (int x = i; x - i < y; x++) {
            if(table[y][x % n] != table[x - i][(y + i) % n]) return 0;
        }
    }
    return 1;
}


int main(){
    cin >> n;
    for (int i = 0; i < n; i++) cin >> table[i];
    int ans = 0;
    for (int i = 0; i < n; i++) ans += check(i) * n;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 764
/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

clock_t time_p=clock();
void aryanc403()
{
#ifdef ARYANC403
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/aryan/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n>>m;
    
    cout<<(n+m-1)/m<<endl;
    return 0;
    
    a.clear();a.reserve(n);

    fo(i,n)
    {
        cin>>in;
        a.pb(in);
    }

}   aryanc403();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string S,T;
  cin>>S>>T;
  vector<vector<int>>dp(S.size()+1,vector<int>(T.size()+1,0));
  for(int i=1;i<=S.size();i++)
  {
    for(int j=1;j<=T.size();j++)
    {
        if(S[i-1]==T[j-1])
        {
          dp[i][j]=1+dp[i-1][j-1];
        }
      else
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    }
  }
  int i=S.size(),j=T.size();
  string ans="";
  while(i>0 && j>0)
  {
     if(S[i-1]==T[j-1])
     {
         ans+=S[i-1];
         i--;
         j--;
     }
     else if(dp[i-1][j]>=dp[i][j-1])
     {
         i--;
     }
     else
     {
        j--;
     }
  }
  reverse(ans.begin(),ans.end());
  cout<<ans;
}


Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

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

	if (x < a)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << 10 << endl;
	}

	return 0;
}


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

int main(void){
    int x,y,a,b,mod_a,mod_b;

    cin >> x >> y;
	a = ( 4*x - y)/2;
    b = ( -2*x + y)/2;
    
  	mod_a = ( 4*x - y)%2;
    mod_b = ( -2*x + y)%2;
  	
    if( (mod_a==0)&&(mod_b==0)&&
        (a>=0)&&(b>=0)){
        cout << "Yes" << endl;
    }
    else{
          cout << "No" << endl;      
    }
     return 0;
}

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

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	
	if (a == b && b == c) {
		if (a % 2 == 0)
			cout << -1 << endl;
		else
			cout << 0 << endl;
	} else {
		int count = 0;
		while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
			int A = (b+c)/2;
			int B = (a+c)/2;
			int C = (a+b)/2;
			
			a = A;
			b = B;
			c = C;
			count++;
		}
		cout << count << endl;
	}
  return 0;
}

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


void solve(int N, std::vector<int> A){
    int temp=0,temp0=0,temp1=0,temp2=0,I=0;
    for(int i=0;i<N;i++){
        if(A[i]>=temp1){temp2=temp1;temp1=A[i];I=i;}
    }
     for(int i=N-1;i>=0;i--){
        if(A[i]>=temp){temp0=temp;temp=A[i];}
    }
    int ans=max(temp2,temp0);

    for(int i=0;i<N;i++){
        if(i!=I){printf("%d\n",temp1);}
        else{printf("%d\n",ans);}
    }

}


int main(){
    int N;
    scanf("%d",&N);
    std::vector<int> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%d",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 2432
k1=int(input())
k2=int(input())
k3=int(input())
k4=int(input())
k5=int(input())
k=0
for i in (k1,k2,k3,k4,k5):
    if i<40:
        k+=40
    else:
        k+=i
print(k//5)       


Measured memory_bytes: 5596
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    if(c - a - b <= 0){
        cout << "No" << endl;
        return 0;
    }
    ll s = (c - a - b) * (c - a - b) - 4 * a * b;
    if(s > 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


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

int main() {
    int N;
    cin >> N;
    vector<int> p(N);
    for (int i = 0; i < N; i++) {
        cin >> p[i];
        p[i]--;
    }
    const int M = 40010;
    vector<int> a(N), b(N);
    for (int i = 0; i < N; i++) {
        a[i] = b[N - 1 - i] = M * i + 1;
    }
    for (int i = 0; i < N; i++) {
        a[p[i]] += i;
    }
    for (int i = 0; i < N; i++) {
        cout << a[i];
        if (i != N - 1) {
            cout << " ";
        } else {
            cout << endl;
        }
    }
    for (int i = 0; i < N; i++) {
        cout << b[i];
        if (i != N - 1) {
            cout << " ";
        } else {
            cout << endl;
        }
    }
}

Measured memory_bytes: 896
from collections import Counter

n = int(input())
data = list(map(int, input().split()))

max_ = 10 ** 6 + 1
b = [True] * (max_ + 1)
data.sort()
c = Counter(data)

ans = 0
for d in data:
    if b[d]:
        for j in range(d, max_, d):
            b[j] = False
        # 複数存在
        if c[d] > 1:
            continue
        else:
            ans += 1

print(ans)


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

num1, num2, num4 = 0, 0, 0
for i in a:
    if i % 4 == 0:
        num4 += 1
    elif i % 2 == 0:
        num2 += 1
    else:
        num1 += 1

if num1 <= num4:
    print('Yes')
elif num1 == num4 + 1 and num2 == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 85348
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  int N,A,B;
  cin>>N>>A>>B;
  if((B-A)%2 == 1)
  {
    cout<<"Borys"<<endl;
  }
  else
  {
    cout<<"Alice"<<endl;
  }
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
int main(){
	bool f[10000];
	memset(f,false,sizeof(f));
	vector<int> dat;
	int n,h,m;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>h>>m;
		int tm=h*100+m;
		if(f[tm])continue;
		f[tm]=true;
		dat.PB(tm);
	}
	int k;
	cin>>k;
	for(int i=0;i<k;i++){
		cin>>h>>m;
		int tm=h*100+m;
		if(f[tm])continue;
		f[tm]=true;
		dat.PB(tm);
	}
	sort(dat.begin(),dat.end());
	for(int i=0;i<dat.size();i++){
		cout<<dat[i]/100<<":";
		if(dat[i]%100<10)cout<<"0";
		cout<<dat[i]%100;
		if(i==dat.size()-1)cout<<endl;
		else cout<<" ";
	}
}

Measured memory_bytes: 1232
#include<iostream>
#include<string>
#include<vector>

int main() {
	int number;
	int temp;
	std::vector<int> value;

	std::cin >> number;
	for (int i = 0; i < number; i++) {
		std::cin >> temp;
		value.emplace_back(temp);
	}

	int count = 0;
	bool OK = true;

	while (OK) {
		for (std::vector<int>::size_type i = 0; i < value.size(); i++)
		{
			if (value[i] % 2 != 0) OK = false;
			else value[i] /= 2;
		}
		if (OK)
			count++;
	}

	std::cout << count << std::endl;

		return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	string s;cin>>s;
	int n=s.size();
	ll dp[n+1];//まず条件に当てはまるものだけ足していく。左右から順々に足していく
	rep(i,n+1) dp[i]=0;//初期化
    
	//s[i]が<ならばdp[i]<dp[i+1]ということ
	for(int i=0;i<n;i++) if(s[i]=='<') dp[i+1]=max(dp[i+1],dp[i]+1);//ここdp[i]+1でもよい

	//s[i]==>ならばdp[i]>dp[i+1]ということ
	for(int i=n-1;i>=0;i--) if(s[i]=='>') dp[i]=max(dp[i],dp[i+1]+1);

	ll ans=0;
	rep(i,n+1) ans+=dp[i];

	cout<<ans<<"\n";
}

Measured memory_bytes: 4740
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
using namespace std;

int S[100001];
int N;

bool binary(int q, int left, int right){
    int mid = (left + right)/2;
    if (right - left == 1) return (S[left] == q);
    
    if (S[mid] == q) return true;
    else if (S[mid] > q) {
        return binary(q, left, mid);
    }else{
        return binary(q, mid, right);
    }
}

int main(){
    int q,Noq;
    cin >> N;
    
    for (int i = 0; i < N; i++) scanf("%d",&S[i]);
    
    cin >> Noq;
    int count = 0;
    
    for (int i = 0; i < Noq; i++) {
        scanf("%d",&q);
        if (binary(q,0,N)) count++;
    }
    
    printf("%d\n",count);
    
    return 0;
}

Measured memory_bytes: 1616
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll MOD=ll(1e9)+7;
const int MAXN=int(1e5);
ll Pow3[MAXN+5];
char S[MAXN+5];
ll a[MAXN+5],c[MAXN+5],kn_fro[MAXN+5],kn_beh[MAXN+5];
int main()
{
	ll f=1;
	for(int i=0;i<=1e5+2;i++) Pow3[i]=f,f*=3ll,f%=MOD;
	scanf("%s",S);int len=strlen(S);
	for(int i=0,totA=0,totkn=0;i<len;i++)
	{
		a[i]=totA;kn_fro[i]=totkn;
		if(S[i]=='A') totA++;
		if(S[i]=='?') totkn++;
	}
	for(int i=len-1,totC=0,totkn=0;i>=0;i--)
	{
		c[i]=totC;kn_beh[i]=totkn;
		if(S[i]=='C') totC++;
		if(S[i]=='?') totkn++;
	}
	ll ans=0;
	for(int i=0;i<len;i++)
		if(S[i]=='?' || S[i]=='B')
		{
			ll O1=a[i]*((c[i]*Pow3[kn_beh[i]+kn_fro[i]])%MOD)%MOD,
			   O2=kn_beh[i]? (a[i]*(kn_beh[i]*Pow3[kn_beh[i]+kn_fro[i]-1]%MOD)%MOD):0ll,
			   O3=kn_fro[i]? (c[i]*(kn_fro[i]*Pow3[kn_fro[i]+kn_beh[i]-1]%MOD)%MOD):0ll,
			   O4=(kn_beh[i] && kn_fro[i])? (kn_fro[i]*(kn_beh[i]*Pow3[kn_fro[i]+kn_beh[i]-2]%MOD)%MOD):0ll;
			ll Sum=((O1+O2)%MOD+(O3+O4)%MOD)%MOD;
			ans+=Sum;
			ans%=MOD;
		}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 4224
import itertools,sys
def f(s):
 for a,b,c,d in itertools.permutations(s):
  for x,y,z in itertools.product('+-*',repeat=3):
   yield f"({a} {x} {b}) {y} ({c} {z} {d})"
   yield f"(({a} {x} {b}) {y} {c}) {z} {d}"
   yield f"{a} {x} ({b} {y} ({c} {z} {d}))"
   yield f"({a} {x} ({b} {y} {c})) {z} {d}"
   yield f"{a} {x} (({b} {y} {c}) {z} {d})"
for e in sys.stdin:
 s=list(map(int,e.split()));a=0
 if sum(s)==0:break
 for m in f(s):
  if eval(m)==10:a='('+m+')';break
 print(a)


Measured memory_bytes: 5672
using System;
using static System.Console;

class Program
{
    public static void Main(string[] args)
    {
        string input = ReadLine();
        WriteLine(CountChar(input, 'o') * 100 + 700);
    }
    public static int CountChar(string input, char c)
    {
        return input.Length - input.Replace(c.ToString(), "").Length;
    }
}

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

int main() {

    int N;
    cin >> N;
    vector<int> A(N), dp(N + 2, INF);
    rep(i, N) cin >> A[i];

    dp[0] = 0;
    rep(i, N) {
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(A[i] - A[i + 1]));
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(A[i] - A[i + 2]));
    }
    cout << dp[N - 1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
signed main()
{
    SPEED;
    int x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;
using P3 = std::tuple<int,int,int>;

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

int N;
P3 ls[40100];

// I want to delete this stupid solution ;(
#define sandwich(x) [](auto a, auto b){return (x)(a, b);}

template <typename T>
using F2 = std::function<T(T,T)>;

template <typename T, int N, typename F = std::plus<T> >
struct SegmentTree{
    SegmentTree(T u, F f = F()){
        size = 1;
        while(size < N){
            size <<= 1;
        }

        unit = u;
        func = f;

        init();
    }
    void init(){
        for(int i=1;i<2*size;++i){
            data[i] = unit;
        }
    }
    void update(int k, T v){
        k += size;
        data[k] = v;

        while(k > 1){
            k >>= 1;
            data[k] = func(data[k*2], data[k*2+1]);
        }
    }
    inline T query(int l, int r){
        return _query(l, r, 1, 0, size);
    }
    T _query(int a, int b, int k, int l, int r){
        if(b <= l || r <= a){return unit;}
        if(a <= l && r <= b){return data[k];}
        int mid = (l + r) >> 1;
        return func(_query(a, b,   2*k,   l, mid),
                    _query(a, b, 2*k+1, mid, r  ));
    }

    T unit, data[N*4];
    int size;
    F func;
};

SegmentTree<ll, 40100> segtree(0);

bool can(double x, function<double(double, P3)> f){
    vector<tuple<double, int> > v;
        
    for(int i=0;i<N;++i){
        double value = f(x, ls[i]);
        v.emplace_back(value, i);
    }

    std::sort(v.begin(), v.end());
        
    segtree.init();

    ll tento = 0;
    for(int i=0;i<N;++i){
        tento += segtree.query(0, N) - segtree.query(0, snd(v[i]));
        segtree.update(snd(v[i]), 1);
    }
    
    return tento >= ((1ll * N * (N - 1) / 2) + 1) / 2;
}

double middle(function<double(double, P3)> f){
    double lb = 1e20, ub = -1e20;

    for(int t=0;t<150;++t){
        double mid = (lb + ub) / 2;

        if(can(mid, f)){
            lb = mid;
        }else{
            ub = mid;
        }
    }

    return lb;
}

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

    std::cin >> N;

    for(int i=0;i<N;++i){
        std::cin >> fst(ls[i]) >> snd(ls[i]) >> thd(ls[i]);
    }

    sort(ls, ls+N, [](const P3& lhs, const P3& rhs){
            return -1. * fst(lhs) / snd(lhs) >= -1. * fst(rhs) / snd(rhs);
        });

    double x = middle([](const double x, const P3& p){
            return -1. * fst(p) / snd(p) * x + 1. * thd(p) / snd(p);
        });
    
    sort(ls, ls+N, [](const P3& lhs, const P3& rhs){
            return -1. * snd(lhs) / fst(lhs) >= -1. * snd(rhs) / fst(rhs);
        });

    double y = middle([](const double x, const P3& p){
            return -1. * snd(p) / fst(p) * x + 1. * thd(p) / fst(p);
        });

    printf("%.12f %.12f\n", x, y);
}


Measured memory_bytes: 3472
#MLE注意！ not は使わず !=
#0や1のケースに注意

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math

    #inf = 10**17
    #mod = 10**9 + 7

    s,w = map(int, input().split())
    if s <= w:
        print('unsafe')
    else:
        print('safe')

if __name__ == '__main__':
    main()

Measured memory_bytes: 65308
using System;
using System.Linq;
using System.Collections.Generic;

class Bmondai
{
    static void Main()
    {
        var N = Int32.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split(' ').Select(x=>Int64.Parse(x)).ToArray();
        var maeArray = new long[N];
        maeArray[0] = A[0];
        var ushiroArray = new long[N];
        ushiroArray[N-1] = A[N - 1];
        var count = 0L;
        //前から
        count = A[0];
        for (int i=1;i<N;++i)
        {
            var a = count < A[i] ? A[i] : count;
            var b = a == count ? A[i] : count;
            count = GetGcd(a, b);
            maeArray[i] = count;
        }
        //後ろから
        count = A[N-1];
        for (int i = N-2; 0 <= i; --i)
        {
            var a = count < A[i] ? A[i] : count;
            var b = a == count ? A[i] : count;
            count = GetGcd(a, b);
            ushiroArray[i] = count;
        }
        //欠けるとき
        count = 0L;
        var ans = long.MinValue;
        var middle = N / 2;
        for (int i = 0; i < N; ++i)
        {
            //前と後ろから
            if (i != 0 && i!=N-1)
            {
                var mae = maeArray[i-1];
                var ushiro = ushiroArray[i + 1];
                var a = mae < ushiro ? ushiro : mae;
                var b = a == mae ? ushiro : mae;
                count = GetGcd(a, b);
            }
            else
            {
                if (i == 0) count = ushiroArray[1];
                else count = maeArray[N - 2];
            }
            if (ans < count) ans = count;
        }
        Console.WriteLine(ans);
    }
    //最大公約数
    static long GetGcd(long a, long b)
    {
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }
}



Measured memory_bytes: 30044
module Main where

import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Control.Monad
import Data.List

main :: IO ()
main = do
    s <- getLine
    t <- getLine
    let tmp = take (length s) t
    let tmp2 = last t
    putStr $ if tmp == s && 'a' <= tmp2 && tmp2 <= 'z' then "Yes" else "No"

Measured memory_bytes: 3728
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

class ABCD
{
public:
	ABCD(){}
	ABCD(int _a, int _b, int _c, int _d)
	{
		a = _a;
		b = _b;
		c = _c;
		d = _d;
	}
	int a;
	int b;
	int c;
	int d;
};

vector<ABCD> vec;
int n, m, q;

int calcScore(long long int in)
{
	int score = 0;

	int seq[10] = {};
	for(int i = 0; i < n; ++i)
	{
		seq[i] = in % 10;
		in /= 10;
	}

	// for(vector<ABCD>::iterator v = vec.begin(); v != vec.end(); v++)
	for(auto v : vec)
	{
		if ((seq[v.a] - seq[v.b]) == v.c)
		{
			score += v.d;
		}
	}
	return score;
}

int create(long long int a, int log)
{
	if (log <= 0)
	{
		return calcScore(a);
	}

	int score = 0;
	for(long long int i = a % 10; i < m; ++i)
	{
		long long int next = a * 10 + i;
		score = max(score, create(next, log - 1));
	}
	return score;
}

void solve()
{
	cin >> n >> m >> q;
	vec = vector<ABCD>(q);

	for (int i = 0; i < q; ++i)
	{
		int a, b, c, d;
		cin >> a >> b >> c >> d;

		// convert a, b to "0 base index".
		vec[i] = ABCD(a - 1, b - 1, c, d);
	}

	cout << create(0, n) << endl;

}

int main()
{
	solve();

	return 0;
}

Measured memory_bytes: 3556
#include<iostream>
#include<cstdlib>

using namespace std;

int top = 0, S[200];


void push(int elem) {
	S[top] = elem; 
	++top;
	return;
}

int pop() {
	--top;
	return S[top];
}

int main() {
	int a, b;
	char C[200];
	while (cin >> C) {
		if (C[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		}

		else if (C[0] == '-') {
			b = pop();
			a = pop();
			push(a - b);
		}

		else if (C[0] == '*') {
			a = pop();
			b = pop();
			push(a*b);
		}
		else {
			push(atoi(C));
		}
	}
	cout << pop() << endl;
	return 0;
}
	

Measured memory_bytes: 3088
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
  int n;
  vector <char> ch;
  string s;
  std::cin>>n;
  std::cin>>s;
  ch.push_back(s[0]);
  int index=1;
  int i;
  for(i=1;i<n;i++)
  {
    if(ch[index-1]!=s[i])
    {
      ch.push_back(s[i]);
      index+=1;
    }
    
  }
  std::cout<<index;
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] c = sc.next().toCharArray();
        int rcnt = 0;
        for (int i = 0; i < n; i++) {
            if (c[i] == 'R') {
                rcnt++;
            }
        }
        int cnt = 0;
        for (int i = 0; i < rcnt; i++) {
            if (c[i] == 'R') {
                cnt++;
            }
        }
        System.out.println(rcnt - cnt);
    }

}


Measured memory_bytes: 41132