akhauriyash/Code-Regression huggingface dataset:
li = list(map(int, input().split()))
count5 = 0
count7 = 0
for i in li:
    if i == 5:
        count5 += 1
    elif i == 7:
        count7 += 1
if count5 == 2 and count7 == 1:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <unordered_set>
#include <cmath>
#define endl '\n'
#define ll long long
#define mod 1000000007

using namespace std;

int main(void)
{
	cin.tie(NULL); ios_base::sync_with_stdio(false);
	deque<int> data;
	int n, input; cin >> n;
	bool flag = true;

	for (int i = 0; i < n; i++)
	{
		cin >> input;
		if (flag)
		{
			data.push_back(input);
			flag = false;
		}
		else
		{
			data.push_front(input);
			flag = true;
		}
	}
	if (flag)
	{
		while (!data.empty())
		{
			cout << data.front() << " ";
			data.pop_front();
		}
	}
	else
	{
		while (!data.empty())
		{
			cout << data.back() << " ";
			data.pop_back();
		}
	}

	return 0;
}

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

#define mp make_pair
#define pb push_back

using namespace std;

const int md = 1e9 + 7;

int m, n;
int x[111111], p[3];

int main(){
//	freopen("input.inp", "r", stdin);
	scanf("%d%d",&n,&m);
	for(int q = 1; q <= 2; ++q){
		if (q == 2) n = m;
		long long tmp = 0, al = 0;
		for(int i = 1; i <= n; ++i){
			scanf("%d",&x[i]);
			tmp += x[i] - x[1];
			tmp %= md;
		}
		for(int i = 1; i < n; ++i){
			p[q] += tmp;
			p[q] %= md;
			tmp -= 1ll * (n - i) * (x[i + 1] - x[i]) % md;
			tmp += md;
			tmp %= md;
		}
	}
	printf("%lld", 1ll * p[1] * p[2] % md);
	return 0;
}

Measured memory_bytes: 640
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
  int n;
  cin >> n;
  ll sum = 0;
  for (ll i = 1; i <= n; i++)
  {
    if (i % 3 != 0 && i % 5 != 0)
      sum += i;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3644
locs = [int(input()) for _ in range(5)]
k = int(input())
flag = False

for i in range(5-1):
    for j in range(i+1,5):

        if locs[j] - locs[i] > k:
            print(':(')
            flag = True
            break
    
    if flag:
        break

if not flag:
    print('Yay!')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
using namespace std;

int main(){
    int n,m; cin >> n >> m;
    vector<P> en(n);
    rep(i,n) cin >> en[i].first >> en[i].second;
    sort(all(en));
    int now=0;
    ll ans=0;
    rep(i,n){
        if(en[i].second+now<m){
            now+=en[i].second;
            ans+=en[i].first*en[i].second;
        }
        else{
            ans+=(m-now)*en[i].first;
            cout << ans << endl;
            return 0;
        }
    }
return 0;
}


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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long Int;
typedef pair<Int, Int> P;

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

bool sosuu(int x){
	bool b = 1;
	if(x == 1) b = 0;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			b = 0;
			break;
		}
	}
	return b;
}

int a, b, x;

int main(){
	cin >> a >> b >> x;
	
	if(x < a || x > a + b) cout << "NO" << endl;
	else cout << "YES" << endl;
	
	return 0;
}

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

const int len = 200000;
int n, f;
int t[len];

int main(){
    cin >> n >> f;
    for(int i = 0;i < n;i++)
        cin >> t[i];
    int l = 0;
    int r = 0;
    long long ans = 0;
    l = t[0];
    for(int i = 0;i < n;i++){
        //cout << t[i] << ' ' << t[i] + f << endl;
        r = max(r, t[i] + f);
        ans += r - max(l, t[i]);
        l = t[i] + f;
    }
    cout << ans;
}

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

int main(){
    int a,b,c,d;
    bool flg = true;
    cin >> a >> b >> c >> d;

    while(flg){
        c = c - b;
        if (c<=0){
            cout << "Yes";
            flg = false;
            continue;
        }
        a = a - d;
        if (a<=0){
            cout << "No";
            flg = false;
            continue;
        }
    }
    return 0;
}

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

int main(){
	int n;
	cin>>n;
	string str[n];
	for(int i=0;i<n;i++){
		cin>>str[i];
	}
	int a=0,b=0,c=0,d=0;
	for(int i=0;i<n;i++){
		if(str[i]=="AC")
		   a++;
		   if(str[i]=="WA")
		   b++;
		   if(str[i]=="TLE")
		   c++;
		   if(str[i]=="RE")
		   d++;
	}
	cout<<"AC"<<" x "<<a<<endl;
		cout<<"WA"<<" x "<<b<<endl;
			cout<<"TLE"<<" x "<<c<<endl;
				cout<<"RE"<<" x "<<d<<endl;
	
	
	return 0;
}

Measured memory_bytes: 6748
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

long long battle(long long H){
  if(H==1){return 1;}else{return 1+2*battle(H/2);}
}


int main() {
  long long H;
  cin>>H;
  cout<<battle(H)<<endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()
using namespace std;
using P = pair<int, int>;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	string s;

	cin >> s;
	if (s == "ABC")
		cout << "ARC" << '\n';
	else
	{
		cout << "ABC" << '\n';
	}


	return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int t = a[n - 1];
		int max = 0, cnt = 0;
		for (int i = n - 2; i >= 0; i--) {
			if (t <= a[i]) {
				cnt++;
				max = Math.max(max, cnt);
			} else {
				cnt = 0;
			}
			t = a[i];
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 48772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[20002];
ll s[20002];
int main() {
	ll n,m;
	cin>>n>>m;
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	ll ans=INF;
	for(ll i=0;i<n;i++){
		ll sum=i*m;
		for(ll j=0;j<n;j++){
			ll now=j+i;
			if(now>=n){
				now-=n;
			}
			if(s[j]==0){
				s[j]=a[now];
			}
			else if(s[j]>a[now]){
				s[j]=a[now];
			}
			sum+=s[j];
		}
		ans=min(sum,ans);
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
// ABC157 B

#include <iostream>
#include <vector>

using namespace std;

int main(){
    vector<vector<int>> a(3, vector<int>(3, 0));
    vector<vector<bool>> bingo(3, vector<bool>(3, false));
    for(int i=0; i<3; i++){
        cin >> a.at(i).at(0) >> a.at(i).at(1) >> a.at(i).at(2);
    }

    int n, tmp;
    cin >> n;

    vector<int> b;
    for(int i=0; i<n; i++){
        cin >> tmp;
        for(int x=0; x<3; x++){
            for(int y=0; y<3; y++){
                if(a.at(x).at(y) == tmp){
                    bingo.at(x).at(y) = true;
                }
            }
        }
    }

    for(int i=0; i<3; i++){
        if(bingo.at(i).at(0) && bingo.at(i).at(1) && bingo.at(i).at(2)){
            cout << "Yes" << endl;
            return 0;
        }
    }

    for(int i=0; i<3; i++){
        if(bingo.at(0).at(i) && bingo.at(1).at(i) && bingo.at(2).at(i)){
            cout << "Yes" << endl;
            return 0;
        }
    }

    if(bingo.at(0).at(0) && bingo.at(1).at(1) && bingo.at(2).at(2)){
        cout << "Yes" << endl;
        return 0;
    }

    if(bingo.at(0).at(2) && bingo.at(1).at(1) && bingo.at(2).at(0)){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;

    return 0;
}

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

int main()
{
    int n,k; ll sum=0,sum1=0,maxi=0;
    cin>>n>>k;
    ll a[k+1];
    for(int i=0;i<k;i++)
    {
        cin>>a[i];
        if(i!=0)
            maxi=max(maxi,(abs(a[i]-a[i-1])));
    }
    sum=n-a[k-1];
    sum+=a[0];
    maxi=max(maxi,sum);
    cout<<n-maxi<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	 cin>>arr[i];
	sort(arr,arr+n);
	int count = 0;
	vector<int > brr;
	for(int i=0;i<1000002;i++)
	 brr.push_back(0);
	brr[0]=1; 
	for(int i=0;i<n;i++){
		
		if(brr[arr[i]]==1000000){
		   count--;
		   brr[arr[i]]=1;
		}
		if(brr[arr[i]]==0){
			brr[arr[i]]=1000000;
			count++;
			int t = arr[i]*2;
			//int t1 = arr[i];
			for(int k = t;k<=1000000;k+=arr[i]){
				brr[k]=1;
			}
		}
	}
	cout<<count<<endl;
	
}

Measured memory_bytes: 8248
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string.h>
#include <stdlib.h>
#include <limits>
#include <iomanip>
using namespace std;

int main(){

    string str_day[7] = {
        "SUN",
        "MON",
        "TUE",
        "WED",
        "THU",
        "FRI",
        "SAT"
    };
    string str_in;

    cin >> str_in;

    if( str_in == str_day[0] )      cout << 7 << endl;
    else if( str_in == str_day[1] ) cout << 6 << endl;
    else if( str_in == str_day[2] ) cout << 5 << endl;
    else if( str_in == str_day[3] ) cout << 4 << endl;
    else if( str_in == str_day[4] ) cout << 3 << endl;
    else if( str_in == str_day[5] ) cout << 2 << endl;
    else if( str_in == str_day[6] ) cout << 1 << endl;

}


Measured memory_bytes: 256
#!python3

iim = lambda: map(int, input().rstrip().split())
liim = lambda: list(map(int, input().rstrip().split()))

def resolve():
    N = int(input())
    S = []
    T = []
    for i in range(N):
        s, t = input().split()
        t = int(t)
        S.append(s)
        T.append(t)
    X = input()

    i = S.index(X)
    print(sum(T[i+1:]))






if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3064
import bisect
import sys
input = lambda: sys.stdin.readline().rstrip()

n=int(input())
s= list(input())
q=[]
qq=int(input())
for i in range(qq):
    q.append(list(input().split()))

# アルファベットごとに出現位置を記録
x=[[] for i in range(26)]
for i,j in enumerate(s):
    x[ord(j)-97].append(i)

# 終点対策
for i in range(26):
    x[i].append(5*10**5)


for i,j,k in q:
    if int(i)==1:
        if s[int(j)-1]!=k:
            v=s[int(j)-1]
            s[int(j)-1]=k
            # 変更前の要素を削除
            index=bisect.bisect_right(x[ord(v)-97], int(j)-1) - 1
            x[ord(v)-97].pop(index)
            # 変更後の要素を加える
            bisect.insort_right(x[ord(k)-97],int(j)-1)
    else:
        cnt=0
        j=int(j)-1
        k=int(k)-1
        for l in range(26):
            index=bisect.bisect_left(x[l],j)
            if x[l][index]<=k:
                cnt+=1


        print(cnt)

Measured memory_bytes: 97920
x,k,d=map(int,input().split())
if abs(x)<=d:
	if k%2==0:
		kotae=abs(x)
	else:
		kotae=abs(abs(x)-d)
else:
	c=abs(x)//d
	if c>=k:
		kotae=abs(abs(x)-k*d)
	else:
		if (k-c)%2==0:
			kotae=abs(abs(x)-c*d)
		else:
			kotae=abs(abs(abs(x)-c*d)-d)
print(kotae)

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
#define rg register
#define ll long long 
#define maxn 230044
inline ll read()
{
    ll x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            f=-1;
        }
        c=getchar();
    } 
    while(c<='9'&&c>='0')
    {
        x=(x<<1)+(x<<3)+(c^48);
        c=getchar();
    }
    return x*f;
}
ll n;
char a[maxn][11];
map <string,int> vis;
ll ans;
int main()
{
	n=read();
	for(rg int i=1;i<=n;++i) cin>>a[i];
	for(rg int  i=1;i<=n;++i)
	{
		sort(a[i],a[i]+10);
		ans+=vis[a[i]]++;
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 12288
sub f{my$d+=pop;
	$c[$_-1]||=$';
	$d[$_]=$d,map f($d-1),@$_ if$d>$d[$_]
}
<>=~$";
@c=(0)x$`;
map{push@$_,$_[--$|]for@_=<>=~/\d+/g}1..$';
<>;
$_*=/ .* /,f$&for reverse<>;
print"@c"


Measured memory_bytes: 117376
class Main
{
	public static void main(String args[])
	{
		for (int i = 1; i < 10; i++)
			for (int j = 1; j < 10; j++)
				System.out.println(Integer.toString(i) + "x" + Integer.toString(j) + "=" + Integer.toString(i*j));
	}
}

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

const int64_t MAX = 510000;
const int64_t MOD = 998244353;

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

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

// 二項係数計算
int64_t COM(int64_t n, int64_t k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    int64_t N,M,K;
    cin >> N >> M >> K;
    COMinit();
    
    vector<int64_t> POW(N+1);
    POW[0] = 1;
    for ( int64_t i = 1; i <= N; ++i){
        POW[i] = POW[i-1] * (M-1) % MOD;
    }
    
    int64_t ans = 0;
    for ( int64_t k = 0; k <= K; ++k){
        ans = ( ans + M * COM(N-1,k) % MOD * POW[N-1-k] ) % MOD;
    }
    
    if ( ans < 0 ) ans += MOD;
    cout << ans << endl;
    
    return 0;
}


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

using namespace std;

int main() {
	int n; cin >> n;
	vector<vector<int> > abc(3, vector<int>(n)), dp(n + 1, vector<int>(3));
	for (int i = 0; i < n; ++i) cin >> abc[0][i] >> abc[1][i] >> abc[2][i];
	dp[0][0] = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j < 3; ++j) {
			dp[i][j] = max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]) + abc[j][i - 1];
		}
	}
	cout << *max_element(dp[n].begin(), dp[n].end()) << endl;

	return 0;
}

Measured memory_bytes: 6904
#define _[301][301]
N,M,i,j,t,r,C _,D _;char S _;
main(v){
	for(scanf("%d%d ",&N,&M);gets(S+i++););
	for(;++t<M;r+=v){
		for(i=j=1;j>N?j=i++<N:1;++j)v=D[i][j]=fmin(D[i-1][j],D[i][j-1])+(C[i][j]=C[i-1][j-1]+(S[i-1][t-1]==S[j-1][t]));
	}
	printf("%d\n",r);
}


Measured memory_bytes: 1024
use v5.18;
use warnings;
use List::Util qw( sum0 min max );
sub read_line { chomp(my $s = <>); $s }
sub splited_read_line { split / /, read_line }

use constant INF => 10 ** 9;

my ($N, $A, $B, $C) = splited_read_line;
my @l = map { read_line } 0 .. $N - 1;

sub dfs {
  my ($depth, $str) = @_;
  return $str if $depth == $N;
  map { dfs($depth + 1, $str . $_) } qw/ A B C /, ' ';
}

my $ans = min map {
  my %ts;
  my @r = split //, $_;
  my $concat_cnt = 0;
  for my $i (0 .. $#r) {
    for my $t (qw/ A B C /) {
      if ( $r[$i] eq $t ) {
        $concat_cnt++ if exists $ts{$t};
        $ts{$t} += $l[$i];
      }
    }
  }
  if ( grep { !exists $ts{$_} } qw/ A B C / ) {
    INF;
  }
  else {
    my $mp = 0;
    $mp += $concat_cnt * 10;
    $mp += abs($A - $ts{A});
    $mp += abs($B - $ts{B});
    $mp += abs($C - $ts{C});
    $mp;
  }
} dfs(0, '');

say $ans;


Measured memory_bytes: 8832
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int getsqrt(_int64 x)
{
  int left,right,mid;
  left=0;right=1100000000;
  while (right-left>1)
  {
    mid=(left+right)/2;
    if ((_int64)mid*mid>=x) right=mid;
    else left=mid;
  }
  return left;
}

int main()
{
  int i,j,q,l,a,b;
  _int64 tmp,p,tot;
  scanf("%d",&q);
  for (l=0;l<q;l++)
  {
    scanf("%d%d",&a,&b);
    p=(_int64)a*b;
    tmp=getsqrt(p);
    if (a==b) tot=(a-1)+(a-1);
    else
    if (tmp*(tmp+1)<p)
    {
      tot=tmp*2;
      tot--;
    }
    else
    {
      tot=(tmp-1)*2+1;
      tot--;
    }
    printf("%lld\n",tot);
  }
}

Measured memory_bytes: 256
import collections

N = int(input())

words = []

for i in range(N):
    words.append(input())

ans = 'Yes'
c = collections.Counter(words)    

if c.most_common()[0][1] != 1:
    ans = 'No'
else:
    for i in range(N-1):
        tail = words[i][-1]
        head = words[i+1][0]
        if tail != head:
            ans = 'No'
            break
            
print(ans) 



Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  string s;
  cin >> s;
  s[5] = ' ';
  s[13] = ' ';
  cout << s << endl;
}

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

int main () {
  int n;
  int ans =0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a , b;
    cin >> a >> b;
    ans += (b - a + 1);
  }
cout << ans << endl;
}


Measured memory_bytes: 3520
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int main(){
    int N,K;
    cin >> N >> K;
    ll num = 0;
    for(int b = K+1; b <= N; b++){
        int q = N/b;
        num += q*(b-K);
        num += max(0, (N%b - K + 1));
    }
    //num -= (N-K);
    if(K == 0) num -= N;

    cout << num << endl;
    return 0;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int a, b, c;

int main(void) {
  // Here your code !
  scanf("%d %d %d", &a, &b, &c);

  if ((a <= c && c <= b) || (b <= c && c <= a)) {
    printf("Yes\n");
  }
  else {
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define irep(i, n) for(int i = n-1; i >= (int)0; i--)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;


int main(int argc, char const *argv[]) {
  ll t, n;std::cin >> n;
  vll num(9, 0);
  re(i, n){
    std::cin >> t;
    if(t>=3200) num[8]++;
    else num[t/400]++;
  }
  ll ans = 0;
  re(i, 8) if(num[i]>0)ans++;
  std::cout  << max((ll)1, ans) << " "<< ans + num[8] << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define pb push_back
typedef long long ll;
typedef long double ld;

using namespace std;

signed main(){
    #define int long long
    int n , m ;
    cin >> n >> m;
    vector < int > a(n);
    for(auto &i : a)cin>>i;
    vector < pair < int , int > > b;
    for(int i = 0 ; i < m;  ++i){
        int a , c;
        cin >> a >> c;
        b.pb({c , a});
    }
    sort(rall(b));
    int x = 0;
    sort(all(a));
    for(int i = 0 ; i < n;  ++i){
        while(x < (int)b.size() && b[x].se==0){
            ++x;
        }
        if(x < m && b[x].fi > a[i])
        a[i] = b[x].fi , b[x].se--;
    }
    int sum = 0;
    for(auto &i : a) sum += i;
    cout << sum;
    return 0;
}


Measured memory_bytes: 3188
nkq=list(map(int,input().split()))
a = [int(input()) for _ in range(nkq[2])]
point=[nkq[1]-nkq[2]]*nkq[0]
for i in range(nkq[2]):
    point[a[0]-1]+=1
    del a[0]
for j in range(nkq[0]):
    if point[j]>0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 7852
import math
r,g,b,n = map(int, input().split())
count = 0
r,g,b = sorted((r,g,b), reverse=True)
for x in range( math.ceil((n / r)) + 1):
    for y in range( math.ceil( (n - (r*x) ) / g) + 1):
        if (n - (r*x) - (y*g)) < 0:
            break
        if ((n - (r*x) - (g * y)) % b) == 0:
            count = count + 1
print(count)

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

int main() {
  int n, m;
  while (true) {
    cin >> n >> m;
    if (n == 0 && m == 0) {
      break;
    }
    int place[n], dice[m];
    int i;
    for (i = 0; i < n; i++) {
      cin >> place[i];
    }
    for (i = 0; i < m; i++) {
      cin >> dice[i];
    }
    int now_prace = 0;
    for (i = 0; i <= m; i++) {
      if (now_prace >= n - 1) {
        cout << i << endl;

        break;
      }
      now_prace += dice[i];
      if (now_prace < n) {
        now_prace += place[now_prace];
      }
    }
  }
  return 0;
}



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

const int N=1e5 +3;
long long a[N], b[N];

bool cmp(long long s, long long f){
    return(s>f);
}

int main(){

    int n;
    long long h;
    scanf("%d%lld", &n, &h);
    long long mx=0LL, sum=0LL;
    int cnt=0;
    for(int i=0; i<n; ++i){
        scanf("%lld%lld", &a[i], &b[i]);
        mx=max(mx, a[i]);
    }

    sort(b, b+n, cmp);

    for(int i=0; i<n; ++i){
        if(b[i]>=mx){
            sum+=b[i];
            ++cnt;
        }
        else
            break;

        if(sum>=h){
            break;
        }
    }

    if(sum>=h)
        printf("%d", cnt);
    else{
        long long rem=h-sum;
        long long ans=((rem-1)/mx)+1;
        cnt+=(int)ans;

        printf("%d", cnt);
    }


    return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast,fast-math,unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) (int)v.size()
#define fi first
#define se second
#define sqrt(x) sqrt(abs(x))
#define sqr(x) ((x) * (x))
#define unq(x) (x.resize(unique(all(x)) - x.begin()))
#define fill(x, y) memset(x, y, sizeof(x))
#define mp make_pair
#define pb emplace_back
#define popcnt __builtin_popcount
#define ctz __builtin_ctz

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using ll = long long;
using ld = long double;

template <class T> using indexed_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

template <class T, class U>
istream& operator >> (istream &in, pair <T, U> &p) {
    in >> p.first >> p.second;
    return in;
}

template <class T, class U>
ostream& operator << (ostream &out, pair <T, U> &p) {
    out << p.first << ' ' << p.second;
    return out;
}

template <class T>
istream& operator >> (istream &in, vector <T> &a) {
    for (T &i: a) in >> i;
    return in;
}

template <class T>
ostream& operator << (ostream &out, vector <T> &a) {
    for (T i: a) out << i << ' ';
    out << '\n';
    return out;
}

template <class T>
ostream& operator << (ostream &out, set <T> &a) {
    for (T i: a) out << i << ' ';
    out << '\n';
    return out;
}

void fastIO() {
    ios_base:: sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
}

ll n, s;

signed main() {
    fastIO();

    cin >> n;
    for (int i = 1; i <= n; ++i) {
        if (i % 5 && i % 3) s += i;
    }

    cout << s;

    return 0;
}

/// ЗАПУСКАЕМ ГУСЯ:
/*
     ▄▀▀▀▄
▄███▀░◐░░░▌
    ▌░░░░░▐
    ▐░░░░░▐
    ▌░░░░░▐▄▄
    ▌░░░░▄▀▒▒▀▀▀▀▄
   ▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
   ▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
    ▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
      ▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
           ▌▌░▌▌
           ▌▌░▌▌
         ▄▄▌▌▄▌▌        */


Measured memory_bytes: 3656
n, x , y = map(int, input().split())

import heapq
from collections import defaultdict
cost = defaultdict(list)
for i in range(1, n):
    cost[i-1].append((i, 1))
    cost[i].append((i - 1, 1))
cost[x-1].append((y - 1, 1))
cost[y-1].append((x - 1, 1))

dists = []

for start in range(n):
    d = [float('inf')] * n # 最短距離
    d[start] = 0

    q = [(d[start], start)] # min-heap, (距離, 頂点)
    prev = [None] * n # 経路をたどるときに使う
    heapq.heapify(q)
    while q:
        du, u = heapq.heappop(q) # 最短距離とその頂点
        if d[u] < du:
            continue
        for v, weight in cost[u]:
            if du + weight < d[v]:
                d[v] = du + weight
                prev[v] = u
                heapq.heappush(q, (d[v], v))

    dists.append(d)



from collections import Counter
c = Counter()
for i in range(n):
    for j in range(i+1, n):
        c[dists[i][j]] += 1

for k in range(1, n):
    print(c[k])


Measured memory_bytes: 130696
#itertoolsを使うversion
import itertools
S = input()
N = len(S)
res = 0
for ptr in itertools.product([0,1], repeat=(N-1)):
  formula = ""
  for i in range(N-1):
    if ptr[i] == 1:
      formula += S[i]
      formula += "+"
    else:
      formula += S[i]
  formula += S[N-1]    
  res += eval(formula)
print(res)

Measured memory_bytes: 73684
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    int n,k;
    cin >> n >> k;
    if(k == 1){
        cout << 0 << endl;
        return 0;
    }
    cout << n-k << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100005
#define db(x) cout<<#x<<"="<<x<<endl;
using namespace std;
int n,a[N],t[N];
int main() {
	scanf("%d",&n);
	for(int i=1; i<=n; i++)scanf("%d",&a[i]),t[a[i]]++;
	if(n&1)puts("0");
	else {
		int res=0;
		for(int i=1; i<N; i++) {
			t[i]+=t[i-1];
			if(t[i]==(n>>1))res++;
		}
		printf("%d\n",res);	
	}
	return 0;
}


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

int main()
{
ll n ;
string  s ;
cin >> n >> s ;
string f=s.substr(0,n);
string b=s.substr(n,n);
reverse(b.begin(), b.end());
map<pair<string,string>, long long > ma;
rep(i,1LL<<n){
  string re="",bl="";
  rep(j,n){
    if(i>>j&1LL)re+=f[j];
    else bl+=f[j];
  }
  pair<string,string> p={re,bl};
  ma[p]++;
}
rep(i,1LL<<n){
  string re="",bl="";
  rep(j,n){
    if(i>>j&1LL)re+=b[j];
    else bl+=b[j];
  }
  pair<string,string> p={re,bl};
  ans+=ma[p];
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 91904
#include<bits/stdc++.h>
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define ss st.st
#define sn st.nd 
#define mod 1000000007
/****************************/
using namespace std;
int n,m;
ll a,b,c,d;
int main()
{
	cin>>a>>b>>c>>d;
	ll ans=max(a*c,b*d);
	ans=max(ans,a*d);
	ans=max(ans,b*c);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3632
X, Y = map(int, input().split())

p = [300000, 200000, 100000]
if X < 4:
    ans = p[X - 1]
else:
    ans = 0
if Y < 4:
    ans += p[Y - 1]
if X == 1 and Y == 1:
    ans += 400000

print(ans)

Measured memory_bytes: 3060
def getter(i):
  res=0
  while True:
    res+=i%10
    i//=10
    if i==0:
      break
  return res
n=int(input())
digit=0
hoge=n
while True:
  hoge//=10
  if hoge==0:
  	break
  digit+=1
a=10**digit
if n-a>0:
  res=1+getter(n-a)
  print(res)
  exit()
else:
  print("10")



Measured memory_bytes: 38256
#include <cstdio>
#include <vector> 

typedef long long LL;
const int MN = 100005;

int N, M; LL Ans;
std::vector<int> G[MN], iG[MN];

int ok, col[MN], a[3], cv, ce;
void DFS(int u, int c) {
	++a[col[u] = c], ++cv;
	ce += G[u].size();
	for (int v : G[u])
		if (!~col[v]) DFS(v, (c + 1) % 3);
		else if (col[v] != (c + 1) % 3) ok = 0;
	for (int v : iG[u])
		if (!~col[v]) DFS(v, (c + 2) % 3);
		else if (col[v] != (c + 2) % 3) ok = 0;
}

int main() {
	scanf("%d%d", &N, &M);
	while (M--) {
		int x, y;
		scanf("%d%d", &x, &y);
		G[x].push_back(y);
		iG[y].push_back(x);
	}
	for (int i = 1; i <= N; ++i) col[i] = -1;
	for (int i = 1; i <= N; ++i) if (!~col[i]) {
		ok = 1, a[0] = a[1] = a[2] = cv = ce = 0;
		DFS(i, 0);
		if (!ok) Ans += (LL)cv * cv;
		else if (a[0] && a[1] && a[2]) Ans += (LL)a[0] * a[1] + (LL)a[1] * a[2] + (LL)a[2] * a[0];
		else Ans += ce;
	}
	printf("%lld\n", Ans);
	return 0;
}

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

using namespace std;
using i64 = long long int;

int main() {
    i64 n, l;
    cin >> n >> l;
    vector<i64> a(n);
    for(int i = 0; i < n; ++i) cin >> a[i];
    i64 idx = -1;
    for (int i = 0; i < n - 1; ++i) {
        if (a[i] + a[i + 1] >= l) {
            idx = i;
        }
    }
    if(idx == -1) cout << "Impossible" << endl;
    else {
        cout << "Possible" << endl;
        for (int i = 0; i < idx; ++i) cout << i + 1 << endl;
        for (int i = n - 1; i > idx + 1; --i) cout << i << endl;
        cout << idx + 1 << endl;
    }
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int n, k; cin >> n >> k;
    vector<int> x(n);
    for(int i = 0; i < n; i++) cin >> x[i];

    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        int tmp = min(x[i], abs(x[i] - k));
        ans += 2 * tmp;
    }
    cout << ans << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 256
k,x=map(int,input().split())
if x-k+1<-1000000:
  ans1=-1000000
else:
  ans1=x-k+1
if x+k-1>1000000:
  ans2=1000000
else:
  ans2=x+k-1
while ans1<ans2:
  print(ans1,end=' ')
  ans1+=1
print(ans2)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int maxCnt = 0;
        int currentCnt = 0;
        for (int i = 0; i < s.length(); i++) {
            if(s.charAt(i) == 'R') {
                currentCnt++;
            } else {
                currentCnt = 0;
            }
            maxCnt = Math.max(maxCnt, currentCnt);
        }

        System.out.println(maxCnt);
    }
}

Measured memory_bytes: 35616
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INF = 1<<29;
const int MOD = 1000000007;
 
void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

ll num[30];
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N; cin >> N;
    vector<ll> a(N*3);
    rep(i,N*3) cin >> a[i];

    // 左から前処理
    vector<ll> S(N*2+1, 0);
    priority_queue<ll, vector<ll>, greater<ll> > que1;
    rep(i,N){
      S[i+1] = S[i] + a[i];
      que1.push(a[i]);
    }
    REP(i, N, N*2){
      ll mi = que1.top();
      if(a[i] > mi){
        S[i+1] = S[i] - mi + a[i];
        que1.pop();
        que1.push(a[i]);
      }
      else S[i+1] = S[i];
    }

    // 右から前処理
    vector<ll> T(N*2+1, 0);
    priority_queue<ll> que2;
    rep(i,N){
      T[i+1] = T[i] + a[N * 3 - 1 - i];
      que2.push(a[N * 3 - 1 - i]);
    }
    REP(i,N,N*2){
      ll ma = que2.top();
      if(a[N * 3 - 1 - i] < ma){
        T[i+1] = T[i] - ma + a[N*3-1 - i];
        que2.pop();
        que2.push(a[N * 3 - 1 - i]);
      }
      else T[i+1] = T[i];
    }

    ll ans = -(1LL << 60);
    REP(i,N,N*2+1){
      ans = max(ans, S[i] - T[N*3-i]);
    }
    cout << ans << endl;

}

Measured memory_bytes: 8052
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    S = s_input()

    for i,s in enumerate(S):
        if i % 2 == 1:
            continue
        print(s,end='')

    print()

if __name__ == '__main__':
    main()


Measured memory_bytes: 76788
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        String arg = br.readLine();
        String[] inputArray = arg.split(" ");
        int[] inputIntArray = new int[inputArray.length];
 
        for (int count = 0; count < inputIntArray.length; count++) {
            inputIntArray[count] = Integer.parseInt(inputArray[count]);
        }
        int x = inputIntArray[0];
        int y = inputIntArray[1];
 
        int menseki = x * y;
        int nagasa = (x + y) * 2;
 
        System.out.println(menseki + " " + nagasa);
    }
}

Measured memory_bytes: 16896
import java.util.Arrays;
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        long mod = 1000000007;

        int n = stdIn.nextInt();
        
        int x = -1;
        int y = -1;
        int z = -1;
        
        int a, candidate;
        long ans = 1;
        for(int i=0; i<n; i++){
            a = stdIn.nextInt();
            candidate = 0;

            if(x == a-1){
                candidate++;
            }
            if(y == a-1){
                candidate++;
            }
            if(z == a-1){
                candidate++;
            }

            if(x == a-1){
                x++;
            }else if(y == a-1){
                y++;
            }else if(z == a-1){
                z++;
            }

            ans = ans * candidate % mod;
        }

        int noStackedCounter = 0;
        if(x == -1){
            noStackedCounter++;
        }
        if(y == -1){
            noStackedCounter++;
        }
        if(z == -1){
            noStackedCounter++;
        }

        System.out.println(ans);
    }
}

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

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

  int ans = pow(10, 9);
  for (int i = 0; i < N; i++) {
    vector<int> head(i + 1);
    vector<int> tail(N - i);
    copy(v.begin(), v.begin() + i, head.begin());
    copy(v.begin() + i, v.end(), tail.begin());
    int head_sum = accumulate(head.begin(), head.end(), 0);
    int tail_sum = accumulate(tail.begin(), tail.end(), 0);
    ans = min(abs(head_sum - tail_sum), ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n, m, x, y = map(int, input().split())
xx = tuple(map(int, input().split())) + (x,)
yy = tuple(map(int, input().split())) + (y,)

maxx = max(xx)
miny = min(yy)

if maxx >= miny:
    print('War')
else:
    print('No War')


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

int main()
{
  string S;
  cin >> S;
  int s = stoi(S);
  int _12 = s/100;
  int _34 = s%100;
  if (0 == _12)
    cout << ((1 <= _34 && _34 <= 12) ? "YYMM" : "NA");
  else if (_12 <= 12)
    cout << ((1 <= _34 && _34 <= 12) ? "AMBIGUOUS" : "MMYY");
  else
    cout << ((1 <= _34 && _34 <= 12) ? "YYMM" : "NA");
  return 0;
}


Measured memory_bytes: 256
from collections import Counter
def solve():
    ans = 0
    N = int(input())
    A = list(map(int, input().split()))
    c = Counter(A)
    for i in range(1,10**5-1):
        cnt = 0
        if i-1 in c:
            cnt += c[i-1]
        if i in c:
            cnt += c[i]
        if i+1 in c:
            cnt += c[i+1]
        ans = max(ans,cnt)   
    return ans
print(solve())

Measured memory_bytes: 57452
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <typeinfo>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<pair<int,int>> ab(N);
  vector<pair<int,int>> cd(N);
  for(int i=0;i<N;i++){
    int a,b;
    cin >> a >> b;
    ab.at(i)=make_pair(a,b);
  }
  for(int i=0;i<N;i++){
    int c,d;
    cin >> c >> d;
    cd.at(i)=make_pair(c,d);
  }
  sort(cd.begin(),cd.end());

  int ans=0;
  for(int i=0;i<N;i++){
    int maab=-1;
    int maj=-1;
    for(int j=0;j<N;j++){
      if(ab.at(j).first < cd.at(i).first && ab.at(j).second < cd.at(i).second){
        if(maab<ab.at(j).second){
          maab=ab.at(j).second;
          maj=j;
        }
      }
    }
    if(maab!=-1){
      ans++;
      ab.at(maj).first=2*N;
      ab.at(maj).second=2*N;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
open System

let [| N; M |] = stdin.ReadLine().Split() |> Array.map int

let s = Array.zeroCreate<int []> M

for i in [ 0..M - 1 ] do
    s.[i] <- stdin.ReadLine().Split()
             |> Array.skip 1
             |> Array.map int

let p = stdin.ReadLine().Split() |> Array.map int

let mutable result = 0

for i in [ 0..pown 2 N - 1 ] do
    let c = Convert.ToString(i, 2).PadLeft(N, '0').ToCharArray()
    let mutable flag = true
    for j in [ 0..M - 1 ] do
        if flag then
            let mutable t = 0
            for k in [ 0..(s.[j] |> Array.length) - 1 ] do
                t <- t + int c.[s.[j].[k] - 1]
            if t % 2 <> p.[j] then flag <- false
    if flag then result <- result + 1

result |> stdout.WriteLine


Measured memory_bytes: 15572
#include <stdio.h>
#define ll long long int
#include <queue>
#include <vector>
#include <iostream>
#include <bits/stdc++.h>
#include <string.h>

using namespace std;

int main(){
string s;
cin>>s;
int to=s.size()/2;
int j,k,c;
c=0;
j=s.size()-1;
k=0;
while(k<j)
{
  if(s[k++]!=s[j--])
  c++;
}
cout<<c;

}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  vl A(3);
  cin >> A[0] >> A[1] >> A[2];
  if (A[0] + A[1] + A[2] >= 22)
    cout << "bust" << endl;
  else
    cout << "win" << endl;

  return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll S;
    cin >> S;
    ll cnt[2010];
    fillnum(cnt,1);
    cnt[1] = cnt[2] = 0;
    for (int i = 3; i <= S; i++) {
        for (int j = 3; j <= S-3; j++) {
            if(i+j <= S){
                cnt[i+j] += cnt[i];
                cnt[i+j] = cnt[i+j]%mod;
            }
        }
    }
    cout << cnt[S]%mod << endl;
}

Measured memory_bytes: 3624
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define p 1000000007
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define LONGLONG_MAX 10000000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int a,b;
	cin>>a>>b;
	if(a>=13)cout<<b;
	else if(a>5)cout<<b/2;
	else cout<<0;
    return 0;
}

Measured memory_bytes: 256