akhauriyash/Code-Regression huggingface dataset:
N = int(input())
# N = 10000000019


def make_div(n):
    div = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n//i)

    # divisors.sort()
    return div

def get_center(l):
    if len(l) %2 == 0:
        return l[len(l) // 2 - 1] + l[len(l) // 2 ] - 2
    else:
        return l[len(l) // 2] * 2 - 2

a = sorted(make_div(N))
print(get_center(a))

Measured memory_bytes: 3296
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	int N;
	scanf("%d",&N);

	printf("%d %d\n",N/30,(N%30)*2);

	return 0;
}

Measured memory_bytes: 3220
#include <cstdio>
#include <iostream>
#include <algorithm>

// Definitions
#define MAXN 200010
#define elif else if
typedef long long int64;
typedef long double num128;
typedef unsigned long long uint64;

#define PUTLINE printf("[%d] current line.\n", __LINE__)
#define STARTFUNC printf("[%s] function start.\n", __FUNCTION__)
#define File(s) freopen(#s".in", "r", stdin), freopen(#s".out","w", stdout)

// Improve the speed of read-in.
inline bool IsNum(char x) { return ('0' <= x) && (x <= '9'); }
inline int64 ReadNum() {
  int64 sign = 1, val = 0; char tmp = getchar();
  while (!IsNum(tmp)) { if (tmp == '-') {sign = -sign;} tmp = getchar(); }
  while (IsNum(tmp)) { val = val * 10 + tmp - 48; tmp = getchar(); }
  return val * sign;
}

// Variables
int n, m, ans,
    size[MAXN];

// Disjoint Set
int fa[MAXN];
inline void Init() {
  for (int i = 1; i <= n; i++)
    fa[i] = i;
}
inline int Ancestor(int x) {
  return x == fa[x] ? x : fa[x] = Ancestor(fa[x]);
}
inline bool SameSet(int u, int v) {
  return Ancestor(fa[u]) == Ancestor(fa[v]);
}
inline void Join(int u, int v) {
  if (!SameSet(u, v))
    fa[Ancestor(u)] = fa[Ancestor(v)];
}

// Functions
inline void Process() {
  for (int i = 1; i <= n; i++)
    size[Ancestor(i)]++;
  for (int i = 1; i <= n; i++)
    ans = std::max(size[i], ans);
}
inline void ReadIn() {
  n = ReadNum();
  m = ReadNum();
  Init();
  for (int i = 1; i <= m; i++)
    Join(ReadNum(), ReadNum());
}
inline void PrintAns() {
  printf("%d\n", ans);
}

int main() {
  #ifndef ONLINE_JUDGE
    File(data);
  #endif
  ReadIn();
  Process();
  PrintAns();
  return 0;
}
/*

*/


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

int main() {
	ll n,k; cin>>n>>k;
	vector<pair<ll,ll>> sushi(n);
	vector<ll> replace;
	set<ll> toppings;
	for (ll i=0; i<n; i++)
		cin>>sushi[i].second>>sushi[i].first;

	sort(sushi.begin(),sushi.end());
	reverse(sushi.begin(),sushi.end());

	ll ans=0;
	for (ll i=0; i<k; i++) {
		ans+=sushi[i].first;
		if (toppings.count(sushi[i].second))
			replace.push_back(i);
		toppings.insert(sushi[i].second);
	}
	ans+=toppings.size()*toppings.size();

	ll temp = ans-toppings.size()*toppings.size();
	for (ll i=k; i<n; i++) {
		if (toppings.count(sushi[i].second)) continue;
		if (replace.empty()) break;

		toppings.insert(sushi[i].second);
		temp -= sushi[replace.back()].first;
		temp += sushi[i].first;
		replace.pop_back();

		ll bonus=toppings.size()*toppings.size();
		ans = max(ans,temp+bonus);
	}
	cout << ans << endl;

	return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  string S;
  cin >> S;

  bool has_dash = false;
  rep(i, 0, S.size()) {
    if (S[i] == '-') {
      if (A != 0) {
        cout << "No" << endl;
        return 0;
      }
      has_dash = true;
      continue;
    } else if (has_dash) {
      B--;
    } else {
      A--;
    }
  }

  if (B == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3584
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

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

	int INF=1<<28;
	double EPS=1e-9;

	int n;
	P v;
	C[] cs;

	void run(){
		for(;;){
			n=sc.nextInt();
			if(n==0){
				break;
			}
			int x=sc.nextInt();
			int y=sc.nextInt();
			int z=sc.nextInt();
			v=new P(x, y, z);
			cs=new C[n];
			double maxDist=0;
			for(int i=0; i<n; i++){
				x=sc.nextInt();
				y=sc.nextInt();
				z=sc.nextInt();
				int r=sc.nextInt();
				cs[i]=new C(x, y, z, r);
				maxDist=Math.max(maxDist, cs[i].c.abs()+r);
				// debug(cs[i].c.abs()+r+"");
			}
			v=v.div(v.abs());
			double d=0.01, e=0.00001;
			double e2 = 0.000001;
			P p=new P(0, 0, 0);
			P last=new P(0, 0, 0);
			for(int t=0;;){
				p=p.add(v.mul(d));
				int k=-1;
				for(int i=0; i<n; i++){
					if(cs[i].contains(p)){
						k=i;
					}
				}
				if(k!=-1){
					for(; cs[k].contains(p);){
						p=p.sub(v.mul(e));
					}
					P q=p.add(v.mul(e));
					p=p.add(q).div(2);
					for(; cs[k].contains(p);){
						p=p.sub(v.mul(e2));
					}
					q=p.add(v.mul(e2));
					p=p.add(q).div(2);

					// ½©ÌÉüÁ½ç
					P u=p.sub(cs[k].c);// @ü
					u=u.div(u.abs());// ³K»
					v=v.sub(u.mul(2*v.dot(u)));
					v=v.div(v.abs());
					last=new P(p);
					// debug(p);
					if(++t>=5){
						break;
					}
				}
				// ­U»è
				if(p.abs()>maxDist+10){
					break;
				}
			}
			//println(last.x+" "+last.y+" "+last.z);
			println(String.format("%.3f %.3f %.3f", last.x,last.y,last.z));
		}
	}

	class C{
		P c;
		double r;

		C(double x, double y, double z, double r){
			c=new P(x, y, z);
			this.r=r;
		}

		boolean contains(P p){
			return p.sub(c).abs()+EPS<r;
		}
	}

	class P{
		double x, y, z;

		P(){
			this(0, 0, 0);
		}

		P(double x, double y, double z){
			this.x=x;
			this.y=y;
			this.z=z;
		}

		P(P p){
			this(p.x, p.y, p.z);
		}

		P add(P p){
			return new P(x+p.x, y+p.y, z+p.z);
		}

		P sub(P p){
			return new P(x-p.x, y-p.y, z-p.z);
		}

		P mul(double m){
			return new P(x*m, y*m, z*m);
		}

		P div(double d){
			return new P(x/d, y/d, z/d);
		}

		double abs(){
			return Math.sqrt(abs2());
		}

		double abs2(){
			return x*x+y*y+z*z;
		}

		// àÏ
		double dot(P p){
			return x*p.x+y*p.y+z*p.z;
		}

		public String toString(){
			return String.format("(%.3f, %.3f, %.3f)", x, y, z);
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		try{
			// System.setIn(new FileInputStream("in.txt"));
		}catch(Throwable e){
			e.printStackTrace();
		}
		new Main().run();
	}
}

Measured memory_bytes: 13000
#!/usr/bin/env python3

N = int(input().split()[0])
ab_list = []

for _ in range(N):
    a, b = list(map(int, input().split()))
    ab_list.append((a, b))

count = 0
w_list = ab_list[:]
# 後ろから確定させる
for i in range(N):
    idx = (N - 1) - i
    a, b = ab_list[idx]
    a += count

    if a % b == 0:
        continue

    if a < b:
        count += b - a
    else:
        w = b - (a % b)
        count += w

ans = count
print(ans)


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

using namespace std;
using ll = long long;
using P = pair<int, int>;

// GCD, LCM
// https://youtu.be/8lm8o8L9Bmw?t=2285
// https://youtu.be/XI8exXVxZ-Q?t=3595
// https://youtu.be/F2p_e6iKxnk?t=843
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

void solve(long long K)
{
    ll res = 0;
    for (size_t i = 1; i <= K; i++)
    {
        for (size_t j = 1; j <= K; j++)
        {
            for (size_t k = 1; k <= K; k++)
            {
                res += gcd(gcd(i, j), k);
            }
        }
    }
    cout << res << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long K;
    scanf("%lld", &K);
    solve(K);
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;

// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair

ll h[100005],ans[100005];

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

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

	ll n,i,a,b,c,pa,pb,pc,x,y,z;
	cin >> n >> pa >> pb >> pc;
	for(i=1;i<n;i++)
	{
		cin >> x >> y >> z;
		a=max(pb,pc)+x;
		b=max(pa,pc)+y;
		c=max(pa,pb)+z;
		pa=a;
		pb=b;
		pc=c;
	}
	cout << max(pa,max(pb,pc));
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		
		int N = Integer.parseInt(st.nextToken()); int W = Integer.parseInt(st.nextToken());
		int[] w = new int[N]; int[] v = new int[N];
		
		int sum = 0;
		for(int i=0; i<N; i++) {
			st = new StringTokenizer(br.readLine());
			w[i] = Integer.parseInt(st.nextToken());
			int val = Integer.parseInt(st.nextToken());
			v[i] = val;
			sum += val;
		}
		
		long[] dp = new long[sum+1];
		Arrays.fill(dp, (long) 1e18+5);
		dp[0] = 0;
		for(int i=0; i<N ;i++) {
			for(int j=sum; j>=0; j--) {
				if(j-v[i] >= 0) {
					dp[j] = Math.min(dp[j], dp[j-v[i]]+w[i]);
				}else {
					dp[j] = dp[j];
				}
			}
		}
		
		long ans = 0;
		for(int i=0; i<= sum; i++) {
			if(dp[i] <= W) {
				ans = Math.max(ans, (long) i);
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 33840
#include "bits/stdc++.h"
using namespace std;

using ll = long long;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;

ll n,a,b;
vector<ll> h;

// index が条件を満たすかどうか。主にここを書き換える。
bool isOK(ll t) {
    ll needed = 0;
    for(int i = 0; i < n; i++){
        ll res = h[i] - b * t;
        if(res > 0) needed += (res + a - b - 1) / (a - b);
    }
    if(needed <= t) return true;
    else return false;
}

// 汎用的な二分探索のテンプレ
ll binary_search() {
    ll ng = 0; //「index = 0」が条件を満たすこともあるので、初期値は -1。最終的にはぎりぎり満たさないやつになる。
    ll ok = 1000000000; // 「index = n-1」が条件を満たさないこともあるので、初期値はn。最終的にはぎりぎり満たすやつになる。

    /* ok と ng のどちらが大きいかわからないことを考慮するならabsをつける */
    while ((ok - ng) > 1) {
        ll mid = (ok + ng) / 2;

        if (isOK(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> a >> b;
    h.resize(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    cout << binary_search() << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <algorithm>
#include <map>

using namespace std;

template <typename T>
void readVec(vector<T>& v, int n)
{
	for(int i = 0; i < n; ++i)
			cin >> v[i];
}

int main()
{
	int n;  cin >> n;
	vector<int> v(n);
	readVec(v, n - 1);
	map<int, int> m;
	for(int i = 1; i <=n; ++i) m[i] = 0;
	for(auto& num : v)
			m[num] += 1;
	for(int i= 1; i <= n; ++i)
			cout << m[i] << "\n";
    return 0;
}


Measured memory_bytes: 13552
#include <bits/stdc++.h>
#define ff first
#define ss second

using namespace std;
typedef pair<int, int> pii;

vector <pii> v;
vector <int> beginnings, endings;
vector <int> seg[800200];

void build_tree(int node, int a, int b){
    if(a == b){
        seg[node].push_back(endings[a]);
        return;
    }
    int m = (a + b)/2;
    build_tree(2*node, a, m), build_tree(2*node + 1, m + 1, b);
    merge(seg[2*node].begin(), seg[2*node].end(), seg[2*node + 1].begin(), seg[2*node + 1].end(), back_inserter(seg[node]));
}

int query(int node, int a, int b, int l, int r, int v){
    if(a > r || b < l)  return 0;
    if(l <= a && b <= r){
      return upper_bound(seg[node].begin(), seg[node].end(), v) - seg[node].begin();
    }
    int m = (a + b)/2;
    return query(2*node, a, m, l, r, v) + query(2*node + 1, m + 1, b, l, r, v);
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, m, q, l, r, a, b;
    cin >> n >> m >> q;
    v.resize(m), beginnings.resize(m), endings.resize(m);
    for(int i = 0; i < m; ++i)  cin >> v[i].ff >> v[i].ss;
    sort(v.begin(), v.end()); 
    for(int i = 0; i < m; ++i)  beginnings[i] = v[i].ff, endings[i] = v[i].ss;
    build_tree(1, 0, m - 1);

    for(int i = 0; i < q; ++i){
        cin >> l >> r;
        a = (lower_bound(beginnings.begin(), beginnings.end(), l) - beginnings.begin());
        b = (upper_bound(beginnings.begin(), beginnings.end(), r) - beginnings.begin()) - 1;
            cout << query(1, 0, m - 1, a, b, r) << "\n";
    }

    return 0;
}

Measured memory_bytes: 50036
mod = 1000000007

l = input()
n = len(l)
dp = [[0, 0] for _ in range(n+1)]

dp[0][1] = 1
for i in range(n):
    if l[i] == '1':
        dp[i + 1][0] = (dp[i][0] * 3 + dp[i][1]) % mod
        dp[i + 1][1] = (dp[i][1] * 2) % mod
    else:
        dp[i + 1][0] = (dp[i][0] * 3) % mod
        dp[i + 1][1] = dp[i][1]
print((dp[n][0] + dp[n][1]) % mod)


Measured memory_bytes: 75708
#include <bits/stdc++.h>
#define ll long long 
#define pb push_back
#define MAX 10000005
#define mod 1000000007
#define sp fixed<<setprecision(12)
using namespace std;
/*
vector<int> primes;
ll sumprime[MAX];
bool is_prime[MAX];
void sieve(){
	is_prime[0]=is_prime[1]=true;
	for(int i=4;i<MAX;i+=2){
		is_prime[i]=true;
	}
	for(int i=3;i*i<MAX;i+=2){
		if(!is_prime[i]){
			for(int j=i*i;j<MAX;j+=i){
				is_prime[j]=true;
			}
		}
	}
	for(int i=0;i<MAX;i++){
		if(!is_prime[i]){
			sumprime[i]=sumprime[i-1]+i;
		}else{
			sumprime[i]=sumprime[i-1];
		}
	}
}
*/

int optimal_game(int arr[],int s,int e,vector<vector<int>> &dp){
	if(s>e){
		return 0;
	}
	if(dp[s][e]!=-1){
		return dp[s][e];
	}
	int op1=arr[s]+min(optimal_game(arr,s+2,e,dp),optimal_game(arr,s+1,e-1,dp));
	int op2=arr[e]+min(optimal_game(arr,s,e-2,dp),optimal_game(arr,s+1,e-1,dp));
	return dp[s][e]=max(op1,op2);
}

int main(){

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	//double	pi=3.14159265358979323846;
	//sieve();
	
	int n;
	cin>>n;
	int a[n];
	vector<bool> dp(1000005,true);

	int mx=INT_MIN;
	map<int,int> mp;
	for(int i=0;i<n;i++){
		cin>>a[i];
		mp[a[i]]++;
		mx=max(mx,a[i]);
	}
	
	sort(a,a+n);
	for(auto it:mp){
		int no=it.first;
		
		if(it.second>1){
			dp[no]=false;
		}
		for(int j=2*no;j<=mx;j+=no){
			dp[j]=false;
		}
	}
	
	
	int ct=0;
	for(int i=0;i<n;i++){
		if(dp[a[i]]==true){
			ct++;
		}

	}
	cout<<ct<<"\n";
	

	return 0;
	
}

Measured memory_bytes: 13736
// {{{ Template for Competitive Programming
// -std=c++14 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define FOR(i, a, b)  for (int(i) = (a); (i) < (b); ++(i))
#define CFOR(i, a, b) for (int(i) = (a); (i) <= (b); ++(i))
#define RFOR(i, a, b) for (int(i) = (a); (i) >= (b); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define CREP(i, n) CFOR((i), 0, (n))
#define RREP(i, n) RFOR((i), (n), 0)
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(ALL(x), 0)

const int INF = 1'010'000'000'000'000'017LL;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

using vint = vector<int>;
using pint = pair<int, int>;
// }}}

signed main() {
	int n, k;
	cin >> n >> k;
	vint h(n+1), dp(n+1);
	CFOR(i, 1, n) cin >> h[i];

	dp[1] = 0;
	dp[2] = abs(h[2] - h[1]);

	CFOR(i, 3, n) {
		dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
		CFOR(j, 2, k) {
			if (i - j < 1) break;
			dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
		}
	}

	cout << dp[n] << endl;
}



Measured memory_bytes: 1792
#include<iostream>
#include<string>

int main(){

    size_t n;
    std::cin >> n;

    auto s = std::to_string(n);

    for(size_t i = s.size() - 1; i >= 1; i--){
        if(s[i] < '9'){
            s[i] = '9';
            s[i - 1]--;
        }
    }

    size_t sum = 0;

    for(const auto& e : s){
        sum += e - '0';
    }

    std::cout << sum << std::endl;

    return 0;
}


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



int main()
{
    double x1, y1, x2, y2;
	double r2;

	cin >>  x1 >> y1 >> x2 >> y2;
    r2 = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1);
	printf("%.8f\n", sqrt((double)r2));
    return 0;
}

Measured memory_bytes: 1236
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a_sum = sum(a)
for i in range(n):
    if a[i] > b[i]:
        a[i] -= b[i]
    else:
        b[i] -= a[i]
        a[i] = 0
        a[i+1] = max(a[i+1]-b[i], 0)
print(a_sum-sum(a))

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

#define rep(i,n)  for(int i=0;i<n;++i)
#define per(i,n)  for(int i=n-1;i>=0;--i)
#define sc1(a)  scanf("%d",&a)
#define sc2(a,b)  scanf("%d %d",&a,&b)
#define sc3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define sl1(a)  scanf("%lld",&a)
#define sl2(a,b)  scanf("%lld %lld",&a,&b)
#define sl3(a,b,c)  scanf("%lld %lld %lld",&a,&b,&c)
#define PI 3.1415926535897932

int main(){
    int mod=1000000007;
    int n,m;
    sc2(n,m);
    int a[n][m],b[m];
    rep(i,n) rep(j,m) sc1(a[i][j]);
    rep(i,m) sc1(b[i]);
    rep (i,n) {
        int ans=0;
        rep (j,m)  ans+=a[i][j]*b[j];
        printf("%d\n",ans);
    }
    return 0;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
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,t; cin>>s>>t;
    map<char, int> sm, tm;
    string ans = "Yes";
    for(int i=0;i<s.size();i++){
        sm[s[i]]++; tm[t[i]]++;
        if(sm[s[i]] != tm[t[i]]){
            ans = "No";
            break;
        }
    }
    cout<<ans<<endl;
}

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

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

    if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0])
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    
    return 0;
}

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

bool pat[104][104];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {-1, 0, 1, 0};

int main() {
    int n, m;
    cin >> n;
    bool lf = false;
    while (n--) {
        cin >> m;
        for (int i=0; i<=m+3; ++i) {
            for (int j=0; j<=m+3; ++j) {
                pat[i][j] = (i == 0 || i == m+3 || j == 0 || j == m+3);
            }
        }
        int x = 2;
        int y = m+1;
        int k = 0;
        while (1) {
            pat[y][x] = true;
            if (pat[y + dy[k] * 2][x + dx[k] * 2]) {
                k = (k + 1) % 4;
            }
            int adj = 0;
            for (int i=0; i<4; ++i) {
                if (pat[y + dy[k] + dy[i]][x + dx[k] + dx[i]]) {
                    adj ++;
                }
            }
            if (1 < adj) {
                break;
            }
            x += dx[k];
            y += dy[k];
        }
        if (lf) {
            cout << endl;
        }
        for (int i=2; i<=m+1; ++i) {
            for (int j=2; j<=m+1; ++j) {
                cout << (pat[i][j] ? "#" : " ");
            }
            cout << endl;
        }
        lf = true;
    }
    return 0;
}

Measured memory_bytes: 1160
class B {
    static func solve() {
        let NK = readLine()!.split(separator: " ")
        let N = Int(NK[0])!
        let K = Int(NK[1])!
        let ps = readLine()!.split(separator: " ").map { Int($0)! }.sorted()
        var ans = 0
        for i in 0..<K {
            ans += ps[i]
        }

        print(ans)
    }
}

B.solve()


Measured memory_bytes: 8452
S = list(input())

front = int(S[0]+S[1])
rear = int(S[2]+S[3])


if front <= 12 and front >= 1:
    if rear <= 12 and rear >= 1:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif rear <= 12 and rear >= 1:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3060
import sys
import math
A,B,H,M = list(map(int, input().split()))


a = (H/12+M/720) * 360
b = M/60 * 360

a = a-b
if a > 180:
    a = 360 - a
    

c = math.sqrt(A**2 + B**2 - (2 * A * B * math.cos(math.radians(a))))
print(c)


Measured memory_bytes: 62580
n,m=map(int,input().split())
a=[[int(i) for i in input().split()]for i in range(m)]
s=set()
for i in a:
    if i[1]==n:
        s.add(i[0])
for i in a:
    if i[0]==1 and i[1] in s:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')

Measured memory_bytes: 42364
A,B = map(int,input().split())
S = input()
for i in range(A+B+1):
    if i < A and S[i] == '-':
        print('No')
        exit(0)
    elif i == A and S[i] != '-':
        print('No')
        exit(0)
    elif i > A and S[i] == '-':
        print('No')
        exit(0)
print('Yes')

Measured memory_bytes: 9108
from collections import defaultdict
x,n=map(int,input().split())
p_array=map(int,input().split())
p_map=defaultdict(bool)

for p in p_array:
    p_map[p]=True
ans=0
for i in range(51):
    if not p_map[x-i]:
        ans=x-i
        break
    elif not p_map[x+i]:
        ans=x+i
        break
print(ans)

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

int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll a,b,k;
    cin >> a >> b >> k;
    vector <ll> pos;
    for (int z=1;z<=max(a,b);z++){
    	if (a%z == 0 && b%z == 0){
    		pos.push_back(z);
    	}
    }
    cout << pos[pos.size()-k] << endl;
    cin >> a;
}

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

vector <long long> par;
set <int> R;

long long root(long long v){
	if (par[v] < 0)
		return v;
	return par[v] = root(par[v]);
}

void merge(long long v, long long u){
	v = root(v);
	u = root(u);
	if (v == u)
		return;
	if (par[v] > par[u])
		swap(v, u);
	par[v] += par[u];
	par[u] = v;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long n, m;
	cin >> n >> m;
	par.resize(n, -1);
	// long long ans = 0;
	for (long long i = 0; i < m; i++){
		long long x, y, z;
		cin >> x >> y >> z;
		x --;
		y --;
		merge(x, y);
			// ans --;
	}
	for (int i = 0; i < n; i++){
		R.insert(root(i));
	}
	cout << R.size();
}

Measured memory_bytes: 5760
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
using Graph=vector<vector<int>>;
template<class T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, T b){ if(a>b){ a=b; return 1; } return 0; }

int main(){
    int n;
    cin>>n;
    if(n%1000==0) cout<<0<<endl;
    else cout<<1000-n%1000<<endl;
}

Measured memory_bytes: 3632
/*      ░░█ ▄▀█ █   █▀ █░█ █▀█ █▀▀ █▀▀   █▀█ ▄▀█ █▀▄▀█
        █▄█ █▀█ █   ▄█ █▀█ █▀▄ ██▄ ██▄   █▀▄ █▀█ █░▀░█     */

// Author : Udit "luctivud" Gupta @ (https://www.linkedin.com/in/udit-gupta-1b7863135/)


#include <bits/stdc++.h>
#pragma GCC optimize "trapv"

using namespace std;

typedef long long int lld;
typedef unsigned long long int llu;


#define       TESTCASES()  cin >> (T3X0); T353 = T3X0; while(T3X0--)
#define       _input(V3C)  for(auto &V3C_I7 : (V3C)) cin >> (V3C_I7)
#define mems(A77AY, V4LU)  memset((A77AY), (V4LU), sizeof((A77AY)))
#define  CH3K(I7, E4, S7)  (((S7)<0) ? (I7)>(E4) : (I7)<(E4))
#define for4(I7,S4,E4,S7)  for(auto I7=(S4); CH3K(I7,E4,S7); (I7)+=(S7))




void solveEachTest(lld T35TC453N = 1) {

	lld n, m; cin >> n >> m;

	for4(i, 0ll, m+2ll, 1ll) cout << "#";
	cout << "\n";
	for4(i,0ll, n, 1ll) {
		string s; cin >> s;
		cout << "#" << s << "#\n";
	}
	for4(i, 0ll, m+2ll, 1ll) cout << "#";
	cout << "\n";

	return;
}


signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0);

	lld T3X0 = 0, T353 = 1;

	// TESTCASES()
	solveEachTest(T353 - T3X0);
	return 0;
}
// Random Thought :  null

Measured memory_bytes: 3608
# D - Xor Sum 2

N = int(input())
A = list(map(int, input().split()))

if N == 1:
    print(1)
    exit()

l,r = 0,1 # l<rの場合を考える
tmp_xor = A[l] ^ A[r]
tmp_sum = A[l] + A[r]
ans = N

while 1:
    if tmp_xor == tmp_sum:
        ans += r-l # 先頭l以上、末尾rの部分数列の個数
        r += 1
        if r == N:
            break
        tmp_xor = tmp_xor ^ A[r]
        tmp_sum += A[r]
    elif l+1 < r:
        tmp_sum -= A[l]
        tmp_xor = tmp_xor ^ A[l]
        l += 1
    else:
        l = r
        r += 1
        if r == N:
            break
        tmp_xor = A[l] ^ A[r]
        tmp_sum = A[l] + A[r]

print(ans)

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

int main()
{
    vector<int> x(999);
    rep(i, 999) {
        x[i] = (i + 1) * (i + 2) / 2;
    }
    int a, b;
    cin >> a >> b;
    rep(i, 998) {
        if(b - a == x[i + 1] - x[i]) cout << x[i] - a << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  int a=0;
  int b=abs(arr[1]-arr[0]);
  for(int i=2;i<n;i++)
  {
    int temp=min(a+abs(arr[i]-arr[i-2]),b+abs(arr[i]-arr[i-1]));
    a=b;
    b=temp;
  }

  cout<<b<<endl;
}

Measured memory_bytes: 640
N=int(input())
a=list(map(int,input().split()))
d=[[0]*21 for i in[0]*~-N]
d[0][a[0]]=1
for i in range(1,N-1):
 for j in range(21):
  d[i][j]=(21>j+a[i]and d[i-1][j+a[i]])+(0<=j-a[i]and d[i-1][j-a[i]])
print(d[N-2][a[N-1]])


Measured memory_bytes: 5604
n = map(int, input().split(' '))
cnt1 = 0
cnt2 = 0
for t in n:
    if t == 5:
        cnt1 += 1
    if t == 7:
        cnt2 += 1

if cnt1 == 2 and cnt2 == 1:
    print('YES')
else:
    print('NO')

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

int main(){
    long long a, b, c;cin>>a>>b>>c;
    long long area_1 = a * b;
    long long area_2 = b * c;
    long long area_3 = a * c;

    if (area_1 <= area_2 && area_1 <= area_3){
        if (c % 2 == 0){
            cout << 0 << endl;
            return 0;
        } else {
            cout << area_1 << endl;
            return 0;
        }
    } else if (area_2 <= area_1 && area_2 <= area_3){
        if (a % 2 == 0){
            cout << 0 << endl;
            return 0;
        } else {
            cout << area_2 << endl;
            return 0;
        }
    } else {
        if (b % 2 == 0){
            cout << 0 << endl;
        } else {
            cout << area_3 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int N;cin>>N;
    int a;
    int max=0;
    int ans=0;
    rep(i,N){
        cin>>a;
        if(i==0){
            ans++;
            max=a;
        }else{
            if(max<=a){
                max=a;
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3620
n = int(input())
r = []
for i in range(n):
    r.append(int(input()))
min = r[0]
max_prof = -2000000000000
for i in range(1, n):
    if (r[i] - min) > max_prof:
        max_prof = r[i] - min
    if r[i] < min:
        min = r[i]
print(max_prof)



Measured memory_bytes: 13588
l, k = map(int, input().split())

dpW = [0] * 101
dpB = [0] * 101

dpW[0] = 1

ans = 0
for i in range(1, l + 1):
    if i >= k:
        dpB[i] += dpW[i - k]
        ans += dpW[i - k]
        
    dpB[i] += dpW[i - 1]
    dpW[i] += dpB[i - 1]
    ans += dpW[i - 1]

print(ans)



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=1000010;
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  n %= 10;
  if(n==3){
    cout << "bon" << endl;
  } else if(n==0||n==1||n==6||n==8){
    cout << "pon" << endl;
  } else {
    cout << "hon" << endl;
  }

  return 0;
}

Measured memory_bytes: 3636
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
#define inf 1e9+1
using namespace std;

const int maxn = 210000;

int n;
char str[maxn];
int sum[30];

ll ans;

int main()
{
	scanf("%s",str); n=strlen(str);
	ans=1;
	for(int i=0;i<n;i++)
	{
		ans+=(ll)i-sum[str[i]-'a'];
		sum[str[i]-'a']++;
	}
	printf("%lld\n",ans);
	
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        check(num);
    }

    public static void check(int num) {
        int cnt=0;
        for(int i=1;i<=num;i++) {
            if(String.valueOf(i).length() % 2 == 1) {
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}

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

int main() {
int a,b;
cin >> a >> b;
int all = a*b;
int x = a+b -1;
cout << all -x << endl;
}
  


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a, b, c, i, sum;
    scanf("%d", &a);
    sum = 0;
    for(i = 0; i < a; i++){
        scanf("%d%d", &b,&c);
        sum = sum + (c - b + 1);
    }
    printf("%d", sum);
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
N, M = map(int,input().split())
A = [int(x) for x in input().split()]
BC = [list(map(int,input().split())) for i in range(M)]

A.sort()
BC.sort(key=lambda x: -x[1])

i = 0
temp = 0
change = 0
while i < N and temp < M :
    if A[i] < BC[temp][1] :
        A[i] = BC[temp][1]
        i += 1
        change += 1
    else :
        break
    if change == BC[temp][0] :
        temp += 1
        change = 0

print(sum(A))


Measured memory_bytes: 73624
def guess(N,M,S,C,guess_num):
    no_num=False
    if len(guess_num)!=1:
        guess_num[0]=1
    else:
        pass

    num_input=[0 for n in range(N)]
    for m in range(M):
        if num_input[S[m]-1]==0 or guess_num[S[m]-1]==C[m]:
            guess_num[S[m]-1]=C[m]
            num_input[S[m]-1]=1
        else:
            no_num=True
            break
    
    if no_num==True or (len(guess_num)!=1 and guess_num[0]==0):
        return -1
    else:
        return int("".join(map(str,guess_num)))

def main():
    #initialize
    NM=[]
    SC=[]
    #input
    NM=list(map(int,input().strip().split()))
    N=NM[0]
    M=NM[1]
    for n in range(M):
        SC.append(list(map(int,input().strip().split())))
    S=[SC[i][0] for i in range(M)]
    C=[SC[j][1] for j in range(M)]

    guess_num=[0 for n in range(N)]
    
    print(guess(N,M,S,C,guess_num))

main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, m;
    cin >> n >> m;
    set<P> s;
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        if(a > b)swap(a, b);
        s.insert(make_pair(a, b));
    }
    vector<vector<int>> to(n);
    rep(i, n)rep(j, n){
        if(i >= j)continue;
        if(s.find(make_pair(i, j)) == s.end()){
            to[i].push_back(j);
            to[j].push_back(i);
        }
    }

    vector<int> a, b;
    vector<int> d(n, -1);
    rep(i, n){
        if(d[i] != -1)continue;
        d[i] = 0;
        int cnt1 = 1;
        int cnt2 = 0;
        queue<int> que;
        que.push(i);
        while(!que.empty()){
            int v = que.front();
            que.pop();
            for(int t : to[v]){
                if(d[t] != -1){
                    if(d[v] == d[t]){
                        cout << -1 << endl;
                        return 0;
                    }
                    continue;
                }
                if(d[v] == 0){
                    d[t] = 1;
                    cnt2++;
                }
                else{
                    d[t] = 0;
                    cnt1++;
                }
                que.push(t);
            }
        }
        a.push_back(cnt1);
        b.push_back(cnt2);
    }

    int k = a.size();
    vector<vector<bool>> dp(k+1, vector<bool>(n+1, false));
    dp[0][0] = true;
    rep(i, k){
        rep(j, n){
            if(dp[i][j] && j + a[i] <= n){
                dp[i+1][j+a[i]] = true;
            }
            if(dp[i][j] && j + b[i] <= n){
                dp[i+1][j+b[i]] = true;
            }
        }
    }

    int ans = 1001001001;
    rep(i, n+1){
        if(dp[k][i]){
            int a = i;
            int b = n - i;
            ans = min(ans, a * (a - 1) / 2 + b * (b - 1) / 2);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 15060
//Problem *
#include<bits/stdc++.h>
using namespace std;
const int N=3005;
int n,m,dp[N][N],e[N][N],t;
char a[N],b[N],s[N];
int main(){
	scanf("%s%s",a+1,b+1);n=strlen(a+1),m=strlen(b+1);
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++){
		int x=dp[i][j-1],y=dp[i-1][j],z=dp[i-1][j-1]+1;
		if(x<y)dp[i][j]=y,e[i][j]=1;else dp[i][j]=x;
		if(a[i]==b[j]&&dp[i][j]<z)dp[i][j]=z,e[i][j]=2;
	}
	int x=n,y=m;
	while(x&&y){
		if(e[x][y]==2)s[++t]=a[x],--x,--y;
		else{if(e[x][y])--x;else --y;}
	}
	for(int i=t;i;i--)printf("%c",s[i]);
	return 0;
}

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

int a[6];

class Dice{
  public:
   
    Dice(int aa, int bb, int cc, int dd, int ee, int ff){
        a[0] = aa;
        a[1] = bb;
        a[2] = cc;
        a[3] = dd;
        a[4] = ee;
        a[5] = ff;
    }
    
    void roll_N(int aaa, int bbb, int ccc, int ddd, int eee, int fff){
        a[0] = bbb;
        a[1] = fff;
        a[2] = ccc;
        a[3] = ddd;
        a[4] = aaa;
        a[5] = eee;
    }
    
    void roll_S(int aaa, int bbb, int ccc, int ddd, int eee, int fff){
        a[0] = eee;
        a[1] = aaa;
        a[2] = ccc;
        a[3] = ddd;
        a[4] = fff;
        a[5] = bbb;
    }
    
    void roll_E(int aaa, int bbb, int ccc, int ddd, int eee, int fff){
        a[0] = ddd;
        a[1] = bbb;
        a[2] = aaa;
        a[3] = fff;
        a[4] = eee;
        a[5] = ccc;
    }
    
    void roll_W(int aaa, int bbb, int ccc, int ddd, int eee, int fff){
        a[0] = ccc;
        a[1] = bbb;
        a[2] = fff;
        a[3] = aaa;
        a[4] = eee;
        a[5] = ddd;
    }
};

int main(){
    int A, B, C, D, E, F;
    int q, up, front;
    
    cin >> A >> B >> C >> D >> E >> F;
    cin >> q;
    
    for(int i = 0; i < q; i++){
        cin >> up >> front;
        Dice sai(A, B, C, D, E, F);
        
        for(int j = 0; j < 5; j++){
            if(front == a[1]) break;
            
            sai.roll_N(A, B, C, D, E, F);
            A = a[0];
            B = a[1];
            C = a[2];
            D = a[3];
            E = a[4];
            F = a[5];
        }
        
        if(front != a[1]){
            sai.roll_E(A, B, C, D, E, F);
            A = a[0];
            B = a[1];
            C = a[2];
            D = a[3];
            E = a[4];
            F = a[5];
            
            for(int k = 0; k < 5; k++){
                if(front == a[1]) break;
            
                sai.roll_N(A, B, C, D, E, F);
                A = a[0];
                B = a[1];
                C = a[2];
                D = a[3];
                E = a[4];
                F = a[5];
            }
        }
        
        for(int j = 0; j < 5; j++){
            if(up == a[0]) break;
            
            sai.roll_E(A, B, C, D, E, F);
            A = a[0];
            B = a[1];
            C = a[2];
            D = a[3];
            E = a[4];
            F = a[5];
        }
         
    cout << a[2] << endl;
    }
}



Measured memory_bytes: 3104
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		double A = 0;
		for(int i = 0; i < N; i++) {
			double a = sc.nextDouble();
			A += 1 / a; 
		}
		sc.close();
		System.out.println(1 / A);
	}
}


Measured memory_bytes: 24272
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    ll ans = 0;
    fori (i, 1, n + 1) {
        fori (j, 1, n + 1) {
            fori (k, 1, n + 1) {
                int f = gcd(i, j);
                int g = gcd(f, k);
                ans += g;
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N;
    cin >> N;
    double v[N];
    for(int i=0;i<N;i++){
        cin >> v[i];
    }
    if(N==1){
        cout<< v[0];
        return 0;
    }
    sort(v, v+N);
    for(int i=1;i<N;i++){
        v[i]=(v[i]+v[i-1])/2.0;
    }
    cout<<v[N-1];
    return 0;
}

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


using namespace std;



#define For(i,x,n)  for(long long i=x;i<n;i++)
#define rFor(i,x,n) for(long long i=x;i>=n;i--)
#define itFor(it,st)   for(auto it=st.begin() ; it!=st.end() ; it++)
#define MOD 1000000007
#define PI 3.141592653589793
#define INF 999999999999999999
#define N 1000005
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sp " "
#define cont continue
#define brk break

#define deb1(x)                cout<<#x<<": "<<x<<endl
#define deb2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define deb3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define deb4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define deb5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define deb6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

using namespace std;

int main()
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed;
    cout<<setprecision(3);
    srand(time(NULL));

    string s,t;
    cin>>s>>t;
    ll cnt = 0;
    For(i,0,s.size()){
        if(s[i]!=t[i])
            cnt++;
    }
    cout<<cnt;
    
    //cout<<"\nTime used = "<<static_cast<double>(clock())/(CLOCKS_PER_SEC)<<"s"<<endl;  // - for checking time used for a test case
    return 0;
}

//s1.substr(1,3) - return 3 characters starting from position 1 as substring of string sz1. eg sz1="shreynumh" sz1.substr(2,5)="reyan"
//num = atoi(s.c_str()); //convert string s to integer num
//n.erase(i,std::string::npos); //erase i th position in string n , decreasing string size
//s.find(b)!= std::string::npos - finds string b in string a - true if found
//cout<<"Time used = "<<static_cast<double>(clock())/(CLOCKS_PER_SEC)<<"s"<<endl;  // - for checking time used for a test case                


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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))
#define int ll

const int N = 1e5 + 5;
int dp[N];
bool cant[N];
int n;
int calc(int i){
    if(i > n)return 0;
    if(cant[i])return 0;
    if(i == n){
        return 1;
    }

    if(dp[i] != -1){
        return dp[i];
    }
    return dp[i] = ((calc(i + 1)%MOD) + calc(i + 2)%MOD)%MOD;
}
int32_t main(){
    FAST
    int m;
    cin >> n >> m;
    memset(dp, -1, sizeof(dp));
    for(int i = 0; i < m; i++){
        int a; cin >> a;
        cant[a] = 1;
    }
    cout << calc(0);
    return 0;
}


Measured memory_bytes: 7504
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

#maincode-------------------------------------------------
n = ini()
s = input()
r = s.count('R')
g = s.count('G')
b = s.count('B')
ans = r*g*b

for j in range(n):
    for i in range(j):
        k = 2*j-i
        if k < n:
            if (s[i] == s[j]):
                continue
            if (s[i] == s[k]):
                continue
            if (s[j] == s[k]):
                continue
            ans -= 1
print(ans)

Measured memory_bytes: 73528
/*Flow..................*/
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
#include <list>
#include <deque>
#include <bitset>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <sstream>
#include <complex>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <climits>
#include <utility>
#include <ctime>
#include <tuple>
#include <fstream>
#include <cctype>
#define FOR(i,a,n) for(i=a;i<n;i++)
#define FORD(i,a,n) for(i=a;i>=n;i--)
#define FORS(i,a) for(i=0;a[i];i++)
#define si(x) scanf("%d",&x)
#define sc(x) cin>>x
#define sd(x) scanf("%lf",&x)
#define sll(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define prs(x) printf("%d ",x)
#define pls(x) printf("%lld ",(long long)x)
#define pc(x) printf("%c",(char)x)
#define pi(x) printf("%d\n",x)
#define pd(x) printf("%0.10lf\n",x);
#define pll(x) printf("%lld\n",(long long)x)
#define ps(x) printf("%s\n",x)
#define M 1000000007
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define pb push_back
#define fr first
#define se second
#define in insert
#define er erase
#define pii pair<int, int>
#define plll pair<long long, long long>
#define PI 3.14159265358979323846264338327950288419716939937510582097494459230
#define bs(x,y,z,w) {cerr<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w<<"="<<w<<endl;}
#define ts(x,u,y,z,w) {cerr<<x<<" "<<#u<<"="<<u<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w<<"="<<w<<endl;}
#define trace(x) {cerr << #x << "=" << x <<endl;}
#define trace2(x, y) {cerr << #x << "=" << x << " " << #y << "=" << y <<endl;}
#define trace3(x, y, z) {cerr << #x << "=" << x << " " << #y << "=" << y << " " << #z << "=" << z << endl;}
using namespace std;
template <typename T> ostream& operator<<(ostream& os, const vector<T> &p){os << "[ "; for (T x: p) os << x << " "; os << "]" << endl; return os;}
template <typename T> ostream& operator<<(ostream& os, const set<T> &p){os << "{ "; for (T x: p) os << x << " "; os << "}" << endl; return os;}
template <typename T> ostream& operator<<(ostream& os, const multiset<T> &p){os << "{ "; for (T x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const map<Tk, Tv> &p){os << "{ "; for (pair<Tk, Tv> x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const pair<Tk, Tv> &p){os << "{" << p.first << ',' << p.second << "}";return os;}
ll gcd (ll a, ll b) {return ( a ? gcd(b%a, a) : b );}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n&1) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n&1) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}

char a[200005];
ll f[26];

int main()
{
   int i,j;
	ss(a);
	ll ans=0;
	FORS(i,a)
	{
		ans=ans+(ll)i-f[a[i]-'a'];
		f[a[i]-'a']++;
	}	   
	pll(ans+1);
   return 0;
}


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

// vector<int> dp(100000, 1e9);

int main()
{
    ll N,t;
    ll count = 0;
    std::vector<int> H;
    scanf("%lld", &N);
    rep(i, N)
    {
        scanf("%lld", &t);
        H.push_back(t);
    }
    sort(H.begin(), H.end());
    rep(i,N-1){
        if(H[i]==H[i+1])
            count++;
    }
    if(count == 0)printf("YES");
    else printf("NO");

    return 0;
}

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

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

    int o1,o2,o3,o4;
    int both = min(x,y);
    o1 = a*x + b*y;
    o2 = 2*c*both + (x-both)*a + (y-both)*b;
    o3 = 2*c*x + b*max(y-x, 0);
    o4 = 2*c*y + a*max(x-y, 0);

    int out = min({o1,o2,o3,o4});

    cout << out << endl;

	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

def judge() :
    for i in range(N - M + 1) :
        for j in range(N - M + 1) :
            flg = True
            for k in range(M) :
                for l in range(M) :
                    if A[i+k][j+l] != B[k][l] :
                        flg = False
                        break
                    if not flg :
                        break
            if flg :
                return 'Yes'
                    
    return 'No'
    
print(judge())

Measured memory_bytes: 40048