akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>

int idx1, idx2;
std::string s1, s2;
unsigned int dp[1010][1010];

int main() {
    std::cin >> s1 >> s2;
    
    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;
    for(unsigned int i = 0; i <= s1.size(); ++i) {
        for(unsigned int j = 0; j <= s2.size(); ++j) {
            if(s1.size() == i && s2.size() == j)
                break;
            
            if(s1[i] == s2[j]) {
                dp[i + 1][j + 1] = std::min(dp[i + 1][j + 1], dp[i][j]);
            }else if(i != s1.size() && j != s2.size()){
                dp[i + 1][j + 1] = std::min(dp[i + 1][j + 1], dp[i][j] + 1);
            }
            
            if(i != s1.size()) {
                dp[i + 1][j] = std::min(dp[i + 1][j], dp[i][j] + 1);
            }
            if(j != s2.size()) {
                dp[i][j + 1] = std::min(dp[i][j + 1], dp[i][j] + 1);
            }
        }
    }
    std::cout << dp[s1.size()][s2.size()] << std::endl;
}

Measured memory_bytes: 7192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
#define inf 0x3f3f3f3f3f3f3f3f
struct Dat
{
	ll mincost;
	int posa,posb,posc,posd,pose;
	ll smallA,smallB,bigA,bigB;
	Dat(){}
	Dat(ll a,ll b,ll c,ll d,ll e,int pa,int pb,int pc,int pd,int pe):
	mincost(a),smallA(b),smallB(c),bigA(d),bigB(e),
	posa(pa),posb(pb),posc(pc),posd(pd),pose(pe){}
}dat[1<<20];
ll A[maxn];
int n;
ll D;
void upd(int x,int l,int r)
{
	dat[x].mincost=dat[x*2].mincost;
	dat[x].posa=dat[x*2].posa;
	if(dat[x*2+1].mincost<dat[x].mincost)
	{
		dat[x].mincost=dat[x*2+1].mincost;
		dat[x].posa=dat[x*2+1].posa;
	}
	
	if(dat[x*2].smallA+dat[x*2+1].bigB<dat[x].mincost)
	{
		dat[x].mincost=dat[x*2].smallA+dat[x*2+1].bigB;
		dat[x].posa=dat[x*2+1].pose;
	}
	
	if(dat[x*2].smallB+dat[x*2+1].bigA<dat[x].mincost)
	{
		dat[x].mincost=dat[x*2].smallB+dat[x*2+1].bigA;
		dat[x].posa=dat[x*2].posc;
	}
	
	if(dat[x*2].smallA<dat[x*2+1].smallA)dat[x].smallA=dat[x*2].smallA,dat[x].posb=dat[x*2].posb;
	else dat[x].smallA=dat[x*2+1].smallA,dat[x].posb=dat[x*2+1].posb;
	
	if(dat[x*2].smallB<dat[x*2+1].smallB)dat[x].smallB=dat[x*2].smallB,dat[x].posc=dat[x*2].posc;
	else dat[x].smallB=dat[x*2+1].smallB,dat[x].posc=dat[x*2+1].posc;
	
	if(dat[x*2].bigA<dat[x*2+1].bigA)dat[x].bigA=dat[x*2].bigA,dat[x].posd=dat[x*2].posd;
	else dat[x].bigA=dat[x*2+1].bigA,dat[x].posd=dat[x*2+1].posd;
	
	if(dat[x*2].bigB<dat[x*2+1].bigB)dat[x].bigB=dat[x*2].bigB,dat[x].pose=dat[x*2].pose;
	else dat[x].bigB=dat[x*2+1].bigB,dat[x].pose=dat[x*2+1].pose;
}
void build(int x,int l,int r)
{
	if(l==r)
	{
		if(l==0)
			dat[x]=Dat(inf,A[l]-D*l,inf,A[l]+D*l,inf,-1,l,-1,l,-1);
		else dat[x]=Dat(inf,inf,A[l]-D*l,inf,A[l]+D*l,-1,-1,l,-1,l);
		
		return;
	}
	int mid=(l+r)>>1;
	build(x*2,l,mid);
	build(x*2+1,mid+1,r);
	upd(x,l,r);
}

void modify(int x,int l,int r,int pos)
{
//	cout<<l<<" "<<r<<" "<<pos<<endl;
	if(pos<l||pos>r)return;
	if(l==r)
	{
//		cout<<"modify "<<l<<endl;
		dat[x]=Dat(inf,A[l]-D*l,inf,A[l]+D*l,inf,-1,l,-1,l,-1);
		return;
	}
	int mid=(l+r)>>1;
	modify(x*2,l,mid,pos);
	modify(x*2+1,mid+1,r,pos);
	upd(x,l,r);
}
int main()
{
	scanf("%d%lld",&n,&D);
	for(int i=0;i<n;i++)scanf("%lld",&A[i]);
	
	build(1,0,n-1);
	
	ll ans=0;
	for(int i=0;i<n-1;i++)
	{
	//	cout<<dat[1].mincost<<" "<<dat[1].posa<<endl;
		ans+=dat[1].mincost;
		modify(1,0,n-1,dat[1].posa);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 35072
N, M = map(int, input().split())
flag = True
ex = [-1]*N
for i in range(M):
  S,C = map(int, input().split())
  if ex[S-1]==-1 or ex[S-1]==C:
    ex[S-1] = C
  else:
    flag = False
    break
if N>1 and ex[0]==0:
  flag = False
if flag:
  for i in range(1,N):
    if ex[i]==-1:
      ex[i] = 0
  if ex[0]==-1 and N>1:
    ex[0] = 1
  elif ex[0]==-1:
    ex[0] = 0
  print(int("".join(map(str, ex))))
else:
  print(-1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A,B;
    cin>>A>>B;
    if((A*B*1)%2==0 && (A*B*2)%2 == 0 && (A*B*3)%2==0){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }

    return 0;
}


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


int keta(unsigned long long n) {
  int ans = 1;
  while(n>=10) {
    n = n/10;
    ans++;
  }

  return ans;
}


int main() {
  int n;
  cin>>n;
  unsigned long long nums[n];
  unsigned long long ans = 1;
  for(int i=0; i<n; i++) {
    cin>>nums[i];
    if(nums[i]==0) {
      cout<<0<<endl;
      return 0;
    }
  }

  for(int i=0; i<n; i++) {
    if(keta(ans)+keta(nums[i])>=20 && ans!=1000000000) {
      cout<<-1<<endl;
      return 0;
    }
    else {
      ans *= nums[i];
    }

    if(ans>1000000000000000000) {
      cout<<-1<<endl;
      return 0;
    }
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 4420
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>

using namespace std;

int main() {
    int N;
    string S, T;
    cin >> N;
    cin >> S >> T;
    string answer = "";
    for(int i=0; i<N; i++){
        answer+=S[i];
        answer+=T[i];
    }

    cout<<answer<<endl;

    return 0;
}

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

using namespace std;

int main() {
    int n, ans = 0;
    cin >> n;
    for(int i=0; i<n+1; i++) {
        string s = to_string(i);
        if(s.size() % 2 == 1 && i != 0) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 200010
#define MOD 998244353
using namespace std;

int N;
int powerTwo[MAX];
char str[MAX];
char number[MAX];
char example[MAX * 2];
int weight[MAX];

int rotate(int i)
{
	int two = !(i & 1);
	i >>= 1;
	i |= (two << (N - 1));
	return i;
}

int add(int a, int b)
{
	return (a + b) % MOD;
}

int sub(int a, int b)
{
	return (a + MOD - b) % MOD;
}

int prod(int a, int b)
{
	return 1LL * a * b % MOD;
}

int main(void)
{
	cin >> N;
	cin >> str;
	powerTwo[0] = 1;
	for (int i = 1; i < N; i++) powerTwo[i] = add(powerTwo[i - 1], powerTwo[i - 1]);
	int K = strlen(str);
	for (int i = 0; i < N - K; i++) number[i] = '0';
	for (int i = N - K; i < N; i++) number[i] = str[i - (N - K)];
	K = 0;
	for (int i = 0; i < N; i++)
	{
		if (number[i] == '1') K = add(K, powerTwo[N - 1 - i]);
		weight[i] = 2 * N;
	}
	weight[N] = 2 * N;
	int ans = prod(2 * N, K + 1);
	for (int i = 3; i <= N; i += 2)
	{
		if (N % i) continue;
		int coeff = 0;
		for (int j = 0; j < N / i; j++)
		{
			if (number[j] == '1') coeff = add(coeff, powerTwo[N / i - 1 - j]);
		}
		weight[i] = sub(weight[i], 2 * N / i);
		ans = sub(ans, prod(coeff, weight[i]));
		for (int j = 0; j < N / i; j++) example[j] = number[j];
		for (int j = N / i; j < N; j++) example[j] = '0' + (example[j - N / i] == '0');
		if (strcmp(example, number) <= 0) ans = sub(ans, weight[i]);
		for (int j = i * 2; j <= N; j += i) weight[j] = sub(weight[j], weight[i]);
	}
	cout << ans << endl;
	return 0;
}


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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fr, to)    for (int i = fr; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 3e5, mod = 998244353;
int n, a[nsz + 5], cnt[3];
num f[nsz + 5], ans = 1;
string s;

struct segment {
    int a, b, c;
    
    segment() {
        a = b = c = 0;
    }
};
segment dat[nsz + 5];

void inline upd(int id, int val) {
    if (!dat[id].a) {
        dat[id].a = val;
    } else if (!dat[id].b) {
        dat[id].b = val;
    } else if (!dat[id].c) {
        dat[id].c = val;
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    f[0] = 1;
    cont (i, nsz) {
        f[i] = f[i - 1] * i % mod;
    }
    cin >> n;
    cin >> s;
    s = ' ' + s;
    cont (i, 3 * n) {
        if (s[i] == 'R') {
            a[i] = ++cnt[0];
            upd(cnt[0], i);
        } else if (s[i] == 'G') {
            a[i] = ++cnt[1];
            upd(cnt[1], i);
        } else if (s[i] == 'B') {
            a[i] = ++cnt[2];
            upd(cnt[2], i);
        }
    }
    for (int i = 1, j = 1; i <= n; ++i) {
        while (j <= n && dat[i].c > dat[j].b) {
            ++j;
        }
        ans *= (num) j - i;
        ans %= mod;
    }
    for (int i = 1, j = 1; i <= n; ++i) {
        while (j <= n && dat[i].b > dat[j].a) {
            ++j;
        }
        ans *= (num) j - i;
        ans %= mod;
    }
    ans *= f[n];
    ans %= mod;
    cout << ans << ln;
}


Measured memory_bytes: 7680
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
struct edge { int to, cap, rev, cost; };

constexpr int MAX_V = 20002;
vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];

void add_edge(int from, int to, int cap, int cost = 0) {
	G[from].push_back(edge{ to, cap, (int)G[to].size(),cost });
	G[to].push_back(edge{ from,0,(int)G[from].size() - 1,-cost });
}

void bfs(int s) {
	fill_n(level, MAX_V, -1);
	queue<int> q;
	level[s] = 0;
	q.push(s);
	while (!q.empty()) {
		int v = q.front(); q.pop();
		for (int i = 0; i < G[v].size(); i++) {
			edge &e = G[v][i];
			if (e.cap > 0 && level[e.to] < 0) {
				level[e.to] = level[v] + 1;
				q.push(e.to);
			}
		}
	}
}
ll dfs(int v, int t, int f) {
	if (v == t)return f;
	for (int &i = iter[v]; i < G[v].size(); i++) {
		edge &e = G[v][i];
		if (e.cap > 0 && level[v] < level[e.to]) {
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
ll max_flow(int s, int t) {
	int flow = 0;
	for (;;) {
		bfs(s);
		if (level[t] < 0)return flow;
		fill_n(iter, MAX_V, 0);
		ll f;
		while ((f = dfs(s, t, INF)) > 0) {
			flow += f;
		}
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w;
	cin >> h >> w;
	vector<string> v(h);
	REP(i, h)cin >> v[i];
	REP(i, h) {
		REP(j, w) {
			REP(k, 4) {
				int ni = i + dy[2*k], nj = j + dx[2*k];
				if (ni < 0 || ni == h || nj < 0 || nj == w) {
					add_edge(i*w + j + 1+h*w, 2*h*w + 1, 1000000);
				}
				else {
					add_edge(i*w + j + 1+h*w, ni*w + nj + 1, 1);
				
				}
			}
			if (v[i][j] == 'X') {
				add_edge(0, i*w + j + 1, 1000000);
				add_edge(i*w + j + 1, i*w + j + 1 + w*h, 1000000);
			}
			else {
				add_edge(i*w + j + 1, i*w + j + 1 + w*h, 1);
			}
			
		}
	}
	ll ans = max_flow(0, 2 * w*h + 1);
	if (ans >= 100000)cout << -1 << endl;
	else cout<<ans << endl;
}


Measured memory_bytes: 3964
import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int arr[][];
        arr = new int[n][3];
        for(int i= 0;i<n;i++){
            for(int j = 0;j<3;j++){
                arr[i][j] = s.nextInt();
            }
        }
        int dp[][] = new int[n][3];
        dp[0][0] = arr[0][0];
        dp[0][1] = arr[0][1];
        dp[0][2] = arr[0][2];
        for(int i = 1;i<n;i++){
            for(int j = 0;j<3;j++){
                if(j == 0) {
                    dp[i][j] = Math.max(arr[i][j] + dp[i - 1][1], arr[i][j] + dp[i - 1][2]);
                }
                else if(j == 1) {
                    dp[i][j] = Math.max(arr[i][j] + dp[i - 1][0], arr[i][j] + dp[i - 1][2]);
                }
                if(j == 2) {
                    dp[i][j] = Math.max(arr[i][j] + dp[i - 1][1], arr[i][j] + dp[i - 1][0]);
                }
                }
            }
        System.out.println(Math.max(dp[n-1][0],Math.max(dp[n-1][1],dp[n-1][2])));

    }
}


Measured memory_bytes: 98868
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> tp(5);
    rep(i,5) {
        cin >> tp.at(i);
    }
    sort(tp.begin(),tp.end());
    int64_t devide = N / tp.at(0);
    int64_t time = 5 ;
    if (N % tp.at(0) == 0) {
        devide -=1;
    }
    time += devide;
    cout << time << endl;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int c = 1;
        String input;
        while (!(input = br.readLine()).equals("0")) {
            bw.append("Case " + (c++) + ": " + input + "\n");
        }
        bw.flush();
    }


}


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

using namespace std;

int h[100001][10];
int val(int n,int a)
{
//	if(n==0)
//	return 0;
//	
//	int i,c,j;
//	c=0;
//	for(i=0;i<3;i++)
//	{
//		
//		if(i==a)
//		{
//			
//			
//		}
//		
//		else
//		{
//		c= max( c, val(n-1,i)+h[n-1][i] );
//		
//			
//			
//		}
//		
//	}
//	
//	return c;
	
	int i,j,k,c;
	int dp[100001][10];
	
	
	for(i=0;i<3;i++)
	dp[0][i]=h[0][i];
	
	
	for(i=1;i<n;i++)
	{
		
		for(j=0;j<3;j++)
		{
			
			c=0;
			for(k=0;k<3;k++)
			{
				if(j!=k)
				{
				c=max(c,dp[i-1][k]+h[i][j]);	
					
					
				}
				
				
			}
			
			dp[i][j]=c;
			
			
		}
		
	}
	
	
	c=0;
	for(i=0;i<3;i++)
	c=max(dp[n-1][i],c);
	
	
	return c;
}
int main()
{
	int t;
	t=1;
	while(t--)
	{
	 int n,i,j;
	 
	 cin>>n;
	 
	 for(i=0;i<n;i++)
	 for(j=0;j<3;j++)
	 cin>>h[i][j];
	
   cout<<val(n,-1);
	
	}



}


Measured memory_bytes: 8064
s = input().split()
s = [int(i) for i in s]
N = s[0]

s = input().split()
a = [int(i) for i in s]

L = [0] * N
L[0] = a[0] - sum(a[1 : ])

if N == 2 : 
    print(abs(a[0] - a[1]))
else : 
    MIN = float("inf")
    for i in range(1 , N - 1 ) : 
        L[i] = L[i - 1] + 2 * a[i]
        if MIN > min( abs(L[i]) , abs(L[i - 1])) : MIN = min( abs(L[i]) , abs(L[i - 1]))
    print(MIN)

Measured memory_bytes: 32556
#include "bits/stdc++.h"

using namespace std;

void Main() {
    vector<int> A(3, 0);
    cin >> A[0] >> A[1] >> A[2];

    sort(A.begin(), A.end());
    if (A[0] == 5 && A[1] == 5 && A[2] == 7) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3528
#include<iostream>
#include<vector>
#include<string>
using namespace std;
// Problem https://atcoder.jp/contests/tenka1-2019-beginner/tasks/tenka1_2019_c
// refer http://drken1215.hatenablog.com/entry/2019/04/21/000500
// (a little arrange)
int solve(int stringLength,string stoneMap){
    vector<int> accumBlackStone(stringLength+1,0),accumWhiteStone(stringLength+1,0);
    int nowPosition;
    // initialize 文字配列の先頭は白も黒も0個
    accumBlackStone[0]=0;
    accumWhiteStone[0]=0;
    for(nowPosition=0;nowPosition < stringLength;nowPosition++){
        if(stoneMap[nowPosition] == '#'){// 黒石の場合 ともに[+0]は不要な気も
            accumBlackStone[nowPosition+1] = accumBlackStone[nowPosition]+1;
            accumWhiteStone[nowPosition+1] = accumWhiteStone[nowPosition]+0; 
        }
        else{
            accumBlackStone[nowPosition+1] = accumBlackStone[nowPosition]+0;
            accumWhiteStone[nowPosition+1] = accumWhiteStone[nowPosition]+1;
        }
    }
    // todo refを参考に 変数leftの左は白を黒に、右は黒を白にしたときの差の一番少ない値を取る
    // 念のためどこをleftにすると良いか出す
   long long answer = 1LL<<60;
    for(int left = 0;left < stringLength+1;left++){
        int changeCounter=0;
        // leftからの左にある白(.)を数える→変換する
        changeCounter = accumBlackStone[left]-accumBlackStone[0];
        // leftから右にある黒(#)を数える。それを先の値に足す。
        changeCounter = changeCounter+(accumWhiteStone[stringLength]-accumWhiteStone[left]);
        // 今あるanswerとどれだけ差があるか。もし小さくなっていれば新たな最小値として設定
        if(changeCounter < answer){
            answer = changeCounter;
        }
        // elseは不要
    }
    return answer;
}

int main(void){
    int answer;
    int N;
    string S;
    cin >> N;
    cin >> S;
    answer = solve(N,S);
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 2308
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    N, C = map(int, input().split())
    D = [list(map(int, input().split())) for _ in range(C)]
    c = [list(map(int, input().split())) for _ in range(N)]
    R = [[] for _ in range(3)]

    for i in range(N):
        for j in range(N):
            r = (i + 1) + (j + 1)
            if r % 3 == 0:
                R[0].append(c[i][j])
            elif r % 3 == 1:
                R[1].append(c[i][j])
            else:
                R[2].append(c[i][j])
    Diff = [[] for _ in range(3)]
    for i in range(3):
        l = len(R[i])

        for color in range(C):
            cnt = 0
            for j in range(l):
                cnt += D[R[i][j] - 1][color]
            Diff[i].append(cnt)
    answer = INF
    for i in range(C):
        for j in range(C):
            for k in range(C):
                if i == j or j == k or k == i:
                    continue
                else:
                    ans = Diff[0][i] + Diff[1][j] + Diff[2][k]
                    if ans < answer:
                        answer = ans
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9744
#include <stdio.h>

int main(void) {
	int n,i,t;
	t=0;
	scanf("%d",&n);
	int a[n],b[n-1];
	for(i=0;i<n-1;i++){
		scanf("%d",&b[i]);
	}
	for(i=0;i<n-2;i++){
		if(b[i]<b[i+1]){
			a[i+1]=b[i];
		}else{
			a[i+1]=b[i+1];
		}
		t+=a[i+1];
	}
	t+=b[0]+b[n-2];
	printf("%d",t);
	
	// your code goes here
	return 0;
}


Measured memory_bytes: 128
/*
ID: yzshang1
LANG: C++11
TASK:
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int (i) = 1; (i) <= (int)n; (i)++)
#define rep(i, n) for (int (i) = 0; (i) < (int)n; (i)++)
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-9;
struct Point {
	long double x, y;
	Point(long double x = 0, long double y = 0) : x(x), y(y) {}
}p[52];
bool equal(long double x, long double y) {
	return abs(x - y) <= EPS;
}
long double dist(long double x1, long double y1, long double x2, long double y2) {
	return sqrt((y2 - y1) * (y2 - y1) + (x2 - x1) * (x2 - x1));
}
int n;
int main() {
	cin >> n;
	cout << fixed << setprecision(12);
	repn(i, n) cin >> p[i].x >> p[i].y;
	long double res, ans = INF;
	if (n == 2) {
		Point A = p[1], B = p[2];
		Point N = Point((B.x + A.x) / 2, (B.y + A.y) / 2);
		cout << dist(A.x, A.y, N.x, N.y) << endl;
		return 0 ;
	}
	repn(p1, n) repn(p2, n) {
		Point A = p[p1], B = p[p2];
		Point O = Point((B.x + A.x) / 2, (B.y + A.y) / 2);
		res = 0;
		repn(pn, n) {
			Point D = p[pn];
			res = max(res, dist(D.x, D.y, O.x, O.y));
		}
		ans = min(ans, res);
	}
	repn(p1, n) for (int p2 = p1 + 1; p2 <= n; p2++) for (int p3 = p2 + 1; p3 <= n; p3++){
		Point A = p[p1], B = p[p2], C = p[p3];
		long double k1, k2, kBC, kAB;
		
		if (C.x == B.x) k1 = 0;
		else if (C.y == B.y) k1 = INF;
		else {
			kBC = (C.y - B.y) / (C.x - B.x);
			k1 = -1 / kBC;
		}
		Point M = Point((B.x + C.x) / 2, (B.y + C.y) / 2);
		long double b1 = M.y - k1 * M.x;
		
		if (B.x == A.x) k2 = 0;
		else if (B.y == A.y) k2 = INF;
		else {
			kAB = (B.y - A.y) / (B.x - A.x);
			k2 = -1 / kAB;
		}
		Point N = Point((B.x + A.x) / 2, (B.y + A.y) / 2);
		long double b2 = N.y - k2 * N.x;
		
	//	cerr << k1 << ' ' << k2 << ' ' << b1 <<  ' ' << b2 << endl;
		if (k2 == k1) continue;
		Point O;
		O.x = (b1 - b2) / (k2 - k1);
		O.y = k1 * O.x + b1;
	//	cerr << O.x << ' ' << O.y << endl;
		
		res = 0;
		repn(pn, n) {
			Point D = p[pn];
	//		cerr << D.x << ' ' << D.y << endl;
	//		cerr << dist(D.x, D.y, O.x, O.y) << endl;
			res = max(res, dist(D.x, D.y, O.x, O.y));
		}
		ans = min(ans, res);
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
    long long int n,sum=0,c=0;
    cin>>n;
    char ch;

    for(int i=1;;i++)
    {
        if(i%3==0 && i%5==0)
        {
           ch=65;
        }
        else if(i%3==0)
        {
            ch=65;
        }
        else if(i%5==0)
        {
            ch=65;
        }
        else{
            sum+=i;

        }
        c++;
        if(c==n)
        {
            cout<<sum;
            break;
        }
    }


    return 0;
}


Measured memory_bytes: 3620
class Node
  attr_accessor :child, :parent
  def initialize
    @child = {}
    @parent = {}
  end
end

v, e = gets.split.map(&:to_i)
g = Array.new(v){Node.new}

edges = {}
e.times{
  s, t = gets.split.map(&:to_i)
  g[s].child[t] = 1
  g[t].parent[s] = 1
  edges[[s,t]] = true
}

list = []
start = []
v.times{|i|
  if g[i].parent.size == 0
    start << i
  end
}

while start.size > 0
  n = start.shift
  list << n
  ed = g[n].child.clone
  ed.each{|m, val|
    g[n].child.delete(m)
    g[m].parent.delete(n)
    edges.delete([n,m])
    start << m if g[m].parent.size == 0
  }
end

puts list

Measured memory_bytes: 24628
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	char c;
	cin >> c;
	switch (c)
	{
		case 'a':
		case 'e':
		case 'i':
		case 'o':
		case 'u':
			cout << "vowel" << endl;
			break;

		default:
			cout << "consonant" << endl;
			break;
	}

	return 0;
}

Measured memory_bytes: 256
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest090-B
#  TODO https://atcoder.jp/contests/abc090/tasks/abc090_b
def checkPalindrom(number):
	numberString = str(number)
	if (numberString[0] == numberString[-1]) and (numberString[1] == numberString[-2]):
		result = True
	else:
		result = False
	return result

def  countPalindrom(checkRange):
	count = 0
	for number in checkRange:
		result=checkPalindrom(number)
		if result :
			count=count+1
	answer = count
	return answer

if __name__ == '__main__':
	A,B = map(int,input().strip().split(' '))
	checkRange = range(A,B+1,1)
	solution=countPalindrom(checkRange)
	print("{}".format(solution))

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n;
	cin >> n;
	rep(z, n) {
		VI a(11);
		rep(i, 10)cin >> a[i];

		VI b, c;
		bool flag = true;
		rep(i, 10) {
			switch (i){
			case 0:
				b.pb(a[0]);
				c.pb(-1);
				break;
			default:
				bool f1, f2;
				int b1 = b.back(), c1 = c.back();

				if (c1 < a[i])f2 = true;
				else f2 = false;
				if (b1 < a[i])f1 = true;
				else f1 = false;

				if (f1&&f2) {
					if (b1 < c1)c.pb(a[i]);
					else b.pb(a[i]);
				}
				else if (f1 && !f2) {
					b.pb(a[i]);
				}
				else if (!f1&&f2) {
					c.pb(a[i]);
				}
				else {
					flag = false;
				}
				break;
			}
		}

		puts(flag ? "YES" : "NO");
	}
}


Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 +10;
const int lim = 18;
int read(){
	int x=0,flag=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')flag=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*flag;
}
stack <int> s;
void out(int x){
	if(!x)s.push(0);
	while(x){s.push(x%2);x/=2;}
	for(int i=lim;i>(int)s.size();i--)printf("0");
	while(!s.empty()){printf("%d",s.top()%2);s.pop();}
	puts("");
}
int n,ans,cnte;
int f[maxn],f2[maxn];
int ai[maxn],label[maxn];
int head[maxn],to[maxn*2],nxt[maxn*2];
int lowbit(int x){return x&(-x);}
void AddEdge(int x,int y){ ++cnte;to[cnte]=y;nxt[cnte]=head[x];head[x]=cnte; }
void init(){
	ai[0] = (1<<lim)-1;
	for(int i=1;i<=lim;i++)ai[i]=ai[i-1]-lowbit(ai[i-1]);
}
int find(int x,int first){ 
	for(int i=first;i<=lim;i++)if(!((1<<i)&x))return i; return -1; 
}
void dfs(int x,int fa){
	for(int i=head[x];i;i=nxt[i])if(to[i]^fa){
		dfs(to[i],x);
		f2[x] |= f[to[i]] & f[x];
		f[x] = f[to[i]] ^ f[x];
	}

//	printf("pro_x:%d\n",x);
//	printf("f1:");out(f[x]);
//	printf("f2:");out(f2[x]);

	label[x] = find(f[x],(!f2[x])?0:32-__builtin_clz(f2[x]));
//	printf("label[x]:%d\n",label[x]);

	ans=max(ans,label[x]);

	f[x] = f[x] & ai[ label[x] ];
	f2[x] = f2[x] & ai[ label[x] ];

	f[x] |= (1<<label[x]);

//	printf("updated_x:%d\n",x);
//	printf("f1:");out(f[x]);
//	printf("f2:");out(f2[x]);
//	puts("");

}
int main(){
//	freopen("test.in","r",stdin),freopen("test.out","w",stdout);
	init();

	n=read();
	for(int i=1;i<=n-1;i++){
		int x,y;
		x=read();y=read();
		AddEdge(x,y);AddEdge(y,x);
	}

	dfs(1,0);
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 9472
#include <iostream>
#include <algorithm>
#include <vector>

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

    int n;
    std::cin >> n;
    std::vector<bool> s(13, true), h(13, true), c(13, true), d(13, true);
    for(int i=0; i<n; ++i){
        char suit;
        int rank;
        std::cin >> suit >> rank;
        switch(suit){
            case 'S': s[rank-1]=false; break;
            case 'H': h[rank-1]=false; break;
            case 'C': c[rank-1]=false; break;
            case 'D': d[rank-1]=false; break;
        }
    }
    for(int i=0; i<13; ++i) if(s[i]) std::cout << "S " << i+1 << "\n";
    for(int i=0; i<13; ++i) if(h[i]) std::cout << "H " << i+1 << "\n";
    for(int i=0; i<13; ++i) if(c[i]) std::cout << "C " << i+1 << "\n";
    for(int i=0; i<13; ++i) if(d[i]) std::cout << "D " << i+1 << "\n";
    return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<string> a(H);
  for (int i = 0; i < H; i++) cin >> a.at(i);
  
  int WW = W;
  
  //後ろから全部白の列を削除
  for (int i = W - 1; i >= 0; i--) {
    int white = 1;
    for (int j = 0; j < H; j++)
      if (a.at(j).at(i) == '#')
        white = 0;
    if (white == 1) {
      for (int j = 0; j < H; j++)
        a.at(j).erase(a.at(j).begin() + i);
      WW--;
    }
  }
  
  //出力、ただし全部白の行はとばす
  string whitestr = string(WW, '.');
    
  for (int i = 0; i < H; i++)
    if (a.at(i) != whitestr)
      cout << a.at(i) << endl;
  
}

Measured memory_bytes: 256
A, B, C =map(int,input().split())
# B should be 7 and A and C should be 5
if A==7:
    a=A
    b=B
    A=b
    B=a
elif C==7:
    c=C
    b=B
    C=b
    B=c
if A==5 and B==7 and C==5:
    print('YES')
else:
   print('NO')

Measured memory_bytes: 9108
#include<stdio.h>
long long MIN(long long a,long long b){return a<b?a:b;}
int main(){
  long long n,m,l,i,j,k,d[310][310],e[310][310];
  scanf("%lld %lld %lld",&n,&m,&l);
  n++;
  for(i=1;i<n;i++){
    for(j=1;j<n;j++)d[i][j]=1e18;
    d[i][i]=0;
  }
  while(m--){
    scanf("%lld %lld %lld",&i,&j,&k);
    d[i][j]=d[j][i]=k;
  }
  for(k=1;k<n;k++){
    for(i=1;i<n;i++){
      for(j=1;j<n;j++)d[i][j]=MIN(d[i][j],d[i][k]+d[k][j]);
    }
  }
  for(i=1;i<n;i++){
    for(j=1;j<n;j++){
      if(d[i][j]<=l)e[i][j]=1;
      else          e[i][j]=1e18;
    }
    e[i][i]=0;
  }
  for(k=1;k<n;k++){
    for(i=1;i<n;i++){
      for(j=1;j<n;j++)e[i][j]=MIN(e[i][j],e[i][k]+e[k][j]);
    }
  }
  scanf("%lld",&m);
  while(m--){
    scanf("%lld %lld",&i,&j);
    if(e[i][j]>1e17)printf("-1\n");
    else printf("%lld\n",e[i][j]-1);
  }
  return 0;
}
		      
    


Measured memory_bytes: 1920
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(solver() ? "Yes" : "No");
        }
        static Boolean solver()
        {
            var XY = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var X = XY[0]; var Y = XY[1];
            if (Y > 4 * X) return false;
            if ((Y % 2) != 0) return false;
            if (Y < 2 * X) return false;
            return true;
        }
    }
}


Measured memory_bytes: 27540
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int c,sum,x,y,z,b;

    cin>>c;
    if(c<5)
    {
        cout<<c<<endl;
    }
    else
    {
        while(c>4)
    {
        sum=c/500;
        x=sum*1000;
        c=c%500;
        y=c/5;
        z=y*5;
        c=c%5;
        b=z+x;
         cout<<b<<endl;
    }


    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(s) int(s.size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int main(){FIN;
	ll x; cin>>x;
	ll now=100,ans=0;
	while(now<x) now+=now/100,ans++;
	cout<<ans<<"\n";
}

Measured memory_bytes: 3652
#include<stdio.h>

int main(void){
	int d[3];
	int k;
	int max;
	int total=0;

	scanf("%d",&d[0]);
	max=d[0];
	scanf("%d",&d[1]);
	if(max>d[1]){
		total+=d[1];
	}
	else{
		total+=max;
		max=d[1];
	}
	scanf("%d",&d[2]);
	if(max>d[2]){
		total+=d[2];
	}
	else{
		total+=max;
		max=d[2];
	}
	scanf("%d",&k);
	for(;k>0;k--)max<<=1;
	printf("%d\n",total+max);

	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
bool kaibun(string S) {
	int N = S.size();
	bool ret = true;
	rep(i, N / 2) {
		if (S[i] != S[N - 1 - i])
			ret = false;
	}
	return ret;
}
signed main() {
	string S;
	cin >> S;
	N = S.size();
	string ans = "Yes";
	M = N / 2;
	if (!kaibun(S))
		ans = "No";
	if (!kaibun(S.substr(0, N / 2)))
		ans = "No";
	if (!kaibun(S.substr(N / 2 + 1, N / 2)))
		ans = "No";
	cout << ans << endl;
	return 0;
}

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

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            //int N, M, K;

            //string[] number = Console.ReadLine().Split(' ');

            //N = int.Parse(number[0]);
            //M = int.Parse(number[1]);
            //K = int.Parse(number[2]);

            //string[] number2 = Console.ReadLine().Split(' ');

            //var A = new List<int>();

            //for (int i = 0; i < N; i++)
            //{
            //    A.Add(int.Parse(number2[i]));
            //}

            //string[] number3 = Console.ReadLine().Split(' ');

            //var B = new List<int>();

            //for (int i = 0; i < M; i++)
            //{
            //    B.Add(int.Parse(number3[i]));
            //}


            ////A.Sort();
            ////B.Sort();





            //int readTime = 0;
            //int ans = 0;

            //while (readTime < K && (A.Count > 0 || B.Count > 0))
            //{
            //    if (A.Count == 0 || A[0] > B[0])
            //    {
            //        if (readTime + B[0] > K)
            //        {
            //            break;
            //        }
            //        else
            //        {
            //            readTime += B[0];
            //            B.RemoveAt(0);
            //            ans++;
            //        }
            //    }
            //    else
            //    {
            //        if (B.Count == 0 || readTime + A[0] > K)
            //        {
            //            break;
            //        }
            //        else
            //        {
            //            readTime += A[0];
            //            A.RemoveAt(0);
            //            ans++;
            //        }
            //    }
            //}

            //Console.WriteLine(ans);



            //var test = new List<int>();
            //test.Add(1);

            //test.RemoveAt(0);

            ////Console.WriteLine(test[0]);

            //if (test.Count == 0)
            //{
            //    Console.WriteLine("aa");
            //}
            //else
            //{
            //    Console.WriteLine("bb");
            //}


            int a = int.Parse(Console.ReadLine());

            Console.WriteLine(a + a*a + a*a*a);
        }
    }
}


Measured memory_bytes: 27264
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>
#include <vector>
#include <list>
#include <iterator>

#include <cmath>

typedef std::pair<double,double> Vec;
typedef std::pair<Vec,Vec> Line;

Vec operator+(const Vec& lhs, const Vec& rhs) {
	return std::make_pair(lhs.first+rhs.first, lhs.second+rhs.second);
}

Vec operator-(const Vec& lhs, const Vec& rhs) {
	return std::make_pair(lhs.first-rhs.first, lhs.second-rhs.second);
}

Vec lineToVec(const Line& l) {
	return l.first - l.second;
}

double cross(const Vec& lhs, const Vec& rhs) {
  return lhs.first*rhs.second - lhs.second*rhs.first;
}

int main(void){
	using namespace std;

	int n;
	cin >> n;

	vector< pair<Line,Line> > input;
	input.reserve(n);

	for(int i=1; i<=n; i++){
		double x1,y1,x2,y2,x3,y3,x4,y4;
		cin
			>> x1 >> y1
			>> x2 >> y2
			>> x3 >> y3
			>> x4 >> y4;

		auto AB = make_pair( make_pair(x1,y1), make_pair(x2,y2) );
		auto CD = make_pair( make_pair(x3,y3), make_pair(x4,y4) );

		input.push_back(make_pair(AB,CD));
	}

	for(auto itr=input.begin(); itr!=input.end(); itr++){
		auto AB = itr->first;
		auto CD = itr->second;

		auto cr = cross( lineToVec(AB), lineToVec(CD) );

		if( abs(cr) <1e-10 ){
			cout << "YES";
		}
		else{
			cout << "NO";
		}
		if( distance( itr, input.end() )>0 ){
			cout << endl;
		}
	}
}

Measured memory_bytes: 1236
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int N;
typedef pair<int,int> P;
int main(){
	cin >> N;
	vector<P> v(N);
	int a;
	for(int i=0;i<N;i++){
		cin >> a;
		v[i] = P(a,i);
	}
	sort(v.begin(),v.end());
	int ans = 0;
	for(int i=0;i<N;i++){
		if(i%2!=v[i].second%2) ans++;
	}
	cout << ans/2 << endl;
}

Measured memory_bytes: 1024
#include <math.h>
#include <stdio.h>
#define PI 3.1415926536
int main() {
	double a, b, x;
	scanf("%lf%lf%lf", &a, &b, &x);
	if (a * a * b <= 2 * x) {
		printf("%.10f\n",
			   atan(2.0 * (a * a * b - x) / (a * a * a)) * 180.0 / PI);
	} else {
		printf("%.10f\n", atan(a * b * b / 2.0 / x) * 180.0 / PI);
	}
	return 0;
}

Measured memory_bytes: 128
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let v:Vec<usize> = (0..n).map(|_| read()).collect();
    let mut ans = v[0];
    for i in 1..n {
        ans = gcd(ans, v[i]);
    }
    println!("{}", ans);
}

fn gcd(a:usize, b:usize) -> usize {
    if b == 0 {
        return a
    }
    return gcd(b, a%b)
}


Measured memory_bytes: 2772
#include<cstdio>
const char c[]={'M','A','R','C','H'};
char s[15];
int a[10];
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s);
		for(int j=0;j<5;j++)
		if(c[j]==s[0]) a[j]++;
	}
	long long ans=0;
	for(int i=0;i<5;i++)
	for(int j=i+1;j<5;j++)
	for(int k=j+1;k<5;k++) ans+=1LL*a[i]*a[j]*a[k];
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 128
//You could not live with your own failure,
//where did that bring you? back to me.
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define vi vector <int>
#define vs vector <string>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll lcm(ll a, ll b){return a*b/__gcd(a, b);}
ll gdp(ll a , ll b){return (a - (a%b)) ;}
ll ld(ll a , ll b){if(a < 0) return -1*gdp(abs(a) , b) ; if(a%b == 0) return a ; return (a + (b - a%b)) ;} // least number >=a divisible by b
ll gd(ll a , ll b){if(a < 0) return(-1 * ld(abs(a) , b)) ;    return (a - (a%b)) ;} // greatest number <= a divisible by b
#define N 500001
vector<int> adj[N];

void DFS(int v, vector<bool>& visited){
	visited[v] = true;
	cout<<v<<" ";
	for(auto i:adj[v]){
		if(visited[i]==false){
			DFS(i,visited);
		}
	}
}

void BFS(int v, vector<bool>& visited){
	queue<int> q;
	q.push(v);
	while(!q.empty()){
		int u = q.front();
		q.pop();
		cout<<u<<" ";
		visited[u]=1;
		for(auto i:adj[u]){
			if(!visited[i])q.push(i);
		}
	}
}

bool isCyclicDFS(int v, vector<bool>& visited, int parent){
	visited[v] = true;
	//cout<<v<<" ";
	for(auto i:adj[v]){
		if(visited[i]==false){
			if(isCyclicDFS(i,visited,v))
				return true;
		}
		else if(i!=parent)return true;
	}
	return false;
}

void topologicalSort(int v, vector<bool>& visited, stack<int>& s){
	visited[v]=true;
	for(auto i:adj[v]){
		if(!visited[i]){
			topologicalSort(i,visited,s);
		}
	}
	s.push(v);
}

void solve()
{
	ll n,k; cin>>n>>k;
	ll cnt=0;
	while(n--){
		ll x,y;
		cin>>x>>y;
		if(x*x+y*y<=k*k)cnt++;
	}
	cout<<cnt<<endl;
}

using namespace std;

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("inp.txt", "r", stdin);
    freopen("outp.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
  	//cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //if(t<T)cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 15568
#include<iostream>
#include<algorithm>
#include<set>
#include<utility>
#include<string>
using namespace std;
  


int main(){
	int n,h;
	while(cin>>n>>h&&(n||h)){
		set<pair<pair<int,int>,int> > s;
		for(int i=0;i<h;i++){
			string c;
			int a,b;
			cin>>c>>a>>b;
			a--;b--;
			if(c=="xy"){
				for(int j=0;j<n;j++)
					s.insert(make_pair(make_pair(a,b),j));	
			}else if(c=="xz"){
				for(int j=0;j<n;j++)
					s.insert(make_pair(make_pair(a,j),b));
			}else{
				for(int j=0;j<n;j++)
					s.insert(make_pair(make_pair(j,a),b));		
			}
		}
		cout<<n*n*n-s.size()<<endl;
	}
    return 0;
}

Measured memory_bytes: 4332
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
   int N;
   cin>>N;
   int a[N];
   rep(i,N){
       cin>>a[i];
   }
   sort(a,a+N);
   cout << a[N-1]-a[0]<<endl;





}


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

using ll = long long;

int main(void) {

    int N;
    std::cin >> N;

    std::vector<ll> a(N);

    int not_mod4 = 0;
    int mod4 = 0;
    int mod2 = 0;

    for ( int i = 0 ; i < N; ++i ) {
        std::cin >> a[i];

        if (a[i] % 4 == 0) {
            mod4++;
        } else {
            if (a[i] % 2 == 0) {
                mod2++;
            } else {
                not_mod4++;
            }
        }
    }

    // std::cout << "mod4:" << mod4 << std::endl;
    // std::cout << "mod2:" << mod2 << std::endl;
    // std::cout << "not_mod4:" << not_mod4 << std::endl;

    // mod2 %= 2;
    // if (mod2 == 0){
    //     if (not_mod4 -1 <= mod4) {
    //         std::cout << "Yes" << std::endl;
    //     } else {
    //         std::cout << "No" << std::endl;
    //     }

    // } else {
    //     not_mmod2
    // }
    mod2 %= 2;
    if (not_mod4 + mod2 - 1 <= mod4) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}

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

int main(){
    int n;
    long min,max,sum;
    cin >> n;
    long work[n];
    for(int i = 0; i < n;i++){
        cin >> work[i];
    }
    max = sum = min = work[0];
    for(int i = 1; i < n;i++){
        if(max < work[i]){
            max = work[i];
        }
        if(min > work[i]){
            min = work[i];
        }
        sum += work[i];
    }
    cout << min << " " << max << " " << sum << endl;
    return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
using Int = long long;
const Int MOD = 1000000007;
int main() {
    int N, K; cin >> N >> K;
    vector<Int> A(N); for (auto &a : A) cin >> a;
    int pos = 0, zero = 0, neg = 0;
    for (auto a : A) {
        if (a > 0) pos++;
        if (a == 0) zero++;
        if (a < 0) neg++;
    }
    sort(begin(A), end(A));
    Int ans = 1;
    if (neg == 0) {
        for (int i = N - K; i < N; i++) {
            ans = (ans * A[i]) % MOD;
        }
    } else if (K == N) {
        for (int i = 0; i < N; i++) {
            if (A[i] < 0) A[i] = MOD - abs(A[i]);
            ans = (ans * A[i]) % MOD;
        }
    } else if (pos == 0 && K % 2 == 0) {
        for (int i = 0; i < K; i++) {
            ans = (ans * abs(A[i])) % MOD;
        }
    } else if (pos == 0 && K % 2 == 1) {
        for (int i = N - K; i < N; i++) {
            ans = (ans * abs(A[i])) % MOD;
        }
        ans = (ans * (MOD - 1)) % MOD;
    } else {
        vector<pair<Int, int>> B;
        for (auto a : A) {
            B.emplace_back(abs(a), a < 0);
        }
        sort(rbegin(B), rend(B));
        vector<Int> plus, minus;
        for (int i = 0; i < N; i++) {
            if (B[i].second == 0) {
                plus.push_back(B[i].first);
            } else {
                minus.push_back(B[i].first);
            }
        }
        int p = K, n = 0;
        while (p > plus.size()) {
            p--, n++;
        }
        if (n % 2 == 1) p--, n++;
        while (p >= 2 && n + 2 <= minus.size()
            && plus[p-1] * plus[p-2] < minus[n] * minus[n+1]) {
            p -= 2, n += 2;
        }
        for (int i = 0; i < p; i++) ans = (ans * plus[i]) % MOD;
        for (int i = 0; i < n; i++) ans = (ans * minus[i]) % MOD;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

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

    int x=0;

    for(int i=0;i<n.length();i++){
        //cout<<x<<endl;
        x+=n.at(i)-'0';
        //cout<<x<<endl;
        //cout<<n.at(i)<<endl;
        x=x%9;
    }
    //cout<<x<<endl;
    if(x==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
 
int main(){
 
    size_t n, m;
    std::cin >> n >> m;
    auto p = std::minmax(n, m);
 
    if(p.first == 1){
        if(p.second == 1){
            std::cout << 1 << std::endl;
        }else{
            std::cout << p.second - 2 << std::endl;
        }
    }else{
        std::cout << (p.first - 2) * (p.second - 2) << std::endl; 
    }
 
    return 0;
}

Measured memory_bytes: 256
// atcoder/arc079/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli k;
  while (cin >> k) {
    const int N = 50;
    vector<lli> a(N, (N - 1) + k / 50);
    for (int i = 0; i < k % N; ++i) {
      a[i] += N;
    }
    for (int i = 0; i < N; ++i) {
      a[i] -= k % N;
    }
    cout << a.size() << endl;
    for (int i = 0; i < a.size(); ++i) {
      if (i) cout << ' ';
      cout << a[i];
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256