akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	x1 := readInt()
	y1 := readInt()
	x2 := readInt()
	y2 := readInt()

	dx := x2 - x1
	dy := y2 - y1

	dx, dy = -dy, dx
	x3, y3 := x2+dx, y2+dy
	dx, dy = -dy, dx
	x4, y4 := x3+dx, y3+dy
	println(x3, y3, x4, y4)
}

// -----------------------------------------------------------------------------


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

int main(){

  // ll n,m;cin>>n>>m;
  // ll s[m],c[m];rep(i,0,m)cin>>s[i]>>c[i];
  ll n;cin>>n;
  out((n+1)/2);


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast_io ios :: sync_with_stdio(false);
using namespace std;

int main() {
	cout << fixed << setprecision(3);
	fast_io;
	string s; cin >> s;
	int cont = 0;
	for(int i = 0; i < s.size()/2; i++) {
		if(s[i] != s[s.size() - 1 - i]) {
			cont++;
		}
	}
	cout << cont;
	return 0;	
}

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

using namespace std;
const int MAXN=100001;
int n,m,st[MAXN],et[MAXN],c[MAXN],pre[2*MAXN],res[2*MAXN];

int main()
{
	cin >> n >> m;
	for(int i=1;i<=n;i++) cin >>st[i] >>et[i] >>c[i];
	for(int i=1;i<=m;i++)
	{
		memset(pre,0,sizeof(pre));
		for(int j=1;j<=n;j++) if(c[j]==i) pre[st[j]]++,pre[et[j]+1]--;
		for(int j=1;j<=MAXN;j++) pre[j]+=pre[j-1];
		for(int j=1;j<=MAXN;j++) if(pre[j]>0) res[j]++;
	}
	
	int ans=0;
	for(int i=1;i<=2*MAXN-2;i++) ans=max(ans,res[i]);
	cout << ans;
	return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>
#define MAX 1000000

typedef struct{
    char number[100];
    int t;
}data;

int head,tail;
int count;
data Q[MAX];

int isEmpty();/*キューが空なら1を返し、そうでないなら0を返す*/
int isFull();/*キューにこれ以上要素が入らなければ1を返し、そうでないなら0を返す*/
void enqueue(data num);/*要素挿入*/
data dequeue();/*要素取出し*/


int main(){
    int i,n,q;
    count=0;
    scanf("%d %d",&n,&q);

    for(int i=1; i<=n; i++){
        scanf("%s",Q[i].number);
        scanf("%d",&Q[i].t);
    }

    head = 1;
    tail = n+1;

    while(tail != head){
        data num;
        num = dequeue();
        if(num.t <= q){
            count += num.t;
            num.t = 0;
            printf("%s %d\n",num.number,count);
        }

        else if(num.t > q){
            count += q;
            num.t -= q;
            enqueue(num);
        } 
    }

    return 0;
}

int isEmpty(){
    if(head == tail) return 1;
    return 0;
}

int isFull(){
    if(head == (tail+1)%MAX) return 1;
    return 0;
}

void enqueue(data num){
    if(isFull()){
        printf("Erorr,queue is full\n");
        exit(2);
    }

    Q[tail] = num;

    if(tail +1 == MAX)tail = 0;
    else tail++;
    
}

data dequeue(){
    data num;
    if(isEmpty()){
        printf("Error, queue is empty\n");
        exit(3);
    }

    num = Q[head];
    if(head + 1 == MAX) head = 0;
    else head++;

    return num;
}



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

int main(){
  int N;
  string W[110];
  char last_word;
  int flag = 0;
  int i, j;

  cin >> N;
  for(i = 0;i < N;i++){
    cin >> W[i];
  }

  last_word = W[0].back();
  //cout << last_word << endl;

  for(i = 1;i < N;i++){
    for(j = 0;j < i-1;j++){
      if(W[i] == W[j]){
        flag = 1;
        break;
      }
    }
    //cout << "flag" << flag << endl;
    //cout << i << j << endl;
    //cout << W[i] << W[j] << endl;
    //if(flag == 1) cout << W[i] << W[j] << endl;
    //cout << "point 1" << endl;
    //cout << W[i].front() << last_word << endl;
    if(flag == 0){
        if(W[i].front() == last_word) last_word = W[i].back();
        else {
          flag = 1;
          break;
        }
    }
    //cout << "point 2" << endl;
    if(flag == 1) break;
    //cout << "point 3" << endl;
  }

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

}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;

mat memo(110,vec(110,-1));

ll comb(int i,int j){
    if(i<j)return 0;
    if(j==0)return 1;
    if(i==j)return 1;
    if(memo[i][j]!=-1)return memo[i][j];

    return memo[i][j]=(comb(i-1,j)+comb(i-1,j-1));
}

int main(){
    string N;cin>>N;
    int S=N.size();
    int K;cin>>K;
    ll ans=0;
    int k=0,i=0;
    while(k<K && i<S){
        int a=N[i]-'0';
        if(a>0){
            ans+=(a-1)*pow(9,K-k-1)*comb(S-1-i,K-k-1)+pow(9,K-k)*comb(S-1-i,K-k);
            k++;i++;
        }
        else{
            i++;
        }
    }
    if(k==K)ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

#ifdef __APPLE__
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...)
#endif

const int N = (int)1e6 + 123;
const int MOD = (int)1e9 + 7;
const int inf = (int)5e8;
const long long infll = (long long)1e17;


map<int, int> cnt;

void solve() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        ++cnt[x];
    }
    long long ans = 0;
    map<int, int> usefull;
    for (auto i : cnt) {
        if (i.second >= 2) {
            usefull[i.first] = i.second;
        }
    }
    for (auto i : cnt) {
        if (i.second >= 2) {
            if (i.second >= 4) {
                ans = max(ans, i.first * 1ll * i.first);
            }
            int was = usefull[i.first];
            usefull.erase(i.first);
            if (usefull.size() > 0) {
                ans = max(ans, i.first * 1ll * usefull.rbegin()->first);
            }
            usefull[i.first] = was;
        }
    }
    printf("%lld\n", ans);
}

int main() {
#ifdef __APPLE__
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    while (t--) {
        solve();
    }
    return 0;
}



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

using ll = long long;
#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 INF 1e9
// const ll INF = 1LL << 60;

int n;
vector<int> a, L, length;
int main(){
  cin >> n;
  a.resize(n);
  REP(i, n){
    cin >> a[i];
  }
  L.resize(n, INF), length.resize(n, 0);
  REP(i, n){
    auto it = lower_bound(L.begin(), L.end(), a[i]);
    if(it == L.end()) continue;
    *it = a[i];
    int idx = it - L.begin();
    length[i] = idx+1;
  }
  // cout << "L:";
  // REP(i, n){
  //   cout << L[i] << " ";
  // }
  // cout << endl << "length: ";
  // REP(i, n){
  //   cout << length[i] << " ";
  // }
  // cout << endl;
  int ans = 0;
  REP(i, n){
    ans = max(ans, length[i]);
  }
  cout << ans << endl;
  return 0;
}




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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

struct UnionFind {
  vector<int> par; // 親の番号

  // n要素で初期化する
  // 問題のindexによっては、添字が変化する可能性がある
  UnionFind(int N) : par(N) {
    for(int i = 0; i < N; ++i) par[i] = i;
  }

  // 木の根を求める
  int root(int x) {
    if(par[x] == x) {
      return x; // 根
    } else {
      return par[x] = root(par[x]); // 経路圧縮(根っこを再帰で探る)    
    }
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return; // xとyの根が同じ場合はすでに併合している
    par[rx] = ry;
  }

  bool same(int x, int y) { // x と y が同じ集合に属するか否か
    return root(x) == root(y);
  }
};

int main() {
  int N, M; cin >> N >> M;
  vector<int> a(M), b(M);
  REP(i, M) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  int ans = 0;
  for(int i = 0; i < M; ++i) {
    UnionFind uf(N);
    for(int k = 0; k < M; ++k) {
      if(i == k) continue;
      uf.unite(a[k], b[k]);
    }
    if(!uf.same(a[i], b[i])) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3572
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Integer[] a = new Integer[n];
        Arrays.setAll(a, i -> Integer.parseInt(sc.next()));
        sc.close();

        // 主処理
        int sum = Arrays.stream(a).mapToInt(i -> i).sum();
        if (sum % 10 == 0) {
            int min = Arrays.stream(a).filter(i -> i % 10 != 0).mapToInt(i -> i).min().orElse(0);
            sum -= min;
        }
        int result = sum % 10 == 0 ? 0 : sum;

        // 出力
        System.out.println(result);
    }
}


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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector < int >L(N);
	for (int i = 0; i < N; i++) {
		cin >> L[i];
	}
	sort(L.begin(), L.end());

	int ans = 0;
	for (int i = 0; i < N - 2; i++) {
		for (int j = i + 1; j < N - 1; j++) {
			for (int k = j + 1; k < N; k++) {
				if (L[i] + L[j] > L[k]) {
					ans++;
				} else {
					break;
				}
			}
		}
	}

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


Measured memory_bytes: 256
import numpy as np
from itertools import groupby

N = int(input())
T = np.array(['0'] + input().split() + ['10000000000'], np.int64)
A = np.array(['10000000000'] + input().split() + ['0'], np.int64)
mod = 10 ** 9 + 7

t = (T[1:] != T[:-1]) * T[1:]
a = (A[1:] != A[:-1]) * A[:-1]
t = t[:-1]
a = a[1:]

flag = True
idx = np.where((t != 0) & (a != 0))[0]
if np.any(t[idx] != a[idx]):
    flag = False

seq = np.maximum(t, a)
if np.any(seq > T[1:-1]) or np.any(seq > A[1:-1]):
    flag = False

if flag:
    group = [(i, len(list(j))) for i, j in groupby(seq.tolist())]
    answer = 1
    for i, (key, n) in enumerate(group):
        if key == 0:
            answer *= pow(min(group[i - 1][0], group[i + 1][0]), n, mod)
            answer %= mod
    print(answer)
else:
    print(0)


Measured memory_bytes: 27872
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

int main(){
  char stage[4][4] = {{'A','B','C'},{'D','E','F'},{'G','H','I'}};
  string pass;
  while(cin >> pass){
    bool isok = true;
    for(int i=0;i+1<pass.size();i++){
      int sx=0,sy=0,gx=0,gy=0;
      for(int y=0;y<3;y++){
	for(int x=0;x<3;x++){
	  if(pass[i] == stage[y][x]){
	    sx = x;
	    sy = y;
	  }
	}
      }
      for(int y=0;y<3;y++){
	for(int x=0;x<3;x++){
	  if(pass[i+1] == stage[y][x]){
	    gx = x;
	    gy = y;
	  }
	}
      }
      if(!(abs(gx - sx) > 1
	   || abs(gy - sy) > 1)
	 && !(abs(gx - sx) == 1 && abs(gy - sy) == 1)
	 && !(gx == sx && gy == sy)){
	// nothing to do
      }
      else{
	isok = false;
      }
    }

    if(isok){
      cout << pass << endl;
    }
  }
}

Measured memory_bytes: 1176
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>
#define PI acos(-1)
typedef long long ll;
const long long mod = 1e9 + 7;
const long long maxn = 1e5 + 5; 
using namespace std;

const int N = 2e5 + 5;
char s[N];
int ma[2020];
int main() {
    scanf("%s", s);
    ll ans = 0;
    int res = 0, t = 1, n = strlen(s);
    for(int i = n - 1; i >= 0; i--) 
	{
        ma[res]++;
        res = (res + (s[i] - '0') * t) % 2019;
        ans += ma[res];
        t = t * 10 % 2019;
    }
    printf("%lld\n", ans);
    return 0;
}

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

using namespace std;

#define rep(i, a) for(int i = 0; i < a; i++)
#define reps(i, a, b) for(int i = a; i < b; i++)
#define MP(a, b) make_pair(a, b)

int costa[100000];
int costb[100000];
int N;
int A[100000];

int main()
{
  cin >> N;
  rep(i, N) cin >> A[i];
  int b = A[0];
  costa[0] = abs(A[0]);
  reps(i, 1, N-1) {
    costa[i] = abs(A[i]-b) + costa[i-1];
    b = A[i];
  }
  b = A[N-1];
  costb[N-1] = abs(b);
  reps(j, 2, N) {
    int i = N-j;
    costb[i] = abs(A[i]-b) + costb[i+1];
    b = A[i];
  }
  int mi = 1e9;
  rep(i, N) {
    int s = i == 0 ? 0 : costa[i-1];
    int e = i == N-1 ? 0 : costb[i+1];
    int S = i == 0 ? 0 : A[i-1];
    int E = i == N-1 ? 0 : A[i+1];
    cout << s+e+abs(S-E) << endl;
  }
  return 0;
}

Measured memory_bytes: 2432
{-# LANGUAGE TypeApplications #-}

import Control.Monad

main = do
    n <- readLn @ Int
    xs <- replicateM n getLine
    m <- readLn @ Int
    ys <- replicateM m getLine

    print $ (foldl max 0 . fmap (\x -> ((length . filter (== x)) xs) - ((length . filter (== x)) ys))) xs


Measured memory_bytes: 4032
import math
from itertools import accumulate
def is_prime(n):
  if n==1:
    return False
  for i in range(2,int(math.sqrt(n)+1)):
    if n%i==0:
      return False
  return True
q=int(input())
l=[0]*q
r=[0]*q
for i in range(q):
  l[i],r[i]=list(map(int,input().split()))
min_l=min(l)
max_r=max(r)
a=[]
for i in range(min_l,max_r+1):
  if i%2==0:
    a.append(0)
  else:
    if is_prime(i) and is_prime((i+1)/2):
      a.append(1)
    else:
      a.append(0)
check=[0]+a
check=list(accumulate(check))
for i in range(q):
  print(check[r[i]-min_l+1]-check[l[i]-min_l])
  
    

Measured memory_bytes: 17336
import sys

sys.setrecursionlimit(100000)


def check(i, xs, checked):
    xi = xs[i]
    children = set()
    for j, d in links[i]:
        if j in checked:
            continue
        if j not in xs:
            xs[j] = xi + d
        elif xi + d != xs[j]:
            return False
        children.add(j)
    checked.add(i)
    for j in children:
        if not check(j, xs, checked):
            return False
    return True


def solve():
    checked = set()
    for i in range(n):
        if i not in checked:
            xs = {}
            xs[i] = 0
            if not check(i, xs, checked):
                return False
    return True


n, m = map(int, input().split())
links = [set() for _ in range(n)]
for _ in range(m):
    l, r, d = map(int, input().split())
    l -= 1
    r -= 1
    links[l].add((r, d))
    links[r].add((l, -d))
print('Yes' if solve() else 'No')


Measured memory_bytes: 172508
#include<iostream>
#include<string>
#include<bits/stdc++.h>
using namespace std;
int main() 
{ 
char a='H';
char b='H';
 cin>>a>>b;
 
 
 if(a=='H'&&b=='H')
 cout<<"H";
 else if(a=='D'&&b=='D')
 cout<<"H";
 else
 cout<<"D";
    
    

   return 0; 
} 

Measured memory_bytes: 3576
#include <bits/stdc++.h>
 
#define rep(i, n) for (ll i=0;i<(n); i++)
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; }
#define ALL(x) (x).begin(),(x).end()
 
using namespace std;
//using ll=long long;
typedef long long ll;
typedef pair<ll, ll> pi;
 
 
 
int main(){
  long double  a,b,c;
  cin>>a>>b>>c;

  long double tmp = c-a-b;
  long double ans = tmp;

  ans -= 2*sqrt((a*b));

  if(ans>0) cout<<"Yes"<<endl;
  else  cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#define int long long
using namespace std;
int n;
signed main(){
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++){
		if(n%i==0)
			ans--;
//		cout<<i<<" "<<n/i<<endl;
		ans+=(n/i);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	cin >> n;
	double a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	double mx = (a[n - 4] + a[n - 3]) / (a[n - 1] - a[n - 2]);
	mx = max(mx, (a[n - 1] + a[n - 4]) / (a[n - 2] - a[n - 3]));
	double ab = a[n - 1] + a[n - 2];
	for(int i = 1; i < n - 2; i++) mx = max(mx, ab / (a[i] - a[i - 1]));
	printf("%.5lf\n", mx);
	return 0;
}


Measured memory_bytes: 3344
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int M = (int) 1e5 + 100;
		bool[] isPrime = new bool[M];
		for(int i=2;i<M;i++) isPrime[i] = true;
		for(int i=2;i<M;i++){
			if(isPrime[i]){
				for(int j=i+i;j<M;j+=i) isPrime[j] = false;
			}
		}
		
		int[] sum = new int[M+1];
		for(int i=0;i<M;i++) sum[i+1] = sum[i] + ((isPrime[i] && isPrime[(i + 1) / 2]) ? 1 : 0);
		
		for(int i=0;i<Q;i++){
			Console.WriteLine(sum[R[i] + 1] - sum[L[i]]);
		}
		
		
	}
	int Q;
	int[] L,R;
	public Sol(){
		Q = ri();
		L = new int[Q];
		R = new int[Q];
		for(int i=0;i<Q;i++){
			var d = ria();
			L[i] = d[0]; R[i] = d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

killed = 0
for i in range(n):
    now_kill = min(a[i],b[i])
    killed += now_kill
    a[i] -= now_kill
    b[i] -= now_kill
    if b[i] == 0:continue
    now_kill = min(a[i+1],b[i])
    killed += now_kill
    a[i+1] -= now_kill
    b[i] -= now_kill

print(killed)

Measured memory_bytes: 18476
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int n;
    cin >> n;

    vector<vector<vector<vector<int>>>> dp(n + 1, vector<vector<vector<int>>>(4,vector<vector<int>>(4,vector<int>(4,0))));
    REP(i,4){
        REP(j,4){
            REP(k,4){
                dp[3][i][j][k] = 1;
            }
        }
    }

    dp[3][0][2][1] = 0;
    dp[3][2][0][1] = 0;
    dp[3][0][1][2] = 0;

    REP(i,n){
        REP(j,4){
            REP(k,4){
                REP(l,4){
                    if(dp[i][j][k][l]==0){
                        continue;
                    }

                    
                    REP(m,4){

                        if((k==0&&l==2&&m==1)||(k==2&&l==0&&m==1)||(k==0&&l==1&&m==2)||(j==0&&l==2&&m==1)||(j==0&&k==2&&m==1)){
                            continue;
                        }else{
                            dp[i + 1][k][l][m] += dp[i][j][k][l];
                            dp[i + 1][k][l][m] %= mod;
                        }

                    }
                }
            }
        }
    }

    long long int result = 0;

    REP(i,4){
        REP(j,4){
            REP(k,4){

                result += dp[n][i][j][k];
                result %= mod;
            }
        }
    }


    cout << result << endl;

    return 0;
}


Measured memory_bytes: 384
N, M = map(int, input().split())
b = [False] * (N+1)
for i in range(M):
  a = int(input())
  b[a] = True
dp = [0] * (N+1)

for i in range(N+1):
  if b[i]:
    dp[i] = 0
  elif i <= 1:
    dp[i] = 1
  else:
    dp[i] = (dp[i-1] + dp[i-2]) % (10**9+7)
print(dp[N])

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, l;
    cin >> n >> l;
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += l + i;
    }
    if (l > 0) {
        cout << sum - l << endl;
    } else if (n-1+l < 0) {
        cout << sum - (n-1+l) << endl;
    } else {
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int a[5];

int main() {
    rep (i, 5) scanf("%d", a+i);
    sort(a, a+5);
    reverse(a, a+5);
    rep (i, 5) printf("%d%c", a[i], "\n "[i<4]);
    return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(){
  int p[100000]={2};
  int i,j,n,c=1,s=0;
  for(i=3;i<1000000;i+=2){
    s=0;
    for(j=0;p[j]*p[j]<=i;j++){
      if(i%p[j]==0){
	s=1;
	break;
      }
    }
    if(s==0){
      p[c]=i;
      c++;
    }
  }
  p[c]=1000000;
  while(scanf("%d",&n)!=EOF){
    for(i=0;p[i]<=n;i++);
    printf("%d\n",i);
  }
  return 0;
}

Measured memory_bytes: 992
// Problem : B - String Palindrome
// Contest : AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define Ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define Test Ios; int tz; cin>>tz; while(tz--)
#define prec(ans) cout<<fixed<<setprecision(20)<<ans<<'\n';
#define all(v) v.begin(), v.end()
#define F first
#define S second

#define sa(a,n)  		int a[n]; for(int zz = 0 ; zz<n; zz++) cin>>a[zz];
#define sda(a,n) 		int n; cin>>n; sa(a,n)
#define pra(a,n)        for(size_t zz=0;zz<n;zz++) cout<<a[zz]<<' '; cout<<'\n';
#define prv(a)          for(auto zz:a) cout<<zz<<' '; cout<<'\n';
#define tr1(x)          cerr <<#x<<": "<<x<<'\n';
#define tr2(x, y)       cerr <<#x<<": "<<x<<" | "<<#y<<": "<<y<<'\n';
#define tr3(x, y, z) 	cerr <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<'\n';
#define tr4(a, b, c, d) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<'\n';


bool isp(string a){
	string b = a;
	reverse(all(b));
	return a==b;
}

int32_t main(){
//Test
{
	string s;
	cin>>s;
	int n = s.size();
	string s1 = s.substr(0,(n-1)/2);
	string s2 = s.substr((n+3)/2-1);
	//tr2(s1,s2);
	if(isp(s) && isp(s1) && isp(s2)) cout<<"Yes\n";
	else cout<<"No\n";
	
    
}}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(abs(a-c) <= d) cout << "Yes" << endl;
  else if(abs(a-b) <= d && abs(b-c) <= d) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mxn 1000010
#define db double
#define LL long long
#define ldb long double
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair<int,int> 
#define mp make_pair
#define fr first
#define sc second
#define x1 faqx1
#define y1 faqy1
#define x2 faqx2
#define y2 faqy2
using namespace std;
int x,y,z,sl,fh;
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
int main()
{
	x=rd();y=rd();z=rd();
	if(x+y+z>=22) puts("bust");
	else puts("win");
	return 0;
}

Measured memory_bytes: 256
import sys
import math

N = int(sys.stdin.readline())

amount = []
for i in range(5):
    amount.append(int(sys.stdin.readline()))

min_index = 0
min_amount = amount[0]
for i in range(5):
    if min_amount > amount[i]:
        min_index = i
        min_amount = amount[i]

total_time = math.ceil(N/min_amount)
total_time += 4
print(total_time)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
const in INF=1<<30;
using vec = vector<vector<int>>;

int kai(int x){
int ret=1;
  if(x==0) return 1;
  for(int i=1;i<=x;i++) ret *=i;
  return ret;
}

int ban(vector<int> a,int n){
  int ret=0;
   for(int i=0;i<n;i++){
     ret +=kai(a.size()-1)*(a.at(0)-1);
     //cout<<endl<<"kai="<<ret<<endl;
     //for(int x:a) cout<<x<<" ";
     
     
    for(int j=1;j<a.size();j++){ if(a.at(j)>=a.at(0)){a.at(j)--;}}
     a.erase(a.begin());
   }
  return ret;
}

int main(){
  int n;
    cin>>n;
  vector<int> p(n);
  vector<int> q(n);

  rep(i,n) cin>>p.at(i);
  rep(i,n) cin>>q.at(i);
  
  
  int a=ban(p,n);
  int b=ban(q,n);
  //cout<<a<<" "<<b<<endl;
  int ans =abs(a-b);
  cout<<ans;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
const int INF=0x3f3f3f3f;
const int N=2005;
int dp[N][N],a[N],b[N],c1[N][N],c2[N][N],ans;
char s[10];
int main()
{
	int n,x;
	scanf("%d",&n);
	for(int i=1;i<=2*n;++i)
	{
		scanf("%s",s+1);
		scanf("%d",&x);
		if(s[1]=='B') a[x]=i;
		else b[x]=i;
	}
	for(int i=1;i<=n;++i)
	{
		for(int j=i+1;j<=n;++j)
		{
			if(a[i]>a[j]) ans++;
			if(b[i]>b[j]) ans++;
		}
		for(int j=n;j>=1;--j)
		{
			c1[i][j]=c1[i][j+1];
			c2[i][j]=c2[i][j+1];
			if(a[j]<b[i]) c2[i][j]++;
			if(b[j]<a[i]) c1[i][j]++;
		}
	}
	for(int i=0;i<=n;++i)
	{
		for(int j=0;j<=n;++j)
		{
			if(i==0&&j==0) dp[i][j]=0;
			else 
			{
				dp[i][j]=INF;
				if(i>0) dp[i][j]=min(dp[i][j],dp[i-1][j]+c1[i][j+1]);
				if(j>0) dp[i][j]=min(dp[i][j],dp[i][j-1]+c2[j][i+1]);
			}
		}
	}
	ans+=dp[n][n];
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 47360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
const ll mei = (ll)1e9 + 7;

int main(){
  string s;
  int a = 0;
  cin >> s;
  rep(i, s.size()){
    if(i % 2 == 0 && s[i] == 'L')
      a++;
    if(i % 2 == 1 && s[i] == 'R')
      a++;
  }
  if(a == 0)
    cout << "Yes";
  else
    cout << "No";
  memi;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  map<int,long long> mp;
  long long ans=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    ans+=a[i];
    mp[a[i]]++;
  }
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int b,c;
    cin>>b>>c;
    mp[c]+=mp[b];
    ans-=b*mp[b];
    ans+=c*mp[b];
    mp[b]=0;
    cout<<ans<<endl;
  }
  return 0;
}


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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#ifdef MPS
#define D(x...) printf(x)
#else
#define D(x...)
#endif
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;

void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}

int main()
{
	#ifdef MPS	
		fp("1.in","r",stdin);
		fp("1.out","w",stdout);
	#endif
	int n, k;
	cin >> n >> k;
	if(n/2+(n%2==0?0:1)>=k) cout << "YES"; else cout << "NO";
	return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
ln = []

def sqpls(i, j)
  num = i * i + j * j
  return num
end

n.times do |i|
  ln[i] = gets.chomp.split
  3.times do |j|
    ln[i][j] = ln[i][j].to_i
  end
end

n.times do |i|
  if sqpls(ln[i][0], ln[i][1]) == sqpls(ln[i][2], 0) ||
     sqpls(ln[i][1], ln[i][2]) == sqpls(ln[i][0], 0) ||
     sqpls(ln[i][2], ln[i][0]) == sqpls(ln[i][1], 0)
    puts "YES"
  else
    puts "NO"
  end
end


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

const long long N = 1000 * 1000 + 100, mod = 1LL * 1000 * 1000 * 1000 + 7;
map<long long, long long> mp;
long long n, a[N], cnt[N];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	long long size = 0;
	for (long long i = 1; i <= n; i++)
		cin >> a[i];
	vector<long long> p;
	for (long long i = 1; i <= n; i++) {
		long long k = a[i];
		for (long long j = 2; 1LL * j * j <= a[i]; j++)
			if (a[i] % j == 0) {
				if (mp[j] == 0) 
					mp[j] = ++size, p.push_back(j);
				long long x = 0;
				while (a[i] % j == 0)
					a[i] /= j, x++;
				cnt[mp[j]] = max(cnt[mp[j]], x);
			}
		if (a[i] > 1) {
			if (mp[a[i]] == 0)
				mp[a[i]] = ++size, p.push_back(a[i]);
			cnt[mp[a[i]]] = max(cnt[mp[a[i]]], 1LL);
		}
		a[i] = k;
	}
	long long sum = 0;
	for (long long i = 1; i <= n; i++) {
		long long k = a[i];
		for (long long j = 2; 1LL * j * j <= a[i]; j++) 
			while (a[i] % j == 0)
				cnt[mp[j]]--, a[i] /= j;
		if (a[i] > 1)
			cnt[mp[a[i]]]--;
		a[i] = k;
		long long t = 1;
		for (long long j = 1; j <= size; j++)
			for (long long K = 1; K <= cnt[j]; K++)
				(t *= p[j - 1]) %= mod;
		(sum += t) %= mod;
		for (long long j = 2; 1LL * j * j <= k; j++)
			while (k % j == 0)
				cnt[mp[j]]++, k /= j;
		if (k > 1)
			cnt[mp[k]]++;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3072
#include<stdio.h>

int main(void){
	int h,w,i,j;
	for(;;){
	scanf("%d %d",&h,&w);
	if(h==0 && w==0)
		break;
	for(i = 0;i < h;i++){
		for(j = 0;j < w;j++){
			printf("#");
			}
		printf("\n");
		}
	printf("\n");
	}

	return 0;
}

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

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, ans = 0;
	vector<int> A;
	vector<pair<int,int>> X;
	
	cin>>N;
	
	A.resize(N);
	X.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
		
		for(int j = 0; j < A[i]; j++){
			int x, y;
			
			cin>>x>>y;
			
			x--;
			
			if(y) X[i].first |= (1<<x);
			else X[i].second |= (1<<x);
		}
	}
	
	
	for(int i = 0; i < (1<<N); i++){
		bool flag = true;
		int con = 0;
		for(int j = 0; j < N; j++){
			if((i>>j)&1) {
				con++;
				for(int k = 0; k < N; k++){ 
					//if(i == 3) cout<<"j = "<<j<<"k = "<<k<<" "<<((X[j].first>>k)&1)<<endl;
					if((X[j].first>>k)&1) {
						//if(i == 3) cout<<"k = "<<k<<" "<<((i>>k)&1)<<endl;
						if((i>>k)&1) {
							
						} else {
							flag = false;
							break;
						}
					}
				}
				
				for(int k = 0; k < N; k++){
					if((X[j].second>>k)&1) {
						if((i>>k)&1) {
							flag = false;
							break;
						} else {
							
						}
					}
				}
				if(!flag) break;
				// int z = X[]
			} else {
				
			}
		}
		
		if(flag) ans = max(con, ans);
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#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 FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
  ll n;
  cin >> n;
  vector<string> s(n);
  vector<ll> t(n);
  REP(i, n) cin >> s[i] >> t[i];
  string x;
  cin >> x;

  ll ans = 0;
  bool ok = false;
  REP(i, n) {
    if (ok) ans += t[i];
    if (s[i] == x) ok = true;
  }

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

Measured memory_bytes: 256
// AtCoder ::
//

#include <bits/stdc++.h>
#include <atcoder/fenwicktree>

using namespace std;
using namespace atcoder;
using ll = long long;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, Q;
    cin >> N >> Q;
    fenwick_tree<ll> FT(N);
    for (int i{0}; i < N; ++i) {
        ll a;
        cin >> a;
        FT.add(i, a);
    }
    for (int i{0}; i < Q; ++i) {
        int t;
        cin >> t;
        if (t == 0) {
            int p;
            ll x;
            cin >> p >> x;
            FT.add(p, x);
        } else {
            int l, r;
            cin >> l >> r;
            cout << FT.sum(l, r) << "\n";
        }
    }
    return EXIT_SUCCESS;
}


Measured memory_bytes: 8252
import java.io.BufferedReader; 
import java.io.*;
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
import java.math.*;
public class Main 
{ 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader()
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next()
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine();
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
   public static void main(String args[])
    {
        FastReader sc=new FastReader();
        PrintWriter pw=new PrintWriter(System.out);
        int t=1;//sc.nextInt(),k=0;
        long ans=0,mod=1000000007;
        while(t-->0)
        {
         double l=sc.nextDouble();
         pw.println((l*l*l)/27);
        }
           pw.close();
    }
}
  

Measured memory_bytes: 32984
#python3
# utf-8

from itertools import product

abcd = input()
a, b, c, d = list(abcd)

for operations in product('+-', repeat=3):
    string = a
    string += operations[0]
    string += b
    string += operations[1]
    string += c
    string += operations[2]
    string += d
    ans = eval(string)
    if ans == 7:
        string += '=7'
        print(string)
        quit()


Measured memory_bytes: 3060
// created_by  Rishi_Mohan

#include<bits/stdc++.h>

#define    ll           long long
#define    db1(x)       cout<<#x<<"="<<x<<'\n'
#define    db2(x,y)     cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define    db3(x,y,z)   cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define    rep(i,n)     for(int i=0;i<(n);++i)
#define    repA(i,a,n)  for(int i=a;i<=(n);++i)
#define    repD(i,a,n)  for(int i=a;i>=(n);--i)

using namespace std;

void solve()
{
   string str;
   cin >> str;
   if(str[2]==str[3] && str[4]==str[5]) cout << "Yes";
   else cout << "No";
} 

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

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
#include <fstream>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second


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

ll lcm(ll a,ll b){
  return a*b/__gcd(a,b);
}

main(){
  ll a[3],m[3];
  ll x[3];
  while(true){
    rep(i,3){
      cin>>a[i]>>m[i];
      x[i]=1;
    }
    if(a[0]==0)break;
    

    int n[3];
    rep(i,3){
      n[i]=1;
      x[i]=x[i]*a[i]%m[i];
      while(x[i]!=1){
	n[i]++;
	x[i]=x[i]*a[i]%m[i];
      }
    }
    cout<<lcm(lcm(n[0],n[1]),n[2])<<endl;
  }
}

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

using namespace std;
typedef long long ll;

int main(){
  ll N;
  cin >> N;
  
  vector<ll> A(N+1);
  for(ll i=1; i<=N; i++) cin >> A[i];                         
                                
  unordered_map<ll, ll> a, b;
  for(ll i=1; i<=N; i++){
    ll temp1 = i - A[i];
    ll temp2 = i + A[i];
    if(a.find(temp1) == a.end()) a.emplace(temp1, 0);
    if(b.find(temp2) == b.end()) b.emplace(temp2, 0);
    ++a[temp1];
    ++b[temp2];
  }
  
  ll count = 0;
  for(auto &av : a){
     if(b.find(av.first) != b.end()) count += av.second * b[av.first];
  }
  
  cout << count << endl;
  return 0; 
}

Measured memory_bytes: 20124
n, a, b = map(int,input().split())

result = 0
for i in range(1,n+1):
  cList = list(str(i))
  chSum = 0
  for j in cList:
    chSum += int(j)
  if a <= chSum <= b:
    result += int(''.join(cList))

print(result)



Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

int main(){
    string s,t;
    cin>>s>>t;
    ll ssum[(int)s.size()+1];
    ssum[0]=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A')ssum[i+1]=1;
        else ssum[i+1]=2;
        ssum[i+1]+=ssum[i];
    }
    ll tsum[(int)t.size()+1];
    tsum[0]=0;
    for(int i=0;i<t.size();i++){
        if(t[i]=='A')tsum[i+1]=1;
        else tsum[i+1]=2;
        tsum[i+1]+=tsum[i];
    }
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        if((ssum[b]-ssum[a-1])%3==(tsum[d]-tsum[c-1])%3){
            cout<<"YES"<<endl;
        }
        else cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define Sheryang main
typedef long long ll;
#pragma GCC optimize(3)
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
int read()
{
    int x=0,f=1;    char c=getchar();
    while(c<'0'||c>'9')   {if(c=='-') f=-1;c=getchar();}
    while(c>='0'&&c<='9') {x=x*10+c-'0';c=getchar();}
    return x*f;
}
struct ios
{
    inline char gc()
    {
        static const int IN_LEN=1<<18|1;
        static char buf[IN_LEN],*s,*t;
        return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;
    }
    template <typename _Tp> inline ios & operator >> (_Tp&x)
    {
        static char ch,sgn; ch = gc(), sgn = 0;
        for(;!isdigit(ch);ch=gc())
        {   
            if(ch==-1)return *this;sgn|=ch=='-';
        }
        for(x=0;isdigit(ch);ch=gc())x=(((x<<2)+x)<<1)+(ch^'0');
        sgn&&(x=-x); return *this;
    }
}io;
const int maxn = 1e6 + 7;
const int mod = 1e9 + 7;
/** keep hungry and keep calm! **/
 
unsigned long long p,cnt=1;
int main()
{
    cin >> p;
    while(p >= cnt) cnt<<=1;//求2的第一个比h大的次幂
    cout << cnt-1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  long long int A,B,C,ans;
  scanf("%lld%lld%lld",&A,&B,&C);
  if(A%2==0||B%2==0||C%2==0){
    ans=0;
  }else{
    if(A<B){
      if(B<C){
	ans=A*B;
      }else{
	ans=A*C;
      }
    }else{
      if(C<A){
	ans=B*C;
      }else{
	ans=A*B;
      }
    }
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 128
#行けるかどうかは判断できる、回数は判断できない
#-->回数を数えるように変更
import sys
input = sys.stdin.readline
N, M = map(int, input().split())

#辺の管理(1-index)s
edge = [[] for _ in range(N + 1)]
for _ in range(M):
    u, v = map(int, input().split())
    edge[u] += [v]
# print (edge)
INF = 10 ** 9
used1 = [INF] * (N + 1) #1手目で行けたところ
used2 = [INF] * (N + 1) #2手目で行けたところ
used3 = [INF] * (N + 1) #3手目で行けたところ

def solve(s): #スタート地点s
    from collections import deque
    used3[s] = 0
    
    #ここまで最初の準備
    from1 = deque() #used1から向かう辺のdeque
    from2 = deque() #used2から向かう辺のdeque
    from3 = deque() #used3から向かう辺のdeque

    f1append = from1.append
    f2append = from2.append
    f3append = from3.append

    f1pop = from1.popleft
    f2pop = from2.popleft
    f3pop = from3.popleft

    for i in edge[s]:
        # print (i)
        f3append(i)

    #deque: 空のとき = False
    count = 0
    while from1 or from2 or from3: #どれかが空ではないとき
        count += 1
        #from3 --> from1 -->from2の順にすべて処理
        for _ in range(len(from3)):
            # print ('from3', count)
            v = f3pop()
            if used1[v] == INF:
                used1[v] = count
                for i in edge[v]:
                    f1append(i)
        
        for _ in range(len(from1)): #中にある分すべてを処理する
            # print ('from1', count)
            v = f1pop()
            if used2[v] == INF:
                used2[v] = count
                for i in edge[v]:
                    f2append(i)
        
        for _ in range(len(from2)):
            # print ('from2', count)
            v = f2pop()
            if used3[v] == INF:
                used3[v] = count
                for i in edge[v]:
                    f3append(i)
        
    return


S, T = map(int, input().split())

solve(S)
# print (1, used1)
# print (2, used2)
# print (3, used3)

if used3[T] == INF:
    print (-1)
else:
    print (used3[T])

Measured memory_bytes: 23856
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define READ(a) int a; cin >> a;
#define READARR(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define READMAT(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
#define print(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
    int n, m;
    cin >> n >> m;
    int x, prob[n + 1] = {}, penalty[n + 1] = {};
    FOR (i, 1, m)
    {
        string str;
        cin >> x >> str;
        if (str == "AC") prob[x] = 1;
        else if (!prob[x]) penalty[x]++;
    }
    
    int a = 0, b = 0;
    FOR (i, 1, n) 
        if (prob[i]) a++, b += penalty[i];
    cout << a << " " << b;
}

Measured memory_bytes: 1792