akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	scanner := makeWordScanner()
	a := eGetInt(scanner)
	b := eGetInt(scanner)
	ans := []bool{true, true, true}
	ans[a-1], ans[b-1] = false, false
	for i, e := range ans {
		if e {
			fmt.Println(i + 1)
			break
		}
	}
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeCharScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanRunes)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func pow(a, n int) int {
	return int(math.Pow(float64(a), float64(n)))
}
func countBitOfOn(i, numbits int) int {
	count := 0
	var bit uint64
	for bit = 0; bit < uint64(numbits); bit++ {
		t := 1 << bit
		if i&t > 0 {
			count++
		}
	}
	return count
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N, K;
    int Ah[200];
    MEMSET(Ah, 0);
    cin>>N>>K;
    rep(i, K){
        ll d;
        cin>>d;
        rep(j, d){
            ll A;
            cin>>A;
            Ah[A-1]=1;
        }
    }
    ll count=0;
    rep(i, N){
        if(Ah[i]==0) count++;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int n;
int main() {
	cin>>n;
	bool f=0;
	while(n) {
		if(n%10==9)
			f=1;
		n/=10;
	}
	if(f)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 764
import java.io.*;

class Main{
    public static void main(String[] args)throws IOException{
        int i = 0, x;

        InputStreamReader isr =new InputStreamReader(System.in);
   		BufferedReader br =new BufferedReader(isr);
    	String buf = br.readLine();
    	x = Integer.parseInt(buf);
        
        while(true) {
        	if (x == 0) break;
            i++;
        	System.out.printf("Case %d: %d\n", i, x);
        	buf = br.readLine();
    		x = Integer.parseInt(buf);
    	}
    }
}

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

int main(void)
{
        int n,c,oomoji;
        int i;
        char s[12];

        scanf("%s",s);

        n = strlen(s);

        //A,C以外が小文字か確認
        i=0;
        oomoji = 0;
        while(s[i]!='\0'){
                if(s[i]>='A' && s[i]<='Z')
                        oomoji++;
                i++;
        }
        if(oomoji!=2){
                printf("WA\n");
                return 0;
        }


        //Aが先頭にあるか確認
        if(s[0]!='A'){
                printf("WA\n");
                return 0;
        }


        //Cが一つか確認
        c = 0;
        i = 2;
        while(i<n-1){
                if(s[i]=='C')
                        c++;
                i++;
        }
        if(c==0 || c>1){
                printf("WA\n");
                return 0;
        }


        printf("AC\n");
        return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

#define min(a, b) ((a < b)?(a):(b))
#define max(a, b) ((a > b)?(a):(b))

int main() {
    int i;
    int n;

    scanf("%d", &n);

    for (i=0; i<n; i++) {
        unsigned long long int x, y, b, p;
	unsigned long long int sum1;
	unsigned long long int sum2;

        scanf("%llu %llu %llu %llu", &x, &y, &b, &p);
	sum1 = x * b + y * p;
	sum2 = x * max(b, 5) + y * max(p, 2);
	sum2 /= 5;
	sum2 *= 4;

        if (b >= 5 && p >= 2) {
	    sum1 /= 5;
	    sum1 *= 4;
	}

	printf("%llu\n", min(sum1, sum2));
    }
}

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

int main() {
    int x,y,r,W,H;
    
    cin>>W>>H>>x>>y>>r; 
    
    if (r<=x && x<=W-r && r<=y && y<=H-r){
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
}
    
        
    return 0;        
         
}

Measured memory_bytes: 1160
[x1,y1,x2,y2] = list(map(int,input().split()))

D = ((x1-x2)**2 + (y1-y2)**2)**(1/2)

x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)

x4 = x3 - (x2 - x1)
y4 = y3 - (y2 - y1)

print(x3,y3,x4,y4)


Measured memory_bytes: 61980
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 1000000000
#define MOD 1000000007
#define ll long long int
using namespace std;


//累乗を高速に（MODとってないよ！！！！！！）
ll my_pow(ll a,ll b){
  ll res;
  if(b==1) return a;
  if(b % 2 == 0){
    res = my_pow(a,b/2);
    return res * res;
  } else {
    res = my_pow(a,b/2);
    return res * res * a;
  }
}

int main(){

  ll x;cin>>x;

  ll ans =1;

  for(ll b=1;b<=100;b++){
    for(ll p=2;p<=100;p++){
      ll pre = my_pow(b,p);
      if(pre > x) break;
      ans = max(ans,pre);


    }
  }
cout<<ans<<endl;


 return 0;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

const long long INF = 1e18;

int N, W;

long long dp[105][100005];

long long wt[105];

long long val[105];



int32_t main()
{



	cin >> N >> W;


	for (int i = 0; i < N; ++i) {

		cin >> wt[i] >> val[i];
	}




	// for (int i = 0; i <= N; ++i)
	// 	for (int j = 0; j <= 100005; ++j)
	// 		dp[i][j] = INF;



	for (int i = 0; i <= N; ++i)
		dp[i][0] = 0;


	for (int i = 0; i <= 100000; i++)
		dp[0][i] = INF;


	dp[0][0] = 0;


	for (int i = 1; i <= N; ++i)
	{

		for (int j = 1; j <= 100000; ++j)
		{

			if (val[i - 1] <= j)
				dp[i][j] = min(dp[i - 1][j], wt[i - 1] + dp[i - 1][j - val[i - 1]]);
			else dp[i][j] = dp[i - 1][j];

		}


	}


	long long ans;


	for (int val = 100000; val >= 0; --val) {

		if (dp[N][val] <= W) {

			ans = val;
			break;
		}
	}



	cout << ans << endl;


}

Measured memory_bytes: 82560
#include <bits/stdc++.h>
#define md 1000000007
#define fi first
#define se second
#define mp make_pair
#define	inf 1000000000
#define li 100005
#define lo long long
#define pb push_back
using namespace std;
int A[8],tp[80];
int main(){
	for(int i=1;i<=4;i++) {scanf("%d",&A[i]);tp[A[i]]++;}
	if(tp[1]==1 && tp[4]==1 && tp[9]==1 && tp[7]==1) printf("YES\n");
	else printf("NO\n");
	return 0;
}


Measured memory_bytes: 256
N,A = (int(T) for T in input().split())
X = [int(T)-A for T in input().split()]
DP = [[0]*(2*(50*N)+1) for TI in range(0,N+1)]
DP[0][50*N] = 1
for TI in range(0,N):
    for TS in range(0,2*50*N+1):
        if DP[TI][TS]!=0:
            DP[TI+1][TS] += DP[TI][TS]
            DP[TI+1][TS+X[TI]] += DP[TI][TS]
print(DP[N][50*N]-1)

Measured memory_bytes: 69552
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    int N, M, P; cin >> N >> M >> P;
    vector<Int> A(M), B(M), C(M);
    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i] >> C[i];
        A[i]--, B[i]--;
        C[i] = P - C[i];
    }
    const Int INF = 1e18;
    vector<Int> dist(N, INF);
    dist[0] = 0;
    for (int i = 0; i < N-1; i++) {
        for (int j = 0; j < M; j++) {
            if (dist[A[j]] == INF) continue;
            dist[B[j]] = min(dist[B[j]], dist[A[j]] + C[j]);
        }
    }
    Int distN = dist[N-1];
    for (int j = 0; j < M; j++) {
        if (dist[A[j]] == INF) continue;
        if (dist[B[j]] > dist[A[j]] + C[j]) {
            dist[B[j]] = -INF;
        }
    }
    for (int i = 0; i < N-1; i++) {
        for (int j = 0; j < M; j++) {
            if (dist[A[j]] == INF) continue;
            dist[B[j]] = min(dist[B[j]], dist[A[j]] + C[j]);
        }
    }
    if (distN > dist[N-1]) {
        cout << -1 << endl;
    } else {
        cout << max(0LL, -dist[N-1]) << endl;
    }
    return 0;
}


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

const int INF = 1012345678;


int main()
{
	int a, b = 0;
	cin >> a >> b;
	int ans = 0;
	for (int i = a; i <= b; i++)
	{
		string str = to_string(i);
		string rev = str;
		reverse(rev.begin(), rev.end());
		if (str == rev)
		{
			ans++;
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int main() {
    int n,q;
    string s;
    cin >> n >> s >> q;


    for (int i=0; i<q; i++) {
        int k;
        cin >> k;

        long ans = 0;
        long r = 0;
        long d = 0;
        long m = 0;
        long dm = 0;
        for (int l=0; l<n; l++) {
            if (r<l) r = l;
            while(r<n && r-l<k) {
                if (s[r] == 'D') d++;
                if (s[r] == 'M') m++,dm+=d;
                if (s[r] == 'C') ans += dm;
                r++;
            }
            if (s[l] == 'D') d--,dm-=m;
            if (s[l] == 'M') m--;
        }
        cout << ans << endl;
    }
}


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

typedef long long ll;

template<class T> inline void chmin(T &a, T b) {if(a > b) a = b;}

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

    ll n;
    cin >> n;
    ll dp[100100];
    const ll INF = 1LL<<60;
    for(ll i=0;i<100100;i++) dp[i] = INF;
    dp[0] = 0LL; dp[1] = 1LL;
    const ll uku[] = {6,36,216,1296,7776,46656};
    const ll ushi[] = {9,81,729,6561,59049};
    for(ll i=2;i<=n;i++){
        chmin(dp[i],dp[i-1]+1);
        for(ll j=0;j<6;j++){
            if(i-uku[j]>=0) chmin(dp[i],dp[i-uku[j]]+1);
            if(j<5 && i-ushi[j]>=0) chmin(dp[i],dp[i-ushi[j]]+1);
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1024
#![allow(unused_imports)]
#![allow(dead_code)]
use std::io::prelude::*;
use std::collections::{BinaryHeap, HashSet};
 
const MOD: i64 = 1e9 as i64 + 7;
 
fn main(){
    let s : String = read();
    let _t : String = read();
    let mut n : i32 = read();
    let mut m : i32 = read();
    let u : String = read();
    if s == u {
        n -= 1;
    }
    else{
        m -= 1;
    }
    println!("{} {}", n, m);
}
 
fn read<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define INF (int)1e9+1
#define INFLL (int)1e18+1
#define sz(bb) (int)bb.size()
#define all(qq) qq.begin(), qq.end() 
#define Max(a, b, c) max(a, max(b, c))
#define Min(a, b, c) min(a, min(b, c))
const double PI=acos(-1);
// #define int unsigned long long int//used when x<=2^64-1 && x>0
#define int long long//used when x<=2^63-1
//bool cmp if returns true it keeps 1st as first else swaps
typedef long long  ll;

void solve()
{
    int n;
    cin>>n;
    double prob[n];
    for(int i=0;i<n;i++)
        cin>>prob[i];
    double dp[n+1][n+1];// dp[i][j] means till toss 'i' times having 'j' heads 
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        dp[i][0]=(1-prob[i-1])*dp[i-1][0];
        dp[0][i]=0;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            dp[i][j]=prob[i-1]*(dp[i-1][j-1]); //heads
            dp[i][j]+=(1-prob[i-1])*(dp[i-1][j]);
        }
    }
    double ans=0;
    for(int i=n/2+1;i<=n;i++)
    {
        ans+=dp[n][i];
    }
    cout<<setprecision(10)<<ans<<"\n";
}
int32_t main()
{
    IOS;
    int t;
    // cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 74072
import sys
from operator import itemgetter

sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return map(int, input().split())
def lmi(): return list(map(int, input().split()))
def iif(n): return [int(input()) for _ in range(n)]
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]
def ss(): return input().split()

def main():
    mod = 1000000007
    
    N = ii()
    ans = [0] * N

    xyz = range(1, 101)
    for x in xyz:
        for y in xyz:
            for z in xyz:
                tmp = x*x + y*y + z*z + x*y + y*z + z*x
                if tmp <= N:
                    ans[tmp-1] += 1
    
    print(*ans, sep="\n")

    return

main()


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

using namespace std;

const int N = 22, M = 1000000007;
vector <int> v[N];
int a[N][N], dp[N][1<<N];

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			scanf("%d", &a[i][j]);
		}
	}
	for (int i = 0; i < (1 << n); i++) {
		v[__builtin_popcountll(i)].push_back(i);
	}
	for (int i = 0; i < n; i++) {
		int idx = i, sz = v[idx].size();
		for (int j = 0; j < sz; j++) {
			int mask = v[idx][j];
			for (int k = 0; k < n; k++) {
				if (((1<<k) & mask) == 0) {
					if (a[i][k]) {
						if (i > 0) {
							dp[i][mask | (1<<k)] += dp[i-1][mask];
							dp[i][mask | (1<<k)] %= M;
						} else {
							dp[i][mask | (1<<k)] += 1;
							dp[i][mask | (1<<k)] %= M;
						}
					}
				}
			}
		}
	}
	printf("%d", dp[n-1][(1<<n)-1]);
	return 0;
}


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

int main() {
  
  int X = 0;
  int M, D;
  
  cin >> M >> D;
  
  for (int m = 1; m <= M; m++) {
   
    for (int d = 1; d <= D; d++) {
      
      int d10 = d / 10;
      int d1 = d % 10;
        
      
        if (d1 > 1 && d10 > 1 && d1 * d10 == m){
          X++;
        }
  
    }
  }
  
  cout << X << endl;
  
}


Measured memory_bytes: 256
#include<iostream>

int gcd(int x, int y){
    while(x%y!=0){
        int z;
        z = x % y;
        x = y;
        y = z;
        gcd(x,y);
    }
    return y;
}

int main(){
    int x,y;
    std::cin >> x;
    std::cin >> y;
    std::cout << gcd(x,y) << '\n';
    return 0;
}


Measured memory_bytes: 3100
while True:
    a,op,b=input().split()
    a=int(a)
    b=int(b)

    if op=="?":
         break
    if op=="+":
        print(a+b)
    if op=="-":
        print(a-b)
    if op=="*":
        print(a*b)
    if op=="/":
        print(a//b)


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

class C
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
		var r = Enumerable.Range(10 * h[1], 10).FirstOrDefault(x => (int)(0.08 * x) == h[0]);
		Console.WriteLine(r > 0 ? r : -1);
	}
}


Measured memory_bytes: 28348
#include<iostream>
using namespace std;
#define MAX 200000
#define SENTINEL 1000000001                                               

typedef long long ll;

int L[MAX/2+2],R[MAX/2+2];

ll merge(int A[],int n,int left,int mid,int right){    
    int i,j,k;
    ll cnt=0;
    int n1=mid-left;
    int n2=right-mid;
    for(i=0;i<n1;i++)L[i]=A[left+i];
    for(i=0;i<n2;i++)R[i]=A[mid+i];
    L[n1]=R[n2]=SENTINEL;
    i=j=0;
    for(k=left;k<right;k++){
        if(L[i]<=R[j])  A[k]=L[i++];
        else{
            A[k]=R[j++];
            cnt+=n1-i;
        }   
    }        
    return cnt;
}
ll mergeSort(int A[],int n,int left,int right){
    int mid;
    ll v1,v2,v3;
    if(left+1<right){
        mid=(left+right)/2;
        v1=mergeSort(A,n,left,mid);
        v2=mergeSort(A,n,mid,right);
        v3=merge(A,n,left,mid,right);
        return v1+v2+v3;
    }   
    else return 0 ; 
}
int main(){
    int A[MAX],n,i;
    cin>>n;
    for(i=0;i<n;i++)
        cin>>A[i];
    ll ans=mergeSort(A,n,0,n);
    cout<<ans<<"\n";
    return 0;
}        


Measured memory_bytes: 4620
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

static large solve_neg_result(std::vector<int> Ns, std::vector<int> Ps, large k) {
    sort(Ns.rbegin(), Ns.rend());
    auto R = large(Ns.front()) * Ps.front();   // |Ns|*|Ps| pairs
    auto L = large(Ns.back()) * Ps.back() - 1; // 0 pairs

    const auto count_le = [&](const large thrs) {
        auto cnt = 0LL;
        auto j0 = int(Ps.size()) - 1;
        auto j = j0;
        for (auto i = 0; i < Ns.size(); ++i) {
            auto x = large(Ns[i]);
            while (0 <= j && x * Ps[j] <= thrs) {
                --j;
            }
            cnt += j0 - j;
        }
        return cnt;
    };

    while (L + 1 < R) {
        auto M = L + (R - L) / 2;
        auto mc = count_le(M);
        if (mc < k)
            L = M;
        else
            R = M;
    }

    return R;
}

static large solve_pos_result(std::vector<int> Ns, std::vector<int> Ps, large k) {
    sort(Ns.rbegin(), Ns.rend());

    auto R = 0LL;
    auto L = -1LL;
    if (Ns.size() >= 2) {
        R = max(R, large(Ns[Ns.size() - 1]) * Ns[Ns.size() - 2]);
    }
    if (Ps.size() >= 2) {
        R = max(R, large(Ps[Ps.size() - 1]) * Ps[Ps.size() - 2]);
    }

    const auto count_le = [&](const large thrs, const vector<int>& v) {
        auto cnt = 0LL;
        auto i = 0;
        auto j0 = int(v.size()) - 1;
        auto j = j0;
        for (; i < v.size() && i < j; ++i) {
            auto x = large(v[i]);
            while (j > i && x * v[j] > thrs) {
                --j;
            }
            cnt += (j - i);
        }
        return cnt;
    };

    while (L + 1 < R) {
        auto M = L + (R - L) / 2;
        auto mp = count_le(M, Ps);
        auto mn = count_le(M, Ns);
        auto mc = mp + mn;
        if (mc < k)
            L = M;
        else
            R = M;
    }

    return R;
}

static large solve(const large n, const large k, std::vector<int> a) {
    auto negatives = vector<int>();
    auto positives = vector<int>();
    auto zeros = 0;

    for (auto a_i : a) {
        if (a_i < 0)
            negatives.push_back(a_i);
        if (a_i > 0)
            positives.push_back(a_i);
        if (a_i == 0)
            zeros++;
    }

    auto neg_product_count = negatives.size() * positives.size();
    auto zero_product_count = (negatives.size() + positives.size()) * zeros + (zeros * (zeros - 1) / 2);
    auto pos_product_count = (n * (n - 1) / 2) - neg_product_count - zero_product_count;

    if (k <= neg_product_count) {
        return solve_neg_result(move(negatives), move(positives), k);
    }

    if (k <= neg_product_count + zero_product_count) {
        return 0;
    }

    return solve_pos_result(move(negatives), move(positives), k - neg_product_count - zero_product_count);
}

int main() {
    large n, k;
    cin >> n >> k;

    auto a = vector<int>(n);
    for (auto& a_i : a)
        cin >> a_i;
    sort(a.begin(), a.end());
    cout << solve(n, k, move(a));
    return 0;
}

Measured memory_bytes: 5020
a,b,c,x,y = map(int, input().split(" "))
sum = 0
if a+b >= c*2:
    v = min(x, y)
    for i in range(v):
        sum += 2*c
    x -= v
    y -= v

if a < c*2:
    sum += a*x
if b < c*2:
    sum += b*y
if a >= c*2:
    sum += 2*c*x
if b >= c*2:
    sum += 2*c*y
print(sum)

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

int main() {
  int x, y; cin >> x >> y;
  int d = abs(abs(x) - abs(y));
  int ans = d;
  if (x > y) {
    ans++;
    if (y < 0 && x < 0) ans++;
    if (y > 0 && x > 0) ans++;
  }
  if (y > 0 && x < 0) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  ll c, k;
  cin >> c >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(ALL(a));
  ll limit = a[0] + k;
  int ans = 1;
  int pp = 0;
  rep(i, n){
    if(a[i] > limit || pp >= c){
      ans++;
      limit = a[i] + k;
      pp = 1;
    }else{
      pp++;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3972
//by yjz
#include<bits/stdc++.h>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
typedef long long ll;
using namespace std;
int n, M, V, P;
int a[100111];
bool check(int p)
{
	int K = n-V;
	ll tot = 1ll*K*M;
	int rk = 1;
	for (int i=p+1; i<=n; i++)
	{
		if (a[i]>a[p])
		{
			ll lft = a[i]-a[p];
			ll t = min((ll)M, min(lft, tot));
			tot -= t;
			lft -= t;
			if (lft>0) rk++;
		}
	}
	return rk<=P;
}
int main()
{
	scanf("%d", &n);
	scanf("%d%d%d", &M, &V, &P);
	for (int i=1; i<=n; i++) scanf("%d", &a[i]);
	sort(a+1, a+n+1);
	int l = 1, r = n;
	while (l<=r)
	{
		int m = l+r>>1;
		if (check(m)) r = m-1;
		else l = m+1;
	}
	cout<<n-r<<endl;
	return 0;
}

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	os << "{";
	rep(i, (int)v.size()) {
		if (i)
			os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
	for (auto val : array)
		std::cout << val << ", ";
	std::cout << "\n";
}

const int MOD = 1'000'000'000 + 7;
const int INF = 1'000'000'000 + 5;

const int MAX = 8;
int n;
int x[MAX], y[MAX];
int route[8];
bool isVisited[8];
double sum;

void calc() {
	double tmp = 0;
	rep(i, n-1) {
		int s = route[i], d = route[i+1];
		double x2 = (x[s] - x[d]) * (x[s] - x[d]);
		double y2 = (y[s] - y[d]) * (y[s] - y[d]);
		tmp += sqrt(x2 + y2);
	}
	sum += tmp;
}

void dfs(int d) {
	if (d == n)
		calc();
	rep(i, n) {
		if (isVisited[i]) continue;
		isVisited[i] = true;
		route[d] = i;
		dfs(d + 1);
		isVisited[i] = false;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(16);

	std::cin >> n;
	rep(i, n)
		std::cin >> x[i] >> y[i];
	dfs(0);
	double ans = sum;
	rrep(i, n)
		ans /= i;
	std::cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using tii = tuple<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m, fsum = 0, bsum = 0;
	cin >> n >> m;
	ll ans = 0, w = 0,h = 0;
	vl x(n), y(m);
	rep(i, n) {
		cin >> x[i];
	}
	rep(i, m) {
		cin >> y[i];
	}
	rep(i, n-1) {
		ll tmp= ((x[i + 1] - x[i])*(i + 1) % MOD*(n - i - 1)) % MOD;
		w += tmp;
		w %= MOD;
	}
	rep(i, m-1) {
		ll tmp= ((y[i + 1] - y[i]) * (i + 1) % MOD*(m - i - 1)) % MOD;
		h += tmp;
		h %= MOD;
	}
	//cout << w << " " <<h<< endl;
	cout << h*w%MOD << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> V;

#define _ cin.tie(0);ios::sync_with_stdio(false);
int n;

int main(){ _;
  cin>>n;
  int a=1;
  while(a<=(n/2))
    a*=2;
  cout<<a<<endl;

  return 0;
}


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

using namespace std;
#define ull unsigned long long
#define si short int
#define ll long long
#define pii pair<int, int>

/*-----------------------------------------------------MATH------------------------------------------------*/
inline ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
inline int pwm(ll xx, ll pow, int MD) {
    if (pow < 0) { pow = pow % (MD - 1) + MD - 1; }
    ll mlt = 1;
    while (pow) {
        if (pow & 1) {
            mlt *= xx;
            mlt %= MD;
        }
        xx *= xx;
        pow >>= 1;
        xx %= MD;
    }
    return (int) mlt;
}
inline ll gcdex(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll xx, yy;
    ll gc = gcdex(b, a % b, yy, xx);
    x = xx;
    y = yy - (a / b) * xx;
    return gc;
}
inline int inv(ll r, int _mod) { return pwm(r % _mod, _mod - 2, _mod); }
/*-----------------------------------------------------MATH------------------------------------------------*/

const int inf = 1e9;
const int MAXN = 2e5 + 10;
ll mod = 1e9 + 7;
vector<vector<int>> vert(400, vector<int>(0));
vector<string> arr;
vector<bool> was(400);
int dist(int a, int b){
    if(a==b) return 0;
    list<pair<int, int>> list1;
    list1.push_back({a,0});
    for(int i=0;i<400;i++){
        was[i]=false;
    }
    was[a]=true;
    while(!list1.empty()){
        int s=list1.front().first;
        int dist=list1.front().second;
        if(s==b) return dist;
        list1.pop_front();
        for(int son:vert[s]){
            if(!was[son]) {
                list1.push_back({son, dist+1});
                was[son]=true;
            }
        }
    }
}
void solve(){
    int n,m;
    cin>>n>>m;
    int ans=0;
    arr.resize(n);
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        arr[i]=s;
        for(int j=0;j<m;j++){
            if(s[j]=='#') continue;
            if(j!=0){
                if(s[j-1]==s[j]){
                    vert[i*m+j].push_back(i*m+j-1);
                    vert[i*m+j-1].push_back(i*m+j);
                }
            }
            if(i!=0){
                if(arr[i-1][j]==s[j]){
                    vert[(i-1)*m+j].push_back(i*m+j);
                    vert[i*m+j].push_back((i-1)*m+j);
                }
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++) {
            for (int k = 0; k < n; k++) {
                for (int d = 0; d < m; d++) {
                    if(arr[k][d]=='#' || arr[i][j]=='#') continue;
                    ans=max(dist(k*m+d, i*m+j), ans);
                }
            }
        }
    }
    cout<<ans;

}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n=1;
    for (int i = 0; i < n; i++) solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define all(e) e.begin(), e.end()
#define vi vector<int>
#define vd vector<double>

//ここからAtCoder向けdefine
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;

typedef long long ll;
typedef unsigned long long ull;

const int INF = ~(1 << 31);

using namespace std;

int a = 100001;

int num[100001];

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

    int n;
    cin >> n;
    vi vec(n);
    rep(i, n){
        cin >> vec[i];
        if(vec[i] > a){ num[a]++; }
        else{ num[vec[i]]++; }
    }

    int cnt = 0;
    int b;
    REP(i, 1, a - 1){
        if(num[i] != i || num[i] != 0){
            b = max(num[i] - i, num[i] % i);
            cnt += b;
        }
    }
    cnt += num[a];
    cout << cnt << endl;

    return 0;
}

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

int main()
{
	int w, n, a, b;
	char abdata;
	int wdata[1000];
	cin >> w >> n;
	for (int i = 0; i < w; i++) {
		wdata[i] = i+1;
	}
	for (int k = 0; k < n; k++) {
		int data;
		cin >> a >> abdata >> b;
		data = wdata[a-1];
		wdata[a-1] = wdata[b-1];
		wdata[b-1] = data;
	}
	for (int y = 0; y < w; y++) {
		cout << wdata[y] << endl;
	}
}

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

#define mp make_pair
const int N = 2000;
int l[N+100][N+100],r[N+100][N+100],u[N+100][N+100],d[N+100][N+100];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int w,h;
	cin >> h >> w;
	string s[h+5];
	for(int i=0;i<h;i++)cin >> s[i];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(s[i][j]=='#')l[i][j] = j;
			else{
				if(j==0)l[i][j] = -1;
				else{
					l[i][j] = l[i][j-1];
				}
			}
		}
	}
	for(int i=0;i<h;i++){
		for(int j=w-1;j>=0;j--){
			if(s[i][j]=='#')r[i][j] = j;
			else{
				if(j==w-1)r[i][j] = w;
				else{
					r[i][j] = r[i][j+1];
				}
			}
		}
	}
	for(int j=0;j<w;j++){
		for(int i=0;i<h;i++){
			if(s[i][j]=='#')u[i][j] = i;
			else{
				if(i==0)u[i][j] = -1;
				else{
					u[i][j] = u[i-1][j];
				}
			}
		}
	}
	for(int j=0;j<w;j++){
		for(int i=h-1;i>=0;i--){
			if(s[i][j]=='#')d[i][j] = i;
			else{
				if(i==h-1)d[i][j] = h;
				else{
					d[i][j] = d[i+1][j];
				}
			}
		}
	}
	int ans = 0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(s[i][j]=='.'){
				int t1 = j-1-l[i][j];
				int t2 = r[i][j]-(j+1);
				int t3 = i-1-u[i][j];
				int t4 = d[i][j]-(i+1);
				//cout << t1 << " " << t2 << " " << t3 << " " << t4 << "\n";
				ans = max(ans,t1+t2+t3+t4+1);
			}
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 72576
x,y=(int(x) for x in input().split())
b = 0
if x == 1:
    b += 300000
elif x == 2:
    b += 200000
elif x == 3:
    b += 100000
else:
    b += 0
if y == 1:
    b += 300000
elif y == 2:
    b += 200000
elif y == 3:
    b += 100000
else:
    b += 0
if x == 1 and y == 1:
    b += 400000

print(b)

Measured memory_bytes: 3060
from collections import Counter
S = input()
CS = Counter(S)
a = CS["a"]
b = CS["b"]
c = CS["c"]
a, b, c = sorted([a,b,c])
if a == 0 and b == 0:
    if c == 1:
        print("YES")
    else:
        print("NO")
elif a == 0:
    if c <= 1:
        print("YES")
    else:
        print("NO")
else:
    if c-a<=1:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 3444
use v5.18;
use warnings;
sub read_line { chomp(my $s = <>); $s }
sub splited_read_line { split / /, read_line }
my $n = read_line;
my @r = map { my ($s, $p) = splited_read_line; +{ s => $s, p => $p, n => $_ + 1 } } 0 .. $n - 1;
say $_->{n} for sort { $a->{s} eq $b->{s} ? $b->{p} <=> $a->{p} : $a->{s} cmp $b->{s} } @r;


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

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N);
  vector<int> y(M);
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }
  for (int i = 0; i < M; i++) {
    cin >> y[i];
  }
  int Xmax = X;
  int Ymin = Y;
  for (int i = 0; i < N; i++) {
    Xmax = max(Xmax, x[i]);
  }
  for (int i = 0; i < M; i++) {
    Ymin = min(Ymin, y[i]);
  }

  if (Xmax < Ymin) cout << "No War" << endl;
  else  cout << "War" << endl;
}

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

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

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

    int *ms = new int[m];
    for (int k = 0; k < m; ++k) {
        cin >> ms[k];
    }

    for (int j = 0; j < n; ++j) {
        int tmp = 0;
        for (int i = 0; i < m; ++i) {
            tmp += ns[j][i] * ms[i];
        }
        cout << tmp << endl;
    }

    for (int j = 0; j < n; ++j) {
        delete[] ns[j];
    }
    delete[] ns;
    delete[] ms;
    return 0;
}

Measured memory_bytes: 1236
N,T = map(int,input().split())
A = list(map(int,input().split()))
B = []
mini = 0
for i in range(N):
    if A[i] < A[mini]:
        mini = i
    B.append(A[i]-A[mini])
m = max(B)
ans = 0
for i in B:
    if i == m:
        ans += 1
print(ans)

Measured memory_bytes: 14292
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,in;
	cin>>n;
	vl v(n+1,LINF);
	rep(i,n){
		cin>>in;
		*lower_bound(all(v),in)=in;
	}
	cout<<lower_bound(all(v),LINF)-v.begin()<<endl;

	
}


Measured memory_bytes: 3532
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
struct edge{
	int to,nt;
}e[N<<1];
int ans[N],d[N],a[N],cnt=1,h[N],n;
void add(int u,int v){
	e[cnt]={v,h[u]};
	h[u]=cnt++;
}
void dfs(int u,int fa){
	int p=lower_bound(d+1,d+n+1,a[u])-d;
	int tmp=d[p];
	d[p]=a[u];
	ans[u]=max(ans[fa],p);
	for(int i=h[u];i;i=e[i].nt)
	{
		 int v=e[i].to;
		 if(v==fa) continue;
		 dfs(v,u);
	}
	d[p]=tmp;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1,u,v;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		add(u,v),add(v,u);
	}
	memset(d,0x3f,sizeof d);
	dfs(1,0);
	for(int i=1;i<=n;i++)
		printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 24268
n = int(input())

now_mod = 0

if n % 2 == 0:
    print(-1)
    exit()

for i in range(1, n+1):
    now_mod *= 10
    now_mod += 7
    now_mod %= n
    if now_mod == 0:
        print(i)
        exit()

print(-1)
exit()


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

int main() {
    int K;
    string S;
    cin >> K >> S;

    if (S.length() <= K){
        cout << S << endl;
    } else{
        cout << S.substr(0, K) + "..." << endl;
    }
	return 0;
}

Measured memory_bytes: 3600
from itertools import groupby

S = input()
T = [len(tuple(v)) for _, v in groupby(S)]

ans = []
for i in range(0, len(T), 2):
    r, l = T[i:i + 2]
    t = (r + 1) // 2 + l // 2
    ans += [0] * (r - 1) + [t, r + l - t] + [0] * (l - 1)

print(*ans)


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

int main() {
  string s; cin >> s;
  
  int want = 753;
  
  int ans = abs(want - std::stoi(s.substr(0,3)));
  for(int i = 1; i < s.size() - 2; i++){
    int temp = abs(want - std::stoi(s.substr(i,3)));
    if(ans > temp) ans = temp;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(void){
	int i, j, n, m, c, s, b[300], a[300][300], count;
	scanf("%d %d %d", &n, &m, &c);
	for(i=0; i<m; i++){
		scanf("%d", &b[i]);
	}
	for(i=0; i<n; i++){
		for(j=0; j<m; j++){
			scanf("%d", &a[i][j]);
		}
	}
	count = 0;
	for(i=0; i<n; i++){
		s = 0;
		for(j=0; j<m; j++){
			s += a[i][j] * b[j];
		}
		s += c;
		if(s > 0)	count++;
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
//long long num[100000];
ll gcd(ll a, ll b){
  if(b==0) return a;
  return gcd(b,a%b);
}
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a*b/g;
}
int main(){
  ll n,ans=0;
  cin>>n;
  ll a[n],b[n],c[n];
  for(int i=0;i<n;i++)  cin>>a[i];
  for(int i=0;i<n;i++)  cin>>b[i];
  for(int i=0;i<n;i++)  cin>>c[i];
  sort(a,a+n);
  sort(b,b+n);
  sort(c,c+n);
  for(int i=0;i<n;i++){
    ans+=(lower_bound(a,a+n,b[i])-a)*(c+n-upper_bound(c,c+n,b[i]));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<math.h>
long long power(long long a){
    if(a==1) return 2;
    return 2*power(a-1);
}
int main(){
    long long int h,ans=0;
    long double p;
    scanf("%lld",&h);
    p=log2l(h);
    long long int q=p/1;
    if(h==1)
        ans=1;
    else{
        ans=power(q+1)-1;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	while(1){
		int x,y; cin >>x>>y;
		if(x ==0 && y==0)break;
		if(x>=y)cout << y << " "<<x << endl;
		else cout << x << " "<< y << endl;
	}
}


Measured memory_bytes: 3084
N,P=map(int, input().split())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
ans=1
F=factorization(P)
for arr in F:
    v=arr[0]
    num=arr[1]
    ans*=v**(num//N)

print(ans)

Measured memory_bytes: 63272
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	long long n;
	cin >> n;
	long long a[n], prod = 1, i, zero = 0;
	for (i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] == 0)
			zero++;
	}
	if (zero > 0)
		cout << "0\n";
	else
	{
		bool flag = 0;
		for (i = 0; i < n; i++)
		{
			if (a[i] <= 1000000000000000000 / prod)
			{
				prod *= a[i];
			}
			else
			{
				cout << "-1" << endl;
				return 0;
			}

		}

		printf("%lld\n", prod );
	}

}

Measured memory_bytes: 4528
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

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

  int len = s.length();
  bool ans = false;
  for (int i = 0; i < len-2; i++) {
    if (s.substr(i, 2) == "AC") {
      ans = true;
    }
  }

  if(s == "AC"){
    ans = true;
  }

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

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include <iomanip>
using namespace std;
typedef long long ll;
char a[200005];
int main()
{
	int n;
	int cnt = 0;
	cin >> n;
	for (int i = 0;i < n;i++)
		cin >> a[i];
	int f = 0,ff = n - 1;
	while (1)
	{
		if (f >= ff)
			break;
		if (a[f] == 'W')
		{
			for (;f < ff;ff--)
				if (a[ff] == 'R')
				{
					cnt++;
				//	cout << "*" << f << " " << ff << endl;
					ff--;
					break;
				}
		}
		f++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3356
def main():
    n, *a = map(int, open(0).read().split())
    x1 = sum(a[::2]) - sum(a[1::2])
    x = [x1]
    for i in a[:-1]:
        x.append(2 * i - x[-1])
    ans = ' '.join(map(str, x))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19212
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  
  string t;
  cin >> t;
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  
  if(s < t)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
using namespace std;
typedef pair<double,int> P;
typedef pair<P,int> PP;
int n,m,p,a,b,inf = 1e9;
int T[10];
double dp[31][1<<8] = {};
vector<vector<P>> v(31);

int main(){
    while(cin >> n >> m >> p >> a >> b && n>0){
        for(int i=0;i<n;i++){
            cin >> T[i];
        }
        int x,y;
        double z;
        for(int i=1;i<=m;i++) v[i].clear();
        for(int i=0;i<p;i++){
            cin >> x >> y >> z;
            v[x].push_back({z,y});
            v[y].push_back({z,x});
        }
        for(int i=1;i<=m;i++) for(int j=0;j<(1<<n);j++) dp[i][j] = inf;
        priority_queue<PP,vector<PP>,greater<PP>> Q;
        Q.push({{0,a},0});
        dp[a][0] = 0;
        while(!Q.empty()){
            PP pp = Q.top(); Q.pop();
            int now = pp.first.second,S = pp.second;
            if(dp[now][S]<pp.first.first) continue;
            for(auto x:v[now]){
                for(int i=0;i<n;i++){
                    if(S&(1<<i)) continue;
                    int nS = S|(1<<i);
                    if(dp[x.second][nS]>pp.first.first+x.first/T[i]){
                        dp[x.second][nS] = pp.first.first+x.first/T[i];
                        Q.push({{dp[x.second][nS],x.second},nS});
                    }
                }
            }
        }
        double ans = inf;
        for(int S=0;S<(1<<n);S++) ans = min(ans,dp[b][S]);
        if(inf-1<=ans && ans<=inf+1) cout << "Impossible" << endl;
        else printf("%.10f\n",ans);
    }
}


Measured memory_bytes: 5396
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c ) {
  stack<int> S;
  S.push(r);
  color[r] = c;
  while ( !S.empty() ) {
    int u = S.top(); S.pop();
    for ( int i = 0; i < G[u].size(); i++ ) {
      int v = G[u][i];
      if ( color[v] == NIL ) {
	color[v] = c;
	S.push(v);
      }
    }
  }
}

void assignColor() {
  int id = 1;
  for ( int i = 0; i < n; i++ ) color[i] = NIL;
  for ( int u = 0; u < n; u++ ) {
    if ( color[u] == NIL ) dfs(u, id++);
  }
}

int main() {
  int s, t, m, q;

  cin >> n >> m;

  for ( int i = 0; i < m; i++ ) {
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }

  assignColor();

  cin >> q;

  for ( int i = 0; i < q; i++ ) {
    cin >> s >> t;
    if ( color[s] == color[t] ) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 8976
# 2019/08/08

from bisect import bisect_left,bisect_right

n=int(input())
x=list(map(int,input().split()))
xx=sorted(x)
mid=n//2

for i in range(n):
    if bisect_left(xx,x[i])<mid:
        print(xx[mid])
    else:
        print(xx[mid-1])

Measured memory_bytes: 25228
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

typedef struct {
	vector <int> to;
	int cost;
	bool is_visited;
} edge;
int main( void ){
	int N, M,C; cin >> N>>M>>C;
	vector<int> B(M);
	vector<vector<int>> A(N, vector<int>(M));
	rep(i,0,M)cin >> B[i];
	rep(i,0,N){
		rep(j,0,M){
			cin >> A[i][j];
		}
	}

	int cnt = 0;
	rep(i,0,N){
		int sum = 0;
		rep(j,0,M){
			sum += A[i][j]*B[j];
		}
		if (sum+C>0)
			cnt++;
	}
	cout << cnt <<endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256