akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
using namespace std;


int main(){
    int N;
    cin >> N;
    char S[4000];
    scanf("%s", S);
    long long count_r = 0, count_g = 0, count_b = 0;

    for(int i = 0; i < N; i ++){
        if(S[i] == 'R'){
            count_r++; 
        }
        else if(S[i] == 'G'){
            count_g++; 
        }
        else if(S[i] == 'B'){
            count_b++; 
        }
    }
    //printf("cpunt_r %d\n", count_r);
    //printf("cpunt_g %d\n", count_g);
    //printf("cpunt_b %d\n", count_b);

    long long count = 0;
   //int j;

    for(int i = 0; i < N; i++){
        for(int j = 1; i + 2 * j < N; j++){
            if(S[i] != S[i + j] and S[i + j] != S[i + 2 * j] and S[i + 2 * j] != S[i]){
                count++;
            }
        }
    }

    //printf("count %d\n", count);

    //printf("%d\n", count_r*count_g*count_b);

    printf("%lld\n", count_r*count_g*count_b - count);

    return 0;
}

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

using namespace std;

const int MAX = 1e5+10;

int a[MAX], b[MAX], c[MAX], dp[MAX][5];

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    for(int i=1;i<=n;++i)
        cin >> a[i] >> b[i] >> c[i];
    
    dp[1][1] = a[1];
    dp[1][2] = b[1];
    dp[1][3] = c[1];

    for(int i=2;i<=n;++i){
        dp[i][1] = max(dp[i-1][2], dp[i-1][3]) + a[i];
        dp[i][2] = max(dp[i-1][1], dp[i-1][3]) + b[i];
        dp[i][3] = max(dp[i-1][2], dp[i-1][1]) + c[i];
    }

    cout << max(max(dp[n][1], dp[n][2]), dp[n][3]) << '\n';

    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <cstring>
using namespace std;

int main() {
  int n,x;
//  int b = 0;
//  int a[100];
//  long long int x,y;
  cin >> n;
  x = n / 3;

  cout << x <<'\n';
  return 0;
}

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

using namespace std;

typedef long long ll;

ll s[3000][60][2];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, a;
    cin >> n >> a;
    s[0][0][0] = 1;
    s[0][0][1] = 1;
    ll ans = 0;
    int x;
    for (int i = 0; i < n; ++i) {
        cin >> x;
        for (int j = 0; j <= 2500; ++j) {
            for (int k = 0; k <= i; ++k) {
                s[j + x][k + 1][1] += s[j][k][0];
            }
        }
        for (int j = 0; j <= 2500; ++j) {
            for (int k = 0; k <= n; ++k) {
                s[j][k][0] = s[j][k][1];
            }
        }
    }
    for (int k = 1; k <= n; ++k) {
        ans += s[a * k][k][1];
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std; 
bool prime[100009];

int main()
{
    int n = 100007;
    
    for(int i=4; i<=n; i=i+2)
    {
		  prime[i] = 1;
    }
    
    int sq = sqrt(n);
    for(int i=3; i<=sq; i++)
    {
		 if(prime[i] == 0){
			 for(int j=i*i; j<=n; j=j+i)
			 {
				 prime[j] = 1;
		     }
		}
     }
     
     prime[1] = 1;
     int ans[100009];
     ans[0] = 0;
     for(int i=1; i<=n; i++)
     {
		  if(i !=2 && prime[i] == 0 && prime[(i+1)/2] == 0){
			   ans[i] = ans[i-1] +1;
			}
		  else  ans[i] = ans[i-1];
     }
     int q;
     scanf("%d",&q);
     for(int i=1; i<=q; i++)
     {
		 int a,b,pr;
		 scanf("%d %d", &a, &b);
		  if(a !=2 && prime[a] == 0 && prime[(a+1)/2] == 0){
		   pr = ans[b] - ans[a] + 1;
	    }
		 else pr = ans[b] - ans[a];
		 printf("%d\n",pr);
     }
     
     return 0;
     
 }
	
	 


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

int main() {
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    for (int n500 = 0; n500 <= a; ++n500) {
        for (int n100 = 0; n100 <= b; ++n100) {
            for (int n50 = 0; n50 <= c; ++n50) {
                int sum = 500 * n500 + 100 * n100 + 50 * n50;
                if (sum == x) {
                    ++ans;
                }
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string n;
    long long i,s=0,a;
    cin>>n;
    for(i=0;i<n.size();i++)
    {
        a=n[i]-48;
        s+=a;
    }
    cout<<(s%9==0?"Yes":"No")<<endl;
}



Measured memory_bytes: 3724
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (n, p) = readLongList()
    val prime = primeFactor(p)
    var ans = 1L
    for (e in prime) {
        if (e.value >= n) {
            for (i in 0 until e.value / n) ans *= e.key
        }
    }
    out.println(ans)
}

/**
O(n^(1/2)) // n * n <= Long.MAX_VALUE n <= 10^8 or more
if n == 1, return emptyMap
 */
fun primeFactor(n: Long): Map<Long, Long> {
    val factorMap = mutableMapOf<Long, Long>()
    var target = n
    var i = 2L
    while (i * i <= target) {
        while (target % i == 0L) {
            factorMap[i] = factorMap.getOrElse(i) { 0L } + 1L
            target /= i
        }
        i++
    }

    if (target != 1L) { factorMap[target] = 1 }
    return factorMap
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 36524
#include<math.h>

int main(){
        int a, b, h, m;
        double ang, len, lon, shor;
        scanf("%d %d %d %d", &a, &b, &h, &m);
        if(h>=12)
                h-=12;

        shor=h*30+m*0.5;
        lon=m*6;

        ang=fabs(shor-lon);
        ang=ang*M_PI/180;

        //if(ang>(360-ang))
        //      ang=360-ang;

        len=a*a+b*b-2*a*b*cos(ang);

        len=sqrt(len);

        printf("%.20f", len);

        return 0;
}


Measured memory_bytes: 2656
#include <iostream>
using namespace std;
int main(){
int n,m;
cin >>n >>m;
int c=n*(n-1)/2+m*(m-1)/2; //sumC2の計算　->これを奇数・奇数 or 偶数・偶数の通りで割る
cout <<c <<endl;
return 0;
}

Measured memory_bytes: 256
//k_k_dubey_
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define inf 999999999999
#define mx 200005
#define gcd __gcd
#define pb push_back
#define mk make_pair
#define bs binary_search
#define ub upper_bound
#define lb lower_bound
#define endl "\n"
#define vl vector<ll>
#define vs vector<string>
#define non __builtin_popcount
#define ml map<ll, ll> 
#define ms map<string , ll> 
using namespace std;

bool isp[mx];

void sv(){

	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}

ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	//sv();
	
	
	ll n,i,j,a[mx];
	cin>>n;
	map<ll, ll> mp;
	for(i=0 ; i< n;i ++)
	{
	    cin>>a[i];
	    mp[a[i]]++;
	}
	auto it= mp.begin();
	ll ans= 0;
	while(it!= mp.end()){
	    ll kk= it->second - it->first;
	    if(kk<0)
	    ans+= it->second;
	    else
	    ans+= kk;
	    //cout<<kk<<" ";
	    it++;
	}
	cout<<ans;
    return 0;
}























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

int main(){
	
	int i, j;
	
	for(i = 1; i <= 9; i++){
		for(j = 1; j <= 9; j++){
			cout << i << 'x' << j << '='<< i*j << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1116
#include <iostream>
#include <iomanip>
#include <cmath>

#define MAX_SIZE (1000)
#define MAX_SET  (1000)

using namespace std;

int main()
{
    int n;
    int size;
          
    double* alpha = new double[MAX_SIZE + 1];
    
    for (int i = 0; i < MAX_SIZE + 1; i++) {      
         do {
             cin >> n;
         } while (n > MAX_SET);
         
         if (n == 0) {
             size = i;
	     break;
         } else {      
             int* s = new int[n];       	    
             int  sum = 0;
             int  sum_sq = 0;

	     for (int j = 0; j < n; j++) {
	          do {
	              cin >> s[j];
		  } while (s[j] < 0 || s[j] > 100);
            
                  sum += s[j];
                  sum_sq += s[j] * s[j];                  
             }

             alpha[i] = sqrt((double)sum_sq / n - pow((double)sum / n, 2));
             
             delete[] s;       
          }                  
    }
  
    for (int i = 0; i < size; i++) {
         cout << fixed << setprecision(8) << alpha[i] << endl;         
    }

    delete[] alpha;
    
    return (0);
}

Measured memory_bytes: 1272
#include <vector>
#include <cstdio>
#include <algorithm>
using namespace std;


int main(int argc, const char * argv[]) {
    
    int k;
    vector<int> v(3);
    
    scanf("%d %d %d %d",&v[0],&v[1],&v[2],&k);
    
    sort(v.begin(),v.end());
    
    for(int i=0;i<k;i++) v[2] *=2;
    
    printf("%d\n",v[0]+v[1]+v[2]);
    
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

template <typename T>
bool MinPlace(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool MaxPlace(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename Container>
int SZ(const Container& S) { return S.size(); }

template <typename S, typename T>
ostream& operator <<(ostream& out, const pair<S, T>& p) {
    out << "{" << p.first << ", " << p.second << "}";
    return out;
}

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        out << v[i];
        if (i != (int)v.size()-1) out << ", ";
    }
    out << "]";
    return out;
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg_var(x) clog << #x  << ": " << x << endl;
    #define dbg_array(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg_var(x)
    #define dbg_array(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////

const int MAXN = 100100;
int N;
LL C;
LL xx[2][MAXN];
LL vv[2][MAXN];
LL val[2][MAXN];
LL pref[2][MAXN]; // ESCLUSO!

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!

    cin >> N >> C;
    for (int i = 0; i < N; i++) {
        cin >> xx[0][i] >> vv[0][i];
        vv[1][N-1-i] = vv[0][i];
        xx[1][N-1-i] = C-xx[0][i];
    }

    for (int it = 0; it < 2; it++) {
        val[it][0] = vv[it][0]-xx[it][0];
        pref[it][0] = 0;
        pref[it][1] = max(0ll, val[it][0]);
        for (int i = 1; i < N; i++) {
            val[it][i] = vv[it][i]-(xx[it][i]-xx[it][i-1]) + val[it][i-1];
            pref[it][i+1] = max(pref[it][i], val[it][i]);
        }
    }

    LL res = 0;
    for (int it = 0; it < 2; it++) {
        for (int i = 0; i < N; i++) {
            res = max(res, val[it][i]);
            res = max(res, val[it][i] - xx[it][i] + pref[it^1][N-1-i]);
        }
    }
    cout << res << "\n";
}



Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
const int pi=3.1415926535897932384626433832795;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};
#define ll long long
#define inf int(1e9+7)
#define pb push_back
#define mp make_pair
char ch[100005];
char ans[100005];
char tmp;
bool flag;
int n;
int main()
{
    scanf("%d%s",&n,&ch);
    for(int i=0;i<4;i++)
    {
        if(i/2==0)
            ans[0]='S';
        else
            ans[0]='W';
        if(i%2==0)
            ans[1]='S';
        else
            ans[1]='W';
        for(int j=2;j<n;j++)
        {
            tmp=ch[j-1];
            if(ans[j-1]=='W')
                tmp='o'+'x'-tmp;
            if(tmp=='o')
                ans[j]=ans[j-2];
            else
                ans[j]='S'+'W'-ans[j-2];
        }
        if(ans[n-2]==ans[0])
            tmp='o';
        else
            tmp='x';
        if(ans[n-1]=='W')
            tmp='o'+'x'-tmp;
        if(tmp!=ch[n-1])
            continue;
        if(ans[n-1]==ans[1])
            tmp='o';
        else
            tmp='x';
        if(ans[0]=='W')
            tmp='o'+'x'-tmp;
        if(tmp!=ch[0])
            continue;
        flag=1;
        break;
    }
    puts((!flag?"-1":ans));
    return 0;
}

Measured memory_bytes: 512
from collections import deque

n,m = map(int,input().split())
to = [[] for _ in range(n)]

for i in range(m):
    x, y = map(int,input().split())
    to[x-1].append(y-1)
    to[y-1].append(x-1)

INF = float('inf')
dist = [INF]*n
dist[0] = 0

pre = [-1]*n

que = deque([])
que.append(0)

while que:
    v = que.popleft()
    for u in to[v]:
        if dist[u] != INF:continue
        dist[u] = v + 1
        pre[u] = v
        que.append(u)
print("Yes")
for i in range(1,n):
    print(dist[i])

Measured memory_bytes: 37744
#include<iostream>
#include<unordered_map>

int main(){
  std::unordered_map<long long,long long> counter;
  std::string line;
  int tmp = 0;
  getline(std::cin,line);
  for(int i=0;i<(int)line.size();i++){
    tmp += ((line[i]=='(')?+1:-1);
    if(tmp)counter[tmp]++;
  }
  long long ans = 0;
  for(std::pair<long long,long long> iter : counter)ans += (iter.second*(iter.second-1))/2;
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 3232
#include<stdio.h>


int main(){
 double a;
 double A[11];
 double sum;
 int i;

 while(scanf("%lf",&a)!=EOF){

   sum=a;
   A[1]=a;
   for(i=2;i<=10;i++){

     if(i%2==0)
       A[i]=A[i-1]*2;
     else
       A[i]=A[i-1]/3;

     sum+=A[i];

   }

   printf("%lf\n",sum);

 }

return 0;
}


Measured memory_bytes: 2032
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,m,k = na()
a = na()
b = na()
aa = [0]
bb = [0]

for i in a:
    aa.append(aa[-1]+i)
for i in b:
    bb.append(bb[-1]+i)

import bisect
ans = 0
for i in range(n+1):
    if aa[i] > k:
        break
    kk = k-aa[i]
    ans = max(ans, i+bisect.bisect_right(bb,kk)-1)

print(ans)

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

using LL = long long;

#define ALL(a) begin((a)), end((a))
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); (i)--)
#define debug(x) cout << #x << " : " << x << '\n'

const int INF = 1e9;

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

  int ans;
  int A, B;
  cin >> A >> B;

  if (A >= 13) {
    ans = B;
  } else if (A >= 6) {
    ans = B / 2;
  } else {
    ans = 0;
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Map<String, Integer> map = new HashMap<>();
        map.put("A", 10);
        map.put("B", 11);
        map.put("C", 12);
        map.put("D", 13);
        map.put("E", 14);
        map.put("F", 15);
        String x = sc.next();
        String y = sc.next();

        if(map.get(x) > map.get(y)){
            System.out.println(">");
        } else if(map.get(x) == map.get(y)){
            System.out.println("=");
        } else {
            System.out.println("<");
        }
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }
}


Measured memory_bytes: 21716
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    auto dp = new long[][](100 + 1, (10 ^^ 5) * 2 + 1);
    long N, W;
    scan(N, W);
    auto w = new long[](100 + 1);
    auto v = new long[](100 + 1);
    foreach (i; 0 .. N)
        scan(w[i], v[i]);

    dp[0][] = long.max / 2;
    dp[0][0] = 0;

    foreach (n; 0 .. N)
    {
        dp[n + 1][] = long.max / 2;
        foreach (val; 0 .. 10 ^^ 5 + 1)
        {
            dp[n + 1][val].minAssign(dp[n][val]);
            // writeln(v[n]);
            dp[n + 1][val + v[n]].minAssign(dp[n][val] + w[n]);
        }
    }

    foreach_reverse (i, val; dp[N])
    {
        if (val <= W)
        {
            writeln(i);
            return;
        }
    }

}


Measured memory_bytes: 162940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
ll n,x,ans=LLONG_MAX;
std::vector<ll> xi;
int main(){
  cin >> n >> x;
  xi.resize(n);
  for (size_t i = 0; i < n; i++) {
    cin >> xi[i];
    if(ans > abs(xi[i]-x)) ans = abs(xi[i]-x);
  }
  sort(all(xi));
  for (size_t i = 0; i < n-1; i++) {
    ans = gcd(ans , (xi[i+1] - xi[i]));
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
"""
https://atcoder.jp/contests/abc136/tasks/abc136_b
"""

import math

import numpy as np


def calc(N: int) -> int:
    if N == 0:
        return 0

    keta_suu = calc_ketasuu(N)

    # Nが奇数桁ならその桁の分を考慮
    max_keta_count = N - 10 ** (keta_suu - 1) + 1 if is_odd(keta_suu) else 0

    # i 桁
    other_keta_count = 0
    for keta in range(keta_suu):
        if not is_odd(keta):
            continue
        other_keta_count += 10 ** keta - 10 ** (keta - 1)

    return max_keta_count + other_keta_count


def calc_ketasuu(value: int) -> int:
    return int(math.log10(value) + 1)


def is_odd(value: int) -> bool:
    return value % 2 == 1


def load_input_as_int_array() -> np.ndarray:
    return np.array([int(v) for v in input().split(" ")])


def main() -> None:
    N, = load_input_as_int_array()
    result = calc(N)
    print(result)


main()


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;
const ll MOD = 1000000007;

int main(){
  int N;
  cin >> N;

  int p[1001] = {0};
  p[0] = p[1] = 1;
  for(int i = 2; i <= 1000; ++i) {
    for(int j = 2; i * j <= 1000; ++j) {
      p[i * j] = 1;
    }
  }
  vector<int> prime;
  REP(i,1001) if(!p[i]) prime.push_back(i);

  ll res = 1LL;
  REP(i,prime.size()) {
    int cnt = 1;
    int tmp = prime[i];
    while(N / tmp > 0) {
      cnt += N / tmp;
      tmp *= prime[i];
    }
    res = res * (cnt % MOD) % MOD;
  }
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
#define rep(i,x) for(ll i = 0;i<x;i++)
#define REP(i,x) for(ll i = 1;i<=x;i++)
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << "\n"
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const dou pi = 3.14159265358;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T, class U> inline bool chmin(T& a, const U& b){ if(a > b){ a = b; return 1; } return 0; }
template<class T, class U> inline bool chmax(T& a, const U& b){ if(a < b){ a = b; return 1; } return 0; }
template<class T, class U> inline bool change(T& a,U& b){if(a > b){swap(a,b);return 1;}return 0;}
//0の場合のアレンジに注意
template<class T>
T gcd(T a,T b){
    if(a == 0)return b;
    else if(b == 0)return a;
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
template<class T>
T lcm(T a,T b){
    return a / gcd(a,b) * b;
}

//素数判定O(sqrt(N))
template<class T>
inline bool isp(T n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
vector<ll> fac(cmax),finv(cmax),inv(cmax);

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if(fac[0] == 0)COMinit();
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logm)
ll modpow(ll n,ll m,ll MOD){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}
ll mypow(ll n,ll m){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n);
        m >>= 1;
        n *= n;
    }
    return res;
}
template<class T = ll>
T in(){T x;cin >> x;return x;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll N = in();
    if(N % 2 == 0){
        cout << "-1\n";
        return 0;
    }
    if(N % 5 == 0){
        cout << "-1\n";
        return 0;
    }
    else{
        ll cnt = 1;
        ll amari = 7 % N;
        while(amari){
            amari *= 10;
            amari += 7;
            amari %= N;
            cnt++;
        }
        cout << cnt << "\n";
    }
}

Measured memory_bytes: 26604
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define break break
#define continue continue
#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
#define vint vector<int>
#define vll vector<ll>
typedef long long ll;

using namespace std;


int main(void){
	ll a, b, q; cin >> a >> b >> q;
	vll s(a);
	rep(i, a) cin >> s[i];
	vll t(b);
	rep(i, b) cin >> t[i];
	rep(_, q){
		ll x; cin >> x;
		ll ls=0, rs=0, lt=0, rt=0;
		if(x < s[0]){
			ls = -1; rs = s[0];
		}
		if(s[a-1] < x){
			rs = -1;
			ls = s[a-1];
		}
		if(x < t[0]){
			lt = -1;
			rt = t[0];
		}
		if(t[b-1] < x){
			rt = -1;
			lt = t[b-1];
		}

		if(ls != -1 && rs != -1){
			ll left = 0, right = a-1;
			while(right-left != 1){
				ll mid = (left+right)/2;
				if(s[mid] == x){
					ls = x;
					rs = x;
					break;
				}
				if(s[mid] > x) right = mid;
				else left = mid;
			}
			ls = s[left];
			rs = s[right];
		}

		if(lt != -1 && rt != -1){
			ll left = 0, right = b-1;
			while(right-left != 1){
				ll mid = (left+right)/2;
				if(t[mid] == x){
					lt = x;
					rt = x;
					break;
				}
				if(t[mid] > x) right = mid;
				else left = mid;
			}
			lt = t[left];
			rt = t[right];
		}

	
		if(ls == -1) ls = 1e12;
		if(rs == -1) rs = 1e12;
		if(lt == -1) lt = 1e12;
		if(rt == -1) rt = 1e12;
		
		ls = abs(ls-x);
		rs = abs(rs-x);
		lt = abs(lt-x);
		rt = abs(rt-x);
		ll ans = max(ls, lt);
		ans = min(ans, max(rs, rt));
		ans = min(ans, rs*2+lt);
		ans = min(ans, ls*2+rt);
		ans = min(ans, rt*2+ls);
		ans = min(ans, lt*2+rs);
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
struct revran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { --i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr revran(const i64 e) noexcept: b(0), e(e) {}
  constexpr revran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(e - 1); }
  constexpr iter end() const noexcept { return iter(b - 1); }
};

struct ran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { ++i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr ran(const i64 e) noexcept: b(0), e(e) {}
  constexpr ran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(b); }
  constexpr iter end() const noexcept { return iter(e); }
  constexpr revran rev() const noexcept { return revran(b, e); }
};

constexpr ran rin(const i64 e) noexcept { return ran(1, e + 1); }
constexpr ran rin(const i64 b, const i64 e) noexcept { return ran(b, e + 1); }

i64 gcd(i64 a, i64 b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

int main() {
  i64 a, b, c;
  cin >> a >> b >> c;
  i64 g = gcd(a, b);
  cout << a / g * b / g * c << endl;
}




Measured memory_bytes: 3104
#include <cstdio>

using namespace std;
 
int main() {
    int n,m[20],p=0,q=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&m[i]);
        if(m[i]>=q){
            q=m[i];
            p++;
        }
    }
    printf("%d",p);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;


int main() {
  
  int N, M;
  
  while(cin >> N >> M && (N|M)) {
    vector<vector<double> > p(N, vector<double>(N, 0));
      
    for(int i=0; i<N; i++) for(int j=0; j<N; j++) cin >> p[i][j];
      
    vector<vector<double> > dp(M, vector<double>(N, 0));
    for(int i=0; i<N; i++) dp[0][i] = 1.0;
	
    for(int k=1; k<M; k++)
      for(int i=0; i<N; i++)
	for(int j=0; j<N; j++)
	  dp[k][j] = max(dp[k][j], dp[k-1][i]*p[i][j]);
    
    double res = 0.0;
    for(int i=0; i<N; i++) res = max(res, dp[M-1][i]);
    
    printf("%.2f\n", res);
  }  
  
  return 0;
}

Measured memory_bytes: 1360
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;
int dp[1<<17][17];
int INF = 1<<28;
int ts[17][17];
int n;
int tsp(int S, int v) {
	if (dp[S][v] >= 0) {
		return dp[S][v];
	}
	int min = ts[v][0];
	for (int i = 1; i <= n; i++) {
		if (i == v)
			continue;
		if ((S >> i & 1) == 1) {
			min = std::min(min, ts[v][i]);
		}
	}
	if (S == (1 << (n + 1)) - 1) {
		return dp[S][v] = min;
	}
	int res = INF;
	for (int u = 1; u <= n; u++) {
		if ((S & (1 << u)) == 0) {

			res = std::min(res, tsp(S | 1 << u, u) + min);
		}
	}
	return dp[S][v] = res;
}
int main(){

	while (cin >> n) {
		if (n == 0)
			break;
		for (int i = 1; i <= n; i++) {
			for (int j = 0; j <= n; j++) {
				cin >> ts[i][j];
			}
		}
		int min = INF;
		for (int j = 0; j < 1 << (n + 1); j++) {
			memset(dp[j],-1,sizeof(dp[j]));
		}
		for (int i = 1; i <= n; i++) {
			min = std::min(min, tsp(1 | 1 << i, i));
		}
		cout << min<<"\n";
	}
}

Measured memory_bytes: 9864
h, w = map(int, input().split())
s = []
s.append("."*(w+2))
for i in range(h):
    s.append("." + input() + ".")
s.append("."*(w+2))

flag = 1
for i in range(1, h+1):
    for j in range(1, w+1):
        f = 0
        if s[i][j] == "#":
            for x, y in [(0, 1), (1, 0), (-1, 0), (0, -1)]:
                if s[i+x][j+y] == "#":
                    f = 1
            if f == 0:
                flag = 0

if flag == 0:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
/*
	散列函数: h(k) = k mod m 
	双散列函数: H(k) = h(k,i) = (h1(k)+i*h2(k)) mod m 
	形成下标的方法 
	
	H(C)=(cm*b^0+...+c2*b^m-2+c1*b^m-1) mod h
	hash[0]=0;
	hash[i]=hash[i-1]*b+(ULL)(s[i]-'A'+1); //主串的滚动哈希值
	power[0]=0;...power[i]=b^i;
	H(C')==H(C,i+n)-H(C,i)*power[n]; //主串中长n的子串的哈希值	
*/
#define M 1046527
#define NIL (-1)
#define L 14
using namespace std;
char H[M][L];
//char->int 
int getInt(char ch){
	if(ch=='A')	return 1;
	else if(ch=='B')	return 2;
	else if(ch=='C')	return 3;
	else if(ch=='D')	return 4;
	else return 0;
}
//获得散列值 
long long getKey(char str[]){
	long long sum = 0,p = 1,i;
	for(int i=0;i<strlen(str);i++){
		sum += p*getInt(str[i]);
		p*=5;
	}
	return sum;
}
int h1(int key){
	return key % M;
}
int h2(int key){
	return 1+key%(M-1);
}

int find(char str[]){
	long long key,i,h;
	key = getKey(str);
	for(int i=0;;i++){ 
		//双散列函数求下标 
		h = (h1(key)+i*h2(key))%M;
		//判断该下标下的值 
		if(strcmp(H[h],str)==0)
			return 1;
		else if(strlen(H[h])==0)
			return 0;
	}
	return 0;
}
int insert(char str[]){
	long long key,i,h;
	key = getKey(str);
	for(int i=0;;i++){
		h = (h1(key)+i*h2(key))%M;
		if(strcmp(H[h],str)==0)
			return 1;
		else if(strlen(H[h])==0){
			strcpy(H[h],str);
			return 0;
		}	
	}
	return 0;	
}
int main(){
	int i,n,h;
	char str[L],com[9];
	for(int i=0;i<M;i++)
		H[i][0]='\0';
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%s %s",com,str);
		if(com[0]=='i'){
			insert(str);
		}
		else{
			if(find(str))
				cout<<"yes"<<endl;
			else
				cout<<"no"<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 17544
#include<iostream>

int n;
int x;
unsigned long long dp[100][21];

int main()
{
	std::cin >> n;
	
	dp[0][0] = 1;

	for( int i = 1; i != n; ++i )
	{
		std::cin >> x;

		for( int j = 0; j <= 20; ++j )
		{
			if( j + x <= 20 )
				dp[i][j+x] += dp[i-1][j];

			if( j - x >= 0 && i != 1 )
				dp[i][j-x] += dp[i-1][j];
		}
	}

	std::cin >> x;
	std::cout << dp[n-1][x] << std::endl;

	return 0;
}

Measured memory_bytes: 1172
#include <iostream>
#include <stdio.h>
#define PI 3.1415926535898

using namespace std;
int main(int argc, char *argv[])
{
    double r;
    scanf("%lf", &r);
    printf("%lf %lf\n", PI * r * r, 2 * PI * r);

   // double ppi = 214.382199 / (2 * 34.1201);
   //cout << ppi << endl;
    return 0;
}



Measured memory_bytes: 3208
#include <iostream>
using namespace std;
typedef long long LL;
#define MAX 1000000000000000000 
int main(int argc, char* argv[])
{
	LL A,B,C,K;
	cin>>A>>B>>C>>K;
	if (K==0){
		cout<<A-B<<endl;
		return 0;
	}
	if (A==B &&B==C){
		cout<<0<<endl;
		return 0;
	}
	LL aw;
	if (K%2==0){
		aw=A-B;
	}else{
		aw=B-A;
	}
	if (aw>MAX){
		cout<<"Unfair"<<endl;
	}else{
		cout<<aw<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
//https://www.cnblogs.com/Tiw-Air-OAO/p/11736325.html
#include<cstdio>
const int MAXN = 400;
const int MOD = 998244353;
int inv[MAXN + 5];
struct mint{
    int x;
    mint(int _x=0) : x(_x) {}
    friend mint operator + (const mint &a, const mint &b) {return a.x + b.x >= MOD ? a.x + b.x - MOD : a.x + b.x;}
    friend mint operator - (const mint &a, const mint &b) {return a.x - b.x < 0 ? a.x - b.x + MOD : a.x - b.x;}
    friend mint operator * (const mint &a, const mint &b) {return 1LL * a.x * b.x % MOD;}
    friend mint operator / (const mint &a, const int &b) {return a * inv[b];}
};
mint pow_mod(mint b, int p) {
    mint ret = 1;
    while( p ) {
        if( p & 1 ) ret = ret*b;
        b = b*b;
        p >>= 1;
    }
    return ret;
}
void init() {
    inv[1] = 1;
    for(int i=2;i<=MAXN;i++)
        inv[i] = MOD - 1LL*inv[MOD%i]*(MOD/i)%MOD;
}
mint coef[MAXN + 5][MAXN + 5];
int A[MAXN + 5], B[MAXN + 5], N, SA, SB;
void read() {
    scanf("%d", &N);
    for(int i=0;i<N;i++)
        scanf("%d%d", &A[i], &B[i]), SA += A[i], SB += B[i];
}
mint tmp[MAXN + 5][MAXN + 5];
void get() {
    coef[0][0] = 1;
    for(int i=0;i<N;i++) {
        for(int j=0;j<=SA;j++)
            for(int k=0;k<=SB;k++)
                tmp[j][k] = coef[j][k], coef[j][k] = 0;
        mint p = mint(A[i]) / SA, f = MOD - 1;
        for(int l=0;l<B[i];l++,f=f/l*p)
            for(int j=0;j<=SA;j++)
                for(int k=l;k<=SB;k++)
                    coef[j][k] = coef[j][k] + f*tmp[j][k-l];
        for(int j=A[i];j<=SA;j++)
            for(int k=0;k<=SB;k++)
                coef[j][k] = coef[j][k] + tmp[j-A[i]][k];
    }
    for(int i=0;i<=SA;i++)
        for(int j=0;j<=SB;j++)
            coef[i][j] = 0 - coef[i][j];
    coef[SA][0] = coef[SA][0] + 1;
}
int solve() {
    mint ret = 0, f = 1;
    for(int j=0;j<=SB;j++,f=f*j)
        for(int i=0;i<=SA;i++) {
            mint p = mint(i) / SA;
            p = pow_mod(1 - p, MOD - 2 - j);
            ret = ret + coef[i][j]*p*f;
        }
    return ret.x;
}
int main() {
    init(), read(), get();
    printf("%d\n", solve());
}

Measured memory_bytes: 1408
N,M,K = map(int,input().split())

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

###Bをi冊目まで読むのにどれだけ時間がかかるか
P = [0]*M
P[0] = B[0]
for i in range(1,M):
    P[i] = P[i-1] + B[i]

T = K###残り時間
ans = 0
num = M-1
for i in range(N):
    T -= A[i]
    if T < 0:
        break
    while P[num] > T and num >= 0:
        num -= 1
    ans = max(ans,i+num+2)
    #print(i,num,ans)

###Aを1冊も読まない場合
for i in range(M):
    if P[i] <= K:
        ans = max(ans,i+1)
    else:
        break

print(ans)

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

using namespace std;
typedef long long ll;

int n;
ll dp[3010][3010];
int a[3010];
ll f(int l, int r)
{
    if (l == r) return a[l];
    ll &ret = dp[l][r];
    if (~ret) return ret;
    return ret = max(a[l] - f(l+1, r), a[r] - f(l, r-1));
}
int main()
{
    memset(dp, -1, sizeof dp);

    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        scanf("%d", &a[i]);
    printf("%lld\n", f(0, n-1));

    return 0;
}


Measured memory_bytes: 71168
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[0].size()){ cout << m[i][j] << ","; } cout << endl; }}



signed main(){

    int A, B; cin >> A >> B;
    mat d(A, vec(B));
    REP(i, A) readv(d[i]);

    mat c(101, vec(101, 0));
    REP(i, A){
        REP(j, B){
            REP(Nx, 101) REP(Ny, 101){
                c[Nx][Ny] = max(c[Nx][Ny], d[i][j] - (i + 1) * Nx - (j + 1) * Ny);
            }
        }
    }

    REP(i, A){
        REP(j, B){
            int tmp = INF;
            REP(Nx, 101) REP(Ny, 101){
                tmp = min(tmp, (i + 1) * Nx + (j + 1) * Ny + c[Nx][Ny]);
            }
            if(tmp != d[i][j]){
                cout << "Impossible" << endl;
                return 0;
            }
        }
    }

    cout << "Possible" << endl;
    cout << 202 << " " << 200 + 101 * 101 << endl;
    REP(i, 100) cout << i + 1 << " " << i + 2 << " X" << endl;
    REP(i, 100) cout << i + 102 << " " << i + 103 << " Y" << endl;
    REP(Nx, 101) REP(Ny, 101) cout << Nx + 1 << " " << 202 - Ny << " " << c[Nx][Ny] << endl;
    cout << "1 202" << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;



int main(){
    int n;
    cin >> n;
    vector<P> v;
    rep(i, n){
        ll x, y;
        cin >> x >> y;
        v.push_back({x,y});
    }
    long double ans = 0;
    vector<int> p(n);
    rep(i, n) p[i] = i;
    do{
        rep(i, n-1) ans += pow(pow(v[p[i]].first - v[p[i+1]].first, 2) + pow(v[p[i]].second - v[p[i+1]].second, 2), 0.5);
    }while(next_permutation(p.begin(), p.end()));

    rep(i, n) ans /= (i+1);
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


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

int inputAppleInfo(int nApples, deque<int>& apples, int arrayLength){
    for (int i = 0; i < nApples; i++){
        int p;
        cin >> p;
        apples.push_back(p);
    }
    sort( apples.begin(), apples.end(), greater<int>());
    while (apples.size() > arrayLength){
        apples.pop_back();
    }   
    return 0;
}

int main(void)
{
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    deque<int> SelectedRedApple;
    deque<int> SelectedGreenApple;
    deque<int> TransparentApple;
    inputAppleInfo(a, SelectedRedApple, x);
    inputAppleInfo(b, SelectedGreenApple, y);
    inputAppleInfo(c, TransparentApple, c);

    bool isSwap = true;
    while (isSwap && TransparentApple.size() > 0){
        int redMin = SelectedRedApple.back();
        int greenMin = SelectedGreenApple.back();
        int trMax = TransparentApple.front();
        int tmp = trMax;
        if ( (redMin <= greenMin) && (redMin < trMax) ){
            SelectedRedApple.push_front(tmp);
            SelectedRedApple.pop_back();
            TransparentApple.pop_front();
        }
        else if ( (greenMin < redMin) && (greenMin < trMax) ){
            SelectedGreenApple.push_front(tmp);
            SelectedGreenApple.pop_back();
            TransparentApple.pop_front();
        }
        else{
            isSwap = false;
        }
    }
    
    long ans = 0;
    for (auto itr = SelectedRedApple.begin(); itr != SelectedRedApple.end() ; itr++){
        ans += (long) *itr;
    }
    for (auto itr = SelectedGreenApple.begin(); itr != SelectedGreenApple.end() ; itr++){
        ans += (long) *itr;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4696
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	int n;
	cin>>n;
	vector<P> v(n);
	rep(i, n){
		ll x, y;
		cin>>x>>y;
		if(x>y) swap(x, y);
		v[i] = P(x, y);
	}
	sort(all(v));
	ll bl = 1e9, br = 0;
	rep(i, n){
		chmin(bl, v[i].snd);
		chmax(br, v[i].snd);
	}
	ll res = (v[n-1].fst-v[0].fst)*(br-bl);
	ll k = br-v[0].fst;
	ll ar = v[n-1].fst, lb = 1e9;
	rep(i, n-1){
		swap(v[i].fst, v[i].snd);
		chmax(ar, v[i].fst);
		chmin(lb, v[i].fst);
		ll al = min(v[i+1].fst, lb);
		chmin(res, (ar-al)*k);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
using namespace std;
 
int main ()
{
int a, b, c, d ,e, k;cin >> a >> b >> c >> d >> e >> k;
int arr[5] = {a, b, c, d, e};
bool ok = true;
for(int i = 0; i < 5; i++){
  for(int j= i + 1; j < 5;j++){
      if(arr[j] - arr[i] > k){
        ok = false;
      }
  }
}
if(ok){
  cout << "Yay!";
}else{
  cout << ":(";
}
    return 0;
}
// ans = 1 + 1 + - 1 + 

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

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll N, num[2] = {}, L = 0, ans = 1;
string S;
bool isLeft[200000] = {};

ll fact(ll num) {
	if (num == 1) {
		return 1;
	}
	else {
		return (num * fact(num - 1)) % 1000000007;
	}
}

int main() {
	cin >> N;
	cin >> S;
	isLeft[0] = true;
	num[1]++;
	num[0]++;
	for (int i = 1; i < sz(S) - 1; i++) {
		if (S[i - 1] == S[i]) {
			isLeft[i] = !isLeft[i - 1];
		}
		else {
			isLeft[i] = isLeft[i - 1];
		}
		num[isLeft[i]]++;
	}
	if ((S[sz(S) - 2] == S[sz(S) - 1] && !isLeft[sz(S) - 2]) || (S[sz(S) - 2] != S[sz(S) - 1] && isLeft[sz(S) - 2]) || num[0] != num[1] || S[0] == 'W' || S[sz(S) - 1] == 'W') {
		cout << 0 << endl;
		return 0;
	}
	rep(i, sz(S)) {
		if (isLeft[i]) {
			L++;
		}
		else {
			ans *= L;
			ans %= 1000000007;
			L--;
		}
	}
	cout << (ans* fact(N)) % 1000000007 << endl;
	return 0;
}

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

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

    int matrix[9][9];
    rep(i,9)rep(j,9) matrix[i][j] = (i+1)*(j+1);

    bool ok = false;
    rep(i,9)rep(j,9) {
        if (matrix[i][j] == n) ok = true;
    }
    puts(ok?"Yes":"No");

    return 0;
}

Measured memory_bytes: 256
h, w, k = map(int, input().split())
cake = [0]*h

ans = [[0]*w for i in range(h)]

key = True
count = 1

for i in range(h):
    cake = input()
    judge = cake.count("#")
    t = True
    if key and judge == 0:
        continue
    if judge == 0:
        for j in range(w):
            ans[i][j] = ans[i-1][j]
        key = False
        continue
    for j in range(w):
        if cake[j] == "#":
            if t:
                t = False
            else:
                count += 1
            judge -= 1
        ans[i][j] = count
    if key:
        for k in range(i):
            ans[k] = ans[i]
        key = False
    count += 1

for i in range(h):
    for j in range(w):
        if j == w-1:
            print(ans[i][j])
        else:
            print(ans[i][j], end=" ")

Measured memory_bytes: 7376
//https://atcoder.jp/contests/abc134/tasks/abc134_a
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
// clang-format on
int main()
{
    int r;
    cin >> r;
    cout << 3 * pow(r, 2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#define 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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long

#define INF 999999999

using namespace std;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
// input
int n,m;

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

    ll m_case = 1900 * m;
    ll n_case = 100 * (n-m);

    ll ave = pow(2,m);

    cout << (m_case+n_case) * ave << "\n";
}

Measured memory_bytes: 384