akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &m) { for (auto &e : m) os << e << endl; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ll n, k; cin >> n >> k;
  vector<VV> a(2, VV(k, V(k)));

  rep(i, n) {
    int x, y; cin >> x >> y;
    char c; cin >> c;
    x %= 2*k;
    y %= 2*k;
    int z = ((c == 'B') ? 0 : 1);

    if (x >= k) {
      x -= k;
      z ^= 1;
    }
    if (y >= k) {
      y -= k;
      z ^= 1;
    }
    ++a[z][x][y];
  }

  vector<VV> s0(2, VV(k+1, V(k+1)));
  vector<VV> s1(2, VV(k+1, V(k+1)));
  rep(z, 2) {
    rep(i, k) rep(j, k) s0[z][i+1][j+1] = s0[z][i+1][j] + a[z][i][j];
    rep(j, k) rep(i, k) s0[z][i+1][j+1] += s0[z][i][j+1];
    rep(i, k) drep(j, k) s1[z][i][j] = s1[z][i][j+1] + a[z][i][j];
    rep(j, k) drep(i, k) s1[z][i][j] += s1[z][i+1][j];
  }

  int all0 = s1[0][0][0];
  int all1 = s1[1][0][0];

  ll ans = 0;
  rep(i, k+1) rep(j, k+1) {
    ll x = s0[0][i][j] + s1[0][i][j] + all1 - s0[1][i][j] - s1[1][i][j];
    ll y = s0[1][i][j] + s1[1][i][j] + all0 - s0[0][i][j] - s1[0][i][j];
    chmax(ans, x);
    chmax(ans, y);
  } 

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 28032
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)

bool g[777][777];
int n,x[777],bc,wc;

bool dfs(int v, int c){
	int i;
	x[v] = c;
	if(c>0){
		++bc;
	}else{
		++wc;
	}
	for(i=0; i<n; ++i){
		if(!g[v][i]){
			continue;
		}
		if(x[i]==c){
			return false;
		}else if(x[i]==0 && (!dfs(i,-c))){
			return false;
		}
	}
	return true;
}

bool dp[777][777];

int main(void){
	int m,a,b,cnt,i,j,ans=INF;
	fill(g[0],g[777],true);
	fill(dp[0],dp[777],false);
	dp[0][0] = true;
	cin >> n >> m;
	for(i=0; i<n; ++i){
		g[i][i] = false;
	}
	for(i=0; i<m; ++i){
		cin >> a >> b; --a; --b;
		g[a][b] = false;
		g[b][a] = false;
	}
	for(i=0; i<n; ++i){
		if(x[i]){
			for(j=0; j<=n; ++j){
				dp[i+1][j] = dp[i][j];
			}
			continue;
		}
		bc = 0; wc = 0;
		if(!dfs(i,1)){
			cout << "-1" << endl;
			return 0;
		}
		for(j=bc; j<=n; ++j){
			if(dp[i][j-bc]){
				dp[i+1][j] = true;
			}
		}
		for(j=wc; j<=n; ++j){
			if(dp[i][j-wc]){
				dp[i+1][j] = true;
			}
		}
	}
	for(j=0; j<=n; ++j){
		if(dp[n][j]){
			ans = min(ans,(n*(n-1))/2 - j*(n-j));
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <string.h>
int main() {
    int val1,val2;
	char vetor[200000];
	scanf("%s",vetor);
	for(int x =0;x<strlen(vetor);++x){
	    if(vetor[x]=='A'){
	        val1 = x;
	        break;
	    }
	}
	for(int y=strlen(vetor)-1;;--y){
	    if(vetor[y]=='Z'){
	        val2= y;
	        break;
	    }
	}
	printf("%d",(val2-val1)+1);
	return 0;
}

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

# x, y がともに負の場合
if 0 > x and 0 > y:
    if y > x:  # yの方が大きい場合、そのままボタンを押すだけ, -20, -10
        print(abs(y-x))
        exit()
    else:  # xの方が大きい場合 -10 -20
        print(abs(x-y)+2)
        exit()

# xのみ負の場合
if 0 > x and y >= 0:  # -10, 5  この場合15, -10, 12この場合は4
    ans = min(abs(abs(y)-abs(x))+1, y-x)
    print(ans)
    exit()

# yのみ負の場合
if x >= 0 and 0 > y:  # わからん 9, -11, 2増やして反転, 11, -5  反転して6増やす
    print(abs(x-abs(y))+1)
    exit()

# x, yがともに正の場合
if x >= 0 and y >= 0:
    if x > y:  # 8, 5
        ans = x-y+2
        if y == 0:
            ans -= 1
        print(ans)
        exit()
    else:  # 5, 8
        print(y-x)


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

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	int rmin, pmax, r;
	cin>>n;
	cin>>rmin>>r;
	pmax =r-rmin;
	rmin=min(rmin, r);
	for(int i=2; i<n; i++) {
		cin>>r;
		pmax=max(pmax, r-rmin);
		rmin=min(rmin, r);
	}
	cout<<pmax<<'\n';
	return 0;
}



Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
//typedef
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
//define
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
 
int main(){
  int l,r,d;
  int count=0;
  cin >> l >> r >> d;

  for(int i=l; i<r+1; i++){
    if(i%d==0) count++;
  }
  cout << count << endl;
    return 0;
  }

Measured memory_bytes: 3592
N,X,M=map(int, input().split())

p=[0]*(M+2)
sum=[0]*(M+2)
p[X]=1
sum[1]=X
f=0
for i in range(2,N+1):
    X=(X**2)%M  
    if p[X]!=0:
        j=p[X]
        f=i
        break
    else:
        sum[i]=X+sum[i-1]
        p[X]+=i

if f==0:
    print(sum[N])
else:
    d,mod=divmod(N-j+1,i-j)
    print(d*(sum[i-1]-sum[j-1])+sum[j+mod-1])

Measured memory_bytes: 13876
#include <stdio.h>

int main(){

  int x,y,r;

  scanf("%d%d",&x,&y);

  if(x<y){
    r=x;
    x=y;
    y=r;
  }
  r=x%y;
  while(r!=0){
    x=y;
    y=r;
    r=x%y;
  }
  
  printf("%d\n",y);


  return 0;
}



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

int main(){
	int n;
	cin >> n;
	while(n != 0){
		int a[n];
		

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

		int maximum = -100000000;
		for(int i = 0; i < n; i++){
			int sum = 0;
			for(int j = i; j < n; j++){
				sum += a[j];
				maximum = max(maximum, sum);
			}
		}

		cout << maximum << endl;
		cin >> n;
	}

	return 0;
}

Measured memory_bytes: 1168
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=510;
struct data{int pos,w;}dt[N];
inline bool cmp(const data &a,const data &b){return a.pos<b.pos;}
int a[N*N];
int que[N],use[N];
int last[N],rk[N*N];
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&dt[i].pos);
		dt[i].w=i;a[dt[i].pos]=i;
	}
	sort(dt+1,dt+n+1,cmp);
	int sum=0,now=1;
	for(int i=1;i<=n;i++)
	{
		if(dt[i].pos-sum<dt[i].w)
		{
			printf("No\n");
			return 0;
		}
		for(int j=1;j<dt[i].w;j++)
		{
			while(a[now]) now++;
			a[now]=dt[i].w;
		}
		sum+=dt[i].w;
	}
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n-dt[i].w;j++)
	{
		while(a[now]) now++;
		a[now]=dt[i].w;
	}
	for(int i=1;i<=n*n;i++)
	{
		rk[i]=rk[last[a[i]]]+1;
		last[a[i]]=i;
	}
	for(int i=1;i<=n;i++)
	if(rk[dt[i].pos]!=dt[i].w)
	{
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	for(int i=1;i<=n*n;i++) printf("%d ",a[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=(j); i<=(k); i++)
#define FFOR(i, j, k) for(int i=(j); i<(k); i++)
#define DFOR(i, j, k) for(int i=(j); i>=(k); i--)
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'
#define pb push_back
#define mp make_pair
#define setbit(s, i) (s|=(1LL<<(i)))
#define bit(s, i) (((s)>>(i))&1LL)
#define mask(i) ((1LL<<(i)))
#define builtin_popcount __builtin_popcountll
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "D"
int n;
int m;
vector <pair <int, ll> > g[200001];
bool done[200001];
ll f[200001];
ll low, high;
void dfs(int u, ll p){
    if(done[u]){
        if(f[u]!=p){
            puts("No");
            exit(0);
        }
        return;
    }
    done[u]=1;
    f[u]=p;
    low=min(low, p);
    high=max(high, p);
    for(pair <int, ll> x: g[u]) dfs(x.first, p+x.second);
}
int main(){
    #ifdef Kanikou
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Kanikou
    read(n);
    read(m);
    {
        int l, r;
        ll d;
        FOR(i, 1, m){
            read(l);
            read(r);
            read(d);
            g[l].pb(mp(r, d));
            g[r].pb(mp(l, -d));
        }
    }
    FOR(i, 1, n) if(!done[i]){
        high=-1e18;
        low=1e18;
        dfs(i, 0);
        if(high-low>1000000001){
            puts("No");
            exit(0);
        }
    }
    puts("Yes");
}

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

using namespace std;


int main(){
    
    string S;
    cin >> S;
    if (S == "Sunny") {
        cout << "Cloudy" << endl;
    }else if(S == "Cloudy"){
        
        cout << "Rainy" << endl;
        
    }else{
        cout << "Sunny" << endl;
    }
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#define int long long
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

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

    int N,K; cin>>N>>K;
    vector<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];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end(),greater<int>());

    auto check=[&](int X)
    {
        int cnt=0;
        for(int i=0;i<N;i++){
            cnt+=max(a[i]-X/b[i],0LL);
        }
        return cnt<=K;
    };

    int ng=-1,ok=1e12;
    while(ok-ng>1){
        int mid=(ng+ok)/2;
        if(check(mid)) ok=mid;
        else ng=mid;
    }
    cout<<ok<<endl;
    return 0;
}

Measured memory_bytes: 3456
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
ll n,m,k,d;

int a[maxn];
priority_queue<int> q;

int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        scanf("%d",a+i);
        q.push(a[i]);
    }
    for(int i=0;i<k;i++)
    {
        int num=q.top();
        if(num==0) break;
        q.pop();
        num/=2;
        q.push(num);
    }
    ll ans=0;
    while(!q.empty())
    {
        int num=q.top();
        ans+=num;
        q.pop();

    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1148
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef map<int,int> MPi; typedef pair<Int,Int> Pl; typedef int8_t shor;
const int mod = 1000000007;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) v.begin(),v.end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
#define rep(i,n) for(int (i)=0; i<(n); i++)
#define PU push_back
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,d=3,m=1;
V(bool)t(100001);

void table(int n){
	t[1]=true;
	for(int i = 3; i <= n;){
		t[i]=true;
		i+=d; d++;
	}
	return;
}

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

    cin>>n; table(n); d--; //cout<<d<<'\n';
	if(!t[n]){cout<<"No"<<'\n'; return 0;}
	V(int) a[d];
	int p[d-1][d-1];
	for (int i = 0; i < d-1; i++){
		for (int j = 0; j <= i; j++){
			p[i][j]=m; a[i].PU(m);
			m++;
		}
	}
	for (int i = 0; i < d-1; i++){
		for (int j = i+1; j < d-1; j++)a[i].PU(p[j][i]);
	}
	a[d-1].PU(1);
	for (int i = 3; i <= n; i++)if(t[i])a[d-1].PU(i);
	cout<<"Yes\n"<<d<<'\n';
	for (int i = 0; i < d; i++){
		cout<<d-1<<' ';
		for (int j = 0; j < d-1; j++)cout<<a[i][j]<<(j==d-2?'\n':' ');
	}
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  string S;
  cin>>S;
  LL K;
  cin>>K;
  int firstIndex=0;
  int firstValue=1;
  REP(i,0,S.length()){
    if(S[i]!='1'){
      firstIndex=i;
      firstValue=S[i]-'0';
      break;
    }
  }
  DUMP(firstIndex, firstValue);
  int ans = 0;
  if(firstIndex>K-1){
    ans=1;
  }else ans=firstValue;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int N,M,X;
  int A[110];

  cin >> N >> M >> X;

  int cp=0;

  for(int i=1;i <= M;i++){
    cin >> A[i];
    if(X >= A[i]){
      cp = i;
    }
  }

  if(cp > M/2){
    cout << M - cp << endl;
  }else{
    cout << cp << endl;
  }

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main() {
  int a, b; cin >> a >> b;
  cout << max(0, a-b*2) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  
  if( (a == 7) || (b == 7) || (c == 7))
  {
    if( (a == b) && (b == 5) || (a == c) && (a == 5) || (b == c) && (b == 5))
    {
      cout << "YES"<< endl;
    }
    else
  	{
    	cout << "NO" << endl;
  	}
  }
  else
  {
    cout << "NO" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i,j,l,t,a,b,n,s[1000],f[1000],max,min,flg;
	scanf("%d %d",&a,&b);
	scanf("%d",&n);
	t=0;
	flg=0;
	for(i=0;i<n;i++){
		scanf("%d %d",&s[i],&f[i]);
	}
	max=0;
	min=100000;
	for(i=0;i<n;i++){
		for(j=s[i];j<f[i];j++){
			for(l=a;l<b;l++){
				if(j==l){
					flg=1;
				}
			}
		}
	}
	if(flg==1){
		printf("1\n");
	}
	else{
		printf("0\n");
	}
	return 0;
}	


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#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++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;
const int mod = 1e9 + 7;

struct	UnionFind {
	vector<int> d;
	UnionFind(int n = 0): d(n, -1) {}
	int find(int x) {
		if (d[x] < 0) return x;
		return (d[x] = find(d[x]));
	}
	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return false;
		if (d[x] > d[y]) swap(x, y);
		d[x] += d[y];
		d[y] = x;
		return true;
	}
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -d[find(x)]; }
};

void	solve()
{
	int n, m;
	cin >> n >> m;
	UnionFind uf(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		uf.unite(a, b);
	}

	int ans = 0;
	rep(i, n) ans = max(ans, uf.size(i));
	cout << ans << endl;
}

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

	solve();
}



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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;


int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> jewelries(n);
    rep(i, n) cin >> jewelries[i];

    deque<ll> dq;
    rep(i, n) dq.push_back(jewelries[i]);

    auto check = [&](ll l, ll r, ll m) {
        deque<ll> dq_tmp = dq;
        ll sum = 0;
        PQ_ASK pqAsk;
        rep(i, l) {
            assert(!dq_tmp.empty());
            ll f = dq_tmp.front();
            sum += f;
            pqAsk.push(f);
            dq_tmp.pop_front();
        }

        rep(i, r) {
            assert(!dq_tmp.empty());
            ll b = dq_tmp.back();
            sum += b;
            pqAsk.push(b);
            dq_tmp.pop_back();
        }

        rep(i, m) {
            ll f = pqAsk.top();
            sum -= f;
            pqAsk.pop();
        }
        return sum;
    };
    ll ans = 0;
    rep(i, k + 1) {
        rep(j, min(i + 1, n + 1)) {
            ll m = i - j;
            if (m > j) continue;
            rep(l, j + 1) {
                ll r = j - l;
                ll now = check(l, r, m);
                cmax(ans, now);
            }
        }
    }
    cout << ans << endl;
}


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

void solve(std::string S)
{
    if (S[0] == 'R' && S[0] == S[1] && S[0] == S[2])
    {
        puts("3");
        return;
    }
    if (S[1] == 'R' && (S[0] == 'R' || S[2] == 'R'))
    {
        puts("2");
        return;
    }
    if (S[0] == 'R' || S[1] == 'R' || S[2] == 'R')
    {
        puts("1");
        return;
    }
    puts("0");
}

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


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N; cin >> N;
    vector<int> P(N);

    for(auto &it:P){
        cin >> it;
    }

    int smallest = 1e8;
    int ans = 0;

    for(auto it:P){
        if(it <= smallest){
            smallest = it;
            ans++;
        }

    }

    cout << ans << endl;
    
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,a,b) for(auto i=(a);i<(b);i++)
#define per(i,a,b) for(auto i=(a);i>=(b);i--)
#define Min(a,b) ((a) < (b) ? (a) : (b))
#define Max(a,b) ((a) > (b) ? (a) : (b))
#define int_inf 0x3f3f3f3f
#define int_max 2147483647
#define ll_max 9223372036854775807
#define ull_max 18446744073709551615
#define ll_inf 0x7f7f7f7f7f7f7f7f
#define lowbit(x) (x)&(-x)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define eps 1e-8
#define all(v) (v.begin(),v.end())
#define db double
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const double pi=acos(-1.0);
const double inf = 1e100;
template<class T>
inline T read()
{
	T x=0,f=1;char s=getchar();
	while(s<'0'||s>'9') {if(s=='-')f=-1;s=getchar();};
	while(s>='0'&&s<='9'){x=(x<<3)+(x<<1)+s-48;s=getchar();};
	return x*f;
}
template<typename T>
inline void wri(T x)
{
	if(x<0){x=-x;putchar('-');};
	if(x/10) wri(x/10);
	putchar(x%10+48);
}
template<typename T>
inline void print(T x,char s)
{
	wri(x);
	putchar(s);
}
template<typename T>
T gcd(T a,T b)
{
	return b==0?a:gcd(b,a%b);
}
//关闭流同步就不能手写读入优化啦
const int N=1e7+10;
ll fac[10001100],inv[10100100];
char s[10001100];
int k;
ll quick_pow(ll a,ll b){
	ll ret=1;
	while(b){
		if(b&1) ret=(ret*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return ret;
}
void init(){
	fac[0]=fac[1]=1;
	for(int i=2;i<N;i++){
		fac[i]=(i*fac[i-1])%mod;
	}
	inv[N-1]=quick_pow(fac[N-1],mod-2);
	per(i,N-2,0) inv[i]=(inv[i+1]*(i+1))%mod;
}
ll C(ll a,ll b){
	if(b>a) return 0ll;
	return fac[a]*inv[b]%mod*inv[a-b]%mod;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    init();
    cin>>k>>s;
    ll res=0;
    int len=strlen(s);
    for(int i=len;i<=k+len;i++){
    	res=(res+C(i-1,len-1)*quick_pow(25ll,i-len)%mod*quick_pow(26ll,k+len-i)%mod)%mod;
	}
	cout<<res<<endl;
    return 0;
}



Measured memory_bytes: 160860
K, A, B = map(int, input().split())

if A + 2 >= B or K + 1 < A:
    print(K + 1)
else:
    print(1 + (A - 1) + (B - A) * ((K - (A - 1)) // 2) + (K - (A - 1)) % 2)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll long long int
#define endl "\n"
#define db(x) cout<<#x<<" ->"<<x<<endl
#define db2(x,y) cout<<#x<<"->"<<x<<", "<<#y<<" -> "<<y<<endl
#define db3(x,y,z) cout<<#x<<" -> "<<x<<" , "<<#y<<" -> "<<y<<" , "<<#z<<" -> "<<z<<endl
#define db4(w,x,y,z) cout<<#w <<" -> " << w << " , " << #x<<" -> "<<x<<" , "<<#y<<" -> "<<y<<" , "<<#z<<" -> "<<z<<endl
#define prt(x) for(auto it = x.begin(); it!=x.end(); it++) { cout<<*it<<" "; } cout<< endl
#define IN freopen("input.txt","r",stdin)
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = (int)1e5+5;
deque< int > lol[5];
deque< pair< int , int > > V;
const int inf = 1 << 30;

int32_t main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
//    IN;
    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    for(int i = 0; i < a; i++){
        int x;
        cin >> x;
        lol[0].push_back(x);
    }
    for(int i = 0; i < b; i++){
        int x;
        cin >> x;
        lol[1].push_back(x);
    }
    for(int i = 0; i < c; i++){
        int x;
        cin >> x;
        lol[2].push_back(x);
    }
    for(int i = 0; i < 3; i++){
        sort(lol[i].rbegin(),lol[i].rend());
        if(i==0){ lol[i].resize(x) ; }
        else if(i==1){ lol[i].resize(y) ;}
//        prt(lol[i]);
        else{
            lol[i].resize(min(c,x+y));
        }
        for(auto &x : lol[i]){
            V.push_back({x,i});
        }
    }
    int red = 0, green = 0;
    ll ans  = 0LL;
    sort(V.begin(),V.end());
    reverse(V.begin(),V.end());
    for(int i = 0 ; i < V.size() && i < (x+y); i++){
        pair< int, int > t = V[i];
        int cost = t.first;
        int id = t.second;
        ans+=cost;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long int  ll;
typedef pair<ll, ll> P;

constexpr int MOD = 998244353;
constexpr ll inf = 1LL << 60;

template< typename S, typename T >
inline void chmax(S &a, const T &b) { if(a < b) a = b; }
 
template< typename S, typename T >
inline void chmin(S &a, const T &b) { if(a > b) a = b; }
 

//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
	if(n==0) return (ll)1;
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
ll modinv(ll a, ll m) {
	if(m==0)return (ll)1;
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


////////////////////////////////////////////////////////////////////

int main() {
 ios::sync_with_stdio(false);

ll h,w;
cin>>h>>w;
ll k;
cin>>k;
ll ans=0;

char gr[h+1][w+1];
rep(i,h){
	rep(j,w){
		char pp;
		cin>>pp;
		gr[i][j]=pp;
	}
}

for(int bit=0;bit<(1<<(h+w));bit++){
char gr2[h+1][w+1];
rep(i,h){
	rep(j,w){
		gr2[i][j]=gr[i][j];
	}
}
for(int i=0;i<=11;i++){
if(bit&(1<<i)){
	if(i<=h-1){
		for(int k=1;k<=w;k++){
			gr2[i+1][k]='.';
		}
	}
	if(i>=h){
for(int k=1;k<=h;k++){
	gr2[k][i-h+1]='.';
}

	}
}
}

ll cnt=0;
rep(i,h){
	rep(j,w){
if(gr2[i][j]=='#')cnt++;
	}
}
if(cnt==k)ans++;

}

cout<<ans<<endl;

return 0;
}




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

int count(int higher, int lower, int N) {

  int ans = 0;
  if(higher == lower && higher <= N) {
    ans++;
  }

  if(higher * 10 + lower <= N) {
    ans += 1;
  } else {
    return ans;
  }
  int factor = 100;
  while(true) {
    auto n = higher * factor + (factor / 10 - 1) * 10 + lower;
    if(n <= N) {
      ans += (factor / 10);
    } else {
      for(int i = 0; i < factor / 10; ++i) {
        auto nn = higher * factor + i * 10 + lower;
        if(nn <= N) {
          ans++;
        } else {
          return ans;
        }
      }
    }
    factor *= 10;
  }
}

using ll = long long;

int main() {
  int N;
  cin >> N;

  ll ans = 0;
  for(int i = 1; i <= 9; ++i) {
    for(int j = 1; j <= 9; ++j) {
      ll left = count(i, j, N);
      ll right = count(j, i, N);
      ans += left * right;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n,q = [int(i) for i in input().split()]
s = input()
l = []
r = []
memo = [0] * 100001
for i in range(q):
    x,y=[int(i) for i in input().split()]
    l.append(x)
    r.append(y)
#カウントの処理は1回
for i in range(len(s)):
    if i==0:
        continue
    else:
        memo[i] = memo[i-1] + s[i-1:i+1].count("AC")

for i in range(q):
    print(memo[r[i]-1]-memo[l[i]-1])

Measured memory_bytes: 15828
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int N;

signed main()
{
	cin >> N;

	int min = INT_MAX;

	for (int i = 1; i < N; i++)
	{
		int a = i;
		int b = N - i;

		int as = 0;
		int bs = 0;
		while (true)
		{
			as += a % 10;
			a /= 10;
			if (a == 0)
			{
				break;
			}
		}
		while (true)
		{
			bs += b % 10;
			b /= 10;
			if (b == 0)
			{
				break;
			}
		}

		min = MIN(min, as + bs);
	}

	cout << min << endl;
}






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

using namespace std;

typedef long long ll;

const ll MOD = 1e9+7;
const int MAX_H = 1e3 + 10, MAX_W = 10;

ll fib[1000];

void calcFib(){
	fib[0] = 1;
	fib[1] = 1;
	for (int i = 2; i < 1000; ++i) {
		fib[i] = fib[i-1]+fib[i-2] % MOD;
	}
}

vector<vector<ll>> matmul(vector<vector<ll>> a, vector<vector<ll>> b){
	int l = a[0].size();

	vector<vector<ll>> ret(l, vector<ll>(l,0));

	for (int i = 0; i < l; ++i) {
		for (int j = 0; j < l; ++j) {
			for (int k = 0; k < l; ++k) {
				ret[i][j] += a[i][k] * b[k][j];
				ret[i][j] %= MOD;
			}
		}
	}
	return ret;
}

vector<vector<ll>> matpow(vector<vector<ll>> m, int n){
	int l = m[0].size();

	if (n==0) {
		for (int i = 0; i < l; ++i) {
			for (int j = 0; j < l; ++j) {
				m[i][j] = (i==j);
			}
		}
		return m;
	}

	if (n==1) return m;

	if (n%2) {
		return matmul(matpow(m, n-1), m);
	}
	else {
		return matpow(matmul(m,m), n/2);
	}
}

int main(int argc, char const *argv[])
{
	calcFib();

	int H, W, K;
	cin >> H >> W >> K;
	K--;

	vector<vector<ll>> M(W, vector<ll>(W,0));

	for (int i = 2; i <= W; ++i) {
		M[i-2][i-1] = fib[i-2]*fib[W-i] % MOD;
	}

	for (int i = 1; i < W; ++i) {
		M[i][i-1] = fib[i-1]*fib[W-i-1] % MOD;
	}

	for (int i = 1; i <= W; ++i) {
		M[i-1][i-1] = fib[i-1]*fib[W-i]%MOD;
	}

	auto res = matpow(M, H);
	cout << res[K][0] << endl;
	return 0;
}

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

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

#define endl '\n'
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define int long long
#define pb push_back
#define f(i,l,r) for(ll i=l;i<=r;i++)
#define rf(i,r,l) for(ll i=r;i>=l;i--)
#define Max 5000001
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define d0(a) cout<<a<<' ';
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<' '<<b<<endl;
#define d3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define d4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
#define d5(a,b,c,d,e) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl;
#define d6(a,b,c,d,e,f) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<' '<<f<<endl;

const ll N=1e5+5,mod=1e9+7,lg=64;

int basis[lg],sz=0,n;

void Insert(int x)
{
    for(int i=lg-1;i>=0;i--)
    {
        if(((x>>i)&1)==0)
        {
            continue;
        }
        if(basis[i]==0)
        {
            basis[i]=x;
            sz++;
            break;
        }
        x^=basis[i];
    }
}


signed main()
{
    fast;

    ll t=1;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n];
        sz=0;
        memset(basis,0,sizeof(basis));
        f(i,0,n-1)
        {
            cin>>a[i];
        }
        string s;
        cin>>s;
        bool ans=0;
        rf(i,n-1,0)
        {
            if(s[i]=='0')
            {
                Insert(a[i]);
            }
            else
            {
                ll prev=sz;
                Insert(a[i]);
                ll curr=sz;
                if(curr!=prev)
                {
                    ans=1;
                    break;
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


















Measured memory_bytes: 3604
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
# print(a, b, c)
for i in range(n):
    a[i] -= 1
ans = 0
last = -2
for i in range(n):
    ans += b[a[i]]
    if last + 1 == a[i]:
        ans += c[last]
    last = a[i]
print(ans)


Measured memory_bytes: 3064
N,M,V,P = map(int,input().split())
A = sorted(list(map(int,input().split())))
B = A[:N-P+1]
S = sum(B)
accum = [0]
for i in range(N-P+1):
    accum.append(accum[-1]+B[i])

ans = P-1

for i in range(N-P+1):
    if B[i]+M-B[-1]<0:
        continue
    if B[i]*(N-P-i)-S+accum[i+1]+M*(N-P)>=max(M*(V-P),0):
        ans += 1

print(ans)

Measured memory_bytes: 65304
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n; cin >> n;
    map<int, int> mp;
    for(int i = 0; i < n; i++) {
        int a; cin >> a;
        mp[a]++;
    }

    if(mp[0] == n) {
        cout << "Yes" << endl;
        return 0;
    }

    if(n % 3 != 0) {
        cout << "No" << endl;
        return 0;
    }

    vector<int> cnt;
    for(auto& itr : mp) {
        for(int i = 0; i < itr.second / (n / 3); i++) {
            cnt.push_back(itr.first);
        }
    }

    if(cnt.size() == 3 && (cnt[0] ^ cnt[1] ^ cnt[2]) == 0) {
        cout << "Yes" << endl;
        return 0;
    } else {
        cout << "No" << endl;
        return 0;
    }
}


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

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

}


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

using ll = long long;
using Pii = std::pair<int, int>;
using Pll = std::pair<ll, ll>;

const ll INF = (ll)1e16;

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int N, M;
    scanf("%d %d", &N, &M);

    vector<int> A(N), B(M), C(M);
    for (int i = 0; i < N; ++i) {
        scanf("%d", &A[i]);
    }
    for (int i = 0; i < M; ++i) {
        scanf("%d %d", &B[i], &C[i]);
    }

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

    vector<int> index(M);
    iota(index.begin(), index.end(), 0);
    sort(index.begin(), index.end(), [&C](auto l, auto r) {
        return C[l] > C[r];
    });

    ll sum = 0;
    int cnt = 0;

    for (int j = 0; j < M && cnt < N; ++j) {
        int i = index[j];
        int replaceable = distance(A.begin(), lower_bound(A.begin(), A.end(), C[i])) - cnt;
        if (replaceable <= 0) break;
        int replace = min(replaceable, B[i]);
        sum += (ll)C[i] * replace;
        cnt += replace;
    }

    for (int i = cnt; i < N; ++i) {
        sum += (ll)A[i];
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const string YES = "Yes";
const string NO = "No";

void solve(long long X, long long Y){
    ll a = (4 * X -Y)/2;
    ll b = X-a;

    if(a+b == X && 2*a + 4*b == Y && a >=0 && b>=0){
        cout << YES <<endl;
        return;
    }
    cout << NO <<endl;

}

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


Measured memory_bytes: 3764
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll n;
    std::cin >> n;
    std::cout << (n-2)*180 << std::endl;
}


Measured memory_bytes: 256
A,B,C,D=input().split()
A=int(A)
B=int(B)
C=int(C)
D=int(D)

n_1=A//D
n_2=A/D
if n_1<n_2:
    takahashi=n_1+1
else:
    takahashi=n_1

n_3=C//B
n_4=C/B
if n_3<n_4:
   aoki=n_3+1
else:
    aoki=n_3

if takahashi>=aoki:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9120
#include <iostream> 
#include <bits/stdc++.h>
#include <vector> 
#include <algorithm> 
#include <string>
#include <cmath>
#include <iomanip> 
#include<climits> 
#include <utility>   
#include <set>
#include <numeric> 
#include <iterator>
#include <map> 
using namespace std; 
#define ll unsigned long long int
typedef pair<ll,ll> p; 
 

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

ll p=a[0],q=a[0],c=1;
for(i=1;i<n;i++)
{
    if(a[i]<=q)
    {
      c++;
         q=a[i];
    }
}
 cout<<c<<endl;   
}

Measured memory_bytes: 1920
n,q = map(int,input().split())
S = input()
sum_ = [0]*n
for i in range(1,n):
    if S[i-1] == 'A' and S[i] == 'C':
        sum_[i] += 1
for i in range(1,n):
    sum_[i] += sum_[i-1]
for i in range(q):
    l,r = [int(j)-1 for j in input().split()]
    print(sum_[r]-sum_[l])

Measured memory_bytes: 7668
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int dp[100100];

int main()
{
    int n; cin >> n;
    double a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    double div = 0.0;
    for(int i = 0; i < n; i++){
        div += (1 / a[i]);
    }
    double ans = 1 / div;
    printf("%.8lf\n",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define space " "
#define MOD (long long) 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename T> void __f(const char* variable_name, T&& value){cout << variable_name << ": " << value << endl;}
template <typename T1, typename... T2> void __f(const char* names, T1&& arg1, T2&&... args){const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);}

const ll N = 5e5 + 5;
ll *v;
ll x;

void solve(){
    cin >> x;
    ll num = 100, steps = 0;
    while(num < x){
        num += num / 100;
        steps++;
    }
    cout << steps;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    // cout << "\n\nBLAH BLAH BLAH\n\n";
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int i, j, n, q, b, m, e;
		try (Scanner sc = new Scanner(System.in)) {
			n = sc.nextInt();
			int[] a = new int[n];
			int[] box = new int[n];
			for(i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}
			q = sc.nextInt();
			for(i = 0; i < q; i++) {
				b = sc.nextInt();
				m = sc.nextInt();
				e = sc.nextInt();
				for(j = b; j < e; j++) {
					box[b + ((j - b + (e - m)) % (e - b))] = a[j];
				}
				for(j = b; j < e; j++) {
					a[j] = box[j];
				}
			}
			for(i = 0; i < n - 1; i++){
				System.out.print(a[i] + " ");
			}
			System.out.println(a[n - 1]);
		}
	}
}



Measured memory_bytes: 36832
// CONTEST SOURCE
#include <iostream>
#include <sstream>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>
//#include <priority_queue>
using namespace std;
#define ll long long
#define x first
#define y second
#define pii pair<int, int>
#define pdd pair<double, double>
#define L(s) (int)(s).size()
#define VI vector<int>
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define ull unsigned ll
#define inf 1000000000
int n, m;
vector<int> e[111111];
int u[111111][2];
void dfs(int v, int par) {
  if (u[v][par]) return;
  u[v][par] = 1;
  for(int i = 0; i < L(e[v]); ++i) dfs(e[v][i], par ^ 1);
}
int main() {
  scanf("%d%d", &n, &m);
  for(int i = 0; i < m; ++i) {
    int x, y; scanf("%d%d", &x, &y);
    --x; --y;
    e[x].pb(y);
    e[y].pb(x);
  }
  dfs(0, 0);
  int lft = 0, rgt = 0;
  for(int i = 0; i < n; ++i) {
    if (u[i][0] && !u[i][1]) ++lft; else
      if (u[i][1] && !u[i][0]) ++rgt; else {
        cout << 1LL * n * (n - 1) / 2 - m << endl;
        return 0;
      }
  }
  cout << 1LL * lft * rgt - m << endl;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	long long N;

	cin >> N;

	long long A[N];

	for(long long i = 0; i < N; i++){
		cin >> A[i];
		A[i] -= i+1;
	}

	sort(A, A+N);

	long long b0, b1;
	b0 = A[(N-1)/2]; 
	b1 = A[N/2]; 

	long long ans0 = 0, ans1 = 0;
	for(long long i = 0; i < N; i++){
		ans0 += abs(A[i]-b0);
		ans1 += abs(A[i]-b1);
	}

	cout << min(ans0, ans1) << endl;

	return 0;
}


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

int main(){
	int h,n,t;scanf("%d%d",&h,&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&t);h-=t;
	}if (h<=0)printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 256
import math

a, b, C = map(float, input().split())
C = (C / 180) * math.pi
c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(C))
h = b*math.sin(C)

print(a*h/2)
print(a + b + c)
print(h)


Measured memory_bytes: 5696
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    k,n=MI()
    aa=LI()
    mx=k-aa[-1]+aa[0]
    for a0,a1 in zip(aa,aa[1:]):
        mx=max(mx,a1-a0)
    print(k-mx)

main()

Measured memory_bytes: 25876
N=int(input())
a = list(map(int, input().strip().split()))

result = 0
if N % 2 != 0:
  cor = [0]
  for i in range(1,int(N/2)+1):
    cor.append(i*2)
    cor.append(i*2)
  if sorted(a) == cor:
    result = 2**int((N-1)/2) % (10**9 + 7)
else:
  cor = []
  for i in range(1,int(N/2)+1):
    cor.append(i*2-1)
    cor.append(i*2-1)
  if sorted(a) == cor:
    result = 2**int(N/2) % (10**9 + 7)
    
print(result)
  

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

	int countDivisibles(int A, int B, int M) 
{ 
    // Variable to store the counter 
    int counter = 0; 
  
    // Running a loop from A to B and check 
    // if a number is divisible by M. 
    for (int i = A; i <= B; i++) 
        if (i % M == 0) 
            counter++; 
  
    return counter; 
} 

int main()
{
	
	
	int k;
	int A,B;
	int counter;
	
	cin>>k;
	cin>>A>>B;
	

	 counter=countDivisibles(A, B, k);
		
		
		if(counter>0)
		{
			printf("OK");
			
		}
		else 
		{   
		    
			printf("NG");
			
		}

	
    
	return 0;
}


Measured memory_bytes: 3764
N = int(input())
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]

ans = 0
for i in range(N):
    if x[i] == y[i]:
        ans += 1
        if ans == 3:
            break
    else:
        ans = 0
if ans == 3:
    print("Yes")
else:
    print("No")

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

string grid[55];

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

    int n, m;
    cin >> n >> m;
    for (int i=0; i<n; i++)
        cin >> grid[i];

    mcf_graph<int, int> mcf(n * m + 2);
    int s = n * m, t = n * m + 1;

    int tot = 0;
    for (int i=0; i<n; i++)
        for (int j=0; j<m; j++) {
            if (grid[i][j] == 'o') {
                mcf.add_edge(s, m * i + j, 1, 0);
                tot += n + m - i - j - 2;
            }
            if (grid[i][j] != '#')
                mcf.add_edge(m * i + j, t, 1, n + m - i - j - 2);
            if (i < n - 1 && grid[i+1][j] != '#')
                mcf.add_edge(m * i + j, m * (i + 1) + j, n * m, 0);
            if (j < m - 1 && grid[i][j+1] != '#')
                mcf.add_edge(m * i + j, m * i + j + 1, n * m, 0);
        }

    cout << tot - mcf.flow(s, t).second << "\n";

    return 0;
}


Measured memory_bytes: 4196
#include<stdio.h>

int main(void){

	int h,m,s,S;
	scanf("%d",&S);
	h=S/3600;
	m=(S-3600*h)/60;
	s=S-(h*3600+m*60);
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
import java.util.*;
public class Main{
        static Scanner sc = new Scanner(System.in);
        static int rectangle, rhomboid;
        static String line;
        static String[] input = new String[3];
        public static void main(String[] args){
                while(read()){
                        slove();
                }
                System.out.println(rectangle);
                System.out.println(rhomboid);
                
        }
        static boolean read(){
                line = sc.nextLine();
                if(sc.hasNext() == false)
                        return false;
                input = line.split(",");
                return  true;
        }
        static void slove(){
                int w, h, diagonal;
                String tmp;
                tmp = input[0];
                w = Integer.parseInt(tmp);
                tmp = input[1];
                h = Integer.parseInt(tmp);
                tmp = input[2];
                diagonal = Integer.parseInt(tmp);
                
                if(w == h){
                        if(w*w + h*h != diagonal*diagonal)
                                rhomboid++;
                }else{
                        if(w*w + h*h == diagonal*diagonal)
                                rectangle++;
                }
        }
}

Measured memory_bytes: 12000