akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 112345
int a[N];

int main(){
	int n; scanf("%d", &n);
	REP(i, n) scanf("%d", a+i);
	sort(a, a+n);
	printf("%d", a[n/2]-a[n/2-1]);
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int N=160;
typedef pair<int,int> pii;
#define mp make_pair
#define fi first
#define se second

int n,m,mod;
map<pii,int> f[N][N][N];

void inc(int &a,int b) {
	a=a+b>=mod?a+b-mod:a+b;
}

int main() {
	cin>>n>>m>>mod;
	if(m&1) {
		f[0][0][0][mp(n+1,n+1)]=1;
		for(int i=1;i<=n;i++)
			for(int j=0;j<=n;j++)
				for(int k=0;k<=n;k++)
					for(auto x:f[i-1][j][k]) {
						if(i&1) {
							inc(f[i][0][k][mp(n+1,x.fi.se)],x.se);
							if(i!=x.fi.fi) {
								if(i-m>=i-2*k+1) inc(f[i][j+1][k][mp(x.fi.fi,min(x.fi.se,max(i+1,i-2*j+m)))],x.se);
								else inc(f[i][j+1][k][x.fi],x.se);
							}
						}
						else {
							inc(f[i][j][0][mp(x.fi.fi,n+1)],x.se);
							if(i!=x.fi.se) {
								if(i-m>=i-2*j+1) inc(f[i][j][k+1][mp(min(x.fi.fi,max(i+1,i-2*k+m)),x.fi.se)],x.se);
								else inc(f[i][j][k+1][x.fi],x.se);
							}
						}
					}
		int ans=0;
		for(int i=0;i<=n;i++)
			for(int j=0;j<=n;j++)
				for(auto x:f[n][i][j]) inc(ans,x.se);
		cout<<ans;
	}
	else {
		m>>=1;
		static int f[N][N];f[0][0]=1;
		for(int i=0;i<n;i++)
			for(int j=0;j<=m;j++) {
				inc(f[i+1][0],f[i][j]);
				if(j<m) inc(f[i+1][j+1],f[i][j]);
			}
		int x=0,y=0;
		for(int i=0;i<=m;i++)
			inc(x,f[n>>1][i]),inc(y,f[(n+1)>>1][i]);
		cout<<1ll*x*y%mod;		
	}
	return 0;
}


Measured memory_bytes: 245888
import java.util.ArrayList;
import java.util.Scanner;

class Item {
    int value,weight; //????????????????????????
    public Item(int value, int weight) {
        this.value = value;
        this.weight = weight;
    }
    public int getValue() {
        return this.value;
    }
    public int getWeight() {
        return this.weight;
    }
}

public class Main {
    
    static int N,W; //??????????????°?????????
    static int Nmax = 105;
    static int Wmax = 10005;
    static ArrayList<Item> items = new ArrayList<>(); //???????????????????????????
    static int[][] C = new int[Nmax+1][Wmax+1]; //?????????????¨?????????§????????????
    
    public static int knapsack() {
        int result = 0;
        int maxVal = 0;
        for(int i = 1; i <= N; i++) {
            for(int w = 1; w <= W; w++) {
                if(items.get(i).getWeight() <= w) {
                    if(items.get(i).getValue() + C[i-1][w - items.get(i).getWeight()] > C[i-1][w]) {
                        C[i][w] = items.get(i).getValue() + C[i-1][w - items.get(i).getWeight()];
                    } else {
                        C[i][w] = C[i-1][w];
                    }
                }else{
                    C[i][w] = C[i-1][w]; //?????????????????????
                }
            }
            maxVal = C[N][W];
        }
        return result=maxVal;
    }
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        W = sc.nextInt();
        
        Item padding = new Item(0,0);
        items.add(padding);
        
        for(int i = 0; i < N; i++) {
            Item item = new Item(sc.nextInt(),sc.nextInt());
            items.add(item);
        }
        
        System.out.println(knapsack());
    }
    
}

Measured memory_bytes: 31396
# Problem A - Colorful Slimes 2

# input process
N = int(input())
a_list = list(map(int, input().split()))

# initialization
magic_num = 0
chohuku_num = 0

# count process
for i in range(0, N):
    if i==0:
        continue

    if a_list[i]==a_list[i-1]:
        chohuku_num += 1
    else:
        magic_num += (chohuku_num + 1) // 2
        chohuku_num = 0
magic_num += (chohuku_num + 1) // 2

print(magic_num)


Measured memory_bytes: 38384
N, M = map(int, input().split())
B = [0 for _ in range(M+1)]

for i in range(N):
    KA = list(map(int, input().split()))
    for a in KA[1:]:
        B[a] += 1
count = 0
for b in B:
    if b == N:
        count += 1
print(count)


Measured memory_bytes: 38256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  lint N,K;
  cin>>N>>K;
  lint M=N%K;
  cout<<min(M,K-M)<<endl;
  return 0;
}


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

#define pb            push_back
#define mp            make_pair
#define all(x)        x.begin(),x.end()
#define debug(X)      { cerr<<'\n'<<(#X)<<" = "<<(X)<<'\n'; }
//#define cerr if(0)cerr

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll k,a,b;
    string ok="NG";
    cin>>k>>a>>b;

    for (int i=a; i<=b; ++i) {
        if (i%k==0) ok="OK";
    }
    cout<<ok;
}



Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c=0,d=0,e,f,g;
  cin >>a;
  for(int n=0;n<a;n++){
    e=0;
    cin >>b>>c>>d;
    if(d<c){
      if(d<b) e+=d,b=b-d,c=c-d,d=0;
      else e+=b,b=0,c=c-b,d=d-b;
    }
    else{
      if(c<b) e+=c,b=b-c,c=0,d=d-c;
      else e+=b,b=0,c=c-b,d=d-b;
    }
    f=b/2;
    if(f>c) e+=c,b=b-(2*c),c=0;
    else e+=f,b=b-(2*f),c=c-f;
    f=b/3,e+=f;
    cout <<e<<'\n';
  }
  return (0);
}



Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
 
int main()
{

    int n;
    cin>>n;

    vector<int> d(n);
    for(int i=0;i<n;i++){
        cin>>d.at(i);
    }

    int sum=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            sum+=d.at(i)*d.at(j);
        }
    }

    cout<<sum<<endl;

    return 0;
}  




Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>

using namespace std;

const int FIRST = -1;

int main() {
  while( true ) {
	int n;
	cin >> n;
	if ( n == 0 ) break;
	
	int begin = FIRST;
	int end = begin;
	for ( int i = 0; i < n; i++ ) {
	  int val;
	  cin >> val;
	  if ( begin == FIRST ) {
		begin = end = val;
	  } else if( val == end + 1 ){
		end = val;
	  } else {
		if ( begin == end ) {
		  cout << begin << " ";
		} else {
		  cout << begin << "-" << end << " ";
		}
		begin = end = val;
	  }
	}
	if ( begin == end ) {
	  cout << begin << endl;
	} else {
	  cout << begin << "-" << end << endl;
	}
  }
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const int N=16;
int n;
int z[N][N];
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n;

    REP(i,N)
        fill(z[i], z[i]+N,-1);

    REP(i,n){
        int a;
        cin>>a;
        REP(j,a){
            int  x,y;
            cin>>x>>y;
            z[i][x-1] = y;
        }
    }
    
    int ans = 0;
    for(int bit=0; bit < 1<<n; bit++){
        bool flg = true;
        int honest = 0;
        REP(i,n){
            REP(j,n){ 
                int stati = (bit>>i) & 1;
                int statj = (bit>>j) & 1;

                if(z[i][j] != -1 && stati==1 && z[i][j] != statj){
                    // DEBUG2(i, j);
                    // DEBUG2(z[i][j], statj);
                    flg = false;
                }

                if(!flg) break;
            }

            if(bit & 1<<i) honest++;
        }
        if(flg && ans < honest) ans = honest;
    }

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

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

/* ======IO====== */
var (
	InputString func() string
	stdout      *bufio.Writer
)

func init() {
	InputString = newInputString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newInputString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("error scan")
		}
		return r.Text()
	}
}

func InputInt() int {
	return int(readInt64())
}
func InputInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func InputInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func InputInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(InputString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func InputIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = InputInt()
	}
	return b
}

func InputFloat64() float64 {
	return float64(inputFloat64())
}

func inputFloat64() float64 {
	f, err := strconv.ParseFloat(InputString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func InputFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = InputFloat64()
	}
	return b
}

func InputRuneSlice() []rune {
	return []rune(InputString())
}

/* ======Math====== */
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

func Sum(integers ...int) int {
	s := 0

	for _, i := range integers {
		s += i
	}

	return s
}

func AbsInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

/* ======Util====== */

func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic("strtoi error")
	} else {
		return i
	}
}

//
//type sortable [][]int
//
//func (s sortable) Len() int { return len(s) }
//
//func (s sortable) Less(i, j int) bool { return s[i][0] < s[j][0] }
//
//func (s sortable) Swap(i, j int) { s[i], s[j] = s[j], s[i] }

func main() {
	n := InputInt()
	as := InputIntSlice(n)

	ans := make([]string, n)
	for i, a := range as {
		ans[a-1] = strconv.Itoa(i + 1)
	}

	fmt.Println(strings.Join(ans, " "))
}


Measured memory_bytes: 6528
import java.util.Scanner;

class Main{
  public static void main(String[]args){
    Scanner  sc=new Scanner(System.in);
    int k,a,b;
    k=sc.nextInt();
    a=sc.nextInt();
    b=sc.nextInt();
    boolean flag=true	;
    for(int i=a;i<=b;i++){
      if(i%k==0){
        System.out.println("OK");
       flag=false;
        break;
      }
    }
    if(flag)
      System.out.println("NG");
  }
}


Measured memory_bytes: 35744
#define DEBUG 0

/**
 * File    : E2.cpp
 * Author  : Kazune Takahashi
 * Created : 2019-5-26 00:18:02
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

const int MAX_SIZE = 1000010;
const long long MOD = 1000000007;

long long inv[MAX_SIZE];
long long fact[MAX_SIZE];
long long factinv[MAX_SIZE];

void init()
{
  inv[1] = 1;
  for (int i = 2; i < MAX_SIZE; i++)
  {
    inv[i] = ((MOD - inv[MOD % i]) * (MOD / i)) % MOD;
  }
  fact[0] = factinv[0] = 1;
  for (int i = 1; i < MAX_SIZE; i++)
  {
    fact[i] = (i * fact[i - 1]) % MOD;
    factinv[i] = (inv[i] * factinv[i - 1]) % MOD;
  }
}

long long C(int n, int k)
{
  if (n >= 0 && k >= 0 && n - k >= 0)
  {
    return ((fact[n] * factinv[k]) % MOD * factinv[n - k]) % MOD;
  }
  return 0;
}

long long power(long long x, long long n)
{
  if (n == 0)
  {
    return 1;
  }
  else if (n % 2 == 1)
  {
    return (x * power(x, n - 1)) % MOD;
  }
  else
  {
    long long half = power(x, n / 2);
    return (half * half) % MOD;
  }
}

long long gcd(long long x, long long y)
{
  return y ? gcd(y, x % y) : x;
}

ll N, M, K;
ll ans = 0;

void solve()
{
  ll t = N * N;
  t %= MOD;
  t *= inv[6];
  t %= MOD;
  t *= C(N * M - 2, K - 2);
  t %= MOD;
  t *= ((M - 1) * M * (M + 1)) % MOD;
  t %= MOD;
  ans += t;
  ans %= MOD;
}

int main()
{
  init();
  cin >> N >> M >> K;
  solve();
  swap(N, M);
  solve();
  cout << ans << endl;
}

Measured memory_bytes: 23680
import heapq
N, M = map(int, input().split())
task = []
for i in range(N):
    heapq.heappush(task, tuple(map(int, input().split())))
heapq.heappush(task, (1000000,1000000))

availR = []
ans = 0
for i in range(M+1):  #i日前
    while task[0][0] <= i:
        tmp = list(heapq.heappop(task))
        tmp[1] *= -1
        tmp = tuple(reversed(tmp))
        heapq.heappush(availR, tmp)
    #print(availR)
    if len(availR) >= 1:
        todayReward = heapq.heappop(availR)[0] * (-1)
        ans += todayReward

print(ans)


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001001001001ll;

int N,C;
int X[555555],V[555555];
int S[555555];

int ans;

void solve(){
    rep(i,N)S[i+1]=S[i]+V[i];
    int ma=-INF;
    for(int i=N-1;i>=0;i--){
        chmax(ans,S[i+1]-X[i]);
        chmax(ans,S[i+1]-2*X[i]+ma-C);
        chmax(ma,S[N]-S[i]+X[i]);
    }
}

signed main(){
    cin>>N>>C;
    vint x(N),v(N);
    rep(i,N)cin>>x[i]>>v[i];

    rep(t,2){
        rep(i,N){
            X[i]=x[i];
            V[i]=v[i];
        }
        solve();
        rep(i,N)x[i]=C-x[i];
        reverse(all(x));reverse(all(v));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6784
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
const int INF = 1e9;

int n, k; //????????° ???????????¬??°
int c[5010], r[5010]; //???????????£?¶???????????????????????????¬??°
vector<int> d[5010];//???????????£??\
int G[5010][5010];//r?????¶???????????????????????????????????£??\???????????§?¨????

int dist[5010]; //0->i??????????°??????????
bool used[5010]; //?????£??????????¨????

void dijkstra(int start){
	rep(i, n) dist[i] = INF;//?????????
	dist[start] = 0;
	while(1){
		int v = -1;
		//???????????????????????????????????????????????¢???????°???????????????¢???
		for (int u = 0; u < n; ++u){
			if(!used[u] && (v == -1 || dist[u] < dist[v])) v = u;
		}
		//?????????????????¢???????°???????????????????v???
		if(v == -1) break;
		used[v] = true;//?????¨??????
		for (int u = 0; u < n; ++u){
			dist[u] = min(dist[u], dist[v] + G[v][u]);//??????????????£??\????????????G?????¨??§?????????
		}
	}
}

int main(void){
	cin >> n >> k;
	rep(i, n) cin >> c[i] >> r[i];
	rep(i, k){
		int a, b; cin >> a >> b;
		a--; b--;
		d[a].push_back(b);
		d[b].push_back(a);
	}

	rep(i, 5010)rep(j, 5010) G[i][j] = INF;
	//???????????¢?´¢?????¨?????????i???->j?????????????????¨?????§?????????????¨?????????????
	for (int i = 0; i < n; ++i){
		queue<pair<int, int> > q; q.push(make_pair(i, 0));//<???, ?????¬???>
		int cnt = 0;
		while(!q.empty()){
			auto now = q.front(); q.pop();
			if(now.second >= r[i]) continue;
			for(auto j : d[now.first]){
				if(G[i][j] != INF) continue;
				q.push(make_pair(j, now.second + 1));
				G[i][j] = c[i];//??£??\??????????????£????????????????¨????
			}
		}
	}
	dijkstra(0);
	printf("%d\n", dist[n - 1]);
}

Measured memory_bytes: 101752
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
end

nums = inputs[1]

def rec(arr, buf)
  l = arr.size
  return buf if l == 0
  l.times do |j|
    if arr[l-1-j] == l-j
      arr.delete_at(l-1-j)
      return rec(arr, (buf << (l-j)))
    end
  end
  return [-1]
end

puts rec(nums, []).reverse


Measured memory_bytes: 1916
H,W,A,B = map(int,input().split())
for i in range(H):
    rowInvert = i >= B
    row = []
    for j in range(W):
        colInvert = j >= A
        invert = rowInvert ^ colInvert
        if invert:
            v = "1"
        else:
            v = "0"
        row.append(v)
    print("".join(row))

Measured memory_bytes: 3956
#include <stdio.h>
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	if (a<b){
		printf("a < b\n");
	}else if(a>b){
		printf("a > b\n");
	}else if(a=b){
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 1008
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s; cin >> s;
	for(int i = 0; i < s.size(); i++) cout << (s[i] == '?' ? 'D' : s[i]);

	return 0;
}

Measured memory_bytes: 3788
g=[[0]*5 for _ in[0]*5]
for i in range(9):
 e=input()
 for j in range(4+i%2):
  if int(e[j]):
   if i%2:g[i//2][j]+=4;g[i//2+1][j]+=1
   else:r=g[i//2];r[j]+=2;r[j+1]+=8
y,x=0,1
k=1
a='1'
while 1:
 k=k%4+2
 for _ in[0]*4:
  k+=1
  if g[y][x]&int(2**(k%4)):a+=str(k%4);break
 if k%2:x+=[1,-1][(k%4)>1]
 else:y+=[-1,1][(k%4)>0]
 if x+y==0:break
print(''.join('URDL'[int(c)]for c in a))


Measured memory_bytes: 5612
#include <iostream>
#include <cstdio>

int main(void) {
  int A, B;

  scanf("%d %d", &A, &B);

  if ( A >= 13 ) printf("%d\n", B);
  else if ( A >= 6 && A <= 12) printf("%d\n", B / 2);
  else printf("0\n");

  return 0;

}


Measured memory_bytes: 256
object Main extends App {
  val n = scala.io.StdIn.readInt()
  var read = scala.io.StdIn.readLine()
  val array =  read.split(" ").map(_.toInt).toVector
  var hArray = Vector.empty[Int]

  array.zipWithIndex.foreach{ case(h, index) =>
    if (index == 0) {
      hArray :+= h
    } else {
      if(h >= hArray.max) {
        hArray :+= h
      }
    }
  }
  print(hArray.length)
}

Measured memory_bytes: 25544
s = [str(x) for x in input()]
t = [str(x) for x in input()]

def solve(s_list,t_list,n):
    if n== 120:
        return print("No")
    a = s_list.pop(-1)
    s_list.insert(0,a)
    if s_list ==t_list:
        return print("Yes")
    else:
        solve(s,t,n+1)

solve(s,t,0)

Measured memory_bytes: 38384
<?php
fscanf(STDIN, "%s", $n);
for ($i = 0; $i < $n; $i++) {
	$f[$i] = bindec(str_replace(' ', '', trim(fgets(STDIN))));
}
for ($i = 0; $i < $n; $i++) {
	$p[$i] = explode(' ', trim(fgets(STDIN)));
}

for ($b = 0; $b < 1024; $b++) {
	$c[$b] = substr_count(decbin($b), '1');
}

$x = PHP_INT_MIN;
for ($t = 1; $t < 1024; $t++) {
	$q = 0;
	for ($i = 0; $i < $n; $i++) {
		$b = $f[$i] & $t;
		$q += $p[$i][$c[$b]];
	}
	if ($q > $x) $x = $q;
}
echo $x;

Measured memory_bytes: 4728
fun main() {
    val list1 = readLine()!!.split(" ").map { it.toInt() }.toMutableList()
    val list2 = readLine()!!.split(" ").map { it.toInt() }.toMutableList()
    val list3 = readLine()!!.split(" ").map { it.toInt() }.toMutableList()

    val bngList = listOf(list1, list2, list3)

    val n = readLine()!!.toInt()

    var bngNum = List(n) {
        readLine()!!.toInt()
    }

    val bingo = listOf(
        mutableListOf(0, 0, 0),
        mutableListOf(0, 0, 0),
        mutableListOf(0, 0, 0)
    )

    for (i in 0..2){
        for (j in 0..2){
            if (check(bngList[i][j],bngNum)){
                bingo[i][j] = 1
            }
        }
    }

    if(bingoCheck(bingo)){
        println("Yes")
    }else{
        println("No")
    }

}

fun check(a: Int, b: List<Int>): Boolean {
    for (i in b) {
        if (a == i) {
            return true
        }
    }
    return false
}

fun bingoCheck(list: List<MutableList<Int>>):Boolean{

    for (i in 0..2){
        if (list[i][0] == 1 && list[i][1] == 1 && list[i][2] == 1){
            return true
        }

        if (list[0][i] == 1 && list[1][i] == 1 && list[2][i] == 1){
            return true
        }
    }

    if (list[0][0] == 1 && list[1][1] == 1 && list[2][2] == 1){
        return true
    }

    if (list[0][2] == 1 && list[1][1] == 1 && list[2][0] == 1){
        return true
    }

    return false

}

Measured memory_bytes: 38860
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
      cin>>a[i];
    }

    int sum = 0;
    for (int i = 0; i < n; i++) {
      sum +=a[i];
    }

    int out = 1;
    for (int t = 2; t <= sum; t++) {
      if(sum%t) continue;

      vector<int> mod;

      int kpsum=0;
      for (int i = 0; i < n; i++) {
        mod.push_back(a[i]%t);
        kpsum += a[i]%t;
      }

      sort(mod.begin(),mod.end());
      int ith = n-kpsum/t;
      int ktry=0;
      for (int i=0; i<ith; i++) {
        ktry+=mod[i];
        if(ktry>k) break;
      }
      //cout<<ktry<<endl;
      if(ktry>k) continue;

      out = t;
    }

    cout<<out<<endl;
    return 0;
}


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

using namespace std;

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

#define F first
#define S second

const int MAXN = 3e5 + 10;
const int MOD = 998244353;

int n, a, b;
ll k;
int ss[MAXN], tt[MAXN];

int pw(int a, int b){
	int ret = 1;
	while (b){
		if (b & 1)
			ret = 1ll*ret*a%MOD;
		b >>= 1;
		a = 1ll*a*a%MOD;
	}
	return ret;
}

int choose(int a, int b){
	if (a < b) return 0;
	return 1ll*ss[a]*tt[a-b]%MOD*tt[b]%MOD;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ss[0] = 1;
	for (int i = 1; i < MAXN; i++) ss[i] = 1ll*ss[i-1]*i%MOD;
	tt[0] = 1;
	for (int i = 1; i < MAXN; i++) tt[i] = 1ll*tt[i-1]*pw(i, MOD-2)%MOD;

	cin >> n >> a >> b >> k;
	ll ans = 0;
	for (int i = 0; i <= n; i++){
		ll rem = k - 1ll*i*a;
		if (rem < 0 || rem % b != 0 || rem/b > n) continue;

		ans = (ans + 1ll*choose(n, i)*choose(n,rem/b)%MOD) % MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD 998244353
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}



int main() {
    ll h,w,k;
    cin >> h >> w >> k;
    string c[h];
    for (ll i=0;i<h;i++)cin >> c[i];
    ll count=0;
    for (ll i=0;i<h;i++){
        for (ll j=0;j<w;j++){
            if (c[i][j]=='#'){
                count++;
            }
        }
    }
    ll ans=0;
    for (ll i=0;i<(1<<h);i++){
        for (ll j=0;j<(1<<w);j++){
            ll x=count;
            for (ll k=0;k<h;k++){
                for (ll l=0;l<w;l++){
                    if ((1<<k)&i or (1<<l)&j){
                        if (c[k][l]=='#')x--;
                    }
                }
            }
            if (x==k)ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
using System;

namespace TestConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);
            var c = int.Parse(input[2]);

            while (a > b || b > c)
            {
                if (a > b)
                {
                    var temp = a;
                    a = b;
                    b = temp;
                }
                if (b > c)
                {
                    var temp = b;
                    b = c;
                    c = temp;
                }
            }

            Console.WriteLine($"{a} {b} {c}");
        }
    }
}



Measured memory_bytes: 17932
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;cin>>N;
  int A[N+2];FOR(i,1,N+1)cin>>A[i];
  A[0]=A[N+1]=0;
  int mx=0;
  FOR(i,0,N+1){
    mx+=abs(A[i+1]-A[i]);
  }
  FOR(i,0,N){
    cout<<mx-abs(A[i+1]-A[i])-abs(A[i+2]-A[i+1])+abs(A[i+2]-A[i])<<endl;
  }
}

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

int main()
{
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    char t[200005], d[200005];
    for(int i = 0; i < q; i++) cin >> t[i] >> d[i];
    int left = 0, right = n + 1;
    while(right - left > 1){
        int mid = (right + left) / 2;
        int p = mid;
        bool f = false;
        for(int i = 0; i < q; i++){
            if(s[p - 1] == t[i]){
                if(d[i] == 'L') p--;
                else p++;
            }
            if(p <= 0) f = true;
        }
        if(f) left = mid;
        else right = mid;
    }
    int l = left;
    left = 0, right = n + 1;
    while(right - left > 1){
        int mid = (right + left) / 2;
        int p = mid;
        bool f = false;
        for(int i = 0; i < q; i++){
            if(s[p - 1] == t[i]){
                if(d[i] == 'L') p--;
                else p++;
            }
            if(p > n) f = true;
        }
        if(f) right = mid;
        else left = mid;
    }
    int r = right;
    cout << max(0, n - l - (n + 1 - r)) << endl;
}


Measured memory_bytes: 4156
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int max(int a,int b){
    if(a>b){
        return a;
    }
    else{
        return b;
    }
} 

int main(void){
    int i,a,b,c,k,val;
    scanf("%d %d %d",&a,&b,&c);
    scanf("%d",&k);
    val = max(max(a,b),c);
    for(i=0;i<k;i++){
        val = val*2;
    }

    printf("%d\n",val+a+b+c-max(max(a,b),c));

    return 0;
}

Measured memory_bytes: 128
N,M=map(int,input().split())
A=["10"]*N
for i in range(M):
    s,c=input().split()
    s=int(s)
    s-=1
    if (A[s]!="10" and A[s]!=c) or (s==0 and c=="0" and N!=1):
        print("-1")
        exit()
    A[s]=c
for i in range(N):
    if A[i]=="10":
        if N==1:
            A[i]="0"
        elif i==0:
            A[i]="1"
        else:
            A[i]="0"
print("".join(A))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T> inline T sqr(T t) {return t*t;}
#define pb push_back
#define mp make_pair
#define endl "\n"

inline void files()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef _WIN32
        return;
    #endif // _WIN32
    //freopen("C.in", "r", stdin);freopen("C.out", "w", stdout);
}



int main(){
    files();
    int n;
    cin >> n;
    if (n%10==9||n/10==9)
    cout << "Yes"; else
    cout << "No";
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    l = [1,2,3]
    l.remove(A)
    l.remove(B)
    print(l[0])
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


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

int main() {
  string a;
  string b;
  string c;
  cin >> a >> b >> c;
  char d = a.at(0);
  char e = b.at(0);
  char f = c.at(0);
  cout << d << e << f << endl;
}

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

int main(){
  int n, m;
  cin >> n >> m;
  long long ans = 0;
  for ( int i = m/n ; i >= 1 ; i--){
    if ( m % i == 0 && m/i >= n){
      ans = i;
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	ll l,r;
	cin >> l >> r;
	ll ans = 11000;
	bool zero = true;
	if(r-l>=2019){
		zero=false;
	}
	if(zero){
		for(ll i=l; i<r; i++){
			for(ll j=l+1; j<=r; j++){
				ans = min(ans, ((i%2019)*(j%2019))%2019);
			}
		}
		cout << ans << endl;
	}else{
		cout << 0 << endl;
	}
}

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

#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define FORD(i,a,b) for(int i=a;i>=b;--i)
#define maxn 110
#define maxweight 100010

typedef long long ll;
using namespace std;
const ll oo = 1e18;

struct dta { int w, v; };

int n, W;
ll F[maxn][maxweight];
dta A[maxn];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> W;
    FOR(i, 1, n) cin >> A[i].w >> A[i].v;
    FOR(i, 1, W) F[0][i] = -oo;
    F[0][0] = 0;
    FOR(i, 1, n)
    FOR(j, 0, W) {
        F[i][j] = F[i-1][j];
        if (j-A[i].w >= 0) F[i][j] = max(F[i][j], F[i-1][j-A[i].w] + A[i].v);
    }

    ll res = 0;
    FOR(i, 1, W) res = max(res, F[n][i]);
    cout << res;
	return 0;
}


Measured memory_bytes: 80128
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

static vector<uint32_t> array;

int32_t main()
{
  uint32_t N;
  cin >> N;

  array.push_back(0);
  for(uint32_t i = 0; i< N; i++){
    uint32_t val;
    cin >> val;
    array.push_back(val);
  }

  uint32_t count = 0;
  for(uint32_t i = 1; i < array.size(); i++){
    if(array[i] == i){
      swap(array[i], array[i+1]);
      count++;
    }
  }

  if(array[array.size() - 1] == N){
    count++;
  }

  cout << count << endl;

  return 0;
}


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

int main(){
    long N, A, B;
    cin >> N >> A >> B;

    long sum = 0;
    long x = N / (A + B);
    sum += A * x;
    long y = N - (A + B) * x;
    if(y <= A){
        sum += y;
    }
    else if(y > A){
        sum += A;
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
from sys import stdin

N = int(input())
A = list(map(int,stdin.readline().split()))

ans = 0

if 0 in A:
    pass
else:
    temp = 1
    for a in A:
        temp *= a
        if temp > 10**18:
            ans = -1
            break
    else:
        ans = temp

print(ans)


Measured memory_bytes: 21908
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int ui;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
#define All(v) (v).begin(),(v).end()
#define Rep(i,n) for(int i = 0; i < (int)n; i++)
#define Reps(i,n) for(int i = 1; i <= (int)n; i++)
#define For(i,m,n) for(int i = m; i < n; i++)
#define Fors(i,m,n) for(int i = m; i <= n; i++)
#define Inf 2e9
#define F first
#define S second
#define pb push_back
#define mp make_pair
struct speed{speed(){cin.tie(); ios::sync_with_stdio(false); cout << fixed << setprecision(18);}}speed;

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

ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

ll lcm(ll a, ll b){
    return a*b/gcd(a,b);
}


int main (){
    int w,h,x,y;
    cin >> w >> h >> x >> y;
    cout << w/2.0*h << " ";
    if(x == w/2.0 && y == h/2.0){
        cout << 1 << "\n";
    }else{
        cout << 0 << "\n";
    }
}

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

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<vector<int>> dp(n + 10, vector<int>(n + 10));
    for (int i = 1; i <= 2; ++i) {
        for (int j = 1; j <= n; ++j) {
            cin >> dp[i][j];
            dp[i][j] += max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    cout << dp[2][n] << "\n";
    return 0;
}


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

int main() {
    int n,b=0;
    cin>>n;
	int a[n];
	for(int i = 0; i < n; i++)
	cin>>a[i];
	
	//sort(a,a+3);
	for(int i = 0; i < n; i++)
	{
	    if(a[i]%2 == 0)
	    {
	        if(a[i]%3 != 0 && a[i]%5 != 0)
	        {
	            b = 1;
	            cout<<"DENIED"<<endl;
	            break;
	        }
	    }
	}
	if(b == 0)
	cout<<"APPROVED"<<endl;
	
	 
	return 0;
}

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

int main(){
  int H, N;
  
  cin >> H >> N;
  
  int A[N];
  
  for(int i=0; i < N; i++){
    cin >> A[i];
  }
  
  for(int i=0; i<N; i++){
    H-=A[i];
  }
  if(H <= 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 640
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MAX 5005
using namespace std;
//char nc()
//{
//	static char buf[100000],*p1=buf,*p2=buf;
//	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
char nc(){return getchar();}
int read()
{
	int x=0,y=1;
	char c=nc();
	while(!isdigit(c))
	{
		if(c=='-')y=-1;
		c=nc();
	}
	while(isdigit(c))
	{
		x=(x<<1)+(x<<3)+(c^48);
		c=nc();
	}
	return x*y;
}
int n,k;
char s[MAX<<1],ans[MAX];
void chkmn(int st)
{
	for(int i=0;i<n;i++)
		if(s[st+i]<ans[i])
		{
			for(int j=0;j<n;j++)
				ans[j]=s[st+j];
			return;
		}
		else if(s[st+i]>ans[i]) return;
}
int main()
{
	n=read();k=read();
	scanf("%s",s);
	for(int i=0;i<n;i++)
		s[n+i]=s[n-i-1];
	ans[0]='z'+1;
	for(int i=0;i<n;i++)
		chkmn(i);
	int L=0;
	while(L<n&&ans[L]==ans[0]) L++;
	if(k>14||L*(1<<(k-1))>=n)
		for(int i=0;i<n;i++)
			putchar(ans[0]);
	else
	{
		int len=L*(1<<(k-1));
		for(int i=0;i<len;i++)
			putchar(ans[0]);
		for(int i=len;i<n;i++)
			putchar(ans[i-len+L]);
	}
	return 0;
}


Measured memory_bytes: 3744
n=int(input())
l=list(map(int,input().split()))
memo={}

for i in range(n+1):
    if l[i]in memo:
        g=l[i]
        x,y=memo[g],i
        break
    memo[l[i]]=i
mod=10**9+7

fact=[1]*(n+1+1)
inv=[1]*(n+1+1)
for i in range(2,n+1+1):
    fact[i]=i*fact[i-1]%mod
inv[-1]=pow(fact[-1],mod-2,mod)
for i in range(n+1,1,-1):
    inv[i-1]=inv[i]*i%mod
def comb(x,y):return fact[x]*inv[y]%mod*inv[x-y]%mod if x>=y>=0 else 0
for i in range(1,n+2):print((comb(n+1,i)-comb(x+n-y,i-1))%mod)

Measured memory_bytes: 29396
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DLuckyPIN solver = new DLuckyPIN();
        solver.solve(1, in, out);
        out.close();
    }

    static class DLuckyPIN {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            String s = in.next();
            int cnt = 0;
            for (int i = 0; i < 1000; i++) {
                int x = i / 100;
                int y = (i / 10) % 10;
                int z = i % 10;
                if (exist(s, (char) (x + '0'), (char) (y + '0'), (char) (z + '0'))) {
                    cnt++;
                }
            }
            out.println(cnt);
        }

        boolean exist(String s, char x, char y, char z) {
            boolean fx = false;
            boolean fy = false;
            boolean fz = false;
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == x && !fx) {
                    fx = true;
                    continue;
                }
                if (s.charAt(i) == y && fx && !fy) {
                    fy = true;
                    continue;
                }
                if (s.charAt(i) == z && fy && !fz) {
                    fz = true;
                    break;
                }
            }

            return fz;
        }

    }
}



Measured memory_bytes: 23764
def q2():
    N = int(input())
    P = [int(i) for i in input().split()]
    P_sorted = sorted(P)
    cnt = 0
    for i, p in enumerate(P):
        if P[i] - P_sorted[i] != 0:
            cnt += 1

    if cnt == 0 or cnt == 2:
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    q2()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  double t, x;
  cin >> t >> x;

  cout << t/x << endl;


  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>



int main()
{
	int moun[10];
	int top[3]={0,0,0},pos[3];
	int i=0,j,ne=0;/*更新*/

	do
	{
		scanf("%d",moun+i);
		if(0<=moun[i] && moun[i]<=10000)
			i++;
	}while(i<10);

	for(i=0;i<10;i++)
	{
		for(j=0;j<3;j++)
		{
			if(!ne && moun[i]>top[j])
			{	
				pos[j] = top[j];
				top[j] = moun[i];
				ne = 1;/*1,2番目の更新が起こったときに必要*/
			}
			else if(ne)
			{
				pos[j] = top[j];
				top[j] = pos[j-1];
			}
		}
		ne = 0;
	}

	for(i=0;i<3;i++)
	{
		printf("%d\n",top[i]);
	}

	return 0;
}

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;

template<typename T, typename Op>
struct segment_tree {
    size_t offset;
    vector<T> v;

    const Op f;
    const T t0;

    segment_tree(size_t size, const T &unit = T(), const Op &op = Op()): f(op), t0(unit) {
        offset = 1;
        while (offset < size) offset <<= 1;
        v.assign(offset << 1, unit);
        offset--;
    }

    void update(size_t i, const T &x) {
        i += offset;
        v[i] = x;
        while (i >>= 1) {
            v[i] = f(v[i << 1 | 0], v[i << 1 | 1]);
        }
    }

    T query(size_t l, size_t r) {
        T lv = t0, rv = t0;
        for (l += offset, r += offset; l < r; l >>= 1, r >>= 1) {
            if (l & 1) lv = f(lv, v[l++]);
            if (r & 1) rv = f(v[--r], rv);
        }
        return f(lv, rv);
    }
};

void solve() {
    i64 n;
    cin >> n;
    vector<i64> h(n);
    for (auto& e : h) cin >> e;
    vector<i64> a(n);
    for (auto& e : a) cin >> e;

    auto maximum = [](i64 x, i64 y) { return max(x, y); };
    segment_tree<i64, decltype(maximum)> dp(n, 0, maximum);
    for (i64 i = 0; i < n; i++) {
        dp.update(h[i], dp.query(1, h[i]) + a[i]);
    }
    cout << dp.query(1, n + 1) << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


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

int main(){
    set<int> s;
    int a,b,c;
    scanf(" %d %d %d",&a,&b,&c);
    s.insert(a);s.insert(b);s.insert(c);
    if(s.size() == 2) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque
N, M = map(int, input().split())
dic = defaultdict(list)
par =  [0]*(N+1)
cnt = [0]*(N+1)
for i in range(N-1+M):
  a, b = map(int, input().split())
  dic[a] += [b]
  cnt[b] += 1

for i in range(1,N+1):
  if cnt[i]==0:
    q = deque([i])
    break
  
while q:
  m = q.popleft()
  for c in dic[m]:
    cnt[c] -= 1
    if cnt[c]==0:
      par[c] = m
      q += [c]

for i in range(1,N+1):
  print(par[i])

Measured memory_bytes: 76372
#include <iostream>

using namespace std;

void solve()
{
	int A, B, C;
	cin >> A >> B >> C;
	if (A <= C && C <= B)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

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

Measured memory_bytes: 256
if __name__ == '__main__':
    n = int(input())
    ans = 99999999
    for i in range(1, n):
        total = list(str(n-i)) + list(str(i))
        tmp = 0
        for t in total:
            tmp += int(t)
        ans = min(ans, tmp)
    print(ans)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		try (Scanner scan = new Scanner(System.in)) {
			
			int N = scan.nextInt();
			int K = scan.nextInt();
			int ans = 0;
					
			for(int i=0; i<N; i++) {
				int h = scan.nextInt();
				if(h >= K) ++ans;
			}
			
			System.out.println(ans);
			return;
			
		}
	}
}

Measured memory_bytes: 48480
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long int r,d,x;
	cin>>r>>d>>x;
	for(int i=0;i<10;i++)
	{
	    cout<<((r*x)-d)<<endl;
	    x=((r*x)-d);
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n;
    int arr[n];
    cin>>m;
    for(int i=0; i<n; i++)
        cin>>arr[i];

    int sum = 0;
    for(int i=0; i<n; i++)
    {
        sum+=arr[i];
    }
    int count =0;
    for(int i=0; i<n; i++)
    {
        if(arr[i]>=(1.0*sum/(4.0*m)))
            {
                count++;
            }
    }
    if(count>=m)
    {
        cout<<"Yes"<<endl;

    }
    else
    {
        cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 3636
import sys
from decimal import Decimal
def input(): return sys.stdin.readline().rstrip()


def twofive(x):
    cnt = 0
    while x % 2 == 0:
        x = x//2
        cnt += 20
    while x % 5 == 0:
        x = x//5
        cnt += 1
    return cnt


def main():
    n = int(input())
    bag = [0]*1000
    ans = 0
    for _ in range(n):
        bag[twofive(int(Decimal(input())*10**9))] += 1
    for i in range(999):
        for j in range(i+1, 1000):
            i2 = i//20
            i5 = i % 20
            j2 = j//20
            j5 = j % 20
            if i2+j2 >= 18 and i5+j5 >= 18:
                ans += bag[i]*bag[j]
    for k in range(1000):
        if k//20 >= 9 and k % 20 >= 9:
            ans += (bag[k]*(bag[k]-1))//2

    print(ans)


if __name__ == '__main__':
    main()

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

int main(){
	int n; cin >> n;
	int res=n;
	for(int i=0;i<=n;i++){
		int cc=0;
		int t=i;
		while(t>0) {
			cc+=t%6;
			t/=6;
		}
		t=n-i;
		while(t>0){
			cc+=t%9;
			t/=9;
		}
		if(res>cc) res=cc;
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define pii pair<int, int>
#define pll pair<long long, long long>
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
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() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string S; cin >> S;
    int N = S.size();

    bool ok = false;
    if (S[0] == S[N-1]) {
        if (N%2==0) ok = true;
    } else {
        if (N%2==1) ok = true;
    }

    cout << (ok ? "First" : "Second") << endl;
}


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

// 2つの整数の場合
long long GetLeastCommonMultiple(long long a, long long b) {
	long long m = a;
	long long n = b;
	long long temp;

	while (m % n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}
	return a / n * b;
}

int main()
{
	ll a, b, c, d; cin >> a >> b >> c >> d;
	
	if (d < c) swap(c, d);

	ll can_c_num = b / c - (a - 1) / c;
	ll can_d_num = b / d - (a - 1) / d;

	ll t = GetLeastCommonMultiple(c, d);
	ll can_cd_num = b / t - (a - 1) / t;

	ll tmp = can_c_num + can_d_num - can_cd_num;

	cout << b - a + 1 - tmp << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define INF 1e9
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int,int> P;
struct edge{int to,cost;
	edge(int t,int c):to(t),cost(c){}
};

int d[10100],N,M,L,K,A,H,f[100];
vector<edge> g[10100];

void dijkstra(int s){
	priority_queue<P,vector<P>,greater<P> > q;
	fill(d,d+10100,INF);
	d[s]=0;
	q.push(P(0,s));
	while(!q.empty()){
		P p=q.top();q.pop();
		int v=p.second;
		if(d[v]<p.first)continue;
		rep(i,g[v].size()){
			edge e=g[v][i];
			if(d[e.to]>d[v]+e.cost){
				d[e.to]=d[v]+e.cost;
				q.push(P(d[e.to],e.to));
			}
		}
	}
}

int main(){
	while(cin>>N>>M>>L>>K>>A>>H&&N){
		rep(i,10100)g[i].clear();
		rep(i,L){
			int n;
			cin>>n;
			rep(j,M)for(int k=1;j+k<=M;k++)g[j*100+n].push_back(edge((j+k)*100+n,k));
		}
		rep(i,K){
			int X,Y,T;
			cin>>X>>Y>>T;
			rep(j,M+1)if(j>=T){
				g[j*100+X].push_back(edge((j-T)*100+Y,T));
				g[j*100+Y].push_back(edge((j-T)*100+X,T));
			}
		}
		dijkstra(M*100+A);
		int ans=INF;
		rep(i,M+1)ans=min(ans,d[i*100+H]);
		if(ans!=INF)cout<<ans<<endl;
		else cout<<"Help!"<<endl;
	}
}

Measured memory_bytes: 7572