akhauriyash/Code-Regression huggingface dataset:
// #define DEBUG_MODE
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
typedef vector< int > vi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< ll > vll;
#ifdef DEBUG_MODE
	#define errp(...) fprintf(stderr, __VA_ARGS__)
#else
	#define errp(...)
#endif
#define dbg(x) errp("[%s = %s]\n", #x, to_string(x).data())

int main () { 
#ifdef DEBUG_MODE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	
	int n;
	double ans = 0;
	scanf("%d", &n);
	priority_queue<double, vector<double>, greater<double>> Q;
	int tmp;
	for (int i = 0; i < n; i++) {
		scanf("%d", &tmp);
		Q.push((double)tmp);
	}
	while (Q.size() >= 2) {
		double a = Q.top(); Q.pop();
		double b = Q.top(); Q.pop();
		Q.push((a + b) / 2.0);
	}
	printf("%f\n", Q.top());
	
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <utility>
#include <set>
#include <stack>
#include <iterator>
#include <fstream>
using namespace std;
#define int long long
int32_t main(){
    int n;
    cin >> n;
    map<int,int>l;
    for(int i = 0; i < n; ++i){
        int t;
        cin >> t;
        if(l.find(t)==l.end())
            l[t]=1;
        else
        {
            cout << "NO\n";
            exit(0);
        }
    }
    cout << "YES\n";
    return 0;
}

Measured memory_bytes: 12800
from sys import stdin
input = stdin.readline

N = int(input())

cnt = [0] * (10 ** 7 + 1)

ans = 0

for i in range(1, N + 1):
    for j in range(i, N + 1, i):
        cnt[j] += 1
    ans += cnt[i] * i

print(ans)


Measured memory_bytes: 151296
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <deque>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < (n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
typedef long long ll;
using namespace std;
int main() {
    int n; cin >> n;
    vector<int> a(n); repeat (i,n-1) cin >> a[i];
    int sum_a = accumulate(a.begin()+2, a.end(), 0);
    deque<int> dp(sum_a*2+1); whole(iota, dp, 0);
    repeat_from (i,2,n) {
        repeat (j,a[i]) dp.push_front(dp[2*j+1]);
    }
    int m; cin >> m;
    while (m --) {
        int x; cin >> x;
        cout << (x < dp.size() ? dp[x] : x - sum_a) + a[0] - a[1] << endl;
    }
    return 0;
}


Measured memory_bytes: 15232
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
 
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef long double LD;
//#define int ll
#define double LD
#define pb push_back
#define mp make_pair
#define REP(i,n) for (int i = 0; i < n; i++)
#define loop(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define mem(a, b) memset(a, b, sizeof a)
#define append push_back
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define print(x) cout << (x) << endl
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const double PI=acos(-1);
const int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;

mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(all(v), RNG);
// Use mt19937_64 for 64 bit random numbers.
 
void solve();
 
signed main(){
	FAST_IO;
	PRECISION(10);
 
	int t = 1;
	//cin>> t;
	FOR(testcase,1,t+1){
		// printf("Case #%lld: ",testcase); 
		solve();
	}
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
}   
 
void solve(){
	int n, m, x;
	cin>> n >> m >> x;
	vector<int> cost(n);
	int grid[n][m];

	for(int i = 0; i < n; i++){
		cin>> cost[i];
		for(int j = 0; j < m; j++)
			cin>> grid[i][j];
	}
	int mn = 1e9;
	for(int i = 0; i < (1<<n); i++){
		vector<int> course(m, 0);
		int tmp = 0;
		for(int j = 0; j < n; j++){
			if((i&(1<<j))){
				//cerr<< j <<' ';
				tmp += cost[j];
				for(int hehe = 0; hehe < m; hehe++)
					course[hehe] += grid[j][hehe];
			}
		}
		// cerr<< endl;
		bool flag = 1;
		for(int j = 0; j < m; j++)
			flag = (flag and (course[j] >= x));
		// cerr<< tmp << ' ' << flag << endl;
		if(flag)
			mn = min(mn, tmp);
	}
	if(mn == 1e9)
		print(-1);
	else
		print(mn);
}

Measured memory_bytes: 3652
#include       <set>
#include       <map>
#include     <queue>
#include     <cmath>
#include    <cstdio>
#include    <cctype>
#include    <vector>
#include   <cstring>
#include <algorithm>
using namespace std;

typedef long long ll;
const ll mod = 1e9+7;
const double eps = 1e-7;
const int maxn = 5e6+5;

ll fast_pow(ll a,ll b,ll mod){
    ll ans = 1;
    while(b){
        if(b&1)
            ans = ans*a%mod;
        a = a*a%mod;
        b>>=1;
    }
    return ans;
}
int S[105][105];
int SG(int x,int y){
    if(x>y)swap(x,y);
    if(S[x][y]!=-1)return S[x][y];

    for(int i=2;i<=x;i+=2){
        if(SG(x-i,y+i/2)==0)
            return S[x][y] = 1;
    }
    for(int i=2;i<=y;i+=2){
        if(SG(x+i/2,y-i)==0)
            return S[x][y] = 1;
    }
    return S[x][y] = 0;
}
int main(){
    /*
    memset(S,-1,sizeof(S));
    S[0][0] = S[0][1] = S[1][0] = S[1][1] = 0;
    for(int i=1;i<=60;i++)
    for(int j=1;j<=60;j++)
        SG(i,j);
    for(int j=0;j<=15;j++){
        for(int i=0;i<=j;i++)
            printf("SG[%d][%d]=%d ",i,j,S[i][j]);
        puts("");
    }
    */
    ll x, y;
    scanf("%lld%lld",&x,&y);
    ll t = x-y;
    if(t<0)t=-t;
    printf("%s\n",(t<=1?"Brown":"Alice"));
    return 0;
}



Measured memory_bytes: 256
const val MOD = 1000000007L
fun main(args: Array<String>) {
    val (N, A, B) = listOfInt()
    fun pow2(n: Int): ModInt {
        if (n == 0) return ModInt(1)
        var x = pow2(n / 2)
        x *= x
        if (n % 2 == 1) x *= 2
        return x
    }
    fun C(n: Int, a: Int): ModInt {
        var x = ModInt(1)
        var y = ModInt(1)
        repeat(a) { i ->
            x *= n - i
            y *= i + 1
        }
        return x / y
    }
    var ans = pow2(N) - 1 - C(N, A) - C(N, B)
    println(ans.toString())
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)


data class ModInt(private var v: Long) {
    companion object { private const val MOD = 1000000007L }
    init { this.v %= MOD }
    constructor(n: Int): this(n.toLong())
    operator fun plus(other: Int) = ModInt((this.v + other) % MOD)
    operator fun minus(other: Int) = ModInt((this.v + MOD - other) % MOD)
    operator fun minus(other: ModInt) = ModInt((this.v + MOD - other.v) % MOD)
    operator fun times(other: Int) = ModInt(this.v * other % MOD)
    operator fun times(other: ModInt) = ModInt(this.v * other.v % MOD)
    operator fun div(other: ModInt) = ModInt(this.v * pow(other.v, MOD - 2) % MOD)
    private fun pow(a: Long, b: Long): Long {
        if (b == 0L) return 1L
        if (b % 2 == 0L) {
            val d = pow(a, b / 2)
            return (d * d) % MOD
        }
        return a * pow(a, b - 1) % MOD
    }
    override fun toString() = this.v.toString()
}



Measured memory_bytes: 42932
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A[32]={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};
    int K; cin>>K;
    cout<<A[K-1];

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define pb push_back
#define in(x) int x; cin>>x;
#define inn(x, y) int x, y; cin>>x>>y;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;

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

int32_t main(void){
	IOS;
	
	inn(n, k);
	int d = n/k;
	if(n%k == 0) cout<<"0";
	else
	{
		int ans1 = n%k;
		int ans2 = k - n%k;
		cout<<min(ans1, ans2);
	}
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    int N;
    cin >> N;
    Vi A(N);
    unordered_map<int, int> mp;
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
        ++mp[A[i]];
    }
    sort(A.begin(), A.end());
    constexpr int MX_A = 1000000;
    vector<bool> used(MX_A + 1, false);
    int ans = 0;
    for (ll i = 0; i < N; i++) {
        if (used[A[i]]) continue;
        if (mp[A[i]] == 1) ++ans;
        for (ll j = A[i]; j <= MX_A; j += A[i]) {
            used[j] = true;
        }
    }
    cout << ans << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 12440
#%%
k, a, b = map(int, input().split())

d = k - a + 1

if d >= 0:
    if b-a >= 2:
        step = b-a
    else:
        step = 2

ans = 1 

if d % 2 == 0:
    ans += d//2 * step + a - 1
else:
    ans += d//2 * step + a

print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;



int main() {
	double h, w;
	int x, y;
	cin >> w >> h >> x >> y;
	printf("%f", w * h / 2);
	if (x == w / 2 && y == h / 2)cout << " " << 1 << endl;
	else cout << " " << 0 << endl;


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
   ll dp[2000000];
 int gcd(int a, int b)
{
  if (a%b == 0)
{
return(b);
}
else
{
return(gcd(b,a%b));
}
}
int main(){
  ll a,b,c;cin>>a>>b>>c;
  ll d=c-b,e;
  vector<ll>f(a+1,0);
  rep(i,c){
    cin>>e;
    f[e-1]++;
  }
  rep(i,a){
    if(f[i]>d)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}



Measured memory_bytes: 27560
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int N,A[300005],BitA[63]={},two[63]={1},res=0,tmp;
int main() {
	cout << fixed << setprecision(18);
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	for(int i=1;i<61;i++){
		two[i]=2*two[i-1];
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<60;j++){
			BitA[j]+=(A[i]&two[j])/two[j];
		}
	}
	for(int i=0;i<61;i++){
		res+=((BitA[i]*(N-BitA[i]))%mod)*(two[i]%mod);
		res%=mod;
	}
	cout<<res;
} 

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int n, m, q;
const int N = 200000;
int dis[N][15], ci[N], inq[N];
vector <int> bi[N];
queue <int> Q;
int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; ++ i)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        bi[a].push_back(b);
        bi[b].push_back(a);
    }
    scanf("%d", &q);
    for (int i = 1; i <= q; ++ i)
    {
        int v, d, c;
        scanf("%d%d%d", &v, &d, &ci[i]);
        dis[v][d] = i;
    }
    for (int i = 1; i <= n; ++ i)
    {
        for (int j = 10; j; -- j)
            if (dis[i][j] > dis[i][j - 1])
                dis[i][j - 1] = dis[i][j];
        Q.push(i); inq[i] = 1;
    }
    while (!Q.empty())
    {
        int t = Q.front(); Q.pop(); inq[t] = 0;
        for (int i = 0; i < bi[t].size(); ++ i)
        {
            int cg = 0;
            for (int j = 10; j; -- j)
                if (max(dis[t][j], dis[bi[t][i]][j]) > dis[bi[t][i]][j - 1])
                {
                    dis[bi[t][i]][j - 1] = max(dis[t][j], dis[bi[t][i]][j]);
                    cg = 1;
                }
            if (cg && !inq[bi[t][i]])
            {
                Q.push(bi[t][i]);
                inq[bi[t][i]] = 1;
            }
        }
    }
    for (int i = 1; i <= n; ++ i) cout << ci[dis[i][0]] << "\n";
}


Measured memory_bytes: 16888
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.charAt(0) == n.charAt(2)){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 21972
use proconio::input;
use std::collections::{HashMap, VecDeque};

fn main() {
  input! {
    n: usize,
  }
  let mut result = n-1;
  
  for i in 2..=n {
    for ii in 1..=n {
      if n - 1 < i * ii { break }
      result += 1;
    }
  }
  println!("{}", result);
}

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

int main(){
	int n;
	cin>>n;
	bool flag=false;

	for (int i = 0; i <= n/4 ; i++){
		for (int j = 0; j <= n/7; j++){
			if(4*i+7*j==n){
				flag=true;
			}
		}
	}

	if(flag){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

}

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


int max_sum(int n){
	// if (n % 10 == 0)
	// 		return 9;

	// if (n < 10){
		
	// 	return n;
	// }
	// return (n%10) + max_sum(n/10);


}






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

	int x;
	cin >> x;
	int a; 
	cin >> a;
	int b; 
	cin >> b;

	cout << (x - a) % b << endl;

	//cout << max_sum(10) << endl;






// 	int n;
// 	cin >> n;
// 	int x;
// 	vector<int> v;

// 	for (int i = 0; i <  n; i++){
// 		cin >> x;
// 		v.push_back(x);

// 	}


// while(v.size() > 2){
// 	for (int i = 0; i < n; i++){
// 		if (v[i + 1] < (v[i] + v[i + 2])){
// 			v[i + 1] = (v[i] + v[i + 2]);
// 			v.erase(v.begin()+i);
// 			v.erase(v.begin() + (i + 2));
// 			i--;
// 			}
// 		}

// 	}

// if (v.size() == 2)
// 	return max(v[0], v[1]);

// if (v.size() == 1)
// 	return v[0];

// 	return 0;



}













Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include <cstdlib>
#include<cmath>
#include<string>
#include <iomanip>
#include <sstream>

using namespace std;



int main (){

    string s [4] ={"AC","WA","TLE","RE"};
    int a[4]={0,0,0,0};



    int n,i,j,cnt=0;
    cin>>n;

    string words[n];

    for(i=0;i<n;i++){

        cin>>words[i];

    }

    for(i=0;i<4;i++){

        for(j=0;j<n;j++){

            if( s[i] == words[j] ){

                cnt++;
            }

        }

        a[i]=cnt;
        cnt=0;

    }


for(i=0;i<4;i++){

    cout<<s[i]<<" "<<"x"<<" "<<a[i];
    cout<<endl;

}






}

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

dp = [[0,0,0] for _ in range(n)]
dp[0] = abc[0]

for i in range(1,n):
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + abc[i][0]
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + abc[i][1]
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + abc[i][2]

ans = max(dp[n-1])

print(ans)

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

int num[1000005];

int main()
{
    int a;
    int i = 1;
    int ans;

    cin >> a;

    do {
        num[a] = i;

        i++;

        a = (a & 1 ? 3 * a + 1 : a / 2);
    } while(num[a] == 0);

    cout << i << endl;

    return 0;
}


Measured memory_bytes: 256
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()

al = [1]
nc = 0

def ntow(x):
    if x == 0:
        return 'z'
    v = chr(ord('a')+x-1)
    # print(x,v)
    return v

for i in range(1,15):
    nc += 26 ** i
    al.append(nc+1)
    if nc > 1000000000000001:
        break

# print(al)

for i in range(15):
    if n < al[i]:
        keta = i
        break

# print('keta',keta)
ans = ''

for i in range(keta):
    tmp = 26**(i+1)
    # print('tmp',tmp)
    nk = n%tmp
    if nk == 0:
        ans =  'z' + ans
        n -= tmp
    else:
        # print(nk//(26**i))
        ans =  ntow(nk//(26**i)) + ans
        n -= nk

print(ans)









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

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout << fixed;
    
    int n;
    cin >> n;
    n %= 10;
    if(n ==  3){
        cout << "bon";
        return 0;
    }
    if(n == 0 || n == 1 || n == 6 || n == 8) cout << "pon";
    else cout << "hon";
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD  998244353 
#define ll long long
#define int long long
# define INF 9999999
#define ar array
#define MAX 1000004
# define fr first
# define sc second
#define wt(x) int x;cin>>x;while(x--)
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
//#define cerr if(false)cerr
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> pbds;
const int N=6e5+6;
void  c_p_c(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
 
#ifndef ONLINE_JUDGE
  freopen("input1.txt","r",stdin);
  freopen("output1.txt","w",stdout);
#endif
 }
 
int power(int a,int b,int mod){
    a=a%mod;
    if(a==0){
        return 1;
    }
    int res=1;
    while(b){
        if(b&1){
            res=(res*a)%mod;
        }
        b>>=1;
        a=(a*a)%mod;
    }
    return res;
 }
 
int  MMI(int p){
    return power(p,MOD-2,MOD);
}



int32_t main()
{
    c_p_c();
    
        int x1,x2,x3,x4,x5;
        for(int i=0;i<5;i++){
            int x;
            cin>>x;
            if(x==0){
                cout<<i+1;
                return 0;
            }
        }

        

        
}
        
   


//abcdef-abcdef
//factorial vs power

Measured memory_bytes: 3664
/* nuttela - Soham Chakrabarti */
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define all(v) v.begin(),v.end()
#define pb push_back
#define ins insert
#define rep(i,j,k) for(ll i=j;i<k;i++)
#define per(i,j,k) for(ll i=j;i>=k;--i)
#define in freopen("input.txt","r",stdin);
#define out freopen("output.txt","w",stdout);
#define ff first
#define ss second
 
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <ll,ll> pll;
 
const int N = 1e5 + 5;
const int M = 1e5 + 1;
const int inf = INT_MAX;
const int mod = 1e9 + 7;


int32_t main() {
    io;
    // in; out;
    // ll t;
    // cin>>t;
    // while(t--) {
    string s;
    cin>>s;
    rep(i,0,s.size()) {
        if(s[i]=='?')
            cout<<'D';
        else
            cout<<s[i];
    }
    cout<<"\n";
    // }
    return 0;
}
 


Measured memory_bytes: 3744
#include <bits/stdc++.h>
#define LL long long
#define INF 0x7FFFFFFF//or 0x3f3f3f3f ? -Wall
using namespace std;

template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	char ch = getchar();

	while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

/*============ Header Template ============*/

const int N = 10 + 5;

LL a[N];

LL solve1() {
	LL ans = 0;
	LL a1 = a[1], a4 = a[4], a5 = a[5];
	LL tmp = min(min(a1, a4), a5);
	ans += tmp * 6;
	a1 -= tmp, a4 -= tmp, a5 -= tmp;
	ans += 4 * (a1 / 2) + 2 * a[2] + 4 * (a4 / 2 + a5 / 2);
	return ans;
}

LL solve2() {
	LL ans = 0;
	LL a1 = a[1], a4 = a[4], a5 = a[5];
	LL tmp = min(min(a1, a4), a5);
	if (tmp == 0) return 0; tmp--;
	ans += tmp * 6;
	a1 -= tmp, a4 -= tmp, a5 -= tmp;
	ans += 4 * (a1 / 2) + 2 * a[2] + 4 * (a4 / 2 + a5 / 2);
	return ans;
}

int main() {
	for (int i = 1; i <= 7; i++) read(a[i]);
	LL ans = 0;
	ans = max(ans, solve1());
	ans = max(ans, solve2());
	printf("%lld\n", ans / 2);
	return 0;
}

Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws FileNotFoundException {

//    	File file = new File("src/in.txt");

        //コード
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int L = sc.nextInt();
    	int R = sc.nextInt();
    	int d = sc.nextInt();
    	int ans = 0;
    	sc.close();
    	for(int i=L;i<=R;i++) {
    		if(i%d==0) {
    			ans++;
    		}
    	}
    	System.out.println(ans);

    }
}


Measured memory_bytes: 35792
N = int(input())
scores = [int(input()) for _ in range(N)]

s = sum(scores)

if s % 10 == 0:
    non_10_multiples = [score for score in scores if score % 10 != 0]
    if len(non_10_multiples) == 0:
        s = 0
    else:
        s -= min(non_10_multiples)

print(s)


Measured memory_bytes: 9180
#include <stdio.h>

int main(){
	int r,g,b;
	scanf("%d %d %d",&r,&g,&b);
	if ( (100 * r + 10 * g + b )%4 == 0 ) {
		printf("YES");
	} else {
		printf("NO");
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main()
{
  int n, i, max=-1000000, min=1000000;
  double sum=0;
  scanf("%d",&n);
 
  int a;
 
  for(i=0;i<n;i++){
    scanf("%d",&a);
    if(a<min){min=a;}
    if(a>max){max=a;}
    sum = sum + a;
  }
 
 
 
  printf("%d %d %.0f\n", min, max, sum);
 
  return 0;
}

Measured memory_bytes: 632
#n=int(input())
n,x,y=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

#adjl=[[0 for i in range(n)] for j in range(n)]

dic={}

for i in range(n):
    for j in range(i,n):
        #if i>=j:
        #    continue
        dis=j-i
        maybe=abs(x-(i+1))+1+abs(y-(j+1))
        dis=min(dis,maybe)
        #adjl[i][j]=dis
        dic[dis]=dic.get(dis,0)+1

for k in range(1,n):
    print(dic.get(k,0))


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

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> pii;

#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)

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

    if(N%2==1){
        cout << 0 << endl;
        return 0;
    }

    N/=2;

    ll ret = 0;
    for(ll i=5;i<=N;i*=5){
        ret += N/i;
    }

    cout << ret << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1000000007
//S.size()

using namespace std;


typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;



int main(void){
  int n;cin>>n;
  int p[n];rep(i,n)cin>>p[i];
  int cnt = 0;
  for(int t = 0;t < n - 2;t++){
    if(p[t + 1] > p[t] && p[t + 1] < p[t + 2] ||p[t + 1] <
      p[t] && p[t + 1] > p[t + 2])cnt++;
  }
  cout<<cnt;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int x,y;
    while(1){
        cin>>x>>y;
        if(x > y){
            swap(x,y);
        }
        if(x == 0&&y == 0){
            break;
        }
        cout<<x<<" "<<y<<endl;
    }
    return 0;
}


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

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

	int k;
	cin >> k;

	int ret = 0;
	while (b <= a) {
		b *= 2;
		++ret;
	}
	while (c <= b) {
		c *= 2;
		++ret;
	}

	if (ret <= k) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3632
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

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

int main()
{
    int N;
    cin >> N;
    vector<string> vstring[9];
    int ans = 0;

    vstring[0].push_back("7");
    vstring[0].push_back("3");
    vstring[0].push_back("5");

    for (int i = 1; i < 9; i++)
    {
        for (int j = 0; j < vstring[i - 1].size(); j++)
        {
            vstring[i].push_back(vstring[i - 1][j] + "3");
            vstring[i].push_back(vstring[i - 1][j] + "5");
            vstring[i].push_back(vstring[i - 1][j] + "7");
        }
    }

    for (int i = 0; i < 9; i++)
    {
        for (int j = 0; j < vstring[i].size(); j++)
        {
            if (vstring[i][j].find("3") == std::string::npos)
            {
                continue;
            }
            if (vstring[i][j].find("5") == std::string::npos)
            {
                continue;
            }
            if (vstring[i][j].find("7") == std::string::npos)
            {
                continue;
            }
            if (atoi(vstring[i][j].c_str()) <= N)
            {
                ans++;
            }
        }
    }

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

Measured memory_bytes: 2172
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}

ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll div_num(ll n){
  vl div(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      div[i]++;
    }
  }
  if(n!=1)div[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=div[i];
  }
  return num;
}
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}
long long lopow(ll a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a ;
        a = a * a ;
        n >>= 1;
    }
    return res;
}

        
//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;
int main(){
  int N;cin>>N;
  vi dp(100001);
  rep(i,100001)dp[i]=i;
for(int n=1; n<= N;n++){
  dp[n] =min(dp[n],dp[n-1]+1);
  for(int i=1;i<=6*6*6*6*6*6;i*=6){
    if(i>n)continue;
    dp[n]=min(dp[n],dp[n-i]+1);
  }
  for(int i=1;i<=9*9*9*9*9;i*=9){
    if(i>n)continue;
    dp[n]=min(dp[n],dp[n-i]+1);
  }
  
}
   cout<<dp[N]<<endl;
  
}


Measured memory_bytes: 3844
#include <stdio.h>
#define N 1000001

int c[N] = {0}, a[200002];
char f[N] = {0};

int read()
{
	char c;
	while((c = getchar()) < 48 || c > 57);
	int x = c - 48;
	while((c = getchar()) > 47 && c < 58) x = x * 10 + c - 48;
	return x;
}

int main()
{		
	int n, m = 0, i, j, ans = 0, x;
		
	n = read();
	for(i = 0; i < n; i++){
		a[i] = x = read();
		if(x > m) m = x;
		c[x]++;
	}
	for(i = 1; i <= m; i++){
		if(!c[i]) continue;
		for(j = i << 1; j <= m; j += i) f[j] = 1;
	}
	for(i = 0; i < n; i++){
		x = a[i];
		if(c[x] == 1 && !f[x]) ans++;
	}
	printf("%d\n", ans);	
			
	return 0;
}

Measured memory_bytes: 7172
function main(input) {
   input = input.trim();
  const a = input.split(" ").map(Number);
  console.log(Math.max(a[0], Math.max(a[1], a[2]))
					 -Math.min(a[0], Math.min(a[1], a[2])));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 30396
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

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

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

int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    REP(i, 0, N) {
        cin >> P[i];
    }
    vector<int> memo(N + 2, -1);
    memo[N + 1] = 0;
    int ans = 0;
    for (int i = N - 1; i >= 0; i--) {
        if (memo[P[i] + 1] != -1) {
            memo[P[i]] = memo[P[i] + 1] + 1;
        } else {
            memo[P[i]] = 1;
        }
        ans = max(ans, memo[P[i]]);
    }
    cout << N - ans << endl;
    return 0;
}


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

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

    if(N == 2){
        cout << 0 << endl;
    }

    else{

    if(N % 2 == 1){
    cout << N/2 << endl;
    }

    else{
        cout << (N/2) -1 << endl;
    }

    }
}

Measured memory_bytes: 256
/*
 * main.c
 *
 *  Created on: 2020/02/22
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}


int A[200002] = {0};
ll v[200002] = {0};

int main()
{
	ll N = 0, i = 0, max = 0;
	scanf("%lld", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
		v[A[i]]++;
	}

	for (i = 1; i < 200002; i++) {
		if (v[i] != 0) {
			ll tmp = v[i];
			ll val = (tmp * (tmp -1))/2;
			max += val;
		}
	}
	//printf("max = %d\n", max);
	for (i = 0; i < N; i++) {
		ll ans = max, org = v[A[i]];
		//printf("org=%d\n", org);
		ll val = (org * (org -1))/2;
		ans -= val;
		//printf("val=%d\n", val);

		v[A[i]]--;
		val = (v[A[i]] * (v[A[i]] -1))/2;
		ans += val;
		//printf("val=%d\n", val);
		v[A[i]] = org;
		printf("%lld\n", ans);
	}

    return 0;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int y;

signed main(){
    cin>>y;
    cout<<48-y<<endl;
}


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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    s = ' ' + s;

    map<char, long long> m;
    m['R'] = 0;
    m['G'] = 0;
    m['B'] = 0;
    for (int i = 1; i <= n; i++) {
        if (s[i] == 'R') {
            m['R']++;
        } else if (s[i] == 'G') {
            m['G']++;
        } else if (s[i] == 'B') {
            m['B']++;
        }
    }

    long long total = m['R'] * m['G'] * m['B'];
    

    for (int i = 1; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            if (2*j-i <= n) {
                if (s[i] != s[j] && s[i] != s[2*j-i] && s[j] != s[2*j-i]) {
                    total--;
                }
            }
        }
    }

    cout << total << endl;

    return 0;
}


Measured memory_bytes: 3564
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my $s = <STDIN>);

while ($s =~ /^hi/) {
  $s =~ s/hi//;
}
my $ans = "No";
$ans = "Yes" if length($s)==0;
say $ans;

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
const int INF = 1e9;
const ll INFll = 1e18;
#define put(n) cout<<(n)<<endl
#define Cout(n) cout<<(n)
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);++(i))
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define MP make_pair
#define pb(q) push_back(q)
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};


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

    int H,W;
    cin>>H>>W;
    vector<vector<char>> C(H,vector<char>(W));
    vector<int> I(H,0),J(W,0);

    FOR(i,0,H){
        bool ok = false;
        FOR(j,0,W){
            cin>>C[i][j];
            if(C[i][j] == '#') ok = true; 
        }
        if(!ok) I[i] = 1;
    }

    FOR(j,0,W){
        bool ok = false;
        FOR(i,0,H){
            if(C[i][j] == '#') ok = true;
        }
        if(!ok) J[j] = true;
    }

    FOR(i,0,H){
        if(I[i]) continue;
        FOR(j,0,W){
            if(J[j]) continue;
            cout<<C[i][j];
        }
        cout<<endl;
    }



}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.split(" ").map(Number);
var a=arr[0];
var b=arr[1];
if(a===b){
console.log(a);
return;
}
var x=Math.max(a,b);
var y=Math.min(a,b);
var c=x%y;
if(c===0){
console.log(y);
return;
}
for(var i=c;i>=1;i--){
if(x%i==0 && y%i==0)break;
}
console.log(i);

Measured memory_bytes: 8700
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define mk make_pair
#define pb push_back
#define eps 1e-12
#define MAXN 200009
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	ll a[n+1];
	ll suf[n+10];
	suf[n+1]=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=n;i>=1;i--)
	{
		suf[i]=suf[i+1]+a[i];
	}
	ll s=0;
	ll ans=1e18;
	for(int i=1;i<n;i++)
	{
		s+=a[i];
		ans=min(ans,abs(s-suf[i+1]));
	}
	cout<<ans<<"\n";
}

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

#define N 10000

int Prime(int);

int main()
{
  int a[N],n,i,num;

  num=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  for(i=0;i<n;i++){
    if(Prime(a[i])) num++;
  }

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

  return 0;
}

int Prime(int n)
{
  int i;

  if(n==2) return 1;

  if(n<2 || n%2==0) return 0;

  i=3;

  while(i<=(int)sqrt(n)){
    if(n%i==0) return 0;

    i+=2;
  }
  return 1;
}

Measured memory_bytes: 628
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,i,flag,a[1000010],b[1000010];
char s[1000010];
int main(){
	scanf("%d",&n);
	scanf("%s",s);
	for(i=0;i<n;i++){
		a[i]=s[i]-'1';
		if(a[i]==1)flag=1;
		b[a[i]]+=(((n-1)&i)==i);
	}
	if(b[1]&1)puts("1"); 
	 else if(!flag&&b[2]&1)puts("2");
	  else puts("0");
}

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

class UnionFind {
public:
    vector<int> parent;
    vector<int> rank;

    UnionFind(int n) {
        parent.resize(n);
        rank.resize(n);
        for (int i = 0; i < n; i++) {
            parent[i] = i;
            rank[i] = 0;
        }
    }

    int find(int x) {
        if (parent[x] == x) {
            return x;
        } else {
            return parent[x] = find(parent[x]);
        }
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) {
            return;
        }

        if (rank[x] < rank[y]) {
            parent[x] = y;
        } else {
            parent[y] = x;
            if (rank[x] == rank[y]) {
                rank[x]++;
            }
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    UnionFind uf = UnionFind(N);
    for (int i = 0; i < M; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        uf.unite(x - 1, y - 1);
    }

    set<int> s;
    for (int i = 0; i < N; i++) {
        s.insert(uf.find(i));
    }

    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 5760
/*input
6 6 7
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}


int main()
{
	IOS;
	int a[3];
	REP(i,3) cin>>a[i];
	sort(a,a+3);
	cout<<a[0]+a[1]+10*a[2]<<'\n';
	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++)
typedef long long ll;
int main() {
    int n;
    cin>>n;
   vector<string> s(10);
   s[0]="pon";
   s[1]="pon";
   s[2]="hon";
   s[3]="bon";
   s[4]="hon";
   s[5]="hon";
   s[6]="pon";
   s[7]="hon";
   s[8]="pon";
   s[9]="hon";
   s[10]="pon";
   cout<<s[n%10]<<endl;
}

Measured memory_bytes: 3604
io = STDIN
n,k=io.gets.split.map(&:to_i)
a=io.gets.split.map(&:to_i)
ar= a.sort.chunk_while{|x,y|x==y}.sort_by{|x|x.size}.to_a
if  ar.size-k < 0
  puts 0
else
  puts ar.take(ar.size-k).flatten.size
end


Measured memory_bytes: 36964
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;

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

    ll  K;
    cin >> K;

    queue<ll> que;
    que.push(1);
    que.push(2);
    que.push(3);
    que.push(4);
    que.push(5);
    que.push(6);
    que.push(7);
    que.push(8);
    que.push(9);

    ll cnt=0;

    while(true){
        ll fro = que.front();
        // cout << fro << endl;
        que.pop();
        cnt++;
        if(cnt==K){
            ans = fro;
            break;
        }
        
        ll p = fro % 10; // 一番最後の数字

        // queueへの追加処理
        if(p!=0) que.push(10*fro+(p-1));
        que.push(10*fro+p);
        if(p!=9) que.push(10*fro+(p+1));

    }


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


Measured memory_bytes: 1792
def read():
    N, K = list(map(int, input().strip().split()))
    S = input().strip()
    return N, K, S


def solve(N, K, S):
    return S[:K-1] + S[K-1].lower() + S[K:]


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int N; scanf("%d",&N);
    vector<ll> A(N);
    rep(i,N)scanf("%lld",&A[i]);
    rep(i,N) A[i] -= i+1;

    sort(all(A));

    int b = (N&1) ? A[N/2] : (A[N/2-1] + A[N/2])/2;
    ll ans = 0;
    rep(i,N) ans += abs(b-A[i]);
    cout << ans << endl;
}


Measured memory_bytes: 1792
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()
a = [tuple(int(i) for i in input().split()) for _ in range(n)]

dp = [[0]*3 for i in range(n)]
dp[0][0] = a[0][0]
dp[0][1] = a[0][1]
dp[0][2] = a[0][2]
for i in range(1,n):
    for j in range(3):
        comp = []
        for k in range(3):
            if k==j:
                continue
            comp.append(dp[i-1][k] + a[i][j])

        dp[i][j] = max(comp)
print(max(dp[n-1]))


Measured memory_bytes: 40220
import sys


def parse(file):
    s = file.readline().strip()
    t = file.readline().strip()
    return s, t


def main(s, t):
    end = len(s) - len(t)
    for start in reversed(range(end + 1)):
        found = True
        for i in range(len(t)):
            if s[start + i] == t[i] or s[start + i] == '?':
                continue
            else:
                found = False
                break
        if not found:
            continue

        if found:
            ans = s[:start] + t + s[start+len(t):]
            return ans.replace('?', 'a')

    return 'UNRESTORABLE'


if __name__ == '__main__':
    print(main(*parse(sys.stdin)))

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int read() {
	int x; scanf("%d", &x); return x;	
}
const int maxn = 1e6 + 10;
const int INF = 1e9;
int mod = 1e9 + 7;
#define ll long long 
int n;
char s[10];
int main() {
	#ifdef LOCAL
		freopen("1.in", "r", stdin);
	#endif
	scanf("%s", s + 1);
	if (s[1] == 'R' && s[2] == 'R' && s[3] == 'R') cout << 3 << endl;
	else if (s[1] == 'R' && s[2] == 'R' || s[2] == 'R' && s[3] == 'R') cout << 2 << endl;
	else if (s[1] == 'S' && s[2] == 'S' && s[3] == 'S') cout << 0 << endl;
	else cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
#define maxn 1000010
#define ll long long
#define mod 1000000007
using namespace std;
int len[maxn], inv[maxn];
int main()
{
	int n;
	scanf("%d", &n);
	inv[1] = 1;
	for (int i = 2; i <= n || i <= 3; i++)
		inv[i] = ((ll)mod - mod / i) * inv[mod % i] % mod;
	for (int i = 1; i <= n; i++)
		len[i] = (len[i - 1] + (ll)inv[n] * inv[n - i + 1] % mod) % mod;
	for (int i = 1; i <= n; i++)
		len[i] = (ll)len[i] * inv[3] % mod;
	int cur = 1, res = 0, sum = 0;
	for (int i = 1; i <= n - 1; i++)
	{
		cur = (ll)cur * inv[3] % mod;
		int tmp = (ll)2 * cur % mod;
		sum = (sum + tmp) % mod;
		res = (res + (ll)tmp * len[i] % mod) % mod;
	}
	sum = (1 - sum + mod) % mod;
	res = (res + (ll)sum * len[n] % mod) % mod;
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 8064
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define INF 1000000000
#define MOD 998244353
int n, fact[364364], ans;
int k;
int modpow(int a, int b) {
	if (b == 0)return 1;
	if (b % 2)return modpow(a, b - 1)*a%MOD;
	return modpow(a, b / 2)*modpow(a, b / 2) % MOD;
}
int comb(int x) {
	return fact[n] * modpow(fact[x], MOD - 2) % MOD*modpow(fact[n - x], MOD - 2) % MOD;
}
signed main() {
    int a,b;
	cin >> n >> a >> b >> k;
	fact[0] = 1;
	for (int i = 1; i <= n; i++)fact[i] = fact[i - 1] * i%MOD;
	rep(i, n + 1) {
		if ((k - a * i) % b!=0)continue;
		if ((k - a * i) / b > n||(k-a*i)/b<0)continue;
		int x = i, y = (k - a * i) / b;
		ans += comb(x) * comb(y)%MOD;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int N, Q;
    while (cin >> N >> Q && N && Q) {
        vector<int> date(101, 0);
        for (int i=0; i<N; ++i) {
            int M, d;
            cin >> M;
            for (int j=0; j<M; ++j) {
                cin >> d;
                date[d] ++;
            }
        }
        int k = max_element(date.begin(), date.end()) - date.begin();
        cout << (Q <= date[k] ? k : 0) << endl;
    }

    return 0;
}

Measured memory_bytes: 1196