akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define maxn 1000005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second
using namespace std;
char inp[maxn]; 
int a[100][100];
int nx[maxn];
int main() {
	int n;
	cin >> n;
	scanf("%s", inp);
	if (n <= 80) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n - i + 1; j++)
				if (i == 1) a[i][j] = inp[j - 1] - '0';
				else a[i][j] = abs(a[i - 1][j] - a[i - 1][j + 1]); 
		} 
		cout << a[n][1] << endl;
		return 0;
	}
	int fl = 0;
	for (int i = 1; i <= n - 1; i++) {
		nx[i] = abs(inp[i] - inp[i - 1]);
	//	cout << i << ' ' << nx[i] << endl;
		if (nx[i] % 2) fl = 1;
	}
	if (fl == 0) {
		for (int i = 1; i <= n - 1; i++)
			nx[i] /= 2;
		int jr = 0;
		for (int i = 1; i <= n - 1; i++) {
			int u = n - 2, v = i - 1;
			if ((u & v) == v) jr += nx[i]; 
		}
		jr %= 2;
		cout << 2 * jr << endl;
		return 0;
	}
	int dm = 0;
	for (int i = 0; i <= (n - 1); i++) {
		if (((n - 1) & i) == i) dm += inp[i] - '0'; 
	} 
	dm %= 2;
	cout << dm << endl;
	return 0;
}


Measured memory_bytes: 5120
#include <iostream>

using namespace std;

int n, q;
int* S;
int* T;

int solve() {
  int count = 0;
  for (int i = 0; i < q; i++) {
    int t = T[i];
    
    int left = 0;
    int right = n;
    while (left < right) {
      int mid = (left + right) / 2;
      if (S[mid] == t) {
        count++;
        break;
      } else if (S[mid] < t) {
        left = mid + 1; // midはもう調べたので含めない
      } else {
        right = mid; // rightには含めない
      }
    }
  }
  return count;
}

int main() {
  cin >> n;
  S = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> S[i];
  }
  
  cin >> q;
  T = new int[q];
  for (int i = 0; i < q; i++) {
    cin >> T[i];
  }

  int res = solve();
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 1764
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef pair<int,int> pii;
typedef long long int lld;
const lld MAX=17;
const lld MOD=1000000007;
lld dp[1<<MAX][MAX+3],n,m,a[MAX+3],p[1<<MAX]={1,1,},mdp[1<<MAX],fin,pow2[1<<MAX][MAX+3];
lld pow(lld x,lld y){
    if(y==0) return 1;
    if(y==1) return x;
    lld t=pow(x,y/2);
    if(y%2) return ((t*t%MOD)*x)%MOD;
    return t*t%MOD;
}
lld comb(lld x,lld y){
    if(x<0||y<0||y>x) return 0;
    return ((p[x]*pow(p[y],MOD-2)%MOD)*pow(p[x-y],MOD-2))%MOD;
}
lld pow_comb(lld x,lld y){
    if(x<(1<<y)-1||x<0||y<0) return 0;
    return pow2[x][y];
}
lld make_dp(lld x,lld y){
    if(y==0){
        if(x==0) return 1;
        return 0;
    }
    if(dp[x][y]==-1){
        dp[x][y]=0;
        for(lld i=0;i<n;i++) if(x&(1<<i)){
            dp[x][y]+=pow_comb((1<<n)-a[y-1]-(x-(1<<i)),i)*make_dp(x-(1<<i),y-1);
            dp[x][y]%=MOD;
        }
        dp[x][y]+=make_dp(x,y-1),dp[x][y]%=MOD;
        //printf("%lld %lld %lld\n",x,y,dp[x][y]);
    }
    return dp[x][y];
}
int main(){
    scanf("%lld%lld",&n,&m);
    for(lld i=1;i<(1<<n)+5;i++) p[i+1]=p[i]*(i+1),p[i+1]%=MOD;
    for(lld i=0;i<(1<<n)+5;i++) for(lld j=0;j<=16;j++) dp[i][j]=-1,pow2[i][j]=comb(i,(1<<j)-1);
    for(lld i=m-1;i>=0;i--) scanf("%lld",&a[i]);
    for(lld i=0;i<(1<<n);i++) {
        mdp[i]=make_dp(i,m);
        lld r=0;
        for(lld j=0,cnt=i;j<n;j++) if((i&(1<<j))==0) r++,mdp[i]*=comb((1<<n)-cnt-1,(1<<j)),mdp[i]%=MOD,cnt+=(1<<j);
        if((n-r)%2==1) fin+=MOD-mdp[i],fin%=MOD;
        else fin+=mdp[i],fin%=MOD;
        //printf("%lld %lld\n",n-r,mdp[i]);
    }
    for(lld i=0;i<n;i++) fin*=p[1<<i],fin%=MOD;
    fin*=(1<<n),fin%=MOD;
    printf("%lld\n",fin);
}


Measured memory_bytes: 26368
import math
def abssum(nums):
    nums_length = len(nums)
    result = 0
    for i in range(nums_length-1):
        result += abs(nums[i]-nums[i+1])
    return result



N,M = input().split(" ")
N = int(N)
M = int(M)
temp = list(map(int,input().split(" ")))
diffs = [abs(n1-n2) for n1,n2 in zip(temp[0:-1],temp[1:])]
fromzero = [abs(0-n) for n in temp]

scores = [sum(diffs[0:M-1])]

for i in range(1,N-M+1):
    scores.append(scores[i-1]-diffs[i-1]+diffs[i+M-2])

for i,(cand1,cand2) in enumerate(zip(fromzero[0:N-M+1],fromzero[M-1:])):
    scores[i] += min(cand1,cand2)
print(min(scores))




Measured memory_bytes: 18212
#include <bits/stdc++.h>
using namespace std;
int i,j,k,count1=0,count2=0;
int gcd(int,int);
void ABC155();
void ABC156();
void ABC157();
void ABC158();
void ABC161();
void ABC162();
void ABC163();
void ABC164();

int main(){
    ABC155();
}

void ABC155(){
    int n,k=-1;
    cin>>n;
    string str;
    vector<string> s(n);
    for(i=0;i<n;i++){
        cin>>s[i];
    }
    sort(s.begin(),s.end());
    vector<pair<int,string>> list;
    str='\0';
    for(i=0;i<n;i++){
        if(s[i]!=str){
            str=s[i];
            list.push_back(make_pair(1,str));
        }else{
            get<0>(list.at(list.size()-1))++;
        }
    }
    sort(list.begin(),list.end());
    int a=get<0>(list.at(list.size()-1));
    for(i=0;i<list.size();i++){
        if(get<0>(list.at(i))==a)cout<<get<1>(list.at(i))<<endl;
    }
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	ll N, K; cin >> N >> K;
	if (N == K || K == 1) {
		cout << 0 << endl;
		return;
	} else if (N > K) {
		N = N%K;
	}
	cout << min(N, K-N) << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main( void ) 
{
 
    int n;
    scanf( "%d", &n );
    
    int i, j;
    int num; 
    int cnt = n;
    for( i=0; i<n; i++ ) {
        scanf( "%d", &num );
        if( 2 == num ) { continue; }
        
        if( 0 != num%2 ) {
            for( j=3; j*j<=num; j+=2 ) {
                if( 0 == num%j ) {
                    cnt--;
                    break;
                }
            }
        } else {
            cnt--;
        }
        
    }
     
    printf( "%d\n", cnt );
    
    return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n],b[n];
  for(int i=0;i<n;i++)cin >> a[i];
  for(int i=0;i<n;i++)cin >> b[i];
  int k,l=0;
  for(int i=0;i<n;i++){
    k=0;
    for(int j=0;j<n;j++){
      if(j<=i)k+=a[j];
      if(j>=i)k+=b[j];
    }
    if(l<k)l=k;
  }
  cout << l << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 200010;
const int MAXK = 110;
const int MAXQ = 200010;

int n;
ll dp[MAXN][15];
string s;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> s;
    n = SZ(s);
    s = " " + s;
    dp[0][0] = 1;
    FOR(i,0,n-1) {
        FOR(j,0,12) {
            if (s[i+1] == '?') {
                FOR(k,0,9) {
                    dp[i+1][(j * 10 + k) % 13] = (dp[i+1][(j * 10 + k) % 13] + dp[i][j]) % MODBASE;
                }
            }
            else {
                int g = s[i+1] - '0';
                dp[i+1][(j * 10 + g) % 13] = (dp[i+1][(j * 10 + g) % 13] + dp[i][j]) % MODBASE;
            }
        }
    }
    cout << dp[n][5];
    return 0;
}


Measured memory_bytes: 12140
/*
author : seryu
title : ABC172C_"Tsundoku"
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }

void solve()
{
	ll n, m, k;
	cin >> n >> m >> k;
	vector<ll> a(n+1, 0), b(m+1, 0);
	rep(i, n)cin >> a[i+1];
	rep(i, m)cin >> b[i+1];
	rep(i, n)a[i+1] += a[i];
	rep(i, m)b[i+1] += b[i];
	int ans = 0;
	rep(i, n+1)
	{
		ll t = k - a[i];
		if(t < 0)break;
		int tmp = i;
		int l = 0, r = m+1;
		while (l+1 < r)
		{
			int c = (l+r)/2;
			if(b[c] <= t)l = c;
			else r = c;
		}
		tmp += l;
		chmax(ans, tmp);
	}
	cout << ans << endl;
	return;	
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


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

//順列
int main(){
   int n; cin>>n;
   vector<int> p(n);
   vector<int> q(n);
   rep(i,n) cin>>p[i];
   rep(i,n) cin>>q[i];
   vector<int> a(n);
   rep(i,n) a[i]=i+1;
   map<vector<int>,int> mp;
   int cnt=0;
   do{
      //mp.size()で順番を出している
      mp[a]=mp.size();
      //a=[1,2,3]の順列をnext_permutationで出している
      /*cout<<mp.size();
      rep(i,a.size()){
         cout<<a[i]<<" ";
      }
      cout<<endl;*/
   }while(next_permutation(a.begin(),a.end()));

   int ans=abs(mp[p]-mp[q]);
   cout<<ans<<endl;
   return 0; 
}


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

typedef struct box{
	int par;//親の接点番号
	int sunnumber;//子の数
	int *sun;//子のリスト
} Node;

int depthsearch(Node *node,int point)//深さを返す
{
	int i,cnt=0,current = point;
	while(node[current].par!=-1){
		current=node[current].par;
		cnt++;
	}
	
	return cnt;
}

int main(void)
{
	int i,j,n;
	int box,s;
	Node *node;
	
	scanf("%d",&n);
	node=(Node*)malloc(sizeof(Node)*n);
	for(i=0;i<n;i++) node[i].par=-1;//親の節点番号を初期化
	for(i=0;i<n;i++){
		scanf("%d",&box);
		scanf("%d",&node[box].sunnumber);
		node[box].sun=(int*)malloc(sizeof(int)*node[box].sunnumber);//子リストの格納領域を確保
		for(j=0;j<node[box].sunnumber;j++){
			scanf("%d",&node[box].sun[j]);
			node[node[box].sun[j]].par=box;//親ノードを指定
		}
	}
	
	for(i=0;i<n;i++){
		printf("node %d: parent = %d, depth = %d, ",i,node[i].par,depthsearch(node,i));
		if(node[i].par==-1) printf("root, [");
		else if(node[i].sunnumber==0) printf("leaf, [");
		else printf("internal node, [");
		for(j=0;j<node[i].sunnumber;j++){
			if(j!=0) printf(", ");
			printf("%d",node[i].sun[j]);
		}
		printf("]\n");
	}
	
	for(i=0;i<n;i++){
		free(node[i].sun);
	}
	free(node);
	
	return 0;
}


Measured memory_bytes: 6508
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC061B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N, M;
            string[] vals = Console.ReadLine().Split(' ');
            N = int.Parse(vals[0]);
            M = int.Parse(vals[1]);

            int[] count = new int[N + 1];
            int a, b;
            for (int i=1; i <= M; i++)
            {
                vals = Console.ReadLine().Split(' ');
                a = int.Parse(vals[0]);
                b = int.Parse(vals[1]);
                count[a]++;
                count[b]++;
            }

            for(int i=1; i <= N; i++)
            {
                Console.WriteLine(count[i]);
            }
        }
    }
}


Measured memory_bytes: 11092
using System;

public class Hello
{
    public const int MD = 1000000007;
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var m = int.Parse(line[0]);
        var n = int.Parse(line[1]);
        Console.WriteLine(power(m, n));
    }
    public static long power(int m, int n)
    {
        var w = (int)(Math.Log10(n) / Math.Log10(2)) + 1;
        var a = new long[w];
        a[0] = m;
        for (int i = 1; i < w; i++)
            a[i] = (a[i - 1] * a[i - 1]) % MD;
        var ret = 1L;
        for (int i = 0; i < w; i++)
            if (((n >> i) & 1) == 1) { ret *= a[i]; ret %= MD; }
        return ret;
    }
}



Measured memory_bytes: 9484
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
   ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,ans=0,i;
    cin>>n;
    ll a[n+5],v[n+5],c[n+5];
    for(i=0;i<n;i++){
        cin>>v[i];    
    }
    for(i=0;i<n;i++){
        cin>>c[i];
        a[i]=v[i] - c[i];
    }
    sort(a,a+n);
    reverse(a,a+n);
    for(i=0;i<n;i++){
        if(a[i]<=0){
            break;
        }
        ans+=a[i];
    }
    cout<<ans;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
using ll = long long;
const int INF = 1e9 + 5;

void print_vector2(vector<vector<ll> >v){
    for(ll i=0;i<v.size();i++){
        for(ll j=0;j< v[i].size();j++){
            cout<<v[i][j]<<" ";
        }cout<<"\n";
    }
}

void print_vector1(vector<ll> v){
    for(ll i=0; i<v.size();i++){
        cout<<v[i]<<" ";
    }cout<<"\n";
}

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

int main(){
        string s;
        cin>>s;
        if(s[1] == 'B'){
            cout<<"ARC";
        }
        else{
            cout<<"ABC";
        }
    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextLong();
  int X = nextLong();
  int T = nextLong();
  int ans = ((N + X - 1) / X) * T;
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>

using namespace std;

const int MOD = 1000000007;
typedef long long ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,W;
  cin>>N>>W;
  vector<int> w(N),v(N);
  for(int i=0;i<N;i++)cin>>w[i]>>v[i];
  vector<vector<ll> > dp(N+1,vector<ll>(W+1,-1));
  
  dp[0][0]=0;


  for(int i=0;i<N;i++){
    for(int j=0;j<=W;j++){
      if(dp[i][j]==-1)continue;
      //使う
      if(j+w[i]<=W){
        dp[i+1][j+w[i]] = max(dp[i][j]+v[i],dp[i+1][j+w[i]]);
      }
      //使わない
      dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
    }
  }

  vector<ll> tmp=dp[N];
  sort(tmp.rbegin(),tmp.rend());
  cout<<tmp[0]<<endl;
}


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

typedef vector <int> vi;
typedef pair< int ,int > pii;
#define endl "\n"
#define sd(val) scanf("%d",&val)
#define ss(val) scanf("%s",&val)
#define sl(val) scanf("%lld",&val)
#define debug(val) printf("check%d\n",val)
#define all(v) v.begin(),v.end()
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long
#define MOD 1000000007
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl; 
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


int main() 
{
 int n ; cin >> n ; 
 int d = n %10;
if(d== 2 || d == 4 || d == 5 || d ==7 || d ==9)
cout << "hon" << endl;
else if (d == 3)
cout << "bon" << endl;
else cout << "pon" << endl; 



return 0;
   
}

Measured memory_bytes: 3628
#include<iostream>

#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)

using namespace std;

typedef long long int lli;

const int SIZE = 100010;

lli A[SIZE];

int main(){
  lli N;
  cin >> N;
  
  REP (i, 0, N) {
    int t;
    cin >> t;
    A[t - 1]++;
  }
  lli ans = 0;
  int cnt = 0;
  REP (i, 0, SIZE) {
    while (A[i] >= 3) {
      int temp = A[i] / 3;
      A[i] = temp + (A[i] % 3);
    }
    if (A[i] >= 1) cnt++;
    if (A[i] >= 2) ans++;
  }

  cout << cnt - (ans % 2) << endl;

  return 0;
}


Measured memory_bytes: 1024
#pragma region header
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#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 all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------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 / gcd(a, b) * b ;
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
bool isprime(int n) { //素数判定
    if(n==1)return false;
    if(n==2)return true;
    for(int i = 2;i<=sqrt(n);i++) {
        if(n%i==0) return false;
    }
    return true;
}
/* ----------------------end----------------------- */
#pragma endregion

signed main() {
    int n;cin >> n;
    vi v(n);rep(i, n) cin >> v[i];
    int count = 0;
    rep(i, n) {
        if(i+1==v[i]) {
            if(i==n-1) count++;
            else {
                v[i]=v[i+1],v[i+1]=i+1;
                count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<pair<ll, ll>> xy(n);
    rep(i, n) cin >> xy[i].first >> xy[i].second;
    vector<ll> v(n);
    rep(i, n) v[i] = i;
    double ans = 0;
    do {
        double tmp = 0;
        rep(i, n - 1) {
            ll dx = xy[v[i]].first - xy[v[i + 1]].first;
            ll dy = xy[v[i]].second - xy[v[i + 1]].second;
            tmp += sqrt(dx * dx + dy * dy);
        }
        ans += tmp;
    }
    while(next_permutation(all(v)));
    ll bb = 1;
    rep(i, n) bb *= (i + 1);
    ans /= bb;
    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	char moji,bun[1200];

	int abc[123]={0},i=0;

	while((moji=getchar())!=EOF){
		if(65<=(int)moji && (int)moji<=90){
			abc[(int)moji+32]++;
		}
		if(97<=(int)moji && (int)moji<=122){
			abc[(int)moji]++;
		}
	}

	for(i=97;i<=122;i++){
		printf("%c : %d\n",(char)i,abc[i]);
	}
}

Measured memory_bytes: 2604
N = int(input())

A = sorted([int(_) for _ in input().split()])
if N % 2 == 1:
    if A[0] != 0:
        print(0)
        exit()
    A.pop(0)
    s = 2
else:
    s = 1

ans = 1
MOD = 10 ** 9 + 7
for i in range(0, N // 2):
    v = s + 2 * i
    j = 2 * i
    # print(v, A[j],A[j+1])
    if A[j] != v or A[j + 1] != v:
        print(0)
        exit()
    ans *= 2
    ans %= MOD

print(ans)


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

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 100005
#define maxK 305
#define MOD 1000000007
#define oo 1000000000000000007LL
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int n, a[maxN], cnt[30];


int main () {
    scanf("%d", &n);
    fto(i, 1, n) scanf("%d", &a[i]);

    int sum = 0;
    fto(i, 1, n) sum ^= a[i];

    fto(i, 1, n) {
        int b = log2(a[i]&(-a[i]));
        ++cnt[b];
    }

    int ans = 0;
//    debug(sum);
    fdto(i, 29, 0) {
        if (((sum>>i)^(sum>>(i+1)))&1) {
            if (cnt[i] == 0) {
                puts("-1");
                return 0;
            } else ++ans;
        }
    }

    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int A,B,K;
  cin>>A>>B>>K;
  
  if(A+K-1<B-K+1){
    for(int i=A; i<A+K; ++i) cout<<i<<endl;
    for(int i=B-K+1; i<=B; ++i) cout<<i<<endl;
  }
  
  else{
    for(int i=A; i<=B; ++i) cout<<i<<endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S = sc.next();

		int l[] = new int[Q];
		int r[] = new int[Q];

		for (int i = 0; i < Q; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		}

		int ans[] = new int[Q];
		int t[] = new int[N+1];
		t[0] =  0;
		for (int i = 1; i < N; i++) {
			if (S.substring(i-1, i+1).equals("AC")) {
				t[i] = t[i-1] + 1;
			} else {
				t[i] = t[i-1];
			}
		}

		for (int i = 0; i < ans.length; i++) {
			System.out.println(t[r[i]-1]-t[l[i]-1]);
		}
	}
}


Measured memory_bytes: 87864
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <queue>
#include <set>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

const int maxi = 1e6+10;
string s;
vector<int> v[maxi];
int n;
ll a,b;

int main () {
  cin >> a >> b;
  int m=1,r=0;
  while ( m < b ) {
    m+=a-1;
    r++;
  }
  cout << r << endl;
}


Measured memory_bytes: 23808
// Problem : A - Don't be late
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


#include<bits/stdc++.h>
#define 	ll		    long long
#define 	rep(i,a,n)  for(int i=a;i<n;i++)
#define 	MOD 		1000000007
#define 	vp 			vector<pair<int,int> >
#define 	ff 			first
#define 	ss 			second
#define 	pb 			push_back
#define 	all(x) 		(x).begin(),(x).end()
#define 	dg(x)		cerr<<"--- x = "<<x<<"\n"
#define 	endl		"\n"


using namespace std;
const int N = 1e5;
ll ar[N];

void solve(){
	ll d,t,s ; cin >> d >> t >> s;
	
	if(s * t >= d)
		cout << "Yes";
	else
		cout << "No";
}

int main(){

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


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
char s[100005];
bool t[100005];
int main()
{
	int n;
	cin>>n>>s;
	s[0];
	for(int i=0;i<2;i++)
	{
		for(int j=0;j<2;j++)
		{
			t[0]=i;
			t[1]=j;
			for(int k=1;k<n-1;k++)
				t[k+1]=t[k-1]^t[k]^(s[k]=='x');
			if((s[n-1]=='x')==t[n-2]^t[n-1]^t[0]&&(s[0]=='x')==t[n-1]^t[0]^t[1])
			{
				for(int k=0;k<n;k++)
				{
					if(t[k])
						cout<<'W';
					else
						cout<<'S';
				}
				return 0;
			}
		}
	}
	cout<<"-1";

	return 0;
}

Measured memory_bytes: 512
import java.util.*;

class Main {
public static void main(String[] args){

Scanner sc = new Scanner(System.in);
String a = sc.next();
String ans = "No";
for(int i = 0;i < a.length();i++){
  if(a.substring(i,i + 1).equals("9")){
    ans = "Yes";
  }
}
System.out.println(ans);

}
}

Measured memory_bytes: 22100
Scanf.scanf "%s" (fun s ->
    let n = String.length s in
    let proc () =
        let rec loop i prev acc =
            if i = n - 1 then prev, acc else 
                let acc = (prev, i + 2) :: acc in
                if i >= n / 2 then loop (i + 1) prev acc else
                    if s.[i] <> s.[n - 2 - i] then prev, [] else
                    if s.[i] = '1' then loop (i + 1) (i + 2) acc
                                   else loop (i + 1) prev    acc
        in
        let prev, acc = loop 0 1 [] in
        if acc = [] then print_endline "-1" else
            List.iter (fun (a, b) -> Printf.printf "%d %d\n" a b) acc
    in
    if s.[n - 1] = '1' || s.[0] = '0' || s.[n - 2] = '0' then print_endline "-1" else proc ()
)

Measured memory_bytes: 11252
while True:
    a, op, b = input().split()
    a, b = int(a), int(b)

    if op == '?':
        break
    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(int(a / b))


Measured memory_bytes: 5600
s=gets.chomp.chars
n=s.size
a=[s]
sum=0
# それぞれの文字と文字の間に'+'を入れるかどうか
["", "+"].repeated_permutation(n-1) do |i|
  # "+"を`to_i`すると`0`になる
  tmp=s.zip(i).join
  if tmp.include?("+")
    sum+=tmp.split('+').map(&:to_i).inject(:+)
  else
    sum+=tmp.to_i
  end
end
puts sum

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define pb push_back
#define pii pair<int64_t,int64_t>
#define mp make_pair
#define whole(v) begin(v),end(v)
#define print(c,n) for(int64_t i=0;i<n;i++) cout << c[i] << " ";
#define MOD 1000000007
auto comp = [](pii a,pii b){
	return a.second < b.second;
};
void solve(){
	int n;
	cin >> n;
	vector<pii> v;
	v.reserve(n);
	for(int i=0;i<n;i++){
		int a,b;
		cin >> a >> b;
		v.eb(mp(a,b));
	}
	sort(whole(v),comp);
	int temp = 0;
	bool b=true;
	for(int i=0;i<n;i++){
		temp+=v[i].first;
		if(temp>v[i].second){
			b=false;
			break;
		}
	}
	if(b) cout << "Yes";
	else cout << "No";
}
int main(){
	
	solve();
}

Measured memory_bytes: 3328
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int x[] = new int[n+1];
    int y[] = new int[m+1];
    int maxx = -1000000;
    int miny = 1000000;
    x[0]=sc.nextInt();
    y[0]=sc.nextInt();
    for(int i=1;i<n+1;i++){
      x[i]=sc.nextInt();
    }
    for(int i=1;i<m+1;i++){
      y[i]=sc.nextInt();
    }
    for(int i=0;i<n+1;i++){
      maxx=Math.max(maxx,x[i]);
    }
    for(int i=0;i<m+1;i++){
      miny=Math.min(miny,y[i]);
    }
    if(maxx<miny){
      System.out.println("No War");
    }else{
      System.out.println("War");
    }
    
    
      
  }
  

  
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2002;
const LL MOD = 1e9 + 7;

int n, k, a[N];

int main() {
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
	}
	int cnt=0;
	for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++)if(a[i]>a[j])cnt++;
	LL ans = 1LL * cnt * k % MOD;
	for(int i=1;i<=n;i++){
		int tmp=0;
		for(int j=1;j<=n;j++){
			if(a[i]<a[j])tmp++;
		}
		ans = (ans + 1LL * tmp * (1LL * (k-1) * k / 2 % MOD) % MOD) % MOD;
	}
	/*
	for(int i=1;i<=n;i++){
		int tmp=0;
		for(int j=1;j<=n;j++){
			if(a[i]>a[j])tmp++;
		}
		ans = (ans + 1LL * tmp * (1LL * (k-1) * k / 2 % MOD) % MOD) % MOD;
	}
	*/
	cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Diagnostics;
using static System.Console;
using static System.Math;

namespace CodeForces
{
    class CodeForcesss
    {
        static void Main(string[] args)
        {
            long[] s = ReadLine().Split(' ').Select(long.Parse).ToArray();
            long a = s[0];
            long b = s[1];
            var hoge = PrimeFactor(a).Distinct().ToList();
            var fuga = PrimeFactor(b).Distinct().ToList();
            WriteLine(
                hoge.Intersect(fuga).Count() + 1
                );

        }

        static IEnumerable<long> PrimeFactor(long n)
        {
            int i = 2;
            long tmp = n;

            while (i<=Math.Sqrt(n))
            {
                if (tmp % i == 0)
                {
                    tmp /= i;
                    yield return i;
                }
                else i++;
            }
            if (tmp != 1) yield return tmp;
        }
    }
}


Measured memory_bytes: 13396
n,k=map(int, input().split())
a=list(map(int, input().split()))

for t in range(k):
      ok=True
      b=[0]*n
      for i in range(n):
            left=max(0,i-a[i])
            b[left]+=1
            if i+a[i]+1 <= n-1:
                  right=i+a[i]+1
                  b[right]-=1
      for i in range(1,n):
            b[i]=b[i-1]+b[i]
      for i in range(n):
            if a[i]!=b[i]:
                  ok=False
            a[i]=b[i]
      if ok==True:
            break

print(*a)



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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n), bucket(n);
  for( int i = 0; i < n; ++i ) {
    cin >> a[i];
    bucket[a[i]]++;
  }
  sort(bucket.begin(), bucket.end(), greater<int>());
  
  int cnt = 0, sum = 0, ans = 0;
  sum = bucket.size();
  if( sum < k ) cout << 0 << endl;
  else{
    for(int i = 0; i < k; ++i){
      cnt += bucket[i];
    }
    ans = sum - cnt;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 1792
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val Array(h1, m1, h2, m2, k) = in.readLine().split("\\s+").map(_.toInt)

    val l = h1 * 60 + m1
    val r = h2 * 60 + m2

    out.println(r - l - k)

    out.flush()
  }
}

Measured memory_bytes: 54676
#include <cstdio>
#include <cmath>

using namespace std;

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

struct Point {
    double x, y;
};

void print(Point p) {
    printf("%.8f %.8f\n", p.x, p.y);
}

void koch(int n, Point p1, Point p2) {
    if (n == 0) return;
    double th = M_PI * 60.0 / 180.0;
    Point s, t, u;
    s.x = (2.0 * p1.x + 1.0 * p2.x) / 3.0;
    s.y = (2.0 * p1.y + 1.0 * p2.y) / 3.0;
    t.x = (1.0 * p1.x + 2.0 * p2.x) / 3.0;
    t.y = (1.0 * p1.y + 2.0 * p2.y) / 3.0;
    // 三平方の定理 - 回転行列
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch(n - 1, p1, s);
    print(s);
    koch(n - 1, s, u);
    print(u);
    koch(n - 1, u, t);
    print(t);
    koch(n - 1, t, p2);
}

int main() {
    int n;
    scanf("%d", &n);
    Point p1 = {0, 0};
    Point p2 = {100, 0};
    print(p1);
    koch(n, p1, p2);
    print(p2);

    return 0;
}



Measured memory_bytes: 2740
n = int(input())
p = list(map(int, input().split()))

cnt = 0
for i in range(n-2):
	if (p[i]<p[i+1] and p[i+1]<p[i+2]) or (p[i]>p[i+1] and p[i+1]>p[i+2]):
		cnt += 1
	
print(cnt)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  string s;
  cin>>s;
  vi a(26,0);
  rep(i,s.size())a[s[i]-'a']++;
  rep(i,26)if(a[i]>=2){
    cout<<"no"<<endl;
    return 0;
  }
  cout<<"yes"<<endl;

}


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

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++) cin >> L[i];

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

    int count = 0;
    for (int i = 2; i < N; i++) {
        for (int j = 1; j < i; j++) {
            for (int k = 0; k < j; k++) {
                if (L[i] < L[j] + L[k]) count++;
            }
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
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; }
//#define int long long

void solve() {
    int a, b, c; cin >> a >> b >> c;
    if((a < c && c < b) || (b < c && c < a)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
ab = [tuple(map(lambda x:int(x)-1, input().split())) for _ in range(M)]
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1) # 木の高さ
        self.n = [1] * (n+1)    # グループメンバー数
        
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    
    def find_n(self, x):
        return self.n[self.find(x)]
    
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.n[y] = self.n[x] + self.n[y]
        else:
            self.par[y] = x
            self.n[x] = self.n[x] + self.n[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    
    def is_same(self, x, y):
        return self.find(x) == self.find(y) 
def main():
    uf = UnionFind(N)
    p = N * (N - 1) // 2
    ans = [p]
    for x, y in reversed(ab):
        px = uf.find(x)
        py = uf.find(y)
        if px != py:
            p -= uf.find_n(px) * uf.find_n(py)
            uf.unite(px, py)
        ans.append(p)
 
    for a in reversed(ans[:-1]):
        print(a)
 
 
main()


Measured memory_bytes: 26616
N = int(input())
S = input()

seg = [0]*(2*N-1)

def update(k, x):
    k += N-1
    seg[k] = 2**x
    while k:
        k = (k-1)//2
        seg[k] = seg[2*k+1] | seg[2*k+2]
        
def query(p, q):
    p += N-1
    q += N-2
    res = 0
    while q-p > 1:
        if p&1 == 0:
            res = res | seg[p]
        if q&1 == 1:
            res = res | seg[q]
            q -= 1
        p //= 2
        q = (q-1)//2
    if p == q:
        res |= seg[q]
    else:
        res |= seg[p] | seg[q]
    return bin(res).count("1")

def f(s):
    return ord(s) - ord("a") + 1

for i in range(N):
    update(i, f(S[i]))
    
Q = int(input())
for _ in range(Q):
    a,b,c = map(str, input().split())
    if a == "1":
        update(int(b)-1, f(c))
    else:
        print(query(int(b)-1, int(c)))

Measured memory_bytes: 73928
#include<iostream>
using namespace std;
int m,n;
int main()
{
	cin>>m>>n;
    for(int i=0;i<=m;i++)
	{
		for(int j=0;i+j<=m;j++)
		{
			for(int k=0;k<=m,i+j+k<=m;k++)
			{
				if(i+j+k==m&&i*1000+j*5000+k*10000==n)
				{
					cout<<k<<" "<<j<<" "<<i<<endl;
					return 0;   
				}
			}
		}
	}
    cout<<"-1 -1 -1\n";
    return 0;
}

Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
#define MOD (1e9+7)
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")



/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main() { 
  int n;cin>>n;
  int a[n];
  for(int i = 0; n > i; i++){
    cin>>a[i];
  }
  int nw = 1;
  for(int i = 0; n > i; i++){
    if(a[i] == nw){
      nw++;
    }
  }
  cout << ((nw-1)?n-(nw-1):-1) << endl;
}

Measured memory_bytes: 1024
// AOJ 2013 "大崎" (ICPC模擬国内予選 2007 Problem B)
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        sc.useDelimiter("\\r\\n|\\n|:| ");
        
        while (true) {
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }
            
            int[] departure = new int[86400];
            for (int i = 0; i < n; i++) {
                int dh = sc.nextInt();
                int dm = sc.nextInt();
                int ds = sc.nextInt();
                departure[dh*3600+dm*60+ds]++;
                
                int ah = sc.nextInt();
                int am = sc.nextInt();
                int as = sc.nextInt();
                departure[ah*3600+am*60+as]--;
            }
            
            int max = 0;
            int tmp = 0;
            for (int i = 0; i < departure.length; i++) {
                tmp += departure[i];
                max = Math.max(max, tmp);
            }
            System.out.println(max);
        }
    }
}

Measured memory_bytes: 148456
#include "bits/stdc++.h"
using namespace std;

int main() {
  int x,y;
  cin>>x>>y;
  vector<int>gro1={1,3,5,7,8,10,12};
  vector<int>gro2={4,6,9,11};
  int X=0;
  int Y=0;
  for(int i=0;i<7;i++) {
    if(gro1.at(i)==x) {
      X++;
    }
    else if(gro1.at(i)==y) {
      Y++;
    }
  }
  for(int i=0;i<4;i++) {
    if(gro2.at(i)==x) {
      X+=2;
    }
    else if(gro2.at(i)==y) {
      Y+=2;
    }
  }
  if(x==2) {
    X+=3;
  }
  else if(y==2) {
    Y+=3;
  }
  if(X==Y) {
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    rep(i, n - 1){
        if(a[i] + a[i + 1] > x){
            if(a[i] <= x){
                int diff = a[i] - x + a[i + 1];
                ans += diff;
                a[i + 1] -= diff;
            }else{
                ans += a[i + 1];
                a[i + 1] = 0;
                ans += a[i] - x;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
S = int(input())
lst = []
while S > 0:
    lst.append(S%10)
    S //= 10 # 必須
while(len(lst) <= 4):
  lst.append(0)
  
if lst[0] == lst[1] or lst[1] == lst[2] or lst[2] == lst[3]:
  print("Bad")
else:
  print("Good")
  


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

typedef long long LL;
const double eps = 1e-8;



int main()
{
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	LL ans = 1e18;
	
	for (int i = 0; i <= max(x, y); ++i)
	{
		LL tmp = 2LL * i * c + 1LL * max(0, x - i) * a + 1LL * max(0, y - i) * b;
		ans = min(ans, tmp);
	}
	cout << ans << endl;
		
	return 0;
}

Measured memory_bytes: 256
from copy import deepcopy

d=int(input())
c=list(map(int,input().split())) #scoreを減らす
s=[] #scoreを増やす
for i in range(d):
    t=list(map(int,input().split()))
    s.append(t)
last=[0]*26 #それぞれのコンテストが最後に行われたのは何日目か

for i in range(1,d): #364日、1日目ならi=1
    temp_best=-100000000
    for j in range(26): #それぞれの日において、26個のコンテストを順番にピックアップ
        temp=s[i-1][j]
        for k in range(26): #ピックアップされていないコンテストは、スコアを減らす
            if j!=k:
                temp-=(c[k]*(i-last[k]))
        temp_last=deepcopy(last)
        temp_last[j]=i
        for k in range(26):
            temp+=s[i][k]
            for l in range(26):
                if k!=l:
                    temp-=(c[l]*(i+1-temp_last[l]))
        if temp>temp_best:
            temp_best=temp
            rem=j
    print(rem+1)
    last[rem]=i
    
temp_best=-100000000 #365日目は、次の日のことは考えなくてよい
for j in range(26): #26個のコンテストを順番にピックアップ
    temp=s[i-1][j]
    for k in range(26): #ピックアップされていないコンテストは、スコアを減らす
        if j!=k:
            temp-=(c[k]*(i-last[k]))
    if temp>temp_best:
        temp_best=temp
        rem=j
print(rem+1) #AtCoder運営お疲れ様です

Measured memory_bytes: 71672