akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Problems 1257
Problem A: Sum of Consecutive Prime Numbers
"""
import math
def eratosthenes(n):
    """
    エラトステネスのふるい
    """
    primes = [i for i in range(n)]
    primes[1] = 0 # 1は素数ではない
    for prime in primes:
        if prime > math.sqrt(n):
            break
        if prime == 0:
            continue
        for non_prime in range(2 * prime, n, prime): # primeの分、合成数をふるいかけていく
            primes[non_prime] = 0 # 素数でない要素は0にする
    prime_list = []
    for prime in primes:
        if prime != 0:
            prime_list.append(prime)
    return prime_list

# 素数を生成
primes = eratosthenes(11000)
while True:
    n = int(input())
    if n == 0:
        break
    r = 1
    ans = 0
    for i in range(len(primes)): # 生成した素数リストから使用する範囲を決定する
        if n <= primes[i]: # 与えられた正の整数がi番目の素数以上ならそのiを使用する範囲にする
            r = i + 1
            break
    for i in range(r):
        sum = 0
        for j in range(i, r):
            sum += primes[j]
            if n == sum:
                ans += 1
                break
            if sum > n:
                break
    print(ans)



Measured memory_bytes: 5844
#include<stdio.h>

int main(void)
{
  int n,m,c;
  scanf("%d%d%d",&n,&m,&c);

  int i,j,a[n][m],b[m];
  for(i=0;i<m;i++)
    scanf("%d",&b[i]);
  for(i=0;i<n;i++)
    for(j=0;j<m;j++)
      scanf("%d",&a[i][j]);

  int add,ans=0;
  for(i=0;i<n;i++){
    add=0;

    for(j=0;j<m;j++)
      add += a[i][j]*b[j];

    add += c;

    if(add>0)
      ans++;
  }

  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
N = input()
a = list(map(int, input(). split()))
count = 0

for k in range(8):
    if len([i for i in a if 400*k <= i < 400*(k + 1)]) > 0:
        count += 1

r =  len([i for i in a if 3200 <= i])
print('{} {}'.format(max(1, count), count + r))

Measured memory_bytes: 3060
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-11
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 500031;

int w[N];
long long ar[1000][1000],T[1000][1000],D[1000][1000],ans;
int n;
vector<pair<int,pair<int,int> > > order;

int get(int x)
{
	if (x==w[x])
		return x;
	return w[x]=get(w[x]);
}

void merge(int a,int b)
{
	a=get(a);
	b=get(b);
	w[a]=b;
}

int main(){
	//freopen("tree.in","r",stdin);
	//freopen("tree.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin>>n;
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=n;j++)
		{
			cin>>ar[i][j];
			order.push_back(make_pair(ar[i][j],make_pair(i,j)));
		}
	}

	sort(order.begin(),order.end());

	for (int i=1;i<=n;i++)
	{
		w[i]=i;
	}

	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=n;j++)
		{
			D[i][j]=1e18;
		}
		D[i][i]=0;
	}

	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=n;j++)
		{
			T[i][j]=ar[i][j];
		}
	}

	for (int k=1;k<=n;k++)
	{
		for (int i=1;i<=n;i++)
		{
			for (int j=1;j<=n;j++)
			{
				T[i][j]=min(T[i][j],T[i][k]+T[k][j]);
			}
		}
	}

	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=n;j++)
		{
			long long best=1e18;
			for (int k=1;k<=n;k++)
			{
				if (k==i||k==j)
					continue;
				best=min(best,T[i][k]+T[k][j]);
			}
			if (best>ar[i][j])
				ans+=ar[i][j],
				D[i][j]=ar[i][j];
		}
	}

	for (int k=1;k<=n;k++)
	{
		for (int i=1;i<=n;i++)
		{
			for (int j=1;j<=n;j++)
			{
				D[i][j]=min(D[i][j],D[i][k]+D[k][j]);
				if (ar[i][k]+ar[k][j]<ar[i][j]){
					cout<<-1<<endl;
					return 0;
				}
			}
		}
	}

	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=n;j++)
		{
			if (ar[i][j]!=D[i][j])
			{
				cout<<-1<<endl;
				return 0;
			}
		}
	}

	cout<<ans/2<<endl;

	cin.get(); cin.get();
	return 0;
}



Measured memory_bytes: 15348
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <functional>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
using namespace std;
// #define int long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = (((1<<30)-1)<<1)+1;
const int nINF = 1<<31;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, int> pci;

/////////////////////////////////////////////////////////////////////

const int N = 2e5+10;
int n, m, c[N], good[N], vis[N], path[N], rn[N], bn[N];
vector<int> g[N];

void yes() {
	cout << "Yes" << endl;
	exit(0);
}

void dfs(int s) {
	vis[s] = 1;
	path[s] = 1;
	for(int v : g[s]) {
		if(!good[v]) continue;
		if(path[v]) yes();
		if(!vis[v]) dfs(v);
	}
	path[s] = 0;
}

signed main() {
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);
    memset(vis, 0, sizeof(vis));
    memset(path, 0, sizeof(path));
    memset(rn, 0, sizeof(rn));
    memset(bn, 0, sizeof(bn));
    cin >> n >> m;
    FOR(i, 1, n) {
    	char ch;
    	cin >> ch;
    	c[i] = (ch == 'B');
    }
    REP(i, m) {
    	int a, b;
    	cin >> a >> b;
    	g[a].push_back(b);
    	g[b].push_back(a);
    }
    FOR(i, 1, n) {
    	for(int v : g[i]) {
    		if(c[v]) ++bn[i];
    		else ++rn[i];
    	}
    	if(rn[i] && bn[i]) good[i] = true;
    	else good[i] = false;
    }
    queue<int> nxt;
    FOR(i, 1, n) {
    	if(!good[i]) continue;
    	for(int v : g[i]) {
    		if(!good[v]) {
    			if(c[v]) --bn[i];
    			else --rn[i];
    		}
    	}
    	if(!rn[i] || !bn[i]) {
			vis[i] = 1;
			nxt.push(i);
    	}
    }
    while(!nxt.empty()) {
    	int cur = nxt.front();
    	nxt.pop();
    	good[cur] = 0;
    	for(int v : g[cur]) {
    		if(good[v]) {
    			if(c[cur]) --bn[v];
    			else --rn[v];
	    		if(!vis[v] && (!rn[v] || !bn[v])) {
	    			vis[v] = 1;
	    			nxt.push(v);
	    		}
    		}
    	}
    }
    memset(vis, 0, sizeof(vis));
    FOR(i, 1, n) {
    	if(good[i] && !vis[i]) dfs(i);
    }
    cout << "No" << endl;

    return 0;
}

// Easy things to check:
// - LONG LONGS (WA)
// - const int N is correct (WA, RTE)
// - .size()-k underflow (WA, RTE, TLE)
// - small n edge cases (WA)

// Rare mistakes made in the past:
// - division by 0 (WA)
// - integer division (WA)
// - setprecision (WA)
// - INF not big enough using ll (WA)
// - setting min to 0 instead of -INF (WA)
// - outputting debug (WA)
// - allocating too much memory (locRTE, MLE)
// - stack size (locRTE)


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

int main(){
    int N, Q;
    string S;
    cin >> N >> Q >> S;
    int l[N], r[N], c[N];

    for(int i = 0; i < Q; i++){
        cin >> l[i] >> r[i];
    }

    c[0] = 0;

    for(int i = 1; i < N; i++){
        if(S[i-1] == 'A' & S[i] == 'C'){
            c[i] = c[i-1] + 1;
        }
        else{
            c[i] = c[i-1];
        }
    }

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

Measured memory_bytes: 2176
import sys
def main(lines):
  n = int(lines[0])
  a = []
  hei = lines[1].split()
  for i in range(n):
    a.append(int(hei[i]))
  tmp = a[0]
  ans = 0
  for i in range(1,n):
    if tmp < a[i]:
      tmp = a[i]
    else:
      ans += tmp-a[i]
  print(ans)

if __name__ == '__main__':
    lines = []
    for l in sys.stdin:
        lines.append(l.rstrip('\r\n'))
    main(lines)


Measured memory_bytes: 35256
#include <iostream>
#include <string>
#include <list>
#include <cassert>

typedef std::list<int> IList;

void input(IList& ilist);
int output(const IList& vec);
// IList calc(const PList& vec);

int main()
{
    std::cin.tie(0);//??\??????????????????
    std::ios::sync_with_stdio(false);
    IList result;
    input(result);
// 	IList ovec = calc(ivec);
    output(result);
    return 0;
}
///--------------------------------------------
void input(IList& ilist)
{
    int n;
    std::cin >> n;
//    list.resize(n);
    for(int i = 0; i < n; i++){
        std::string meirei;
        std::cin >> meirei;
        
        if( meirei == "deleteFirst"){
            ilist.pop_front();
            // ilist.erase(ilist.begin());
        }
        else if(meirei == "deleteLast"){
            ilist.pop_back();
        }else{
            int value;
            std::cin >> value;
            if(meirei =="insert"){
                //???????????????
                ilist.insert(ilist.begin(), value);
        //        ilist.push_back(value);
            }else{//??????
                for(auto itr = ilist.begin(); itr != ilist.end(); ++itr){
                    if(*itr == value){
			            ilist.erase(itr);
                        break;    
                    }
                }
            }
        }
    }
    // output(ilist);
}
///--------------------------------------------
int output(const IList& intlist)
{
    for(auto itr = intlist.begin(); itr != intlist.end(); ++itr){
        if(itr != (intlist.begin())){
            std::cout << " "  ;
        }
        std::cout << *itr;               //  itr ????????????????´????????????????????????§ 1 ?????¨???
    }
    std::cout << std::endl;
    return 0;
}
///--------------------------------------------
///@func    calc
///@brif    ??¨????
///--------------------------------------------
/*
IList calc(const PList& ilist)
{
	IList ovec;
//   std::cout << "IList ovec;"<< std::endl;
    for(auto itr = ilist.begin(); itr != ilist.end(); ++itr){
        if(itr->meirei == "insert"){
  //          	std::cout << "ovec.insert"<< std::endl;
            ovec.insert(ovec.begin(), itr->value);
            
        }else if(itr->meirei == "delete"){
            auto otr = ovec.begin();
            for(; otr != ovec.end(); ++otr){
                if(*otr == itr->value){
                    break;
                }
            }
            if(otr != ovec.end()){
				ovec.erase(otr);
//				std::cout << "ovec.erase(otr)"<< std::endl;
            }
        }else if(itr->meirei == "deleteFirst"){
            ovec.erase(ovec.begin());
 //           std::cout << "deleteFirst" << std::endl;
        }else if(itr->meirei == "deleteLast"){
            ovec.pop_back();
 //           std::cout << "deleteLast" << std::endl;
        }else {
            assert(true);
        }
//      output(ovec);
    }
    return ovec;
}

*/

Measured memory_bytes: 34488
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()

using namespace std;

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	ll N; cin >> N;
	VLL A(N);
	ll waru;
	for (int i = 0;i < N;i++) cin >> A[i];
	sort(all(A));
	waru = A[0];
	waru = gcd(A[0], A[1]);
	for (int h = 1;h<N;h++) {
		waru = gcd(waru, A[h]);
	}
	cout << waru << endl;
}


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

int main()
{
    int n,k,ans=0;
    cin>>n;
    k = n/100;
    if(n>=k*100&&n<=k*105)
        ans=1;
    if(n<100)
        ans=0;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3608
n = int(input())
a = list(map(int,input().split()))
a.sort()
if n == 3:
    while a[1] % a[2] != 0:
        r = a[1] % a[2]
        a[1] = a[2]
        a[2] = r
    a[1] = a[2]
while a[0] % a[1] != 0:
    r = a[0] % a[1]
    a[0] = a[1]
    a[1] = r

if a[1] == 1:
    print(1)
else:
    y = [1]
    i = 2
    while len(y) == 1 or i <= int(a[1] / y[1] + 1):
        if a[1] % i == 0:
            y.append(i)
        i += 1
    for i in y:
        print(i)
    print(a[1])


Measured memory_bytes: 5608
n = int(input())
face = []
for i in range(n):
	face.append(list(map(int,input().split())))
def Nroll(list):
	a = [list[1],list[5],list[2],list[3],list[0],list[4]]
	return a
def Wroll(list):
	a = [list[2],list[1],list[5],list[0],list[4],list[3]]
	return a
ans = "Yes"
for ss in range(n):
	fac = face[ss]
	for ii in range(2):
		fac = Wroll(fac)
		for k in range(4):
			fac = Nroll(fac)
			for kk in range(4):
				fac = Wroll(fac)
				if fac in face[ss+1:]:
					ans = "No"
					break
			else:
				continue
			break
		else:
			continue
		break
print(ans)


Measured memory_bytes: 5600
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

M, D = map(int, input().split())

cand = set()
for m in range(1, M+1):
    i = 2
    while i*i <= D:
        if m % i == 0:
            ma = m//i
            mi = i
            if mi <= 1 or ma <= 1:
                pass
            elif int(str(mi)+str(ma)) <= D:
                cand.add(int(str(m)+str(mi)+str(ma)))
            elif int(str(ma)+str(mi)) <= D:
                cand.add(int(str(m)+str(ma)+str(mi)))

        i += 1
print(len(cand))


Measured memory_bytes: 3064
# Author: cr4zjh0bp
# Created: Thu Mar 12 19:24:47 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

N = ni()
D, X = na()
a = nin(N)

ans = X
for i in range(N):
    ans += 1
    b = a[i]
    while b + 1 <= D:
        ans += 1
        b += a[i]

print(ans)

Measured memory_bytes: 3064
hoge = {} ; teki=[]
while True:
  try:
    a,b = raw_input().split()
    if a not in hoge:
      hoge[a] = [int(b)]
    elif a in hoge:
      hoge[a].append(int(b))
  except EOFError: 
    for j in sorted(hoge):
      print j
      ans = len(hoge[j])
      aaa =sorted(hoge[j])
      for i in range(ans): print aaa[i],
      print 
    break

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n;
void solve(){
    cin>>n;
    int ans=0;
    rep(i,1,n+1) ans+=i*(n-i+1);
    rep(i,0,n-1){
    	int u,v;
    	cin>>u>>v;
    	if(u>v) swap(u,v);
    	ans-=u*(n-v+1);
    }
    cout<<ans<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  //sort(begin(ret), end(ret));
  return (ret);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll n;
	cin >> n;
	vector<ll> div = divisor(n);
	ll sum = 0;
	for(auto d: div){
		if(d==1) continue;
		d--;
		if(n/d==n%d) sum += d;
	}
	cout << sum << '\n';
	return 0;
}



Measured memory_bytes: 384
R, G, B, N = map(int, input().split())
R, G, B = sorted([R, G, B], reverse=True)
maxR = N // R
ans = 0
if R == 1:
    ans = (N+2)*(N+1) // 2
    print(ans)
    quit()

for r in range(maxR+1):
    if r * R == N:
        ans += 1
        continue
    n = N - r * R
    maxG = n // G
    for g in range(maxG+1):
        if g * G == n:
            ans += 1
            continue
        nn = n - g * G
        maxB = nn // B
        for b in range(maxB+1):
            if b * B == nn:
                ans += 1

print(ans)

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

#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 namespace std;
const int INF = 1 << 30;
const long long MOD = 1000000000 + 7;
const double PI = acos(-1);

int main() {
	int A, B; cin >> A >> B;
	int H, M; cin >> H >> M;
	double a = 0;
	a = 2 * PI * abs(((double)M / 60) - ((H + (double)M / 60) / 12));
	double ans = (double)A * A + (double)B * B - (double)2 * A * B * cos(a);
	ans = sqrt(ans);
	cout << fixed << setprecision(15) << ans << endl;
}

Measured memory_bytes: 4136
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {

	int n;
	string s; 
	cin >> n >> s;
	/*vector<vector<int> > hoge(6, vector<int>());
	//rgb,rbg,grb,gbr,brg,bgr
	vector<int> rafterg;
	vector<int> bafterg;
	int countr = 0, countb=0, countg = 0;
	rep(i,n) {
		if(s[i] == 'B') {
			countb++;
			hoge[1].pb(countr);
			hoge[3].pb(countg);
		}
		if(s[i] == 'R') {
			hoge[2].pb(countg);
			hoge[4].pb(countb);
			countr++;
		}
		if(s[i] == 'G') {
			countg++;
			hoge[0].pb(countr);
			hoge[5].pb(countb);
		}
			
	}
	countr = 0;
	countb=0;
	countg = 0;
	//rgb,rbg,grb,gbr,brg,bgr
	vector<vector<int> > fuga(6, vector<int>());
	for(int i=n-1; i>=0; i--) {
		if(s[i] == 'R') {
			countr++;
			fuga[2].pb(countb);
			fuga[4].pb(countg);
		}
		if(s[i] == 'G') {
			countg++;
			fuga[0].pb(countb);
			fuga[5].pb(countr);
		}
		if(s[i] == 'B') {
			countb++;
			fuga[1].pb(countg);
			fuga[3].pb(countr);
		}
		if(s[i] == 'G') bafterg.pb(countb);
	}
	rep(i,6) {
		reverse(fuga[i].begin(), fuga[i].end());
	}
	ll ans = 0;
	rep(i,6) {
		rep(j, fuga[i].size()) {
			ans += fuga[i][j] * hoge[i][j];
		}
	}
	/*rep(i, rbeforeg.size()) {
		ans += rbeforeg[i] * bafterg[i];
		cout << rbeforeg[i] << " " << bafterg[i] << endl;
	}*/
	
	//reverse(bafterg.begin(), bafterg.end());
	ll ans = 1;
	ll countr = 0, countg = 0, countb = 0;
	rep(i,n) {
		if(s[i] == 'R') countr++;
		if(s[i] == 'G') countg++;
		if(s[i] == 'B') countb++;
	}
	ans *= countr;
	ans *= countb;
	ans *= countg;
	for(int i=1;i <= (n-1)/2; i++) {
		rep(j,n) {
			if(j + 2*i >= n) continue;
			if(s[j] == 'R' && s[j+i] == 'G' && s[j+2*i] == 'B') ans--;
			if(s[j] == 'R' && s[j+i] == 'B' && s[j+2*i] == 'G') ans--;
			if(s[j] == 'B' && s[j+i] == 'R' && s[j+2*i] == 'G') ans--;
			if(s[j] == 'B' && s[j+i] == 'G' && s[j+2*i] == 'R') ans--;
			if(s[j] == 'G' && s[j+i] == 'B' && s[j+2*i] == 'R') ans--;
			if(s[j] == 'G' && s[j+i] == 'R' && s[j+2*i] == 'B') ans--;
		}
	}

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


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

string s;
int use;

bool parse(int l,int r){
  int p = 0;
  for(int i=l;i<r;i++){
    if(s[i] == '(')p++;
    if(s[i] == ')')p--;
    if(!p){
      if(s[i] == '*')return parse(l,i) && parse(i+1,r);
      if(s[i] == '+')return parse(l,i) || parse(i+1,r);
      if(s[i] == '-' && s[i+1] == '>')return !parse(l,i) || parse(i+2,r);
    }
  }

  if(s[l] == '-')return !parse(l+1,r);
  if(s[l] == '(' && s[r-1] == ')')return parse(l+1,r-1);
  if(s[l] == 'T')return true;
  if(s[l] == 'F')return false;
  return ( ( use >> (s[l]-'a') ) & 1);
}

int main(){
  while(cin >> s,s!="#"){
    int x = s.find("=");
    bool f = true;
    for(use=0;use<(1<<11);use++){
      f &= parse(0,x) == parse(x+1,s.size());
      if(!f)break;
    }
    cout << (f?"YES\n":"NO\n");
  }
}

Measured memory_bytes: 940
q = int(input())
for i in range(q):
    a,b,c,d,e,f,g,h = [int(i) for i in input().split()]
    A = a*d-b*c
    B = e*h-f*g
    C = d-b
    D = c-a
    E = f-h
    F = e-g
    G = C*F - D*E
    print((A*F + B*D)/G,(A*E + B*C)/G)

Measured memory_bytes: 7748
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main(){
  int n; cin >> n;
  string s;
  cin >> s;
  if(n%2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  string s1, s2;
  s1 = s.substr(0, n/2);
  s2 = s.substr(n/2, n/2);
  cout << (s1==s2 ? "Yes": "No") << endl;

  return 0;
}

// EOF


Measured memory_bytes: 256
N=int(input())
S=list(input())
 
def rgb(now,sec):
    if now=='R' and sec=='G':
        return 'B'
    if now == 'R' and sec == 'B':
        return 'G'
    if now == 'G' and sec == 'R':
        return 'B'
    if now == 'G' and sec == 'B':
        return 'R'
    if now == 'B' and sec == 'G':
        return 'R'
    if now == 'B' and sec == 'R':
        return 'G'
 
r=[]
g=[]
b=[]
for i in range(N):
    r.append(S[i:].count('R'))
    g.append(S[i:].count('G'))
    b.append(S[i:].count('B'))
    
ans=0
for i in range(N-2):
    now = S[i]
    for j in range(i+1,N-1):
        if S[j] == now:
            continue
        else:
            sec = S[j]
            thi = rgb(now,sec)
            if thi=='R':
                ans += r[j+1]
            if thi=='G':
                ans += g[j+1]
            if thi=='B':
                ans += b[j+1]
            if j+(j-i) < N and S[j+(j-i)]==thi:
                ans-=1
print(ans)

Measured memory_bytes: 71488
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x))%modulo)
#define Inf 100000000000000000



int main(){
	int N;
	cin>>N;
	vector<int> H(N);
	
	for(int i=0;i<N;i++){
		cin>>H[i];
	}
	H[0]--;
	for(int i=0;i<N-1;i++){
		if(H[i]>H[i+1]){
			cout<<"No"<<endl;
			return 0;
		}
		if(H[i]!=H[i+1]){
			H[i+1]--;
		}
	}
	
	cout<<"Yes"<<endl;
	
	
	
	
	return 0;
}




Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

//mod計算用のクラス
class ModInt{
public:
    long long int x;
    long long int mod;
	ModInt(){}
    ModInt(long long int _x, long long int _mod = 1000000007){
        this->x = _x % _mod;
        this->mod = _mod;
    }
	ModInt operator+(ModInt other){
		return ModInt(this->x + (other.x % this->mod),this->mod);
	}
	ModInt operator-(ModInt other){
		long long int res = this->x - (other.x % this->mod);
		if (res < 0) return ModInt(res + this->mod, this->mod);
		return ModInt(res);
	}
	ModInt operator*(ModInt other){
		return ModInt(this->x * (other.x % this->mod),this->mod);
	}
	ModInt operator/(ModInt other){
		return ModInt(*this * other.inv());
	}
	ModInt pow(long long int n){
		ModInt res(1, this->mod), a(this->x, this->mod);
		while (n){
			if (n & 1){
				res = res * a;
			}
			n >>= 1;
			a = a * a;
		}
		return res;
	}
	ModInt inv(){
		return ModInt(this->pow(this->mod - 2));
	}
	void disp(){
		cout << this->x << endl;
	}
};
ostream& operator<<(ostream& stream, const ModInt m){
	stream << to_string(m.x);
	return stream;
}

class modcomb{
	public:
		vector<ModInt> fact;
		vector<ModInt> ifact;
		modcomb(){}
		modcomb(int n){
			this->fact.resize(n + 1, ModInt(1));
			this->ifact.resize(n + 1, ModInt(1));
			for (int i = 1; i <= n;i++)
				this->fact[i] = this->fact[i - 1] * i;
			this->ifact[n] = fact[n].inv();
			for (int i = n; i >= 1; --i)
				this->ifact[i - 1] = ifact[i] * i;
		}
		ModInt operator()(int n, int k){
			if (k < 0 || k > n)
				return 0;
			return this->fact[n] * this->ifact[k] * this->ifact[n - k];
		}
};

int main()
{
	int n, k;
	cin >> n >> k;
	k = min(k, n - 1);
	modcomb c(n);
	ModInt ans(0);
	rep(i, k+1)
	{
		ans = ans + c(n,i)*c((n-i-1)+i, i);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6656
import sys
sys.setrecursionlimit(10 ** 7)
N = int(input())
E = [[] for _ in range(N+1)]

for i in range(N-1):
  a, b = map(int, input().split())
  E[a].append((b, i))
  E[b].append((a, i))
  
K = max(len(e) for e in E)  # 使用する色の最大数
print(K)

ans = [-1]*(N-1)
def dfs(v=1, p=0, p_col=-1):
  col = 1
  for u, idx in E[v]:
    if u == p: continue # 親だったらスキップ
    if col == p_col: col += 1 # 親とつながっている辺の色は使わない
    ans[idx] = col
    dfs(u, v, col)
    col += 1
dfs()
print("\n".join(map(str, ans)))
      

Measured memory_bytes: 85652
//include
//------------------------------------------
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>(b);i--)
#define REP(i,n)  FOR(i,0,n)

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
//-------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


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

    int n;
    while(1) {
        cin >> n;
        if (!n) break;
        int c = 0;
        long long data[4001] = {0};
        REP(i, n) {
            int e;
            long long p, q;
            cin  >> e >> p >> q;

            if (data[e] < 1000000 && data[e] + p * q >= 1000000) {
                cout << e << endl;
                ++c;
            }
            data[e] += p * q;
        }
        if (!c) cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 3164
#include<iostream>


using namespace std;

int main (){
	string s;
	cin >> s ;
	
	int l = s.length();
	int i;
	int cnt = 0;
	
	for(i=0; i<l; i++){
		if(s[i] == '0' && s[i+1] =='0'){
			s[i+1] = '1';
			cnt++; 
		}   
		if(s[i] == '1' && s[i+1] == '1'){
			s[i+1] = '0';
			cnt++; 
		}  
		
	}
	
	//cout << s << endl;
	cout << cnt <<endl;
	
	

	return 0;
} 

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;

int main() {
    //AKIHABARA
    string S; cin >> S;
    if(S == "KIHBR"){cout << "YES" << endl; return 0;}

    else if(S == "AKIHBR"){cout << "YES" << endl; return 0;}
    else if(S == "KIHABR"){cout << "YES" << endl; return 0;}
    else if(S == "KIHBAR"){cout << "YES" << endl; return 0;}
    else if(S == "KIHBRA"){cout << "YES" << endl; return 0;}

    else if(S == "AKIHABR"){cout << "YES" << endl; return 0;}
    else if(S == "AKIHBAR"){cout << "YES" << endl; return 0;}
    else if(S == "AKIHBRA"){cout << "YES" << endl; return 0;}
    else if(S == "KIHABAR"){cout << "YES" << endl; return 0;}
    else if(S == "KIHABRA"){cout << "YES" << endl; return 0;}
    else if(S == "KIHBARA"){cout << "YES" << endl; return 0;}

    else if(S == "AKIHABAR"){cout << "YES" << endl; return 0;}
    else if(S == "AKIHABRA"){cout << "YES" << endl; return 0;}
    else if(S == "AKIHBARA"){cout << "YES" << endl; return 0;}
    else if(S == "KIHABARA"){cout << "YES" << endl; return 0;}

    else if(S == "AKIHABARA"){cout << "YES" << endl; return 0;}
    else cout << "NO" << endl; return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include<cstdio>

using namespace std;

int main(){
    int n;
    int x[100],y[100];
    cin >> n;
    for(int i = 0;i<n;i++){
        cin >> x[i];
    }
    for(int i = 0;i<n;i++){
        cin >> y[i];
    }
    
    //p=1の時
    double d1 =0.0;
    for(int j=0;j<n;j++){
        d1 += fabs(x[j] - y[j]);
    }
    printf("%lf\n",d1);
   
    //p=2の時
    double d2 =0.0,w2 =0.0;
    for(int k=0;k<n;k++){
        w2 += pow(fabs(x[k] - y[k]),2);
    }
    d2  = sqrt(w2);
    printf("%lf\n",d2);
    
    //p=3の時
    double d3 =0.0,w3=0.0;
    for(int l=0;l<n;l++){
        w3 += pow(fabs(x[l] - y[l]),3);
    }
    d3 = pow(w3,1.0/3.0);
    printf("%lf\n",d3);
    
    //p=∞の時
    double d4 =0.0,w4 = 0.0;
    for(int m=0;m<n;m++){
        w4 = fabs(x[m] - y[m]);
        d4 = (d4<w4?w4:d4);
    }
    printf("%lf\n",d4);
    return 0;
}


Measured memory_bytes: 3344
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string S;
  cin >> S;
  if (S[0] == '7' || S[1] == '7' || S[2] == '7')
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3608
import bisect
N=int(input())
A=[int(i) for i in input().split()]
X=sorted([i-A[i] for i in range(N)])
Y=sorted([i+A[i] for i in range(N)])
ans=0
for i in range(N):
    l=bisect.bisect_left(Y,X[i])
    r=bisect.bisect_right(Y,X[i])
    ans+=r-l
print(ans)

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

int main(void){
  int n, ans=1;
  char c, prev;
  
  cin >> n >> prev;
  for (int i=1; i<n; i++){
    cin >> c;
    if (c!=prev) ans++;
    prev = c;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	ss := strings.Split(s, "")

	cnt := 0
	tmp := ""
	for _, s := range ss {
		if tmp == "" {
			tmp = s
			continue
		}

		if tmp == s {
			cnt++
			if s == "0" {
				tmp = "1"
			} else {
				tmp = "0"
			}
			continue
		}
		tmp = s
	}

	fmt.Print(cnt)
}


Measured memory_bytes: 2944
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

MOD = 10 ** 9 +7

n = int(readline())
ab = list(list(map(int,readline().split()))for _ in range(n-1))
m=int(readline())
uv=list(list(map(int,readline().split()))for _ in range(m))

graph = [[]for _ in range(n+1)]
for i ,(a,b) in enumerate(ab):
    graph[a].append((b,i))
    graph[b].append((a,i))

def get_path(U,V):
    INF = 100
    visited =[False]*(n+1)
    pred =[None]*(n+1)
    stack =[U]
    visited[U]=True
    while stack:
        v = stack.pop()
        for w,i in graph[v]:
            if visited[w]:
                continue
            visited[w] = True
            pred[w] = (v,i)
            stack.append(w)
    path = 0
    w = V
    while w!= U:
        v,i = pred[w]
        w =v
        path+=1<<i
    return path

condition_path = [get_path(u,v)for u,v in uv]

s=np.zeros(1<<m,np.int64)
sgn = np.ones(1<<m,np.int64)
for i in range(m):
    s[1<<i:1<<(i+1)] = s[:1<<i] | condition_path[i]
    sgn[1<<i:1<<(i+1)]=-sgn[:1<<i]

def popcnt(n):
    c = (n & 0x5555555555555555) + ((n>>1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c>>2) & 0x3333333333333333)
    c = (c & 0x0f0f0f0f0f0f0f0f) + ((c>>4) & 0x0f0f0f0f0f0f0f0f)
    c = (c & 0x00ff00ff00ff00ff) + ((c>>8) & 0x00ff00ff00ff00ff)
    c = (c & 0x0000ffff0000ffff) + ((c>>16) & 0x0000ffff0000ffff)
    c = (c & 0x00000000ffffffff) + ((c>>32) & 0x00000000ffffffff)
    return c

n_edges = popcnt(s)

x= 1<<(n-1-n_edges)
answer =(x*sgn).sum()
print(answer)
#maspyさんのコードをほぼ写経しました。すみません。(+_+)

Measured memory_bytes: 61680
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 1e6 + 10;
#define fi first
#define se second
#define pb push_back
LL n;
set<LL>x;
int p[N],a[N],cnt;
void P(){
  for(int i=1;i<N;i++){
    if(!p[i])a[++cnt]=i;
    for(int j=1;j<=cnt&&1ll*a[j]*i<N;j++){
      p[a[j]*i]=1;
      if(i%a[j]==0)break;
    }
  }
}
int c(LL x,LL y){
  if(y==1)return 0;
  while(x%y==0)x/=y;
  if(x%y==1)return 1;
  return 0;
}
int main() {
  ios::sync_with_stdio(false);
  cin>>n;
  LL y=n-1;
  int z=sqrt(y);
  for(int i=1;i<=z;i++){
    if(y%i==0){
      if(i!=1)x.insert(i);
      if(y/i!=1)x.insert(y/i);
    }
  }
  for(int i=1;1ll*i*i<=n;i++){
    if(n%i==0){
      if(c(n,i))x.insert(i);
      if(c(n,n/i))x.insert(n/i);
    }
  }
  cout<<x.size()<<'\n';
  return 0;
}

Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1285

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>
#include<iomanip>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int main()
{
	cout << setprecision( 6 ) << fixed;

	int N,W;
	while(cin >> N >> W && N)
	{
		vector<int> hist(30,0);

		int v;
		int most=0;
		rep(nth,N)
		{
			cin >> v;
			hist[ v / W ]++;
			most = max(most, v/W);
		}

		int height = *max_element(ALL(hist));

		double ans=0.01;
		for(int i=most; i>=0; i--){
			ans += ((double)i / most) * ((double)hist[most - i] / (double)height);
		}

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

Measured memory_bytes: 1256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h> // sqrt
using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 4e18
#define EPS 1e-3
#define PI 3.1415926535897932385
#define display(v) f(v.size())cout << v[i]<<" "
const double h = 1e-6;
const int MAX_  = 200005;
#define all(v) v.begin(),v.end()

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
ll sqr(ll x)
{
    return x*x;
}
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////
struct graph{
    vi v;
};

void bfs(graph G[],int start,vl & d){
    queue<int> q;
    q.push(start);
    d[start] = 0;
   
    while(!q.empty()){
        int from = q.front();
        q.pop();
        for(int i=0;i<G[from].v.size();i++){
            int to = G[from].v[i];
          //  cout << from << "  " << to << "\n";
            if(d[to] == inf){
                d[to] = d[from]+1;
                q.push(to);
            }
        }
    }
}

ll cc(ll a,ll b,ll m){
    if(m>b)
    return 0;
    if(a%m == 0){
        return ((b/m) - (a/m) + 1);
    }
    return ((b/m) - (a/m));
}
ll hf(ll a,ll b){
    ll val = a*b;
    val /= (__gcd(a,b));
    return val;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll tot = b-a+1;
    tot = tot - cc(a,b,c) - cc(a,b,d) + cc(a,b,hf(c,d));
    cout << tot;

    return 0;
}
    


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <iomanip>
#include <queue>
#include <map>


int main()
{
	long long L, R;
	std::cin >> L >> R;

	if (L==0 || R==0) {
		std::cout << 0 << std::endl;
		return 0;
	}

	long long val = 0;

	unsigned long long min = 18446744073709551615;
//	std::cout << min << std::endl;


	long long end_p;
	if (R - L < 2019) {
		end_p = R;
	}
	else {
		end_p = L+2019;
	}

//	std::cout << end_p << std::endl;

//	for (long long i = L; i < R+1; i++) {
	for (long long i = L; i < end_p+1; i++) {
		for (long long j = i+1; j < end_p+1 ; j++) {
//			std::cout << i << " " << j << std::endl;
//				std::cout << i*j << std::endl;
				val = (i*j) % 2019;
				if (val < min) {
					min = val;
				}
		}

	}


	
	std::cout << min;

}


Measured memory_bytes: 256
loop{n=gets.to_i;exit if n==0;y=gets.to_i;
a,b=n.times.map{b,r,t=gets.split.map &:to_i;a=t==1 ? 1+y*r/100.0 : (1+r/100.0)**y;[a,b]}.sort[-1];
p b}



Measured memory_bytes: 6948
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); }
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

#if 1
template <class T> void _print(T v) { cerr << v; } void _err(istream_iterator<string> it) { (void)it; }
template <class A, class B> void _print(pair<A,B> v) { cerr << "("; _print(v.ff); cerr << ","; _print(v.ss); cerr << ")"; }
template <class T, class... Args> void _err(istream_iterator<string> it, T a, Args... args) { cerr << '\t' << *it << " = "; _print(a); _err(++it, args...); }
#define trace(...)  { cerr << "Line " << __LINE__ << ":"; string _s = #__VA_ARGS__; replace(_s.begin(), _s.end(), ',', ' ');       \
  stringstream _ss(_s); _err(istream_iterator<string>(_ss), __VA_ARGS__); cerr << nl; }
#define debug if(1)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define trace(...)	{}
#define debug if(0)
#define eprintf(...) {}
#endif

struct mi {
  int val; static const int MOD = 1e9+7; static_assert(MOD > 0, "Modulus not set!");
  mi(int v=0) : val(v) { if ((val %= MOD) < 0) val += MOD; }
  mi& operator += (const mi& b) { (val += b.val) %= MOD; return *this; }
  mi& operator -= (const mi& b) { return (*this) += MOD-b.val; }
  mi& operator *= (const mi& b) { val = ((ll)val*(ll)b.val) % MOD; return *this; }
  mi& operator /= (const mi& b) { return (*this) *= b.pow(MOD-2); }
#define _op(op, op2) mi operator op (const mi& b) const { mi ans = *this; return ans op2 b; }
  _op(+, +=); _op(-, -=); _op(*, *=); _op(/, /=);
#undef _op
  mi pow(ll e) const { mi res(1), b(*this); for (; e>0; e/=2, b*=b) { if (e&1) res*=b; } return res; }
  int toInt() const { return val; }
};

const int N = 105;
const int K = 1e5+5;
bool vis[N][K];
mi dp[N][K];
int a[N], n, k;

int main() { // Emily <3
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  dp[n-1][0] = 1;
  for (int j = 1; j <= k; ++j) {
    dp[n-1][j] = dp[n-1][j-1] + (j <= a[n-1]);
  }
  for (int i = n-1; i--;) {
    dp[i][0] = 1;
    for (int j = 1; j <= k; ++j) {
      dp[i][j] = dp[i][j-1] + dp[i+1][j];
      if (j > a[i]) {
        dp[i][j] -= dp[i+1][j-a[i]-1];
      }
    }
  }
  trace(dp[0][0].toInt());
  mi ans = dp[0][k];
  if (k > 0) {
    ans -= dp[0][k-1];
  }
  cout << ans.toInt() << nl;

  return 0;
}



Measured memory_bytes: 43264
#include <cstdio>

using namespace std;

char ans3[3][4] = {
    "aa.",
    "..a",
    "..a"
};

char ans4[4][5] = {
    "aacd",
    "bbcd",
    "cdaa",
    "cdbb"
};

char ans5[5][6] = {
    "aabba",
    "bcc.a",
    "b..cb",
    "a..cb",
    "abbaa"
};

char ans6[6][7] = {
    "aabbaa",
    "bbaabb",
    "cde...",
    "cde...",
    "...cde",
    "...cde"
};

char ans7[7][8] = {
    "aabbaa.",
    "bbaa..a",
    "aabb..a",
    "....bab",
    "....bab",
    "....aba",
    "....aba"
};

char ans[1000][1001];

int main() {
    int n, i, j;
    
    scanf("%d", &n);
    
    if (n == 2) {
        puts("-1");
    } else if (n == 3) {
        for (i = 0; i < n; i++) printf("%s\n", ans3[i]);
    } else {
        int c = n, p = 0;
        
        for (i = 0; i < n; i++) {
            for (j = 0; j < n; j++) {
                ans[i][j] = '.';
            }
        }
        
        while (c >= 8) {
            for (i = 0; i < 4; i++) {
                for (j = 0; j < 4; j++) {
                    ans[p + i][p + j] = ans4[i][j];
                }
            }
            
            c -= 4;
            p += 4;
        }
        
        if (c == 4) {
            for (i = 0; i < 4; i++) {
                for (j = 0; j < 4; j++) {
                    ans[p + i][p + j] = ans4[i][j];
                }
            }
        } else if (c == 5) {
            for (i = 0; i < 5; i++) {
                for (j = 0; j < 5; j++) {
                    ans[p + i][p + j] = ans5[i][j];
                }
            }
        } else if (c == 6) {
            for (i = 0; i < 6; i++) {
                for (j = 0; j < 6; j++) {
                    ans[p + i][p + j] = ans6[i][j];
                }
            }
        } else {
            for (i = 0; i < 7; i++) {
                for (j = 0; j < 7; j++) {
                    ans[p + i][p + j] = ans7[i][j];
                }
            }
        }
        
        for (i = 0; i < n; i++) {
            for (j = 0; j < n; j++) {
                putchar(ans[i][j]);
            }
            puts("");
        }
    }
    
    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 2e5+10 , OO = 0x3f3f3f3f ;
//const int mod = 1000000007;
 
#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define xloop(i,a,b) for(int i = int(a);i <= int(b);i++)
#define range(vec) for(auto &x : vec) cin >> x;
#define ALL(v) ((v).begin()) , ((v).end())
#define SZ(v)  ((int)((v).size()))
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction


int main()
{
   // startTime = (double)clock();
    #ifndef ONLINE_JUDGE
        //freopen("in.in", "r", stdin);
        //freopen("out.in", "w", stdout);
    #endif
	//ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
    char c;
    scanf("%c" , &c);
    if(c >= 'A' && c <= 'Z')
        puts("A");
    else 
        puts("a");

    return 0;
}

Measured memory_bytes: 3656