akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }



// isprime[n] := is n prime?
// mebius[n] := mebius value of n
// min_factor[n] := the min prime-factor of n

struct Eratos {
    vector<int> primes;
    vector<bool> isprime;
    vector<int> mebius;
    vector<int> min_factor;

    Eratos(int MAX) : primes(),
                      isprime(MAX+1, true),
                      mebius(MAX+1, 1),
                      min_factor(MAX+1, -1) {
        isprime[0] = isprime[1] = false;
        min_factor[0] = 0, min_factor[1] = 1;
        for (int i = 2; i <= MAX; ++i) {
            if (!isprime[i]) continue;
            primes.push_back(i);
            mebius[i] = -1;
            min_factor[i] = i;
            for (int j = i*2; j <= MAX; j += i) {
                isprime[j] = false;
                if ((j / i) % i == 0) mebius[j] = 0;
                else mebius[j] = -mebius[j];
                if (min_factor[j] == -1) min_factor[j] = i;
            }
        }
    }

    // prime factorization
    vector<pair<int,int>> prime_factors(int n) {
        vector<pair<int,int> > res;
        while (n != 1) {
            int prime = min_factor[n];
            int exp = 0;
            while (min_factor[n] == prime) {
                ++exp;
                n /= prime;
            }
            res.push_back(make_pair(prime, exp));
        }
        return res;
    }

    int func(int n) {
        int res = 1;
        while (n != 1) {
            int prime = min_factor[n];
            int exp = 0;
            while (min_factor[n] == prime) {
                ++exp;
                n /= prime;
            }
            res *= exp + 1;
        }
        return res;
    }
};

const int MAX = 11000000;

int main() {
    Eratos er(MAX);
    int N;
    cin >> N;
    long long res = 0;
    for (long long K = 1; K <= N; ++K) {
        res += K * er.func(K);
    }
    cout << res << endl;
}

















Measured memory_bytes: 94552
#include <iostream>
#include <cmath>
#include <vector>
#include <limits>
using namespace std;
using ll = long long;

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> a(N);
    vector<ll> sum(N);
    vector<ll> sum2(N);
    for(int i=0; i<N; ++i) {
        cin >> a[i];
        if(i == 0) {
            sum[0] = a[0];
            sum2[0] = max(0LL, a[0]);
            continue;
        }
        sum[i] = sum[i-1] + a[i];
        sum2[i] = sum2[i-1] + max(0LL, a[i]);
    }
    ll ans = numeric_limits<ll>::min();
    for(int i=0; i<=N-K; ++i) {
        ll tmp = max(sum[i+K-1] - (i == 0 ? 0LL : sum[i-1]), 0LL);
        if(i != 0) {
            tmp += sum2[i-1];
        }
        tmp += sum2[N-1] - sum2[i+K-1];
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}


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

#define UN unsigned
#define ll long long
#define mod 1000000007
#define pii pair<int, int>
#define pb push_back
//~ #define x first
//~ #define y second
// const int N = 1e6 + 5;

int main(void) {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);
	
	string s, t;
	cin >> s >> t;
	int n = s.length(), cnt = 0;
	for(int i=0; i<n; i++)	{
		if(s[i] != t[i]) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

int main(){
    ll n, m, x, y, z, q;
    cin >> n >> m;
    if(n==m || n%m==0)cout << n%m;
    else if(n>m){
        n %= m;
        x = abs(n-m), y = abs(x-m), z = abs(y-m);
        cout << min(min(x, y), z);
    }else{
        x = abs(n-m), y = abs(x-m), z = abs(y-m);
        cout << min(min(x, y), z);
    }
    return 0;
}

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

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

Measured memory_bytes: 256
N = int(raw_input())
# T_list = []
# A_list = []
T = 1
A = 1

for n in range(N):
    t, a = map(int, raw_input().split())
    k = max(int(T/t), int(A/a))
    if T > t*k or A > a*k:
        T = t*(k+1)
        A = a*(k+1)
    else:
        T = t*k
        A = a*k

print T+A
    

Measured memory_bytes: 2696
"use strict";
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.split(/ |\n/), cid = 0;
function next(a) { return a ? cin[cid++] : +cin[cid++]; }
function nexts(n, a) { return a ? cin.slice(cid, cid += n) : cin.slice(cid, cid += n).map(a => +a); }
function nextm(h, w, a) { var r = [], i = 0; if (a) for (; i < h; i++)r.push(cin.slice(cid, cid += w)); else for (; i < h; i++)r.push(cin.slice(cid, cid += w).map(a => +a)); return r; }
function xArray(v) { var a = arguments, l = a.length, r = "Array(a[" + --l + "]).fill().map(x=>{return " + v + ";})"; while (--l) r = "Array(a[" + l + "]).fill().map(x=>" + r + ")"; return eval(r); }

var myOut = main();
if (myOut !== undefined) console.log(myOut);

function main() {
    //console.log(cin);
    cin = cin.map(i => +i);
    var n = cin.shift();
    let nArray = Array(n + 1).fill(1);
    nArray[0] = 0;
    var k = cin.shift();
    let pdi = 0;
    let A = [];
    for (let i = 0; i < cin.length;) {
        let di = (cin[i]); i++;
        //console.log(di);
        //        A.push(cin.slice(i,i+ di)); i += di;
        let used = cin.slice(i, i + di); i += di;
        used.forEach(i => { nArray[i] = 0; });
        //console.log("used:", used);
    }
    let ans = 0;
    //console.log(nArray);
    nArray.forEach(x => { ans += x; });


    return ans;
}

Measured memory_bytes: 30460
#include <iostream>
#include <stdint.h>

using namespace std;

int32_t main()
{
  int32_t sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  int32_t diff_x = tx - sx;
  int32_t diff_y = ty - sy;

  for (int32_t i = 0; i < diff_y; i++) {
    cout << "U";
  }
  for (int32_t i = 0; i < diff_x; i++) {
    cout << "R";
  }

  for (int32_t i = 0; i < diff_y; i++) {
    cout << "D";
  }
  for (int32_t i = 0; i < diff_x; i++) {
    cout << "L";
  }

  cout << "D";
  for (int32_t i = 0; i < diff_x + 1; i++) {
    cout << "R";
  }
  for (int32_t i = 0; i < diff_y + 1; i++) {
    cout << "U";
  }
  cout << "L";

  cout << "U";
  for (int32_t i = 0; i < diff_x + 1; i++) {
    cout << "L";
  }
  for (int32_t i = 0; i < diff_y + 1; i++) {
    cout << "D";
  }
  cout << "R";

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



signed main() {
	cin.tie(nullptr);
	cout.tie(nullptr);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	int n;
	cin >> n;
	int a[n];
	rep(i, n) {
		cin >> a[i];
		//a[i] %= MOD;
	}
	int sum[n+10] = {}, allsum = 0;
	rep(i, n) {
		sum[i+1] = (sum[i] + a[i]) % MOD;
		allsum += a[i];
		sum[i+1] %= MOD;
		allsum %= MOD;
	}
	int ans = 0;
	rep(i, n-1) {
		int now = (allsum + 2 * MOD - sum[i] - a[i]) % MOD;
		now = now * a[i] % MOD;
		ans += now, ans %= MOD;
		//cout << allsum - sum[i] - a[i] << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6652
N = int(input())
A,B = map(int,input().split())
P = list(map(int,input().split()))
P1,P2,P3=0,0,0
for i in range(N):
    if P[i]  <= A:
        P1 += 1
    elif P[i]  <= B:
        P2 += 1
    else:
        P3 += 1
print(min(P1,P2,P3))

Measured memory_bytes: 3064
package main

import "fmt"

func main() {
        var n int
        fmt.Scan(&n)

        tmp, denom := n, 0
        for tmp != 0 {
                denom += tmp % 10
                tmp = tmp / 10
        }
        if n%denom == 0 {
                fmt.Println("Yes")
        } else {
                fmt.Println("No")
        }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main () {
string s;
cin>>s;
vector<int> v(int(s.length())-2);
for(int i=0;i<int(s.length())-2;i++)v[i]=abs(753-stoi(s.substr(i,3) )) ;
sort(v.begin(),v.end());
cout<<v[0]<<endl;
return 0;
}

Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{
	   public static void main(String[] args) {
	        Scanner stdin  = new Scanner(new BufferedInputStream(System.in));
	        List<String> output = new ArrayList<String>();
	        while (stdin.hasNext()) {
	            String input = stdin.nextLine();
	            String[] in = input.split(" ");
	            int a = Integer.parseInt(in[0]);
	            String op = in[1];
	            int b = Integer.parseInt(in[2]);
	 
	            if ("?".equals(op)) {
	                break;
	            } else {
	                if (a >= 0 && a <= 20000 && b >= 0 && b <= 20000) {
	                    if ("+".equals(op)) {
	                        int result = a + b;
	                        output.add(String.valueOf(result));
	                    } else if ("-".equals(op)) {
	                        int result = a - b;
	                        output.add(String.valueOf(result));
	                    } else if ("*".equals(op)) {
	                        int result = a * b;
	                        output.add(String.valueOf(result));
	                    } else if ("/".equals(op)) {
	                        if (b != 0) {
	                            int result = a / b;
	                            output.add(String.valueOf(result));
	                        }
	                    }
	                }
	            }
	        }
	        for (String out : output) {
	            System.out.println(out);
	        }
	    }
	 
	
}

Measured memory_bytes: 26184
#include <iostream>

int main(int argc, char **argv)
{
    int N, A, B;
    std::cin >> N >> A >> B;

    int Max, Min;

    if (A <= B) {Max = A;}
    else {Max = B;}

    if (A+B <= N) {Min = 0;}
    else {Min = A+B - N;}

    std::cout << Max << ' ' << Min << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long 
#define f(z) for(int i=1;i<=z;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define vi vector<int>
#define pb push_back
#define si set<int>
int cl(int n ,int m) { if(n%m)return n/m + 1 ;else return n/m ;}
int pw(int a,int b){int r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
#define mod  1000000007
#define T() int TT; cin>>TT; while(TT--)
#define P pair<int,int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 1e6 + 5 ;

signed main(){
	int a , b ,c ;
	cin >> a >> b >> c ; 
	if( a + b + c >= 22 ) cout <<"bust\n";
	else cout <<"win\n";
}







Measured memory_bytes: 256
while True:
    a=int(input())
    if a==0:
        break
    else:
        L=[]
        for i in range(a):
            b=int(input())
            L.append(b)
            i+=1
        for j in range(10):
            c=L.count(j)
            if c==0:
                print("-")
            else:
                for k in range(c):
                    print("*",end="")
                    k+=1
                print()



Measured memory_bytes: 7680
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();
    String res = "Yes";
    for (int i = 0; i < s.length(); i++) {
      if (s.charAt(i) != t.charAt(i)) res = "No";
    }
    System.out.println(res);
    sc.close();
  }
}

Measured memory_bytes: 35668
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

char c1, c2;

int main()
{
	cin >> c1 >> c2;
	
	if (c1 > c2) {
		cout << ">" << endl;
	}
	else if (c1 < c2){
		cout << "<" << endl;
	}
	else {
		cout << "=" << endl;
	}

	return 0;
}


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

int dp[MAX],in[MAX],n,k;

int solve(int pos)
{
    if(pos>=n)
        return 0;
    if(dp[pos]!=-1)
        return dp[pos];

    int res=1e9,i;
    for(i=1; i<=k; i++)
    {
        if((i+pos)>n)
            break;
        int a=in[pos]-in[pos+i];
        if(a<0)
            a*=-1;
        res=min(res,a+solve(pos+i));
    }
    dp[pos]=res;
    return dp[pos];
}

int main()
{
    int i,res,j;
    scanf("%d%d",&n,&k);
    memset(dp, -1, sizeof(dp));
    for(i=1; i<=n; i++)
        scanf("%d",&in[i]);

    res=solve(1);
    printf("%d\n",res);


    return 0;
}


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

int main()
{
    long long A[100][100] { 0 };
    long long B[100][100] { 0 };
    long long C[100][100] { 0 };
    int n, m, l;
    cin >> n >> m >>l;

    for(int i=0; i<n; ++i){
        for(int j=0; j<m; ++j){
            cin >> A[i][j];
        }
    }

    for(int i=0; i<m; ++i){
        for(int j=0; j<l; ++j){
            cin >> B[i][j];
        }
    }

    for(int i=0; i<n; ++i){
        for(int j=0; j<m; ++j){
            for(int k=0; k<l; ++k){
                C[i][k] += A[i][j] * B[j][k];
            }
        }
    }

    for(int i=0; i<n; ++i){
        for(int j=0; j<l; ++j){
            cout << C[i][j];
            if(j!=l-1)
                cout << ' ';

        }
        cout << endl;
    }

    

    return 0;
}



Measured memory_bytes: 3352
#include<stdio.h>

#define MAX 2000001
#define INF -2000000001

int size;

int A[MAX];

int left(int);

int right(int);

void increase(int, int);

void insert(int);

void maxHeapify(int);

int extractMax(void);


int main(){

  char com[10];

  int num;

  size = 0;

  while(1){

    scanf("%s", com);

    if(com[0] == 'i'){

      scanf("%d", &num);

      insert(num);

    }

    else if((com[0] == 'e') && (com[1] == 'x')){

      printf("%d\n", extractMax());

    }

    else if((com[0] == 'e') && (com[1] == 'n')){
      
      break;

    }

  }

  return 0;

}

int left(int x){

  return (2 * x);

}
 
int right(int x){
  
  return (2 * x + 1);

}

void increase(int i, int key){

  int tmp;

  A[i] = key;

  while((i > 1) && (A[i / 2] < A[i])){

    tmp = A[i];
    
    A[i] = A[i / 2];

    A[i / 2] = tmp;

    i = (i / 2);

  }

}

void insert(int key){

  size++;

  A[size] == INF;

  increase(size, key);

}

void maxHeapify(int i){

  int l, r, largest, tmp;

  l = left(i);

  r = right(i);

  if((l <= size) && (A[l] > A[i]))
    largest = l;
  else
    largest = i;

  if((r <= size) && (A[r] > A[largest]))
    largest = r;

  if(largest != i){

    tmp = A[i];

    A[i] = A[largest];

    A[largest] = tmp;

    maxHeapify(largest);

  }

}
 
int extractMax(){

  int max;

  max = A[1];

  A[1] = A[size];

  size--;

  maxHeapify(1);

  return max;

}

Measured memory_bytes: 4696
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;


int N;

bool check(const vector<pair<ld, ld>>&cs, const ld amid) {
	map<ld, int>mp;
	for (auto c : cs) {
		const ld r = c.second;
		const ld x = c.first;
		if (r > amid) {
			ld dis = sqrt(r*r - amid*amid);
			mp[x - dis]++;
			mp[x + dis]--;
		}
	}
	ld pre = -1;
	int num = 0;
	ld len = 0;
	bool preok = false;
	for (auto m : mp) {
		num += m.second;
		if (num) {
			if (!preok) {
				pre = m.first;
			}
		}
		else {
			if (num < 0)assert(false);
			if (preok) {
				len = max(len, m.first - pre);
			}
		}
		preok = num;
	}
	return amid*2 < len;
}
int main() { 
	while (1) {
		cin >> N;
		if (!N)break;
		vector<pair<ld, ld>>cs;
		for (int i = 0; i < N; ++i) {
			int x, r; cin >> x >> r;
			cs.push_back(make_pair(x, r));
		}
		ld amin = 0;
		ld amax = 2e6;
		int atime = 40;
		while (atime--) {
			ld amid = (amin + amax) / 2;
			if (check(cs, amid)) {
				amin = amid;
			}
			else {
				amax = amid;
			}
		}
		cout << setprecision(22) << fixed << amin*2 << endl;
	}
	
	return 0;
}

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

// macros
#define overload_rep(va_0, va_1, va_2, name, ...) name
#define rep_0(i, n) for(int i = 0; i < (n); ++i)
#define rep_1(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
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; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// libraries
template<const int_fast64_t mod = 1000000007>
struct ModInt {
private: using ll = int_fast64_t;
public: ll x;
    constexpr ModInt(ll t = 0) noexcept : x((t %= mod) < 0 ? t + mod : t) {}
    constexpr friend istream& operator >> (istream& s, ModInt& m) noexcept {
        s >> m.x; m.x %= mod; if(m.x < 0)m.x += mod; return s;
    }
    constexpr friend ostream& operator << (ostream& s, ModInt m) noexcept {
        return s << m.x;
    }
    constexpr ModInt operator + (const ModInt m) noexcept { return ModInt(*this) += m; }
    constexpr ModInt& operator += (const ModInt m) noexcept {
        if((x += m.x) >= mod)x -= mod; return *this;
    }
    constexpr ModInt operator - (const ModInt m) noexcept { return ModInt(*this) -= m; }
    constexpr ModInt& operator -= (const ModInt m) noexcept {
        if((x += mod - m.x) >= mod)x -= mod; return *this;
    }
    constexpr ModInt operator * (const ModInt m) noexcept { return ModInt(*this) *= m; }
    constexpr ModInt& operator *= (const ModInt m) noexcept {
        x = x * m.x % mod; return *this;
    }
    constexpr ModInt operator / (const ModInt m) noexcept { return ModInt(*this) /= m; }
    constexpr ModInt& operator /= (const ModInt m) noexcept {
        return *this *= m.inv();
    }
    constexpr ModInt inv() const noexcept {
        return pow(mod - 2);
    }
    constexpr ModInt pow(ll p) const noexcept {
        ModInt res(1), mult(*this);
        for(; p; p >>= 1){ if(p & 1)res *= mult; mult *= mult; }
        return res;
    }
};

// declarations
using mint = ModInt<>;
int memo[3];

// solve
int main(){

    int N;
    cin >> N;

    mint ans(1);
    rep(i, N){
        int a, c = 0;
        cin >> a;
        rep(j, 3)if(memo[j] == a)c++;
        ans *= mint(c);
        rep(j, 3)if(memo[j] == a){
            memo[j]++;
            break;
        }
    }

    cout << ans << '\n';
    return 0;

}


Measured memory_bytes: 256
# ABC125C - GCD on Blackboard
from fractions import gcd


class SegmentTree:
    __slots__ = ["_default_value", "_seg_func", "_size", "_tree"]

    def __init__(self, initial_values, default_value, seg_func) -> None:
        self._default_value = default_value
        self._seg_func = seg_func
        self._size = 1 << (len(initial_values) - 1).bit_length()
        self._tree = self._build(initial_values)

    def _build(self, initial_values) -> list:
        """Build a segment tree with initial values."""
        tree = [self._default_value] * (2 * self._size)

        for idx, val in enumerate(initial_values):  # set
            # modify val if needed (e.g. str -> ord())
            tree[idx + self._size - 1] = val

        for idx in range(self._size - 2, -1, -1):  # build
            tree[idx] = self._seg_func(tree[2 * idx + 1], tree[2 * idx + 2])

        return tree

    def update(self, index: int, value: int) -> None:
        """Update index to value."""
        index += self._size - 1
        # modify value if needed as same as in _build()
        self._tree[index] = value
        while index:
            index = (index - 1) // 2
            self._tree[index] = self._seg_func(self._tree[2 * index + 1], self._tree[2 * index + 2])

    def query(self, left: int, right: int):
        """Respond to query in [left, right]."""
        left += self._size
        right += self._size
        result = self._default_value
        while left < right:
            if left & 1:
                result = self._seg_func(result, self._tree[left - 1])
                left += 1
            if right & 1:
                right -= 1
                result = self._seg_func(result, self._tree[right - 1])
            left >>= 1
            right >>= 1
        return result


def main():
    N, *A = map(int, open(0).read().split())
    seg = SegmentTree(A, 0, gcd)
    ans = max(gcd(seg.query(0, i), seg.query(i + 1, N)) for i in range(N))
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 16172
#include <stdio.h>
#include <math.h>

int main(void)
{
    int n, x, i, j= 0;
    double m;
    
    int c = 0;
    
    scanf ( "%d", &n );
    
    for ( i = 0; i < n; i++){
        scanf("%d", &x);
        if ( x == 2 ) {
            c = c + 1;
        }
        else if ( x > 2 && x % 2 == 1) {
            j = 3;
            m = sqrt(x);
            int z = 1;
            while ( j <= m) {
                if ( x % j == 0 ) {
                    z = 0;
                    break;
                }
                j = j + 2;
            }
            
            if ( z == 1 ) {
                c = c + 1;
            }
        }
    }
    printf ( "%d\n", c );
    
    return 0;
}



Measured memory_bytes: 2048
N  = int (input())
nums = list(map(int, input().split(" ")))
colors = [0,0,0]
ans = 1
MOD = 10 ** 9 + 7
for num in nums:
    cot = 0
    ind = -1
    for i in range(3):
        if colors[i] == num:
            ind = i
            cot += 1
    colors[ind] += 1
    ans *= cot
    ans %= MOD
print(ans)

Measured memory_bytes: 52204
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define INF 1LL<<60
#define pi 3.14159265358979323846
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}

int main(){
    string s;cin>>s;
    vector<int> num(4,0);//w,e,n,sの個数

    for(ll i=0;i<s.size();i++){
        if(s[i]=='W'){
            num[0]=1;
        }else if(s[i]=='E'){
            num[1]=1;
        }else if(s[i]=='N'){
            num[2]=1;
        }else if(s[i]=='S'){
            num[3]=1;
        }
    }

    int number=0;
    for(int i=0;i<4;i++){
        if(num[i]){number++;}
    }

    if(number%2==1){
        cout<<"No"<<endl;
    }else{
        if((num[0] && num[1])||(num[2] && num[3])||(num[0] && num[1] && num[2] && num[3])) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
 
//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
//const ll mod = 998244353 ;
const ll mod=1e9+7;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return ((a%mod)*1ll*b)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}


/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 

ll i,j,k,l,m,r,n;
ll a[MAX],b[MAX];
vll adj[MAX];

int main()
{
 
  #ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
//cout << setprecision(15) << fixed;
fast

cin >> n >> k;
fr(i,1,1+n)
	cin >> a[i];
fr(i,0,k)
{
	cin >> l >> r;
	adj[l].pb(r);
	adj[r].pb(l);
}
ll ans = 0;
fr(i,1,1+n)
{
	if(adj[i].size() == 0)
		ans++;
	else
	{
		bool check = true;
		ll sz = a[i];
		for(auto x: adj[i])
		{
			if(a[x]>=sz)
				check = false;
		}
		ans += (check==true);
	}
}

cout << ans;

  #ifndef ONLINE_JUDGE
  cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  #endif
 
  return 0;
 
}

Measured memory_bytes: 31244
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.StringJoiner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long A = scan.nextLong();
        long B = scan.nextLong();
        long gcd = gcd(A, B);
        Map<Long, Long> map = divisors(gcd);
        System.out.println(map.size() + 1);
    }
    private Map<Long, Long> divisors(long N) {
        Map<Long, Long> result = new HashMap<>();
        for (long i = 2; i * i <= N; i++) {
            if (N % i != 0) {
                continue;
            }
            long count = 0;
            while (N % i == 0) {
                count += 1;
                N /= i;
            }
            result.put(i, count);
        }
        if (N != 1) {
            result.put(N, 1L);
        }
        return result;
    }
    private long gcd(long A, long B) {
        if (B == 0) {
            return A;
        }
        return gcd(B,A % B);
    }
}


Measured memory_bytes: 23124
n=int(input())
a=[0]*(n+1)
six=0
nine=0
for i in range(1,n+1):
  if i>=6**(six+1):
    six+=1
  if i>=9**(nine+1):
    nine+=1
  a[i]=min(a[i-1],a[i-6**six],a[i-9**nine])+1
print(a[n])

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
    vector<valarray<int>> C(3, valarray<int>(3));
    for(int i = 0; i < 3; i++){
        for(int k = 0; k < 3; k++){
            cin >> C[i][k]; 
        }
    }

    int MIN = C[0].min();
    vector<valarray<int>> a(3); 
    valarray<int> b(3);
    for(int a0 = 0; a0 <= MIN; a0++){
        a[0] = valarray<int>(a0, 3);
        b = C[0] - a[0];
        a[1] = C[1] - b;
        a[2] = C[2] - b;
        if(a[1].min() == a[1].max() && a[2].min() == a[2].max()){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,m;
    cin>>n>>m;
    if(n>=2)
    n=n*(n-1)/2;
    else
        n=0;
    if(m>=2)
        m=m*(m-1)/2;
    else
        m=0;
    cout<<n+m<<endl;

}

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

using namespace std;

const int MAXN=4096;
double f[MAXN][MAXN],a[MAXN];
double ans;
int n;

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	f[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=i;j++){
			if(j) f[i][j]+=f[i-1][j-1]*a[i];
			f[i][j]+=f[i-1][j]*(1-a[i]);
		}
	}
	for(int i=(n+1)/2;i<=n;i++){
		ans+=f[n][i];
	}
	printf("%.10lf\n",ans);
	return 0;
}


Measured memory_bytes: 94720
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	class FS{
		int p[];
		int rank[];
		int cnt[];
		public FS(int n) {
			p= new int[n];
			rank=new int[n];
			cnt = new int[n];
			for(int i=0; i<n; i++) {
				makeSet(i);
			}
		}
		public void makeSet(int i) {
			p[i]=i;
			rank[i]=0;
			cnt[i]=1;
		}
		public boolean same(int x, int y) {
			return find(x) == find(y);
		}
		public int find(int x) {
			if(p[x]==x) return x;
			p[x] = find(p[x]);
			return p[x];
		}
		public boolean link(int x, int y) {
			if(x==y) return false;
			if(rank[x]>rank[y]) {
				p[y]=x;
				cnt[x] += cnt[y];
			}else {
				p[x]=y;
				cnt[y] += cnt[x];
				if(rank[x]==rank[y]) {
					rank[y]++;
				}
			}
			return true;
		}
		public boolean unite(int x, int y) {
			return link(find(x), find(y));
		}
		public int size(int x) {
			return cnt[find(x)];
		}
	}

	class Edge implements Comparable<Edge>{
		int s;
		int t;
		long c;
		Edge(int s, int t, long c){
			this.s=s;
			this.t=t;
			this.c=c;
		}
		@Override
		public int compareTo(Edge o) {
			return Long.compare(this.c, o.c);
		}
	}

	class Pair implements Comparable<Pair>{
		int p;
		int i;
		Pair(int p, int i){
			this.p=p;
			this.i=i;
		}
		@Override
		public int compareTo(Pair o) {
			if(this.p==o.p) {
				return Long.compare(this.i, o.i);
			}
			return Long.compare(this.p, o.p);
		}

	}
	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();

		ArrayList<Pair> px = new ArrayList<Pair>();
		ArrayList<Pair> py = new ArrayList<Pair>();
		for(int i=0; i<n; i++) {
			int x=sc.nextInt();
			int y=sc.nextInt();
			px.add(new Pair(x, i));
			py.add(new Pair(y, i));
		}

		Collections.sort(px);
		Collections.sort(py);

		ArrayList<Edge> es = new ArrayList<Edge>();


		for(int i=0; i<n-1; i++) {
			Pair ps = px.get(i);
			Pair pt = px.get(i+1);
			int s = ps.i;
			int t = pt.i;
			int c = Math.abs(pt.p-ps.p);
			Edge e = new Edge(s,t,c);
			es.add(e);

			ps = py.get(i);
			pt = py.get(i+1);
			s = ps.i;
			t = pt.i;
			c = Math.abs(pt.p-ps.p);
			e = new Edge(s,t,c);
			es.add(e);
		}

		Collections.sort(es);

		long ans = kruskal(es);
		System.out.println(ans);

		sc.close();
	}

	private long kruskal(ArrayList<Edge> es) {
		FS fs = new FS(es.size());
		long cnt = 0;
		for(Edge e : es) {
			if(!fs.same(e.s, e.t)) {
				fs.unite(e.s, e.t);
				cnt += e.c;
			}
		}
		return cnt;
	}
}


Measured memory_bytes: 101768
(N,) = [int(x) for x in input().split()]
XY = [[int(x) for x in input().split()] for i in range(N)]

best = 0

mn = min(XY, key=lambda pt: pt[0] + pt[1])
mx = max(XY, key=lambda pt: pt[0] + pt[1])
best = max(best, abs(mn[0] - mx[0]) + abs(mn[1] - mx[1]))

mn = min(XY, key=lambda pt: pt[0] - pt[1])
mx = max(XY, key=lambda pt: pt[0] - pt[1])
best = max(best, abs(mn[0] - mx[0]) + abs(mn[1] - mx[1]))


print(best)


Measured memory_bytes: 102396
import java.util.*;
public class Main{
  public static void main(String [] args){
    Scanner sc = new Scanner(System.in);
    int a,b,i,lcm,gcd;
    while(sc.hasNext()){
      a = sc.nextInt();
      b = sc.nextInt();
      gcd = 1;
      for(i = 1;i <= Math.min(a,b);i++){
        if(a % i == 0 && b % i == 0)gcd = i;
      }
      lcm = a / gcd * b ;
      System.out.println(gcd + " " + lcm);
    }
  }
}

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

using namespace std;

typedef string::const_iterator State;
typedef pair<int, int> Pii;

#define fr first
#define sc second

bool is_over = false;

struct Parser {
  Pii expression(State &idx) {
    Pii ret = term(idx);
    if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    while ( 1 ) {
      if ( *idx == '+' ) {
	idx++;
	Pii tmp = term(idx);
	ret.fr = ret.fr + tmp.fr;
	ret.sc = ret.sc + tmp.sc;
	if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
      } else if ( *idx == '-' ) {
	idx++;
	Pii tmp = term(idx);
	ret.fr = ret.fr - tmp.fr;
	ret.sc = ret.sc - tmp.sc;
	if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
      } else {
	break;
      }
    }
    if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    return ret;
  }
  
  Pii term(State &idx) {
    Pii ret = factor(idx);
    if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    //
    while ( 1 ) {
      if ( *idx == '*' ) {
	idx++;
	Pii tmp = factor(idx), tmp2 = ret;
	//cout << ret.fr << " " << ret.sc << endl;
	//cout << tmp.fr << " " << tmp.sc << endl;
	ret.fr = tmp2.fr * tmp.fr - tmp2.sc * tmp.sc;
	ret.sc = tmp2.fr * tmp.sc + tmp2.sc * tmp.fr;
	if ( abs(ret.fr)> 10000 || abs(ret.sc) > 10000 ) is_over = true;
	//	cout << ret.fr << " " << ret.sc << endl;
      } else {
	break;
      }
    }
    if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    return ret;
  }

  Pii factor(State &idx) {
    Pii ret;
    if ( *idx == '(' ) {
      idx++;
      ret = expression(idx);
      if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
      idx++;
    } else {
      ret = number(idx);
      if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    }
    if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    return ret;
  }

  Pii number(State &idx) {
    int tmp = 0;
    while ( '0' <= *idx && *idx <= '9' ) {
      tmp *= 10;
      tmp += *idx - '0';
      if ( abs(tmp) > 10000 ) is_over = true;
      idx++;
      /*if ( *idx == 'i' ) {
	is_real = false;
	idx++;
	}*/
    }
    if ( abs(tmp) > 10000 ) is_over = true;
    //cout << tmp << endl;
    if ( *idx == 'i' ) {
      idx++;
      return Pii(0, 1);
    }
 
    else return Pii(tmp, 0);
  }
};

int main()
{
  string s;
  while ( cin >> s ) {
    is_over = false;
    Parser ps;
    string tmp = s.substr(0, s.size() - 1);
    State idx = s.begin();

    Pii ret = ps.expression(idx);
    if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    if ( is_over ) cout << "overflow" << endl;
    else if ( ret.fr == 0 && ret.sc == 0 ) cout << 0 << endl;
    else if ( ret.fr == 0 ) {
      printf("%di\n", ret.sc);
    }
    else if ( ret.sc == 0 ) {
      printf("%d\n", ret.fr);
    }
    else {
      printf("%d", ret.fr);
      printf("%+di\n", ret.sc);
      //   cout << ret.fr << '+' << ret.sc << 'i' << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3376
#include <algorithm>
#include <cmath>
#include <ctime>
#include <climits>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <tuple>
#include <bitset>
#include <unordered_map>

using namespace std;

int main() {
    const string search = "Hoshino";

    int n;
    cin >> n;
    cin.get();

    string text;
    while (n --) {
        getline(cin, text);
        for (int i=0; i<(int)text.size(); ) {
            int j;
            for (j=0; j<(int)search.size(); ++j) {
                if ((int)text.size() < i+j || search[j] != text[i+j]) {
                    i += (j == 0 ? 1 : j);
                    break;
                }
            }
            if (j == (int)search.size()) {
                text[i+j-1] = 'a';
                i += j;
            }
        }
        cout << text << endl;
    }

    return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

ll pow_mod(ll a, ll n, ll p)
{
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res*a%p;
        a = a*a%p;
        n >>= 1;
    }
    return res;
}

int main()
{
    ll i,j;
    ll n;
    string x;
    cin >> n >> x;
    ll cnt = 0;
    for(i = 0;i < n;++i){
        if(x.at(i) == '1') ++cnt;
    }
    ll plusspare = 0;
    ll minusspare = 0;
    ll tmp = cnt+1;
    ll beki2 = 1;
    for(i = n-1;i >= 0;--i){
        if(x.at(i) == '1') plusspare += beki2;
        beki2 *= 2;
        beki2 %= tmp;
        plusspare %= tmp;
    }
    tmp -= 2;
    if(tmp == 0) minusspare = 0;
    else{
        beki2 = 1;
        for(i = n-1;i >= 0;--i){
            if(x.at(i) == '1') minusspare += beki2;
            beki2 *= 2;
            beki2 %= tmp;
            minusspare %= tmp;
        }
    }
    for(i = 0;i < n;++i){
        if(x.at(i) == '0'){
            tmp = cnt+1;
            ll spare = plusspare + pow_mod(2ll, n-1-i, tmp);
            ll ans = 0;
            while(spare%tmp){
                spare = spare%tmp;
                ++ans;
                tmp = 0;
                for(j = 0;j < 32;++j){
                    if((1ll << j) & spare) ++tmp;
                }
            }
            ++ans;
            cout << ans << endl;
        }else{
            tmp = cnt-1;
            if(tmp == 0){
                cout << 0 << endl;
                continue;
            }
            ll tmpspare = pow_mod(2ll, n-1-i, tmp);
            ll spare = minusspare + tmp - tmpspare;
            ll ans = 0;
            while(spare%tmp){
                spare = spare%tmp;
                ++ans;
                tmp = 0;
                for(j = 0;j < 32;++j){
                    if((1ll << j) & spare) ++tmp;
                }
            }
            ++ans;
            cout << ans << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3752
#include<iostream>
#include<sstream>
#include<fstream>
#include<cstring>/*The header <string> and
<string.h> does not contain the useful
function 'memset' and 'memcpy'.*/
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<utility>
#include<algorithm>
#include<functional>
#include<ctime>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#define pii pair<int,int>
#define vpii vector<pii>
#define mpii map<pii,bool>
#define pb push_back
#define mp make_pair
using namespace std;
mpii ball;
vpii pos;
int make(int p,int q)
{
	int ans=0;
	for(int i=0;i<pos.size();i++)
		if(!ball[mp(pos[i].first+p,pos[i].second+q)])
			ans++;
	return ans;
}
int main()
{
	int N,ans=1234567890;
	cin>>N;
	while(N--)
	{
		int x,y;
		cin>>x>>y;
		pos.pb(mp(x,y));
		ball[mp(x,y)]=true;
	}
	if(pos.size()==1)
	{
		cout<<1<<endl;
		return 0;
	}
	sort(pos.begin(),pos.end());
	for(int i=0;i<pos.size();i++)
		for(int j=0;j<i;j++)
		{
			pii a=pos[j],b=pos[i];
			int pp=a.first-b.first,qq=a.second-b.second;
			ans=min(ans,make(pp,qq));
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int N = 200005;

int n;
string a;

int main() {
  cin >> a;
  n = a.size();
  long long ans = 0;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (i < n - 1 && a[i] == 'B' && a[i + 1] == 'C') {
      ans += cnt;
      i++;
      continue;
    }
    if (a[i] == 'A') {
      cnt++;
    } else cnt = 0;
    //cout << i << " " << cnt << " " << ans << endl;
  }
  cout << ans << endl;
  return 0;
}


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

#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define endl '\n'
// #define int long long

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int r, D, x;
int32_t main()
{
	IOS
	//freopen("input.txt", "r", stdin);
	cin >> r >> D >> x;
	for(int i=1; i<=10; i++){
		x = r*x - D;
		cout << x << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
s = gets.chomp!
s.reverse!

sl = ["dream", "dreamer", "erase", "eraser"]
sl.each { |st| st.reverse! }

while !s.empty? do
  fl = false
  sl.each do |st|
    if s[0...st.length] == st
      s.slice!(0...st.length)
      fl = true
    end
  end
  break if(!fl) 
end

puts "YES" if fl
puts "NO" unless fl


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

using namespace std;



int main()
{
	int a, b;
	cin >> a >> b;
	if ((a*b) % 2 == 0) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
N = int(input())
F = [list(map(int,input().split())) for i in range(N)]
P = [list(map(int,input().split())) for i in range(N)]

ans = -int(1e09)
for i in range(1,1 << 10):
    m = [0] * N
    for j in range(10):
        if(i >> j & 1):
            for k in range(N):
                if F[k][j] == 1:
                    m[k] += 1
    l = 0
    for j in range(N):
        l += P[j][m[j]]
    ans = max(ans,l)
print(ans)

Measured memory_bytes: 42224
n = int(input())
ls = [list(map(int, input().split())) for i in range(n)]

ls2 = list()

for i in range(n):
    ls2.append([ls[i][0]-ls[i][1], ls[i][0]+ls[i][1]])

ls2.sort(key=lambda x:x[1])

idx=ls2[0][0]
ans=0

for i in range(n):
    if idx<=ls2[i][0]:
        idx=ls2[i][1]
        ans+=1

print(ans)

Measured memory_bytes: 78040
def main():
    s = input().rstrip()
    N, W, S, E = 0, 0, 0, 0
    for c in s:
        if c == "N":
            N += 1
        if c == "W":
            W += 1
        if c == "S":
            S += 1
        if c == "E":
            E += 1
    if (N==0 and S>0) or (N>0 and S==0) or (W==0 and E>0) or (W>0 and E==0):
        print("No")
    else:
        print("Yes")

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
from math import sqrt
N, D = map(int, input().split())
xlist = [list(map(int, input().split())) for x in range(N)]

cnt = 0
for i in range(N):
	for j in range(i+1, N):
		il = xlist[i]
		jl = xlist[j]
		total = 0
		for n in range(D):
			total = total + (il[n]-jl[n])**2
		
		if sqrt(total).is_integer():
			cnt = cnt + 1

print(cnt)

Measured memory_bytes: 3064
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}


//↑template↑


int n, k[25], l[25], m[25], ans;
int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> k[i];
	}
	for (int i = 0; i < n; ++i) {
		cin >> l[i];
	}
	for (int i = 0; i < n - 1; ++i) {
		cin >> m[i];
	}

	for (int i = 0; i < n; ++i) {
		ans += l[k[i] - 1];
		if (i != 0 && k[i - 1] + 1 == k[i]) { ans += m[k[i - 1] - 1]; }
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String ans = S.replace("dreameraser", "0");
		String ans2 = ans.replace("dreamerase", "0");
		String ans3 = ans2.replace("dreamer", "0");
		String ans4 = ans3.replace("dream", "0");
		String ans5 = ans4.replace("eraser", "0");
		String ans6 = ans5.replace("erase", "0");
		String ans7 = ans6.replace("0", "");
		System.out.println(ans7.equals("") ? "YES" :"NO");
	}
}

Measured memory_bytes: 30928
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        long[] a = Console.ReadLine().Split(' ').Select(se => long.Parse(se)).ToArray();
        long k = long.Parse(s[0]);
        int n = int.Parse(s[1]);
        long[] d = new long[n];
        for (int i = 0; i < n - 1; i++)
            d[i] = a[i + 1] - a[i];
        d[n - 1] = a[0] + k - a[n - 1];
        Console.WriteLine(k - d.Max());
    }
}

Measured memory_bytes: 38132
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int d=max({a,b,c});
  if((a+b+c)%2==3*d%2) {
    cout << (3*d-a-b-c)/2 << endl;
  }
  else {
    cout << (3*d+3-a-b-c)/2 << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt(), B = sc.nextInt(), C = sc.nextInt(), D = sc.nextInt();
		sc.close();
		int min1 = Math.min(A, B), min2 = Math.min(C, D);
		System.out.println(min1 + min2);
	}
}


Measured memory_bytes: 21972