akhauriyash/Code-Regression huggingface dataset:
n = int(input())
arr = list(map(int,input().split()))
flag = 0
for i in arr:
    if i%2 == 0:
        if i%3 != 0 and i%5 != 0:
            flag = 1
            break
if flag == 1:
    print("DENIED")
else:
    print("APPROVED")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
    bool end = true;
    while (end){
        int a, b;
        char c;
        cin >> a >> c >> b;
        if (c == '?'){
            end = false;
        }
        else if(c == '+'){
            cout << a+b << endl;
        }
        else if(c == '-'){
            cout << a-b << endl;
        }
        else if(c == '*'){
            cout << a*b << endl;
        }
        else if(c == '/'){
            cout << a/b << endl;
        }
    }
    
}


Measured memory_bytes: 3100
//partially from gfg
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 998244353;
#define dd double
#define vi vector<int>
#define vll vector<ll>
#define forr(i, n) for(ll i=0;i<n;i++)
#define revf(i,n) for(ll i=n-1;i>=0;i--)
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep1(i,b) for(ll i=1;i<=b;i++)
#define inp(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define outp(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" "
#define outp1(a,n) for(ll i=1;i<n;i++)cout<<a[i]<<" "
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (((a)*(b))/gcd((a),(b)))
#define pb push_back
#define mp make_pair
#define mem(x,n) memset(x,n,sizeof(x))
#define BINSC binary_search
#define BITOUT __builtin_popcount
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define test ll t; cin>>t; while(t--)
#define cn cout<<"\n";
ll s[1000001];
void sieveOfEratosthenes(ll N) 
{ 
	// Create a boolean array "prime[0..n]" and 
	// initialize all entries in it as false. 
	vector <bool> prime(N+1, false); 

	// Initializing smallest factor equal to 2 
	// for all the even numbers 
	for (ll i=2; i<=N; i+=2) 
		s[i] = 2; 

	// For odd numbers less then equal to n 
	for (ll i=3; i<=N; i+=2) 
	{ 
		if (prime[i] == false) 
		{ 
			// s(i) for a prime is the number itself 
			s[i] = i; 

			// For all multiples of current prime number 
			for (ll j=i; j*i<=N; j+=2) 
			{ 
				if (prime[i*j] == false) 
				{ 
					prime[i*j] = true; 

					// i is the smallest prime factor for 
					// number "i*j". 
					s[i*j] = i; 
				} 
			} 
		} 
	} 
} 

// Function to generate prime factors and its power 
ll calc(ll N) 
{ 
	// s[i] is going to store smallest prime factor 
	// of i. 
	ll res=1;

	ll curr = s[N]; // Current prime factor of N 
	ll cnt = 1; // Power of current prime factor 

	// Printing prime factors and their powers 
	while (N > 1) 
	{ 
		N /= s[N]; 

		// N is now N/s[N]. If new N als has smallest 
		// prime factor as curr, increment power 
		if (curr == s[N]) 
		{ 
			cnt++; 
			continue; 
		} 

		res*= (cnt+1);

		// Update current prime factor as s[N] and 
		// initializing count as 1. 
		curr = s[N]; 
		cnt = 1; 
	} 
	return res;
}
int main()
{
     ll n;
     cin>>n;
     ll x=0;
     ll N=1000000;
     sieveOfEratosthenes(N);
     forr(i,n)
     {
          ll pro=n-i-1;
          x+=calc(pro);
     }
     cout<<x-1;
}

Measured memory_bytes: 11576
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
   
//#include <x86intrin.h>
#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;

template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, k, a[N], gcd, pref[N], suff[N];
pii b[N];

inline bool check (int x) {
   for (int i = 1; i <= n; i ++) {
      b[i] = {x - (a[i] % x), a[i]};
   }
   sort (b + 1, b + n + 1);
   for (int i = 1; i <= n; i ++) pref[i] = pref[i - 1] + b[i].F;
   for (int i = n; i >= 1; i --) suff[i] = suff[i + 1] + (b[i].S % x);
   for (int i = 1; i <= n; i ++)
      if (pref[i] <= k && pref[i] == suff[i + 1])
         return 1;
   return 0;
}

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n >> k;
   for (int i = 1; i <= n; i ++) cin >> a[i], gcd = __gcd (gcd, a[i]);
   int ans = gcd;
   int sum = accumulate (a + 1, a + n + 1, 0);
   for (int i = 1; i * i <= sum; i ++) {
      if (sum % i == 0) {
         if (check (i)) ans = max (ans, i);
         if (check (sum / i)) ans = max (ans, sum / i);
      }
   }
   cout << ans;
}

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}
                          

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

namespace abc086_b
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine().Split().Aggregate((a,b) => a + b));
            var i = 1;
            while(true){
                var sq = i * i;
                if(sq == n){
                    Console.WriteLine("Yes");
                    break;
                }else if(sq > n){
                    Console.WriteLine("No");
                    break;
                }
                i += 1;
            }
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;

int main(){
    ll N; cin >> N;
    vector<ll> V(N); for(int i = 0; i < N; i++) cin >> V[i];
    ll cnt = 0;
    for(int i = 0; i < N-2; i++){
        for(int j = i+1; j < N-1; j++){
            for(int k = j+1; k < N; k++){
                if(V[i] == V[j] || V[j] == V[k] || V[k] == V[i]) continue;
                ll SUM = V[i]+V[j]+V[k];
                ll MAX = max(V[i], max(V[j], V[k]));
                if(MAX < SUM-MAX) cnt++;

            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3576
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;

struct Z {
  long long st, nd;
  void f(Z a) {
    long long v[4] = {st, nd, a.st, a.nd};
    sort(v, v + 4);
    st = v[3];
    nd = v[2];
  }
};

void zeta(int n, vector<Z> &v) {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < (1 << n); j++)
      if (j & (1 << i))
        v[j].f(v[j ^ (1 << i)]);
}

int main() {
  int n, m;
  cin >> n;
  m = (1 << n);
  vector<long long> v(m);
  for (int i = 0; i < m; i++)
    cin >> v[i];
  vector<Z> z(m);
  for (int i = 0; i < m; i++) {
    z[i].st = v[i];
    z[i].nd = 0;
  }
  zeta(n, z);
  long long bef = z[0].st + z[0].nd;
  for (int i = 1; i < m; i++) {
    bef = max(bef, z[i].st + z[i].nd);
    cout << bef << endl;
  }
  return 0;
}


Measured memory_bytes: 9216
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        int sum=0,i=0,j;
        String t;
        Scanner s = new Scanner(System.in);
        while(true){
            t = s.next();
            if(t.charAt(0) =='0'&&t.length()==1)break;
            for(i=0;i<t.length();i++){
                sum+=t.charAt(i)-'0';
            }
            System.out.println(sum);
            sum = 0;
        }
    }
}


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

int main() {
  int N;
  int y=0;
  cin >> N;
  vector<int> vec(N);
  for (int i=0; i < N; i++) {
    cin >> vec.at(i);
    y += vec.at(i) - 1;
  }

  cout << y << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;


int main(int argc, char *argv[])
{
	int r;

	//input
	cin >> r;


	//calc
	double ans = r * r;


	//ans
	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

signed main() {
    char c;
    cin >> c;

    if(c > 'Z') cout << 'a' << endl;
    else cout << 'A' << endl;

    return 0;
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String n = sc.next();

		if (n.contains("7")) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();

	}
}


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

int main() 
{
	int a[3];
	int t;
	cin >> a[0] >> a[1] >> a[2];
	cin >> t;
	sort(a,a+3);
	while(t--){
		a[2] = a[2] * 2;
	}
	cout << a[0] + a[1] + a[2] <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    ll N;
    cin >> N;
    for(int n = 1; n <= 3500; n++){
        for(int w = 1; w <= 3500; w++){
            if ((4*n*w - N*(n+w)) <= 0) continue;
            if ((N * n * w) % (4*n*w - N*(n+w)) == 0){
                int h = (N * n * w) / (4*n*w - N*(n+w));
                printf("%d %d %d\n", h, n, w);
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3776
N=int(input())
ans=[0]*(N+5)
for i in range(1,100) :
    for j in range(1,100) :
        for k in range(1,100) :
            n=i*i+j*j+k*k+i*j+j*k+k*i
            if N>=n :
                ans[n]+=1

for i in range(1,N+1) :
    print(ans[i])

Measured memory_bytes: 9296
#include <stdio.h>
#include <string.h>


int main(void) {

	int a, b, i;
	char s;

	for (i = 0; i < 1000; i++) {
	scanf("%d %c %d", &a, &s, &b);
	if (s == '+') printf("%d\n", a + b);
	if (s == '-') printf("%d\n", a - b);
	if (s == '/') printf("%d\n", a / b);
	if (s == '*') printf("%d\n", a * b);
	if (s == '?') break;
	}

	return 0;
}

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

int main(){
    int n, m;
    cin >> n;
    vector<int> d(n);
    for(int i = 0; i < n; i++){
        cin >> d[i];
    }
    cin >> m;
    vector<int> t(m);
    for(int i = 0; i < m; i++){
        cin >> t[i];
    }
    sort(d.begin(), d.end());
    sort(t.begin(), t.end());
    int j = 0;
    for(int i = 0; i < n; i++){
        if(j == m){
            break;
        }
        if(d[i] < t[j]){
            continue;
        } else if (d[i] == t[j]) {
            j++;
        } else {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
    return 0;
}

Measured memory_bytes: 4744
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

int main(){
    ll N,goukei = 0;
    cin >> N;

    vector<ll>L(N);

    for(ll i = 0;i < N;i++)
        cin >> L.at(i);

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

    vector<tuple<ll,ll,ll>> ss;
    ll res = 0;

    for(int i = 0;i < N-2;i++){
        for(int j = i + 1;j < N-1;j++){
            for(int k = j + 1;k < N;k++){
                if((L.at(i) == L.at(j)) or (L.at(i) == L.at(k)) or (L.at(j) == L.at(k)))
                    continue;
                else if((L.at(i) + L.at(j)) > L.at(k))
                    res++;
            }
        }
    }


    cout << res << endl;

}





    

Measured memory_bytes: 3636
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var wh=arr.shift();
   if(wh=="0 0")break;
   wh=wh.split(" ").map(Number);
   var w=wh[0];
   var h=wh[1];
   var xy=[0,1,1];
   while(true){
      var ary=arr.shift().split(" ");
      if(ary[0]=="STOP")break;
      else if(ary[0]=="RIGHT"){xy[0]++;if(xy[0]==4)xy[0]=0;}
      else if(ary[0]=="LEFT"){xy[0]--;if(xy[0]==-1)xy[0]=3;}
      else if(ary[0]=="FORWARD"){
         ary[1]=ary[1]-0;
         while(ary[1]--){
            if(xy[0]==0)xy[2]++;
            else if(xy[0]==1)xy[1]++;
            else if(xy[0]==2)xy[2]--;
            else if(xy[0]==3)xy[1]--;
         }
         if(xy[1]<1)xy[1]=1;
         if(xy[2]<1)xy[2]=1;
         if(xy[1]>w)xy[1]=w;
         if(xy[2]>h)xy[2]=h;
      }
      else if(ary[0]=="BACKWARD"){
         ary[1]=ary[1]-0;
         while(ary[1]--){
            if(xy[0]==0)xy[2]--;
            else if(xy[0]==1)xy[1]--;
            else if(xy[0]==2)xy[2]++;
            else if(xy[0]==3)xy[1]++;
         }
         if(xy[1]<1)xy[1]=1;
         if(xy[2]<1)xy[2]=1;
         if(xy[1]>w)xy[1]=w;
         if(xy[2]>h)xy[2]=h;
      }
   }
   xy.shift();
   console.log(xy.join(" "));
}

Measured memory_bytes: 17356
n,q = map(int,input().split())
sl = list(input())

tdl = [list(map(str,input().split())) for _ in range(q)]

def simulate(i):
    if i < 0:
        return 0
    if i > n - 1:
        return 2
    now = sl[i]
    for t, d in tdl:
        if t == now:
            if d == "R":
                i += 1
            else:
                i -= 1
        if i == -1:
            return 0
        if i == n:
            return 2
        now = sl[i]
    return 1
ub = n+1
lb = -2
while True:
    if ub == lb:
        ans = ub
        break
    target = (ub + lb) // 2 + 1
    if simulate(target) == 0:
        lb = target
    else:
        ub = target - 1

ub = n+1
lb = -2
while True:
    if ub == lb:
        ans2 = ub
        break
    target = (ub + lb) // 2
    if simulate(target) == 2:
        ub = target
    else:
        lb = target + 1


print(n-(ans+1+n-ans2))



Measured memory_bytes: 101192
#include <iostream>
#include <string>
#include <cstring>

using namespace std;

int main()
{
	int a,b,kaisei,tukukoma;
	cin>>a>>b;
	kaisei=a*b;
	tukukoma=(a+b)*2;
	cout<<kaisei<<" "<<tukukoma<<endl;
	
}



Measured memory_bytes: 3088
s = gets.chomp
gets.to_i.times do
    cmd = gets.chomp.split
    case cmd[0]
    when "print"
        a, b = cmd[1].to_i, cmd[2].to_i
        puts s[a..b]
    when "reverse"
        a, b = cmd[1].to_i, cmd[2].to_i
        s[a..b] = s[a..b].reverse
    when "replace"
        a, b, r = cmd[1].to_i, cmd[2].to_i, cmd[3]
        s[a..b] = r
    end
end



Measured memory_bytes: 6932
#include<cstdio>
int main() {
	int A, B, K;
	scanf("%d%d%d", &A, &B, &K);
	for(int i=A;i<=B;i++) {
		if( i-A+1 > K ) {
			if( B-i+1 > K )
				i = B-K+1;
		}
		printf("%d\n", i);
	}
}

Measured memory_bytes: 128
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <vector>
#include <list>
using namespace std;
#include <stdio.h>
#include <map> 
#include <algorithm>
#include <functional>
#include <algorithm>
#include <functional>
#include <array>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#include <cstdio>
#include <cinttypes>


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

	int r = 0;
	for (int i = 0; i < N; ++i) {
		double x, y;
		cin >> x >> y;

		if (sqrt(x * x + y * y) <= (double)D) {
			r++;
		}
	}

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

	return 0;
}


Measured memory_bytes: 3256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a1 = sc.nextLine().split(" ").map { it.toInt() }
    val a2 = sc.nextLine().split(" ").map { it.toInt() }
    val a3 = sc.nextLine().split(" ").map { it.toInt() }

    val n = sc.nextInt()

    val b = mutableListOf<Int>()
    for(i in 0 until n){
        b.add(sc.nextInt())
    }

    val c = listOf<List<Int>>(
        a1,
        a2,
        a3,
        listOf(a1[0], a2[0], a3[0]),
        listOf(a1[1], a2[1], a3[1]),
        listOf(a1[2], a2[2], a3[2]),
        listOf(a1[0], a2[1], a3[2]),
        listOf(a1[2], a2[1], a3[0])
    )

    for( c_ in c){
        if(b.containsAll(c_)){
            println("Yes")
            return
        }
    }

    println("No")

}




Measured memory_bytes: 35960
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] ABK = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int A = ABK[0];
            int B = ABK[1];
            int K = ABK[2];
            List<int> list = new List<int>();
            int largeInt = Math.Max(A, B);
            for(int i = largeInt; i >= 1; i--)
            {
                if(A % i == 0 && B % i == 0)
                {
                    list.Add(i);
                }
            }
            Console.WriteLine(list[K - 1]);
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  int n; cin >> n;
  cout << (n - 1) / 2 << endl;
}

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

ans=[-1]*n
flag=True
for s,c in ls:
    if s==1:
        if (c==0 and n>1) or not(ans[s-1]==c or ans[s-1]==-1):
            flag=False
            break
        else:
            ans[s-1]=c
    else:
        if not(ans[s-1]==c or ans[s-1]==-1):
            flag=False
            break
        else:
            ans[s-1]=c

for i in range(n):
    if ans[i]==-1:
        ans[i]=0
        if i==0 and n>1:
            ans[0]=1

if flag:
    print(''.join(map(str,ans)))
else:
    print(-1)





Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define bp  __builtin_popcount
#define pb push_back
#define sz(s) (int)(s.size())

using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
const  double EPS = 1e-14;
const int MOD = 1e9+7;
/*
ll GCD(ll a,ll b){return (a)?GCD(b%a,a):b;}
ll LCM(ll a, ll b){return a*b/GCD(a,b);}
ll fastpow(ll b, ll p)
{if(!p)return 1;ll ret = fastpow(b, p >> 1);ret *= ret;if(p&1)ret*= b;return ret;}

vector<vector<int>>adj(maxn);
queue<int>q;
bool vis[maxn]={0};
int dis[maxn];
int bfs(int n)
{
   vis[n]=true;
   dis[n]=0;
   q.push(n);
   while(!q.empty())
   {
       int s=q.front();
       q.pop();
       for(int i : adj[s])
       {
           if(vis[i])
            continue;
           vis[i]=true;
           dis[i]=dis[s]+1;
           q.push(i);
       }
   }
}
*/

int solve(vector<int>&v)
{
    vector<int>vv=v;
    sort(vv.begin(),vv.end());
    int pos=0;
    while(true)
    {
        pos++;
        if(vv==v)
            return pos;
        next_permutation(vv.begin(),vv.end());
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
   // freopen("in.txt", "r", stdin);
#endif
    int n;
    cin>>n;
    vector<int>a,b;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        a.pb(x);
    }
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        b.pb(x);
    }
    int ans=abs(solve(a)-solve(b));
    cout<<ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> rate(4);
    for (auto& r : rate) {
        cin >> r;
    }
    int ans = 1 << 30;
    rep(mask, 0, 1 << 4) {
        if (__builtin_popcount(mask) != 2) {
            continue;
        }
        int team1 = 0, team2 = 0;
        rep(i, 0, 4) {
            if ((mask >> i) & 1) {
                team1 += rate[i];
            }
            else {
                team2 += rate[i];
            }
        }
        chmin(ans, abs(team1 - team2));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3216
import queue

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))

q = queue.PriorityQueue()
for k in a:
  q.put(k)
  
for _ in range(m):
  q.put(-(-q.get()//2))
  
ans = 0
for _ in range(n):
  ans += q.get()
  
print(-ans)

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

using namespace std;

typedef long long int li;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

vi par,sz,vis,dis;
vector<vi> graph;
vector<vector<pair<li,li>>> wgraph;

void init(li n)
{
    par.resize(n);
    sz.resize(n);
    wgraph.resize(n);
    dis.resize(n);
    vis.resize(n);
    graph.resize(n);

    f(i,0,n-1)
    {
        par[i]=i;
        sz[i]=1;
        dis[i]=1e18;
    }
}

li root(li a)
{
    while(a!=par[a])
    {
        par[a]=par[par[a]];
        a=par[a];
    }

    return a;
}

void unio(li a,li b)
{
    li r_a=root(a);
    li r_b=root(b);

    if(par[r_a]!=r_b)
    { 
        if(sz[r_a]<sz[r_b])
        {
            par[r_a]=par[r_b];
            sz[r_b]+=sz[r_a];
            sz[r_a]=0;
        }
        else
        {
            par[r_b]=par[r_a];
            sz[r_a]+=sz[r_b];
            sz[r_b]=0;
        }
    }
}

int main()
{    
   

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    string s,t;

    cin>>s>>t;

    li a,b;

    cin>>a>>b;

    string u;

    cin>>u;

    if(u==s)
    {
        a--;
    }
    else
        b--;

    cout<<a<<" "<<b;

    return 0;
}

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

typedef long long int ll;

int main()
{
    ll n;cin>>n;
    ll Arr[n+2];
    for(int i=1;i<=n;i++)cin>>Arr[i];

    ll Res = 0,now = 0;
    map<ll,ll>M;
    map<ll,ll>::iterator it;
    M[0]++;
    for(int i=n;i>=1;i--)
    {
        now += Arr[i];
        M[ now ]++;
    }
    for( it=M.begin();it!=M.end();it++ )
    {
        ll s = (it)->second;
        Res += ( s*(s-1)/2 );
    }
    cout<<Res<< "\n";


    return 0;
}


Measured memory_bytes: 14336
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include "bits/stdc++.h"
#include <random>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,n) for(int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for(int i=(a)-1;i>=b;--i)
#define range(i,a,b,c) for(int i=a;\
                    c>0?i<b:\
                    i>b;\
                    i+=c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define int long long
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif
 
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 1 << 28;
const ll INFL = (ll)1 << 58;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real& r) { return (r > eps) - (r < -eps); }
int sgn(const Real& a, const Real &b) { return sgn(a - b); }
 
//.....................
const int MAX = (int)2e5 + 5;
 
vector<string> split(const string &str, char sep) {
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}
 
template<class InputIterator>
int sum(InputIterator begin, InputIterator end) {
	return accumulate(begin, end, 0ll);
}

int N;
int a[MAX];

void solve() {
	cin >> N;
	int even = 0;
	int odd = 0;
	rep(i, N) {
		cin >> a[i];
		if (a[i] % 2 == 0) even++;
		else odd++;
	}
	while (odd >= 2) {
		odd -= 2;
		even++;
	}
	while (even >= 2) {
		even--;
	}
	if (odd + even == 1) cout << "YES" << endl;
	else cout << "NO" << endl;
}

signed main() {
	cout << fixed << setprecision(20);
	while(true) {
		char s[MAX];
		if (scanf("%s", s) == EOF) break;
		int n = strlen(s);
		for (int i = n - 1; i > -1; i--) {
			ungetc(s[i], stdin);
		}
		solve();
	}
	return 0;
}


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

int main(){
    int x1, x2, x3, x4, y1, y2, y3, y4;
    cin >> x1 >> y1 >> x2 >> y2;
    x3 = x2 + (y1-y2);
    y3 = y2 + (-x1+x2);
    x4 = x1 + (y1-y2);
    y4 = y1 + (-x1+x2);
    cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
    return 0;
}

Measured memory_bytes: 3640
# coding: utf-8
# Your code here!

s = input().split()
n=int(s[0])
k=int(s[1])

ct = 0
ans = 0.0

for i in range(1,n+1):
    pt=i;
    while pt <= k-1:
        pt=pt*2;
        ct+=1
    ans+= 1.0/n * pow(0.5, ct)
    ct=0
    
print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<string>

void solve_A() {
	int S, W;
	std::cin >> S >> W;
	//std::string result = (S <= W ? "unsafe" : "safe");
	std::cout << (S <= W ? "unsafe" : "safe") << std::endl;
}

void solve_B() {
	int A, B, C, D;
	std::cin >> A >> B >> C >> D;
	while (!( A <= 0 || C <= 0)) {
		C -= B;
		if (C <= 0) break;
		A -= D;
	}
	std::cout << (A <= 0 ? "No" : "Yes") << std::endl;
}

#include<vector>
#include<algorithm>

void solve_C() {
	int N;
	std::vector<std::string> v;
	std::cin >> N;
	for (int i = 0; i < N; i++) {
		std::string tmp;
		std::cin >> tmp;
		v.push_back(tmp);
	}
	std::sort(v.begin(), v.end());
	auto last = std::unique(v.begin(), v.end());
	v.erase(last, v.end());
	std::cout << v.size() << std::endl;

}

#include<set>

void solve_C2() {
	int N;
	std::set<std::string> st;
	std::cin >> N;
	for (int i = 0; i < N; i++) {
		std::string s;
		std::cin >> s;
		st.insert(s);
	}
	std::cout << st.size() << std::endl;
}

void solve_D() {//TLE
	std::string S;
	std::cin >> S;
	int N = S.length();
	int ans = 0;
	for (int i = 0; i < N-3; i++) {
		for (int j = i+3; j < N; j++) {
			int num = atoi(S.substr(i, j - i+1).c_str());
			if (num % 2019 == 0) {
				ans++;
			}
		}
	}
	std::cout << ans << std::endl;
}

void solve_D2() {
	std::string s;
	std::cin >> s;
	int n = s.size();
	std::reverse(s.begin(), s.end());
	int x = 1, ans = 0, total = 0;//累積和
	const int m = 2019;
	std::vector<int> cnt(m);
	for (int i = 0; i < n; i++) {
		cnt[total]++;
		total += atoi(s.substr(i, 1).c_str()) * x;
		total %= m;
		ans += cnt[total];
		x = x * 10 % m;
	}
	std::cout << ans << std::endl;
}

int main()
{
	//solve_A();
	//solve_B();
	//solve_C();
	solve_D2();
    return 0;
}


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

long long a, b, mn = 1e9;
int main() {
	long long i, j;
	cin>>a>>b;
	if(a/2019 == b/2019) {
		for(i=a; i<=b; i++) for(j=i+1; j<=b; j++) mn = min(mn, i * j % 2019);
	} else mn = 0;
	cout<<mn;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
   int a,b,i,j;
   while(1){
   scanf("%d %d", &a, &b);
   if(a == 0 && b == 0)
    break;
   for(i = 0; i < a; i++){
       for(j = 0; j < b; j++)
       {

        printf("#");
       }
       printf("\n");
   }
   printf("\n");

   }
   return 0;
}


Measured memory_bytes: 2032
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	int a, b, x;
	cin >> a >> b;
	if((a + b) % 2 == 0){
		x = (a + b) / 2;
	}
	else{
		x = (a + b) / 2 + 1;
	}
	cout << x << endl;
	return 0;
}

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

int main() {
  int N;
  
  cin >> N;
  
  vector<int> a(N+2, 0);
  for (int i = 0; i < N; i++) cin >> a[i];
  
  vector<ll> s(N+2, 0);
  map<ll, ll> nums;
  
  nums[0]++;
  for (int i = 0; i < N; i++) {
    s[i+1] = s[i] + a[i];
    nums[s[i+1]]++;
  }

  ll res = 0;
  for (auto it : nums) {
    ll num = it.second;
    res += num * (num -1) / 2;    
  }
  cout << res << endl;
  
  
  
  
    

}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr double INF{1e9};
constexpr int MAGIC_PRIME{1000000000 + 7};
constexpr array<int, 4> dy{-1, 1, 0, 0};
constexpr array<int, 4> dx{0, 0, -1, 1};
constexpr int div_ru(int a, int b)
{
    return (a - b + 1) / b;
}
ll pow_mod(ll b, ll e, ll m)
{ // https://atcoder.jp/contests/atc002/tasks/atc002_b
    ll r = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            r = (r * b) % m;
        b = (b * b) % m;
    }
    return r;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;
    s[k - 1] -= 'A' - 'a';

    cout << s << endl;
}
// 　　　　　　_......_
// 　　　　 , ´　 <＊y　♪
// 　　　　 i,（i ﾉﾉﾊ）_）
// 　　　　ﾉ_iﾊﾟ ヮﾟﾉﾊ
// 　　　 　 ,´i'_ｿﾉj,〈つ　))
// 　　　　〈_,ﾉ＾＾＾ヽ.´
// 　　　　 .＾＾i_ｿ_ｿ^´
// 　　　　 ￣￣ ￣　
// vector<vector<int>> mm(h, vector<int>(w, -1));


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pi pair<ll, ll>
#define mp make_pair
#define pb push_back
#define vi vector<ll>
#define pd pair<double, double>
#define vp vector<pi>
#define f(i, n) for(int i = 0; i < n; i++)
#define fo(i, a, n) for(int i = a; i < n; i++)
#define mod (1000*1000*1000+7)
#define sz(x) int((x).size())
#define all(x) x.begin(),x.end()
#define DBG(v) cerr << #v << " = " << (v) << endl;
ll INF = (1ll<<61);

using namespace std;

int main(int argc, char* argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll a, b; cin >> a >> b;
    cout << a * b / __gcd(a, b) << endl;;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
const int INF_INT = 2147483647;
const long long INF_LONG = 9223372036854775807;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
     
int main() {
  ll n, m, k, ans=0;  cin >> n >> m >> k;
  vector<ll> a(n), sa(n, 0), b(m), sb(m, 0);
  rep (i, n) cin >> a[i];
  rep (i, m) cin >> b[i];

  sa[0] = a[0];  sb[0] = b[0];
  for (int i=1; i<n; ++i) sa[i] = sa[i-1] + a[i];
  for (int i=1; i<m; ++i) sb[i] = sb[i-1] + b[i];

  rep (i, n) {
    ll count, t = k - sa[i];
    if (t < 0) continue;
    auto itr = upper_bound(sb.begin(), sb.end(), t);
    count = itr - sb.begin();
    if (ans < i + 1 + count) ans = i + 1 + count;
  }

  auto itr = upper_bound(sb.begin(), sb.end(), k);
  ll count = itr - sb.begin();
  if (ans < count) ans = count;

  cout << ans << endl;
}

Measured memory_bytes: 9560
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    string s = "Christmas";
    while(d < 25){
        s += " Eve";
        ++ d;
    }
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
use std::cmp;

const INF: i64 = std::i64::MAX;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let w: usize = sc.read();
    let p: Vec<i64> = sc.vec(n);
    let mut graph = vec![vec![]; n];
    for _ in 1..n {
        let u = sc.read::<usize>() - 1;
        let v = sc.read::<usize>() - 1;
        let cost = sc.read::<usize>();
        graph[u].push((v, cost));
        graph[v].push((u, cost));
    }

    let mut tree = vec![vec![]; n];
    tree_dfs(0, 0, &graph, &mut tree);

    let mut ans = -INF;
    for i in 0..n {
        let mut state = vec![-INF; w + 1];
        state[0] = 0;
        let state = rec_dp(i, &state, &tree, w, &p);
        ans = cmp::max(ans, state.into_iter().max().unwrap());
    }
    println!("{}", ans);
}

fn tree_dfs(
    v: usize,
    p: usize,
    graph: &Vec<Vec<(usize, usize)>>,
    tree: &mut Vec<Vec<(usize, usize)>>,
) {
    for &(next, cost) in graph[v].iter() {
        if next == p {
            continue;
        }
        tree_dfs(next, v, graph, tree);
        tree[v].push((next, cost));
    }
}

fn rec_dp(
    v: usize,
    state: &Vec<i64>,
    tree: &Vec<Vec<(usize, usize)>>,
    w: usize,
    values: &Vec<i64>,
) -> Vec<i64> {
    let mut state = state.clone();
    for &(next, cost) in tree[v].iter() {
        let next_state = rec_dp(next, &state, tree, w, values);
        for i in 0..(w + 1) {
            if i + cost > w {
                break;
            }
            state[i + cost] = cmp::max(next_state[i], state[i + cost]);
        }
    }

    for i in 0..(w + 1) {
        state[i] += values[v];
    }
    state
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}



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

using namespace std;

#define sz(x) (int) x.size()
#define all(a) a.begin(), a.end()

const int MAXN = 55;

int n, m, qn;
int a[MAXN], b[MAXN], c[MAXN], d[MAXN];
int ans = 0;
int val[MAXN];

void go(int pos) {
    if (pos == n) {
        int curScore = 0;
        for (int i = 0; i < qn; i++) 
            if (val[b[i]] - val[a[i]] == c[i])
                curScore += d[i];
        ans = max(ans, curScore);
        return;
    }

    int st = 1;
    if (pos != 0) 
        st = val[pos - 1];

    for (int i = st; i <= m; i++) {
        val[pos] = i;
        go(pos + 1);
    }
}

int main() {

    scanf("%d %d %d", &n, &m, &qn);
    for (int i = 0; i < qn; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }

    go(0);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3800
#include <stdio.h>
#include <stdlib.h>
int main() {
  int n;
  scanf("%d", &n);
  
  int *t = (int *)malloc(sizeof(int) * n);
  
  for (int i = 0; i < n; i++) {
    scanf("%d", &t[i]);
  }
  int m;
  scanf("%d", &m);
  
  int *p = (int *)malloc(sizeof(int) * m);
  int *x = (int *)malloc(sizeof(int) * m);
  for (int i = 0; i < m; i++) {
    scanf("%d", &p[i]);
    scanf("%d", &x[i]);
  }
  
  int *time = (int *)malloc(sizeof(int) * m);
  for (int i = 0; i < m; i++) {
    time[i] = 0;
  }
  
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if((p[i]-1) == j) {
        time[i] += x[i];
        //printf("time : %d\tx[%d] : %d\n", time[i], i, x[i]);
      }
      else {
        time[i] += t[j];
        //printf("time : %d\tt[%d] : %d\n", time[i], j, t[j]);
      }
    }
  }
  
  for (int i = 0; i < m; i++) {
    printf("%d\n", time[i]);
  }
    
  free(t);
  free(p);
  free(x);
  
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int n, A[50];

int solve (int i, int m){
   if(m==0) return 1;
   if(i>=n) return 0;
   int R = solve(i+1, m) || solve(i+1,m-A[i]);
   return R;
}

int main(){
   int q, k, i;
   scanf("%d", &n);
   for(i=0;i<n;i++)
      scanf("%d", &A[i]);
   scanf("%d", &q);
   for(i=0;i<q;i++){
      scanf("%d", &k);
      if(solve(0, k))
      printf("yes\n");
      else printf("no\n");
}

 return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	cin>>s;
	if(s=="ARC")
	{
		cout<<"ABC"<<endl;
	}
	if(s=="ABC")
	{
		cout<<"ARC"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char *argv[])
{
    int x, y;

    std::cin >> x >> y;

    const int kame = (y - 2 * x) / 2;
    const int tsuru = x - kame;

    if (y == 2 * tsuru + 4 * kame && kame >= 0 && tsuru >= 0) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <ctype.h>

int main(void){
	char ch[1201]={0};
	int i=0,j=0;
	int a[26]={0};
	while(gets(ch)!=NULL){
		i = 0;
	while(ch[i] != '\0'){
		j = tolower(ch[i]) - 'a';
		if(0<=j && j<=26) a[j]++;
		i++;
	}
	}
	for(i=0;i<26;i++){
	printf("%c : %d\n",i+'a',a[i]);
	}
	return 0;
}

Measured memory_bytes: 524
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>
#include <bitset>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

ll calc(ll n, ll b){
  if(n < b)return n;
  else return calc((ll)(n / b), b) + (n % b);
}

int main(int argc, char const* argv[])
{
  ll n, s;
  cin >> n >> s;
  if(n == s){
    cout << n + 1 << endl;
    return 0;
  }
  for(ll i = 2; i * i <= n; i++){
    if(s == calc(n, i)){
      cout << i << endl;
      return 0;
    }
  }
  ll res = linf;
  for(ll p = 1; p * p <= n; p++){
    ll q = s - p;
    if((n - q) % p != 0)continue;
    ll b = (n - q) / p;
    if(b > 1 && s == calc(n, b)){
      res = min(res, b);
    }
  }
  if(res == linf)cout << - 1 << endl;
  else cout << res << endl;
	return 0;
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// 出力は.xで！！！！

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

//mintと一緒に使ってね！！
//初期化 combination c(cの左側以上の数字)
//使用　c(x,y) xCy

int main(){
    int x,y; cin >> x >> y;
    int mi=min(x,y); int ma=max(x,y);
    if((mi+ma)%3!=0) cout << 0 << endl;
    else if(mi*2<ma) cout << 0 << endl;
    else{
        mint ans=0;
        combination c(1000000);
        ans=c((ma+mi)/3,(mi-(ma-mi))/3);
        cout << ans.x << endl;
    }
    return 0;
}

Measured memory_bytes: 15872
<?php
# スペース区切りの整数の入力
$n = fgets(STDIN);
$input=explode(' ',trim(fgets(STDIN)));

$value_count = array_count_values($input);
$max = max($value_count);

if ($max === 1) {
    echo 'YES';
} else {
    echo 'NO';
}

echo '
';


Measured memory_bytes: 67300
#include<bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin>>n;
  if(n==7||n==5||n==3){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define ll long long
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define f(i,a,b) for(i=a;i<=b;i++)

using namespace std;

int main() {
   ll a;
   cin>>a;
   
   cout<<a+a*a+a*a*a;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
const int MAX = 100, INF = 1e9, WHITE = 0, GRAY = 1, BLACK = 2;

int n, M[MAX][MAX];

void dijkstra(){
    int minv;
    int d[MAX], color[MAX];
    for (int i = 0; i < n; i++)
    {
        d[i] = INF;
        color[i] = WHITE;
    }
    
    d[0] = 0;
    color[0] = GRAY;
    while (true)
    {
        minv = INF;
        int u = -1;
        for (int i = 0; i < n; i++){
            if (minv > d[i] && color[i] != BLACK){
                u = i;
                minv = d[i];
            }
        }
        if (u == -1) break;
        color[u] = BLACK;
        for (int v = 0; v < n; v++)
        {
            if (color[v] != BLACK && M[u][v] != INF)
            {
                if (d[v] > d[u] + M[u][v])
                {
                    d[v] = d[u] + M[u][v];
                    color[v] = GRAY;
                }   
            }
        }
        
    }
    for (int i = 0; i < n; i++)
    {
        cout << i << " " << (d[i] == INF ? -1 : d[i]) << endl;
    }
    
}

int main(){
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            M[i][j] = INF;
        }
        
    }
    int k, c, u, v;
    for (int i = 0; i < n; i++)
    {
        cin >> u >> k;
        for (int j = 0; j < k; j++)
        {
            cin >> v >> c;
            M[u][v] = c;
        }
        
    }
    dijkstra();
    
}


Measured memory_bytes: 3116
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>
#include<chrono>
#include<random>

#define for0(i, N)    for (long long i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (long long i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (long long i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (long long i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (long long i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (long long i = (x), a = 0; a < (N);    \
                              i = (i + 1) % (N), ++a)
#define int long long

long double constexpr pi = 3.141592653589793;

template<class T>
constexpr T sigma1(T i, T n){
    return (n - i + 1) * (i + n) / 2;
}

template<class T>
constexpr T sigma2(T i, T n){
    return (i == 1 ? n * (n + 1) * (2 * n + 1) / 6 :
            sigma2(1, n) - sigma2(1, i - 1));
}

template<class T>
constexpr T sigma3(T i, T n){
    if (i == 1) {
        auto temp = sigma1(i, n);
        return temp * temp;
    }
    return sigma2(1, n) - sigma2(1, i - 1);
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

long long constexpr inf = std::numeric_limits<long long>::max();

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;


signed main(void){
    cin.tie(0); ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);

    int x, y;
    cin >> x >> y;

    if (y % 2 == 0 && 2 * x <= y && y <= 4 * x) {
        cout << "Yes" << "\n";

    } else {
        cout << "No" << "\n";

    }

    return 0;
}


Measured memory_bytes: 3660