akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST
import Data.Array.IO
import Data.Char
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
readInt = fst . fromJust . B.readInt
readInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine :: IO [Int]
readIntegers = map (fst . fromJust . B.readInteger) . B.words <$> B.getLine :: IO [Integer]
read2dInts = map (map (fst . fromJust . B.readInt) . B.words) . B.lines <$> B.getContents
readVInts = map (fst . fromJust . B.readInt) . B.lines <$> B.getContents

main :: IO ()
main = do
  (n:q:_) <- map read . words <$> getLine :: IO [Int]
  qs <- read2dInts
  -- qs <- replicateM q $ map read . words <$> getLine :: IO [[Int]]
  solve n qs

solve :: Int -> [[Int]] -> IO ()
solve n qs = do
  arr <- newArray (0, n) [] :: IO (IOArray Int [Int])
  forM_ qs $ \(query:t:qss) -> do
    at <- readArray arr t :: IO [Int]
    case query of
      0 -> do
        let ([x]) = qss 
        writeArray arr t (x:at) :: IO () 
        return arr
      1 -> do
        if null at
          then return ()
          else print $ head at
        return arr
      2 -> do
        if null at
          then return ()
          else writeArray arr t $ tail at
        return arr
        


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

int main(){
  string s[100];
  int n, l;
  cin >> n >> l;
  for(int i = 0; i < n; i++){
    cin >> s[i];
  }
  
  sort(s, s+n);
  
  for(int i = 0; i < n; i++){
    cout << s[i];
  }
  
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n, i, ct=0;
  cin >> n;
  int p[n];
  for(i=0; i<n; i++){
    cin >> p[i];
    if(p[i]!=i+1) ct++;
  }
  if(ct==0||ct==2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

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

int main() {
  int n; cin >> n;
  if (n & 1) {
    cout << "No" << endl;
    return 0;
  }
  string s; cin >> s;
  for (int i = 0; 2 * i < s.length(); i++)
   	if (s[i] != s[i + s.length() / 2]) {
      cout << "No" << endl;
      return 0;
    }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
ans = 0
cnt = 0
for i in range(N-1):
    if H[i] >= H[i+1]:
        cnt += 1
    else:
        ans = max(cnt,ans)
        cnt = 0
ans = max(cnt,ans)
print(ans)

Measured memory_bytes: 14252
package main

import (
	"fmt"
)

func main() {
	var k, a, b int
	fmt.Scan(&k, &a, &b)

	for i := a; i <= b; i++ {
		if i%k == 0 {
			fmt.Println("OK")
			return
		}
	}
	fmt.Println("NG")
}


Measured memory_bytes: 1752
def main():
    N, K  = map(int, input().split())
    P = list(map(int, input().split()))
    best = sum(P[:K]) # sum of first K terms
    curr = best # tmp var for iteration
    for i in range(N - K):
        curr += P[i+K] - P[i] # slide window
        best = max(best, curr)
    print((best + K) / 2) # based on n(n+1)/2 == sum(range(1, n))

if __name__ == '__main__':
    main()

Measured memory_bytes: 24804
#include <string>
#include <algorithm>
#include <iostream>
#define OPEN 0
using namespace std;
int main(){
	int N,K;
	string S;
	#if OPEN
		freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	#endif
	while(cin>>N>>S>>K){
		char t = S[K-1];
		string out= S;
		int s = out.size();
		for(int i = 0;i<s;i++){
			if(out[i]!=t)out[i] = '*';
		}
		cout<<out<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define REP(i,b,e) for(int i=b; i<e; i++)

int main(){
        int n;
        scanf("%d", &n);
        int f[n];
        REP(i, 0, n){
                f[i] = 0;
                REP(j, 0, 10){
                        getchar();
                        f[i] |= (getchar()%2)<<j;
                }
        }

        int p[n][11];
        REP(i, 0, n) REP(j, 0, 11) scanf("%d", &p[i][j]);

        int ans = -1e9;
        REP(i, 1, 1<<10){
                int tmp = 0;
                REP(j, 0, n) {
                        int c = 0;
                        for(int a=i&f[j]; a; a>>=1) c += a&1;
                        tmp += p[j][c];
                }
                if(ans<tmp) ans = tmp;
        }
        printf("%d\n", ans);
        return 0;
}

Measured memory_bytes: 128
import java.lang.*;
import java.util.*;
class Main
{
  public static void main(String args[])
  {
    String s;int k;
    Scanner sc=new Scanner(System.in);
    k=sc.nextInt();
    s=sc.next();
    String s1[]=s.split("");
    if(s1.length<=k)
    {
     System.out.println(s);
    }
    else
    {
      for(int i=0;i<k;i++)
      {
        System.out.print(s1[i]+"");
      }
      System.out.println("...");
    }
  }
}


Measured memory_bytes: 38736
N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]


def solve(X):
    if not ("1" in X and "2" in X and "3" in X):
        return 1e10

    MS = [[L[i] for i in range(N) if X[i] == j] for j in "123"]
    ret = 1e10
    A_ans = []
    B_ans = []
    C_ans = []
    for i in range(3):
        A_ans.append(solve2(MS[i], A))
        B_ans.append(solve2(MS[i], B))
        C_ans.append(solve2(MS[i], C))
    ret = min(ret, A_ans[0] + B_ans[1] + C_ans[2])
    ret = min(ret, A_ans[0] + B_ans[2] + C_ans[1])
    ret = min(ret, A_ans[1] + B_ans[0] + C_ans[2])
    ret = min(ret, A_ans[1] + B_ans[2] + C_ans[0])
    ret = min(ret, A_ans[2] + B_ans[0] + C_ans[1])
    ret = min(ret, A_ans[2] + B_ans[1] + C_ans[0])
    return ret


def solve2(M, target):
    def rec(Y, target):
        # Y: [1, 0, 0]
        if len(Y) == len(M):
            if len(set(Y)) == 1 and Y[0] == 0:
                return 1e10
            sum_M = sum([M[i] for i in range(len(M)) if Y[i] == 1])
            return abs(target - sum_M) + 10 * (Y.count(1) - 1)
        return min(rec(Y + [0], target), rec(Y + [1], target))
    ret = rec([], target)
    return ret


ans = 1e10


def rec(X):
    global ans
    if len(X) == N:
        ans = min(ans, solve(X))
        return
    rec(X + "1")
    rec(X + "2")
    rec(X + "3")


rec("")

print(ans)


Measured memory_bytes: 3316
#include <stdio.h>
int ABC42(void);
int ABC43(void);

int main(void){
    ABC43();
    return 0;
}

int ABC42(void){
    int a,b,c,n=0;
    scanf("%d %d %d",&a,&b,&c);
    if(a==7||b==7||c==7){
        if((a==5&&b==5)||(b==5&&c==5)||(c==5&&a==5)){
            printf("YES");
            n++;
    }}
    if(n==0)printf("NO");
    return 0;
}

int ABC43(void){
    int i,n,sum=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        sum+=i;
    }
    printf("%d",sum);
}

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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef rsd511
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    #endif
    #ifndef rsd511
    #define trace(...) {}
    #define cotra(...) {}
    #endif
} 

// Code Here

ll s;
ll dp[4001];

ll solve(ll sofar) {
    if(sofar == s) return 1;
    if(sofar > s) return 0;
    if(dp[sofar] != -1) return dp[sofar];
    dp[sofar] = 0;
    f(i,3,2000) dp[sofar] += solve(sofar + i) % MOD, dp[sofar] %= MOD;
    return dp[sofar];
}

int main()
{
    Fast_IO();
    cin >> s;
    f(i,0,4000) dp[i] = -1;
    cout << solve(0) << endl;
    return 0;
}

Measured memory_bytes: 3692
n = gets.to_i
ans = Array.new
cnt = 0
for i in 2..30000
    break if cnt >= n-2
    if i%2 == 0 || i%3 == 0
        ans.push(i)
        cnt += 1
    end
end
rem = ans.inject(:+)%6
if rem == 0
    ans.push(30000).push(29994)
elsif rem == 1
    ans.push(29996).push(29997)
elsif rem == 2
    ans.push(29998).push(30000)
elsif rem == 3
    ans.push(30000).push(29997)
elsif rem == 4
    ans.push(30000).push(29996)
elsif rem == 5
    ans.push(29997).push(29998)
end
if n == 3
    puts "2 5 63"
else
    puts ans.join(" ")
end

Measured memory_bytes: 2300
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(){
	int a, b, v, w, t;
	scanf("%i %i %i %i %i", &a, &v, &b, &w, &t);
	if(w > v){
		puts("NO");
		return 0;
	}else{
		int difp = abs(a - b);
		int difs = abs((v - w) * t);
		if(difp <= difs){
			puts("YES");
		}else{
			puts("NO");
		}
	}
	return 0;
} 


Measured memory_bytes: 1660
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
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;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;

 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
  
 

vll dp(100100);

ll sum(ll n) {
ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}




 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
    ci(n);
  vll A(n);
  FOR(i,0,n){
    ci(A[i])
  }
  SORT(A);

  ll m=A[n-1];
  vll B(n-1);
  FOR(i,0,n-1){
    B[i]=min(A[i],m-A[i]);
  }
  SORT(B);

  bl b=true;

  FOR(i,0,n-1){
    if(A[i]==B[n-2]){
      cout<<m<<" "<<A[i]<<endl;
      b=false;
      break;
    }
  }

  if(b){
    cout<<m<<" "<<m-B[n-2]<<endl;
  }
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
inline void solve(void){
  int N;in(N);
  if(N&1)out((N-1)/2);
  else out(N/2-1);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
import Math._
object Main extends App {
  val Seq(a, b, degc) = readLine.split(' ').map(_.toDouble).toList
  val radc = toRadians(degc)
  println(a * b * sin(radc) / 2)
  println(a + b + sqrt(a*a + b*b - 2*a*b*cos(radc)))
  println(b * sin(radc))
}


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

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

int main()
{
    int S[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << S[K - 1] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<string> vs;
Def inf = sizeof(Def)==sizeof(ll)?2e18:1e9+10;
int n,co;
vvi w;
string s,t;
int dp[110][110][2];//min max
int dfs(int l,int r,int c){
	if(c&&dp[l][r][c]!=-inf)return dp[l][r][c];
	if(!c&&dp[l][r][c]!=inf)return dp[l][r][c];
	
	int out=inf;
	if(c)out=-inf;
	if(l==r)return t[l]-'0';
	if(w[l][1]||w[r][0])return inf;
	loop(i,l,r){
		int a,b;
		if(c){
			a=dfs(l,i,1);
			if(w[i+1][2]==0)b=dfs(i+1,r,1);
			else b=-dfs(i+1,r,0);
		}else{
			a=dfs(l,i,0);
			if(w[i+1][2]==0)b=dfs(i+1,r,0);
			else b=-dfs(i+1,r,1);
		}
		if(abs(a)==inf||abs(b)==inf)continue;
		if(c)out=max(out,a+b);
		else out=min(out,a+b);
	}
//	cout<<l<<" "<<r<<" "<<c<<" "<<out<<endl;
	return dp[l][r][c]=out;
}
int main(){
	cin>>s;
	n=s.size();
	int co=0;
	rep(i,n)if(isdigit(s[i]))co++;
	w=vvi(co,vi(3));
	t="";
	rep(i,s.size()){
		if(s[i]=='('){
			w[t.size()][0]=true;
		}else if(s[i]==')'){
			w[t.size()-1][1]=true;
		}else if(isdigit(s[i])){
			t+=s[i];
		}else if(s[i]=='-'){
			w[t.size()][2]=true;
		}
	}
	rep(i,110)rep(j,110){
		dp[i][j][0]=inf;
		dp[i][j][1]=-inf;
	}
//	cout<<t<<endl;
//	show2d(w);
	cout<<dfs(0,co-1,1)<<endl;
}













Measured memory_bytes: 3316
N = gets.to_i
Ts, Vs = readlines.map{|l| l.split.map(&:to_i)}
INF = 1000000

tvs = Ts.each_with_object([0]){|t, a| a << a.last + t}.zip(Vs + [0])
r = 0.step(tvs.last.first, 0.5)
v1s = r.map{|t| tvs.map{|x, y| x >= t ? y + (x - t) : INF}.min}
v2s = r.map{|t| (tvs.reverse_each.find{|x, y| x < t} || [0]).last}
puts v1s.zip(v2s).drop(1).inject([0]){|a, (v1, v2)| a << [a.last + 0.5, v1, v2].min}.inject(:+) / 2.0

Measured memory_bytes: 6980
import Foundation

let input = readLine()!.split(separator: " ").map { Decimal(string: String($0))! }
let A = input[0]
let B = input[1]

var result = A * B
let locale = NSLocale.current
print(NSDecimalString(&result, locale).split(separator: Character(locale.decimalSeparator!))[0])


Measured memory_bytes: 17272
#include <iostream>
#include <vector>
#include <utility>

using namespace std;
typedef pair<int, int> pii;
const int INF = 1000000000;

int main(){
	ios_base::sync_with_stdio(false);
	int n, d;
	cin >> n >> d;
	vector< vector<int> > p(d, vector<int>(n + 1, INF));
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < d; ++j){ cin >> p[j][i]; }
	}
	vector< vector<pii> > dp(d + 1, vector<pii>(n + 1, pii(INF, INF)));
	vector< vector<int> > trace(d + 1, vector<int>(n, -1));
	dp[d][n] = pii(0, 0);
	for(int i = d - 1; i >= 0; --i){
		for(int j = 0; j < n; ++j){
			for(int k = 0; k <= n; ++k){
				const pii cur = dp[i + 1][k];
				const int a = cur.first + p[i][j];
				const int b = cur.second + (j == k ? 0 : 1);
				const pii next(a, b);
				if(next < dp[i][j]){
					dp[i][j] = next;
					trace[i][j] = k;
				}
			}
		}
	}
	int cur = 0;
	for(int i = 1; i < n; ++i){
		if(dp[0][i] < dp[0][cur]){ cur = i; }
	}
	cout << dp[0][cur].first << " " << (dp[0][cur].second - 1) << endl;
	for(int i = 0; i < d; ++i){
		cout << (cur + 1) << endl;
		cur = trace[i][cur];
	}
	return 0;
}

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

bool perfectSquare(int n) {
 for(int i=1; i*i<=n; i++) {
   if(i*i==n) return true;
 }
 return false;
}

using namespace std;

int main() {
  int n, d, ans=0;
  cin>>n>>d;
  vector<vector<int> > v(n, vector<int> (d));
  for(int i=0; i<n; i++) {
    for(int j=0; j<d; j++) {
      cin>>v[i][j];
    }
  }
  
  for(int i=0; i<n; i++) {
    for(int j=i+1; j<n; j++) {
      int sum = 0;
      for(int k=0; k<d; k++) {
        sum += (v[i][k]-v[j][k])*(v[i][k]-v[j][k]);
      }
      if(perfectSquare(sum)) ans++;
    }
  }
  
  cout<<ans;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
	int a =	sc.nextInt();
	int b =	sc.nextInt();
	int c =	sc.nextInt();
	int d =	sc.nextInt();
	int ab = (int)Math.abs(a-b);
	int bc = (int)Math.abs(b-c);
	int ca = (int)Math.abs(c-a);
	if(ca<=d) {
            System.out.println("Yes");
            return;
        }
	if(ab<=d && bc<=d) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define caseout(i, x) cout << "Case #" << i << ": " << x << endl;

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

    int n,k;
    cin >> n >> k;

    if((n+1)/2<k)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

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

	sort(a.begin(), a.end());


	cout << (a[0] + a[1]);
	return 0;
}

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


int H;

int A[252];

int parent(int i){return i/2;};
int right(int i){return 2*i + 1;};
int left(int i){return 2*i;};

int main(){
	cin >> H;
	for(int i=0;i<H;i++)cin >> A[i];
	for(int i=0;i<H;i++){
		cout << "node " << i+1 << ": key = " << A[i] << ", ";
		if(parent(i+1)>0) cout << "parent key = " << A[parent(i+1)-1] << ", ";
		if(left(i+1)<H+1)cout <<  "left key = " << A[left(i+1)-1] << ", ";
		if(right(i+1)<H+1)cout <<  "right key = " << A[right(i+1)-1] << ", ";
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 3088
#include<stdio.h>                                                                             
int main(void){
    int x,y,i;
    int a[6]={1,3,5,7,8,12};
    int b[4]={4,6,9,11};
    int c = 2;
    int judge[2];
    scanf("%d %d",&x,&y);
    for(i=0;i<4;i++){
            if(x==2){
                   judge[0]=0; 
                   break; 
            }   
            else if(x==b[i]){
                   judge[0]=1; 
                   break;
            }   
            if(i==3){
                   judge[0]=2; 
            }   
    }   
    for(i=0;i<4;i++){
            if(y==2){
                   judge[1]=0; 
                   break; 
            }   
            else if(y==b[i]){
                   judge[1]=1; 
                   break;
            }   
            if(i==3){
                   judge[1]=2; 
            }   
    }   
    if(judge[0]==judge[1]){
            printf("Yes");
    }else{
            printf("No");
    }   
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
    char ch[4];
    for (int i = 0; i < 4; i++)
        ch[i] = getchar();
    if (ch[1] == ch[2] && (ch[0] == ch[1] || ch[2] == ch[3])) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    string str;
    cin>>str;

    if(str == "ABC") {
        cout<<"ARC"<<endl;
    } else {
        cout<<"ABC"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3128
maxlen = 10**5+1
n, channel = [ int(v) for v in input().split() ]
use_list = [ [ 0 for i in range(maxlen) ] for i in range(channel) ]

for i in range(n):
    a, b, c = [ int(v) for v in input().split() ]
    for j in range(a,b+1):
        use_list[c-1][j] = 1


ans = 0
for i in range(maxlen):
    max_at_i = sum([ use_list[j][i] for j in range(channel) ])
    ans = max(max_at_i,ans)
print(ans)

Measured memory_bytes: 118728
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}



	public void run() {
		Scanner sc = new Scanner(System.in);
		char ss[] = sc.next().toCharArray();
		char t[] = sc.next().toCharArray();
		char s[] = Arrays.copyOf(ss, ss.length);
		ArrayList<String> aList = new ArrayList<String>();
		for(int i=0; i<s.length-t.length+1; i++) {
			boolean ok=true;
			for(int j=0; j<t.length; j++) {
				if(s[i+j] != '?' && s[i+j] != t[j]) {
					ok=false;
					break;
				}
			}
			if(ok) {
				StringBuilder sb = new StringBuilder();
				for(int j=0; j<t.length; j++) {
					s[i+j]=t[j];
				}
				for(int j=0; j<s.length; j++) {
					sb.append(s[j]);
				}
				aList.add(sb.toString().replaceAll("\\?", "a"));
				s = Arrays.copyOf(ss, ss.length);
			}
		}
		Collections.sort(aList);
		if(aList.size()==0) {
			System.out.println("UNRESTORABLE");
		} else {
			System.out.println(aList.get(0));
		}
		sc.close();
	}

}


Measured memory_bytes: 23380
import bisect
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a.sort()
b.sort()
c.sort()

ans = 0
for i in range(n):
    p = bisect.bisect_left(a,b[i])
    q = bisect.bisect_right(c,b[i])
    ans += p * (n-q)

print(ans)

Measured memory_bytes: 23328
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


struct Niku{
    double x; double y; double c;
};

double dist(double x1, double y1, double x2, double y2){
    double dy = y1 - y2;
    double dx = x1 - x2;
    return sqrt(dy*dy + dx*dx);
}

void circleCrossPoints(double x1, double y1, double r1, double x2, double y2, double r2, vector<pair<double, double>>& points){
    double d = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
    if(d > r1 + r2) return;
    double rc = (d*d + r1*r1 - r2*r2) / (2*d);
    double rs = sqrt(r1*r1 - rc*rc);
    double dx = (x2 - x1) / d;
    double dy = (y2 - y1) / d;
    points.emplace_back(x1 + dx*rc - dy*rs, y1 + dy*rc + dx*rs);
    points.emplace_back(x1 + dx*rc + dy*rs, y1 + dy*rc - dx*rs);
}

void addPoints(Niku& a, Niku& b, double t, vector<pair<double, double>>& points){
    double r1 = t / a.c;
    double r2 = t / b.c;
    circleCrossPoints(a.x, a.y, r1, b.x, b.y, r2, points);
}


bool acceptable(pair<double, double>& p, LL k, vector<Niku>& niku, double t){
    LL cnt = 0;
    for(Niku a: niku){
        double r = dist(p.first, p.second, a.x, a.y);
        if(r < t / a.c + 1.0e-9) cnt++;
    }
    return cnt >= k;
}


bool acceptable(LL n, LL k, vector<Niku>& niku, double t){
    vector<pair<double, double>> points;
    for(LL i = 0; i < n; ++i){
        points.emplace_back(niku[i].x, niku[i].y);
        for(LL j = i+1; j < n; ++j){
            addPoints(niku[i], niku[j], t, points);
        }
    }
    for(auto p: points){
        if(acceptable(p, k, niku, t)) return true;
    }
    return false;
}

int main(){
    LL n, k;
    cin >> n >> k;
    vector<Niku> niku(n);
    for(LL i = 0; i < n; ++i){
        cin >> niku[i].x >> niku[i].y >> niku[i].c;
    }
    double right = 10000000;
    double left = 0;
    for(LL e = 0; e < 50; ++e){
        double middle = (left + right) / 2;
        if(acceptable(n, k, niku, middle)){
            right = middle;
        }else{
            left = middle;
        }
    }
    cout << setprecision(13) << left << endl;
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
// #include<vor>
using namespace std;
typedef long long int ll;
#define pb push_back
ll mod = 1e9+7;

ll powm(ll a , ll b , ll mod)
{
  ll res = 1;
  while(b)
  {
    if(b & 1)
    res = (res *a)%mod;
    a = (a*a)%mod;
    b>>1;
  }
  return res;
}
ll gcd(ll a , ll b);
ll power(ll x , ll y , ll m);

ll modInverse(ll a , ll m)
{
  ll g = gcd(a,m);
  if(g != 1)
  return 1;
  else
  return power(a,m-2,m);

}

ll power(ll x , ll y , ll m)
{
  if(y == 0)
  return 1;
  ll p = power(x , y/2 , m)%m;
  p = (p*p)%m;

  return (y%2 == 0) ? p : (x *p) % m;
}

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

void solve()
{
  ll n;
  cin>>n;
  // cout<<"hi\n";
  while(n > 0)
  {
    if(n%10 == 7)
    {
      cout<<"Yes\n";
      return;
    }
    n/=10;
  }
  cout<<"No\n";
}

int main()
{
  // int tc;
  // cin>>tc;
  // while(tc--)
  // {
    solve();
  // }
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;
#define FOR(i,n) for(i=0;i<=n;++i)
#define DEBG(s) cout<<s<<endl;
int i,j,a,b,c;

int main(void){
    int k,s,cnt=0;
    cin>>k>>s;
    FOR(i,k){
        FOR(j,k){
            int jdg = s-i-j;
            if(0<=jdg&&jdg<=k)cnt++;
        }
    }
    cout<<cnt;
    
    return 0;
}


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

// bool isPrime(int num){
//     for(int i=6;i<num;i=(i%7==1 ? i+5:i+2)){
//         if(num%i==0) return false;
//     }
//     return true;
// }

int main(){
    int flags[300000+1];
    rep(i,300001) flags[i]=true;
    for(int i=6;i<=300000;i=(i%7==1 ? i+5 : i+2)){
        if(flags[i]){
            for(int j=i*2;j<=300000;j+=i){
                flags[j]=false;
            }
        }
    }
    while(true){
        int num;
        cin >> num;
        if(num==1) break;

        vector<int> ans;
        for(int i=6;i<=num;i=(i%7==1 ? i+5 : i+2)){
            if(num%i==0 && flags[i]){
                ans.push_back(i);
            }//else if(num%i==0 && isPrime(num/i)){
            //     ans.insert(num/i);
            // }
        }
        cout << num << ": ";
        // for(set<int>::iterator itr=ans.begin();itr!=ans.end();itr++){
        //     cout << *itr << " ";
        // }
        rep(i,ans.size()){
            cout << ans[i];
            if(i!=ans.size()-1) cout << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 4308
class Pre753
  attr_reader :n
  def initialize(n,digits=nil)
    @n=n
    if digits
      @digits=digits
    else
      @digits=Array.new(10,0)
      until n==0
        d=n%10
        @digits[d]+=1
        n/=10
      end
    end
  end

  def is753?
    @digits[7]>0&&@digits[5]>0&&@digits[3]>0
  end

  def create_new_pre753(d)
    _dig=@digits.dup
    _dig[d]+=1
    Pre753.new(10*@n+d,_dig)
  end
end

n=gets.to_i

a=[]
digit_num_wise=[7,5,3].map{|d|Pre753.new(d)}
8.times{
  _dnw=[]
  digit_num_wise.each{|pre|
    [7,5,3].each{|d|
      _dnw << pre.create_new_pre753(d)
    }
  }
  _dnw.each{|pre|a << pre if pre.is753?}
  digit_num_wise=_dnw
}

a.sort_by!{|pre|pre.n}
a<< Pre753.new(10**9)
ans=a.bsearch_index{|v|n<v.n}

puts ans

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

int main()
{
  int n, t, a;
  int h;
  float T;
  int idx = 0;
  float min = FLT_MAX;

  cin >> n >> t >> a;
  for (int i = 0; i < n; i++) {
    cin >> h;
    T = abs(t - 0.006 * h - a);
    if (T < min) {
      idx = i;
      min = T;
    }
  }

  cout << idx + 1 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String arg[]){
        Scanner scn=new Scanner(System.in);
        int a=scn.nextInt();
        int b=scn.nextInt();
        int c=scn.nextInt();
        int flag=0;
        if(a<b){
            if(a<c&&c<b){
                flag++;
            }
        }else{
            if(b<c&&c<a){
                flag++;
            }
        }
        
        if(flag==1){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


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

void solve(long long N, long long K, std::string S) {
    if (S[K-1] == 'A') {
        S[K-1] = 'a';
    } else if (S[K-1] == 'B') {
        S[K-1] = 'b';
    } else if (S[K-1] == 'C') {
        S[K-1] = 'c';
    }
    cout << S << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips:
// You use the default template now. You can remove this line by using your
// custom template)
int main() {
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  std::string S;
  std::cin >> S;
  solve(N, K, S);
  return 0;
}


Measured memory_bytes: 3672
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <string>

using namespace std;

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

ll const INF = 1000000000000000000;
int const I_MAX = 2147483647;
ll const MOD = 1e9 + 7;
int const POW_MAX = 1e5;

// nCr
ll po[POW_MAX + 2];
ll mod_pow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}
ll mod_inv (ll x) {
  return mod_pow(x, MOD - 2) % MOD;
}
ll comb(int n, int r) {
  return (((po[n] * mod_inv(po[r])) % MOD) * mod_inv(po[n - r])) % MOD;
}
// greatest common divisor
ll gcd(ll a, ll b) {
  while (a % b != 0) {
    ll tmp = a;
    a = b;
    b = tmp % b;
  }
  return b;
}

int const N_MAX = 2 * 1e5;

int N;
int a[N_MAX + 1];
vector<int> v;

int main() {
  scanf("%d", &N);
  rep(i, N) {
    int b;
    scanf("%d", &b);
    a[i] = b;
    v.push_back(b - (i + 1));
  }
  sort(v.begin(), v.end());
  int center = v[v.size() / 2];
  int center_d = v[v.size()  / 2 + 1];
  ll sum_u = 0;
  ll sum_d = 0;
  rep(i, N) {
    sum_u += abs(a[i] - (center + i + 1));
    sum_d += abs(a[i] - (center_d + i + 1));
  }
  printf("%lld\n", min(sum_u, sum_d));
}


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

int dp[100005];

int main() {
  int n,k;
  int h[100005];
  cin >>n>>k;
  for (int i = 1; i <= n; ++i )cin >> h[i];
 
  for ( int i = 2; i <= n; ++i ) {
     dp[i]=1e9;
        for(int j=1;j<=k;j++){
            if(i-j>=1){
            dp[i] = min ( dp[i], dp[i-j] + abs(h[i-j] - h[i]));
            }
        }
  }

  cout<<dp[n]<<"\n";
  return 0;
}



Measured memory_bytes: 4380
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };
//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	string st;
	while (cin>>st) {
		bool aok = true;
		for (int i = 0; i < st.size() - 1; ++i) {
			int l = st[i] - 'A';
			int r = st[i+1] - 'A';
			int lx = l % 3;
			int ly = l / 3;
			int rx = (r) % 3;
			int ry = r / 3;
			bool ok = false;
			for (int way = 0; way < 4; ++way) {

				if (lx + dx[way] == rx&&ly + dy[way] == ry)ok = true;
			}
			if (!ok)aok = false;
		}
		if (aok)cout << st << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3212
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef vector<int> V;
typedef vector<vector<int> > VV;
typedef long long ll;
const int inf = 2e9;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

int N, M;
V X;
V Y;
int dp[101010][2];

int main()
{
	cin >> N >> M;
	rep(i,0,M) {
		int a, b; cin >> a >> b;
		a--; b--;
		X.pb(a); Y.pb(b);
	}
	rep(i,0,N) dp[i][0] = 1; // 赤玉・白玉の総数
	dp[0][1] = 1;            // 赤玉の確率

	rep(i,0,M) {
		int a = X[i], b = Y[i];

		if (dp[a][0] == 0) continue;
		else if (dp[a][0] == 1) {
			if (dp[a][1] == 0) { // 白のみ
				dp[b][0] += 1;
				dp[a][0] -= 1;
			} else {             // 赤を含む場合
				dp[b][0] += 1;
				dp[b][1] = 1;
				dp[a][0] -= 1;
				dp[a][1] = 0;
			}
		} else { // 1超過の場合
			if (dp[a][1] == 0) {
				dp[a][0] -= 1;
				dp[b][0] += 1;
			} else {
				dp[b][0] += 1;
				dp[b][1] = 1;
				dp[a][0] -= 1;
				dp[a][1] = 1;
			}
		}
	}
	int ans = 0;
	rep(i,0,N) if (dp[i][1]) ans++;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2036
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    ll N,A,B;
    cin >> N >> A >> B;
    if((B-A)%2==0){
        cout << (B-A)/2 << endl;
    }else{
        cout << min(A-1,N-B)+1+(B-A-1)/2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        for(long i=0;;){
            if((1l<<i)<=n)i++;
            else {
                System.out.println((1l<<i)-1);
                break;
            }
        }


    }
}


Measured memory_bytes: 23764
import sys


def resolve():
    H, N = map(int, sys.stdin.readline().split())
    m = map(int, sys.stdin.read().split())
    AB = zip(m, m)
    INF = 10**20
    dp = [INF]*(H+10**4)
    dp[0] = 0
    for a, b in AB:
        for j in range(H+10**4):
            dp[j] = min(dp[j], dp[j-a] + b if j-a >= 0 else INF)
    return min(dp[H:])


if __name__ == '__main__':
    print(resolve())


Measured memory_bytes: 78172
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define chmax(x,y) x = max(x,y)
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll n, a[200005] = {}, b[200005] = {}, j = 0, bef = -1;

int main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n)cin >> b[i];
	rep(i, n) {
		if (bef != a[i])j = 0;
		if (a[i] == b[i]) {
			while ((a[i] == a[j] || a[i] == b[j]) && j < n)j++;
			if (j < n) {
				swap(b[i], b[j]);
			}
			else {
				cout << "No" << endl;
				return 0;
			}
		}
		bef = a[i];
	}
	cout << "Yes" << endl;
	rep(i, n)cout << b[i] << endl;
	return 0;
}

Measured memory_bytes: 6728
X = int(input())
happiness = 0
while X > 0:
    if X >= 500:
        temp = int(X / 500)
        X = X - (500 * temp)
        happiness = 1000 * temp
    else:
        temp = int(X / 5)
        X = X - (500 * temp)
        happiness = happiness + (5 * temp)
        break
print(happiness)

Measured memory_bytes: 3064
#include <iostream>

#include <deque>

#include <stdio.h>

#include <cstdio>

#include <algorithm>

#include<bits/stdc++.h>

#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define sp <<" "
#define nw <<"\n"
#define ca "Case "<<tc++<<": "
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
#define ull unsigned LL
#define check cout<<"* ";
#define show_vector for(int q=0;q<v.size();q++){cout<<v[q]<<" ";}
#define REP(i,n) for (int i=0;i<(n);++i)
#define N_MAX 26

const int inf=1<<30;
const long long int INF=1e10;
const int MOD=1e9+7;
const int maxn = 1e5+10;
int a[200005],b[1000005];

using namespace std;

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

int is_prime(int n)
{
    int coun;
     coun=0;
     if(n>1){
      for(int i=2;i*i<=n;i++){
        if( n%i==0 ){
            coun++;
          }
        }
      }
     if(n==1){
       coun=coun;
         }
    if(coun==0){
        return 1;
        }
    return 0;
}

int main()
{
    int n;
    vector<long long int>v;
    int cnt=0;
    cin>>n;

    for(int i=1;i<=n;i++){
        int z;
        cin>>z;
        //if(is_prime(z)==1){
        //    cnt++;
        //    continue;
        //}
        v.pub(z);
    }
    sort(v.begin(),v.end());

    int m=v.size();
    for(int i=0;i<m;i++)
	{
	    int r=2;
		for(int j=v[i];j<=v[m-1];j+=v[i])
		{
		    //cout<<j sp<<v[i] sp<<b[j] sp sp;
			b[j]++;
			//cout<<j sp<<v[i] sp<<b[j] nw;
		}
	}
	for(int i=0;i<m;i++)
	{
	    //cout<<b[v[i]] sp;
		if(b[v[i]]==1)
		cnt++;
	}
	cout<<cnt nw;
}


Measured memory_bytes: 8588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef __int128 Int;
int n;
ll a[100005];
vector<int>p;
bool check(int x){
	for(int i=2;i*i<=x;i++)if(x%i==0)return false;return true;
}
map<Int,Int>inv,cnt;
int tag=0;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=2;i<=3333;i++)if(check(i))p.push_back(i);
	for(int i=1;i<=n;i++){
		Int val=1,Inv=1;
		for(int tt=0;tt<p.size();tt++){
			int x=p[tt];int cnt=0;
			while(a[i]%x==0){
				cnt++;a[i]/=x;
			}
			cnt%=3;
			if(!cnt)continue;
			if(cnt==1){
				val*=x;
				Inv*=x*x;
			}else{
				val*=x*x;
				Inv*=x;
			}
		}
		if(a[i]>1){
			Int tmp=sqrt(a[i]);
			while(tmp*tmp<a[i])tmp++;
			while(tmp*tmp>a[i])tmp--;
			if(tmp*tmp==a[i]){
				val*=a[i];
				Inv*=tmp;
			}else{
				val*=a[i];
				Inv*=a[i]*a[i];
			}
		}
		if(val==1){
			tag=1;continue;
		}
		cnt[val]++;inv[val]=Inv;
	}
	int ans=0;
	for(map<Int,Int>::iterator itr=cnt.begin();itr!=cnt.end();itr++){
		pair<Int,Int>p=*itr;
		Int now=p.first,nxt=inv[p.first];
		if(!cnt.count(nxt)){
			ans+=cnt[now];cnt[now]=0;continue;
		}
		ans+=max(cnt[now],cnt[nxt]);
		cnt[now]=cnt[nxt]=0;
	}
	cout<<ans+tag<<endl;
	return 0;
}

Measured memory_bytes: 16640
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
const long long MOD = (long long)1e9 + 7;
int H, W, h, w;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> H >> W >> h >> w;
    int ans = H*W - h*W - H*w + h*w;
    cout << ans << "\n";
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
int main(){
	int n,m,i;
	i=0;
	ll ans=0;
	ll sum=0;
	cin>>n>>m;
	vector<vector<int>> an(n,vector<int>(2,0));
	rep(k,n){
		cin>>an.at(k).at(0)>>an.at(k).at(1);
	}
	sort(an.begin(),an.end());
	/*rep(r,n){
		cout<<an.at(r).at(0)<<" "<<an.at(r).at(1)<<endl;;
	}*/
	while(sum<m){
		sum+=an.at(i).at(1);
		//cout<<ans<<endl;
		ans+=(ll)an.at(i).at(0)*an.at(i).at(1);
		i++;
	}
	i--;
	ans-=(ll)an.at(i).at(0)*(sum-m);
	cout<<ans<<endl;
	return 0;
}

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

#define MOD 1000000007

string S;
long long dp[100005][2];

long long solve(int N, int lo)
{
    if(N == S.size())
        return 1;

    if(dp[N][lo] != -1)
        return dp[N][lo];
    
    long long ans = 0;

    for(int i=0; i<2; i++)
        for(int j=0; j<2; j++)
        {
            if(i + j >= 2)
                continue;
            
            if(lo == 0 && (i+j) > S[N] - '0')
                continue;
            
            ans += solve(N+1, lo | ((i+j) < S[N] - '0'));
        }

    return dp[N][lo] = ans % MOD;
}

int main()
{
    ios::sync_with_stdio(0);
    
    cin >> S;
    memset(dp, -1, sizeof(dp));
    cout << solve(0, 0) << "\n";
    return 0;
}


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

using namespace std;

int main(){
    vector <int> a(3);
    for (int i = 0; i < 3; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    cout << a[2] - a[0] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define LEN 100
#define INFTY 2000000001
#define NIL -1
#define WHITE 1
#define BLACK 0
using namespace std;
 
int main()
{
  int n,u,v,k,c,mincost=0;
  int G[LEN+1][LEN+1], d[LEN+1], pi[LEN+1], color[LEN+1];
 
  cin>>n;
 
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      G[i][j] = INFTY;
    }
  }
   
  for(int i = 0; i < n; i++){
    cin>>u>>k;
    for(int j = 0; j < k; j++){
      cin>>v>>c;
      G[u][v] = c;
    }
  }
 
  for(int i = 0; i < n; i++){
    d[i] = INFTY;
    pi[i] = NIL;
    color[i] = WHITE;
  }
   
  d[0] = 0;
   
  while(1){
    mincost = INFTY;
    for(int i = 0; i < n; i++){
      if(color[i] != BLACK && d[i] < mincost){
    mincost = d[i];
    u = i;
      }
    }

    if(mincost == INFTY) break;
    color[u] = BLACK;
    for(int i = 0; i < n; i++){
      if(d[i] > d[u] + G[u][i]){
        d[i] = d[u] + G[u][i];
        pi[i] = u;
      }
    }
  }
 
  for(int i = 0; i < n; i++){
    cout<<i<<" "<<d[i]<<endl;

  }
 
  return 0;
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, B;
  
  cin >> N >> A;
  
  B = N % 500;
 
  if (B <= A) {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        int min = a < b ? a : b;
        int max = a > b ? a: b;
        for(int i = 0 ; i < max ; i++) {
            System.out.printf(""+min);
        }
    }
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
    cin >> N;
    std::vector<pair<int,int>> red(N);
    std::vector<pair<int,int>> blue(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> red[i].second >> red[i].first;
    }
    for (int i = 0; i < N; ++i)
    {
        cin >> blue[i].first >> blue[i].second;
    }
    sort(red.begin(), red.end());
    reverse(red.begin(), red.end());
    sort(blue.begin(), blue.end());
    int count = 0;
    for (int bi = 0; bi < N; ++bi)
    {
        for (int ri = 0; ri < (int)red.size(); ++ri)
        {
                if(blue[bi].first > red[ri].second && blue[bi].second > red[ri].first){
                    count++;
                    red.erase(red.begin() + ri);
                    sort(red.begin(), red.end());
                    reverse(red.begin(), red.end());
                    break;
                }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256