akhauriyash/Code-Regression huggingface dataset:
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N, S = [int(input()), int(input())]


def solve1():
    i = 2
    while i * i <= N:
        if ok(i, N, S):
            return i

        i += 1

    return 1 << 60


def solve2():
    i = 1
    ret = 1 << 60
    while i * i <= N:
        b = (N - S) // i + 1
        if ok(b, N, S):
            ret = min(ret, b)
        i += 1

    return ret


def ok(b, N, S):
    if b <= 1:
        return False

    s, n = 0, N
    while n > 0:
        s += n % b
        n //= b

    return s == S



def solve():
    if S == N:
        return N + 1
    ret = min(solve1(), solve2())
    return ret if ret != 1 << 60 else -1


print(solve())


Measured memory_bytes: 9636
#初期値の入力
import math
input_data = list(input().split())
a = float(input_data[0])
b = float(input_data[1])
c = int(input_data[2])

#サイン計算
sin = math.sin(math.radians(c))
cos = math.cos(math.radians(c))

#三角形の面積 S、周の長さ L, a を底辺としたときの高さ h
h = b * sin
s = (a * h)/2 
l = math.sqrt(a**2+b**2-2*a*b*cos)

#辺の計算と表示
print(f"{s:.8f}")
print(f"{a+b+l:.8f}")
print(f"{h:.8f}")



Measured memory_bytes: 5724
from fractions import gcd

n = int(input())
a = list(map(int, input().split()))

l = a[0]
for k in a:
  l = ( l * k ) // gcd(l, k)

mod = 10 ** 9 + 7
ans = 0
for k in a:
  ans += l // k

print( int(ans) % mod )


Measured memory_bytes: 6200
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
const ll nax=1e6+5, inf=1e18;

const ld PI = 3.141592653589793, eps = 1e-8;
inline ll mult(ll x,ll y){x%=hell;y%=hell;return (1LL*x*y)%hell;}
inline ll add(ll x,ll y){x+=y;return x%hell;}
inline ll powMod(ll base,ll expo){
	if(base==0)return 0;
	ll ans=1;
	while(expo){
		if(expo&1)ans=mult(ans,base);
		base=mult(base,base); 
		expo>>=1;
	}
	return ans;
}
vector<ll> adj[100005], dist(100005,inf), ans(100007);
void solve(){
	ll n, m, x, y;
	cin>>n>>m;
	rep(i,0,m){
		cin>>x>>y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	dist[1]=0;
	queue<ll> q;
	q.push(1);
	while(!q.empty()){
		x=q.front();
		q.pop();
		for(auto i : adj[x]){
			if(dist[i]==inf){
				dist[i]=dist[x]+1;
				ans[i]=x;
				q.push(i);
			}
		}
	}
	cout<<"Yes\n";
	rep(i,2,n+1)cout<<ans[i]<<"\n";
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0 ;
}


Measured memory_bytes: 13704
#include <stdio.h>
#include <iostream>
using namespace std;

void hoge(int n){
  int k = n;
  while(n!=0){
    if(n%10==3){
      printf(" %d", k);
      break;
    }
    n /= 10;
  }
}

int main(void){
  int n;
  cin >> n;
  for(int i=1; i<=n; i++){
    if(i%3==0){
      printf(" %d", i);
    }else{
      //printf("i=%d\n", i);
      hoge(i);
    }
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 3140
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<algorithm>
using namespace std;

int main(){
    string s;
    int K;
    cin >> s;
    cin >> K;
    set<string> ret;
    for(char c = 'a'; c <= 'z'; c++)
    {
        for(size_t i = 0; i < s.length(); i++)
        {
            if(s[i] == c)
            {
                for(size_t k = 0; k < s.length(); k++)
                {
                    if(s[k] == c){
                        for(size_t j = 1; j <= K; j++)
                        {
                            if(k+j <= s.length())
                                ret.insert(s.substr(k, j));
                        }
                    }
                }
                break;
            }
        }
        if(ret.size() >= K)
            break;
    }

    auto it_ret = ret.begin();
    it_ret = next(it_ret, K-1);
    cout << *it_ret << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int num1 = sc.nextInt();
		int num2 = sc.nextInt();
		int count = 0;
      	int target = 0;
		String ans = "";
		if (num1 < num2){
          	target = num1;
			count = num2;
		}else{
          	target = num2;
			count = num1;
		}
		
		for (int i = 0; i < count; i++){
			ans += target;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 21844
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	f := make([]int, n+1)

	fmt.Println(fib(n, f))
}

func fib(n int, f []int) int {
	if n == 0 {
		f[n] = 1
		return f[n]
	}
	if n == 1 {
		f[n] = 1
		return 1
	}

	if f[n] != 0 {
		return f[n]
	}

	f[n] = fib(n-2, f) + fib(n-1, f)
	return f[n]
}



Measured memory_bytes: 1112
insertionSortVerbose :: Ord a => [a] -> [[a]]
insertionSortVerbose xs = scanl step xs [0..length xs-1]
    where
        step es n = let
            (pre,x:post) = splitAt n es
            in
                insertOrderd x pre ++ post

insertOrderd :: Ord a => a -> [a] -> [a]
insertOrderd x ts = let (pre,post) = span (< x) ts
                        in
                            pre ++ (x:post)


main = do
    _ <- getLine
    getLine >>= mapM_ (putStrLn . unwords . map show) . tail .
        insertionSortVerbose . map (read :: String -> Int) . words

Measured memory_bytes: 4124
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
i64 gcd(i64 a,i64 b)
{
  if (b == 0)
      return a;
  else
      return gcd (b, a % b);
}

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

    // ifstream fin(".in");
    // ofstream fout(".in");
i64 a,b;
cin>>a>>b;
i64 g=gcd(a,b);
i64 ans=0;
// cout<<g<<endl;
if(g!=0)
for(i64 i=2;i*i<=g;i++)
{

  if(g%i==0)
  {
    while(g%i==0)g/=i;

    ans++;
  }
}

if(g>1)ans+=2;
else if(g==1)ans++;
cout<<ans;

    return 0;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n, i, poss = 0;
    cin >> n;
    vector <pair <int, int> > a(n);
    for(i = 0; i < n; i++)
    {
        cin >> a[i].first >> a[i].second;
    }
    for(i = 0; i + 2 < n; i++)
    {
        if(a[i].first == a[i].second && a[i + 1].first == a[i + 1].second && a[i + 2].first == a[i + 2].second)
        {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 3624
n=int(input())
T=list(map(int,input().split()))
m=int(input())
PX=[]
for i in range(m):
    PX.append(list(map(int,input().split())))
for i in range(m):
    tmpT=T[:PX[i][0]-1]+T[PX[i][0]:]
    print(sum(tmpT)+PX[i][1])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

const ll MOD=INF;

ll mul(ld a,ld b){
    if(MOD/a<b)return -1;
    return a*b;
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll n;cin>>n;
    ld arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(arr,arr+n,greater<ll>());
    if(arr[n-1]==0){cout<<"0\n";return 0;}
    ll sum=1;
    for(int i=0;i<n;i++){
        sum=mul(sum,arr[i]);
        if(sum==-1){cout<<"-1\n";return 0;}
    }
    cout<<sum<<"\n";
}


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

long long N, M, X[100009], Y[100009], bit[200009], dp[200009], mod = 1000000007; vector<pair<long long, long long>>vec;
vector<int>L[100009];

void add(int pos, long long x) {
	pos++;
	while (pos <= 200008) {
		bit[pos] += x; bit[pos] %= mod; pos += (pos&-pos);
	}
}
long long sum(int pos) {
	long long s = 0; pos++;
	while (pos >= 1) {
		s += bit[pos]; s %= mod; pos -= (pos&-pos);
	}
	return s;
}

int main() {
	cin >> N >> M;
	for (int i = 0; i < N; i++) cin >> X[i];
	for (int i = 0; i < M; i++) cin >> Y[i];
	for (int i = 0; i < N; i++) {
		int pos1 = lower_bound(Y, Y + M, X[i]) - Y;
		if (pos1 >= 1 && pos1 < M) {
			long long r1 = Y[pos1 - 1], r2 = Y[pos1];
			vec.push_back(make_pair(X[i] - r1, r2 - X[i]));
		}
	}
	sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end());

	vector<int>GX, GY;
	for (int i = 0; i < vec.size(); i++) {
		GX.push_back(vec[i].first);
		GY.push_back(vec[i].second);
	}
	sort(GX.begin(), GX.end()); GX.erase(unique(GX.begin(), GX.end()), GX.end());
	sort(GY.begin(), GY.end()); GY.erase(unique(GY.begin(), GY.end()), GY.end());
	for (int i = 0; i < vec.size(); i++) {
		vec[i].first = lower_bound(GX.begin(), GX.end(), vec[i].first) - GX.begin(); vec[i].first++;
		vec[i].second = lower_bound(GY.begin(), GY.end(), vec[i].second) - GY.begin(); vec[i].second++;
		L[vec[i].first].push_back(vec[i].second);
	}
	for (int i = 0; i <= GX.size(); i++) {
		sort(L[i].begin(), L[i].end());
		reverse(L[i].begin(), L[i].end());
	}

	dp[0] = 1; add(0, 1);

	for (int i = 1; i <= GX.size(); i++) {
		for (int j = 0; j < L[i].size(); j++) {
			long long E = sum(L[i][j] - 1);
			dp[L[i][j]] += E; dp[L[i][j]] %= mod;
			add(L[i][j], E);
		}
	}
	long long sum = 0;
	for (int i = 0; i <= GY.size(); i++) { sum += dp[i]; sum %= mod; }
	cout << sum << endl;
	return 0;
}

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

int main(){
    long long W, H;
    long long x, y;
    double area;
    int ans;

    cin >> W >> H >> x >> y;

    area = ((double)W * (double)H) / 2.0;
    if((double)W/2.0 == (double)x && (double)H/2 == (double)y){
        ans = 1;
    }
    else{
        ans = 0;
    }

    cout << fixed << setprecision(15) << area;
    cout << " " << ans << endl;
    return 0;
}

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

#define fst first
#define snd second
#define pb push_back
#define int long long

template<typename T> bool chkmin(T&a, T b) { return a > b ? a = b, 1 : 0; }
template<typename T> bool chkmax(T&a, T b) { return a < b ? a = b, 1 : 0; }

const int maxn = 200000 + 10;

struct bit {
    int c[maxn];
#define lowbit(x) ((x)&(-x))
    void update(int x) {
        for(;x < maxn; x += lowbit(x))
            c[x]++;
    }
    int query(int x) {
        int ans = 0;
        for(;x > 0; x -= lowbit(x))
            ans += c[x];
        return ans;
    }
}bit;

int n, k;
long long d[maxn], ans;
long long a[maxn], s[maxn];

signed main() {

    cin >> n >> k;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        s[i] = s[i-1] + a[i];
        d[i] = s[i] - 1LL*i*k;
        ans += (d[i] >= 0);
    }

    sort(d + 1, d + n + 1);
    for(int i = 1; i <= n; i++) {
        int p = lower_bound(d + 1, d + n + 1, s[i] - i*k) - d;
        ans += bit.query(p);
        bit.update(p);
    }

    cout << ans << endl;

    return 0;
}


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

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

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

  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());

  string ans = "No";
  if(n%3 == 0) {
    // X, Y, X^Y (0, x, x も含む)
    if(a[0] == a[n/3-1] && a[n/3] == a[2*n/3-1] && a[2*n/3] == a[n-1] && (a[0]^a[n/3]) == a[2*n/3]) {
      ans = "Yes";
    }
  } else {
    // 0, 0, 0
    if(a[n-1] == 0) {
      ans = "Yes";
    }
  }

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
n, min_num, max_num = [int(x) for x in input().split()]
xs = range(1, n + 1)

def digit_sum(x):
  return sum([int(d) for d in str(x)])
answers = [x for x in xs if min_num <= digit_sum(x) <= max_num]

print(sum(answers)) 

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

using namespace std;

const int N = 1e5 + 7;

const long long inf = (long long)1e18;

int main() {
    std :: ios :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long n;
    cin >> n;
    int ans = 0;
    for(long long i = 2 ; i * i <= n ; ++i) {
        if(n % i == 0) {
            int vt = 0;
            while(n % i == 0) {
                n /= i;
               // cout << i << "  ---\n";
                vt += 1;
            }
            for(int j = 1 ; ; j++) {
                if(vt >= j) {
                    vt -= j;
                }
                else {
                    break;
                }
                ans++;
            }
        }
    }
    if(n != 1) {
        ans++;
       // cout << "final : " << n << endl;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3652
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: usize,
        b: usize
    }
    println!("{}", if b % a == 0 {a + b} else {b - a});
}


Measured memory_bytes: 4352
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール

// 処理内容
int main() {
    
    ll a, b, c, d; cin >> a >> b >> c >> d;
    ll l = c / __gcd(c, d) * d;

    // 1 ~ b
    ll bc = b / c;
    ll bd = b / d;
    ll bl = b / l;
    ll bx = bc + bd - bl;
    // 1 ~ a
    if (a > 1) {
        ll ac = (a-1) / c;
        ll ad = (a-1) / d;
        ll al = (a-1) / l;
        ll ax = ac + ad - al;
        bx -= ax;
    }

    cout << b-a+1 - bx << endl;

    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
bitset<100000> judge;
ll MOD=1000000007;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  vector<ll> A(m);
  bitset<100020> safe;
  safe.set();
  if(m>0) {
    rep(i,m) {
    int A;
    cin >> A;
    safe.set(A, 0);
    }
  }
  vector<ll> dp(n+10);
  dp[1] = (safe.test(1))
    	  ? 1
    	  : 0;
  dp[2] = (safe.test(2))
          ? dp[1] + 1
          : 0;
  for (int i = 1; i<=n; i++){
    (safe.test(i+2))
    ? dp[i+2] = (dp[i+1] + dp[i]) % MOD
    : dp[i+2] = 0;
  }  
  cout << dp[n] << endl;
}

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

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

  long long e = max(a*c, a*d);
  long long f = max(b*c, b*d);
  
  cout << max(e, f) << endl;
}

Measured memory_bytes: 3632
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from fractions import gcd                    # for Python3.4.3
from itertools import permutations

def main():
    mod = 10000007                  # 10^9+7
    inf = float('inf')
    input = sys.stdin.readline      # 改行文字が残ることに注意
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def ii():  return int(input())
    def mi():  return map(int, input().rstrip().split())
    def lmi(): return list(map(int, input().rstrip().split()))
    def li():  return list(input().rstrip())
    
    n = ii()
    p = tuple(mi())
    q = tuple(mi())
    perm = list(permutations(range(1, n+1))) 
    num_p = perm.index(p)
    num_q = perm.index(q)
    print(abs(num_p - num_q))
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 8052
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;

int main() {
	int N;
	cin >> N;
	string s1,s2;
	cin >> s1 >> s2;
	ll ans;
  	int i=1;
	bool flag=false;
	if(s1[0]!=s2[0]){ ans=6; flag=true; i=2;}//Y
	else ans=3;//X
	for(;i<N;i++){
		if(flag){//Y
			if(s1[i]!=s2[i]){//Y
				ans*=3;
				ans%=MOD;
				i++;
				flag=true;
			}else{//X
				ans*=1;
				ans%=MOD;
				flag=false;
			}
		}else{//X
			if(s1[i]!=s2[i]){//Y
				ans*=2;
				ans%=MOD;
				i++;
				flag=true;
			}else{///X
				ans*=2;
				ans%=MOD;
				flag=false;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def f(n, x):
    a = 0
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            for k in range(j+1, n+1):
                if i + j + k == x:
                    a += 1
    return a

ans = ''
while True:
    n, x = map(int, input().split(' '))
    if n == 0:
        break
    else:
        ans += str(f(n, x)) + '\n'
print(ans[:-1])


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

void cnt_yks(vector<int> &yks,int x){
  
  int y = x;
  for(int i=2;i<=y;i++){
    while(y%i==0){
    	y /= i;
    	yks[i]++;
    }
  }
  return;
}

int main() {
  
  int n; cin >> n;
  vector<int> yks(n+1,0);
    
  for(int i=2; i<=n; i++){
    cnt_yks(yks,i);
  }
  
  long long ans = 1;
  for(int i=2; i<=n; i++){
    if(yks[i]>0){
      ans = (ans*(yks[i]+1)) % 1000000007;
    }
  } 

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int n,m;
	cin >> n >> m;
	int map[m];
	for(int i=0;i<m;i++){
		map[i]=0;
	}

	for(int i=0; i<n ; i++){
		int k;
		cin >> k;
		for(int j=0;j<k;j++){
			int like=0;
			cin >> like;
			map[like-1]+=1;
		}
	}
	int result=0;
	for(int i=0; i<m; i++){
		if(map[i]==n){
			result++;
			}
	}
	cout << result << endl;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
using namespace std;

int N, M;
int p[100000];
int q[100000];
char S[3];

int is_accepted[100000];
int will_be_accepted[100000];


int main() {

	cin >> N >> M;

	for (int i = 0; i < M; i++) {
		cin >> p[i] >> S;
		if (S[0] == 'W') { q[i] = 0; }
		else { q[i] = 1; }
	}

	for (int i = 0; i < N; i++) {
		is_accepted[i] = 0;
		will_be_accepted[i] = 0;
	}

	for (int i = 0; i < M; i++) {
		if (q[i] == 1) {
			will_be_accepted[p[i] - 1] = 1;
		}
	}

	int penalty = 0;
	for (int i = 0; i < M; i++) {
		if (q[i] == 0 && is_accepted[p[i]-1] == 0 && will_be_accepted[p[i]-1] == 1) {
			penalty += 1;
		}
		if (q[i] == 1) {
			is_accepted[p[i]-1] = 1;
		}
	}
	int ac = 0;
	for (int i = 0; i < N; i++) {
		if (is_accepted[i] > 0) {
			ac += 1;
		}
	}

	cout << ac << " " << penalty;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(int i=(int)(st),i##end=(int)(ed);i<=i##end;++i)
#define DREP(i,st,ed) for(int i=(int)(st),i##end=(int)(ed);i>=i##end;--i)
template<typename T>bool chkmin(T &x,const T &y){return x>y?x=y,1:0;}
template<typename T>bool chkmax(T &x,const T &y){return x<y?x=y,1:0;}
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif
template<typename T>T read(){
	T x=0,f=1;
	char c=getchar();
	while((c<'0')||(c>'9')){if(c=='-')f=-1;c=getchar();}
	while((c>='0')&&(c<='9'))x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
#define read() read<int>()
template<typename T>void write(T x,char c){
	static char t[25];
	static int tlen;
	t[tlen=1]=c;
	if(x<0)putchar('-'),x=-x;
	do t[++tlen]=(x%10)^48;
	while(x/=10);
	while(tlen)putchar(t[tlen--]);
}
#define pb push_back
typedef long long ll;
typedef double lf;
int n,m;
int main(){
	n=read(),m=read();
	if(n>m)swap(n,m);
	if(n==1){
		if(m==1)write(1,'\n');
		else write(m-2,'\n');
	}else{
		ll ans=1ll*n*m-2*n-2*(m-2);
		write(ans,'\n');
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 2000000
int H,A[MAX+1];
void maxHeapify(int i){
 int l,r,largest;
 l=2*i;
 r=2*i+1;
 if(l<=H&&A[l]>A[i])largest=l;
 else largest=i;
 if(r<=H&&A[r]>A[largest])largest=r;
 if(largest!=i){
  swap(A[i],A[largest]);
  maxHeapify(largest);
 }
}
int main(){
 cin>>H;
 for(int i=1;i<=H;i++)cin>>A[i];
 for(int i=H/2;i>=1;i--)maxHeapify(i);
 for(int i=1;i<=H;i++)cout<<" "<<A[i];
 cout<<endl;
 return 0;
}


Measured memory_bytes: 4944
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

struct I {
	int n;
	int m;
	int v;
};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;
	vector<I> is;
	FOR_LT(i, 0, n) {
		int a; cin >> a;
		FOR_LT(j, 0, a) {
			int m, v; cin >> m >> v;
			is.push_back({ i, m - 1,v });
		}
	}

	int ans = 0;
	FOR_LT(i, 0, 1 << n) {
		bool is_ok = true;
		for (auto elem : is) {
			if ((i & (1 << elem.n)) == 0) continue;

			bool is_truth = elem.v;
			bool assume = (i & (1 << elem.m));
			if (is_truth != assume) {
				is_ok = false;
				break;
			}
		}
		if (is_ok) {
			int s = 0;
			FOR_LT (j, 0, n) {
				if ((1 << j) & i) {
					s++;
				}
			}
			ans = max(s, ans);
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
	#include <ext/pb_ds/assoc_container.hpp>
	#include <ext/pb_ds/tree_policy.hpp>
	#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
	using namespace std;
	using namespace __gnu_pbds;
	typedef long long ll; 
	#define int long long
	typedef unsigned long long lu;
	typedef vector<ll> v;
	typedef vector<vector<ll> > vv;
	typedef vector<string>  vs;
	typedef vector<pair<ll,ll>> vpr;
	typedef long double ld;
	#define f(i,n) for(ll i = 0; i < n; i++)
	#define ff(i,n) for(ll i=1;i<=n;i++)
	#define pb push_back
	#define mp make_pair
	#define endl "\n"
	#define fi first
	#define se second
	#define all(x) x.begin(),x.end()
	#define rall(x) x.rbegin(),x.rend()
	#define amax(x,y) if(y>x) x=y;
	#define amin(x,y) if(y<x)x=y;
	#define bg(x) x.begin()
	#define sz(x) (ll)x.size()
	#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
	#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
	#define mxt(a) *(max_element(a.begin(),a.end()))
	#define mnt(a) *(min_element(a.begin(),a.end())
	#define tc ll t;cin>>t;while(t--)
	typedef pair<ll,ll> pi;
	#define yes cout<<"YES\n";
	#define no cout<<"NO\n";
	#define yesno(f) if(f) yes else no
	const v dx = {1, -1, 0, 0};
	const v dy = {0, 0, 1, -1};
	const ll mod=1e9+7;
	const ld PI = 2 * acos(0.0);
	ll m(ll a){ return (a+mod)%mod;}
	ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
	ll power(ll a,ll b,ll m)
	{
		if(b==0)
			return 1;
		ll d=power(a,b/2,m);
		d=(d*d)%m;
		if(b&1)
			d=(d*a)%m;
		return d;
	}
	// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
	// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
	/*string operations :
	str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
	str.substr (x) : returns a substring str[x],... end of string
	str.find(qtr) : returns the first occurenece of qtr in str */
	int32_t main()
	{
		ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
		int n;cin>>n;
		int ans=0;
		ff(i,n)
		{
			if(i%3!=0  && i%5!=0)ans+=i;
		}
		cout<<ans<<endl;
		return 0;
	}

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

using namespace std;

#define ll long long
#define endl '\n'

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> sub(n + 1, 0);
    for (int i = 1; i < n; ++i) {
        int temp;
        cin >> temp;
        sub[temp]++;
    }
    for (int k = 1; k <= n; ++k) {
        cout << sub[k] << endl;
    }
    return 0;
}

Measured memory_bytes: 3976
#include<iostream>
#include<cstdio>
#define M 100000
using namespace std;
  
int main(){
    int n, m,l = 0;
    int pos = 0;
    int ans = 0;
    int x[100010];
    scanf("%d %d",&n,&m);
    x[0] = 0;
    for (int i = 1; i < n; i++){
        scanf("%d", &x[i]);
        x[i] += x[i - 1];
    }
    while (m--){
        scanf("%d", &l);
        if(l > 0){
            ans += x[pos + l] - x[pos];
        }
        else{
            ans -= x[pos + l] - x[pos];
        }
        pos += l;
        ans %= M;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 1576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

struct isPrime {
private:
    vector<bool> data;
    
public:
    isPrime() {}
    isPrime(int n) {
        data.resize(n + 1, true);
        data[0] = data[1] = false;
        for(long long i = 2; (i * i) <= n; i++) {
            if (!data[i]) continue;
            for(long long j = 2; (i * j) <= n; j++) {
                data[i * j] = false;
            }
        }
    }
    
    bool is_prime(int n) {
        return data[n];
    }
    
    vector<int> get_primes_vector() {
        vector<int> ans;
        int n = data.size();
        for(int i = 0; i < n; i++) {
            if (data[i]) ans.push_back(i);
        }
        return ans;
    }
    
    set<int> get_primes_set() {
        set<int> ans;
        int n = data.size();
        for(int i = 0; i < n; i++) {
            if (data[i]) ans.insert(i);
        }
        return ans;
    }
};

template<class T>
bool is_prime(T n) {
    if (n <= 1) return false;
    for (long long i = 2; (i * i) <= n; i++) {
        if ((n % i) == 0) return false;
    }
    return true;
}

template<class T>
vector<T> get_divisor(T n) {
    vector<T> res;
    for (long long i = 1; (i * i) <= n; i++) {
        if (n % i != 0) continue;
        res.push_back(i);
        if ((i * i) != n) res.push_back(n / i);
    }
    sort(res.begin(), res.end());
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    if (is_prime(n)) {
        cout << 1 << endl;
        return 0;
    }
    isPrime ip(1000000);
    auto p = ip.get_primes_vector();
    set<ll> s;
    rep(i, sz(p)) {
        ll cv = p[i];
        while(cv <= n) {
            s.insert(cv);
            cv *= p[i];
        }
    }
    // for(auto x : s) printf("%lld\n", x);
    ll ans = 0;
    set<ll> ng;
    while(true) {
        auto div = get_divisor(n);
        bool f = false;
        rep(i, sz(div)) {
            if (s.count(div[i]) > 0) {
                ans++;
                n /= div[i];
                f = true;
                s.erase(div[i]);
                ng.insert(div[i]);
                break;
            }
        }
        if (f) continue;
        reps(i, 1, sz(div)) {
            if ((is_prime(div[i])) && (ng.count(div[i]) == 0)) {
                ans++;
                n /= div[i];
                f = true;
                break;
            }
        }
        if (!f) break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//二項係数の計算
int nCr(int A, int B) {
    ll ans = 1;
    for (int i = 0; i < B; i++) {
        ans*= A - i;
    }
    for (int i = 0; i < B; i++) {
        ans /= i + 1;
    }
    return ans;
}
int main() {
    ll H,W;
    cin>>H>>W;
    if(H==1||W==1){
        cout<<1<<endl;
    }
    else{
        if(H%2==0){
            cout<<H*W/2<<endl;
        }
        else{
            if(W%2==0){
                cout<<H*W/2<<endl;
            }
            else
            {
                cout<<H*W/2+1<<endl;
            }
            
        }

    }
}


Measured memory_bytes: 3592
#include <cstdio>
int main() {
    int a,b,c,x,y,ans;
    scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
    if (a+b > 2*c) while (x && y) x--,y--,ans += 2*c;
    if (a > 2*c) while (x) x--,ans += 2*c;
    if (b > 2*c) while (y) y--,ans += 2*c;
    while (x) x--,ans += a;
    while (y) y--,ans += b;
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solutionB(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solutionA(String[] args) throws Exception{
		int H1=nextInt();
		int M1=nextInt();
		int H2=nextInt();
		int M2=nextInt();
		int K=nextInt();

		int t1=H1*60+M1;
		int t2=H2*60+M2;

		pw.println(t2-t1-K);
	}
	public static void solutionB(String[] args) throws Exception{
		pw.println(nextString().replaceAll("\\?","D"));
	}
	public static void solutionC(String[] args) throws Exception{
		int N=nextInt();
		int[] A = new int[N+2];
		for(int i=1;i<=N+1;i++) {
			A[i]=nextInt();
		}
		long sum=0;
		for(int i=0;i<A.length;i++) {
			sum+=A[i];
		}
		long ans=1;
		//葉ではないノードの数
		long[] s = new long[N+2];
		s[0]=1;

		for(int i=1;i<=N;i++) {
			long tmp = s[i-1]-A[i];
			sum-=A[i];
			if(tmp<=0) {
				pw.println(-1);
				return;
			}
			//残りの葉の数
			long sub=sum-tmp;
			//この階層で何個ノードを作っても矛盾しないか（2倍以内）
			if(sub<0) {
				pw.println(-1);
				return;
			}else {
				tmp=Math.min(tmp*2, tmp+sub);
			}
			s[i]=tmp;
			ans+=tmp;
		}
		pw.println(ans);
	}
	public static void solutionD(String[] args) throws Exception{


	}



	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



Measured memory_bytes: 45844
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    c = c * 2;

    ll ans = 0;

    if(x < y){
        swap(x, y);
        swap(a, b);
    }

    if(a + b > c){
        ans += c * y;
    }else{
        ans += (a + b) * y;
    }

    if(a > c){
        ans += c * (x - y);
    }else{
        ans += a * (x - y);
    }

    cout << ans << endl;

}

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

int main()
{
    int numa, numb, ans;
    cin >> numa >> numb;
    ans = max(numa+numb, numa-numb);
    ans = max(ans, numa*numb);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
use std::io;
use std::str::FromStr;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();

    let mut it = buf.split_whitespace().map(|n| i64::from_str(n).unwrap());
    let (a, b, c) = (it.next().unwrap(), it.next().unwrap(), it.next().unwrap());

    if a == b {
        println!("{}", c);
        return;
    }
    if b == c {
        println!("{}", a);
        return;
    }
    println!("{}", b);
    return;

}


Measured memory_bytes: 4352
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, std::vector<long long> x, std::vector<long long> y, std::vector<long long> h){
  ll t = 0;
  for(; t<N; t++) {
    if(h[t]!=0) {
      break;
    }
  }
  for(ll cx = 0; cx<=100; cx++) {
    for(ll cy=0; cy<=100; cy++) {
      ll H = h[t]+abs(x[t]-cx)+abs(y[t]-cy);
      bool f = true;
      for(ll i=0; i<N; i++) {
	f = f and (h[i] == max(0ll, H-abs(x[i]-cx)-abs(y[i]-cy)));
      }
      if(f) {
	std::cout << cx << " "<< cy<<" " << h[t]+abs(x[t]-cx)+abs(y[t]-cy) << std::endl;
	return;
      }
      // std::cout << (h[0]+abs(x[0]-cx)+abs(y[0]-cy)) << std::endl;
      // std::cout << h[1]+abs(x[1]-cx)+abs(y[1]-cy) << std::endl;
      // return;
    }
  }
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> x(N);
  std::vector<long long> y(N);
  std::vector<long long> h(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&x[i]);
    scanf("%lld",&y[i]);
    scanf("%lld",&h[i]);
  }
  solve(N, std::move(x), std::move(y), std::move(h));
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i< (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}

int main() {
	// 오늘 할 것!  종만북 보기! 
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll a, b; cin >> a >> b;
	a *= b; 
	if (a & 1) {
		cout << "Odd" << '\n';
	}
	else cout << "Even" << '\n';




}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k,s,ans=0;
    cin>>k>>s;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            if(0<=s-i-j&&s-i-j<=k){ans++;}
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
 
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
 
Node root;
 
Node treeMinimum(Node x){
  while(x->left!=NIL)
    x=x->left;
  return x;
 
}
Node treeMaximum(Node x){
  while(x->right!=NIL)
    x=x->right;
  return x;
 
}
 
 
Node treeSearch(Node u, int k){
  while(u!=NIL&&k!=u->key){
    if(k<u->key)u=u->left;
    else u=u->right;
  }
  return u;
}
 
Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL)return treeMinimum(x->right);
  y=x->parent;
   while(y!=NIL&&x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}
 
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL||z->right==NIL)y=z;
  else y=treeSuccessor(z);
 
  if(y->left!=NIL){
    x=y->left;
  }else{
    x=y->right;
  }
 
  if(x!=NIL){
    x->parent=y->parent;
  }
 
  if(y->parent==NIL){
    root=x;
  }else{
    if(y==y->parent->left){
      y->parent->left=x;
    }else{
      y->parent->right=x;
    }
  }
 
  if(y!=z){
    z->key=y->key;
  }
  free(y);
}
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  z->parent = y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key < y->key){
      y->left=z;
    }else{
      y->right=z;
    }
  }
}
 
void inorder(Node u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
 
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
 
  return 0;
}



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

Measured memory_bytes: 3064
#include <iostream>
#include<cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
 
int main() {
    ios::sync_with_stdio(false);
	int n, k, x;
	cin >> n >> k;
	int y = 0;
	for (int i = 0 ; i < n ; i++) {
		cin >> x;
		if (k - x < x) y += k - x;
		else y += x;  
	}
	cout << y * 2;
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (n - 1); i > (a - 1); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define updiv(a, b) ((a + b - 1) / b)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, 1, 1, -1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  int ans = 0;
  int now = 0;
  rep(i, 0, n) {
    int a, b;
    cin >> a >> b;
    if (a == b)
      ++now;
    else
      chmax(ans, now), now = 0;
  }
  chmax(ans, now);
  if (ans >= 3)
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
typedef long long LL;

int main() {
	int a, b;

	std::cin >> a >> b;

	std::cout << a + (b / 2) << std::endl;
}

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

#define endl '\n'
#define Int long long
#define Double long double
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define CLR(a, b) memset(a, b, sizeof a)
#define debug(x) cerr << #x << " " << x << endl;
#define MOD 1000000007
#define MAXN 2002

using namespace std;

int n, k;
int mark[MAXN];
int depth[MAXN];
vector<int> net[MAXN];

void dfs(int v, int d) {
    mark[v] = 1;
    depth[d]++;

    for(int i = 0; i < SZ(net[v]); ++i) {
        if(!mark[net[v][i]])
            dfs(net[v][i], d + 1);
    }
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin >> n >> k;
    for(int i = 0; i < n-1; ++i) {
        int u, v; cin >> u >> v;
        u--, v--;
        net[u].push_back(v);
        net[v].push_back(u);
    }
    int ans = INT_MAX;
    if(k%2 == 0) {
        for(int i = 0; i < n; ++i) {
            CLR(mark, 0);
            CLR(depth, 0);

            dfs(i, 0);

            int res = 0;
            for(int i = k/2 + 1; i < n; ++i)
                res += depth[i];
            ans = min(res, ans);
        }
    } else {
        for(int i = 0; i < n; ++i) {
            for(int j = 0; j < SZ(net[i]); ++j) {
                CLR(mark, 0);
                CLR(depth, 0);

                mark[net[i][j]] = 1;
                dfs(i, 0);

                dfs(net[i][j], 0);

                int res = 0;
                for(int l = k/2 + 1; l < n; ++l) {
                    res += depth[l];
                }

                ans = min(ans, res);
            }
        }
        
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512