akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main{
	int N,M;
	int[] a;
	public void solve() {
		N = nextInt();
		M = nextInt();
		a = new int[M];
		for(int i = 0;i < M;i++)a[i] = nextInt();
		int ans = 0;
		for(int i = 0;i <= M;i++){
			if(i == 0)ans = Math.max(ans, a[i]-1);
			else if(i==M)ans = Math.max(ans,N-a[i-1]);
			else ans = Math.max(ans, (a[i]-a[i-1])/2);
		}
		out.println(ans);
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 32756
n = int(input())
A = list(map(int, input().split()))
A.sort()
MOD = 10 ** 9 + 7
ans = 0
if n % 2 != 0:
  a = list(range(0, n, 2))
  a = sorted(a + a[1:])
  if a == A: ans = (2**((n-1)//2))%MOD
else:
  a = sorted(list(range(1, n, 2)) * 2)
  if a == A: ans = 2**(n//2)%MOD
print(ans)

Measured memory_bytes: 14008
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;

        while(!(line = br.readLine()).equals("-1")){
            int n = Integer.parseInt(line);
            double x = 1.0;
            double y = 0.0;
            double deg = 180;

            for(int i = 1; i < n; i++){
                deg -= 90;
                x += Math.cos(deg / 180.0 * Math.PI);
                y += Math.sin(deg / 180.0 * Math.PI);
                deg = Math.atan(y/x) * 180.0 / Math.PI;
                if(x <= 0 && y >= 0) deg += 180.0;
                if(x <= 0 && y <= 0) deg += 180.0;
                // System.out.println(x + ":" + y + ":" + deg);
            }

            System.out.printf("%.2f%n", y);
            System.out.printf("%.2f%n", x);
        }
    }
}


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

const int mod = 1e9+7;
const int maxn = 1e6+5;
void tlfclwx(){ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
int k[maxn];
ll sum = 0;
ll a = 1;
void fenjie(ll n)
{
    sum += a;
    a *= 2;
    if(n/2==0) return;
    fenjie(n/2);

}
int main()
{
    tlfclwx();
    ll h;  cin >> h;
    fenjie(h);
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define LENGTH 1000

using namespace std;

int LCSLength(string X, string Y){
    int m = X.size();
    int n = Y.size();
    int c[LENGTH+1][LENGTH+1];
    int maxLength = 0;
    X = ' ' + X;
    Y = ' ' + Y;
    for(int i = 1; i <= m; i++) c[i][0] = 0;
    for(int j = 0; j <= n; j++) c[0][j] = 0;
    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= n; j++){
            if(X[i] == Y[j]) c[i][j] = c[i-1][j-1] + 1;
            else if(c[i-1][j] >= c[i][j-1]) c[i][j] = c[i-1][j];
            else c[i][j] = c[i][j-1];
            maxLength = max(maxLength, c[i][j]);
        }
    }
    return maxLength;
}

int main(){
    int n;
    string X, Y;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> X >> Y;
        cout << LCSLength(X, Y) << endl;
    }
    return 0;
}


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

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;
}

bool acgt(char c){
    return c == 'A' || c == 'C' || c == 'G' || c == 'T';
}

int main(){
    string s; cin >> s;
    int n = s.size();
    int ans = 0;
    for(int i = 0; i < n; i++){
        int buf = 0;
        for(int j = i; j < n; j++){
            if(acgt(s[j])) ++buf;
            else break;
        }
        ans = max(ans, buf);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
"use strict";

((stdin) => {
  const input = stdin.split("\n");
  // 10進数に変換
  let n = parseInt(input[0], 10);
  let a = input[1].split(" ");

  for (let i = 0; i < n; i++) {
    a[i] = parseInt(a[i], 10);
  }

  let ans = 0;
  let up = false;
  let down = false;
  for (let i = 0; i < n - 1; i++) {
    if (a[i] < a[i + 1]) {
      up = true;
    }
    if (a[i] > a[i + 1]) {
      down = true;
    }
    if (up && down) {
      up = down = false;
      ans++;
    }
  }

  console.log(ans + 1);
})(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 17612
#include <bits/stdc++.h>
using namespace std;
const int INF = 2100100100;
using ll = long long;

// int main(){
//     int L;
//     cin >> L;
//     double l = L/3.l;
//     printf("%.12f\n.",pow(l,3));
//     return 0;
// }

int main() {
    double L;
    cin >> L;
 
    double d = L / 3;
    double ans = d * d * d;
 
    printf("%.10f", ans);
 
    return 0;
}

Measured memory_bytes: 256
import math

def main():
    S = input()
    char_dict = {}
    for s in S:
        if not s in char_dict:
            char_dict[s] = 1
        else:
            char_dict[s] = char_dict[s] + 1
    flag = 1
    if len(char_dict) == 2:
        for char in char_dict.keys():
            if char_dict[char] != 2:
                flag = 0
    else:
        flag = 0

    if flag:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

template <ll mod> class ModInt {
    ll a;
public:
    constexpr ModInt(const ll a = 0) noexcept : a((a % mod + mod) % mod) {}
    constexpr ll &value() noexcept { return a; }
    constexpr ModInt operator + (const ModInt &rhs) const noexcept { return ModInt(*this) += rhs; }
    constexpr ModInt operator - (const ModInt &rhs) const noexcept { return ModInt(*this) -= rhs; }
    constexpr ModInt operator * (const ModInt &rhs) const noexcept { return ModInt(*this) *= rhs; }
    constexpr ModInt operator / (const ModInt &rhs) const noexcept { return ModInt(*this) /= rhs; }
    constexpr ModInt &operator += (const ModInt &rhs) noexcept {
        a += rhs.a;
        if (a >= mod) a -= mod;
        return *this;
    }
    constexpr ModInt &operator -= (const ModInt &rhs) noexcept {
        a += mod - rhs.a;
        if (a >= mod) a -= mod;
        return *this;
    }
    constexpr ModInt &operator *= (const ModInt &rhs) noexcept {
        a = a * rhs.a % mod;
        return *this;
    }
    constexpr ModInt pow(ll t) const noexcept {
        if (t == 0) return 1;
        auto ret = pow(t >> 1);
        ret *= ret;
        if (t & 1) ret *= *this;
        return ret;
    }
    constexpr ModInt inv() const noexcept { return pow(mod - 2); }
    constexpr ModInt operator /=(const ModInt &rhs) { return (*this) *= rhs.inv(); }
    constexpr bool operator == (const ModInt &rhs) const noexcept { return this->a == rhs.a; }
    constexpr bool operator != (const ModInt &rhs) const noexcept { return this->a != rhs.a; }
    friend constexpr ostream &operator << (ostream &os, const ModInt &rhs) noexcept { return os << rhs.a; }
    friend constexpr istream &operator >> (istream &is, ModInt &rhs) {
        is >> rhs.a;
        return is;
    }
};
using mint = ModInt<MOD>;

mint binomial(ll n, ll k) {
    if (k < 0 || n < k) return 0;
    mint ret = 1;
    for (ll i = 1; i <= k; i++, n--) {
        ret *= n;
        ret /= i;
    }
    return ret;
}

int main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    ll n, a, b;
    cin >> n >> a >> b;
    mint ans = ((mint)2).pow(n) - 1;
    cout << ans - binomial(n, a) - binomial(n, b) << "\n";
    return 0;
}

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

long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}

int main(){
  long long i,n,r=0,t;
  long long *a=malloc(sizeof(long long)*131072);
  long long *b=malloc(sizeof(long long)*131072);
  scanf("%lld",&n);
  for(i=1;i<=n+1;i++){
    scanf("%lld",&a[i]);
  }
  for(i=1;i<=n;i++){
    scanf("%lld",&b[i]);
  }
  for(i=1;i<=n;i++){
    t=llmin(a[i],b[i]);
    r+=t;a[i]-=t;b[i]-=t;
    t=llmin(a[i+1],b[i]);
    r+=t;a[i+1]-=t;b[i]-=t;
  }
  printf("%lld\n",r);
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e12;
const int MOD = 1e9 + 7;

signed main(){
    int a,b,q;
    cin >> a >> b >> q;
    vector<ll> s(a + 2),t(b + 2),x(q);
    s[0] = -INF;
    s[a + 1] = INF;
    t[0] = -INF;
    t[b + 1] = INF;
    for(int i = 1; i <= a; i++){
        cin >> s[i];
    }
    for(int i = 1; i <= b; i++){
        cin >> t[i];
    }
    REP(i,q){
        cin >> x[i];
    }
    REP(i,q){
        ll ans = INF;
        int fi = lower_bound(ALL(s), x[i]) - s.begin();
        int se = lower_bound(ALL(t), s[fi]) - t.begin();
        ans = min(ans, abs(s[fi] - x[i]) + min(abs(t[se] - s[fi]), abs(t[se - 1] - s[fi])));
        fi--;
        se = lower_bound(ALL(t), s[fi]) - t.begin();
        ans = min(ans, abs(s[fi] - x[i]) + min(abs(t[se] - s[fi]), abs(t[se - 1] - s[fi])));
        fi = lower_bound(ALL(t), x[i]) - t.begin();
        se = lower_bound(ALL(s), t[fi]) - s.begin();
        ans = min(ans, abs(t[fi] - x[i]) + min(abs(s[se] - t[fi]), abs(s[se - 1] - t[fi])));
        fi--;
        se = lower_bound(ALL(s), t[fi]) - s.begin();
        ans = min(ans, abs(t[fi] - x[i]) + min(abs(s[se] - t[fi]), abs(s[se - 1] - t[fi])));
        cout << ans << endl;
    }
}

Measured memory_bytes: 3712
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
using namespace std;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int a,b;
	char op;
	cin>>a>>op>>b;
	if(op=='+')cout<<a+b<<endl;
	else cout<<a-b<<endl;
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

template <class T> struct FenwickTree {
   vector<T> node;
   FenwickTree(int n) : node(n,0) {}
   void add(int idx, T val) {
      while (idx < node.size()) {
         node[idx] += val;
         idx += idx & -idx;
      }
   }
   T sum(int idx) {
      T ret = 0;
      while (idx > 0) {
         ret += node[idx];
         idx -= idx & -idx;
      }
      return ret;
   }
};

int main() {

   int n,q; cin >> n >> q;
   FenwickTree<int> inst(100010);
   REP(i,q){
      int com,s,t,x;
      cin >> com;
      if(com == 0) {
         cin >> s >> t >> x;
         inst.add(s,x);
         inst.add(t+1,-x);
      } else{
         cin >> t;
         cout << inst.sum(t) << endl;
      }
   }

   return 0;
}

Measured memory_bytes: 3088
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include<ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
typedef    complex<ld>   P;
#define    X   real()
#define    Y   imag()
ld restant(P p){return abs(p);}
//polar(x,y) mag=l,arg=y
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pair<ll,ll> >   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pair<int,int> >   vpi;
typedef    vector<pair<double,double> >   vpd;
typedef    pair<double,double>   pd;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9223372036854775807
#define    ninf   -inf
#define    ima   2147483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define all(x) x.be(),x.en()
#define    eps   1e-9
const    ld   PI=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return((a-b+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}


int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{

int n,k;
cin>>n>>k;
string s;
cin>>s;
k--;
if(s[k]=='A')
s[k]='a';
else if(s[k]=='B')
s[k]='b';
else
s[k]='c';
cout<<s;





}return 0;}

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

using namespace std;

const long double pi = 4*acos(0);
const long double fractHour = pi/12;
const long double fractMinu = fractHour/60;
const long double otro = pi/60;

int main(){
    int a,b,h,m;
    cin >> a >> b >> h >> m;
    long double hou = fractHour * h + fractMinu * m;
    long double minu = otro*m;
    long double ang = fabs(hou - minu);
    if(ang > pi/2){
        ang = pi - ang;
    }
    long double ans = sqrt(a*a + b*b - 2*a*b*cos(ang));
    printf("%.9Lf",ans);
}


Measured memory_bytes: 4084
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll n;
cin>>n;
vector<ll>v;
for(ll i=0;i<n;i++)
{
    ll a;
    cin>>a;
    v.pb(a);
}
ll ans=0;
for(ll k=0;k<60;k++)
{
    ll x=1ll<<k;
    ll cnt=0;
    ll cnt0=0;
    ll cnt1=0;
    for(ll i=n-1;i>=0;i--)
    {
        if(v[i]&x)
        {
            cnt1++;
            cnt+=cnt0;
        }else
        {
            cnt0++;
            cnt+=cnt1;
        }
    }
    //cout<<k<<" "<<cnt<<endl;
    ll y=power(2,k);
    cnt=cnt%mod;
    cnt=(cnt*y)%mod;
    ans=(ans+cnt)%mod;
}
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 5872
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<string>
#include<vector>
using namespace std;

const long long mod = 1000000007;
long long powmod(long long x, long long n) {
    long long v = 1; 
    while (n > 0) {
        if (n%2 == 1) {
            v = (v*x) % mod;
        }
        x = (x*x) % mod;
        n /= 2;
    }
    return v % mod;
}
int main() {
    int n, k;
    cin >> n >> k;
    vector<long long> d(k+1);
    for(int i = 1; i <= k; ++i) {
        // gcd=iの条件: 全てがiの倍数
        // iをgcdとする場合の数
        // k/i = 倍数の数
        // k/i * k/i * k/i ... 通り
        d[i] = powmod(k/i, n);
    }
    long long ans = 0;
    for(int i = k; i > 0; --i) {
        for(int j = i * 2; j <= k; j += i) {
            // 重複を引く
            // gcd=3の場合にgcd=6の場合も含まれているので引く
            d[i] = (d[i] - d[j] + mod) % mod;
        }
        ans += (d[i] * i) % mod;
    }
    cout << ans % mod << endl;
    return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    string s; cin >> s;
    if (s[sz(s)-1]!='s') s+="s";
    else s+="es";
    cout << s << endl;
}

Measured memory_bytes: 3640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{

    class Program
    {
        public struct cuisine
        {
            public int takahashi;
            public int aoki;
            public int takahashi_gain;

            public cuisine(string input)
            {
                var split = input.Split().Select(int.Parse).ToArray();
                this.takahashi = split[0];
                this.aoki = split[1];
                this.takahashi_gain = this.aoki + this.takahashi;
            }
        }

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            cuisine[] cuisines = new cuisine[N];
            for (int i = 0; i < N; i++)
            {
                cuisines[i] = new cuisine(Console.ReadLine());
            }
            //準備完了
            Array.Sort(cuisines,compare);
            //先行が食べる数
            long output = 0;
            for (int i = 0; i < N; i++)
            {
                if (i % 2 == 0)
                {
                    output += cuisines[i].takahashi;

                }
                else
                {
                    output -= cuisines[i].aoki;
                }

            }
            Console.WriteLine(output);

        }
        public static int compare(cuisine x, cuisine y)
        {
            if (x.takahashi_gain > y.takahashi_gain)
            {
                return -1;
            }
            else if (x.takahashi_gain < y.takahashi_gain)
            {
                return 1;
            }
            else
            {
                if (x.takahashi > y.takahashi) return -1;
                else if (x.takahashi < y.takahashi) return 1;
                else return 0;
            }
        }
    }
}

Measured memory_bytes: 18484
fun main(args: Array<String>) {
  val sc = if (args.size > 1) java.util.Scanner(java.io.File(args[1])) else java.util.Scanner(System.`in`)
  solve(sc)
}

fun solve(sc: java.util.Scanner) {
  val A = sc.nextInt()
  val B = sc.nextInt()
  val C = sc.nextInt()
  val D = sc.nextInt()
  println((A..(B-1)).intersect(C..(D-1)).toSet().count())
}


Measured memory_bytes: 31516
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  int n; cin >> n;
  map<int,int> cnt;
  vi a(n);
  rep(i,n) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  vector<pii> nums(cnt.begin(), cnt.end());

  if (nums.size() > 2) {
    cout << "No" << endl;
    return 0;
  }
  if (nums.size() == 2 and nums[0].fs+1 != nums[1].fs) {
    cout << "No" << endl;
    return 0;
  }

  if (nums.size() == 1) {
    cout << ( (nums[0].fs <= n/2 or nums[0].fs == n-1) ? "Yes" : "No") << endl;
    return 0;
  }

  int k = nums[1].fs;
  int m = nums[0].sc;
  int l = nums[1].sc;
  if (l==1) {
    cout << "No" << endl;
    return 0;
  }
  cout << ( (m+1<=k and k<=m+l/2) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 6144
n=int(input())
arr=[input() for _ in range(n)]
dic={}
for i in range(n): #各単語の出現回数を数える
 if arr[i] not in dic:
   dic[arr[i]]=1
 else:
   dic[arr[i]]+=1
largest=max(dic.values()) #最大の出現回数を求める
ans=[]
for keys in dic.keys():
 if dic[keys]==largest: #出現回数が最も多い単語を集計する
   ans.append(keys)
ans=sorted(ans) #単語を辞書順に並べ替えて出力する
for words in ans:
 print(words)

Measured memory_bytes: 99024
#include "bits/stdc++.h"

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	map<int, int>mp;
	for (int i = 0;i<N;++i) {
		int a;
		cin >> a;
		mp[a]++;
	}
	vector<int>vec;
	for (auto a:mp) {
		vec.push_back(a.second);
	}
	sort(vec.rbegin(),vec.rend());
	int ans = 0;	
	for (int i = K; i < vec.size(); ++i) {
		ans += vec[i];
	}
	cout << ans <<  endl;
	return 0;
}


Measured memory_bytes: 13544
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	string s;
	
	cin>>s;
	
	if(s.back() == 's') s += "es";
	else s += 's';
	
	
	cout<<s<<endl;
	
	return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	std::string s;
	std::cin >> s;
	bool res = true;
	for (int i = 0; i < 3; i++)if (s[i] == s[i + 1]) res = false;
	std::cout << (res ? "Good" : "Bad") << std::endl;
	return 0;
}


Measured memory_bytes: 256
char out[1<<20];outsz;
char ffs[]="0101110101011101110111010101110101011101010111011101110101011101110111010101110111011101010111010101110101011101110111010101110101011101010111011101110101011101010111010101110111011101010111011101110101011101110111010101110101011101010111011101110101011101110111010101110111011101010111010101110101011101110111010101110111011101010111011101110101011101010111010101110111011101010111010101110101011101110111010101110101011101010111011101110101011101110111010101110111011101010111010101110101011101110111010101110101011101010111011101110101011101010111010101110111011101010111011101110101011101110111010101110101011101010111011101110101011101010111010101110111011101010111010101110101011101110111010101110111011101010111011101110101011101010111010101110111011101010111011101110101011101110111010101110101011101010111011101110101011101110111010101110111011101010111010101110101011101110111010101110101011101010111011101110101011101010111010101110111011101010111011101110101011101110111010101110101011101010111011101110101011101";
char in[9];
main(){
	read(0,in,5);
	int N,M;
	if(in[1]==' ')
	{
		N=1<<in[0]-'0';
		if(in[3]=='\n')
		{
			M=1<<in[2]-'0';
		}
		else
		{
			M=1024;
		}
	}
	else
	{
		N=1024;
		if(in[4]=='\n')
		{
			M=1<<in[3]-'0';
		}
		else
		{
			M=1024;
		}
	}
	for(int i=1;i<N;i++)
	{
		for(int j=1;j<M;j++)
		{
			out[outsz++]=ffs[i|j];
		}
		out[outsz++]='\n';
	}
	write(1,out,outsz);
}


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

int main() {
  long int s = 0,sum = 0;
  long int N, tmp, o;
  cin >> N;
  
  for(int j = 0;j<8;j++){
    tmp = N - s;    
    o = 1;
    for(int i = j;i<8;i++){
      tmp /= 10; 
        o *= 10;
    }
    s += tmp * o;
    sum += tmp;
  }
  tmp = N - s;
  sum += tmp;
  if (N%sum>0){
  cout << "No" << endl;
  }
  else{
  cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>

#define MAXN 8
int H,W;
char Map[MAXN+5][MAXN+5];

int main(){
    scanf("%d%d",&H,&W);
    for(int i=1;i<=H;i++)
        scanf("%s",Map[i]+1);
    for(int i=1;i<=H;i++)
        for(int j=1;j<=W;j++){
            if(Map[i][j]!='#')
                continue;
            if(Map[i][j-1]=='#'&&Map[i-1][j]=='#'){
                puts("Impossible");
                return 0;
            }
            if(i==H&&j==W)
                break;
            if((Map[i][j+1]=='#'&&Map[i+1][j]=='#')||(Map[i][j+1]!='#'&&Map[i+1][j]!='#')){
                puts("Impossible");
                return 0;
            }
        }
    puts("Possible");
}


Measured memory_bytes: 128
#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;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int test)
{
  int a, b, c;
  cin >> a >> b >> c;
  cout << b * (c / a) << '\n';
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


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

using namespace std;

#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))


#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
    cerr << name << " is " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " is " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif


void solve()
{

    long long mod=2019ll;

    long long l,r;
    cin>>l>>r;

    if(l*r<mod)
    {
        cout<<l*(l+1)<<endl;
        return;
    }

    long long mn=(l);

    long long mx=(r);

    long long div=(mn+mod-1)/mod;

    if(div*mod<=mx){
        cout<<0<<endl;
        return;
    }



    long long temp=r;

    int tl=l%mod;
    int tr=r%mod;

    l=min(tl,tr);
    r=max(tl,tr);


    long long res=2020;

    for(int i=l;i<=r-1;i++){

        for(int j=i+1;j<=r;j++){
            long long mul=i*j;
           // cout<<((i*j))%mod<<endl;
            res=min(((i*j)%mod),res);
        }
    }
    cout<<res<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    cout.tie(nullptr);
    cin.tie(nullptr);

    int t = 1;

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

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define vsort(v) sort(all(v))
#define mod 1000000007
using data=pair<ll,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

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

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}


int main(){
  ll i,j,N,K,x,f=0;
  cin>>N;
  K=countdigits(N);
  if(K<countdigits(N+1)){
    cout<<sumdigits(N)<<endl;
  }else if(K>countdigits(N-1)){
    if(N==1){
      cout<<1<<endl;
    }else{
      cout<<sumdigits(N-1)<<endl;
    }
  }else{
    N++;
    rep(i,K-1){
      N/=10;
    }
    cout<<N-1+(K-1)*9+f<<endl;
  }
  return 0;
}

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

int main()
{
     long long int n,m,l1[101],x3=0,x4=0,s=0;
     double x12,x13;
     cin>>n>>m;
     for(int i=1;i<=n;i++){
         cin>>l1[i];
         x3+=l1[i];
     }
     x12=(x3+0.0)/(4*m);
     for(int i=1;i<=n;i++){
           if(l1[i]>=x12)x4++;
       if(x4>=m){cout<<"Yes\n";return 0;}
     }
  cout<<"No\n";
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <functional>

using namespace std;


int main() {
	int N;
	int a[101];
	int Alice = 0;
	int Bob = 0;

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

	sort(a, a + N, greater<int>());
	
	for (int i = 0; i < N; i += 2) {
		Alice += a[i];
	}
	for (int i = 1; i < N; i += 2) {
		Bob += a[i];
	}

	printf("%d", Alice - Bob);


	return 0;
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
int n,tot;
bitset<4000004>a;
int main() {
	read(n);a[0]=1;
	while(n--){
		int x;read(x);tot+=x;a|=a<<x;
	}
	rep(i,(tot+1)/2,tot)if(a[i]){printf("%d\n",i);return 0;}
	return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<vector>
using namespace std;
 
int main()
{
    // get two integers separated with half-width break
    int N,M;
    cin >> N >> M;

    // get a string
    vector<int> c2l;
    c2l.resize(N);
    for(int i = 0; i < M; ++i){
      int a,b;
      cin >> a >> b;

      c2l[a-1]++;
      c2l[b-1]++;
    }
    // output
    for(int i = 0; i < N; ++i){
      cout << c2l[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	string ss, tmp;
	int64 qq, tt, ff;
	bool muki = false;
	cin >> ss >> qq;
	for(int64 ii = 0;ii < qq;ii++)
	{
		cin >> tt;
		if(tt == 1)
		{
			muki = !muki;
		}
		else
		{
			cin >> ff >> tmp;
			if(ff == 1 ^ muki)
			{
				ss = tmp + ss;
			}
			else
			{
				ss += tmp;
			}
		}
	}
	if(muki)
	{
		reverse(ss.begin(), ss.end());
	}
	cout << ss << endl;
	return 0;
}


Measured memory_bytes: 4760
a,b,c,d,e,f=map(int,input().split())
t=100
for i in range(0,f+1,a*100):
    for j in range(0,f-i+1,b*100):
        k=i+j
        if k==0:
            continue
        s=min(f-i-j,(i+j)*e//100)
        for ii in range(0,s+1,c):
            for jj in range(0,s-ii+1,d):
                if t>e-(ii+jj)*100/(i+j):
                    t=e-(ii+jj)*100/(i+j)
                    x,y=ii+jj+i+j,ii+jj
print(str(x)+" "+str(y))                    
                    
                

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

int main() {
    int A, B;
    cin >> A >> B;
    int cnt = 0;
    for (int i = A; i <= B; i++){
        if (i/10000 == i%10 && (i/1000)%10 == (i%100)/10){
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int fir[100010],dis[200010],nxt[200010],w[200010],id;
void link(int a,int b,int c){nxt[++id]=fir[a],fir[a]=id,dis[id]=b,w[id]=c;}
int dfn[100010],end[100010],siz[100010];
void dfs(int x,int fa=-1){
	dfn[x]=++dfn[0];siz[x]=1;
	for(int i=fir[x];i;i=nxt[i]){
		if(fa==dis[i])continue;
		dfs(dis[i],x);
		siz[x]+=siz[dis[i]];
	}
	end[x]=dfn[0];
}
int A[100010],B[100010],C[100010];
ll c[100010],now[100010],MAX=-9e18,CMAX=-9e18,ans=-9e18;
struct fuck{int x,o,l,r;}f[10];
bool operator<(fuck a,fuck b){return a.x<b.x;}
int main(){
	int n=gi(),u,v,w;
	for(int i=1;i<n;++i)A[i]=u=gi(),B[i]=v=gi(),C[i]=w=gi(),link(u,v,w),link(v,u,w);
	dfs(1);
	int m=0;ll delta=0;
	for(int i=1;i<n;++i){
		u=A[i],v=B[i];
		if(dfn[u]>dfn[v])std::swap(u,v);
		delta+=1ll*C[i]*std::min(siz[v],n-siz[v])*2;
		if(siz[v]*2==n){
			delta-=C[i];
			if(dfn[v]!=1){
				f[++m]={1,-C[i],1,dfn[v]-1};
				f[++m]={dfn[v],C[i],1,dfn[v]-1};
				f[++m]={end[v]+1,-C[i],1,dfn[v]-1};
			}
			if(end[v]!=n){
				f[++m]={1,-C[i],end[v]+1,n};
				f[++m]={dfn[v],C[i],end[v]+1,n};
				f[++m]={end[v]+1,-C[i],end[v]+1,n};
			}
			f[++m]={dfn[v],-C[i],dfn[v],end[v]};
			f[++m]={end[v]+1,C[i],dfn[v],end[v]};
		}else{
			if(siz[v]*2<n)c[dfn[v]]-=C[i],c[end[v]+1]+=C[i];
			else c[1]-=C[i],c[dfn[v]]+=C[i],c[end[v]+1]-=C[i];
		}
	}
	for(int i=1;i<=n;++i)now[i]=c[i]+=c[i-1];
	for(int i=1;i<=n;++i)
		if(now[i]>MAX)CMAX=MAX,MAX=now[i];
		else if(now[i]>CMAX)CMAX=now[i];
	std::sort(f+1,f+m+1);
	for(int i=1,p=1;i<=n;++i){
		while(p<=m&&f[p].x==i){
			for(int j=f[p].l;j<=f[p].r;++j)now[j]+=f[p].o;
			MAX=CMAX=-9e18;
			for(int j=1;j<=n;++j)
				if(now[j]>MAX)CMAX=MAX,MAX=now[j];
				else if(now[j]>CMAX)CMAX=now[j];
			++p;
		}
		ans=std::max(ans,(now[i]!=MAX?MAX:CMAX)+c[i]);
	}
	printf("%lld\n",ans+delta);
	return 0;
}


Measured memory_bytes: 10880
/*
  Vivek Rathi
  CSE 2nd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e18
#define flush fflush(stdout);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}
//-------------------------------Template--Above------------------------------------------------


int main()
{
	boost
	ll n;
	cin>>n;
	ll a[n];
	ll x[n];
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
		a[i]*=2;
	}
	ll sum=0;
	for(ll i=0;i<n;i++)
	{
		if(i%2==0)
			sum+=a[i];
		else
			sum-=a[i];
	}
	sum/=2;
	x[0]=sum;
	for(ll i=0;i<n-1;i++)
	{
		x[i+1]=a[i]-x[i];
	}
	for(ll i=0;i<n;i++)
		cout<<x[i]<<" ";
	return 0;
}


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

int main()
{
	int n;
	cin>>n;vector<int> v(n);
	for(int i=0;i<n;i++)
	{
		cin>>v[i];
	}
	int cnt=1;int ans=0;
	for(int i=n-1;i>=1;i--)
	{
		if(v[i-1]>=v[i]) cnt++;
		else
		{
			ans=max(cnt,ans);cnt=1;
		}
	}
	ans=max(cnt,ans);
	cout<<ans-1<<endl;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    int n,m;
    cin>>n>>m;
    char a[n+2][m+2];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i+1][j+1];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(a[i+1][j+1]==' ') continue;
            if(a[i+1][j+1]=='.'){
                int count=0;
                if(a[i+1][j]=='#') count++;
                if(a[i+1][j+2]=='#') count++;
                if(a[i][j+1]=='#') count++;
                if(a[i][j]=='#') count++;
                if(a[i+2][j+1]=='#') count++;
                if(a[i+2][j+2]=='#') count++;
                if(a[i+2][j]=='#') count++;
                if(a[i][j+2]=='#') count++;
                cout<<count;
            }else{ cout<<a[i+1][j+1];}
        }
        cout<<endl;
    }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);
bool flag[4001];

int main() {
	int N;
	string S;
	cin >> N >> S;
	vector<int> v, data[3];
	for (auto i : S) {
		if (i == 'R') v.pb(0);
		else if (i == 'G') v.pb(1);
		else v.pb(2);
	}
	for (int i = 0; i < N; i++) {
		data[v[i]].pb(i);
	}
	LL ans = data[0].size();
	ans *= data[1].size();
	ans *= data[2].size();
	for (auto i : data[2]) {
		flag[i] = 1;
	}
	for (auto i : data[0]) {
		for (auto j : data[1]) {
			int x = i, y = j;
			if (x > y) swap(x, y);
			//left
			if (2 * x - y >= 0) {
				ans -= flag[2 * x - y];
			} 
			//middle
			if ((x + y) % 2 == 0) {
				ans -= flag[(x + y) / 2];
			}
			//right
			if (2 * y - x < N) {
				ans -= flag[2 * y - x];
			}
		}
	}
	printf("%lld\n", ans);
} 

Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e15;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    int n,k;
    cin >> n;
    rep(i,1,10){
        k = i + 10*i + 100*i;
        if (n <= k){
            PRINT(k);
            break;
        }
    }
}

Measured memory_bytes: 256
def main():
    n, A, B, C, D = map(int, input().split())
    N = n-1
    a = A-N*D
    b = a+N*(D-C)
    for i in range(n):
        if a <= B <= b:
            return "YES"
        a = b + 2*C-(N-1)*(D-C)
        b = a + N*(D-C)
    return "NO"

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
using namespace std;

bool check(int N)
{
    int s=sqrt(N);
    return s*s==N;
}

signed main()
{
    int N,D; cin>>N>>D;
    vector<vector<int>> x(N,vector<int>(D));
    for(int i=0;i<N;i++){
        for(int j=0;j<D;j++){
            cin>>x[i][j];
        }
    }  

    int ans=0;
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            int sum=0;
            for(int k=0;k<D;k++){
                sum+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            if(check(sum)) ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define first first
#define second se
using namespace std;
typedef pair<int, int> P;
typedef vector<int> vi;

signed main(){
    string s;
    int n, a, b;
    int na = 0, nb = 0;
    cin >> n >> a >> b >> s;
    rep(i, 0, s.size()){
        if(s[i] == 'a' && (na + nb) < (a + b)){
            o("Yes");
            na++;
        }else if(s[i] == 'b' && (na + nb) <(a + b) && nb < b){
            o("Yes");
            nb++;
        }else{
            o("No");
        }
    }
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<int,int> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


int n,x;
int l[110];

int main(){
	cin>>n>>x;
	REP(i,n){
		cin>>l[i];
	}
	int ans=1;
	int d=0;
	REP(i,n){
		d+=l[i];
		if(d<=x)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
int n,q;
vector<vector<int> > G(200010);
ll counter[200010];
int dfs1(int x,int p){
    counter[x]+=counter[p];
    for(auto e:G[x]){
        if(e==p)continue;
        dfs1(e,x);
    }
    return 0;
}
int main(){
    cin>>n>>q;
    rep(i,n-1){
        int a,b;cin>>a>>b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i,q){
        int p,x;cin>>p>>x;
        counter[p]+=x;
    }
    dfs1(1,0);
    REP(i,1,n)cout<<counter[i]<<' ';
    cout<<counter[n]<<endl;
}


Measured memory_bytes: 24320
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


N = I()
ans = 0
if N >= 105:
    for i in range(105, N+1, 2):
        yakusu = 0
        for q in range(1, N+1):
            if i % q == 0:
                yakusu += 1
        if yakusu == 8:
            ans += 1
print(ans)


Measured memory_bytes: 38512
#include<iostream>
#include<string>
#include<math.h>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int main(){
    unsigned long long int X, temp = 100;
    cin >> X;
    int i = 0;
    while(temp < X){
        temp *= 1.01;
        i++;
    }
    cout << i << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
signed main(){
    int n;
    cin >> n;
    vector<long long> X(n),Y(n),P(n),T(n);
    long long U = 0;
    for(int i=0;i<n;i++){
        cin >> X[i] >> Y[i] >> P[i];
        T[i] = min(abs(X[i]),abs(Y[i]));
        U += P[i]*T[i];
    }
    vector<long long>L(n+1,U);
    int mask = (1<<n)-1;
    vector<vector<long long>> A(n, vector<long long>(1<<n,U)),B(n, vector<long long>(1<<n,U));
    for(int j=0;j<n;j++){
        for(int i=0;i<1<<n;i++){
            if((i>>j)&1){
                for(int q=0;q<n;q++){
                    A[q][i] = min(A[q][i],abs(X[q]-X[j]));
                    B[q][i] = min(B[q][i],abs(Y[q]-Y[j]));
                }
            }
        }
    }
    for(int i=0;i<1<<n;i++){
        int s = i ^ mask;
        for(int j=i;j>0;j=(j-1)&i){
            long long temp = 0;
            int cnt = 0;
            for(int k=0;k<n;k++){
                temp += P[k]*min(min(A[k][s],B[k][j]),T[k]);
                if(((s>>k)&1)|((j>>k)&1)) cnt += 1;
            }
            L[cnt] = min(L[cnt],temp);
        }
        long long temp = 0;
        int cnt = 0;
        for(int k=0;k<n;k++){
            temp += P[k]*min(A[k][s],T[k]);
            if((s>>k)&1) cnt += 1;
        }
        L[cnt] = min(L[cnt], temp);
    }
    for(int i=0;i<=n;i++) cout << L[i] << endl;
    return 0;
}

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


int main() {
	string s;
	cin >> s;
	int i = 0;
	while (s[i] != '\0') {
		i++;
	}
	int ans = 0;
	for (int j = 0; j < i; j++) {
		if (s[j] == '1')ans++;
		else ans--;
	}
	if (ans < 0)ans = -ans;
	cout << i - ans << endl;

	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H==0 && W ==0){
                break;
            }
            for(int i=0;i<H;i++){
                if(i==0 || i==H-1){
                    for(int j=0;j<W;j++){
                        System.out.printf("#");
                    }
                }else{
                    for(int j=0;j<W;j++){
                        if(j==0 || j==W-1){
                            System.out.printf("#");
                        }else{
                            System.out.printf(".");                
                        }
                    }
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
    }
}


Measured memory_bytes: 58200