akhauriyash/Code-Regression huggingface dataset:
import sys
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N, A, B, C = in_nn()
    l = list(map(int, read().rstrip().split()))

    comb = list(itertools.product(range(4), repeat=N))
    abc_p = list(itertools.permutations([A, B, C], 3))

    ans = 10**9 + 7
    for abc in abc_p:
        for c in comb:
            if (0 in c) and (1 in c) and (2 in c):
                t = [0] * 3
                m = [-10] * 3
                for i in range(N):
                    if c[i] == 3:
                        continue
                    t[c[i]] += l[i]
                    m[c[i]] += 10

                for i in range(3):
                    m[i] += abs(t[i] - abc[i])

                ans = min(ans, sum(m))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 51380
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
# input = sys.stdin.readline

s = input().rstrip()
s = ">" + s + "<"
n = len(s)

lvs = []

ans = [-1] * n
lv = 0
for i, (ch1, ch2) in enumerate(zip(s, s[1:])):
    if ch1 == ">" and ch2 == "<":
        lv = 0
        ans[i+1] = lv
    if ch1 == "<":
        lv += 1
        ans[i+1] = lv

prev = s[-1]
lv = 0
for i in range(n-2, -1, -1):
    if s[i] == ">":
        lv += 1
        ans[i] = max(ans[i], lv)
    elif s[i] == "<":
        lv = 0
    prev = s[i]

print(sum(ans[1:]))

Measured memory_bytes: 27580
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

s = S()
t = S()

c = 0
for i in range(len(s)):
    if s[i]==t[i]:
        pass
    else:
        c += 1
print(c)

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

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

int main() {

  int n;
  cin >> n;
  vector<int64_t> a(n + 1);
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i) {
      a[j] += 1;
    }
  }
  int64_t ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += i * a[i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 81332
S=input()
num = len(S)-1 #符号を加えられる隙間の数
x=[]

for i in range(2**num):
    tmp=['-']*num #すべてマイナスを初期値として用意しておく
    for j in range(num):
        if ((i >> j) &1):
            tmp[num-1-j] ='+'
    x.append(tmp)
        
#print(x) #これで全符号パターンができた

ans =0

for i in range(len(x)):
    now =S[0]
    for j in range(len(x[i])):
        if x[i][j] == '-':
            now += S[j+1:j+2]
        else:
            now = now + x[i][j] + S[j+1:j+2] 
    #print(now) #プラスの記号を挿入した表記
    ans += eval(now)

print(ans)

Measured memory_bytes: 9096
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <vector>

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

    if(a == b){
        std::cout << c;
        return 0;
    }

    else if(a == c){
        std::cout << b;
        return 0;
    }
    else {
        std::cout << a;
        return 0;

    }
}




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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


signed main(){
    int a, b, c;
    cin >> a >> b >> c;
    PRINT(a * b / 2);
    return 0;
}

Measured memory_bytes: 256
<?php

    $num = array_map('intval',explode(" ",trim(fgets(STDIN))));
    
    $array = array_map('intval',explode(" ",trim(fgets(STDIN))));
    
    sort($array);
    
    $array = array_slice($array,0,$num[1]);
    
    echo array_sum($array)."\n";
?>

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

int main() {
  int n,m; cin>>n>>m;
  int sum=0;
  for (int i=0; i<m; i++){
    int a; cin>>a;
    sum+=a;
  }
  cout<<(n>=sum ? n-sum : -1)<<endl;
}

Measured memory_bytes: 3568
using System;

    class Program
    {
        static void Main(string[] args)
        {
            int x, y, z;

            while (true)
            {
                string[] num = Console.ReadLine().Split(' ');
                x = int.Parse(num[0]);
                y = int.Parse(num[1]);

                if (x > y)
                {
                    z = x;
                    x = y;
                    y = z;
                }else if (x == 0 && y == 0)
                {
                    break;
                }
                Console.WriteLine(x + " " + y);   
            }
        }
    }



Measured memory_bytes: 9400
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;

using ll = long long;

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1){
            res = (res * a)%mod;
        }
        a = (a * a)%mod;
        b >>= 1;
    }
    return (res%mod);
}

signed main(){
	ll n;
    cin >> n;

    ll x = n%10;

    if(x == 1 || x == 0 || x == 6 || x == 8){
        cout << "pon\n";
    }
    else if(x == 3){
        cout << "bon\n";
    }
    else{
        cout << "hon\n";
    }
	return 0;
}

Measured memory_bytes: 3592
N = int(input())
S = list(input())
i, j = 0, N - 1
res = 0
while i < j:
    while i < j and S[i] == 'R':
        i += 1
    while i < j and S[j] == 'W':
        j -= 1
    if i < j and  S[i] == 'W' and S[j] == 'R':
        S[i], S[j] = S[j], S[i]
        i += 1
        j -= 1
        res += 1
        continue

print(res)

Measured memory_bytes: 10784
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
	
	long long int H, W;
	
	cin >> H >> W;
	
	if(H % 3 * W % 3 == 0){
		cout << "0" << endl;
		return 0;
	}
	
	long long int ans = min(H, W);
	
	long long int p1 = W * (H / 3);
	
	long long int p2 = (H - H / 3) * (W / 2);
	
	long long int p3 = H * W - p1 - p2;
	
	long long int poyo = max(abs(p1 - p2), abs(p1 - p3));
	poyo = max(poyo, abs(p2 - p3));
	ans = min(ans, poyo);
	
	p1 = W * (H / 3 + 1);
	
	p2 = (H - H / 3 - 1) * (W / 2);
	
	p3 = H * W - p1 - p2;
	
	poyo = max(abs(p1 - p2), abs(p1 - p3));
	poyo = max(poyo, abs(p2 - p3));
	ans = min(ans, poyo);
	
	swap(H, W);
	
	p1 = W * (H / 3);
	
	p2 = (H - H / 3) * (W / 2);
	
	p3 = H * W - p1 - p2;
	
	poyo = max(abs(p1 - p2), abs(p1 - p3));
	poyo = max(poyo, abs(p2 - p3));
	ans = min(ans, poyo);
	
	p1 = W * (H / 3 + 1);
	
	p2 = (H - H / 3 - 1) * (W / 2);
	
	p3 = H * W - p1 - p2;
	
	poyo = max(abs(p1 - p2), abs(p1 - p3));
	poyo = max(poyo, abs(p2 - p3));
	ans = min(ans, poyo);
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll N,K;
  ll R,S,P;
  string T;
  cin>>N>>K;
  cin>>R>>S>>P;
  cin>>T;
  vector<char>date(N);
  ll ans=0;
  
  rep(i,N){
    if(i-K<0){
if(T[i]=='r'){
  ans+=P;
  date[i]='p';
}
else if(T[i]=='s'){
  ans+=R;
  date[i]='r';
}
    
else{
  ans+=S;
  date[i]='s';
}  
    }
    //Kが適用される時
else{
    if(T[i]=='r'){
      
      if(date[i-K]!='p'){
  ans+=P;
  date[i]='p';
      }
  else{
date[i]='0';
  }
}

     else  if(T[i]=='s'){
      
      if(date[i-K]!='r'){
  ans+=R;
  date[i]='r';
}
  else{
date[i]='0';
  }
}
  
      else{
      
      if(date[i-K]!='s'){
  ans+=S;
  date[i]='s';
}
  else{
date[i]='0';
  }
}
    

}
  }

  
cout<<ans<<endl;
}



Measured memory_bytes: 512
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    long long n;
    cin >> n;

    bool res = false;
    if (n != 0) {
        int d = 0;
        {
            long long x = n;
            while (x != 0) {
                d += x % 10;
                x /= 10;
            }
        }
        assert(d > 0);
        if (n % d == 0) {
            res = true;
        }
    }

    if (res) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <bits/stdc++.h>
#include <set>
#include <vector>
#include <queue>
#include <bitset>
#define NL << endl
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl "\n"
#define fill(x, y) memset(x, y, sizeof(y))
#define debug(x)                          \
    {                                     \
        cerr << #x << " = " << x << endl; \
    }
#define inarr(arr, n)                            \
    {                                       \
        for(int i =0;i<n;i++){              \
            cin >> arr[i];                  \
        }                                   \
    }
typedef long long ll;
const int MOD = 1e9 + 7;
using namespace std;

void solve()
{
    ll n; cin >> n;
    ll arr[n];
    inarr(arr, n);
    ll dp[n];
    dp[0] = 0;
    dp[1] = abs(arr[1] - arr[0]);
    for(int i =2;i<n;i++){
        dp[i] = min( dp[i-1] + abs(arr[i] - arr[i-1]), dp[i-2] + abs(arr[i] - arr[i-2])   );
    }
    cout << dp[n-1] << endl;

}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t; t = 1; 
    // int t; cin >> t;
    while (t--)
        solve();
}


Measured memory_bytes: 5188
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
template<class T> inline int add(T& a, T b, T M = MOD){a=(a+M)%M;b=(b+M)%M;a=(a+b)%M;return a;};
template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
////////////////////////////////////////////////////////////////////

signed main(){
  string s;cin>>s;
  repd(i,1,s.length()){
    string a = s.substr(0,(s.length()-i)/2), b = s.substr((s.length()-i)/2, (s.length()-i)/2);
    if((s.length()-i)%2 == 0 && a == b){
      cout << s.length()-i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n=scanner.nextInt();
		int maxa=-1;
		int maxb=0;
		for(int i=0;i<n;i++) {
			int a=scanner.nextInt();
			int b=scanner.nextInt();
			if(maxa<a) {
				maxa=a;
				maxb=b;
			}
		}
		System.out.println((long)maxa+maxb);
	}
}


Measured memory_bytes: 63588
using System;
namespace AtCoder
{

    class Program
    {
        static void Main(string[] args)
        //static void dummy()
        {
            // 入力データパース
            string szPoint = Console.ReadLine();
            long point = long.Parse(szPoint);

            // 初回は絶対6だ！！その次は5にする、6、5、…

            // 偶数回の計算式から必要な回数を
            long retEven = (long)Math.Ceiling((2d * point) / 11);


            // 奇数回の計算式から必要な回数を
            long retOdd = (long)Math.Ceiling((2d * (point - 6) + 11) / 11);

            long ret = Math.Min(retEven, retOdd);

            Console.WriteLine(ret);
        }
        private static int EvenPoint(int x)
        {
            return 11 * (x / 2);
        }
        private static int OddPoint(int x)
        {
            return 11 * ((x - 1) / 2) + 6;
        }
    }
}


Measured memory_bytes: 2648
l, r = map(int, input().split())

if r - l > 2020:
    r = l + 2020

ans = 2020
for i in range(l,r):
    for j in range(i+1,r+1):
        sub = (i*j)%2019

        if sub < ans:
            ans = sub

print(ans)


Measured memory_bytes: 2940
S = input()
if S == "SSS":
    print(0)
elif S == "SSR":
    print(1)
elif S == "SRS":
    print(1)
elif S == "SRR":
    print(2)
elif S == "RSS":
    print(1)
elif S == "RSR":
    print(1)
elif S == "RRS":
    print(2)
elif S == "RRR":
    print(3)


Measured memory_bytes: 9056
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <cassert>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<int> X(N);
    rep(i, N) cin >> X[i];
    vector<int> D(N - 1);
    vector<vector<int>> P(64, vector<int>(N - 1));
    rep(i, N - 1) D[i] = X[i + 1] - X[i], P[0][i] = i;
    int M;
    ll K;
    cin >> M >> K;
    rep(i, M) {
        int a;
        cin >> a;
        swap(P[0][a - 2], P[0][a - 1]);
    }
    
    rep(i, 1, 64) rep(j, N - 1){
        P[i][j] = P[i - 1][P[i - 1][j]];
    }
    
    vector<int> ans(N - 1);
    rep(i, N - 1) ans[i] = i;
    
    for(int i = 63; i >= 0; i--){
        if((K & (1LL << i)) > 0){
//            vector<int> tmp(N - 1);
            rep(j, N - 1){
                ans[j] = P[i][ans[j]];
            }
//            ans = tmp;
        }
    }
    
    ll ret = X[0];
    output(ret);
    rep(i, N - 1){
        ret += D[ans[i]];
        output(ret);
    }

    assert(ret == X[N - 1]);
    return 0;
}

Measured memory_bytes: 27512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long double A;
  long double B;
  cin >> A >> B;
  cout << (ll)floor(A * B) << endl;
  return 0;
}


Measured memory_bytes: 3748
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

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

		final int n = sc.nextInt();
		
		int[][] matrix = new int[n][n];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				matrix[i][j] = sc.nextInt();
			}
		}
		
		int[][] sum = new int[n + 2][n + 2];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(i == 0 && j == 0){
					sum[i][j] = matrix[i][j];
				}else if(i == 0){
					sum[i][j] = sum[i][j-1] + matrix[i][j];
				}else if(j == 0){
					sum[i][j] = sum[i-1][j] + matrix[i][j];
				}else{
					sum[i][j] = sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1] + matrix[i][j];
				}
			}
		}
		
		int max = Integer.MIN_VALUE;
		for(int e_y = 0; e_y < n; e_y++){
			for(int e_x = 0; e_x < n; e_x++){
				
				for(int s_y = e_y - 1; s_y >= 0; s_y--){
					for(int s_x = e_x - 1; s_x >= 0; s_x--){
						max = Math.max(max, sum[e_y][e_x] - sum[s_y][e_x] - sum[e_y][s_x] + sum[s_y][s_x]);
					}
					
					max = Math.max(max, sum[e_y][e_x] - sum[s_y][e_x]);
				}
				
				for(int s_x = e_x - 1; s_x >= 0; s_x--){
					max = Math.max(max, sum[e_y][e_x] - sum[e_y][s_x]);
				}
				
				max = Math.max(max, sum[e_y][e_x]);
				
			}
		}
		
		System.out.println(max);
	}
	
	public static class Scanner {
		
		private BufferedReader br;
		private StringTokenizer tok;
		
		public Scanner(InputStream is) throws IOException{
			br = new BufferedReader(new InputStreamReader(is));
			getLine();
		}
		
		private void getLine() throws IOException{
			tok = new StringTokenizer(br.readLine());
		}
		
		private boolean hasNext(){
			return tok.hasMoreTokens();
		}
		
		public int nextInt() throws IOException{
			if(hasNext()){
				return Integer.parseInt(tok.nextToken());
			}else{
				getLine();
				return Integer.parseInt(tok.nextToken());
			}
		}
		
		public long nextLong() throws IOException{
			if(hasNext()){
				return Long.parseLong(tok.nextToken());
			}else{
				getLine();
				return Long.parseLong(tok.nextToken());
			}
		}
		
		public double nextDouble() throws IOException{
			if(hasNext()){
				return Double.parseDouble(tok.nextToken());
			}else{
				getLine();
				return Double.parseDouble(tok.nextToken());
			}
		}
	}
}

Measured memory_bytes: 23328
#include <string.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iomanip>

using namespace std;
#define INF 1e9
#define MAX 105
#define MOD 1000000007
#define Q queue
#define PQ priority_queue
#define fr first
#define sc second
#define pb push_back
#define mp make_pair
#define FOR( i, L, U ) for(int i=(int)L ; i<(int)U ; i++ )
#define FORD( i, U, L ) for(int i=(int)U ; i>=(int)L ; i-- )
#define wa cout<<"Wa"<<endl
#define READ(filename)  freopen(filename, "r", stdin);
#define WRITE(filename)  freopen(filename, "w", stdout);

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int> > vvi;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef map<int, string> mis;
typedef map<int , vector<int> > mvi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;

void base(){
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
}


int main(){
//	base();
	int n,x=0,arr[MAX],color[MAX];
	memset(color,0,sizeof color);
	cin>>n;
	FOR(i,0,n){
		cin>>arr[i];
		if (arr[i]>=1 && arr[i]<400){
			color[0]++;
		}else if (arr[i]>=400 && arr[i]<800){
			color[1]++;
		}else if (arr[i]>=800 &&arr[i]<1200){
			color[2]++;
		}else if (arr[i]>=1200 && arr[i]<1600){
			color[3]++;
		}else if (arr[i]>=1600 && arr[i]<2000){
			color[4]++;
		}else if (arr[i]>=2000 && arr[i]<2400){
			color[5]++;
		}else if (arr[i]>=2400 && arr[i]<2800){
			color[6]++;
		}else if (arr[i]>=2800 && arr[i]<3200){
			color[7]++;
		}else color[8]++;
	}
	int mn=0;
	FOR(i,0,8){
		if (color[i]) mn++;
	}
	int mx=mn;
	if (color[8]>0){
		mx= max(mx,mn+  color[8]);
	}
	if (mn==0){
		mn = 1;
		mx = max(mn,mx);
	}
	cout<<mn<<" "<<mx<<endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private static Scanner sc;
	final static int mod=1000000007;
	public static void main(String[] args){
		sc=new Scanner(System.in);
		long m=sc.nextInt();
		long n=sc.nextInt();
		System.out.println(modpow(m,n));
	}

	static long modpow(long x,long n){
		if(n==0){
			return 1;
		}else if(n%2==0){
			long ans=modpow(x,n/2);
			return ((ans%mod)*(ans%mod))%mod;
		}else{
			long ans=modpow(x,n-1);
			return ((x%mod)*(ans%mod))%mod;
		}
	}

}

Measured memory_bytes: 26376
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let s = sc.chars();
    if s.len() % 2 == 1 {
        println!("No");
        return;
    }
    for i in 0..s.len() - 1 {
        if i % 2 == 1 {
            continue;
        }
        if !(s[i] == 'h' && s[i + 1] == 'i') {
            println!("No");
            return;
        }
    }
    println!("Yes");
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}
pub mod utils {
    const DYX: [(isize, isize); 8] = [
        (0, 1),   //right
        (1, 0),   //down
        (0, -1),  //left
        (-1, 0),  //top
        (1, 1),   //down right
        (-1, 1),  //top right
        (1, -1),  //down left
        (-1, -1), //top left
    ];

    pub fn try_adj(y: usize, x: usize, dir: usize, h: usize, w: usize) -> Option<(usize, usize)> {
        let ny = y as isize + DYX[dir].0;
        let nx = x as isize + DYX[dir].1;
        if ny >= 0 && nx >= 0 {
            let ny = ny as usize;
            let nx = nx as usize;
            if ny < h && nx < w {
                Some((ny, nx))
            } else {
                None
            }
        } else {
            None
        }
    }
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

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

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8572
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

int main() {
    ll N,M;
    cin >> N >> M;
    vector<ll> num(N);
    fill(num.begin(),num.end(),1);

    bool red[N];
    fill(red,red+N,false);
    red[0]=true;
    for(int i=0;i<M;i++){
        ll x,y;
        cin >> x >> y;
        x--;y--;
        if(red[x]) red[y]=true;
        num[x]--;num[y]++;
        if(num[x]==0) red[x]=false;
    }
    
    ll ans=0;
    for(int i=0;i<N;i++){
        if(red[i]) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1152
from bisect import*
from numpy import*
n=int(input())
a=sorted(map(int,input().split()))
b=sorted(map(int,input().split()))
c=sorted(map(int,input().split()))
#print(a,b,c)
#print([bisect_right(b,t)for t in a])
#print(cumsum([n-bisect_right(c,s)for s in b][::-1])[::-1])
ans=0
x=cumsum([n-bisect_right(c,s)for s in b][::-1])[::-1]
y=[bisect_right(b,t)for t in a]
for i in y:
    if i<n:
        ans+=x[i]
print(ans)

Measured memory_bytes: 31824
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int n, m;
  cin >> n >> m;
  map<pii,int> mp;
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    mp[pii(a,b)];
  }
  bool can = false;
  for (int i = 1; i <= n-2; ++i) {
    if (mp.count(pii(0,i)) && mp.count(pii(i,n-1))) can = true;
  }
  cout << (can ? "POSSIBLE" : "IMPOSSIBLE") << endl;
  return 0;
}

Measured memory_bytes: 12800
n = int(input())
v = list(map(int, input().split()))
cnt = [[0 for j in range(10**5)] for i in range(2)]
for i in range(n):
  cnt[i%2][v[i]-1] += 1
maxce = max(cnt[0])
maxco = max(cnt[1])
maxve = -1
maxvo = -1
for i in range(len(cnt[0])):
  if(cnt[0][i] == maxce):
    maxve = i
    break
for i in range(len(cnt[1])):
  if(cnt[1][i] == maxco):
    maxvo = i
    break
if(maxvo != maxve):
  print((n//2 - maxco) + (n - n//2 - maxce))
else:
  cnt[0].pop(maxve)
  cnt[1].pop(maxvo)
  maxce2 = max(cnt[0])
  maxco2 = max(cnt[1])
  print(min((n//2 - maxco2) + (n - n//2 - maxce), (n//2 - maxco) + (n - n//2 - maxce2)))

Measured memory_bytes: 14404
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define INF INT64_MAX
#define MOD 1000000007
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[8] = { 1,-1,0,0,1,1,-1,-1 }, ddy[8] = { 0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 222222


ll a[MAX];
int main(void) {
  MAP mp;
  cin >> n >> m;
  FOR(i, 0, n) cin >> a[i];

  ma = 0;
  mi = a[0];
  FOR(i, 0, n) {
	ma = max(ma, a[i] - mi);
	mi = min(mi, a[i]);
  }

  FOR(i, 0, n) {
	if (mp[a[i] - ma]) ans++;
	mp[a[i]]++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 13568
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;

int main() {
    long a, b, K, z, y;
    cin >> a >> b >> K;
    if (a >= K) {
        a = a - K;
        cout << a << " " << b << endl;
    } else if (a < K && a + b >= K) {
        b = a + b - K;
        cout << "0" << " " << b << endl;
    } else if (a + b < K ) {
        cout << "0" << " " << "0" << endl;
    }

    return 0;
}

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

int main(){
  char s,t,u;
  int count = 0;
  
 cin >> s >> t >> u;
  if(s =='1'){count++;}
  if(t =='1'){count++;}
  if(u =='1'){count++;}
  
  cout << count;
  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,m; cin >> n >> m;
    const int nmax = 50;
    char A[nmax][nmax],B[nmax][nmax];
    rep(y,n){
        rep(x,n){
            cin >> A[y][x];
        }
    }
    rep(y,m){
        rep(x,m){
            cin >> B[y][x];
        }
    }

    bool ext = false;
    rep(i,n){
        rep(j,n){
            if(i+m-1 >= n || j+m-1 >= n) continue;
            bool match = true;
            rep(y,m){
                rep(x,m){
                    if(A[i+y][j+x] != B[y][x]) match = false;
                }
            }
            if(match) ext = true;
        }
    }
    if(ext) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N;
  cin>>N;
  ll len=0;
  for(ll i=0; i<50; ++i){
    if((1LL<<i)-1<=N) continue;
    len=i-1;
    N-=(1LL<<len)-1;
    break;
  }
  
  // まずは(1, 2, ..., len)を作る
  vector<ll> p(len);
  for(ll i=0; i<len; ++i){
    p[i]=i+1;
  }
  
  // len+1を適宜追加していく
  for(ll i=len; i>=0; --i){
    if((1LL<<i)<=N){
      // iとi+1の間にlen+1を追加
      p.insert(p.begin()+i,++len);
      N-=(1LL<<i);
    }
  }
  
  cout<<len*2<<endl;
  
  // 前半は作った1~lenの順列
  for(ll n:p){
    cout<<n<<" ";
  }
  
  // 後半は1~lenの昇順列
  for(ll i=1; i<=len; ++i){
    cout<<i<<" ";
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 3604
N = int(input())
A = list(map(int, input().split()))


def bubble_sort(A, N):
    flag = 1
    count = 0
    while flag:
        flag = 0
        for j in range(N-1, 0, -1):
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                count += 1
                flag = 1
    return A, count

A, count = bubble_sort(A, N)
print(' '.join(map(str, A)))
print(count)



Measured memory_bytes: 5600
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
using namespace std;

typedef long long ll;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> p;
    p.push_back(0);
    for (int i = 1; i <= n; i++) {
        int tmp;
        cin >> tmp;
        p.push_back(tmp);
    }

    vector<ll> hyou; 
    hyou.push_back(0);
    for(int i = 1; i <= 1000; i++) {
        hyou.push_back(i + hyou[i - 1]);
    }

    vector<double> exp;
    for (int i = 1; i <= n; i++) {
        exp.push_back(hyou[p[i]] / (double)p[i]);
    }

    vector<double> res;
    double count2 = 0.0;
    double r = 0;
    double s = 0;
    res.push_back(0);
    for (int i = 0; i < n; i++) {
        double t = count2 + (exp[i] + r);
        r = (exp[i] + r) - (t - count2);
        count2 = t;
        res.push_back(count2);
    }

    double ans = 0;
    for (int i = 1; i <= n - k + 1; i++) {
        double s = res[i + k - 1] - res[i - 1];
        ans = max(ans, s);
    }

    printf("%.7f\n", ans);
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) 
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(const T x,const T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),b.begin(),b.end());}
template<class T> void getand(const T &a,const T &b,T &c) {
  set_intersection(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getor(const T &a,const T &b,T &c) {
  set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}

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

const ll MOD=1e9+7;
const int MAX=1e5+100;

int main() {
  // B-Aが偶数の場合にはそのままお互いの方向に(B-A)/2回ずつ歩み寄ればいける
  // B-Aが奇数の場合には、Aが一度1にいって一回待ち、Bの方向に向かうか、
  // Bが一度Nにいって一回待ってAの方に向かう
  ll N,A,B;cin>>N>>A>>B;

  if ((B-A)%2==0) {
    OUT((B-A)/2);
    return 0;
  }

  ll f = A + ((B-A)-1)/2;
  ll b = (N-B+1) + (N-(A+(N-B+1)))/2;

  OUT(min(f,b));

  return 0;
}

Measured memory_bytes: 256
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    ABC = sorted(il())
    mx = max(ABC)
    K = ii()

    for k in range(K):
        mx *= 2
    print(ABC[0] + ABC[1] + mx)


if __name__ == '__main__':
    main()


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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  string s;
  cin >> s;
  int n = sz(s);
  rep(i,n) {
    if(s[i] == '?') s[i] = 'D';
  }
  cout << s << endl;
}

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

 
int main() {
     string s;
     cin>>s;
     if(s=="SUN")
     cout<<7;
     else if(s=="MON")
     cout<<6;
     else if(s=="TUE")
     cout<<5;
     else if(s=="WED")
     cout<<4;
     else if(s=="THU")
     cout<<3;
     else if(s=="FRI")
     cout<<2;
     else if(s=="SAT")
     cout<<1;

        
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int n,m; cin >> n >> m;
    vector<int> A(n);
    bool ans = true;
    rep(i,m){
        int s,c; cin >> s >> c;
        if(s == 1 && c == 0 && n != 1) ans = false;
        if(A[s-1] != 0){
            if(A[s-1] != c) ans = false;
        }
        A[s-1] = c;
    }
    if(!(ans)){
        cout << -1 << endl;
        return 0;
    }
    if(A[0] == 0 && n != 1) A[0] = 1;
    rep(i,n) cout << A[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------
const int MX = 200000 + 7;
ll n, k;
int a[MX];
bool visited[MX];
int first[MX];

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout<<fixed<<setprecision(15);
    cin >> n >> k;

    FOR(i,1,n) {
        cin >> a[i];
    }

    int cur = 1;
    int cnt = 0;
    while(visited[cur] == false) {
        visited[cur] = true;
        first[cur] = cnt++;
        cur = a[cur];
    }

    int reach = 0;
    int now = 1;
    while(now != cur) {
        now = a[now];
        reach++;
    }

    int diff = cnt - first[cur];
    int fr;
    if(k-reach < 0) {
        fr = k;
        int ans = 1;
        FOR(i,1,fr) {
            ans = a[ans];
        } 
        cout << ans << endl;
    } else {
        fr = (k-reach) % diff;
        int ans = cur;
        FOR(i,1,fr) {
            ans = a[ans];
        } 

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 5380
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  double a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a/2==c&&b/2==d)cout<<fixed<<setprecision(6)<<a*b/2<<" "<<1;
  else cout<<fixed<<setprecision(6)<<a*b/2<<" "<<0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ull = unsigned long long;
using bit = bitset<40>;
#define chmax(x,y) x=max(x,y)

ull dp[41][2]; // dp[i][smaller] : 上からi桁目までみたときのxorの最大値

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

    vector<ull> A(n);
    rep(i,n) cin >> A[i];

    int S[41]; // 上からi桁目が1の個数
    S[0] = 0;
    for(int i=1; i<=40; i++) {
        S[i] = 0;
        for(auto a : A) {
            bit ba = a;
            if(ba[40-i] == 1) S[i]++;
        }
    }

    rep(i,41)rep(j,2) dp[i][j] = 0;
    dp[0][0] = 0;
    dp[0][1] = 0;

    for (int i=1; i<=40; i++) {
        ull n1 = S[i]; // 1の個数
        ull n0 = n-n1; // 0の個数

        int j = 40-i;

        ull x = (k>>j)&1;
        if (x == 0) {
            // 0を選ぶ
            chmax(dp[i][0], dp[i-1][0] + n1 * (1ULL<<j));
            if (dp[i-1][1]>0) chmax(dp[i][1], dp[i-1][1] + n1 * (1ULL<<j));
            // 1を選ぶ
            if (dp[i-1][1]>0) chmax(dp[i][1], dp[i-1][1] + n0 * (1ULL<<j));
        } else {
            // 0を選ぶ
            chmax(dp[i][1], max(dp[i-1][0] + n1 * (1ULL<<j), dp[i-1][1] + n1 * (1ULL<<j)));
            // 1を選ぶ
            chmax(dp[i][0], dp[i-1][0] + n0 * (1ULL<<j));
            if (dp[i-1][1]>0) chmax(dp[i][1], dp[i-1][1] + n0 * (1ULL<<j));
        }
    }

    cout << max(dp[40][0], dp[40][1]) << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int X, Y, Z, K;
	cin >> X >> Y >> Z >> K;
	vector<lint> x(X);
	vector<lint> y(Y);
	vector<lint> z(Z);

	for (int i = 0; i < X; i++)
	{
		cin >> x[i];
	}
	for (int i = 0; i < Y; i++)
	{
		cin >> y[i];
	}
	for (int i = 0; i < Z; i++)
	{
		cin >> z[i];
	}
	sort(all(x), greater<lint>());
	sort(all(y), greater<lint>());
	sort(all(z), greater<lint>());
	priority_queue<pair<lint, tuple<int, int, int>>> next;
	set<tuple<int, int, int>> used;

	next.push(make_pair(x[0] + y[0] + z[0], make_tuple(0, 0, 0)));

	for (int i = 0; i < K; i++)
	{
		tuple<lint, lint, lint> t = next.top().second;
		cout << next.top().first << endl;
		next.pop();

		int c_x = get<0>(t);
		int c_y = get<1>(t);
		int c_z = get<2>(t);

		if (c_x + 1 < X)
			if (used.count(make_tuple(c_x + 1, c_y, c_z)) == 0)
			{
				next.push(make_pair(x[c_x + 1] + y[c_y] + z[c_z], make_tuple(c_x + 1, c_y, c_z)));
				used.insert(make_tuple(c_x + 1, c_y, c_z));
			}

		if (c_y + 1 < Y)
			if (used.count(make_tuple(c_x, c_y + 1, c_z)) == 0)
			{
				next.push(make_pair(x[c_x] + y[c_y + 1] + z[c_z], make_tuple(c_x, c_y + 1, c_z)));
				used.insert(make_tuple(c_x, c_y + 1, c_z));
			}

		if (c_z + 1 < Z)
			if (used.count(make_tuple(c_x, c_y, c_z + 1)) == 0)
			{
				next.push(make_pair(x[c_x] + y[c_y] + z[c_z + 1], make_tuple(c_x, c_y, c_z + 1)));
				used.insert(make_tuple(c_x, c_y, c_z + 1));
			}
	}

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 896
#a, b, k = map(int,input().split())
n = int(input())
#b = list(map(int,input().split()))
ls = [input().split() for i in range(n)]
ans = [float(i[0]) if i[1] == "JPY" else float(i[0])* 380000 for i in ls]
#s = input()
print(sum(ans))

Measured memory_bytes: 3060