akhauriyash/Code-Regression huggingface dataset:
package main

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

func lib_CountIntAsList(values []int, max int) []int {
	m := make([]int, max, max)
	for _, value := range values {
		m[value]++
	}
	return m
}
func lib_Divisor(n int) (res []int) {
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			res = append(res, i)
			if n/i != i {
				res = append(res, n/i)
			}
		}
	}
	return
}
func lib_Pow10Int(y int) int {
	return int(math.Pow10(int(y)))
}
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int
	scanner.Scan()
	N, _ = strconv.Atoi(scanner.Text())
	A := make([]int, N)
	for i := 0; i < N; i++ {
		scanner.Scan()
		A[i], _ = strconv.Atoi(scanner.Text())
	}
	fmt.Println(solve(N, A))
}
func solve(N int, A []int) (cnt int) {
	aCounts := lib_CountIntAsList(A, lib_Pow10Int(6)+5)
	for _, a := range A {
		if aCounts[a] != 1 {
			continue
		}
		valid := true
		for _, e := range lib_Divisor(a) {
			if aCounts[e] != 0 && e != a {
				valid = false
				break
			}
		}
		if valid {
			cnt++
		}
	}
	return
}


Measured memory_bytes: 21312
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const ll LINF = 1e18;

struct edge{int to,cost;};

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

	int n;
	ll k;
	cin >> n >> k;

	P ab[n];
	for(int i=0;i<n;i++){
		cin >> ab[i].first >> ab[i].second;
	}
	sort(ab,ab+n);
	
	ll sum=0;
	for(int i=0;i<n;i++){
		sum += ab[i].second;
		if(sum >= k){
			cout << ab[i].first << "\n";
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

r, g, b = rm()
n = ri()
c = 0
while r >= g:
    g *= 2
    c += 1
d = 0
while g >= b:
    b *= 2
    d += 1
print('Yes' if c+d <= n else 'No')



















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

using namespace std;

#define int long long

signed main()
{
	string s;
	cin >> s;
	int a = (s[0] - '0') * 10 + s[1] - '0', b = (s[2] - '0') * 10 + s[3] - '0';
	if (a > 12)
	{
		if (b == 0 || b > 12)
			cout << "NA\n";
		else
			cout << "YYMM\n";	 	
	}
	else if (b > 12)
	{
		if (a == 0 || a > 12)
			cout << "NA\n";
		else
			cout << "MMYY\n";
	}
	else
	{
		if (a == 0)
		{
			if (b == 0)
				cout << "NA\n";
			else
				cout << "YYMM\n";		
		}
		else if (b == 0)
			cout << "MMYY\n";
		else
			cout << "AMBIGUOUS\n";
	}

	return 0;	
}

Measured memory_bytes: 256
while True:
    (a, op, b) = [int(i) if i.isdigit() else i for i in input().split()]

    if op == '?':
        break
    elif op =='+':
        print(a+b)
    elif op == '-':
        print(a-b)
    elif op == '*':
        print(a*b)
    elif op == '/':
        print(a//b)
    else :
        break

Measured memory_bytes: 6724
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 100000000;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
const ll MAX = 200010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,c;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> c;
        a[c-1] = i;
    }
    set<ll> b,m;
    b.insert(-1);
    m.insert(1);
    b.insert(n);
    m.insert(-n);
    ll ans = 0;
    rep(i,n){
        ll index = a[i];
        ll l = -*(m.upper_bound(-index));
        ll r = *(b.upper_bound(index));
        ans += (index-l)*(r-index)*(i+1);
        b.insert(index);
        m.insert(-index);
    }
    PRINT(ans);
}


Measured memory_bytes: 20608
function Main(input) {
    input = input.trim().split("\n");
    var N = parseInt(input[0]);
    var SasStr = input[1];
    var ans = 0;
    var x1, x2, x3, xTmp, x1i, x2i, x3i, sTmp;
    for (var i = 1000; i < 2000; i++){
    	xTmp = String(i);
    	x1 = xTmp.substr(1, 1);
    	x2 = xTmp.substr(2, 1);
    	x3 = xTmp.substr(3, 1);
    	x1i = SasStr.indexOf(x1);
    	if (x1i !== -1) { 
    		sTmp = SasStr.substr(x1i + 1);
    		x2i = sTmp.indexOf(x2);
    		if (x2i !== -1) { 
    		sTmp = sTmp.substr(x2i + 1);
    		x3i = sTmp.indexOf(x3);
    			if (x3i !== -1) { 
    				ans ++;
    			}
    		}
    	}	
    }
    console.log(ans);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7864
N = gets.chomp.to_i
A = gets.split

minus = 0

a = A[0].to_i
if a <= 0
  a *= (-1)
  minus += 1
end
minabs = a
sum = a

for x in 1...N
  a = A[x].to_i
  if a <= 1
    a *= (-1)
    minus += 1
  end
  if a < minabs
    minabs = a
  end
  sum += a
end

if minus % 2 == 1
  sum -= minabs * 2
end

puts sum

Measured memory_bytes: 7812
using System;

namespace AizuOnLine
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var data = Console.ReadLine().Split(' ');
                var num1 = Convert.ToInt32(data[0]);
                var num2 = Convert.ToInt32(data[2]);
                var op = data[1];

                if (op == "?") { return; }

                int ans = 0;
                if (op == "+")
                {
                    ans = num1 + num2;
                }
                else if (op == "-")
                {
                    ans = num1 - num2;
                }
                else if (op == "*")
                {
                    ans = num1 * num2;
                }
                else
                {
                    ans = num1 / num2;
                }

                Console.WriteLine(ans);
            }
        }
    }
}

Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    string x;
    cin >> x;
    if (x == "Y"){
      cout << "Four" << endl;
      break;
    }
    if (i == N-1)
      cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int t;cin>>t;while(t--)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define MOD 1000000007
#define ll long long
#define ld long double
#define int ll
#define pb push_back
#define ii pair<int,int>
#define llll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<ii>
#define vllll vector<llll>
#define ff first
#define ss second
#define INF 1000000000
#define HINF 1000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define arrin(x,n) int x[n]; for(int o=0;o<n;o++) cin>>x[o]
#define arrout(x,n) for(int o=0;o<n;o++) cout<<x[o]<<" "; cout<<endl
#define vecin(x,n); vi x;int hool; for(int o=0;o<n;o++) {cin>>hool; x.pb(hool);}
#define vecout(x,n) for(int o=0;o<n;o++) cout<<x[o]<<" "; cout<<endl
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<'='<<x<<endl
#define deb2(x,y) cout<<#x<<'='<<x<<" "<<#y<<'='<<y<<endl
#define deb3(x,y,z) cout<<#x<<'='<<x<<" "<<#y<<'='<<y<<" "<<#z<<'='<<z<<endl
#define debarr(arr,n) for(int o=0;o<n;o++) deb2(o,arr[o])
#define IO freopen("input.txt", "r", stdin); freopen("output.txt", "w+", stdout)
const double pi = 3.14159265358979323846;

int powersimple(int a, int b){//a^b
    int res=1;
    while(b>0){
        if(b&1)
		{res=(res*a);
		b--;}
        a=(a*a);
        b>>=1;
    }
    return res;
}

int ncr(int n,int k)
{
	int ans=1;
	if(k>n-k)
	k=n-k;
	for(int i=1;i<=k;i++)
	ans*=(n-i+1),ans/=i;
	return ans;
}


int power(int x,int y,int p) 
{ 
    int res = 1;  
    x = x % p;   
    while (y > 0) { 
        if (y & 1) 
            res = (res * x) % p;  
        y = y >> 1; 
        x = (x * x) % p; 
    } 
    return res; 
} 

int modInverse(int n, int p) 
{ 
    return power(n, p - 2, p); 
} 

int ncrModPFermat(int n,int r, int p) 
{ 

    if (r == 0) 
		return 1; 
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
    int fac[n + 1]; 
    fac[0] = 1; 
    for (int i = 1; i <= n; i++) 
        fac[i] = (fac[i - 1] * i) % p; 
  
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; 
} 

int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}



void solve()
{

	int i=0,j=0,k=0,m,n,p,sum=0,cnt=0;
	cin>>n;
	vi pl,mi;
	for(i=0;i<n;i++)
	{
	    cin>>j>>k;
	    pl.pb(j+k);
	    mi.pb(j-k);
	}
	sort(all(pl));
	sort(all(mi));
	j=pl.back()-pl.front();
	k=mi.back()-mi.front();
	cout<<max(j,k);
	
	
	
	 
}
int32_t main() {
    fast
    //IO;
	//cout<<fixed<<setprecision(6);
    //test
    {
        
        solve();
		
		      
    }
    return 0;
}
  


Measured memory_bytes: 6700
import queue


def main():
    K = int(input())
    number_list = queue.Queue()
    for i in range(1, 10):
        number_list.put(i)
    count = 0
    number = 0
    while(count != K):
        number = number_list.get()
        if number % 10 != 0:
            number_list.put((10 * number) + (number % 10) - 1)
        number_list.put(10 * number + number % 10)
        if number % 10 != 9:
            number_list.put(10 * number + (number % 10) + 1)
        count += 1
    print(number)


if __name__ == "__main__":
    main()


Measured memory_bytes: 12528
S = input()

u = {}
sSet = set(S)
for s in S:
	if s not in u.keys():
		u[s] = 1
	else:
		u[s] += 1
			
if len(sSet) == 2:
	if u[list(sSet)[0]] == 2 and u[list(sSet)[1]] == 2:
		print("Yes")
		exit()
print("No") 

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s; cin >> s;
    sort(s.begin(), s.end());
    if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>

#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n"
#define MOD 998244353

const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;

using namespace std;

void solve()
{
    int n;
    cin >> n;

    string s;
    cin >> s;

    int w_count = 0;
    int r_count = 0;

    for(int i = 0; i < n; i++)
    {
        if(s[i] == 'W')
        {
            w_count++;
        }
        else {
            r_count++;
        }
    }

    int ans = 0;

    for(int i = 0; i < w_count; i++)
    {
        if(s[n - 1 - i] == 'R')
        {
            ans++;
        }
    }

    cout << ans << "\n";
   
}

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

    int T = 1;
    //cin >> T;

    while (T--)
    {
        solve();
    }

    return 0;
}





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

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 107;
const int W = 1e5 + 7;

ll dp[N][W];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int n, w;
    cin >> n >> w;
    for (int i = 1; i <= n; ++i) {
        int v, c;
        cin >> v >> c;
        for (int j = 0; j <= w; ++j) {
            dp[i][j] = dp[i - 1][j];
            if (j >= v) {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - v] + c);
            }
        }
    }
    ll ans = 0;
    for (int j = 0; j <= w; ++j) {
        ans = max(ans, dp[n][j]);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 79360
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
typedef pair<ll, ll> pll;
#define pb push_back
typedef long double ld;
#define fi first
#define se second
#define PI 3.14159265358979323846264338327950288419716939937510
#define mp make_pair
ll inf = 1e18;
ll p = 1e9 + 7;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll pwr(ll x, ll y)
{
    ll res = 1;
    x = x ;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) ;
        y = y >> 1;
        x = (x * x) ;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
ll spf[1000001] = {0};
void sieve()
{
    ll i, j;
    spf[1] = 1;
    for (i = 2; i < 1000001; i++)
    {
        spf[i] = i;
    }
    for (i = 4; i < 1000001; i += 2)
    {
        spf[i] = 2;
    }

    for (i = 3; i * i < 1000001; i++)
    {
        if (spf[i] == i)
        {
            for (j = i * i; j < 1000001; j += i)
            {
                if (spf[j] == j)
                    spf[j] = i;
            }
        }
    }
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i, j, y, x,  z, w, g, key,  k, n, m, a, b;
    ll t2, t3, t4, t1, t5, t6;
    string s, t;

    cin >> n ;
    ll arr[n];
    sieve();
    ll ans = 0;
    for (i = 0; i < n; i++)
    {
        cin >> arr[i];
        ans = __gcd(arr[i], ans);
    }
    if (ans != 1)
    {
        cout << "not coprime";
    }
    else
    {
        map<ll, ll>ma;
        ll flag = 1;
        for (i = 0; i < n; i++)
        {
            set<ll>s;
            ll temp = arr[i];

            while (temp != 1)
            {

                s.insert(spf[temp]);
                //cout<<temp<<"\n";
                temp = (temp / spf[temp]);

            }
            for (auto u : s)
            {
                ma[u]++;
                if (ma[u] > 1)
                {
                    flag = 0;
                    break;
                }
            }
            if (flag == 0)
                break;

        }
        if (flag)
            cout << "pairwise coprime";
        else
            cout << "setwise coprime";
    }
    return 0;
}

Measured memory_bytes: 19200
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}

int main(){
    string s;
    cin >> s;
    ll n = s.size();
    vector<ll>a(n);
    ll r =0;ll num = -1,l=0;
    for(int i=0;i<s.size();i++){
        if(s.at(i)=='R')r++;
        else l++;
        if(num==-1&&s.at(i)=='L'){
            num=i;
        }
        if(num!=-1&&s.at(i)=='R'){
            r--;
            if(r%2==0){
                a.at(num)=(r+l)/2+(r+l)%2;
                a.at(num-1)=(r+l)/2;
            }
            else {
                a.at(num)=(r+l)/2;
                a.at(num-1)=(r+l)/2+(r+l)%2;
            }
            r=1,l=0,num=-1;
        }
        if(i==n-1){
            if(r%2==0){
                a.at(num)=(r+l)/2+(r+l)%2;
                a.at(num-1)=(r+l)/2;
            }
            else {
                a.at(num)=(r+l)/2;
                a.at(num-1)=(r+l)/2+(r+l)%2;
            }            
        }
    }
    for(int i=0;i<n;i++){
        cout<< a.at(i)<<" ";
    }
}
    



Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
//#define for(i,a,b) for(int i=(a);i<=(b);i++)

int32_t main()
{

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int k,x;
cin>>k>>x;
for(int i=(x-(k-1));i<=(x+k-1);i++)
{
    cout<<i<<" ";
}
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
res = 0
for i in range(n):
    num = a[i]
    res += b[num - 1]
for i in range(n-1):
    if a[i] +1== a[i+1] :
        num = a[i]
        res += c[num-1]
print(res)


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

typedef pair<int, int> P;

map<int, vector<int> >m[101010];
map<int, int>flg[101010];
int ans[101010];

int main(){

    for(int i = 0; i < 101010; i++)ans[i] = 101010;

    int N, M;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int p, q, c;
        cin >> p >> q >> c;
        m[p][c].push_back(q);
        m[q][c].push_back(p);
    }
    priority_queue<P, vector<P>, greater<P> >Q;
    ans[1] = 0;
    Q.push(P(1, 1));
    while(!Q.empty()){
        int p = Q.top().second;
        Q.pop();
        for(auto it = m[p].begin(); it != m[p].end(); it++){
            int c = (*it).first;
            stack<int>S;
            S.push(p);
            flg[p][c] = 1;
            while(!S.empty()){
                int s = S.top();
                S.pop();
                if(ans[s] == 101010){
                    ans[s] = ans[p] + 1;
                    Q.push(P(ans[s], s));
                }
                for(int i = 0; i < m[s][c].size(); i++){
                    int nxt = m[s][c][i];
                    if(flg[nxt][c] == 0){
                        S.push(nxt);
                        flg[nxt][c] = 1;
                    }
                }
            }
        }
    }    
    if(ans[N] == 101010)cout << "-1" << endl;
    else cout << ans[N] << endl;

    return 0;
}

Measured memory_bytes: 72952
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<iostream>
#include<algorithm>
typedef long long ll;
const int maxn = 1e5 + 10;
using namespace std;

ll n, m, x;

int main() {
    while(scanf("%lld", &x) != EOF) {
        double f = (sqrt(1 + 8 * x) - 1) / 2;
        ll ans = (ll)f;
        if(ans * (ans + 1) < 2 * x) ans++;
        printf("%lld\n", ans);
    }
    return 0;
}


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

ll k, a[33] = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};	//存储这个数列 

inline ll read(){																										//快读 
	ll s = 0, w = 1;
	char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

inline void work(){
	k = read();																											//输入k 
	printf("%lld\n", a[k]);																								//输出数列中第k个数 
}

int main(){
	work();
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  
  static int[][] originalmap;
  static int[][] map;
  static int h,w;
  
  static void solve(int i,int j){
    if(i>0&&map[i-1][j]!=-1&&map[i-1][j]>map[i][j]+1){
      map[i-1][j]=map[i][j]+1;
      solve(i-1,j);
    }
    if(i<h-1&&map[i+1][j]!=-1&&map[i+1][j]>map[i][j]+1){
      map[i+1][j]=map[i][j]+1;
      solve(i+1,j);
    }
    if(j>0&&map[i][j-1]!=-1&&map[i][j-1]>map[i][j]+1){
      map[i][j-1]=map[i][j]+1;
      solve(i,j-1);
    }
    if(j<w-1&&map[i][j+1]!=-1&&map[i][j+1]>map[i][j]+1){
      map[i][j+1]=map[i][j]+1;
      solve(i,j+1);
    }
    
  }
  
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    h = sc.nextInt();
    w=sc.nextInt();
    
    originalmap = new int[h][w];
    
    for(int i=0;i<h;i++){
      String temp = sc.next();
      char[] ver = temp.toCharArray();
      for(int j=0;j<w;j++){
        if(ver[j]=='.'){
          originalmap[i][j]=100000;
        }else{
          originalmap[i][j]=-1;
        }
      }
    }
    
    int ans = 0;
    
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        
        if(originalmap[i][j]!=-1){
          
          map = new int[h][w];
          for(int t=0;t<h;t++){
            
            map[t] = originalmap[t].clone();

          }
          

          
          map[i][j]=0;
          solve(i,j);

          for(int k=0;k<h;k++){
            for(int l=0;l<w;l++){
              
              if(map[k][l]!=100000)ans = Math.max(ans,map[k][l]);
            }
          }
          
        }
      }
    }
    
    System.out.println(ans);
    
    
  }
}


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

using namespace std;
using ll = long long;

int main() {
    ll L, R;
    cin >> L >> R;

    if(R - L > 2018) {
        cout << 0 << endl;
    } else if(R%2019 <= L%2019) {
        cout << 0 << endl;
    } else {
        int ans = 2020;
        for(int i = L%2019; i <= R%2019; i++) {
            for(int j = i + 1; j <= R%2019; j++) {
                ans = min(ans, (i*j)%2019);
            }
        }
        cout << ans << endl;
    }


    return 0;
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
namespace 私が灰コーダーです{
    class Inonoa{
        static void Main(){
            string[] n_m = Console.ReadLine().Split();
            int n = int.Parse(n_m[0]);
            int m = int.Parse(n_m[1]);
            int l = 1;
            int r = n;
            for(int i=0;i<m;i++){
                string[] l_r = Console.ReadLine().Split();
                if(l<int.Parse(l_r[0])){
                    l = int.Parse(l_r[0]);
                }
                if(r>int.Parse(l_r[1])){
                    r = int.Parse(l_r[1]);
                }
            }
            Console.WriteLine(Math.Max(0,r-l+1));
        }
    }
}

Measured memory_bytes: 17344
#include <stdio.h>

int main(void){

  long a,b,n;
  scanf("%ld %ld %ld", &a, &b, &n);
  long x = b-1;
  if (x > n) {
    x = n;
  }
  long answer = a*x/b-a*(x/b);
  printf("%ld\n", answer);

  return 0;
}

Measured memory_bytes: 1668
#include<stdio.h>
#define INF 1000000
#define N 101
int n;
int m[N][N];
int p[N];

void matrixChainOrder(int *p){
    int i,l,j,k,q;
    for(i=1;i<=n;i++)m[i][i]=0;
    for(l=2;l<=n;l++){
        for(i=1;i<=n-l+1;i++){
            j=i+l-1;
            m[i][j]=INF;
            for(k=i;k<=j-1;k++){
                q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
                if(q<m[i][j])m[i][j]=q;
                
            }
        }
    }
}

int main(){
    int i;
    scanf("%d",&n);
    for(i=1;i<=n;i++)scanf("%d%d",&p[i-1],&p[i]);
    matrixChainOrder(p);
    printf("%d\n",m[1][n]);
    return 0;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	cin>>n;
	string s;
	cin>>s;
	int k;
	cin>>k;
	char c;
	for(int i=0;i<n;i++)
	{
		if(i==k-1)
			c=s[i];
	}
	for(int i=0;i<n;i++)
	{
		if(s[i]==c)
			cout<<s[i];
		else
			cout<<"*";
	}
	cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n, k, i;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> k;
while (n>0){
	n/=k;
	i++;
} cout << i;
return 0;
}

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

int main() {
    int N;
    cin >> N;
    int res = 0;
    int i = 0;
    while (1) {
LOOP:
        i++;
        int j = i;
        vector<bool> n(4);
        int t[] = {0, 3,5,7};
        string trinary;
        while (j > 0) {
            int k = j % 4;
            if (k == 0) goto LOOP;
            j /= 4;
            n[k] = true;
            trinary.push_back('0' + t[k]);
        }
        reverse(begin(trinary), end(trinary));
        // printf("%d = %s\n", i, trinary.c_str());
        if (stol(trinary) > N) break;
        if (any_of(n.begin() + 1, n.end(), [](bool b){return !b;})) continue;
        res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
n = int(input())
new_d = {}
for i in range(ord("a"), ord("z") + 1):
    new_d[chr(i)] = 50
for _ in range(n):
    old_d = new_d
    s = input()
    d = defaultdict(int)
    for c in s:
        if c not in old_d:
            continue
        d[c] += 1
    new_d = {}
    for c in d.keys():
        new_d[c] = min(old_d[c], d[c])
ans = ""
for c, v in sorted(new_d.items()):
    ans += c * v
print(ans)

Measured memory_bytes: 9456
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int mex=5000001;
#define ll long long 
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int> 
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr[i]);
#define sz(x) x.size()
#define loop(x) for(auto it=x.begin();it!= x.end();it++) 

int main()
{
    string s1,s2;
    cin>>s1>>s2;
    int a,b;
    cin>>a>>b;
    map<string,int> mp;
    mp[s1]=a;
    mp[s2]=b;
    string s;
    cin>>s;
    mp[s]--;
    cout<<mp[s1]<<" "<<mp[s2];
}

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

using namespace std;

int main() {

    int n;cin >> n;
    string s;
    map<string, int> mp;
    for(int i = 1;i <= n; ++i) {
        cin >> s;
        ++mp[s];
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;

    return 0;
}


Measured memory_bytes: 3604
#include<iostream>
using namespace std;
long long n,m,p=1e9+7;
int main(){
    cin>>n>>m;
    if(n>m){
        int k=n;
        n=m;
        m=k;
    }
    if(m-n>1)cout<<0<<endl;
    else{
        long long ans=1;
        if(n==m){
            for(int i=0;i<n;i++){
                ans=(ans*(i+1))%p;
            }
            ans=(ans*ans*2)%p;
        }
        else{
            for(int i=0;i<n;i++){
                ans=(ans*(i+1))%p;
            }
            ans=(((ans*ans)%p)*m)%p;
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

int main(){
	int N, i;
	cin >> N;
	
	int p[N+1];
	for(i=1; i<=N; i++){
		cin >> p[i];
	}
	
	int count=0;
	for(i=1; i<=N; i++){
		if(p[i]!=i)	count++;
	}
	
	if(count<=2)	cout << "YES" << endl;
	else		cout << "NO" << endl;
	
	return 0;
}


Measured memory_bytes: 256
/*
   AUTHOR :- Gaurang_Kothiya
   
   Quote:-" Great things never come from comfort zones."                                                                                                                
*/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> data_set; 
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long  
#define ld long double
#define f(i,x,n) for(ll i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(ll i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 1000000007



void solver()
{
	ld n;
	cin>>n;
	
	ld temp= (n/3.0) * (n/3.0) * (n/3.0);
	cout<<fixed<<setprecision(12)<<temp;	
}


signed main() 
{
	speed	
		
	ll q=1;	
	//cin>>q;	
	
	while(q--)	
	solver();	
	
	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}

 
 

Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))
b = sum(list(map(int,input().split())))
c = list(map(int,input().split()))
for i in range(len(a)-1):
    if a[i]+1==a[i+1]:
        b += c[a[i]-1]

print(b)

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

static const ll MAX = 100001;
ll a[MAX] = {};
ll b[MAX] = {};
ll c[MAX] = {};
int main() {
    

    ll n,k;
    cin >> n >> k;
    for (ll i=1;i<=n;i++){
        cin >> a[i];
    }
    ll tmp1 = 0;
    ll tmp2 = 0;
    for (ll i=1;i<=n;i++){
        tmp1 += a[i];
        if(a[i] > 0) {
            tmp2 += a[i];
        }
        b[i] = tmp1;
        c[i] = tmp2;
    }
    ll ans = 0;
    for (ll i=1;i<=n-k+1;i++){
        ll tmp = 0;
        tmp = c[i-1] + (c[n] - c[i+k-1]) + (b[i+k-1] - b[i-1]);
//        cout << c[i-1] << " " << (c[n] - c[i+k]) << " " << (b[i+k-1] - b[i-1]) << endl;
//        cout << i << " " << tmp << endl;
        if(ans < tmp){
            ans = tmp;
        }
        tmp = c[i-1] + (c[n] - c[i+k-1]);
        if(ans < tmp){
            ans = tmp;
        }
//        cout << i << " " << tmp << endl;
    }
    cout << ans << endl;

}

Measured memory_bytes: 2560
N = int(input())

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

if 0 in A:
    print(0)
    exit()

for i in range(N):
    C = C * A[i]
    if C > 1000000000000000000:
        print(-1)
        exit()

print(C)

Measured memory_bytes: 21616
import java.util.*;

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

        for (int i = 0; i < s.length(); i++) {
            String rotated = String.format("%s%s", s.substring(i, s.length()), s.substring(0, i));
            if (t.equals(rotated)) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 23764
// Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int t;
		cin >> t;

		if(t==0)
			break;

		int n;
		cin >> n;

		int sum = 0;

		for(int i=0; i<n; i++){
			int s, f;
			cin >> s >> f;

			sum += (f-s);
		}

		if(sum>=t){
			cout << "OK" << '\n';
		}
		else{
			cout << t-sum << '\n';
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl


void solve(long long N, std::vector<std::string> S){
  map<string, bool> m;
  REP(x, N){
    m[S.at(x)] = true;
  } 
  int sum = 0;
  for(const auto& x  : m) {
    sum += 1;
  }
  cout << sum << endl;
}

signed main(){
  long long N;
  scanf("%lld",&N);
  std::vector<std::string> S(N);
  for(int i = 0 ; i < N ; i++){
    std::cin >> S[i];
  }
  solve(N, std::move(S));
}


Measured memory_bytes: 25160
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define ALL(v) v.begin(), v.end()
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
	string S;	cin >> S;
	int k=-1, i=-1, h=-1, b=-1, r=-1;
	rep(j, S.size()) {
		if (S[j]=='A') continue;
		else if (S[j]=='K') {
			if (k==-1) k=j;
			else {
				puts("NO");
				return 0;
			}
		} else if (S[j]=='I') {
			if (i==-1) i=j;
			else {
				puts("NO");
				return 0;
			}
		} else if (S[j]=='H') {
			if (h==-1) h=j;
			else {
				puts("NO");
				return 0;
			}
		} else if (S[j]=='B') {
			if (b==-1) b=j;
			else {
				puts("NO");
				return 0;
			}
		} else if (S[j]=='R') {
			if (r==-1) r=j;
			else {
				puts("NO");
				return 0;
			}
		} else {
			puts("NO");
			return 0;
		}
	}
	if ((k==0 || k==1)&&(k+1==i&&k+2==h)&&(h+1==b||h+2==b)&&(b+1==r||b+2==r)&&(S.size()-r<=2)) {
		puts("YES");
	} else {
		puts("NO");
	}
}

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

int main(){
  int N,H; cin >> H >> N;
  int pwsum=0;
  for(int i=0; i<N; i++){
    int tmp; cin >> tmp;
    pwsum+=tmp;
  }
  cout << (pwsum>=H?"Yes":"No") << endl;
}

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

int main() {
	
  int X, N;
  cin >> X >> N;
  int *d;
  d = new int [N];

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

  if(N==0){
    cout << X << endl;
    return 0;
  }
  
  int mindata;
  int min = 100;
  	for(int i=0; i<N; i++){
      if(min > abs(X-d[i])){
        min = abs(X-d[i]);
        mindata = d[i];
      }
    }
  int mans = mindata-1;
  for(int j=0; j<N/2; j++){
	  for(int i=0; i<N; i++){
    	if(d[i] == mans){
      		mans = mans - 1;
    	}
  	  }
  }
    
    
  int pans = mindata+1;
  for(int j=0; j<N/2; j++){
	  for(int i=0; i<N;i++){
    	if(d[i] == pans){
       		pans = pans + 1;
    	}
  	  }
  }
  
  if(X-mans > pans-X){
    cout << pans;
  }
  else{
    cout << mans;
  }
  }


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


int main (){
    int n, a, b ;
    cin>> n >> a>> b ;

    int i = n*a;

    if (b>i){
        cout<< i<< endl;
    }
    if (b<i){
        cout << b << endl;
    }
    if (i==b){
        cout << b << endl;
    
    }
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main()
{
  string S; cin>>S;
  ll N=S.size();
  ll ans=0;
  rep(i,N/2){
    if(S.at(i)!=S.at(N-i-1)) ans++;
  }
  
  cout<<ans<<endl;
  return 0;
}


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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Trim().Split(' ');
            var k = int.Parse(input[0]);
            var an = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            Array.Sort(an);

            var gap = k - an[an.Length - 1];
            var index = an.Length - 1;

            for (var i = 0; i < an.Length - 1; i++)
            {

                var tmp = an[i + 1] - an[i];

                if (tmp > gap)
                {
                    gap = tmp;
                    index = i;
                }
            }
            var sum = 0;
            if (index < 1 || index >= an.Length - 1)
            {
                sum = an[an.Length - 1] - an[0];
            }
            else
            {
                sum = k - an[index + 1] + an[index];
            }

            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 32732
#include <stdio.h>

int main()
{
  int x, y;
  int sum, ans;
  
  while(scanf("%d %d", &x, &y) != -1){
    sum = x + y;
    
    for(ans = 0; sum != 0; ans++)
      sum = sum / 10;
    
    printf("%d\n", ans);
  }
  
  return 0;
}

Measured memory_bytes: 1732
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;

typedef modint998244353 mint;

const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
//const ll MOD = 1e9 + 7;
const ll MOD = 998244353;

const ll MAX = 1e9 + 5;

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

	vector<int> x(n);
	vector<int> y(n);
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		int xi, yi;
		cin >> xi >> yi;
		xi--;
		yi--;
		x[xi] = i;
		y[yi] = i;
		p[xi] = yi;
		
	}
	
	
	dsu d(n);
	set<int>s;
	for (int i = 0; i < n; i++) {
		auto itr = s.begin();
		auto end = s.upper_bound(p[i]);
		if (itr == end) {
			s.insert(p[i]);
			continue;
		}

		int f = *itr;
		for (; itr != end; itr = s.erase(itr)) {
			d.merge(y[p[i]], y[*itr]);
		}
		s.insert(f);
	}
	
	
	for (int i = 0; i < n; i++) {
		
		cout <<  d.size(i) << endl;
	}

	

}

Measured memory_bytes: 11052
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <functional>
#include <queue>
#include <tuple>
#include <cstring>
#include <iomanip>
#include <algorithm>

using namespace std;

#define rep(i,n) for(int i = 0;i < n;i++)
#define each(i,n) for(auto i : n)
#define all(n) n.begin(),n.end()
#define clr(n) memset(n,0,sizeof(n))
#define mclr(n) memset(n,-1,sizeof(n))
#define int long long

signed main() {
	int n, p, q;
	cin >> n >> p >> q;
	vector<int> c(n);
	int dif = 0, sum = 0;;
	rep(i, n) {
		cin >> c[i];
		c[i] += i * p;
		dif += i * p;
		sum += c[i];
	}
	sort(all(c));
	int ans = sum - dif;
	rep(i, n) {
		sum -= c[i];
		sum += (q + i * 2) * p;
		ans = max(ans, sum - dif);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6776
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i,a) for(ll i=a-1;i>=0;i--)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)
#define printall(n,array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
const ll mod = 1e9 + 7; //10^9+7

int main(){
    string s;
    cin >> s;
    ll w_count = 0;
    ll cnt = 0;
    ll ans = 0;
    REP(i, s.size())if(s[i] == 'W')w_count++;
    RREP(i, s.size()){
        if(s[i] != 'W')continue;
        ans += i - cnt;
        cnt++;
    }
    print(ans);
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int n, a[222][3], res[222];
vector<map<int, int>> mp(3);

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> a[i][j];
            mp[j][a[i][j]]++;
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            if (mp[j][a[i][j]] == 1)
                res[i] += a[i][j];
        }
    }
    for (int i = 0; i < n; i++)
    {
        cout << res[i] << endl;
    }
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const ll INF = 1LL << 60;

 ll calc(ll n) {
   ll ret = 0;
   for (ll i = n / 4 * 4; i <= n; i++) ret ^= i;
   return ret;
 }

 int main() {
  ll A, B; cin >> A >> B;
  if (A == 0) cout << calc(B) << endl;
  else cout << (calc(B) ^ calc(A - 1)) << endl;
}


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

using namespace std;
int main(void){
    // Your code here!
    int n;
    cin >> n;
    
    string s;
    cin >> s;
    
    int ans = 0;
    
    for(int i = 0; i < n - 2; i++){
        if(s.substr(i, 3) == "ABC") ans++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 384
def unification(n,s):
    rc = 0
    bc = 0

    for c in s:
        if c == '0':
            rc += 1
        elif c == '1':
            bc += 1
        else:
            break

    return min(rc,bc) * 2

if __name__ == '__main__':
    s = raw_input()
    n = len(s)
    _s = [i for i in s]

    print unification(n,_s)

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

using namespace std;
int gcd(int a, int b){
  if(a < b) swap(a, b);
  while(b){
    int tmp = b;
    b = a % b;
    a = tmp;
  }
  return a;
} 

int main(){
  int n, x;
  cin >> n >> x;
  vector<int> array(n);
  for(int i = 0; i < n; ++i) cin >> array[i];
  int res = abs(array[0] - x);
  for(int item: array) res = gcd(res, abs(item -x));
  cout << res << endl; 
}

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

#define ALL(a) (a).begin(), (a).end()
#define ll long long

using namespace std;

signed main(){
	string s; cin >> s;
	int ans = 9999999;
	for(int i = 0; i < s.size()-2; i++){
		ans = min(abs(753 - stoi(s.substr(i,3))), ans);
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<cstdio>
#include<cmath>
int main(){
  int x = 0;
	char a[3];
  for(int i = 0; i < 3; i++)	
  scanf(" %c",&a[i]);
  for(int i = 0; i < 3; i++)
  if(a[i] - 48) x++;
  std::cout << x << std::endl;
  return 0;
}

  
  	
  	

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<cstdio>
#include<string>
#include<math.h>
#include<vector>
#include <queue>
#include <bits/stdc++.h>
#include <map>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
using namespace std;
typedef vector<vector<char>> field_t;

typedef pair<int, int> point_t;
int K;
string S;

int main()
{
    cin >> K;
    cin >> S;
    int lg;
    lg=S.length();
    if(K>=lg){
        cout << S <<endl;
    }else{
        cout << S.substr(0,K)<<"..."<<endl;
    }    
}

Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>


typedef long long ll;
typedef long double ld;

using namespace std;
const int MAXN = 5100;
const ll MOD = 1e9 + 7;
const ll B2 = 500000004;

int n, m;
int dp[MAXN];
int dp2[MAXN];
string s;


void add(int &a, int b) {
	a += b;
	if (a >= MOD)
		a -= MOD;
}

int main() {
	cin >> n;
	cin >> s;
	m = s.size();
	dp[0] = 1;
	for (int i = 0; i < n; ++i) {
		memset(dp2, 0, sizeof(dp2));
		for (int j = 0; j <= i; ++j) {
			add(dp2[max(0, j - 1)], dp[j]);
			add(dp2[j + 1], dp[j]);
			add(dp2[j + 1], dp[j]);
		}
		memcpy(dp, dp2, sizeof(dp2));
	}
	ll ans = dp[m];
	for (int i = 0; i < m; ++i)
		ans = (ans * B2) % MOD;
	cout << ans << "\n";

	return 0;
}




Measured memory_bytes: 384
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array, std.functional;

void main() {
  auto input = readln.split.to!(int[]);
  auto N = input[0], Q = input[1];
  auto tree = new int[][N];
  auto cnt = new int[N];

  foreach(i; 0..(N-1)) {
    input = readln.split.to!(int[]);
    auto a = input[0], b = input[1];
    tree[a-1] ~= b-1;
    tree[b-1] ~= a-1;
  }

  foreach(i; 0..Q) {
    input = readln.split.to!(int[]);
    auto p = input[0], x = input[1];
    cnt[p-1] += x;
  }

  auto seen = new bool[N];
  void dfs(int n, int parCnt) {
    seen[n] = true;
    cnt[n] += parCnt;
    foreach(c; tree[n]) {
      if(!seen[c]) {
        dfs(c, cnt[n]);
      }
    }
  } 

  dfs(0, 0);

  foreach(c; cnt) {
    write(c, " ");
  }
}


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

typedef long long LL;

const int N=200005;
const int MOD=998244353;

int n,a[N],f[N];
char str[N];

int solve(int t)
{
	int s=0;
	for (int i=0;i<t;i++) s=(s*2+a[i])%MOD;
	bool flag=0;
	for (int i=t;i<n;i++)
		if (a[i]<(a[i%t]^((i/t)&1))) {flag=1;break;}
		else if (a[i]>(a[i%t]^((i/t)&1))) break;
	if (!flag) s++;
	return s;
}

int main()
{
	scanf("%d",&n);
	scanf("%s",str);
	int r=0;
	for (int i=0;i<n;i++) a[i]=str[i]-'0',r=(r*2+a[i])%MOD;;
	r++;
	for (int i=1;i<=n;i++)
		if (n%i==0&&n/i%2==1)
		{
			(f[i]+=solve(i))%=MOD;
			for (int j=i*2;j<=n;j+=i)
				if (n%j==0) (f[j]+=MOD-f[i])%=MOD;
			(r+=MOD-f[i])%=MOD;
		}
	int ans=(LL)r*n*2%MOD;
	for (int i=1;i<=n;i++)
		if (n%i==0&&n/i%2==1) (ans+=(LL)f[i]*i*2%MOD)%=MOD;
	printf("%d\n",ans);
	return 0;
}

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

int main(){
	long long n,m,sum=0;
	cin>>n>>m;
	for(long long i=m;i<=n+1;i++){
		sum+=i*n-i*(i-1)/2-(i-1)*i/2+1;
	}
	cout<<sum%1000000007;
	return 0;
}

Measured memory_bytes: 3636