akhauriyash/Code-Regression huggingface dataset:
# ARC081c
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    from collections import Counter
    import heapq

    n = int(input())

    def fun(i):
        return -int(i)

    a = list(map(fun, input().split()))
    heapq.heapify(a)

    b = []
    heapq.heapify(b)
    ln = 0
    cou = 0
    mn = 0
    while(len(a) > 0):
        i = -heapq.heappop(a)
        # print(i)
        if ln != i:
            ln = i
            cou = 0
        cou += 1
        if cou > 1:
            heapq.heappush(b, -i)
            cou = 0
    try:
        print(heapq.heappop(b)*heapq.heappop(b))
    except:
        print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14748
#include<bits/stdc++.h>
#define ll long long
#define N 4000
#define M 998244353
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
ll dp[N][N][2];
int n,s;
int a[N];
ll run(int idx,int now,int al)
{
    if(dp[idx][now][al]!=-1)
        return dp[idx][now][al];
   // cout<<idx<<' '<<now<<' '<<al<<endl;
    if(idx==n)
    {
        return now==s;
    }

    ll ans=0;
    if(al==0)
    {
        ans=2*run(idx+1,now,0);
        ans%=M;
        if(a[idx]+now<=s)
        {
            ans+=run(idx+1,a[idx]+now,1);
        }
        ans%=M;
    }
    else
    {
        ans=2*run(idx+1,now,1);
        ans%=M;
        if(now+a[idx]<=s)
            ans+=run(idx+1,now+a[idx],1);
        ans%=M;
    }
    return dp[idx][now][al]=ans;
}

main()
{
    memset(dp,-1,sizeof dp);
    cin>>n>>s;
    for(int i=0;i<n;i++)
        cin>>a[i];
    cout<<run(0,0,0)<<endl;;
   // cout<<run(2,0,0);
}


Measured memory_bytes: 253884
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((int)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

void print(Vl v){
    rep(i, 0, sz(v)){
        if(i) cout << " ";
        cout << v[i];
    }
    cout << endl;
}

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

ll N, M, X;
Vl C;
vector<vector<ll>> A;
ll ans = INF;


void saiki(ll n, ll sum, Vl a){
    if(n == N){
        bool f = true;
        rep(j, 0, M){
            if(a[j] < X) f = false;
        }
        if(f){
            chmin(ans, sum);
        }
    }else{
        saiki(n+1, sum, a);
        sum += C[n];
        rep(j, 0, M){
            a[j] += A[n][j];
        }
        saiki(n+1, sum, a);
    }
}

int main() {
	cin >> N >> M >> X;
    C.resize(N);
    A.resize(N);
    rep(i, 0, N){
        A[i].resize(M);
    }
    rep(i, 0, N){
        cin >> C[i];
        rep(j, 0, M) cin >> A[i][j];
    }

    Vl B(M, 0);
    saiki(0, 0, B);

    if(ans == INF){
        co(-1);
    }else{
        co(ans);
    }

    return 0;
}


Measured memory_bytes: 3604
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll mod=1e9+7;
ll N,K;
vector<ll> v;
ll memo[500][500];
bool vis[500][500];
ll sol(ll l,ll r){
  if(l==r)return 0;
  if(vis[l][r])return memo[l][r];
  vis[l][r]=1;
  ll mi=1e18;
  for(ll i=l;i<r;i++){
    mi=min(mi,(sol(l,i)+sol(i+1,r)));
  }
  for(ll i=l;i<=r;i++){
    mi+=v[i];
  }
  return memo[l][r]=mi;
}
signed main(){
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
		cin>>N;
		for(ll i=0;i<N;i++){
      ll a;
      cin>>a;
      v.push_back(a);
		}

		cout<<sol(0,N-1);
    return 0;
}

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

using namespace std;

int main()
{
    int N, X, Y;
    cin >> N >> X >> Y;
    int cost[N][N];
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if(i==j) 
            {
                cost[i][j] = 0;
            }
            else
            {
                 cost[i][j] = N;
            }
            
           
        }
        
    }
    
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if(i == j) continue;
            int tmp1 = min(cost[i][j], abs(j - i));
            int tmp2 = min(cost[j][i], abs(j - i));
            cost[i][j] = tmp1;
            cost[j][i] = tmp2;
        }
    }
    cost[X - 1][Y - 1] = 1;
    cost[Y - 1][X - 1] = 1;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if(i == j) continue;
            int tmp1 = min(cost[i][j], cost[i][X-1] + cost[X-1][Y-1] + cost[Y-1][j]);
            int tmp2 = min(cost[j][i], cost[i][X-1] + cost[X-1][Y-1] + cost[Y-1][j]);
            cost[i][j] = tmp1;
            cost[j][i] = tmp2;
        }
    }
    
    int ans[N];
    for (int i = 0; i < N; i++)
    {
        ans[i] = 0;
    }
    
    for (int i = 0; i < N - 1; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            ans[cost[i][j]-1]++; 
        }
    }
    for (int i = 0; i < N-1; i++)
    {
        cout << ans[i] << endl;
    }
    
}


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

int main() {
    string a, s, c;
    cin >> a >> s >> c;
    cout << 'A' << s.at(0) << 'C' << endl;
    return 0;
}

Measured memory_bytes: 3608
def pdebut(s):
	o = 0
	for c in s:
		if c=='(':o+=1
		else: o-=1
		if o<0 : return False
	return o>=0
	
def pfin(s):
	c = 0
	for o in s[::-1]:
		if o==')':
			c+=1
		else:c-=1
		if c<0: return False
	return c>=0
	
def valuer(s):
	o = 0
	for c in s:
		if c=='(':o+=1
		else: o-=1
	return o
	
n = int(input())
val = [0]*(n+1)
tab = []
debut = []
fin = []
milieu = []
for i in range(n):
	s = input()
	tab.append(s)
	if pdebut(s):
		debut+=[i]
	elif pfin(s):
		fin+=[i]
	else:
		val[i] = valuer(s)
		milieu+=[i]

def cle(x):
	return -x[1]		
couples = [[i,val[i]] for i in milieu]
couples.sort(key = cle)

S = "".join(tab[i] for i in debut)
S+="".join(tab[c[0]] for c in couples)
S+= "".join(tab[i] for i in fin)

# ~ print("debut",debut)
# ~ print("milieu",milieu)
# ~ print("fin",fin)

# ~ print(S)

def Bon(s):
	o = 0
	for c in s:
		if c=='(':o+=1
		else: o-=1
		if o<0 : return False
	return o==0
print("Yes" if Bon(S) else "No")


Measured memory_bytes: 76340
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=mpowe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
std::vector<string> v ;
void permute(string str, string out) 
{ 
    // When size of str becomes 0, out has a 
    // permutation (length of out is n) 
    if (str.size() == 0) 
    { 
        v.pb(out); 
        return; 
    } 
  
    // One be one move all characters at 
    // the beginning of out (or result) 
    for (int i = 0; i < str.size(); i++) 
    { 
        // Remove first character from str and 
        // add it to out 
        permute(str.substr(1), out + str[0]); 
  
        // Rotate string in a way second character 
        // moves to the beginning. 
        rotate(str.begin(), str.begin() + 1, str.end()); 
    } 
}
int main()
{
    fastio();
    int n;
    cin>>n;
    string s="";
    for(int i=1;i<=n;i++)
    {
        s=s+to_string(i);
    }
    permute(s, "");
    sort(all(v));
    string a="",b="";
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        a=a+to_string(x);
    }
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        b=b+to_string(x);
    }
    //cout<<a<<" "<<b<<endl;
    int ac,bc;
    for(int i=0;i<v.size();i++)
    {
        if(v[i]==a)
        {
            ac=i;
        }
        if(v[i]==b)
        {
            bc=i;
        }
    }
    cout<<abs(ac-bc)<<endl;
}

Measured memory_bytes: 2424
# -*- coding: utf-8 -*-
def inpl(): return tuple(map(int, input().split()))

INF = float("inf")

V, E = inpl()
adj = [[] for _ in range(V)]
D = [[INF]*V for _ in range(V)]

for _ in range(E):
    s, t, d = inpl()
    D[s][t] = d
    D[t][t] = d

for v in range(V):
    D[v][v] = 0 

for k in range(V):
    for i in range(V):
        if D[i][k] == INF:
            continue
        for j in range(V):
            D[i][j] = min(D[i][j], D[i][k] + D[k][j])

for v in range(V):
    if D[v][v] < 0:
        print("NEGATIVE CYCLE")
        break
else:
    for d in range(V):
        print(" ".join(map(str, D[d])).replace("inf", "INF"))

Measured memory_bytes: 8348
#include<bits/stdc++.h>
#define MAXN 99999
#define INF 101
using namespace std;
inline int read(){
 char c=getchar();int x=0,f=1;
 while(c>'9'||c<'0'){if(c!='-')f=-1;c=getchar();}
 while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
 return x*f;
}
char s[INF][INF];
int n,m,tot,pop;
int main()
{
    n=read();
    m=read();
    for(int i=1;i<=n;++i)
     for(int j=1;j<=m;++j)
      cin>>s[i][j];
    s[0][1]=s[1][0]='#';
    for(int i=1;i<=n;++i)
     for(int j=1;j<=m;++j)
      {
      	tot=0;
      	pop=0;
      	if(s[i][j]=='#')
      	 {
      	 	if(s[i][j+1]=='#')
      	 	 tot++;
      	 	if(s[i+1][j]=='#')
      	 	 tot++;
      	 	if(s[i-1][j]!='#')
      	 	 pop++;
      	 	if(s[i][j-1]!='#')
      	 	 pop++;
         }
        if(tot==2||pop==2)
         {
         	cout<<"Impossible\n";
         	return 0;
         }
      }
    cout<<"Possible\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int total = 0;
		for(int i = 0;i < n;i++){
			a[i] = sc.nextInt();
		}

		for(int j = 0;j < n;j++){
			for(int k = j+1;k < n;k++){
				total += a[j] * a[k];
			}
		}

		System.out.println(total);
	}

}


Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	vector<long long> a(200001);
	long long sum = 0;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
		a[v[i]]++;
	}
	for (int i = 0; i < 200001; ++i) {
		sum += a[i] * (a[i] - 1) / 2;
	}
	long long ans;
	for (int i = 0; i < n; ++i) {
		if (a[v[i]] == 0)	cout << sum << endl;
		else {
			ans = sum - (a[v[i]] * (a[v[i]] - ll(1))) / ll(2) + ((a[v[i]] - ll(1)) * (a[v[i]] - ll(2))) / ll(2);
			cout << ans << endl;
		}
	}
	return 0;
}

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

int main(){
  
  int n;
  cin>>n;
 
  int ans;
  ans=(n-2)*n/2;
  if(n%2!=0) ans++;
  cout<<ans<<endl;
  for(int i=1;i<n;i++){
    for(int j=i+1;j<=n;j++){
      if(n%2==0){if(j!=n-i+1) cout<<i<<" "<<j<<endl;}
      else {if(j!=n-i) cout<<i<<" "<<j<<endl;}
    }
  }
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

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

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    ll k = 1, m = 1;
ll n;    cin >> n;
    rep(i, n) {
        ll x; cin >> x;
        if(x%2 == 0)
        {
            m *= 2;
        }
        k *= 3;
    }
    cout << k-m;

}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> d(N);
  for( int i=0; i<N; i++ ){
    cin >> d.at(i);
  }
  
  int num = 0;
  for( int i=0; i<N; i++ ){
    num++;
    for( int j=0; j<i; j++ ){
      if( d.at(i) == d.at(j) ){
        num--;
        break;
      }
    }
  }
  
  cout << num << endl;
}


Measured memory_bytes: 3612
#include<stdio.h>

int main(){
	char S[3];
    
    //入力
	scanf("%s", &S[0]);

    //判定結果出力
    if((S[0] == S[1]) && (S[0] == S[2])){
        printf("No");
    }else{
        printf("Yes");
    }

     return 0;
}

Measured memory_bytes: 128
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var a = int.Parse(spl[0]);
        var b = int.Parse(spl[1]);

        var ary = ToIntArray(input.ReadLine(), a);

        long sum = 0;

        for(int i=0; i<a; i++) {
            var t1 = ary[i];
            var t2 = i<a-1 ? ary[i+1] : int.MaxValue;

            sum += Math.Min(b, t2-t1);
        }

        return sum;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 30236
from collections import defaultdict


def resolve():
    n = int(input())
    a = list(int(input()) for _ in range(n))
    d = defaultdict(int)
    for ai in a:
        d[ai] += 1
    ans = 0
    for v in d.values():
        ans += v % 2
    print(ans)


if __name__ == "__main__":
    resolve()


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

const int MAX_N = (int)(1e5 + 5);

int n, m;
vector<pair<int, int>> prohib;

int ans;

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &m);

  for (int i = 0; i < m; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    prohib.push_back(make_pair(a, b));
  }

  sort(prohib.begin(), prohib.end(), [](auto a, auto b) {return a.second < b.second;});

  int lastcut = prohib[0].second - 1;
  ans += 1;
  for (int i = 1; i < m; ++i) {
    if (prohib[i].first <= lastcut) continue;
    lastcut = prohib[i].second - 1;
    ans += 1;
  }

  printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  string s,t;
  int a,b;
  string u;
  cin >> s >> t >> a >> b >> u;
  if(s==u)cout<< a-1<< " " <<b << endl;
  else cout << a<< " " << b-1 <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;

int main(){
int a;
cin >> a;
if(a%10%10==3){
  cout << "bon" << endl;
}else{
  if(a%10%10==0 || a%10%10==1 || a%10%10==6 || a%10%10==8){
    cout << "pon" << endl;
  }else{
    cout << "hon" << endl;
  }
}

}

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

long long N;

int main(void){

    cin >> N;

    bool exist = false;
    long long ans = 0;
    long long tmod;
    long long lmod;
    tmod = 0;
    lmod = 7 % N;


    if (N % 10 == 2|| N % 10 == 5) {
        exist = false;
    } else {

    for (int i = 1;i <= N;i++){
        tmod = tmod + lmod;
        lmod = lmod * 10 % N;
        tmod = tmod % N;
//        cout << i << "," << tmod << "," << lmod << endl;
        if (tmod == 0) {
            ans = i;
            exist = true;
            break;
        }
    }

    }

    if (exist) cout << ans << endl;
    else cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 3516
#include <bits/stdc++.h>
using i64 = long long;

int ask(const std::deque<int> &v) {
    printf("? ");
    for (int a : v) printf("%d ", a);
    printf("\n");
    fflush(stdout);

    char buf[10];
    scanf("%s", buf);
    if (buf[0] == '-') exit(0);
    return buf[0] == 'R';
}

int main() {
    int n;
    scanf("%d", &n);

    int first = -1;
    {
        std::deque<int> q;
        for (int i = 1; i <= n; i++) q.push_back(i);
        first = ask(q);
    }

    int l = 1, r = n + 1;
    while (r - l > 1) {
        int k = (l + r) / 2;
        std::deque<int> q;
        for (int i = 0; i < n; i++) q.push_back(k + i);
        int res = ask(q);
        if (res == first) l = k;
        else r = k;
    }

    std::deque<int> q;
    for (int i = 0; i + 1 < n; i++) q.push_back(r + i);

    std::vector<int> ret(2 * n + 1, -1);
    for (int i = 1; i < r; i++) {
        q.push_back(i);
        ret[i] = ask(q) == first;
        q.pop_back();
    }
    for (int i = l + n; i <= 2 * n; i++) {
        q.push_back(i);
        ret[i] = ask(q) == first;
        q.pop_back();
    }

    q.clear();
    int same = 0, diff = 0;
    for (int i = 1; i <= 2 * n; i++) {
        if (ret[i] < 0) continue;
        if (ret[i] && same < n / 2) {
            q.push_back(i);
            same++;
        } else if (!ret[i] && diff < n / 2) {
            q.push_back(i);
            diff++;
        }
    }

    for (int i = r; i < l + n; i++) {
        q.push_back(i);
        ret[i] = ask(q) == first;
        q.pop_back();
    }

    printf("! ");
    char sc = first ? 'R' : 'B', dc = first ? 'B' : 'R';
    for (int i = 1; i <= 2 * n; i++) printf("%c", ret[i] ? sc : dc);
    printf("\n");
    fflush(stdout);

    return 0;
}


Measured memory_bytes: 724
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
#======================================================#
def main():
    N = II()
    MAX=3500
    for h in range(1,MAX+1):
        for n in range(1,MAX+1):
            d = 4*h*n-N*h-N*n
            if d > 0 and (N*h*n)%d==0:
                print('{} {} {}'.format(h, n, (N*h*n)//d))
                return None

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
     
    static char[] k = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
     
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        String s = stdIn.next();
        String p = stdIn.next();
         
        boolean ans = false;
         
        IN:for(int i = 0; i < s.length(); i++) {
            for(int j = 0; j < p.length(); j++) {
                if(s.charAt((i + j) % s.length()) != p.charAt(j)) {
                    continue IN;
                }
            }
            ans = true;
            break;
        }
         
        System.out.println((ans)?"Yes":"No");
         
    }
}


Measured memory_bytes: 26192
#include <iostream>

using namespace std;

int main(){
    long long L,R,mod=2019;
    cin>>L>>R;
    int ans=3000;
    if(R-L+1>=2019){
        cout<<0<<endl;
        return 0;
    }
    for(long long i=L;i<=R-1;i++){
        for(long long j=i+1;j<=R;j++){
            int a=(i*j)%mod;
            ans=min(a,ans);
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){    
  ll A, B, C;
  cin >> A >> B >> C;
  if(A == B) cout << C << endl;
  else if(A == C) cout << B << endl;
  else cout << A << endl;
  
}


Measured memory_bytes: 256
def collatz(n):
	if n%2 == 0: return n/2
	else: return 3*n+1
s = int(raw_input())
lst = []
tmp = s
while(True):
	if tmp in lst:
		print len(lst)+1
		break
	else:
		lst.append(tmp)
		tmp = collatz(tmp)

Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
long long MOD = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;
 
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
 
int main() {
  int n;
  int k;
  int conti;
  conti = 0;
  bool pasa ;
  pasa = false;
  cin >> n >> k;
  ll h[n];
  ll dp[n];
 
  rep(i, n) { cin >> h[i]; }
  rep(i, n) { dp[i] = INF; }
 
  dp[0] = 0;
 
  for (int i = 1; i < n; i++) {
    conti ++;
    pasa = true;
    for (int j = 1; j < k + 1; j++) {
      if(pasa = true && conti > 0){
//printtf("Pasa")
}
      
      if (i >= j) {
        chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
      }
    }
  }
  cout << dp[n - 1] << endl;
  return 0;
}

Measured memory_bytes: 1920
//header file---{{{
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
//end.header file---}}}
using namespace std;


//template---{{{
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b); i > (a); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)

#define all(i) (i).begin(), (i).end();
//end.template ---}}}

int main() {

    int N, X;
    int m[100];
    int i;

    cin >> N >> X;

    REP(i, N) cin >> m[i];

    int origin = X;
    int donut_num = 0;

    REP(i, N) {
        origin -= m[i];
        donut_num++;
    }

    sort(m, m + N);

    for (i = 0; origin >= m[0]; ++i) {

        origin -= m[0];
        donut_num++;
    }

    cout << donut_num << endl;

    return (0);
}



Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
char ca[200005];
int main(){
	int n;
	long long int s=0;
	int a=0,b=0;
	cin>>ca;
	n=strlen(ca);
	for(int i=n-1;i>=0;i--){
		if(ca[i]=='W')a++;
		else s+=a;
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 384
# coding: UTF-8
import math
a,b,c,d,e = map(int, input().split())
flag = 0
flaga = 0
flagb = 0
cost = 0
if(a+b< 2*c):
    cost = a*d + b*e
    flag = 1
if(2*c<=a):
    flaga = 1#aが余ったらc2枚買えばいい
if(2*c<=b):
    flagb = 1#bが余ったらc2枚買えばいい

if(flag == 0):#同じ枚数分はcを買う
    if(d<=e):#bを追加で買わな
        if(flagb == 1):
            cost += e * 2 * c
        else:
            cost += d * 2 * c + (e-d)*b
    else:
        if(flaga == 1):
            cost += d * 2 * c
        else:
            cost += e * 2 * c + (d-e)*a
print(cost)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector< vector<int> > se;
	FOR(i,0,(1<<n)){
		vector<int> p;
		FOR(j,0,n){
			if(i&(1<<j)){
				p.push_back(j);
			}
		}
		se.push_back(p);
	}
	FOR(i,0,se.size()){
		cout << i << ":";
		for(auto x:se[i]){
			cout << " " << x;
		}
		cout << endl;
	}
}



Measured memory_bytes: 21648
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
map<ll, int, greater<ll>> mp;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  REP(i, n) {
    ll b;
    cin >> b;
    mp[b]++;
  }

  ll h = 0;
  ll w = 0;
  for (auto const& x: mp) {
    if(x.second >= 2) {
      h = x.first;
      mp[x.first] -= 2;
      break;
    }
  }

  for (auto const& x: mp) {
    if(x.second >= 2) {
      w = x.first;
      mp[x.first] -= 2;
      break;
    }
  }

  cout << (w * h) << endl;
}


Measured memory_bytes: 6528
#include <iostream>
#include<vector>
#include <bits/stdc++.h> 
#include<math.h>
#include<set>
#include<algorithm>
#define ll long long
using namespace std;
const double pi = acos(-1.0); 
ll m=-10000000000;
ll M=998244353;
ll gcd(ll x,ll y){
    if(y==0){
        return x;
    }
    gcd(y,x%y);
}

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

ll divCount(ll n) 
{ 
    ll cnt = 0; 
    for (ll i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            // If divisors are equal, 
            // count only one 
            if (n / i == i) 
                cnt++; 
  
            else // Otherwise count both 
                cnt = cnt + 2; 
        } 
    } 
    return cnt; 
} 

double nGon(int N) 
{ 
  
    // Projection angle variation 
    // from axes 
    double proAngleVar; 
  
    // Projection angle variation 
    // when the number of 
    // sides are in multiple of 4 
    if (N % 4 == 0) { 
        proAngleVar 
            = pi * (180.0 / N) 
              / 180; 
    } 
    else { 
        proAngleVar 
            = pi * (180.0 / (2 * N)) 
              / 180; 
    } 
  
    // Distance between the end points 
    double negX = 1.0e+99, 
           posX = -1.0e+99, 
           negY = 1.0e+99, 
           posY = -1.0e+99; 
  
    for (int j = 0; j < N; ++j) { 
  
        // Projection from all N points 
        // on X-axis 
        double px = cos(2 * pi * j / N 
                        + proAngleVar); 
  
        // Projection from all N points 
        // on Y-axis 
        double py = sin(2 * pi * j / N 
                        + proAngleVar); 
  
        negX = min(negX, px); 
        posX = max(posX, px); 
        negY = min(negY, py); 
        posY = max(posY, py); 
    } 
  
    // Maximum side 
    double opt2 = max(posX - negX, 
                      posY - negY); 
  
    // Return the portion of side 
    // forming the square 
    return (double)opt2 
           / sin(pi / N) / 2; 
} 

void solve(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll s=0;
    for(int i=1;i<n;i++){
        if(a[i]<a[i-1]){
            s+=(a[i-1]-a[i]);
            a[i]=a[i-1];
        }
    }
    cout<<s;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
	int t;
	t=1;
	while(t--){
	    solve();
	}
	
	return 0;
}







//0 0 329221   


//0 0 502890  
//

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

using namespace std;

#define rep(i,a,b) for(int i = a; i<int(b);++i)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define trav(a,c) for(auto a: c)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;

struct Tree {
	typedef int T;
	const T LOW = 0;
	T f(T a, T b) { return a+b; }

	int n;
	vi s;
	Tree() {}
	Tree(int m, T def=0) { init(m, def); }
	void init(int m, T def) {
		n = 1; while (n < m) n *= 2;
		s.assign(n + m, def);
		s.resize(2 * n, LOW);
		for (int i = n; i --> 1; )
			s[i] = f(s[i * 2], s[i*2 + 1]);
	}
	void update(int pos, T val) {
		pos += n;
		s[pos] += val;
		for (pos /= 2; pos >= 1; pos /= 2)
			s[pos] = f(s[pos * 2], s[pos * 2 + 1]);
	}
	T query(int l, int r) { return que(1, l, r, 0, n); }
	T que(int pos, int l, int r, int lo, int hi) {
		if (r <= lo || hi <= l) return LOW;
		if (l <= lo && hi <= r) return s[pos];
		int m = (lo + hi) / 2;
		return f(que(2 * pos, l, r, lo, m),
				que(2 * pos + 1, l, r, m, hi));
	}
};

int main(){
	cin.sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    vi a(n);
    rep(i,0,n) {
        cin>>a[i];
        a[i]-=k;
    }
    set<ll> S;
    vi s(n+1);
    rep(i,0,n){
        s[i+1] = s[i]+a[i];
        S.insert(s[i+1]);
    }
    S.insert(0);
    map<ll,ll> comp;
    ll ind = 0;
    trav(a,S){
        comp[a] = ind;
        ++ind;
    }

    Tree st(S.size()+1);

    ll ans = 0;

    for(ll i = n-1;i>=0;--i){
        ll indNext = comp[s[i+1]];
        st.update(indNext,1);
        ll ind = comp[s[i]];
        ans += st.query(ind,S.size());
    }

    cout<<ans<<endl;
}


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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif


long long subSolve(vector<ll> v) {
    long long subtractSum = 0;
    long long answer = 0;
    for (int i = 0; i < v.size(); i++) {
        answer += v[i] * i - subtractSum;
        subtractSum += v[i];
        answer %= 1000000007;
    }
    return answer;

}

void solve(ll n, ll m, vector<ll> x, vector<ll> y) {


    cout << subSolve(x) * subSolve(y) % 1000000007 << endl;
}


void main_(istream &cin) {
    ll n;
    ll m;
    cin >> n;
    vector<ll> x(n - 1 + 1);
    cin >> m;
    vector<ll> y(m - 1 + 1);
    for (int i = 0; i <= n - 1; i++) {
        cin >> x[i];
    }
    for (int i = 0; i <= m - 1; i++) {
        cin >> y[i];
    }
    solve(n, m, x, y);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 4992
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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

using namespace std;
using namespace __gnu_pbds;

const long long MOD = 1000000007LL;
const long long INF = 1e18;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long mult_mod(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

// ree always check bounds
// int vs long long
// bitset cheese <3

vector<pair<int, int>> jobs;

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, m; cin >> n >> m;

    for(int a, b, i = 0; i < n; ++i){
        cin >> a >> b;
        jobs.push_back(make_pair(a, b));
    }

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

    priority_queue<int> pq;
    long long tot = 0;

    for(int p1 = 0, p2 = m; p2 >= 0; --p2){

        while(p1 < n && jobs[p1].first + p2 <= m){
            pq.push(jobs[p1].second);
            ++p1;
        }

        if(!pq.empty()){
            tot += pq.top(); pq.pop();
        }

    }

    cout << tot;

    return 0;
}


Measured memory_bytes: 1908
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

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

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
c = 0
m = -10**9 + 7
p = 10**9 + 7
s = 0
for e in A:
    s += abs(e)
    if e < 0:
        m = max(m,e)
        c += 1
    else:
        p = min(p,e)

if c%2 == 0:
    print(s)
else:
    print(s-2*min(-m,p))


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

constexpr unsigned int max_buf = 3e5 + 10;

int main()
{
	std::string S;
	int Q;

	std::cin >> S >> Q;

	bool reversed = false;
	std::vector<char> mae, ato;

	for (int i = 0; i < Q; i++)
	{
		int T;
		std::cin >> T;
		if (T == 1)
		{
			reversed = !reversed;
			continue;
		}

		int F;
		char C;
		std::cin >> F >> C;
		bool maeF = F == 1;
		if (reversed == maeF)
		{
			ato.push_back(C);
		}
		else
		{
			mae.push_back(C);
		}
	}

	char ans[max_buf];
	if (reversed)
	{
		char* ap = ans;
		for (auto it = ato.rbegin(); it != ato.rend(); ++it)
		{
			*ap++ = *it;
		}
		for (auto it = S.rbegin(); it != S.rend(); ++it)
		{
			*ap++ = *it;
		}
		for (auto it = mae.begin(); it != mae.end(); ++it)
		{
			*ap++ = *it;
		}
		*ap = '\0';
	}
	else
	{
		char* ap = ans;
		for (auto it = mae.rbegin(); it != mae.rend(); ++it)
		{
			*ap++ = *it;
		}
		for (auto it = S.begin(); it != S.end(); ++it)
		{
			*ap++ = *it;
		}
		for (auto it = ato.begin(); it != ato.end(); ++it)
		{
			*ap++ = *it;
		}
		*ap = '\0';
	}

	std::cout << ans;
}



Measured memory_bytes: 1280
#include <stdio.h>
#include <math.h>

#ifndef M_PI
#define M_PI 3.14159265358979323846264338327950288
#endif

int main(int argc, char** argv)
{
  double dx = 0.0, dy = 1.0;

  double x = 0, y = 0;

  int d, t;

  for (int i = 0; fscanf(stdin, "%d,%d", &d, &t) == 2; i = (i + 1) % 4) {
    if (d == 0 && t == 0)
      break;

    x += d * dx;
    y += d * dy;
    
    double r = t / 180.0 * M_PI;

    double ndx =  cos(r) * dx + sin(r) * dy;
    double ndy = -sin(r) * dx + cos(r) * dy;

    dx = ndx;
    dy = ndy;
  }
  fprintf(stdout, "%d\n%d\n", int(x), int(y));
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	string a,b,c,ans="";

	cin >>a >>b >>c;
	ans+=a[0];
	ans+=b[0];
	ans+=c[0];
	transform(ans.begin(),ans.end(),ans.begin(),::toupper);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, num[30];
	int n, w, i;
	
	scanf("%d", &w);
	scanf("%d", &n);
	
	for (i = 0; i < w; i++){
		num[i] = i + 1;
	}
	
	for (i = 0; i < n; i++){
		
		scanf("%d,%d", &a, &b);
		
		a -= 1;
		b -= 1;
		
		num[a] += num[b];
		num[b] = num[a] - num[b];
		num[a] -= num[b];
	}
	
	for (i = 0; i < w; i++){
		printf("%d", num[i]);
		
		printf("\n");
	}
	
	return (0);
}
		

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

int main() {
  int n, ans=0 ;

  scanf("%d", &n);
  if(n/100>0) ans++;
  n%=100;
  if(n/10>0) ans++;
  n%=10;
  if(n>0) ans++;

  printf("%d\n", ans);
  return 0;
}

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

int main(){
	//freopen("aa.in","r",stdin);
	int i,j,_;
	for(scanf("%d",&_);_--;){
		ll a,b;
		cin>>a>>b;
		if(a>b)swap(a,b);
		ll s=a*b;
		ll c=(ll)sqrt(s);
		ll ans;
		if(c*c==s){
			ans=(c-1)*2;
			if(a<c)--ans;
		}else{
			ans=c*2;
			if(c*(c+1)>=s)--ans;
			if(a<=c)--ans;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

ll sum;

int main(){
	int n;
	cin >> n;
	rep(i,n){
		sum+=i+1;
	}
	cout << sum << endl;
}

Measured memory_bytes: 3572
def reverse(s): 
    return s[::-1] 
  
def isPalindrome(s): 
    
    rev = reverse(s) 
  
    if (s == rev): 
        return True
    return False
def listToString(s):  

    str1 = ""  
    for ele in s:  
        str1 += ele   
   
    return str1   
    
s=input()
n = len(s)
p=int(round((n-1)/2))
q=int(round((n+3)/2))
ans = isPalindrome(s)


t1=[]
t2=[]

for i in range(0,p):
    t1.append(s[i])
for i in range(q-1,n):
    t2.append(s[i])    

ans1=isPalindrome(listToString(t1))
ans2=isPalindrome(listToString(t2))
if (ans==1 and ans1==1 and ans2==1):
    print ("Yes")
    
else:
    print("No")
   

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define BIGINF (int) 4e18 + 7
#define MOD7 1000000007
#define MOD9 1e9 + 9
#define INF  (int)2e9 + 7
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
typedef long long ll;
typedef long double ld;
typedef string str;
typedef double d;
typedef unsigned u;
typedef unsigned long long ull;

int main () {
    //freopen("inputf.txt", "r", stdin);
    //freopen("outputf.txt", "w", stdout);
    int n;
    scanf("%d", &n);
    vector<double> dp(n + 1);//probability that there was i heads so far
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
    	double head;
    	scanf("%lf", &head);
    	for (int j = i + 1; j >= 0; j--) { 
    		dp[j] = ((j == 0)? 0 : 1.0 *dp[j - 1] * head) + 1.0 * dp[j] * (1 - head); 
    	}
    }
    double ans = 0;
    for (int i = 0; i <= n; i++) {
        int tail = n - i;
        if (i > tail) {
            ans += dp[i];        
        }
    } 
    printf("%.10lf\n", ans);
    return 0;
}



Measured memory_bytes: 384
<?php
  $x = trim(fgets(STDIN));
  for($j=-119; $j<=118; $j++){
    for($i=-118; $i<=119; $i++){
      if(pow($i,5) - pow($j,5) == $x){
        echo $i." ".$j."\n";
        exit;
      }
    }
  }

Measured memory_bytes: 16160
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ri = n-1;
  int ans = 0;
  rep(i, n){
    if(s.at(i) == 'W'){
      bool f = false;
      for(; ri >= i; ri--){
        if(s.at(ri) == 'R'){
          swap(s.at(i), s.at(ri));
          f = true;
          break;
        }
      }
      if(f == true) ans++;
      else break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3752
#define DBG 0 //submit 0
#if DBG
    #include <algorithm>
    #include<array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <iostream>
    #include <cmath>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif

using namespace std;


int main(){
    int C,D,i,j,k,tmp = 0,tmpi = 0,ans = 0;
    int N;
    //string S;
    cin >> N;
    array<int, 2010> L = {0};
  	//char a = '';
    for(i=0;i<N;i++){
        cin >> L[i];
    }

  	sort(L.begin(),L.end(),greater<int>());
  
    for(i=0;i<N;i++){
      for(j=i+1;j<N;j++){
      	for(k=j+1;k<N;k++){
          if((L[i] < L[j] + L[k])&&(L[i] > L[j] - L[k]))
            ans++;
          else
            break;
        }
      }
    }

  cout << ans << endl;

}


Measured memory_bytes: 256
def hantei(h):
    mustmax = h[0]
    for hh in h:
        if hh - 1 == mustmax:
            pass
        elif hh-1 < mustmax:
            mustmax = hh
        else:
            print("No")
            return
        
    print("Yes")
    return
        

n = int(input())
h = list(map(int, input().split()))
h.reverse()
hantei(h)

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

int main()
{
    int a, b, t;
    cin >> a >> b >> t;
    cout << t / a * b << endl;
    return 0;
}

Measured memory_bytes: 3508
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> A(N + 1), B(N);
    for (int i = 0; i < N + 1; ++i) cin >> A[i];
    for (int i = 0; i < N; ++i) cin >> B[i];
    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        ll first_cnt = min(A[i], B[i]);
        ans += first_cnt;
        B[i] -= first_cnt;
        ll second_cnt = min(A[i + 1], B[i]);
        ans += second_cnt;
        A[i + 1] -= second_cnt;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
n = int(input())
h = list(map(int, input().split()))

t = h[n - 1]
for i in range(n - 2, -1, -1):
    if t <= h[i] - 2:
        print("No")
        exit()
    if t == h[i] - 1:
        continue
    t = h[i]

print("Yes")




Measured memory_bytes: 14396
N=int(input())
A=list(map(int,input().split()))
#print(A)
count=0
flag = True
while(flag):
    for i in range(N):
        if A[i]%2==1:
            flag=False
            break
        else:
            A[i]=A[i]/2
    if flag==True:
            count+=1

print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
vector<ll> V;
int pre[maxn],a[maxn],b[maxn];
vector<int> nex[maxn];
int main() {
    int n,m;cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>pre[i];
    for(int i=1;i<=m;i++){
        int u,v;cin>>u>>v;nex[u].push_back(v);nex[v].push_back(u);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        for(auto x:nex[i]) if(pre[i]<=pre[x]) goto ed;
        ans++;
        ed:;
    }cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 9124
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<numeric>
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
bool isDigit(char c){return '0' <= c && c <= '9';}
template<typename T> void remove(std::vector<T>& vector, unsigned int index){vector.erase(vector.begin() + index);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    int n, x;
    cin >> n >> x;
    vi m(n);
    rep(i,n)cin >> m[i];
    SORT(m);
    int ans = 0;
    rep(i,n)
    {
        if(x<m[i])break;
        x-=m[i];
        ++ans;
    }
    while(x>=m[0])
    {
        x-=m[0];
        ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256