akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<63)-1
#define MAX 1000000000
int N,M,V,P;
bool f(vi &A,int B){
    int sum=0,Y=N-(B-P+1),Z=M-A[N-P]+A[N-B];
    rep(i,N-B,N-P){
        int X=A[N-P]-A[i];
        if(X>M) return 0;
        sum+=X;
    }
    return A[N-P]-A[N-B]<=M*V&&sum+Y*M+Z*(B-P+1)>=M*V;
}
signed main(){
    cin>>N>>M>>V>>P;
    vi A(N);
    rep(i,0,N) cin>>A[i];
    sort(ALL(A));
    int left=P,right=N;
    while(left+1<right){
        int mid=(left+right)/2;
        if(f(A,mid)) left=mid;
        else right=mid;
    }
    int ans=left;
    if(f(A,right)) ans=right;
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
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
 */
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);
        ABC133_a solver = new ABC133_a();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC133_a {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int A = in.nextInt();
            int B = in.nextInt();

            if ((A * N) > B) {
                out.println(B);
            } else {
                out.println(A * N);

            }
        }

    }
}



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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long int
#define ull unsigned long long int
#define ld long double

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	int x;
	cin >> x;
	if(x == 0) cout << "1\n";
	else if(x == 1) cout << "0\n";
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int dp[3][3], ok[3][3];
int cnt1[3], cnt2[3], cnt3[2];
int main() {
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> dp[i][j];
            ok[i][j] = 0;
            cnt1[i] = 0;
            cnt2[j] = 0;
        }
    }
    cnt3[0] = cnt3[1] = 0;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if(x == dp[j][k] && !ok[j][k]) {
                    cnt1[j]++;
                    cnt2[k]++;
                    if(j == k) cnt3[0]++;
                    if(j == 2-k) cnt3[1]++;
                    ok[j][k] = 1;
                }
            }
        }
    }
    if(*max_element(cnt1, cnt1+3) == 3 || *max_element(cnt2, cnt2+3) == 3 || *max_element(cnt3, cnt3+2) == 3) puts("Yes");
    else puts("No");

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll>P;
typedef pair<P, P>PP;
int main(){

    ll X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll>A(X), B(Y), C(Z);
    for(int i = 0; i < X; i++)cin >> A[i];
    for(int i = 0; i < Y; i++)cin >> B[i];
    for(int i = 0; i < Z; i++)cin >> C[i];
    sort(A.begin(), A.end(), greater<ll>());
    sort(B.begin(), B.end(), greater<ll>());
    sort(C.begin(), C.end(), greater<ll>());
    priority_queue<PP>Q;
    Q.push(PP(P(A[0] + B[0] + C[0], 0), P(0, 0)));
    map<PP, int>flg;
    for(int i = 0; i < K;){
        PP pp = Q.top();
        Q.pop();
        if(flg[pp])continue;
        flg[pp] = 1;
        i++;
        cout << pp.first.first << endl;
        int a = pp.first.second;
        int b = pp.second.first;
        int c = pp.second.second;
        if(a+1<X)Q.push(PP(P(A[a+1]+B[b]+C[c], a+1), P(b, c)));
        if(b+1<Y)Q.push(PP(P(A[a]+B[b+1]+C[c], a), P(b+1, c)));
        if(c+1<Z)Q.push(PP(P(A[a]+B[b]+C[c+1], a), P(b, c+1)));
    }

    return 0;
}

Measured memory_bytes: 768
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias Mame = Tuple!(long, "point", long, "number");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto n = lread();
    auto odd = (n + 1) / 2;
    writeln(cast(double) odd / n);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define inf 1e9+5
using namespace std;

int32_t main(){
      ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,W;
    cin>>n>>W;
  ll i, w; 
   ll K[n+1][W+1]; 
   ll wt[n],val[n];
  for(int i=0;i<n;i++)cin>>wt[i]>>val[i];
   // Build table K[][] in bottom up manner 
   for (i = 0; i <= n; i++) 
   { 
       for (w = 0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (wt[i-1] <= w) 
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   } 
    cout<<K[n][W];
}



Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int n,m,a[N],b[N],c[N],s[N],f[N],tot,head[N],nex[N],to[N];
void add(int u,int v){to[++tot]=v;nex[tot]=head[u];head[u]=tot;}
ll dp[N],sum[N];
bool vis[N];
int getf(int x){return f[x]==x?x:f[x]=getf(f[x]);}
bool cmp(int a,int b){return c[a]<c[b];}
vector<int>e[N];
void dfs(int u)
{
    sum[u]=b[u];
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];dfs(v);
        sum[u]+=sum[v];
    }
    dp[u]=sum[u]+c[u];
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];
        dp[u]=min(dp[u],sum[u]-sum[v]+max(dp[v],(ll)c[u]));
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&a[i],&b[i]),c[i]=max(a[i]-b[i],0),s[i]=f[i]=i;
    for(int i=1;i<=m;i++)
    {
        int u,v;scanf("%d%d",&u,&v);
        e[u].push_back(v);
        e[v].push_back(u);
    }
    sort(s+1,s+1+n,cmp);
    for(int i=1;i<=n;i++)
    {
        int x=s[i];vis[x]=true;
        for(int j=0;j<e[x].size();j++)
        {
            int y=e[x][j];if(!vis[y])continue;
            y=getf(y);
            if(y!=x)
            {
                f[y]=x;
                add(x,y);
            }
        }
    }
    dfs(s[n]);
    printf("%lld\n",dp[s[n]]);
}


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

#define SIZE_OF_ARRAY(array) sizeof(array)/sizeof(array[0])

int main() {
    int K, A, B;
    cin >> K >> A >> B;
    bool b = true;
    for(int i = 1; i <= 1000; i++){
        if(A <= K*i && B >= K*i){
            b = false;
            break;
        }
    }
    if(b){
        cout << "NG";
    } else {
        cout << "OK";
    }
}

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

using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
#define fi first
#define se second
#define endl '\n'
#define y1 holyshit

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll a,b,c; cin>>a>>b>>c;
    if(4*a*b<(c-b-a)*(c-b-a)&&c-b-a>0) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] nm = br.readLine().split(" ");
        int n = Integer.parseInt(nm[0]);
        int m = Integer.parseInt(nm[1]);
        System.out.println(problem152a(n, m));
    }

    private static String problem152a(int n, int m) {
        return (n == m) ? "Yes" : "No";
    }
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace __gnu_pbds;

///#define int long long
#pragma GCC optimize ("O3")
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define maa 1000000007
#define Eps 1e-9
#define PI 3.14159265359

typedef tree<pii,null_type,less <pii>,rb_tree_tag,tree_order_statistics_node_update>ind_set;
///*X.find_by_order("index")
///X.order_of_key("key")

///----------------------------------------------------------------------------------

int n,m;
vi adj[100005];
int DP[100005];
bool vis[100005];
void dfs(int so)
{
    vis[so]=true;
    for (auto x:adj[so])
	{
		if(!vis[x])
		dfs(x);
	}

    DP[so]=0;
    for (auto x:adj[so])
	{
        DP[so]=max(DP[so],1+DP[x]);
	}
}
void solve()
{
	cin>>n>>m;int u,v;rep(i,0,m)cin>>u>>v,adj[u-1].pb(v-1);rep(i,0,n)if (!vis[i])dfs(i);cout<<*max_element(DP,DP+n);

}
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);

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

    int t=1;
///cin>>t;
    rep(a,0,t)
    {
        ///cout<<"Case "<<a+1<<": ";
        solve();
    }
}


Measured memory_bytes: 8064
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int N = sc.nextInt();
		
		int[] a = new int[N];
		for (int i = 0; i < N; i++) {
			int A = sc.nextInt();
			a[i] = A - (i +1);
		}
		
		Arrays.sort(a);
		
		int center = 0;
		if (N % 2 == 0) {
			center = a[(N/2)-1];
		} else {
			center = a[((N+1)/2)-1];
		}
		
		long ans = 0;
		for (int i = 0; i < N; i++) {
			ans += Math.abs(a[i]-center);
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 64876
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,m=parseMap(split(readline()))
    ball=[1 for i in 1:n]
    red=[false for i in 1:n]
    red[1]=true
    for i in 1:m
        x,y=parseMap(split(readline()))
        ball[x]-=1
        ball[y]+=1
        red[y]=red[x] | red[y]
        if ball[x]==0
            red[x]=false
        end
    end
    println(count(x->x,red))
end
main()

Measured memory_bytes: 154124
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll n, k;
    cin >> n >> k;
    if(k >= n){
        cout << min(k - n, k - (k - n));
    }else{
        ll x = (n / k) * k;
        cout << min(n - x, k - (n - x));
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define REP(i,s,N) for (int i=s;i<(N); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;


ll ans=0;

int main(){
	int A,B;
	cin >> A >> B;
	
	float a = A / 0.08;
	float b = B / 0.10;
	int aa = A / 0.08;
	int bb = B / 0.10;
	
	deque<int> q;
	if((float)(a-aa)==0){
		for(int i=0;i<12;i++){
			q.push_back(aa+i);
		}
	}else{
		for(int i=0;i<11;i++){
			q.push_back(aa+i+1);
		}
	}
	deque<int> q2;
	if((float)(b-bb)==0){
		for(int i=0;i<9;i++){
			q2.push_back(bb+i);
		}
	}else{
		for(int i=0;i<8;i++){
			q2.push_back(bb+i+1);
		}
	}
	if(q.front()<=q2.front() && q2.front() <= q.at(q.size()-1)){
		cout << q2.front() << endl;
	}else if(q2.front()<=q.front() && q.front() <= q2.at(q2.size()-1)){
		cout << q.front() << endl;
	}else{
		cout << -1 << endl;
	}
	

}

Measured memory_bytes: 256
import kotlin.*


fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = MyScanner()
        val x = sc.nextInt()
        val y = sc.nextInt()
        for(kame in 0..x){
            val turu = x-kame
            val sum = kame * 4 + turu * 2
            if(sum == y) {
                println("Yes")
                return
            }
        }

        println("No")
    }
}

class MyScanner {
    private var ptr = 0
    private var l = listOf<String>()

    fun next(): String {
        while (l.size <= ptr) {
            l = readLine()!!.split(' ')
            ptr = 0
        }
        return l[ptr++]
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextCharArray() = next().toCharArray()
    fun nextChar() = next()[0]

    fun list(): List<String> {
        ptr = l.size
        return readLine()!!.split(' ')
    }

    fun intList() = list().map { s -> s.toInt() }
    fun longList() = list().map { s -> s.toLong() }
    fun doubleList() = list().map { s -> s.toDouble() }

    fun array() = list().toTypedArray()
    fun intArray() = intList().toIntArray()
    fun longArray() = longList().toLongArray()
    fun doubleArray() = doubleList().toDoubleArray()
}


Measured memory_bytes: 36488
#include<iostream>
using namespace std;
int n,m,a[1<<17],used[1<<18];
main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)cin>>a[i];
	for(int i=m;i--;)
	{
		if(!used[a[i]])
		{
			cout<<a[i]<<endl;
			used[a[i]]++;
		}
	}
	for(int i=1;i<=n;i++)if(!used[i])cout<<i<<endl;
}



Measured memory_bytes: 4272
#define _USE_MATH_DEFINES
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {
	
	int n, w;
	string s[150] = {};
	cin >> n >> w;

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

	for (int i = 0; i < w + 2; i++)
	{
		cout << "#";
	}
	cout << endl;
	for (int i = 0; i < n; i++)
	{
		cout << "#" << s[i] << "#" << endl;
	}
	

	for (int i = 0; i < w + 2; i++)
	{
		cout << "#";
	}
	cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#include<random> 
#define int long long 
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back 
#define mod 1000000007 
#define mk(arr,n,type) type *arr=new type[n]; 
#define sl s1.length(); 
#define yes cout<< "Yes"<<endl 
#define no cout<< "No"<<endl 
#define all(v) (v).begin(),(v).end() 
#define mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
using namespace std; 
void fastio() 
{ 
    #ifndef ONLINE_JUDGE 
    freopen("INPUT.txt","r",stdin); 
    freopen("OUTPUT.txt","w",stdout); 
    #endif 
    ios_base :: sync_with_stdio(false); 
    cin.tie(NULL) ; 
    cout.tie(NULL); 
    
}

signed main() 
{ 
    fastio(); 
        string s,t;
        cin>>s>>t;
        int n=s.length(),m=t.length(),mx=0,c=0;
        for(int i=0;i<=n-m;i++)
        {
            int j=i;
            for(int k=0;k<m;k++)
            {
                if(s[j]==t[k])
                c++;
                j++;
            }
            //cout<<c<<" ";
            mx=max(c,mx);
            c=0;
        }
    mx=max(c,mx);
    cout<<m-mx;
    
}


Measured memory_bytes: 3652
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		mut s: Chars,
	}

	loop {
		s.remove(s.len()-1);
		s.remove(s.len()-1);

		let mut s2 = s.split_off(s.len()/2);
		if s == s2 {
			println!("{}", s.len()*2);
			return;
		}
		s.append(&mut s2);
	}
}



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

int n, a[100000], color, chain[100000], cnt, maxn, recently;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	color = a[0]; cnt = 0; chain[0] = 1;
	for (int i = 1; i < n; i++) {
		if (color == a[i]) {
			cnt++;
			recently = i;
		}
		color = a[i];
		chain[cnt]++;
	}
	cnt++;
	if (cnt == 1) { maxn = n; }
	if (cnt == 2) { maxn = n; }
	for (int i = 0; i < cnt - 2; i++) {
		maxn = max(maxn, chain[i] + chain[i + 1] + chain[i + 2]);
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 1752
import java.io.*;
 
class Main{ 
    public static void main(String[] args){
        int a, b;
        String buf;
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
             
            String[] ab = br.readLine().split(" ");
            a = Integer.parseInt(ab[0]);
            b = Integer.parseInt(ab[1]);
             
            if(a > b){
                System.out.println("a > b");
            } else if ( a < b ){
                System.out.println("a < b");
            } else if ( a == b ){
                System.out.println("a == b");
            }
        } catch(Exception e){
        }
    }
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

ll N, M, R, d[200][200];
vector<ll> r;

// v: 頂点数, d: 頂点間距離
void warshall_floyd(ll v) {
    rep(k, v)rep(i, v)rep(j, v) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

void solve() {
    warshall_floyd(N);
    sort(r.begin(), r.end());
    ll ans = ll_inf;
    do {
        ll temp = 0;
        rep(i, R - 1) temp += d[r[i]][r[i + 1]];
        ans = min(temp, ans);
    } while (next_permutation(r.begin(), r.end()));

    cout << ans << endl;
}

int main() {
    cin >> N >> M >> R;
    r.resize(R);
    rep(i, R) {
        cin >> r[i];
        r[i]--;
    }
    rep(i, 200) rep(j, 200) d[i][j] = ll_inf;
    rep(i, M) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        d[a][b] = c;
        d[b][a] = c;
    }
    solve();
    return 0;
}

Measured memory_bytes: 512
#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 ALL(x) x.begin(),x.end()

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9+7;
const ll INF = 1e18;
const int MAX = 1e6;

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

struct edge {int to, cost;}; // 辺
// vector<edge> graph[MAX]; // 隣接リスト
// bool visit[MAX]; // 訪問の有無

int n, m; // 変数
string s, t;
int dp[3001][3001];
string ans;

void rec(int i, int j) {
    if (i == 0 || j == 0) return;
    if (s[i] == t[j]) {
        ans.push_back(s[i]);
        rec(i-1, j-1);
    } else if (dp[i][j] == dp[i-1][j]) {
        rec(i-1, j);
    } else if (dp[i][j] == dp[i][j-1]) {
        rec(i, j-1);
    }
}

void dp_solve() {
    if (s.size() < t.size()) swap(s, t);
    s = ' ' + s;
    t = ' ' + t;
    n = s.size();
    m = t.size();
    rep(i, n) {
        rep(j, m) {
            if (i == 0 || j == 0) {
                dp[i][j] = 0;
                continue;
            } else {
                if (s[i] == t[j]) {
                    dp[i][j] = dp[i-1][j-1] + 1;
                } else {
                    int x = dp[i-1][j];
                    int y = dp[i][j-1];
                    dp[i][j] = max(x, y);
                }
            }
            // printf("%d ", dp[i][j]);
        }
        // printf("\n");
    }
    // int i = n-1, j = m-1;
    // while (i-1 >= 0 && j-1 >= 0) { 
    //     if (s[i] == t[j]) {
    //         ans.push_back(s[i]);
    //         i--;
    //         j--;
    //     } else if (dp[i][j] == dp[i-1][j]) {
    //         i--;
    //     } else if (dp[i][j] == dp[i][j-1]) {
    //         j--;
    //     }
    // }
    rec(n-1, m-1);
    reverse(ALL(ans));
}


int main() {
// input
    cin >> s;
    cin >> t;
// solve
    dp_solve();
// output
    cout << ans << "\n";
}

Measured memory_bytes: 38796
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key){
    return u;
  }
  if(k < u->key){
    return treeSearch(u->left,k);
  }else{
    return treeSearch(u->right,k);
  }
  while(u != NIL && k != u->key){
    if(k < u->key){
      u = u->left;
    }else{
      u = u->right;
    }
  }
  return u;
}
 
Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL){
    return treeMinimum(x->right);
  }
  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y;
  Node x;
  if(z->left == NIL || z->right == NIL){
    y = z;
  }else{
    y = treeSuccessor(z);
  }
  if(y->left != NIL){
    x = y->left;
  }else{
    x = y->right;
  }
  if(x != NIL){
    x->parent = y->parent;
  }
  if(y->parent == NIL){
    root = x;
  }else if(y == y->parent->left){
    y->parent->left = x;
  }else{
    y->parent->right = x;
  }
  if(y != z){
    z->key = y->key;
    z = y;
  }
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  }else if(z->key < y->key){
    y->left = z;
  }else{
    y->right = z;
  }
}

void inorder(Node u){
  if(u->left != NIL){
    inorder(u->left);
  }
  printf(" %d",u->key);
  if(u->right != NIL){
    inorder(u->right);
  }
}
void preorder(Node u){
  printf(" %d",u->key);
  if(u->left != NIL){
    preorder(u->left);
  }
  if(u->right != NIL){
   preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 19364
s = list(input())
ans = [0] * len(s)
last = ""
cnt = [0, 0]
p = 0
s.append("R")

for i in range(len(s)):
    if s[i] == "L":
        if last == "R":
            p = i
        cnt[0] += 1
    elif s[i] == "R":
        if last == "L":
            csum = cnt[0] + cnt[1]
            if csum % 2 == 0:
                ans[p-1], ans[p] = csum // 2, csum//2
            else:
                a1 = (csum + 1) // 2
                a2 = (csum - 1) // 2
                if cnt[0] % 2 == 0:
                    ans[p-1], ans[p] = a1, a2
                else:
                    ans[p-1], ans[p] = a2, a1
            cnt = [0, 0]
        cnt[1] += 1
    last = s[i]

print(*ans)


Measured memory_bytes: 7092
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yn(int o){
    if (o == 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}

int cul(int n){
    vector<int> ar(10,0);
    int re = 0;
    rep(i,10){
        ar[i] = n % 10;
        n /= 10;
        re += ar[i];
    }
    return re;
}

int main() {
    int n; cin >> n;
    vector<int> art(n);
    vector<P> xy(n);
    rep(i,n) cin >> art[i] >> xy[i].first >> xy[i].second;
    int ix = 0; int iy = 0; int it = 0;
    bool t = true;
    rep(i,n){
        int dt = art[i] - it;
        int dxy = abs(ix - xy[i].first) + abs(iy - xy[i].second);
        if (dxy > dt || (dt - dxy) % 2 == 1){
            t = false;
            break;
        } 
        ix = xy[i].first;
        iy = xy[i].second;
        it = art[i];
    }
    if (t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 4588
m,a[9][2],S[2499];D(d,s){int i=d==m?++S[s]+99:0;for(;i<=a[d][1];i++)D(d+1,s+i**a[d]);}main(i){for(;scanf("%d",&m),m;){for(i=0;i<m;i++)scanf("%d%d",a[i],a[i]+1);memset(S,0,9996);D(0,0);for(scanf("%d",&i);i;i--)scanf("%d",&m),printf("%d\n",S[m]);}exit(0);}

Measured memory_bytes: 612
s[50],j,p,q;
main(i){for(;j=i=atoi(gets(s));printf("%d\n",i)){
for(;i;s[j-i--]=strlen(gets(s+j)));
for(;j;)for(p=i++,q=j=188686;q>0;j/=10)for(q=j%10;q>1;)q-=s[p++];
}}

Measured memory_bytes: 532
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;


public class Test
{	
    public static void Main()
	{
	    int[] nums = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        bool ok = false;
        if(nums[0] % 3 == 0) ok = true;
        if(nums[1] % 3 == 0) ok = true;
        if((nums[0]+nums[1])%3 == 0  ) ok = true;
        
        
        if(ok)   Console.WriteLine("Possible");
        else Console.WriteLine("Impossible");
        
	}
}

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

using namespace std;
typedef long long ll;

string N;
int K;
set <string> nd[3];

int dp[110][5][2]; // 

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> N >> K;

    dp[0][0][0] = 1;
    for (int i = 0; i < N.length(); i++)
    {
        int d = N[i] - '0';
        for (int j = 0; j <= 3; j++)
            for (int k = 0; k < 2; k++)
            {
                if (k == 1)
                {
                    for (int l = 0; l < 10; l++)
                    {
                        if (l) dp[i+1][j+1][k] += dp[i][j][k];
                        else dp[i+1][j][k] += dp[i][j][k];
                    }
                }
                else
                {
                    for (int l = 0; l < d; l++)
                    {
                        if (l) dp[i+1][j+1][1] += dp[i][j][k];
                        else dp[i+1][j][1] += dp[i][j][k];                        
                    }

                    if (d == 0)
                    {
                        dp[i+1][j][0] += dp[i][j][k];
                    }
                    else
                        dp[i+1][j+1][0] += dp[i][j][k];
                }
            }
    }

    int nres = 0;
    for (int i = 0; i < 2; i++)
        nres += dp[N.length()][K][i];
    cout << nres << "\n";
}

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

int main(){
	int N,M;
	cin >> N >> M;
	vector<long long> A(N);
	for(auto &i:A)cin >> i;
	vector<pair<long long,int>> CB(M);
	for(int i=0;i<M;i++){
		long long c;
		int b;
		cin >> b >> c;
		CB[i].first=c;
		CB[i].second=b;
	}
	
	sort(A.begin(),A.end());
	
	sort(CB.begin(),CB.end());
	reverse(CB.begin(),CB.end());
	
	int pos=0;
	vector<long long> AA(N,0);
	for(int i=0;i<M;i++){
		int B=CB[i].second;
		long long C=CB[i].first;
		for(int k=0;k<B;k++){
			if(pos>=N)break;
			AA[pos]=C;
			pos++;
		}
	}
	for(int i=0;i<N;i++)A[i]=max(A[i],AA[i]);
	cout << accumulate(A.begin(),A.end(),0LL) << endl;
	return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    int ans[N];
    bool can[N];
    for (int i = 0; i < N; i++)
    {
        ans[i] = 0;
        can[i] = true;
    }

    
    while (M--)
    {
        int s, c;
        cin >> s >> c;
        --s;
        if (can[s])
        {
            ans[s] = c;
            can[s] = false;
        } else
        {
            if (ans[s] == c)
            {
                continue;
            } else
            {
                cout << -1 << endl;
                return 0;
            }    
        }       
    }
    if (N != 1 && ans[0] == 0 && can[0])
    {
        ans[0] = 1;
    }
    
    if (N != 1 && ans[0] == 0 && !can[0])
    {
        cout << -1 << endl;
    } else
    {
        for (int i = 0; i < N; i++)
        {
            cout << ans[i];
        }
        cout << endl;         
    }  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
#define N 100005
const int inf = 1e9+5;
int main() {
	int a[N], n, k;
	int mn = inf;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	for (int i = 0; i < n-k+1; i++) {
		mn = min(mn, a[k + i-1] - a[i]);
	}
	cout << mn << endl;
	return 0;
}

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

int c;
bool a[11];

bool f(const string& s) {
	if(s[c] == '(') {
		c++;
		bool v1 = f(s);
		char op = s[c++];
		if(op == '-') c++;
		bool v2 = f(s);
		c++;
		if(op == '+') return v1 | v2;
		if(op == '*') return v1 & v2;
		if(op == '-') return !(v1 & !v2);
	}

	if(s[c] == 'T') {
		c++;
		return true;
	}
	if(s[c] == 'F') {
		c++;
		return false;
	}
	if(s[c] == '-') {
		c++;
		return !f(s);
	}
	if('a' <= s[c] && s[c] <= 'k') {
		bool v = a[s[c] - 'a'];
		c++;
		return v;
	}
	cout << "error" << s << "at " << c << endl;
	exit(1);
}

bool solve(string s1, string s2) {
	for(int i = 0; i < (1 << 11); i++) {
		for(int j = 0; j < 11; j++) {
			if(i & (1 << j)) a[j] = true;
			else a[j] = false;
		}
		//cout << i << " " << s1 + " " << s2 << endl;
		c = 0;
		bool res1 = f(s1);
		c = 0;
		bool res2 = f(s2);

		if(res1 != res2) return false;
	}

	return true;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s, s1, s2;
	while(cin >> s, s != "#") {
		int idx = s.find('=');
		s1 = s.substr(0, idx), s2 = s.substr(idx + 1, s.size() - (idx + 1));
		cout << (solve(s1, s2) ? "YES" : "NO") << endl;
	}
}

Measured memory_bytes: 3220
#include <stdio.h>

int main() {
    long int a, b, gcd, lcm;
    long int tmp_a, tmp_b, tmp;
    while (scanf("%ld %ld", &a, &b) == 2) {
        if (a < b) {
            tmp_a = a;
            tmp_b = b;
        } else {
            tmp_a = b;
            tmp_b = a;
        }
        while (tmp_b % tmp_a != 0) {
            tmp = tmp_b % tmp_a;
            tmp_b = tmp_a;
            tmp_a = tmp;
        }
        gcd = tmp_a;
        lcm = gcd * a / gcd * b / gcd;
        printf("%ld %ld\n", gcd, lcm);
    }
    return 0;
}



Measured memory_bytes: 2068
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  int n;
  vector<ll> a;
  vector<ll> b;
  vector<ll> c;
  cin >> n;
  REP(i, n) {
    ll x;
    cin >> x;
    a.push_back(x);
  }
  REP(i, n) {
    ll x;
    cin >> x;
    b.push_back(x);
  }
  REP(i, n) {
    ll x;
    cin >> x;
    c.push_back(x);
  }
  sort(ALL(a));
  sort(ALL(b));
  sort(ALL(c));
  ll ans = 0;

  for (auto j : b) {
    auto itr_a = lower_bound(ALL(a), j);
    ll a_cnt = itr_a - a.begin();
    auto itr_c = upper_bound(ALL(c), j);
    ll c_cnt = c.end() - itr_c;
    ans += a_cnt * c_cnt;
  }

  cout << ans << endl;
}

Measured memory_bytes: 6408
#include<bits/stdc++.h>
using namespace std;
        int main()
{
        int a,b;
        cin>>a>>b;
        if(a < b) cout<<"a < b"<<endl;
        if(a >b) cout<<"a > b"<<endl;
        if(a == b) cout<<"a == b"<<endl;
        return 0;
}


Measured memory_bytes: 3076
package main

import "fmt"

func main() {
  var N string
  fmt.Scan(&N)
  ans := len(N)
  for i := 0; i < len(N)-1; i++ {
    if N[i] != N[i+1] {
      continue
    }
    ans--
    i += 2
  }
  fmt.Println(ans)
}


Measured memory_bytes: 1920
#16D8103010K Ko Okasaki
#ALDS11a

Al=[]
n=int(input())
for i in range(n):
    a=list(map(int,input().split()))
    Al.append(a[2:])
Am=[[0 for j in range(n)]for i in range(n)]

for i in range(n):
    for k in Al[i]:
            Am[i][k-1]=1
for i in range(n):
    print(*Am[i])


Measured memory_bytes: 6392
#include<bits/stdc++.h>
#define int long long
using namespace std; 
const int mod=998244353;
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=ret*x%md;x=x*x%md;}while(y>>=1);return ret;}
int n,m;
int fact[1000005],inv[1000005];
int C(int nn,int mm){
	return fact[nn]*inv[mm]%mod*inv[nn-mm]%mod;
}
signed main(){
	cin>>n>>m;
	fact[0]=1;
	for(int i=1;i<=1e6;i++)fact[i]=fact[i-1]*i%mod;
	inv[1000000]=modpow(fact[1000000],mod-2);
	for(int i=1e6-1;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
	if(n>m)swap(n,m); 
	const int inv2=modpow(2,mod-2);
	int result=C(n+m,n)*m%mod;
	for(int i=1;i<=n;i++){
		int ways=C(i+i,i)*C(n-i+m-i,n-i)%mod;
		result+=ways*inv2%mod;
		result%=mod;
	}
	cout<<result*modpow(C(n+m,n),mod-2)%mod<<endl;
	return 0;
}

Measured memory_bytes: 19260
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            ABC081_A();
        }

        static void ABC081_A()
        {
            Console.WriteLine(Read().Count(x => x == '1'));
        }

        public static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0)
                throw new Exception("0未満");

            if (start > stop || (start == 0 && stop == 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        public static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        public static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        public static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static IList<int> ReadIntInputs()
        {
            return Read().Split(' ').Select(int.Parse).ToList();
        }

        public static int ReadInt()
        {
            return int.Parse(Read());
        }

        public static IList<string> ReadInputs()
        {
            return Read().Split(' ').ToList();
        }
    }
}

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int main(){
    string s, t;
    cin >> s >> t;
    bool f = true;
    if(s.size() + 1 != t.size()){
        f = false;
    }
    for(int i = 0; i < s.size(); i++){
        if(s[i] != t[i]){
            f = false;
            break;
        }
    }
    cout << (f? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<cmath>
#include<unordered_set>
#include<cstdio>

using namespace std;
typedef long long ll;
const int N = 1010;

int main()
{
	ll x, k, d;
	scanf("%lld%lld%lld", &x, &k, &d);
	
	
	ll t = abs(x) / d;
	
	if(k > t)
	{
		if(x > 0)	x -= t * d;
		else	x += t * d;
		if((k - t) & 1)
		{
			if(abs(x + d) < abs(x - d))	x += d;
			else	x -= d;
		}
	}
	else
	{
		if(x > 0)	x -= k * d;
		else	x += k * d;
	}
	
	printf("%lld\n", abs(x));
	
	return 0;
}

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

int main() {
    char c;
    cin >> c;
    if (c=='a' || c=='i' || c=='u' || c=='e' || c=='o'){
        cout << "vowel" << endl;
    }
    else{
        cout << "consonant" << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

long value[100005];

int main(int argc, char* argv[])
{
    long k;
    scanf("%ld", &k);
    
    long i;
    for(i=0; i<k; i++) {
        value[i] = -1;
    }

    deque<long> a;
    a.push_back(1);
    value[1]=1;

    while( !a.empty() ) {
        long curr = a.front();
        a.pop_front();
        
        if(curr==0) {
            printf("%ld\n", value[curr]);
            return 0;
        }

        long next0 = (curr*10)%k;
        if(value[next0]<0 || value[next0]>value[curr]) {
            value[next0] = value[curr];
            a.push_front( next0 );
        }

        long next1 = (curr+1)%k;
        if(value[next1]<0) {
            value[next1] = value[curr] + 1;
            a.push_back( next1 );
        }
    }

    return 0;
}


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

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];
    }
    for(int i = 0; i < n - k; i++) {
        if(a[i] >= a[i+k]) {
            puts("No");
        } else {
            puts("Yes");
        }
    }
    return 0;
}

Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof a) ;
typedef pair<int,int> pii ;
#define vi vector<int>
#define vit vector<int> :: iterator 
#define all(ans) ans.begin(),ans.end()
//#define sz(a) int(a.size())
#define ub upper_bound
#define lb lower_bound
#define create(Name,N,M,val) vector<vector<int> > Name(N,vector<int>(M,val))
#define ull unsigned long long
#define ll long long 
#define db double 
#define ldb long double
#define fl float
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lrep(i,a,b) for(ll i=a;i<b;i++)
//#define all(c) c.begin(),c.end()
#define tr(c,it) for(typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define mpr make_pair
#define pb push_back
#define fr first
#define sn second
#define bpp(x) __builtin_popcountll(x)
const db PI = 3.141592653589793238462643383;
const long long INF = 1e9+7;
int getID(char c)
{
	if(c == ' ') return 0;
	return c - 'a' + 1;
}
void solve()
{
db a,b,h,m; cin>>a>>b>>h>>m;
h=h*5.0 + (m/60)*5.0;
db p =min( abs(h-m) , 60-(abs(h-m)));
p=(p/60)*PI*2.0;
db ans=sqrt(a*a + b*b - 2.0*a*b*cos(p));
cout<<setprecision(15)<<ans;
return;
}
int main()
{
ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
//	cin>>t;
while(t--)
{
solve();
}
return 0;
}

Measured memory_bytes: 4244
n=int(input())
h=list(map(int,input().split()))
if n==1:
  print('Yes')
  exit()
res=h[n-1]
for i in range(1,n):
  if h[n-1-i]-res<=1:
    res=min(res,h[n-1-i])
  else:
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 20672
#include<bits/stdc++.h>
using namespace std;
int main()
{
   //#ifndef ONLINE_JUDGE
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  //#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin>>n;
  vector<int> v(n,100000000);
  vector<int> v1(n,10000000);

  for(int i=0;i<n;i++)
  {
  	cin>>v1[i];
  	if(i==0)
  	{
  		v[i]=0;
  	}
  	else if(i==1)
  	{
  		v[i]=abs(v1[i]-v1[i-1]);
  	}
  	else
  	{
  		v[i]=min(abs(v1[i]-v1[i-1])+v[i-1],abs(v1[i]-v1[i-2])+v[i-2]);
  	}
  }


  cout<<v.back();

}




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

votes = [0, 0]

for i in range(n):
    a, b = map(int, input().split())
    if i == 0:
        votes = [a, b]
    else:
        num = max(-(-votes[0]//a), -(-votes[1]//b))
        x = a * num
        y = b * num
        votes = [x, y]
print(sum(votes))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 11;
#define LL long long
LL a[N], p[N], s, ans;
int n;
LL dfs(int l, int r){
    if(a[l] > s || a[r] < s){
        if(a[l] > s){
            ans += a[r] - s;
            return a[r];
        }
        if(a[r] < s){
            ans += s - a[l];
            return a[l];
        }
    }
    LL now, pos;
    if(p[l] >= p[r]){
        now = r;
        p[l] += p[r];
        pos = dfs(l, r - 1);
    }
    else {
        now = l;
        p[r] += p[l];
        pos = dfs(l + 1, r);
    }
    ans += abs(a[now] - pos);
    return a[now];
}
int main(){
    cin>>n>>s;
    for(int i = 1;i <= n; i++){
        scanf("%lld%lld", &a[i], &p[i]);
    }
    dfs(1, n);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#include <stdio.h>
#include <cmath>
#include <tgmath.h>

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


int main() {
    ll n,ans=inf;
    cin>>n;

    for(ll i=1; i*i<=n; i++){
        if(n%i==0&&n/i+i-2<ans){
            ans=n/i+i-2;
        }
    }

    cout<<ans<<endl;

}


Measured memory_bytes: 256
tt = list(map(int, input().split()))
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))

p = (aa[0] - bb[0]) * tt[0]
q = (aa[1] - bb[1]) * tt[1]

if p > 0:
	p *= -1
	q *= -1

if p + q < 0:
	print(0)
elif p + q == 0:
	print("infinity")
else:
	r, s = divmod((-1 * p), (p + q))
	if s == 0:
		print(r * 2)
	else:
		print(r * 2 + 1)

Measured memory_bytes: 3064
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)

int main(void)
{
    int N;
    cin >> N;
    int T,A;
    cin >> T >> A;
    int H[N];
    REP(i,N) cin >> H[i];

    int idx = 0;
    int min_val = 1 << 30;

    REP(i, N)
    {
        int sa = abs( A * 1000 - ( T * 1000 - H[i] * 6));
        if(sa <= min_val)
        {
            min_val = sa;
            idx = i + 1;
        }
    }
    cout << idx << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int N;
  scanf("%d", &N);
  char S[101];
  scanf("%s", S);

  int Red = 0;
  int Blue = 0;
  for(int i = 0; i < N; i++) {
    if(S[i] == 'R') {
      Red++;
    } else {
      Blue++;
    }
  }

  if(Red > Blue) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000005
#define evn(x) (!((x)&1))
#define MOD (ll)(1e9+7)
#define INF INT32_MAX
#define INFL INT64_MAX
using namespace std;

void solve()	{
	string s;
	cin >> s;
	ll w=0;
	ll ans=0;
	for(int i=0; i<s.size(); i++)	{
		if(s[i]=='W')	{
			ans+=(i-w);
			w++;
		}
	}
	cout << ans << endl;
}

int main()	
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin >> t;
	for(int i=1; i<=t; i++)	{
		solve();
	}
	return 0;
}


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

int main(void){
    // Your code here!
    int n,m,a;
    int h,p,q;
    int data[1000][100]={0};
    while(1){
        cin >> n >> m >> a;
        if(n==0&&m==0&&a==0)break;
        rep(i,1000){
            rep(j,100){
                data[i][j] = -1;
            }
        }
        a--;
        rep(i,m){
            cin >> h >> p >> q;
            h--;p--;q--;
            data[h][p] = q;
            data[h][q] = p;
        }
        // rep(i,15){
        //     rep(j,10){
        //         cout << data[i][j] << " " ;
        //     }
        //     cout << endl;
        // }
        for(int i=999;i>=0;i--){
            if(data[i][a]!=-1){
                a = data[i][a];
                // cout << a << endl;
            }
        }
        cout << a+1 << endl;
    }
}



Measured memory_bytes: 3392
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long L,R; cin >> L >> R;
  long long ans = 9999999999;
  for(long long i = L; i <= R - 1; i++){
    for(long long j = i + 1; j <= R; j++){
      if( ((i % 2019) * (j % 2019) % 2019) == 0){
        cout << 0 <<endl;
        return 0;
      }
      else if(((i % 2019) * (j % 2019) % 2019) < ans){
        ans = ((i % 2019) * (j % 2019) % 2019);
      }
    }
  }
  cout << ans << endl;
}

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

int main() {
  int A,B,C,D; cin >> A >> B >> C >> D;
  int L = A+B;
  int R = C+D;
  if ( L > R ) cout << "Left" << endl;
  else if ( L == R ) cout << "Balanced" << endl;
  else cout << "Right" << endl;
  return 0;
}


Measured memory_bytes: 256