akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>

int main(){
    int N; cin>>N;
    ll a[N+1];
    for(int i=1;i<=N;++i){
        cin >> a[i];
    }
    ll ans = 0;
    ll x = 0;
    for(int i=1;i<=N;++i){
        if(a[i]==0){
            ans += (x/2);
            x = 0;
        }else{
            x += a[i];
        }
    }
    if(x>0){ ans += (x/2); }
    cout << ans << "\n";
}

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

int main(){
    int D, G; cin >> D >> G;
    vector<long long> p, c;
    p.resize(D); c.resize(D);
    for(int i = 0; i < D; ++i)
    {
        cin >> p[i] >> c[i];
    }
    long long res = 1<<29;
    for(int bit = 0; bit < (1<<D); ++bit){
        long long sum = 0;
        long long num = 0;
        for(int i = 0; i < D; ++i){
            if(bit & (1<<i)){
                sum += c[i] + p[i] * 100 * (i+1);
                num += p[i];
            }
        }
        if(sum >= G) res = min(res, num);
        else {
            for(int i = D - 1; i >= 0; --i){
                if(bit & (1<<i)) continue;
                for(int j = 0; j < p[i]; ++j){
                    if(sum >= G) break;
                    sum += 100 * (i+1);
                    ++num;
                }
            }
        }
        res = min(res,num);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
import bisect

n, m, k = map(int, input().split())
a = [0] + [int(x) for x in input().split()]
b = [0]
for x in input().split():
    b.append(b[-1] + int(x))

res = 0
a_ = 0
for i in range(n+1):
    a_ += a[i]
    if a_ > k:
        break
    b_max = k - a_
    b_num = bisect.bisect(b, b_max) - 1
    res = max(res, i + b_num)

print(res)


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

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0; i < N; i++){
        cin >> vec.at(i);
    }

    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());

    int Alice = 0;
    int Bob = 0;
    for(int i = 0; i < N; i++){
        if(0 == (i % 2)){
            Alice += vec.at(i);
        }
        else{
            Bob += vec.at(i);
        }
    }
    int dev;
    dev = Alice - Bob;
    cout << dev << endl;
}


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

typedef long long ll;
const ll mod = 1000000007;

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

    ll sum = 0;
    ll sumb = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i];
        if (i % 2 == 0) {
            if (sum < 1) {
                sumb += 1-sum;
                sum = 1;
            }
        } else {
            if (sum > -1) {
                sumb += sum+1;
                sum = -1;
            }
        }
    }
    ans = sumb;
    sum = 0;
    sumb = 0;

    for (int i = 0; i < n; i++) {
        sum += a[i];
        if (i % 2 == 1) {
            if (sum < 1) {
                sumb += 1-sum;
                sum = 1;
            }
        } else {
            if (sum > -1) {
                sumb += sum+1;
                sum = -1;
            }
        }
    }
    cout << min(ans, sumb) << endl;
}


Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val N = readInt()
    val S = readString()
    if (N % 2 == 1) {
        println("No")
        return
    }
    println(if (S.take(N/2) == S.takeLast(N/2)) "Yes" else "No")
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

fun Int.pow(n:Int) = Math.pow(this.toDouble(), n.toDouble()).toInt()

Measured memory_bytes: 35808
#include<iostream>
#include<cstdio>

char s[15];

int main()
{
	int i;
	scanf("%s",s);
	if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I') puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int n=0,r=0;
    int p=0,c=0;
    int count=0;
    int count2=1;
    int card[100]={0};//0(上)~n(下)
    int tempC[100]={0};
    int tempP[100]={0};
    int answer[100000]={0};
    while(1){
        scanf("%d %d",&n,&r);
        if(n==0&&r==0) break;
        for(int i=0;i<100;i++){
            card[i]=0;
            tempC[i]=0;
            tempP[i]=0;
        }
        for(int i=n-1;i>=0;i--){
            card[i]=count2;
            count2++;
        }
       
        for(int j=0;j<r;j++){
            scanf("%d %d",&p,&c);
            for(int i=0;i<p-1;i++){
                tempP[i]=card[i];
            }
            for(int i=0;i<c;i++){
                tempC[i]=card[p-1+i];
            }
            for(int i=0;i<c;i++){
                card[i]=tempC[i];
            }
            for(int i=0;i<p-1;i++){
                card[c+i]=tempP[i];
            }
        }
       
        answer[count]=card[0];
        count++;
        count2=1;
    }
       
    for(int i=0;i<count;i++){
        printf("%d\n",answer[i]);
    }
    return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
#define PI  acos(-1)
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int N;cin>>N;
  int l=0,r=0,b=0,ans=0;
  string S;
  REP(i,0,N){
    cin>>S;
    REP(i,0,S.size()-1){
      if(S.at(i)=='A'&&S.at(i+1)=='B'){
        ans++;
      }
    }
    if(S.at(0)=='B'&&S.at(S.size()-1)=='A')b++;
    else if(S.at(0)=='B')l++;
    else if(S.at(S.size()-1)=='A')r++;
  }
  // print(r,l,b,ans);
  int d=min(r,l),u=max(r,l);
  int add=d;u-=d;
  add+=((u>0)||(d>0)?b:max(b-1,0LL));
  // add=r+l+b-1;
  print(ans+add);


}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

ll N;
vector<ll> a;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  a.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  ll sum1 = a[0];
  for (int i = 1; i < N; i++) {
    sum1 ^= a[i];
  }
  ll sum2 = a[0] ^ a[0];
  for (int k = 0; k < 2; k++) {
    for (int i = 1; i < N; i++) {
      sum2 ^= a[i];
    }
  }

  if (sum1 == sum2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
import java.util.*

fun readInt(): Int {
    return readLine()!!.toInt()
}

fun readInts(): List<Int> {
    return readLine()!!.split(" ").map(String::toInt)
}

class Solution {
    fun solve() {
        val n = readInt()
        val red = Array(n + 1) { mutableListOf<Int>() }
        val blue = Array(n + 1) { mutableListOf<Int>() }
        val l = IntArray(n)
        val r = IntArray(n)
        var ans = 0L
        for (i in 0 until n) {
            val (ki, li, ri) = readInts()
            if (li >= ri)
                red[ki].add(i)
            else
                blue[ki].add(i)
            l[i] = li
            r[i] = ri
            ans += li.coerceAtMost(ri)
        }

        val pq = PriorityQueue<Pair<Int, Int>>(compareBy<Pair<Int, Int>> { it.first }.thenBy { it.second })
        for (i in 1 until n + 1) {
            for (j in red[i])
                pq.add(Pair(l[j] - r[j], j))
            while (pq.size > i)
                pq.poll();
        }
        while (pq.isNotEmpty())
            ans += pq.poll().first

        for (i in n downTo 1) {
            for (j in blue[i])
                pq.add(Pair(r[j] - l[j], j))
            while (pq.size > n - i)
                pq.poll();
        }
        while (pq.isNotEmpty())
            ans += pq.poll().first

        println(ans)
    }
}

fun main() {
    val t = readInt()
    for (i in 1 until t + 1) {
        val solution = Solution()
        solution.solve()
    }
}


Measured memory_bytes: 100312
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  string A,B,C;
  cin >> N >> A >> B >> C;
  int count = 0;
  for(int i = 0;i < N;i++){
    if(A.at(i) != B.at(i) && A.at(i) != C.at(i) && B.at(i) != C.at(i)){
      count += 2;
    }
    if(A.at(i) != B.at(i) && B.at(i) == C.at(i)){
      count++;
    }
    if(A.at(i) == B.at(i) && B.at(i) != C.at(i)){
      count++;
    }
    if(A.at(i) == C.at(i) && B.at(i) != C.at(i)){
      count++;
    }
  }
   cout << count << endl;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc103/tasks/abc103_d
//区間スケジューリング問題
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll N,M; cin>>N>>M;
    vector<pair<ll,ll>> bam(M); //b,a
    for(auto&& ba:bam){
        cin>>ba.second>>ba.first; //b,aでいれる
    }
    sort(bam.begin(),bam.end());
    ll ans=0;
    ll nowt=-1;
    REP(i,bam.size()){
        const auto& ba=bam.at(i);
        if(ba.second>=nowt){
            ++ans;
            nowt=ba.first;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

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

    for(int x=0; x<=n; x++){
        for(int y=0; y<=n-x; y++){
            for(int z=0; z<=n-x-y; z++){
                if(x+y+z>n) continue;
                if(10000*x+5000*y+1000*z==Y){
                    if(x+y+z==n) {
                        cout << x << " " << y << " " << z << endl;
                        return 0;
                    }
                }
            }
        }
    }

    cout << -1 << " "<< -1 << " "<< -1 << endl;
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm> 
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
vector<int> binext(int n){
    vector<int> a={-1,-1,-1};
    int i = 0;
    while(n>0){
        if(n%2 == 0){
            a[i]=-1;
        }else{
            a[i] = 1;
        }
        n/=2;
        i++;
    }
    return a;
}
int main(){
    int n,m;
    cin >> n >> m;
    long long x[n],y[n],z[n];
    rep(i,n){
        cin >> x[i] >> y[i] >> z[i];
    }
    vector<int> a;
    long long point[n];
    long long tem,ans;
    tem = ans = 0;
    rep(i,8){
        a = binext(i);
        rep(j,n){
            point[j] = x[j]*a[0]+y[j]*a[1]+z[j]*a[2];
        }
        sort(point,point+n,greater<long long>());
        rep(j,m){
            tem+=point[j];
        }
        ans = max(ans,tem);
        tem = 0;
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long LL;

int main(){
  int H, W;
  cin >> H >> W;
  vector<string> a(H);
  rep(i,H) cin >> a[i];
  vector<string> ans(H);
  rep(i,W){
    int num=0;
    rep(j,H) if(a[j][i]=='.') num++;
    if(num!=H) rep(j,H) ans[j].push_back(a[j][i]);
  }
  rep(i,H){
    rep(j,ans[i].size()){
      if(ans[i][j]=='#'){
        cout << ans[i] << endl;
        break;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define repi(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)
#define rep(i, n) repi(i, 0, n)
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
struct Vec{
    double x, y;
};
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;
}
template<class T>
T min(T a, T b)
{
    if (a < b) return a;
    return b;
}
template<class T>
T max(T a, T b)
{
    if (a > b) return a;
    return b;
}
using namespace std;
int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);

    int N;
    string Si;
    cin >> N;
    vector<int> S(4, 0);
    rep(i, N){
        cin >> Si;
        if (Si == "AC") S[0]++;
        else if (Si == "WA") S[1]++;
        else if (Si == "TLE") S[2]++;
        else if (Si == "RE") S[3]++;
    }
    printf("AC x %d\n", S[0]);
    printf("WA x %d\n", S[1]);
    printf("TLE x %d\n", S[2]);
    printf("RE x %d\n", S[3]);

    return 0;
}

Measured memory_bytes: 3720
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
struct node{
    int x,note=0x3f;//x代表数字，note表示状态，是上升还是下降
    //note=0，下降序列；note=1，上升序列；note=2，起点 或 起点后不明上下的点 
}a[100005]; //声明一个数组 
int main(){//主函数 
    int n,ans=1;//n个数，ans统计答案 
    cin>>n;//输入个数 
    for(int i=1;i<=n;i++){//挨个输入 
        cin>>a[i].x;//把数输入 
    }
    a[1].note=2;//第一个数必然是起点，打好状态标记 
    for(int i=2;i<=n;i++){//从第二个数开始找状态 
        if(a[i-1].note==0){//前一个数状态为0（下降） 
            if(a[i].x>a[i-1].x) a[i].note=2,ans++;//如果不下降了，这个数就是下一个序列的起点，序列数++ 
            else a[i].note=0;//下降，标记成0 
        }else if(a[i-1].note==1){//前一个数状态为1（上升） 
            if(a[i].x>=a[i-1].x) a[i].note=1;//继续上升，标记成1 
            else a[i].note=2,ans++;//不上升了，标记成起点，序列数++ 
        }else if(a[i-1].note==2){//是起点或起点后的不明点（统一当起点即可） 
            if(a[i].x<a[i-1].x) a[i].note=0;//比前一个数小，证明是下降序列，标为0 
            else if(a[i].x==a[i-1].x) a[i].note=2;//相等，这个点是不明上升/下降的点 
            else a[i].note=1;//上升，标成1 
        }
    }
    cout<<ans<<endl;//输出（换行） 
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;
typedef pair<int, int> P;
const vector<int> di = {-1, 0, 1, 0};
const vector<int> dj = { 0, 1, 0, -1 };

int main() {
	
	char c;
	cin >> c;

	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}

	return 0;
}

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

int main() {
	// your code goes here
	int l,r,d;
	cin>>l>>r>>d;
	int x1=l/d;
	if(l%d!=0){x1++;}
	int x2=r/d;
	cout<<(x2-x1+1);
	return 0;
}


Measured memory_bytes: 3620
// https://atcoder.jp/contests/abc042/tasks/abc042_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int> v(3);
    REP(i, 3) cin >> v[i];
    sort(ALL(v));
    if (v[0] == 5 && v[1] == 5 && v[2] == 7) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

i64 get(const std::vector<i64>& vector, const i64 i) {
  return vector[i - 1];
}
void set(std::vector<i64>& vector, const i64 i, const i64 value) {
  vector[i - 1] = value;
}

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> a;
  tools::read(a, N);

  std::vector<i64> boxes(N, 0);
  for (i64 i = N; i > 0; --i) {
    i64 sum = 0;
    for (i64 j = i * 2; j <= N; j += i) {
      sum += get(boxes, j);
    }
    set(boxes, i, (sum + get(a, i)) % 2);
  }

  std::vector<i64> answers;
  for (i64 i = 1; i <= N; ++i) {
    if (get(boxes, i) == 1) answers.push_back(i);
  }

  std::cout << answers.size() << std::endl;
  if (!answers.empty()) {
    std::string delimiter = "";
    for (const i64& answer : answers) {
      std::cout << delimiter << answer;
      delimiter = " ";
    }
    std::cout << std::endl;
  }
  return 0;
}

Measured memory_bytes: 4980
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

string S;

int main(int argc, char* argv[]) {
  cin >> S;

  int res = S.size();
  for (int i = 0; i < S.size() - 1; i++) {
    if (S[i] == S[i + 1])
      continue;

    if (res > max<int>(i + 1, S.size() - i - 1))
      res = max<int>(i + 1, S.size() - i - 1);
  }
  cout << res << endl;

  return 0;
}

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

typedef long long ll;
typedef vector <ll> vr;
typedef pair <ll, ll> pr;
typedef vector <ll> :: iterator ir;

#define pub push_back
#define pob pop_back
#define mp make_pair
#define pc __builtin_popcount
#define lb lower_bound
#define mod 1000000007

ll dig(ll n) {
	string s = to_string(n);
	return s.size();
}

ll totSum(ll arr[], ll n) {
	ll sum = 0;
	for (ll i = 0; i < n; i++) {
		sum += arr[i];
	}
	return sum;
}


int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);


#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif




// write your code here

	int n;
	cin >> n;
	vector<int> arr(n);
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		sum += arr[i];
		sum = sum % mod;
	}
	long long result = 0;
	for (int i = 0; i < n; i++) {
		sum = sum - arr[i];
		if (sum < 0)sum += mod;
		result += (sum * arr[i]);
		result = result % mod;
	}
	cout << result;

// this is the end of your code

}


Measured memory_bytes: 3988
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

//gcd,lcm,べき,二進展開
//組み合わせ、mod計算
//最短路問題、bit、union find

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

ll N, M;

bool see[MAX] = {};

vector<ll> g[MAX];

vector<ll> con;

void dfs(ll u) {
	see[u] = 1;
	con.push_back(u);
	for (ll v : g[u]) {
		if (see[v] == 0) { dfs(v); }
	}
	return;
}

ll cap(vector<ll> s, vector<ll> t) {
	ll ans = 0;

	t.push_back(INF);
	for (ll x : s) {
		auto itr = lower_bound(t.begin(), t.end(),x);
		ll y = *itr;
		if (x == y) { ans++; }
	}
	return ans;
}


	
int main() {

	ll N, M;
	cin >> N >> M;

	ll p[MAX];
	repn(i, N) cin >> p[i];

	repn(i, M) {
		ll x, y;
		cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}

	ll ans = 0;

	repn(x, N) {
		if (see[x] != 0) { continue; }

		con.clear();

		dfs(x);

		vector<ll> s, t;

		for (ll y : con) {
			s.push_back(y);
			t.push_back(p[y]);
		}

		sort(s.begin(), s.end());
		sort(t.begin(), t.end());

		ans += cap(s, t);
	}

	cout << ans;



	system("PAUSE");
}

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

int main(){
    int N; cin >> N;
    vector<int> a(N);
    int ans =0;

    rep(i,N){
        cin >> a[i];
    }

    rep(i,N-1){
        if(a[i]==a[i+1]){
            a[i+1]=-1;
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int d[3];
  scanf("%d%d%d",&d[0],&d[1],&d[2]);

  int buf = d[0]*d[1];
  int buff = d[2];

  if(buf<buff) printf("%d\n",buf);
  else printf("%d\n",buff);

  return 0;
}


Measured memory_bytes: 128
while True:
   h,w = map(int, raw_input().split())
   if h == w == 0:
       break
   ret = '#'*w+'\n'
   ret += ('#' + '.' * (w-2) + '#\n') * (h - 2)
   ret += '#'*w+'\n\n'
   print ret,

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

const int N = 1e5 + 5, K = 100 + 5;

int dp[N];
int h[N];
int n, k = 2;

int sol(int idx) {
    if(idx == n - 1) return 0;

    int &ret = dp[idx];

    if(ret != -1) return ret;

    ret = 1e9 + 5;
    for(int i = 1; i <= k && (i + idx) < n; i++) {
        ret = min(ret, sol(idx + i) + abs(h[idx] - h[idx + i]));
    }

    return ret;
}

int main(){
    fIO

//    freopen("", "r", stdin);
//    freopen("", "w", stdout);

    memset(dp, -1, sizeof(dp));
    cin >> n >> k;

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

    cout << sol(0) << "\n";

}








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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef vector<pair<ll, ll>> vpll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;

const int N = 1e5;
vi g[N];
int dp[N];

void dfs(int v) {
    for (int u : g[v]) {
        if (!dp[u]) dfs(u);
        dp[v] = max(dp[v], dp[u] + 1);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    int u, v;
    forn(i, m) {
        cin >> u >> v;
        u--, v--;
        g[u].pb(v);
    }
    int ans = -1;
    forn(i, n) {
        if (!dp[i]) dfs(i);
        ans = max(ans, dp[i]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100010;
const int inf=1e9;
int dp[N];
int main(){
    int n;
    cin>>n;
    int a[n+5];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++) dp[i]=inf;
    dp[0]=0;
    for(int i=0;i<n;i++){
        if(i>=1) dp[i]=min(dp[i],dp[i-1] + abs(a[i]-a[i-1]));
        if(i>=2) dp[i]=min(dp[i],dp[i-2] + abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1]<<'\n';
    
}
  


Measured memory_bytes: 4404
def main():
    n = int(input())
    a_lst = list(map(int, input().split()))
    q = int(input())
    bc_lst = [list(map(int, input().split())) for _ in range(q)]

    a_max = max(a_lst)
    bc_max = 0
    for i in range(q):
        b = bc_lst[i][0]
        c = bc_lst[i][1]
        bc_max = max(b, bc_max)
        bc_max = max(c, bc_max)
    maximum = max(a_max, bc_max)

    count_lst = [0] * maximum
    for i in range(n):
        a = a_lst[i]
        count_lst[a - 1] += 1
    tmp = sum(a_lst)

    for i in range(q):
        b = bc_lst[i][0]
        c = bc_lst[i][1]

        count = count_lst[b - 1]
        tmp += count * (c - b)
        count_lst[b - 1] = 0
        count_lst[c - 1] += count

        print(tmp)


if __name__ == '__main__':
    main()

Measured memory_bytes: 32056
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

int n;
int h[101];
int cnt = 0;

bool allZero(int he[101])
{
    for (int i = 0; i < n; ++i)
    {
        if (he[i] != 0)
            return false;
    }

    return true;
}

int count(int he[101])
{
    int cnt = 0;
    int pre = 0;
    for (int i = 0; i < n; ++i)
    {
        if (pre == 0 && he[i] != 0)
        {
            cnt++;
        }
        pre = he[i];
    }

    return cnt;
}

int sol(int he[101])
{
    if (allZero(he))
    {
        return 0;
    }

    int cnt = count(he);
    for (int i = 0; i < n; ++i)
    {
        he[i] = max(he[i] - 1, 0);
    }

    return cnt + sol(he);
}

int main()
{
    cin >> n;

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

    cout << sol(h) << endl;
}

Measured memory_bytes: 256
#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(){
    int a,b,c,k;
    cin >> a >> b >> c;
    cin >> k;
    int ka=0;
    while(a>=b){
        b*=2;
        ++ka;
    }

    while(b>=c){
        c*=2;
        ++ka;
    }

    if(ka<=k){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main() {
  string s,rv;
  cin>>s;
  rv=s;
  reverse(rv.begin(),rv.end());
  string a,z;
  a='A';
  z='Z';
  long long i,c=0,c2=0;
  for(i=0;i<s.size();i++)
  {
     c++;
     if(s[i]=='A') break;

  }
  for(i=0;i<rv.size();i++)
  {
     c2++;
     if(rv[i]=='Z') break;

  }
  //cout<<c<<" "<<c2<<endl;
  long long x,y;
  y=s.size();
  long long w=c2-1;
  x=y-w;
  //cout<<x<<endl;
  long long ans=(x-c+1);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 772
from itertools import accumulate

def primes(n):
  prime = ([False]*2) + ([True]*(n-2))
  for i in range(2, n):
    if prime[i]:
      for j in range(i*2, n, i):
        prime[j] = False
  return prime

MAX = (10**5)+1
is_prime = primes(MAX)
q = int(input())
A = [1 if is_prime[i] and is_prime[(i + 1)//2] else 0 for i in range(MAX)]
S = [0] + list(accumulate(A))

Q = []
Q_append = Q.append
for _ in range(q):
    l, r = map(int, input().split())
    Q_append((l, r))

for qi in Q:
    print(S[qi[1]+1]-S[qi[0]])

Measured memory_bytes: 22036
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=998244353 ;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//17:00~

int main(void){
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	int i,n;cin>>n;
	stack<int>s;
	s.push(0);
	int in[101]={};
	for(i=1;i<=n;i++){
		int x;cin>>x;
		if(x>0){
			if(in[x]){cout<<i<<endl;return 0;}
			in[x]=1;
			s.push(x);
		}else{
			x*=-1;
			if(s.top()!=x){cout<<i<<endl;return 0;}
			s.pop();
			in[x]=0;
		}
	}
	cout<<"OK"<<endl;
	return 0;
}



Measured memory_bytes: 3216
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
const int MAX = 1000;

int main() {
	int n;
	cin >> n;
	vector<queue<int>> v(n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n-1; j++) {
			int a;
			cin >> a;
			a--;
			v[i].push(a);
		}
	}
	bool cont = true;
	int ans = 0;
	while (cont) {
		ans++;
		cont = false;
		bool b[MAX] = {};
		for (int i = 0; i < n; i++) {
			if (v[i].empty()) continue;
			int p = v[i].front();
			if (b[p] || b[i]) continue;
			if (v[p].front() == i) {
				v[i].pop(); v[p].pop();
				b[i] = b[p] = true;
				cont = true;
			}
		}
	}
	ans--;
	bool ok = true;
	for (int i = 0; i < n; i++) {
		if (!v[i].empty()) ok = false;
	}
	if (ok) {
		cout << ans << endl;
	} else {
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 8064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
using namespace std;

int main(){
  int N;
  cin>>N;
  long long int X[N+1],Y[N+1],cnt=0;
  for(int i=1; i<=N; ++i) cin>>X[i]>>Y[i];
  
  vector<int> A;
  for(int i=1; i<=N; ++i){
    for(int j=1; j<=N; ++j){
      if(i!=j && N>1){
        int p=X[j]-X[i],q=Y[j]-Y[i];
        cnt=0;
        for(int k=1; k<=N; ++k){
          for(int h=1; h<=N; ++h){
            if(X[h]-X[k]==p && Y[h]-Y[k]==q) cnt++;
          }
        }
        A.push_back(cnt);
      }
    }
  }
  
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  
  if(N>1) cout<<N-A.at(0)<<endl;
  else cout<<1<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int a, b, c;

    scanf("%d %d %d",&a,&b,&c);

    if(a == 5 && b == 5 && c == 7){
        printf("YES\n");
    } else if(a == 5 && b == 7 && c == 5){
        printf("YES\n");
    } else if(a == 7 && b == 5 && c == 5){
        printf("YES\n");
    } else {
        printf("NO\n");
    }
    
    return 0;
}

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

using namespace std;

const int N=1e5+5,MOD=1e9+7;

typedef long long ll;

int n,c,u,v,w,k,tc,ans;

vector<pair<int,int> > g[N];

int color[N];

void dfs(int u,int p){
	for(auto pp : g[u]){

		int v = pp.first , cst = pp.second;
		if(v == p)
            continue;
		if(cst%2)
			color[v]=!color[u];
		else
			color[v]=color[u];
		dfs(v,u);
	}
}

int main() {
    scanf("%d",&n);
	for(int i=1;i<n;i++){
        scanf("%d%d%d",&u,&v,&w);
        g[--u].push_back({--v,w});
		g[v].push_back({u,w});
	}
	color[1]=0;
	dfs(0,0);

	for(int i=0;i<n;i++)
        printf("%d\n",color[i] );
}



Measured memory_bytes: 8320
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll INFL = 1e18;
const ll mod = 1e9 + 7;
 
int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}
 
ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

bool is_prime(long long N){
    if (N == 1) return false;
    for (long long i = 2;i * i <= N;i++){
        if (N % i == 0) return false;
    }
    return true;
}
 
ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}
 
double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}
 
 
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
 
 
///////////////////////////////////////////////////////////////////////////////////

int main(){
    int n;
    long long T;
    cin >> n >> T;
    long long ans = 0;
    vector<long long> t(n);
    for (int i = 0;i < n;i++){
        cin >> t[i];
    }

    for (int i = 1;i < n;i++){
        if (t[i] - t[i-1] > T){
            ans += T;
        }
        else {
            ans += t[i] - t[i-1];
        }
    }
    ans += T;
    cout << ans << endl;
}

Measured memory_bytes: 4816
(defun solve (n v)
  (declare (ignore n))
  (reduce (lambda (a b)
            (/ (+ a b) 2))
          (sort v #'<)))

#-swank
(let* ((n (read))
       (v (loop repeat n collect (read)))
       (*read-default-float-format* 'double-float))
  (format t "~A~%" (coerce (solve n v) 'double-float)))


Measured memory_bytes: 6500
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n;
    cin>>n;
    set<string> x;
    REP(i,n){
        string s; 
        cin>>s;
        x.insert(s);
    }
    PUTS(x.size());
}

Measured memory_bytes: 19204
import sys
from heapq import heappush, heappop
def input(): return sys.stdin.readline().strip()

def main():
    """
    中央値の最小値から最大値まで、全ての値を取れるというだけのオチ。。。
    確かに中央値じゃなくて和の場合の問題やったことあるわ。。。
    """
    N = int(input())
    lower = []
    upper = []
    for i in range(N):
        a, b = map(int, input().split())
        heappush(lower, (a, i))
        heappush(upper, (-b, i))
    
    if N % 2 != 0:
        for _ in range(N // 2):
            a, i = heappop(lower)
        a, _ = heappop(lower)
        for _ in range(N // 2):
            b, i = heappop(upper)
        b, _ = heappop(upper)
        print(-b - a + 1)
    else:
        for _ in range(N // 2 - 1):
            a, i = heappop(lower)
        a0, i0 = heappop(lower)
        a1, i1 = heappop(lower)
        for _ in range(N // 2 - 1):
            b, i = heappop(upper)
        b0, i0 = heappop(upper)
        b1, i1 = heappop(upper)
        print((-b1 - b0) - (a1 + a0) + 1)


    

if __name__ == "__main__":
    main()


Measured memory_bytes: 107012
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main()
{
    ll N,T;
    cin >> N >> T;
    vector<ll> t(N);
    for(ll i = 0; i < N; i++)
    {
        cin >> t[i];
    }
 
    ll count = 0;
 
    for(ll i = 1; i < N; i++)
    {
        if(T <= (t[i] - t[i-1]))count += T;
        else count += t[i] - t[i-1];
    }
    count += T;
 
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    string s;
    cin>>s;
    bool ok = true;
    rep(i,0,s.length()-1){
        if ( s[i] == s[i+1] ){
            ok = false;
            break;
        }
    }
    cout<<((ok)?"Good":"Bad")<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n;
	int d[100];

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &d[i]);
	}
	int count = 0;
	int max = 101;

	while (1) {
		bool b = false;//現在の最大値より小さい数字があるかどうかの判定、無ければtrue
		int tmp = 0;
		for (int i = 0; i < n; i++) {
			if (max > d[i]) if (tmp < d[i]) {
				tmp = d[i];
			}
		}
		if (tmp == 0) break;
		else {
			count++;
			max = tmp;
		}
	}
	printf("%d\n", count);
}

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

int main(){
	long long int W, H, x, y; 
	int o = 0;
	scanf("%lld %lld %lld %lld", &W, &H, &x, &y);

	if (W%2 == 0 && H%2 == 0 && x == W/2 & y == H/2){
		o = 1;
	}


	printf("%f %d", (double)(W*H)/2, o);
  	return 0;
}




Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
using namespace std;

typedef long long ll;
const int MAXN=100005;
const ll INF=1e18;

int n,m,T;
int a[MAXN];
ll d[MAXN],mine=INF;

int main(){

    scanf("%d%d%d",&n,&m,&T);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]),d[i]=INF;
    for(int i=1,last=0;i<=n;i++){
        while(T<=2*(a[i]-a[last+1])){
            mine=min(mine,d[last]-2*a[last+1]);
            last++;
        }
        d[i]=d[last]+T;
        d[i]=min(d[i],mine+2*a[i]);
    }
    printf("%lld",m+d[n]);

    fclose(stdin);
    fclose(stdout);
}


Measured memory_bytes: 1280
import java.util.*;
public class Main{

 public static void main(String[] args)
 {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int len = String.valueOf( n ).length(); 
        int sum = 0;
        for(int i =1;i<len;i++){
          if(i%2==1){
            sum = sum + ( (int)Math.pow(10, i)  - 1 - ((int)Math.pow(10, i-1)  - 1));
          }
        }
        if(len%2 == 1){
            int tmp = len - 1;
            sum = sum + n - ((int)Math.pow(10, tmp) - 1);
        }
        System.out.println(sum);
      
    }

}

Measured memory_bytes: 23124
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int a,b;scan(a>>b);
	prin(max({a+b,a-b,a*b}));
	return 0;
}


Measured memory_bytes: 256
s = input()
front = int(s[:2])
back = int(s[2:])

f_bool = (front <13)&(front>0)
b_bool = (back <13)&(back>0)
if f_bool ^ b_bool:
    if f_bool:
        print("MMYY")
    
    else:
        print("YYMM")
elif f_bool:
    print("AMBIGUOUS")
else:
    print("NA")

Measured memory_bytes: 3064
if __name__ == '__main__':
    n = int(input())
    a = [int(i) for i in input().split()]
    avg = sum(a) / n
    min = 101
    now = 0
    for i in range(n):
        if abs(avg -a[i]) < min:
           min = abs(avg -a[i])
           now = i
    print(now)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b,ans;
  string c;
  cin>>a>>c>>b;
  if(c[0]=='+'){
    ans=a+b;
  }
  else{
    ans=a-b;
  }
  cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 3640
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include <vector>
#include <map>

using namespace std;

void Solution()
{
    string str;
    
    getline(cin, str);
    
    for(int i=0; i < (int)str.size(); i++) //output directly, by loop
    {
        
        if("peach" == str.substr(i, 5))  //substr(index, length)
        {
            i += 4; // skip to next word, next is i +4 + 1
            cout<<"apple";
        }
        else if("apple" == str.substr(i, 5))
        {
            i += 4;
            cout<<"peach";
        }
        else
        {
            cout<<str[i];
        }
    }
    
    cout<<endl;
}

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

Measured memory_bytes: 1184
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>
#define rep(i,n) for(int i = 0; i < (n); i++) 
using namespace std;

int main() {
	int n, ans = 0;
	cin >> n;
	int d[n];
	rep(i,n) cin >> d[i];
	rep(i,n) {
		rep(j,n) {
			if (i < j) {
				ans += d[i] * d[j]; 		
			}	
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main() {

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

        cin >> polygon[i];
    }
    sort(polygon, polygon+n);

    int sum = 0;
    for(int i = 0; i < n-1; i++) {

        sum += polygon[i];

    }
//    cout << sum << endl;
//    cout << polygon[n-1] << endl;
    if(sum > polygon[n-1]) {cout << "Yes" << endl;}
    else  {cout << "No" << endl;}
}


Measured memory_bytes: 256
// luogu-judger-enable-o2
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>

#define Min(a,b) ((a)<(b)?(a):(b))
#define Max(a,b) ((a)>(b)?(a):(b))
#define Mabs(a,b) ((a)>(b)?(a)-(b):(b)-(a))
#define Abs(a) (a)>0?(a):(-(a))
template <typename QvQ> inline QvQ Min2(QvQ a,QvQ b){if(a<b) return a;return b;}
template <typename QvQ> inline QvQ Max2(QvQ a,QvQ b){if(a>b) return a;return b;}
template <typename QvQ> inline QvQ Abs2(QvQ a){if(a>0) return a;return -a;}

#define n1kw 10000000
#define inf 0x7f7f7f7f
#define dinf 0x3f3f3f3f
#define llinf 0x7f7f7f7f7f7f7f7f
#define lldinf 0x3f3f3f3f3f3f3f3f

#define ll long long
#define rei register int
#define inv inline void
#define inb inline bool
#define ini inline int

#define bl putchar(' ')
#define ed putchar('\n')
#define test std::cout<<"this:"
#define card system("pause")

#define read2(a,b) read(a),read(b)
#define write2(a,b) write(a),bl,write(b)
#define read3(a,b,c) read(a),read(b),read(c)
#define write3(a,b,c) write(a),bl,write(b),bl,write(c)

//char buf[1<<23],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)

template <typename QvQ>inv read(QvQ &x)
{
    x=0;int f=1;
    char c=getchar();
    for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
    for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48);
    x=x*f;
}
template <typename QvQ>inv write(QvQ x)
{
    if(x<0) x=-x,putchar('-');
    if(x>9) write(x/10);
    putchar(x%10+48);
}
using namespace std;
#include <cmath>
#define MAXN 30005
ll n;
int main()
{
    read(n);
    ll x,y,X=1,Y;
    x=Y=sqrt(n)+1;
    if(x>1e9) --x;
    if(Y>1e9) --Y;
    __int128 cj=x*Y;
    ll need=cj-n;y=need;
    write(0),bl,write(0),bl;
    write(x),bl,write(y),bl;
    write(X),bl,write(Y);
    return 0;
}

Measured memory_bytes: 256