akhauriyash/Code-Regression huggingface dataset:
#define rep(i,x) for (int i = 0; i < x; i++)
#define mod 1000000007
#define MOD 998244353
#define inf 1e18
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;


int main(){
	int n, k;
	cin >> n >> k;
	int min;
	rep(i, n) {
		int p;
		cin >> p;
	}
	cout << (n + k - 3) / (k-1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s1[100],s2[100];
int l1,l2;
inline void sc(int x)
{
	for (int i=1;i<x;++i)
		putchar(s1[i]=='?'?'a':s1[i]);
	for (int i=1;i<=l2;++i)
		putchar(s2[i]);
	for (int i=x+l2;i<=l1;++i)
		putchar(s1[i]=='?'?'a':s1[i]);
	exit(0);
}
inline int check(int x)
{
	for (int i=1;i<=l2;++i)
		if (s1[i+x-1]!='?'&&s1[i+x-1]!=s2[i])
			return 0;
	return 1;
}
int main()
{
	scanf("%s",s1+1);
	scanf("%s",s2+1);
	l1=strlen(s1+1);
	l2=strlen(s2+1);
	for (int i=l1-l2+1;i;--i)
		if (check(i))
			sc(i);
	puts("UNRESTORABLE");
}

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

int main() {
  int n; cin >> n;
  long long ans = 0;
  for(int i = 1; i <= n; i++) {
    if(i%15==0 || i % 3 == 0 || i % 5 == 0) continue;
    ans += i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3604
N,M = [int(i) for i in input().split()]
big = []
small = []
flag = 0

for i in range(N):
    a = input()
    big.append(a)
for i in range(M):
    a = input()
    small.append(a)

for i in range(0,N-M+1):
    for j in range(0,N-M+1):
        if big[i][j] == small[0][0]:
            count = 0
            for k in range(M):
                for l in range(M):
                    if big[i+k][j+l] == small[k][l]:
                        count += 1
                    if k == M-1 and l == M-1 and count == M * M:
                        flag = 1
                        break

if flag == 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
using namespace std;
#define FASTNIBBA   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll          long long
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define mii         map<int,int>
#define vi          vector<int>
#define vll         vector<long long>
#define lbnd        lower_bound
#define ubnd        upper_bound
#define all(a)      (a).begin(),(a).end()
#define clz(a)      __builtin_clz(a) // count leading zeroes
#define ctz(a)      __builtin_ctz(a) // count trailing zeroes
#define popc(a)     __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define SIZE        1000005
#define F           first
#define S           second
#define debug(x)    cerr << #x << " = " << x << endl;
#define mod         998244353
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
#define endl        '\n'
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

void solve()
{
   int n; cin>>n;
   int gcd;
   int x; cin>>x;
   gcd=x;
   rep(i,1,n)
   {
     cin>>x; gcd=__gcd(x,gcd);
   }
   cout<<gcd;     
}
int main()
{
    FASTNIBBA;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    while(t--){
       solve();
    }
    return 0;
}

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

typedef long long int ll;

int main () {
  int K, N;
  cin >> N >> K;
  vector<int> vec;
  for (int i = 0; i < N; i++) {
    int temp;
    cin >> temp;
    vec.push_back(temp);
  }
  sort(vec.begin(), vec.end(), greater<int>());
  /*  for (int i = 0; i < N; i++) {
    cout << vec.at(i) << endl;
    }*/
  int result = 0;
  for (int i = 0; i < K; i++) {
    result += vec.at(i);
  }
  cout << result << endl;
  
  return 0;
}


Measured memory_bytes: 256
X,K,D = map(int,input().split())

#できるだけ0に近づける(K1:正の値ギリギリ K2:負の値ギリギリ)
X = abs(X)

K1 = X // D
K2 = K1 + 1

if K < K1:
    print(X-K*D)
else:
    if (K-K1)%2 == 0:
        print(X-K1*D)
    else:
        print(abs(X-K2*D))

Measured memory_bytes: 9172
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
static const ll MOD = 1000000007;

int main(){
  int A,B,M;
  cin >> A >> B >> M;
  vector<int> a(A);
  vector<int> b(B);
  int minA = MOD, minB = MOD;
  for(int i = 0; i < A; i++){
    cin >> a[i];
    if(a[i] < minA) minA = a[i];
  }
  for(int i = 0 ; i < B; i++){
    cin >> b[i];
    if(b[i] < minB) minB = b[i];
  }
  int res = minA + minB;
  for(int i = 0; i < M; i++){
    int x,y,c;
    cin >> x >> y >> c;
    int tmp = a[x-1] + b[y-1] - c;
    if(tmp < res){
      res = tmp;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define ll long long
#define endl '\n'
#define vi vector<int>
#define rep(i, n) for (i = 0; i < n; i++)


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

   
   int i,n,k,s=0;
   cin>>n>>k;

   int a[n];


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

  for(i=0;i<k;i++)
     s=s+a[i];

 cout<<s;
  
    
 }  


  



Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
using namespace std;
int main(){
// Seiranchan!
    int N,M;
    map <string,int> mp;
    int ans=0;
    cin >> N;
    for (int i=0;i<N;i++){
        string S;
        cin >> S;
        mp[S]++;
    }
    cin >> M;
    for (int i=0;i<M;i++){
        string S;
        cin >> S;
        mp[S]--;
    }
    for (auto & elem:mp){
        ans = max(ans,elem.second);
        
    }
    
    cout << ans << endl;
}

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

p = [-1] * N
p[0] = 0
flag = 0
now = 1
i = 0

while flag == 0:
    i += 1
    now = A[now - 1]
    if p[now - 1] != -1:
        flag = 1
    else:
        p[now - 1] = i
    if i == K:
        flag = 2
if flag == 2:
    print(now)

else:
    r = i - p[now - 1]
    e = p[now - 1]

    count = K - e
    pi = count % r

    for i in range(pi):
        now = A[now - 1]

    print(now)

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

#ifdef ONLINE_JUDGE
#define freopen(N, M, Q)
#endif

#define ll long long
#define ull unsigned long long
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(N) N.begin(), N.end()

using namespace std;

const ll INF = 1e9;

int main() {
    ios_base::sync_with_stdio(false);
	//freopen("input.txt", "r", stdin);

	ull n;
	cin >> n;

    n--;
    cout << n * (n + 1) / 2 << endl;
    

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
using namespace std;
int a = 0, b = 0, c = 0, d = 0, e[1050] = {}, f[100010] , counto = 0, counto1 = 1145148;
double syo = 0, su = 0;
char mado[105][105];
string rik;
bool mazi[110], gi[110];
pair<int, int>n[110];
vector<int> r;
int main() 
{
	cin >> a;
	for (int i = 0; i < a; i++) {
		cin >> e[i];
	}
	sort(e, e + a);
	cout << e[a - 1] - e[0] << endl;
	return 0;
}

Measured memory_bytes: 256
def sort_x(a):
    min = 100000
    min_num = 0
    n = len(a)
    A=[[0, 0] for i in range(n)]
    left_list = [1 for i in range(n)]

    for j in range(n):
        for i in range(n):
            if left_list[i]==1 and int(a[i][0]) < min:
                min = int(a[i][0])
                min_num = i
        left_list[min_num] = 0
        A[j] = a[min_num]
        min=100000
    return A

def sort_y(a):
    min = 100000
    min_num = 0
    n = len(a)
    A=[[0, 0] for i in range(n)]
    left_list = [1 for i in range(n)]

    for j in range(n):
        for i in range(n):
            if left_list[i]==1 and int(a[i][1]) < min:
                min = int(a[i][1])
                min_num = i
        left_list[min_num] = 0
        A[j] = a[min_num]
        min=100000
    return A

if __name__ == '__main__':
    n = int(input())
    a_ = [input().split() for i in range(n)]
    c_ = [input().split() for i in range(n)]
    a = [[0,0] for i in range(n)]
    c = [[0,0] for i in range(n)]
    c = sort_x(c_)
    a = sort_y(a_)
    
    frend_num = 0
    #print(a)
    #print(c)
    #min = 100000
    #min_index = 0
    filter_a = [1 for i in range(n)]
    for j in range(n):
        for i in reversed(range(n)):
            if filter_a[i]==1:
                if int(a[i][0])<int(c[j][0]) and int(a[i][1])<int(c[j][1]):
                        filter_a[i]=0
                        frend_num += 1
                        #print("{},{}".format(a,c))
                        #print("{}".format(filter_a))
                        #print("friend is detected")
                        break
    print(frend_num)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  ll n;
  cin >> n;
  ll a[100000] = {0};
  ll ans = 0;
  rep(i,n) {
    ll t;
    cin >> t;
    a[t-1]++;
    ans += t;
  }
  ll q;
  cin >> q;
  rep(i,q) {
    ll b, c;
    cin >> b >> c;
    ll r = a[b-1];
    a[b-1] = 0;
    a[c-1] += r;
    ans = ans + r*(c-b);
    cout << ans << '\n';
  }
}


Measured memory_bytes: 4392
#include <bits/stdc++.h>
using namespace std;
long long test,n,k;
string s;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    //cin>>test;
    test=1;
    while (test--)
    {
        cin>>k;
        cin>>s;
        long long x=s.length();
        for (int i=0;i<min(k,x);i++) cout<<s[i];
        if (s.length()>k) cout<<"...";
    }
    
}    




Measured memory_bytes: 3640
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp {
  char name[100];
  int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue(){
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a, int b) { return a < b ? a : b; }

int main(void){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d",  &n, &q);
  for (int i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;

  while (head != tail){
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if ( u.t > 0 ) enqueue(u);
    else {
      printf("%s %d\n", u.name, elaps);
    }
  }
  return (0);
}



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


int N;
long long h[110000];
long long dp[110000];

int main() {
    int N, K; cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> h[i];
    for (int i = 0; i < 110000; ++i) dp[i] = INF;
    dp[0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1920
s_list = list(input())
s_set = set(s_list)

if len(s_set) == 2:
    if ''.join(s_list).count(s_list[0]) == 2 and ''.join(s_list).count(s_list[1]) == 2:
        print('Yes')
    else:
        print('No')
else:
    print('No')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
vector<int> e[100005];
lli col[100005];
lli dfs(int cur, int c)
{
    if (col[cur] != -1)
        return 0;
    col[cur] = c;
    int sum = 1;
    for (auto s : e[cur]) {
        if (col[s] == -1) {
            sum += dfs(s, c);
        }
    }
    return sum;
}
lli calc(lli v)
{
    if (v == 1)
        return 0;
    else
        return v * (v - 1) / 2;
}
int main()
{
    lli n, m;
    cin >> n >> m;
    int a, b;
    rep(i, m)
    {
        cin >> a >> b;
        a--, b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    int cnt = 0;
    rep(i, n) col[i] = -1;
    vector<int> s;
    rep(i, n) if (col[i] == -1) s.push_back(dfs(i, cnt++));
    lli h = s[0];
    lli v = s[1];
    lli rem = n - s[0] - s[1];
    lli ans = max(calc(h + rem) + calc(v) - m, calc(h) + calc(v + rem) - m);
    cout << ans << endl;
}


Measured memory_bytes: 11136
#include <iostream>

int main()
{
	int a, b, c;
	std::cin >> a >> b >> c;
	if (a < b)
	{
		if (b < c)
		{
			std::cout << a << " " << b << " " << c << std::endl;
		}
		else
		{
			if (a < c)
			{
				std::cout << a << " " << c << " " << b << std::endl;
			}
			else
			{
				std::cout << c << " " << a << " " << b << std::endl;
			}
		}
	}
	else
	{
		if (a < c)
		{
			std::cout << b << " " << a << " " << c << std::endl;
		}
		else
		{
			if (b < c)
			{
				std::cout << b << " " << c << " " << a << std::endl;
			}
			else
			{
				std::cout << c << " " << b << " " << a << std::endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3076
import numpy as np

a = np.array([list(map(int, input().split())) for _ in range(3)])
n = int(input())
b = [int(input()) for _ in range(n)]

for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            a[i][j] = -1
            
flag = False
for i in a:
    if sum(i)==-3:
        flag = True
for i in a.T:
    if sum(i)==-3:
        flag = True
if a.trace() == -3 or  sum([a[0][2], a[1][1], a[2][0]]) == -3:
    flag = True
    
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 12512
n=int(input())
arr=list(map(int,input().split()))
for i in range(n):
  arr[i]=arr[i]-(i+1)
arr=sorted(arr)
if n%2==1:
  m=arr[n//2]
  ans=0
  for i in range(n):
    ans=ans+abs(arr[i]-m)
  print(ans)
else:
  m1=arr[n//2]
  m2=arr[n//2-1]
  ans1=0
  ans2=0
  for i in range(n):
    ans1=ans1+abs(arr[i]-m1)
    ans2=ans2+abs(arr[i]-m2)
  print(min(ans1,ans2))

Measured memory_bytes: 25744
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;

int main() {
    int N; cin>>N;
    //vector<int> a(N);
    map<int,int,greater<>> mp;
    int a;
    for (int i = 0; i < N; ++i) {
        cin>>a;
        if(mp.find(a)==mp.end()){
            mp[a]=1;
        }else{
            mp[a]++;
        }
    }

    vector<int> beki;
    beki.push_back(1);
    for (int i = 0; i < 30; ++i) {
        beki.push_back(beki.back()<<1);
        //cout<<beki.back()<<endl;
    }
    int ans=0;
    for(auto yoso: mp){
        if(yoso.second==0) continue;
        int total=*lower_bound(beki.begin(),beki.end(),yoso.first);
        if(yoso.first==total){
            ans+=yoso.second/2;
            yoso.second-=(yoso.second/2)*2;
        }else{
            int aite=total-yoso.first;
            auto itr=mp.find(aite);
            if(itr!=mp.end()){
                int cnt=min(yoso.second,itr->second);
                ans+=cnt;
                yoso.second-=cnt;
                itr->second-=cnt;
            }
        }

    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 9600
from sys import stdin
import bisect

n,m = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]

lin = [[]for i in range(n)]
lin2 = []
li3 = []
for j in range(m):
    lin[li[j][0]-1].append(li[j][1])
    lin2.append(li[j][0]-1)

for j in range(n):
    liv = sorted(lin[j])
    li3.append(liv)

for k in range(m):
    tosi = str(li[k][0]).zfill(6)
    ban =  str(bisect.bisect(li3[li[k][0]-1],li[k][1])).zfill(6)
    print(tosi+ban)

Measured memory_bytes: 51640
#include <bits/stdc++.h>
#include <queue>
#include <algorithm>

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> a(n),b(n),c(n);
    for(int i=0; i<n; i++) cin >> a[i] >> b[i] >> c[i];

    vector<vector<int>> dp(3,vector<int>(n+1,0));
    dp[0][0] = a[0]; dp[1][0] = b[0]; dp[2][0] = c[0];
    for(int i=1; i<n; i++){
        for(int j=0; j<3; j++){

            if(j == 0){
                dp[j][i] = a[i] + max(dp[1][i-1],dp[2][i-1]);
            }
            else if(j == 1){
                dp[j][i] = b[i] + max(dp[0][i-1],dp[2][i-1]);
            }
            else{
                dp[j][i] = c[i] + max(dp[0][i-1],dp[1][i-1]);
            }

        }
    }
    int ans = 0;
    for(int i=0; i<3; i++){
        ans = max(ans,dp[i][n-1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5904
#include <iostream>
#include <stdlib.h>
#include <vector> //vector
#include <algorithm> //sort()
#include <numeric>

#define rep(i, n) for(int i=0; i<(int)(n);i++)
#define all(x) (x).begin(), (x).end()
#define debug(a) cout << "debug (" #a "):" << endl << (a) << endl;

typedef uint64_t ulint;
typedef int64_t lint;

using namespace std;

template<class T> inline bool chmin(T& a, T b);
template<class T> inline bool chmax(T& a, T b);
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v);

template<class T> lint sum(vector<T> a);
template<class T> double ave(vector<T> a);

//uint64_t a, b, c, d;
//uint64_t i, j;
lint n, m;

int main(){
//////////////////////////////////////////////////////

    cin >> n >> m;



   

    cout << (int)((n * 3 + m)/2) << endl;

    
//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}


//最小化用関数
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;
}


// vectorprint用
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}

// //合計
// template<class T> lint sum(vector<T> a)
// {
//     return std::accumulate(a.begin(), a.end(), 0);
// }


// //平均
// template<class T> double ave(vector<T> a)
// {
//     return std::accumulate(a.begin(), a.end(), 0.0) / a.size();
// }


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.IO;
 
namespace workspace{
	public class Test{
    	static void Main(){
    		var line = System.Console.ReadLine();
        	var l = line.Split(' ').Select(s => Int32.Parse(s)).ToArray();
            if(l[0]*l[1] > l[2]*l[3]){
              Console.WriteLine(l[0]*l[1]);
            }else if(l[2]*l[3] > l[0]*l[1]){
              Console.WriteLine(l[2]*l[3]);
            }else{
              Console.WriteLine(l[0]*l[1]);
            }
    	}
   }
}

Measured memory_bytes: 28196
m = {}

N = int(input())
a = [int(x) for x in input().split()]

c = 0
for b in a:
    if b in m.keys():
        if m[b] >= b:
            c += 1
        else:
            m[b] += 1
    else:
        m[b] = 1

for k, v in m.items():
    if k > v:
        c += v

print(c)

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
#define rSORT(a, i) sort(all(a),(i))

using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;
constexpr int MAX = 2000200;
constexpr double EPS = 1E-11;

using namespace std;

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

	if (a <= c && c <= b) {
		cout << "Yes" << endl;
	}
	else if (a >= c && c >= b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}




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

int main() {
  int N, ans;
  cin >> N;
  ans=0;
  vector<int> d(N);
  for (int i=0; i<N; i++) {
    cin >> d[i];
  }
  for (int j=0; j<N; j++) {
    for (int k=0; k<N; k++) {
      ans=ans+d[j]*d[k];
    }
  }
  for (int l=0; l<N; l++) {
    ans=ans-d[l]*d[l];
  }
  ans=ans/2;
  cout << ans << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N; string s; cin>>N>>s;
	string head;
	int bar = 0;
	rep(i,N){
		if(s[i] == ')') -- bar;
		else ++bar;
		if(bar >= 0)continue;
		bar = 0;
		head += '(';
	}
	cout<<head<<s;
	rep(i,bar)cout<<')';
	cout<<endl;
	return 0;
}

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

long long int a, d;
struct query
{
	int x, y, z;
};

vector<query>all;

long long int saiki( long long int K, long long int N ) {
	if( N == all.size() ) {
		return a + d*K;
	}
	query now = all[N];
	if( now.y <= K&&K <= now.z ) {
		if( now.x == 0 ) {
			long double center = (now.y + now.z) / 2;
			K = center * 2 - K;

		} else if( now.x == 1 ) {
			return 1 + saiki( K, N + 1 );

		} else {
			return saiki( K, N + 1 ) / 2;
		}
	}
	return saiki( K, N + 1 );
}

int main() {
	long long int N;
	cin >> N;
	cin >> a >> d;

	long long int M;
	cin >> M;
	all.resize( M );
	for( size_t i = 0; i < M; i++ ) {
		long long int x, y, z;
		cin >> x >> y >> z;
		all[i].x = x;
		y--;
		all[i].y = y;
		z--;
		all[i].z = z;
	}
	reverse( all.begin(), all.end() );
	long long int K;
	cin >> K;
	K--;
	cout << saiki( K, 0 ) << endl;
}

Measured memory_bytes: 5748
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def main():
    N = int(input())
    m = 10 ** 15
    for _ in range(5):
        m = min(int(input()), m)
    
    print(5 + (N - 1) // m)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
n = int(input())
L = []
for i in range(n):
    L.append(input())

ans = ''
for i in 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ':
    tmp = []
    for j in range(n):
        tmp.append(L[j].count(i))
    ans += i * min(tmp)
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
using namespace std;
vector<int> ret(101);
int main(void){
    int a,b,k;
    cin>>a>>b>>k;
    int result=0;
    
    for(int i=1;i<=a && i<=b;i++){
        if((a%i==0 && b%i==0)){
            ret.push_back(i);
        }
    }
    result = ret[ret.size()-k];
    

    cout<<result;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
bool has[N];
vector<int> G[N];
int c[N], cnt[N];
int dfs(int x, int p = 0) {
	int leaf = 0;
	if (has[x]) leaf = c[x] % 2 ? 1 : 2;
	cnt[x] = has[x];
	for (int u : G[x]) if (u != p) {
		int o = dfs(u, x);
		cnt[x] += cnt[u];
		if (o == 0) continue;
		if (o != -1) o = 3 - o;
		if (!leaf) leaf = o; else {
			if (leaf != o) leaf = -1;
		}
	}
	return leaf;
}
int par[N], l[N], r[N];
pair<int, int> dfs2(int x, int p = 0) {
	int &l = ::l[x] = -1e9, &r = ::r[x] = 1e9;
	par[x] = p;
	for (int u : G[x]) if (u != p) {
		auto seg = dfs2(u, x);
		seg.first --;
		seg.second ++;
		l = max(seg.first, l);
		r = min(seg.second, r);
	}
	if (has[x]) l = r = c[x];
	//printf("%d : %d %d\n", x, l, r);
	c[x] = l;
	return {l, r};
}
void dfs3(int x, int p = 0) {
	if (p == 0) {
		c[x] = l[x];
	}
	else {
		int cho1 = c[p] + 1;
		int cho2 = c[p] - 1;
		if (cho1 >= l[x] && cho1 <= r[x]) {
			c[x] = cho1;
		}
		else if (cho2 >= l[x] && cho2 <= r[x]) {
			c[x] = cho2;
		}
	}
	for (int u : G[x]) if (u != p) {
		dfs3(u, x);
	}
}
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i < n; ++ i) {
		int u, v;
		scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	int m;
	scanf("%d", &m);
	for (int i = 0; i < m; ++ i) {
		int u, c;
		scanf("%d%d", &u, &c);
		has[u] = 1;
		::c[u] = c;
	}
	if (dfs(1) == -1) return 0 * puts("No");
	dfs2(1);
	//for (int i = 1; i <= n; ++ i) if (c[i] == -1e9) c[i] = c[par[i]] + 1;
	dfs3(1);
	bool flag = 1;
	for (int i = 1; i <= n; ++ i) {
		for (int j : G[i]) if (abs(c[i] - c[j]) != 1) {
			flag = 0;
		}
	}
	if (!flag) return 0 * puts("No");
	puts("Yes");
	for (int i = 1; i <= n; ++ i) printf("%d\n", c[i]);
}



Measured memory_bytes: 16256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(k,i,n) for(ll i=k;i<n;++i)

int main(void){
    ll n,m;
    cin>>n>>m;
    if(n==m)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
long long m,a[100005];
int n,ans;
int main()
{
    scanf("%d%lld",&n,&m);
    for (int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    sort(a+1,a+n+1);
    for (int i=1;i<n;i++)
        if (m>=a[i]) m-=a[i],ans++;
    if (m==a[n]) ans++;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[8]:


import math
ds = [int(input()) for i in range(5)]
"""
29
20
7
35
120
"""


# In[9]:


s1 = [d%10 for d in ds if d%10!=0]
if s1:
    m1 = min(s1)
else:
    m1 = 10


# In[10]:


sum_ = 0
for d in ds:
    sum_ += math.ceil(d/10)*10


# In[11]:


print(sum_-10+m1)


# In[ ]:






Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(),x.end()
const lli inf=1e18;
const int mod=1e9+7;
int main(){
IOS;
int n,k,i;
cin>>n>>k;
string s;
cin>>s;
if(n==1){
    cout<<0<<endl;
    return 0;
}
int count=0;
for(i=1;i<s.length();i++){
    if(s[i-1]==s[i])
        count++;
}
int inv=n-1-count;
count+=min(inv,2*k);
cout<<count<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <utility>

using namespace std;

int main(void){
	int a, b, c;
	cin >> a >> b >> c;
	
	int ans;
	ans = min(min(a + b, b + c), c + a);
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1'000'000'007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  ll ans = 0;
  for(int i=1; i<=N; i++){
    ans += (ll)i * (N+1 - i);
  }
  for(int i=0; i<N-1; i++){
    int a,b;
    cin >> a >> b;
    if(a > b) swap(a,b);
    ans -= (ll)a * (N+1 - b);
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <unistd.h>
using namespace std; 
using namespace std::chrono; 
using namespace __gnu_pbds;
#define ll long long int 
//mp.reserve(1024);
//mp.max_load_factor(0.25);
typedef tree<int, null_type, less<int>, rb_tree_tag,  
                 tree_order_statistics_node_update>  
          ordered_set;  
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
            x += 0x9e3779b97f4a7c15;
            x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
            x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
            return x ^ (x >> 31);
        }

        size_t operator()(uint64_t x) const {
            static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
            return splitmix64(x + FIXED_RANDOM);
        }
};
 
void addEdge(vector<ll> adj[], ll u, ll v) 
{ 
   adj[u].push_back(v); 
   adj[v].push_back(u); 
} 
vector<ll> z_function(string s) {
    ll n = s.length();
    vector<ll> z(n);
    for (ll i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}
ll m=998244353;
ll power(ll x,ll y) 
{ 
    ll res = 1; // Initialize result 
  
    while (y > 0) { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = ((res%m) * (x%m))%m; 
  
        // n must be even now 
        y = y >> 1; // y = y/2 
        x = ((x%m) * (x%m))%m; // Change x to x^2 
    } 
    return res; 
} 
int main() 
{ 
 	ios_base::sync_with_stdio(false);
   	cin.tie(NULL);
   	cout.tie(NULL);
    //freopen("input.txt", "r", stdin); 
    //freopen("output1.txt", "w", stdout); 
	ll n;
	cin>>n;
	set<string >s;
	string s1;
	for( ll i=0;i<n;i++){
		cin>>s1;
		s.insert(s1);
	}
	cout<<s.size()<<endl;
    return 0; 
} 


Measured memory_bytes: 19068
import java.io.*;
import java.util.*;
import java.math.*;
     
public class Main{
	public static void main(String[] args) throws Exception {
	IO io = new IO();
	PrintWriter out = new PrintWriter(System.out);
	Solver sr = new Solver();
	sr.solve(io,out);
	out.flush();
	out.close();
    	}

	static class Solver
	{
	    void solve(IO io, PrintWriter out)
	    {
           int i, j;
           int n= io.nextInt();
          int k= io.nextInt();
          int[] ar = new int[n];
          for(i=0 ; i<n ; i++)
            	ar[i]=io.nextInt();
          Arrays.sort(ar);
          long sum=0;
          for(i=n-1 ; i>=0 ; i--)
          {
            	if(k!=0)
                {
                  ar[i]=0;
                  k--;
                }
                else
                {
					sum+=ar[i];
                }
          }
          out.print(sum);
	    }
    	
	}
	//Special thanks to Petr (on codeforces) who inspired me to implement IO class!
	static class IO
	{
    	BufferedReader reader;
        StringTokenizer tokenizer;
    	public IO() {
                reader = new BufferedReader(new InputStreamReader(System.in));
                tokenizer = null;
            }
     
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public String nextLine() {
            String s="";
            try {
                    s=reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            return s;
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
    
        public long nextLong() {
            return Long.parseLong(next());
        }
    	double nextDouble()
    	{
    		return Double.parseDouble(next());
    	}
	}
}

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

#define int long long

#define Vanya Unstoppable

#define double long double

using namespace std;

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

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

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

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

    cout << k - ans;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double hrad = h*30+m*30/60.0;;
    double mrad = m*6;
    double rad = abs(hrad-mrad)*acos(-1)/180;
    double ans = sqrt(a*a+b*b-2*a*b*cos(rad));
    printf("%.12f\n", ans);
}


Measured memory_bytes: 3580
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 c = sc.nextInt();
        int k = sc.nextInt();
        sc.close();

        int max = 0;
        int ans = 0;

        max = Math.max(Math.max(a, b), c);
        if (max == a) {
            ans = b + c;
        } else if (max == b) {
            ans = a + c;
        } else {
            ans = a + b;
        }

        ans += max * Math.pow(2, k);

        System.out.println(ans);
    }
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })
ll N, M;

vvl graph;
vector<bool> seen;

ll sizeDFS(ll node){
  //cout << node << endl;
  seen[node] = true;
  ll ret = 1;
  FOR(i, 0, graph[node].size()){
    if(seen[graph[node][i]]) continue;
    ret += sizeDFS(graph[node][i]);
  }
  return ret;
}

int main(){
  ios_base::sync_with_stdio (false);
  cin.tie(NULL);
  cin >> N >> M;

  graph = vvl(N+10, vl());
  set <pll> friends;

  FOR(i, 0, M){
    ll a, b;
    cin >> a >> b;
    a--; b--;
    if(friends.find(mp(a, b)) != friends.end()) continue;
    friends.insert(mp(a, b));
    friends.insert(mp(b, a));
    graph[a].pb(b);
    graph[b].pb(a);
  }
  seen = vector<bool>(N, false);
  ll sol = 1;
  FOR(j, 0, N){
    if(seen[j]) continue;
    sol = max(sol, sizeDFS(j));
  }

  cout << sol << endl;
}


Measured memory_bytes: 48548
#include<iostream>
#include<cmath>
#include<vector>
#include<climits>
#include<algorithm>
#include<numeric>
#include<iomanip>
#include<map>
#include<set>
#include<random>
#include<cassert>
using namespace std;
#define ll long long int
#define ld long double
const ll Mod = 1000000007;
ll CaseN=1;
const ld PI = 22/7.0;

bool mycmp(string s,string t)
{
if(s.size()<t.size())
{
return true;	
}		
return false;
}


void solve()
{
 
 string s;
 cin>>s;
 for(ll i=0;i<(ll)s.size();i++)
 {
	 if(s[i]!=',')
	 {
		cout<<s[i]; 
		} 
		else
		{
		cout<<" ";	
		}
	}
 // cout<<"Case #"<<CaseN<<": ";
   CaseN++;
	// print your ans below;
    
return ;
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
	{
	solve();	
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main() {
	long long A, B, C, X, Y; std::cin >> A >> B >> C >> X >> Y;
	long long D = (A * X) + (B * Y);
	long long ans{ D };
	long long all{ 0 };
	long long N = std::min(X, Y);
	for (long long i{ 0 }; i <= N; ++i) {
		all = (A * (X - i)) + (B * (Y - i)) + (C * i * 2);
		if (ans > all) ans = all;
	}
	all = 2 * std::max(X, Y) * C;
	if (ans > all) ans = all;
	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 3640
N=int(input())
T=list(map(int,input().split()))
M=int(input())
P=[]
X=[]
for i in range(M):
    p,x=list(map(int,input().split()))
    P.append(p)
    X.append(x)
for m in range(M):
    s=0
    for n in range(N):
        if n+1==P[m]:
            s+=X[m]
        else:
            s+=T[n]
       #print(n+1,s)
    print(s)


Measured memory_bytes: 3064
while(True):
    var=input()
    var=var.split()
    m=int(var[0])
    r=int(var[1])
    f=int(var[2])
    if(m==r==f==-1):
        break
    if(m==-1 or r==-1):
        print("F")
    elif((m+r)>=80):
        print("A")
    elif(65<=(m+r)<80):
        print("B")
    elif(50<=(m+r)<80):
        print("C")
    elif(30<=(m+r)<50 and f<50):
        print("D")
    elif(30<=(m+r)<50 and f>=50):
        print("C")
    elif((m+r)<30):
        print("F")


Measured memory_bytes: 5592
from collections import deque


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

B = deque()
for i, a in enumerate(A):
    if i % 2 == 0:
        B.append(a)
    else:
        B.appendleft(a)
if n % 2 == 1:
    B = list(B)[::-1]

print(*B)


Measured memory_bytes: 25532
#include <iostream>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <queue>
//#include <cmath>
//#include <stdlib.h>
#define ll long long
#define MOD_P 1000000007
using namespace std;

int main()
{
	//int n;
	//ll int sum = 0LL;
	//cin >> n;

	//for (int i = 1; i <= n; i++) {
	//	if (i % 3 && i % 5) {
	//		sum += (ll int)i;
	//	}
	//}

	//printf("%lld", sum);

	int n;
	cin >> n;

	while (n > 0) {
		if (n % 10 == 7) {
			printf("Yes");
			return 0;
		}
		n /= 10;
	}

	printf("No");

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

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

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int points[5][5];
int dir[4] = {1,2,4,8};
char dirc[4] = {'R','D','L','U'};
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
// [0,1,2,3] : [right,bottom,left,top]

int main(){
  REP(i,9){
    int x;
    cin>>x;
    if(i%2==0){
      // yokonaga
      REP(_j,4){
        int j = 3-_j;
        int val = x%10;
        x/=10;
        if(val==1){
          points[j][i/2] |= dir[0];
          points[j+1][i/2] |= dir[2];
        }
      }
    }else{
      // tatenaga
      REP(_j,5){
        int j = 4-_j;
        int val = x%10;
        x/=10;
        if(val==1){
          points[j][i/2] |= dir[1];
          points[j][i/2+1] |= dir[3];
        }
      }
    }
  }
  // input end
  int x=0, y=0, d=0;
  string res = "";
  while(!(x==0 && y==0) || res.size()==0){
    int kabe = (d+3)%4;
    if(points[x][y] & dir[kabe]) d = kabe;
    while(!(points[x][y] & dir[d])) d = (d+1)%4;
    res += dirc[d];
    x += dx[d];
    y += dy[d];
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
const int MINF=-2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/*---------------------template----------------------*/
/*----------------------end--------------------------*/
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
signed main(){
  int N,K;cin>>N>>K;
  cout<<N%K<<endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <cstdlib>
using namespace std;
int main(){
      int w,h,n,fx,fy,tx,ty,solve=0;
      cin>>w>>h>>n;
      cin>>tx>>ty;
      for(int i=1;i<n;i++){
            fx=tx,fy=ty;
            cin>>tx>>ty;
            if((tx-fx>0&&ty-fy>0)||(fx-tx>0&&fy-ty>0))solve+=max(abs(tx-fx),abs(ty-fy));
            else solve+= abs(tx-fx)+abs(ty-fy);
      }
      cout<<solve<<endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    string s;cin>>s;
    s = "$" + s;
    ll n=s.size();
    ll dp[n+1][2];
    dp[0][0]=dp[0][1]=0;
    for(ll i=1;i<n;i++){
        ll cur = s[i]-'0';
        dp[i][cur] = dp[i-1][1-cur];
        dp[i][1-cur]=1+dp[i-1][cur];
       // cout<<i<<" "<<cur<<" "<<dp[i][cur]<<" "<<dp[i][1-cur]<<endl;
    }
    cout<<min(dp[n-1][0],dp[n-1][1]);
}


Measured memory_bytes: 1900
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
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;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	vpint a;
	while (1) {
		int x, y;
		cin >> x >> y;
		if (x == 0 && y == 0)break;
		a.push_back({ x,y });
	}
	rep(i, a.size()) {
		rep(j, a[i].first) {
			rep(k, a[i].second) {
				if ((j + k) % 2 == 0) {
					cout << "#";
				}
				else {
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


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

int main(){
    int N, K;
    cin >> N >> K;
    bool flg = true;
    int i = 0, M = K;

    while(flg){
        if(N / K < 1){
            flg = false;
        }
        K = K * M;
        i++;
    }
    cout << i << endl;
    return 0;
}

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

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

  vector<int> p(n + 1);
  for (int i = 1; i <= n; ++i)
    cin >> p[i];

  vector<double> e(n + 1);
  for (int i = 1; i <= n; ++i) {
    double sum = (p[i] + 1) * p[i] / 2.0;
    e[i] = sum / p[i];
  }

  for (int i = 1; i <= n; ++i) {
    e[i] = e[i - 1] + e[i];
  }

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

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

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
int main(){
int N,M;
  cin>>N>>M;
  Graph G(N);
  for(int i=0;i<M;i++){
  int a,b;
    cin>>a>>b; a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  
  }queue<int>que;
  vector<int>dist(N,-1);
  que.push(0);
  dist.at(0)=0;
  while(!que.empty()){
  int u=que.front();
    que.pop();
    for(auto v:G[u]){
    if(dist[v]!=-1)
      continue;
      else{
      dist[v]=u;
        que.push(v);
      }
    }
  
  }cout<<"Yes"<<endl;
  for(int i=1;i<N;i++)
    cout<<dist.at(i)+1<<endl;
  
   return 0;
}



Measured memory_bytes: 10136