akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int x=scan.nextInt();
        int y=scan.nextInt();
        switch((int)Math.signum(y-x)){
            case 1:
                System.out.println("a < b");
                break;
            case 0:
                System.out.println("a == b");
                break;
            case -1:
                System.out.println("a > b");
                break;
        }
    }
}


Measured memory_bytes: 26240
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A;
  cin >> A;
  vector<int> vec(A);
  
  for(int i=0;i<A;i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  cout << vec.at(A-1) - vec.at(0) << endl;
}

Measured memory_bytes: 256
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> s(n);
    for(int i = 0; i < n; i++) cin >> s[i];
    ll ans = 0;
    bitset<n_max> used(0);
    rep(c,1,n){
        ll lp = 0, rp = n-1;
        ll temp = 0;
        used &= 0;
        for(; lp < n; lp += c){
            if(lp == rp)break;
            if(rp < c)break;
            if(used[lp])break;
            temp += s[lp];
            temp += s[rp];
            chmax(ans, temp);
            debug(c, lp, rp, temp);
            rp -= c;
            used[lp] = used[rp] = 1;
        }
    }

    cout << ans << "\n";
}

Measured memory_bytes: 3996
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        int k = sc.nextInt();
        k = Math.min(k,41);     
        int [] in = new int [n];
        int [] in2 = new int [n];
        for(int i=0;i<n;i++){
                             in[i] = sc.nextInt();
                            }
        for(int j=0;j<k;j++){
        for(int i=0;i<n;i++){in2[i]=0;}
        for(int i=0;i<n;i++){int l = Math.max(0,i-in[i]);  
                             int r = Math.min(n-1,i+in[i]);  
                             in2[l]++; 
                             if(r+1<n) in2[r+1]--;                             
                            }       
        for(int i=1;i<n;i++){in2[i]+=in2[i-1];}
        for(int i=0;i<n;i++){in[i]=in2[i];}
        }
		for(int i=0;i<n;i++){System.out.println(in[i]);
                            }
	}
}

Measured memory_bytes: 62748
#define ll				long long
#define MOD				1000000007

#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

FILE *in, *ans;
int tno;

int out(const char *s) {
#ifdef TEST
	char buf[8192];
	fgets(buf, sizeof(buf), ans);
	if (strcmp(buf, s)) {
		printf("err\n");
	}
#else
	printf(s);
#endif
	return 0;
}

int outi(int i) {
	char s[128];
	sprintf(s, "%d\n", i);
	out(s);
	return 0;
}

int outd(double d) {
	char s[128];
	sprintf(s, "%.10lf\n", d);
	out(s);
	return 0;
}

int outll(ll l) {
	char s[128];
	sprintf(s, "%lld\n", l);
	out(s);
	return 0;
}

int geti() {
	int i;
	fscanf(in, "%d", &i);
	return i;
}

ll getll() {
	ll l;
	fscanf(in, "%lld", &l);
	return l;
}

int getstr(char *s) {
	fscanf(in, "%s", s);
	return 0;
}

int getmin(int val1, int val2) {
	if (val1 < val2) {
		return val1;
	}
	else {
		return val2;
	}
}

int getmax(int val1, int val2) {
	if (val1 > val2) {
		return val1;
	}
	else {
		return val2;
	}
}

typedef struct data {
	int x, y;
} data;

int n;
int vals[100000];

int sortfnci(const void *v1, const void *v2) {
	int *i1 = (int *)v1;
	int *i2 = (int *)v2;

	if (*i1 > *i2) {
		return 1;
	}
	else if (*i1 < *i2) {
		return -1;
	}

	return 0;
}

int fnc2() {
	int i;
	char s[128];

	n = geti();
	for (i = 0; i < n; i++) {
		vals[i] = geti();
	}
	qsort(vals, n, sizeof(int), sortfnci);

	if (n == 2) {
		outi(vals[1] - vals[0]);
		sprintf(s, "%d %d\n", vals[1], vals[0]);
		out(s);
		return 0;
	}

	int sum = 0;
	int now;
	if (vals[0] > 0) {
		for (i = 0; i < n; i++) {
			sum += vals[i];
		}
		sum -= vals[0] * 2;
		outi(sum);

		now = vals[0];
		for (i = 1; i < n - 1; i++) {
			sprintf(s, "%d %d\n", now, vals[i]);
			out(s);
			now -= vals[i];
		}
		sprintf(s, "%d %d\n", vals[n-1], now);
		out(s);
	}
	else if (vals[n-1] < 0) {
		for (i = 0; i < n; i++) {
			sum += abs(vals[i]);
		}
		sum -= abs(vals[n-1]) * 2;
		outi(sum);

		now = vals[n - 1];
		for (i = 0; i < n - 1; i++) {
			sprintf(s, "%d %d\n", now, vals[i]);
			out(s);
			now -= vals[i];
		}
	}
	else {
		for (i = 0; i < n; i++) {
			sum += abs(vals[i]);
		}
		outi(sum);

		now = vals[0];
		for (i = 1; i < n - 1; i++) {
			if (vals[i] >= 0) {
				sprintf(s, "%d %d\n", now, vals[i]);
				out(s);
				now -= vals[i];
			}
		}
		sprintf(s, "%d %d\n", vals[n - 1], now);
		out(s);
		now = vals[n - 1] - now;
		for (i = 1; i < n - 1; i++) {
			if (vals[i] < 0) {
				sprintf(s, "%d %d\n", now, vals[i]);
				out(s);
				now -= vals[i];
			}
		}
	}

	return 0;
}

int fnc1() {
	int ret = fnc2();
//	outi(ret);
	return 0;
}

int main() {

#ifdef TEST
	for (tno = TEST_SNO; tno <= TEST_ENO; tno++) {
		char str[128];
		sprintf(str, "test%d.txt", tno);
		in = fopen(str, "r");
		sprintf(str, "ans%d.txt", tno);
		ans = fopen(str, "r");
		fnc1();
		fclose(in);
		fclose(ans);
	}
	printf("end\n");
#else
	in = stdin;
	fnc1();
#endif

	return 0;
}


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

from collections import Counter
c=Counter(a)

variation=len(set(a))
if variation<=k:
    print(0)
    exit()

ans=0
for key, val in sorted(c.items(), key=lambda x: x[1]):
    ans+=val
    variation-=1
    if variation<=k:
        break
print(ans)


Measured memory_bytes: 43056
#include <bits/stdc++.h>
 
#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif
 
using namespace std;
 
const int MOD=1e9+7;
int D[1<<20], Dsum[1<<20], Dminus[1<<20], PS[500001];
 
long long mod(long long a)
{
	if(a>=0) return a%MOD;
	return ((-a/MOD+1)*MOD+a)%MOD;
}
 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, PX=0, A;
	cin>>N; PS[0]=1;
	for(int i=1;i<=N;i++) {
		cin>>A;
		if(PX^=A) {
			D[PX]=mod(1+1LL*Dsum[PX]*PS[i-1]-1LL*Dminus[PX]);
			Dsum[PX]=(Dsum[PX]+D[PX])%MOD;
			Dminus[PX]=(Dminus[PX]+1LL*D[PX]*PS[i-1])%MOD;
		}
		else PS[i]=1;
		PS[i]+=PS[i-1];
	}
	if(PX) cout<<D[PX]<<'\n';
	else {
		int ans=1;
		for(int i=2;i<PS[N];i++) ans=(2*ans)%MOD;
		for(int i=(1<<20)-1;i;i--) ans=(ans+Dsum[i])%MOD;
		cout<<ans<<'\n';
	}
	return 0;
}

Measured memory_bytes: 14464
//
//  main.cpp
//  atCoder
//
//  Created by 佐々木勇星 on 2019/07/23.
//  Copyright © 2019 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <regex>
#include <cmath>


int main(void) {
    
    using namespace std;
    
    long a, b, r, tmp, x;
    cin >> a;
    cin >> b;
    
    x = a * b;
    
    if(a < b){
        tmp = a;
        a = b;
        b = tmp;
    }
    
    r = a % b;
    
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    
    cout << x/b;
    
    
    
    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;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
string n;
cin>>n;
if(n[0]==n[1]&&n[1]==n[2]) cout<<"Yes"<<endl;
else if(n[3]==n[1]&&n[1]==n[2]) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}

Measured memory_bytes: 256
a = int(input())
b = map(int, input().split())
b = list(b)
t = []

r = [0]

def he(b, t, idx, tm):
    if len(t) == 2:
        tm[0] += t[0] * t[1]
        return
    for i in range(idx, len(b)):
        t.append(b[i])
        he(b, t, i + 1, tm)
        t.pop()

he(b, t, 0, r)

print(r[0])


Measured memory_bytes: 3060
#if __has_include("D:/dhiraj/Programming/debug.h")
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
    #define cerr if(0) cerr
#endif

// Macro --------------------------------------------------------------------

#define ll                  long long int
#define FOR(i, a, b, s)     for(ll i = (a); ((s)>0 ? i<(b) : i>(b)); i += (s))
#define FOR1(b)             FOR(i, 0, b, 1)
#define FOR2(i, b)          FOR(i, 0, b, 1)
#define FOR3(i, a, b)       FOR(i, a, b, (a) <= (b) ? 1 :-1)
#define FOR4(i, a, b, s)    FOR(i, a, b, s)
#define GET5(a, b, c, d, e, ...) e
#define FORC(...)           GET5(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)
#define loop(...)           FORC(__VA_ARGS__)(__VA_ARGS__)
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define endl                '\n'

// Template -----------------------------------------------------------------

// multiple input
template <typename... T> 
inline void inp(T&... args) {
    ((cin>>args), ...);
}
// scan vector
template <typename T> 
inline istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U> 
inline istream &operator>>(istream &in, pair<T,U> &a) {
    in >> a.first >> a.second; 
    return in;
}

// Solve --------------------------------------------------------------------

void solve(int &T)
{
    ll n;
    cin>>n;
    
    map<string,ll> m;
    loop(n)
    {
        string s;
        cin>>s;
        m[s]++;
    }
    cout<<"AC x "<<m["AC"]<<endl;
    cout<<"WA x "<<m["WA"]<<endl;
    cout<<"TLE x "<<m["TLE"]<<endl;
    cout<<"RE x "<<m["RE"]<<endl;
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt","r",stdin);
        freopen("D:/dhiraj/Programming/o1.txt","w",stdout);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    for(int i=1; i<=t; i++)
    {
        cerr<<"Case #"<<i<<"\n";
        solve(i);
    }
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



char buf[200005];

int main(){

	scanf("%s",buf);

	int loc_A = BIG_NUM,loc_Z = -1;

	for(int i = 0; buf[i] != '\0'; i++){
		if(buf[i] == 'A'){

			if(loc_A == BIG_NUM){

				loc_A = i;
			}

		}else if(buf[i] == 'Z'){

			loc_Z = i;
		}
	}

	printf("%d\n",loc_Z-loc_A+1);

	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Mid ((l+r)/2)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define drep(i,a,b) for(int i=(a);i>=(b);--i)
#define file(a) freopen(#a".in","r",stdin),freopen(#a".out","w",stdout);
const int maxn=1e5+5,mod=1e9+7,inf=0x3f3f3f3f;
int n,m,Q,K,T;
int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}char c[maxn];
int q[maxn];
signed main(){
    //file(a);
    scanf("%s",c+1);
    int res=0;
    rep(i,1,3){
        if(c[i]=='R'){
            int ans=0;
            rep(j,i,3){
                if(c[j]=='R')++ans;
                else break;
            }res=max(res,ans);
        }
    }printf("%d\n",res);

    return 0;
}

Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;



int main()
{

string s ;
cin>>s;

if(s[0]=='7'||s[1]=='7'||s[2]=='7')
    cout<<"Yes"<<endl;
else
    cout<<"No"<<endl;



 return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define  ll long long
int main(){
    ll x,k,d;cin>>x>>k>>d;
    ll y=abs(x);
   ll a,b,c;
    if(x>=0){
        a=x/d;
        b=k-a;
    if(k<a){
        cout<<x-k*d<<endl;
    }
    else{
        c=x-(x/d)*d;
        if(b&1){
            c-=d;
            cout<<abs(c)<<endl;
        }
        else{
            cout<<abs(c)<<endl;
        }
    }
}
else{
    a=y/d;
     b=k-a;
    if(k<a){
        cout<<abs(x+k*d)<<endl;
    }
    else{
        c=x+(y/d)*d;
        if(b&1){
            c+=d;
            cout<<abs(c)<<endl;
        }
        else{
            cout<<abs(c)<<endl;
        }
    }
}
}


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

WA=[0 for _ in range(N+1)]
solved=[False for _ in range(N+1)]
AC=0

for _ in range(M):
    P,S=input().split()
    P=int(P)
    
    if S=="AC" and solved[P]==False:
        AC+=1
        solved[P]=True
    elif S=="WA" and solved[P]==False:
        WA[P]+=1

U=0
for i in range(1,N+1):
    if solved[i]:
        U+=WA[i]

print(AC,U)


Measured memory_bytes: 85904
#include<bits/stdc++.h>
#define rg register
#define oo 0x7fffffff
#define ll long long
using namespace std;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		{
			fh=-1;
			jp=getchar();
		}
	while (jp>='0'&&jp<='9')
		{
			out=out*10+jp-'0';
			jp=getchar();
		}
	return out*fh;
}
const int MAXN=1e5+10;
const int P=1e9+7;
inline int add(int a,int b)
{
	return (a + b) % P;
}
inline int mul(int a,int b)
{
	return 1ll * a * b  % P;
}
char s[MAXN];
int pre[MAXN],f[MAXN],nx[3];
int n;
int main()
{
	//freopen("composer.in","r",stdin);
	//freopen("composer.out","w",stdout);
	scanf("%s",s);
	int flag=0;
	for(; s[n]; ++n)
		{
			pre[n+1]=pre[n]+(s[n]=='a'? 1:2 );
			pre[n+1]%=3;
		}
	for(rg int i=1; i<n; ++i)
		if(s[i]==s[i-1])
			flag=1;
	if(flag==0)
		{
			putchar('1');
			return 0;
		}
	f[n]=1;
	for(rg int i=0; i<3; ++i)
		nx[i]=i==pre[n]?n:n+1;
	for(rg int i=n-1; i; --i)
		{
			f[i]= pre[i]==pre[n];
			for(rg int c=1; c<=2; ++c)
				f[i]=add(f[i],f[nx[(pre[i]+c)%3]]);
			nx[pre[i]]=i;
		}
	cout<<add(f[nx[1]],f[nx[2]]);
	return 0;
}

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

using namespace std;

const int K = 26;

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

    int d;
    cin >> d;
    vector<int> c(K);
    for (int i = 0; i < K; ++i) {
        cin >> c[i];
    }
    vector<vector<int>> s(d, vector<int>(K));
    for (int i = 0; i < d; ++i) {
        for (int j = 0; j < K; ++j) {
            cin >> s[i][j];
        }
    }
    vector<int> ans;
    vector<int> last(26, -1);
    for (int i = 0; i < d; ++i) {
        vector<double> x;
        for (int j = 0; j < K; ++j) {
            x.push_back((double) s[i][j] * s[i][j] * c[j] * (i - last[j]));
        }

        double sum = 0;
        for (int j = 0; j < K; ++j) {
            sum += x[j];
        }
        for (int j = 0; j < K; ++j) {
            x[j] /= sum;
        }

        double prob = (double) (rand() % RAND_MAX) / (double) RAND_MAX;
        double cur = 0;
        for (int j = 0; j < K; ++j) {
            if (cur + x[j] <= prob) {
                cur += x[j];
                continue;
            }
            ans.push_back(j);
            last[j] = i;
            break;
        }
    }

    for (auto u : ans) {
        cout << u + 1 << "\n";
    }

    return 0;
}

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

int main() {
  string n;
  cin >> n;
  REP(i, 3) {
    if (n[i] == '1') {
      n[i] = '9';
    } else if (n[i] == '9') {
      n[i] = '1';
    }
  }
  cout << n << endl;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF   = LL(1e18) + 1;
#define pow10(n) int(1e##n + n)

void solve()
{
    int N;
    cin >> N;
    cout << (N + 1) / 2 << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);
// int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
// int a[12][12];

void solve() {
  int n;
  cin >> n;
  if (n % 1000 % 111 == 0 || n/10 % 111 == 0) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}


int main() {
  solve();
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

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

  set<int>
    a({1,3,5,7,8,10,12}),
    b({4,6,9,11}),
    c({2});

  int x, y;
  cin >> x >> y;

  cout << (
      a.count(x) && a.count(y) ||
      b.count(x) && b.count(y) ||
      c.count(x) && c.count(y) ?
      "Yes" : "No") << LF;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif
 
using namespace std;
 
vector<pair<int,int>> E;
int color[100000];
bool chk[100000];
 
int find_(int a)
{
	return color[a]=a==color[a] ? a:find_(color[a]);
}
 
void union_(int a, int b)
{
	a=find_(a); b=find_(b);
	color[a]=color[b]=max(a,b);
}
 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, Q, c0=0, c1=0;
	long long M;
	cin>>N>>M>>Q;
	for(int i=0;i<N;i++) color[i]=i;
	while(Q--) {
		int a, b, c;
		cin>>a>>b>>c;
		if(c==0) {
			if(find_(a)!=find_(b)) {
				union_(a,b);
				M--;
			}
		}
		else E.emplace_back(a,b);
	}
	for(auto e: E) {
		int a, b;
		tie(a,b)=e;
		if(find_(a)==find_(b)) {
			cout<<"No\n";
			return 0;
		}
		chk[find_(a)]=chk[find_(b)]=true;
	}
	for(int i=0;i<N;i++) {
		c0+=find_(i)==i;
		c1+=chk[i];
	}
	cout<<(M>=0 && (c1==0 || c0>=3 && max(c1,3)<=M) && c0-1<=M && 1LL*c0*(c0-1)/2>=M ? "Yes\n":"No\n");
	return 0;
}

Measured memory_bytes: 1784
d,m=1e9+7,p[10001][2][100];char s[11111];
f(l,i,k,t,x,L){int*r=p[i][t]+k;*r=i-l?*r:!k;if(!~*r)for(L=t?9:s[i]-48,*r=x=0;x<=L;*r%=m)*r+=f(l,i+1,(k+x++)%d,t|x<L);return*r;}
main()
{
	scanf("%s%d",s,&d);
	memset(p,-1,sizeof p);
	printf("%d",(f(strlen(s),0,0,0)-1+m)%m);
}

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

int a, b;

int main() {
	int N, M;
	cin >> N >> M;
	scc_graph scc = scc_graph(N);
	for (int i=0;i<M;i++) {
		cin >> a >> b;
		scc.add_edge(a, b);
	}
	auto vec = scc.scc();
	cout << vec.size() << '\n';
	for (int i=0;i<vec.size();i++) {
		cout << vec[i].size();
		for (int j=0;j<vec[i].size();j++)cout << ' ' << vec[i][j];
		cout << '\n';
	}
	return 0;
}

Measured memory_bytes: 40068
n = int(input()) + 1

k = 50
while ~n >> k & 1:
    k -= 1
k -= 1

a = []
b = []
now = 1
while k >= 0:
    a = a + [now]
    b = b + [now]
    now += 1

    if n >> k & 1:
        a = a + [now]
        b = [now] + b
        now += 1

    k -= 1

print(len(a + b))
print(*(a + b))

Measured memory_bytes: 3064
<?php
$s = trim(fgets(STDIN));
        $arr = [
            'SUN' => 7,
            'MON' => 6,
            'TUE' => 5,
            'WED' => 4,
            'THU' => 3,
            'FRI' => 2,
            'SAT' => 1,
        ];
 
        echo $arr[$s];

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

int main() {
    int N, X;
    cin >> N >> X;
    vector<int> L(N);
    int i;
    rep(i, N) {
        cin >> L[i];
    }

    int ans = 1;
    int d = 0;
    rep(i, N) {
        d += L[i];
        if (d <= X) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
  int N, n, cont;
  cin >> N;
  while (true) {
    cont=0;
    n=N;
    while (n>=10) {
      if (n%10==n%100/10) {
        n/=10;
        continue;
      }
      cont=1;
      break;
    }
    if (cont==0) {break;}
    N++;
  }
  cout << N << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

const double PI = acos(-1);

int main() {
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double x=0.5*(h*60+m);
    double y=6*m;
    double z=0;
    
    if(x==y){
        cout<<abs(a-b)<<endl;
        return 0;
    } 
    if(x>y) z=x-y;
    else z=y-x;
    if(z==180){
        cout<<a+b<<endl;
        return 0;
    }
    if(z>180) z=360-z;

    z=z*PI/180;
    //cout<<z<<endl;

    double ans=sqrt(a*a+b*b-2*a*b*cos(z));

    cout<<setprecision(15)<<ans<<endl;

}



Measured memory_bytes: 4136
from functools import reduce
N = int(input())
g = 10 ** 9 + 7


def mul(a, b):
  return (a * b) % g

def adda(a, p1, p2):
    for x in range(len(a)):
        a[x] = p1[x] + p2[x]

d = []
DP = [[0 for _ in range(N+1)] for _ in range(N+1)]
ans = [0 for _ in range(N+1)]
for i in range(2, N+1):
  for j in (x for x in d if x * x <= N):
    if i % j == 0:
      adda(DP[i], DP[j], DP[i//j])
      break
  else:
    d.append(i)
    DP[i][i] = 1
  adda(ans, ans, DP[i])

print(reduce(mul, [x + 1 for x in ans[1:N+1]]))


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

int main(){

  int N; cin >> N;
  vector<int> d(N);
  for(int i = 0 ;i < N; i++){
    cin >> d[i];}
  ll sum = 0;
  for(int i = 0; i < N-1; i++){
    for(int j = i+1; j < N; j++){
      sum += d[i]*d[j];
    }
  }

  cout << sum << endl; return 0;}

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

int LCS(string x,string y){
	int xs,ys;
	xs=x.size();ys=y.size();
	int dp[xs+1][ys+1];
	for(int i=0;i<xs+1;i++)
		for(int j=0;j<ys+1;++j)
			dp[i][j]=0;
	for(int i=0;i<xs+1;i++){
		for(int j=0;j<ys+1;++j){
			if(i==0||j==0)dp[i][j]=0;
			else{
				if(x[i-1]==y[j-1])dp[i][j]=dp[i-1][j-1]+1;
				else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	return dp[xs][ys];
}


int main(){
	int n;
	cin >> n;
	string s1,s2;
	for(int i=0;i<n;i++){
		cin >> s1 >> s2;
		cout << LCS(s1,s2) << endl;
	}
}


Measured memory_bytes: 7156
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int dp[101][4][4][4];   /* dp[i][c1][c2][c3] : 長さiで末尾3文字がc3,c2,c1のときの条件を満たす文字列の総数
                           ただし、'A' = 0, 'G' = 1, 'C' = 2, 'T' = 3 と対応している */

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

    dp[0][3][3][3] = 1;
    //i文字目まで決める
    rep(i, n) {
        //i文字目を全通り試す
        rep(c1, 4) {
            //i-1文字目を全通り試す
            rep(c2, 4) {
                //i-2文字目を全通り試す
                rep(c3, 4) {

                    if(dp[i][c1][c2][c3] == 0) {
                        continue;
                    }

                    //i+1文字目に置く文字を全通り試す
                    rep(next, 4) {

                        //末尾4文字が?AGCになるときはダメ
                        if(next == 2 && c1 == 1 && c2 == 0) {
                            continue;
                        }
                        //末尾4文字が?GACになるときはダメ
                        if(next == 2 && c1 == 0 && c2 == 1) {
                            continue;
                        }
                        //末尾4文字が?ACGになるときはダメ
                        if(next == 1 && c1 == 2 && c2 == 0) {
                            continue;
                        }
                        //末尾4文字がA?GCになるときはダメ
                        if(next == 2 && c1 == 1 && c3 == 0) {
                            continue;
                        }
                        //末尾4文字がAG?Cになるときはダメ
                        if(next == 2 && c2 == 1 && c3 == 0) {
                            continue;
                        }

                        //それ以外のときはok
                        dp[i+1][next][c1][c2] += dp[i][c1][c2][c3];
                        dp[i+1][next][c1][c2] %= mod;
                    }
                }
            }
        }
    }

    //求める答えは長さnのときの場合の数の総数
    int ans = 0;
    rep(c1, 4) {
        rep(c2, 4) {
            rep(c3, 4) {
                ans += dp[n][c1][c2][c3];
                ans %= mod;
            }
        }
    }

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

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();

    for i in 1.. {
        let _ = stdin.read_line(&mut buf);
        let x = i64::from_str(buf.trim()).unwrap();
        buf.clear();

        if x == 0 { break; }

        println!("Case {}: {}", i, x);
    }
}



Measured memory_bytes: 5028
#include<iostream>
#include<algorithm>
#include<vector>
using lint=int64_t;
using namespace std;

int main()
{
	int N;
	vector<int> A;
	
	cin >> N;
	for(int i=0;i<N;i++)
	{
		int tmp;
		cin >> tmp;
		A.push_back(tmp);
	}
	
	A.erase(unique(A.begin(),A.end()),A.end());
	
	int cnt=0;
	for(int i=1;i<A.size()-1;i++)
	{
		if((A[i]>A[i-1] && A[i]>A[i+1]) || (A[i]<A[i-1] && A[i]<A[i+1]))
		{
			cnt++;
			i++;
		}
	}
	
	cout << cnt+1 << endl;
	return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back

typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

const int mod = (int)1e9 + 7;
const int mod2 = 998244353;

ll exp(ll taban, ll us, ll md) {
    ll carpan = taban % md;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % md;
        temp /= 2;
        carpan = (carpan*carpan) % md;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}
ll mul(ll a, ll b, ll md){
	return a*b % md;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; ll k; cin>>n>>k;
	vector<int> vec(n+1);
	for(int i = 1; i <= n; i++){
		cin>>vec[i];
	}
	int vis[n+1] = {};
	vector<int> ans;
	int cur = vec[1];
	int u = 1;
	while(!vis[cur]){
		vis[cur] = u;
		u++;
		ans.pb(cur);
		cur = vec[cur];
	}
	int m = ans.size();
	int period = u - vis[cur];
	if(k < m - period){
		cout<<ans[k - 1]<<"\n";
	}else{
		k -= m - period;
		//ilk == m - period
		cout<<ans[(k-1) % period + m - period]<<endl;
	}
}

Measured memory_bytes: 5844
package main

import (
  "bufio"
  "fmt"
  "os"
  "strconv"
)

const mod int64 = 1000000007

func main() {
  n := NextInt()
  c := []int64{}
  m := int64(0)
  for i:=0;i<n;i++ {
    t := NextInt64()
    if i == 0 || t != c[len(c)-1] { c = append(c,t) }
    if m < t { m = t }
  }
  n = len(c)
  dp := make([]int64,n)
  nm := make([]int64,m+1)
  dp[0] = 1
  for i:=0;i<n;i++ {
    dp[i] = (dp[i]+nm[c[i]])%mod
    if i == 0 {
      nm[c[i]] = 1
      continue
    }
    nm[c[i]] = (nm[c[i]]+dp[i-1])%mod
    dp[i] = (dp[i]+dp[i-1])%mod
  }
  fmt.Println(dp[n-1])
}

var reader = bufio.NewReaderSize(os.Stdin,1000000)
func NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n,_ := strconv.Atoi(NextLine())
  return n
}
func NextInt64() int64 {
  n,_ := strconv.ParseInt(NextLine(),10,64)
  return n
}

Measured memory_bytes: 11008
package main

import "fmt"

func main() {
	var n, l int
	fmt.Scan(&n, &l)
	s := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&s[i])
	}

	for i := 0; i < n-1; i++ {
		for j := i + 1; j < n; j++ {
			if s[i] > s[j] {
				s[i], s[j] = s[j], s[i]
			}
		}
	}
	for _, v := range s {
		fmt.Print(v)
	}
	fmt.Println()
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring> 
using namespace std;
int n, m, k;
int cnt[15][1005];
char mp[15][1005];
bool vis[1005];
int cut[20], top;
int ans = 0x7f7f7f7f;
int cal(int x1, int x2, int y1, int y2) {
    return cnt[x2][y2] - cnt[x2][y1 - 1] - cnt[x1 - 1][y2] + cnt[x1 - 1][y1 - 1];
}
void dfs(int pos) {
    cut[++top] = pos;
    if (pos == n) {
        memset(vis, 0, sizeof(vis)); 
        int sx, sy, lst = 0, tmp = 0;
        for (int j = 1; j <= m; j++) {
            for (int i = 1; i <= top; i++) {
                sx = cut[i - 1] + 1, sy = lst + 1;
                if (cal(sx, cut[i], sy, j) > k) {
                    if (lst == j - 1) {
                        top--;
                        return;
                    } else {
                        sy = j;
                        if (!vis[j - 1]) tmp++, vis[j - 1] = 1;
                    }
                }
            }
            if (vis[j - 1]) lst = j - 1;
        }
        ans = min(ans, tmp + top - 1);
        top--;
        return;
    }
    for (int i = pos + 1; i <= n; i++) {
        dfs(i);
    }
    top--;
}
int main() {
    scanf("%d%d%d", &n, &m, &k);
    for (int i = 1; i <= n; i++) {
        scanf("%s", mp[i] + 1); 
        for (int j = 1; j <= m; j++) {
            cnt[i][j] = cnt[i - 1][j] + cnt[i][j - 1] - cnt[i - 1][j - 1] + mp[i][j] - '0';
        }
    }
    for (int i = 1; i <= n; i++) {
        dfs(i);
    }
    cout << ans;
    return 0;
}


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

int main() {
	int a, b, c, aa, bb, cc, cnt = 0;
	cin>>a>>b>>c;
	while(1) {
		if(a%2 || b%2 || c%2) {
			cout<<cnt<<endl;
			break;
		} else if(cnt > 1000) {
			cout<<-1<<endl;
			break;
		}
		aa = b/2 + c/2;
		bb = a/2 + c/2;
		cc = a/2 + b/2;
		a = aa;
		b = bb;
		c = cc;
		cnt++;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()  
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    string s;
    cin >> s;
    if (s == "ARC") {
        cout << "ABC\n";
    }
    else {
        cout << "ARC\n";
    }
	// your code goes here
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

i64 m[100];
i64 cnt[100];

int main() {
  i64 N;
  cin >> N;
  i64 X;
  cin >> X;
  m[0] = 1;
  cnt[0] = 1;
  for(int i = 1;i <= 50;i++) {
    m[i] = m[i - 1] * 2 + 1;
    cnt[i] = cnt[i - 1] * 2 + 3;
  }

  i64 ans = 0;
  i64 i = N;
  while(true) {
    if(i == 0) {
      X -= 1;
      ans++;
      break;
    }
    X -= 1;
    if(X == 0) break;
    if(cnt[i - 1] >= X) {
      i -= 1;
      continue;
    }
    X -= cnt[i - 1];
    ans += m[i - 1];
    X -= 1;
    ans++;
    if(X == 0) break;
    if(cnt[i - 1] >= X) {
      i -= 1;
      continue;
    }
    X -= cnt[i - 1];
    ans += m[i - 1];
    break;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define IOS 		ios_base::sync_with_stdio(false);; cin.tie(0); cout.tie(0)
#define sd(n)       scanf("%d", &n)
#define sdd(a,b)    scanf("%d %d", &a, &b)
#define sddd(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sld(n)      scanf("%lld", &n)
#define slld(a,b)   scanf("%lld %lld", &a, &b)
#define sllld(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define slu(n)      scanf("%llu", &n)
#define sllu(a,b)   scanf("%llu %llu", &a, &b)
#define slllu(a,b,c) scanf("%llu %llu %llu", &a, &b, &c)
#define ss(a)		scanf("%s", a)
#define inStrAftInSome cin.ignore(numeric_limits<streamsize>::max(),'\n')		//input string(with whitespace) after input something(char, int, bool, str)
#define all(a) 		a.begin(),a.end()
#define unq(x)      x.erase(unique(all(x)), x.end()
#define mp 			make_pair
#define mt 			make_tuple
#define sz(av) 		int((av).size())					//return size of vec
#define CLR(arr)    memset(arr, 0, sizeof(arr))			//assign 0 to whole arr
#define SET(vec)    memset(arr, -1, sizeof(arr))		//assign -1 to whole arr
#define CLRV(vec)	fill(vec.begin(), vec.end(), 0)		//assign 0 to whole vec
#define SETV(vec,n,a) vec.assign(n, a)	
#define vtd(rowsize,colsize,type,name) 		vector < vector <type> > name(rowsize,vector <type> (colsize)); 	//assign to first n elements value a in vec
#define SETB(a)		memset(a, true, sizeof(a))			//boolean array initialize by true value
#define CLRB(a)		memset(a, false, sizeof(a))			//boolean array initialize by false value
#define vintitr 	vector<int>::iterator
#define vlnlnitr 	vector<long long>::iterator
#define sintitr 	set<int>::iterator
#define slnlnitr 	set<long long>::iterator
#define aa			first
#define bb			second
#define MOD 		1000000007
#define PI 			acos(-1.00)
#define psb 		push_back
#define ppb			pop_back
#define ppb			pop_back
#define psf			push_front
#define ppf			pop_front
#define in 			inset
#define rep(i, n) 	for(int i=0; i<n; i++)
#define repi(i,j,n) for(int i=j; i<n; i++)
#define rof(i, n)   for(int i=n-1; i>=0; i--)
#define roff(i, n, f)	for(int i = n-1; i>=f; i--)
#define min3(a,b,c) (min((c),min((a),(b))))
#define max3(a,b,c) (max((a),max((b),(c))))
#define __lcm(a, b)	a*b / __gcd(a, b)
#define __builtin_zerocount(a)	8*sizeof(a)-__builtin_popcount(a)-__builtin_clz(a)-__builtin_ctz(a)
#define D(t)        cerr << #t " = " <<t  << '\n'
#define DBG         cerr << "Hi!" << '\n'
 
 
typedef long long	 		ll;
typedef unsigned long long	llu;
typedef long double			ld;
typedef vector< int > 		vi;
typedef vector< vi >		vvi;
typedef pair<int, int> 		pii;
typedef tuple<int,int,int>  tiii;

int main()
{
	IOS;
	int n, k;	cin >> n >> k;
	vi H(n+1);
	H[n] = INT_MAX;
	rep(i, n)	cin >> H[i];
	vi dp(n, INT_MAX);
	dp[0] = 0;
	rep(i, n){
		repi(j, 1, k+1){
			if(i+j < n)
				dp[i+j] = min(dp[i+j], dp[i] + abs(H[i]-H[i+j]));
		}
	}
	cout << dp[n-1] << endl;
    return 0;
}


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

using namespace std;

int n, k;
int arr[500100];
vector<int> lis[500100];
map<int,int> mi;

int ans[500100];
int dfs(int here, int s = 1) {
    int sz = 1;
    for (int &there : lis[here]) {
        sz += dfs(there,s+sz-1);
    }
    ans[here]=s+sz-1;
    return sz;
}

int main() {
    int i;

    scanf("%d%d",&n,&k);
    for (i=1;i<=n;i++) scanf("%d",&arr[i]);
    mi[n+1] = 0;
    for (i=1;i<=n;i++) {
        if (i>k) mi.erase(arr[i-k]);
        mi[arr[i]] = i;
        auto it = mi.find(arr[i]);
        it++;
        lis[(*it).second].push_back(i);
    }
    dfs(0);
    for (i=1;i<=n;i++) printf("%d\n",ans[i]);

    return 0;
}


Measured memory_bytes: 58240
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF=1001001001;
using ll=long long;
 
int main() {
  vector<int> n={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin>>k;
  cout<<n.at(k-1)<<endl;

}

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

#define sc second
#define fr first
#define mk make_pair
#define pb push_back
#define int long long

using namespace std;

const int N = (1e6 + 5);
const int inf = (1e18 + 7);

int n;
int a[N];
int ans = inf;
int sl,sr,now;

vector <pair<int,int> > v;

main () {
    cin >> n;

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

    now = 1;

    for (int i = 1; i <= n; i ++) {
        sr += a[i];
        while (now <= i && abs(sl - sr) >= abs(sl + a[now] - (sr - a[now])))
            sl += a[now],sr -= a[now],now ++;
        v.pb(mk(min(sl,sr),max(sl,sr)));
    }
    sl = sr = 0;
    now = n;
    for (int i = n; i >= 2; i --) {
        sr += a[i];
        while (now >= i && abs(sl - sr) >= abs(sl + a[now] - (sr - a[now])))
            sl += a[now],sr -= a[now],now --;
        ans = min(ans,max(sl,max(sr,v[i - 2].sc)) - min(sl,min(sr,v[i - 2].fr)));
    }
    cout << ans << endl;
}


Measured memory_bytes: 7920
N = int(input())
B = list(map(int, input().split()))
A = [0]*(len(B)+1)

A[0] = B[0]
for i in range(len(B)):
    if A[i]>=B[i]:
        A[i]=B[i]
    A[i+1]=B[i]
print(sum(A))

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

int main() {
  string s;
  int k;
  cin >> s >> k;
  int n = s.size();
  if(n == 1){
    int rest = k % 26;
    int g = s[0] - 'a';
    g += rest;
    g %= 26;
    s[0] = g + 'a';
    cout << s << endl;
    return 0;
  }
  rep(i, n){
    int a = s[i] - 'a';
    if(a == 0)continue;
    if(26 - a <= k){
      s[i] = 'a';
      k -= 26 - a;
    }
  }
  if(k > 0){
    int rest = k % 26;
    int g = s[n-1] - 'a';
    g += rest;
    g %= 26;
    s[n-1] = g + 'a';
  }
  cout << s << endl;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
int n,m;
char r[600][600],b[600][600],a[600][600];
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i+=2)
        for(int j=1;j<=m;j++)
            r[i][j]='#';
    for(int i=2;i<=n;i+=2)
        for(int j=1;j<=m;j++)
            r[i][j]='.';
    for(int i=2;i<=n;i+=2)
        for(int j=1;j<=m;j++)
            b[i][j]='#';
    for(int i=1;i<=n;i+=2)
        for(int j=1;j<=m;j++)
            b[i][j]='.';
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            char cur;
            cin>>cur;
            if(cur=='#'){
                r[i][j]='#';
                b[i][j]='#';
            }
        }
    for(int i=1;i<=n;i++)
        r[i][1]='#',b[i][1]='.';
    for(int i=1;i<=n;i++)
        r[i][m]='.',b[i][m]='#';
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++)
          cout<<r[i][j];
        cout<<endl;
    }
    cout<<endl;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
          cout<<b[i][j];
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 1280
#-*-coding:utf-8-*-

def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    threshold = round(sum(a_list) / n)
    #threshold1 = -(-sum(a_list) // n)
    #threshold2 = sum(a_list) // n
    ans = 0
    #ans1 = 0
    #ans2 = 0
    for i in a_list:
        ans += (i - threshold) ** 2
        #ans1 += (i - threshold1) ** 2
        #ans2 += (i - threshold2) ** 2

    print(ans)
    #print(min(ans1, ans2))

if __name__ == '__main__':
    main()

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

int main()
{
	int a,b,c,d,sum=0;
	string s;

	cin>>s;
    
    for(int i=0;i<3;i++)
    {
        if(s[i]=='1')
            sum++;
    }
	cout<<sum;
	return 0;
}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int maxn=2*1e5+5;
bool vis[maxn];
void SieveOfEratosthenes(int n,int x)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {

        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }

    for (int p=2; p<=n; p++)
        if (prime[p] && p>=x)
        {
            cout << p <<endl;
            return;


        }


}
int main()
{
    FAST
    int a;
    cin>>a;
    SieveOfEratosthenes((int)1e6+1,a);



    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;


void alchemist()
{
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) cin >> v[i];

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

  double v_sum = v[0];
  for (int i = 1; i < n; ++i) v_sum = (v_sum + v[i]) / 2;

  cout << v_sum << "\n";
}


void lower_atc()
{
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; ++i) cin >> h[i];

  int tmp = 0, v_max = 0;
  for (int i = 0; i < n; ++i)
  {
    if ((i != n - 1) && h[i] >= h[i + 1]) ++tmp;
    else
    {
      v_max = max(v_max, tmp);
      tmp = 0;
    }
  }

  cout << v_max << "\n";
}


void maximal_value()
{
  int n;
  cin >> n;
  vector<int> b(n - 1);
  for (int i = 0; i < n - 1; ++i) cin >> b[i];

  vector<int> a(n);
  for (int i = 0; i < n; ++i)
  {
    if (i == 0)          a[i] = b[i];
    else if (i == n - 1) a[i] = b[i - 1];
    else                 a[i] = min(b[i - 1], b[i]);
  }

  cout << accumulate(a.begin(), a.end(), 0) << "\n";
}

int main()
{
  alchemist();
  //lower_atc();
  //maximal_value();
}


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

typedef double f64;
typedef long long i64;
typedef int i32;
typedef pair<i32, i32> pi32;
typedef unsigned long long u64;
typedef unsigned int u32;
typedef vector<i32> vi32;
typedef deque<i32> di32;

#define all(c) (c).begin(), (c).end()
#define REP(i, a, b) for (auto i = a; i < b; i++)
#define REPA(i, a, b, acc) for (auto i = a; i < b; i += acc)
#define PB push_back
#define PF push_front
#define PRINT(x) cout << #x ": " << (x) << endl;
#define TR(c, it) for (auto(it) = (c).begin(); (it) != (c).end(); (it)++)
#define MAX_PRECISION cout << setprecision(numeric_limits<double>::max_digits10);

i32 main() {
  ios::sync_with_stdio(false);  // Makes IO faster, remove this line if C style scanf/printf needed.

  i32 a, b, c;
  cin >> a >> b >> c;
  bool works = true;
  if (a > c && b > c) {
    works = false;
  }
  if (a < c && b < c) {
    works = false;
  }
  cout << (works ? "Yes" : "No") << endl;
}


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

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size();
  bool OK = true;
  rep(i,n) {
    if(s[i] != t[i]) OK = false;
  }
  if(OK) puts("Yes");
  else puts("No");
}


Measured memory_bytes: 3576
w,h,n = map(int,raw_input().split())
l = []
for i in range(n):
    row = map(int,raw_input().split())
    l.append(row)

minX =  map(lambda i:i[0], filter(lambda i:i[2]==1,l))
minX.append(0)
minX = max(minX)

maxX =  map(lambda i:i[0], filter(lambda i:i[2]==2,l))
maxX.append(w)
maxX = min(maxX)

minY =  map(lambda i:i[1], filter(lambda i:i[2]==3,l))
minY.append(0)
minY = max(minY)

maxY =  map(lambda i:i[1], filter(lambda i:i[2]==4,l))
maxY.append(w)
maxY = min(maxY)

X = maxX-minX
Y = maxY-minY
if X>0 and Y>0:
    print X*Y
else:
    print 0

Measured memory_bytes: 2696
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = InputNumList();
            var a = ab[0];
            var b = ab[1];

            var ans = 0;

            var del = b - a;
            var sum = 0;
            for (int i = 1; i < del; i++)
            {
                sum += i;
            }
            ans = sum - a;
            WriteLine(ans);
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}

Measured memory_bytes: 13268