akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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 (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n, a;
  cin >> n >> a;

  if (n % 500 <= a) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>

int main(){
        int n, u, k, num, mat[128][128];
        int i, j;

        for(i = 1 ; i <= n ; i++){
                for(j = 1 ; j <= n ; j++){
                        mat[i][j] = 0;
                }
        }

        scanf("%d", &n);

        for(i = 1 ; i <= n ; i++){
                scanf("%d %d", &u, &k);
                for(j = 0 ; j < k ; j++){
                        scanf("%d", &num);
                        mat[u][num] = 1;
                }
        }

        for(i = 1 ; i <= n ; i++){
                for(j = 1 ; j <= n; j++){
                        printf("%d", mat[i][j]);
                        if(j < n)printf(" ");
                }
                printf("\n");
        }

        return 0;
}



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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()
#define m_p make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,k,q;
    cin >> n >> k >> q;
    vector<ll> a(q);
    vector<bool> ok(n,false);
    map<ll,ll> mp;
    rep(i,q){
        cin >> a[i];
        mp[a[i]]++;
    }
    if(k-q>0){
        rep(i,n){
            cout << "Yes" << endl;
        }
        return 0;
    }
    rep(i,q){
        if(k-(q-mp[a[i]])>0) ok[a[i]-1] = true;
    }
    rep(i,n){
        if(ok[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 5376
n, d = list(map(int, input().split()))
x = [list(map(int, input().split())) for _ in range(n)]
ans = 0

for i in range(n-1):
    for j in range(i+1, n):
        tmp = 0
        for a, b in zip(x[i], x[j]):
            tmp += (a-b)**2
        ans += (tmp**0.5).is_integer()

print(ans)

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[252521];

bool check(int x){
  int m = 2*n-1;
  int l = n-1;
  int r = n-1;
  if((a[l]>=x)^(a[l-1]>=x)==0)return a[l]>=x;
  if((a[r]>=x)^(a[r+1]>=x)==0)return a[r]>=x;
  while(l>0 && (a[l]>=x)^(a[l-1]>=x)==1)--l;
  while(r<m-1 && (a[r]>=x)^(a[r+1]>=x)==1)++r;
  if((n-1)-l <= r-(n-1)){
    return a[l]>=x;
  }else{
    return a[r]>=x;
  }
}

int main(){
  scanf("%d",&n);
  REP(i,2*n-1)scanf("%d",a+i);
  int low = 0, high = 2*n;
  while(low+1<high){
    int mid = (low+high)/2;
    if(check(mid))low=mid;
    else high=mid;
  }
  printf("%d\n",low);
  return 0;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    string s;
    cin >> s;
    ll n = s.size();
    ll cnt = 0;
    ll ans = 0;
    for(i = 0;i < n;++i){
        if(s.at(i) == 'W'){
            ans += i;
            ++cnt;
        }
    }
    for(i = 0;i < cnt;++i){
        ans -= i;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/


int main() {
	cin >> n;
	REP(i,n) {
		cin >> m >> k;
		if(m==k){
			cout << (m - 1) * 2 << endl;
		}else{
			ans = sqrt(m * k);
			if(ans*(ans+1)<m*k){
				cout << ans - 1 + ans << endl;
			}else if(ans*ans==m*k){
				cout << ans - 1 + ans - 2 << endl;
			}else{
				cout << ans - 1 + ans - 1 << endl;
			}
		}
	}
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	long la = rlong, lb = rlong, lx = rlong;
	if(lx == 0){
		"90.0000000".writeln;
		return;
	}
	else if(la * la * lb == lx){
		"0.00000000".writeln;
		return;
	}
	
	real a = la.to!real, b = lb.to!real, x = lx.to!real;

	real s = x / a;
	
	real ans;
	if(s >= b * a / 2){
		real h = s / a * 2 - b;
		ans = atan((b - h) / a) / PI * 180;
	}
	else{
		real w = s / b * 2;
		ans = atan(b / w) / PI * 180;
	}
	
	
	writefln("%10.10f", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<unsigned int mod_>
struct ModInt{
	using uint = unsigned int;
	using ll = long long;
	using ull = unsigned long long;

	constexpr static uint mod = mod_;

	uint v;
	ModInt():v(0){}
	ModInt(ll v):v(normS(v%mod+mod)){}
	explicit operator bool() const {return v!=0;}
	static uint normS(const uint &x){return (x<mod)?x:x-mod;}		// [0 , 2*mod-1] -> [0 , mod-1]
	static ModInt make(const uint &x){ModInt m; m.v=x; return m;}
	ModInt operator+(const ModInt& b) const { return make(normS(v+b.v));}
	ModInt operator-(const ModInt& b) const { return make(normS(v+mod-b.v));}
	ModInt operator-() const { return make(normS(mod-v)); }
	ModInt operator*(const ModInt& b) const { return make((ull)v*b.v%mod);}
	ModInt operator/(const ModInt& b) const { return *this*b.inv();}
	ModInt& operator+=(const ModInt& b){ return *this=*this+b;}
	ModInt& operator-=(const ModInt& b){ return *this=*this-b;}
	ModInt& operator*=(const ModInt& b){ return *this=*this*b;}
	ModInt& operator/=(const ModInt& b){ return *this=*this/b;}
	ll extgcd(ll a,ll b,ll &x,ll &y) const{
		ll u[]={a,1,0},v[]={b,0,1};
		while(*v){
			ll t=*u/ *v;
			rep(i,3) swap(u[i]-=t*v[i],v[i]);
		}
		if(u[0]<0) rep(i,3) u[i]=-u[i];
		x=u[1],y=u[2];
		return u[0];
	}
	ModInt inv() const{
		ll x,y;
		extgcd(v,mod,x,y);
		return make(normS(x+mod));
	}
	bool operator==(const ModInt& b) const { return v==b.v;}
	bool operator!=(const ModInt& b) const { return v!=b.v;}
	friend istream& operator>>(istream &o,ModInt& x){
		ll tmp;
		o>>tmp;
		x=ModInt(tmp);
		return o;
	}
	friend ostream& operator<<(ostream &o,const ModInt& x){ return o<<x.v;}
};
using mint = ModInt<1000000007>;
mint i2 = (mint)1/2;
mint f[3000][3000];
int is[20000];
int js[20000];
mint vs[20000];
int main(){
	int N,Q;
	cin>>N>>Q;
	V<int> a(N);
	rep(i,N) cin>>a[i];
	rep(i,N) rep(j,N) if(i>j) f[i][j] = 1;
	V<int> X(Q),Y(Q);
	rep(i,Q){
		cin>>X[i]>>Y[i];
		X[i]--,Y[i]--;
	}
	for(int t=Q-1;t>=0;t--){
		int K = 0;
		auto add = [&](int i,int j,mint v){
			is[K] = i;
			js[K] = j;
			vs[K] = v;
			K++;
		};
		int x = X[t], y = Y[t];
		rep(_,2){
			add(x,y,i2);
			rep(j,N) if(j!=x && j!=y){
				add(x,j,(f[x][j]+f[y][j])/2);
				add(j,x,(f[j][x]+f[j][y])/2);
			}
			swap(x,y);
		}
		rep(k,K){
			f[is[k]][js[k]] = vs[k];
		}
	}
	mint ans = 0;
	rep(i,N) rep(j,N) if(a[i]<a[j]) ans += f[i][j];
	rep(_,Q) ans *= 2;
	cout<<ans<<endl;
}

Measured memory_bytes: 35584
class Forest:
    def __init__(self, g, id):
        self.forest = set([id])
        self.graph = g
        self.next_wait = self.graph[id]
        self.wait = 0
    def add_tree(self, id):
        self.wait += self.next_wait[id]
        self.forest.update([id])
         
        self.marge_next_wait(id)
    def next_tree(self):
        min_id = min_wait = None
        for id, wait in self.next_wait.items():
            if id not in self.forest:
                if min_wait == None or min_wait > wait:
                    min_wait = wait
                    min_id = id
        return min_id
    def marge_next_wait(self, merge_id):
        for id, wait in self.graph[merge_id].items():
            if id not in self.next_wait or self.next_wait[id] > wait:
                self.next_wait[id] = wait
n = int(input())
g = [{e:i for e, i in enumerate(map(int, input().split())) if i != -1} for _ in range(n)]
forest = Forest(g,0)
for i in range(n - 1):
    id = forest.next_tree()
    forest.add_tree(id)
print(forest.wait)    

Measured memory_bytes: 7168
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;



void main() {
    while (true) {
        int H;
        scan(H);
        if (!H) return;
        auto g = iota(H).map!(i => readln.split.to!(int[])).array;
        auto ans = solve(H, g);
        writeln(ans);
    }
}

int solve(int H, int[][] g) {
    int res;

    bool fine = false;

    while (!fine) {
        fine = true;

        auto cnt = new int[][](H, 5);
        auto gc = new int[][](H, 5);

        foreach (i ; 0 .. H) {
            foreach (j ; 0 .. 5) {
                gc[i][j] = g[i][j];
            }
        }

        foreach_reverse (i ; 0 .. H) {
            foreach (j ; 0 .. 3) {
                if (g[i][j] && g[i][j] == g[i][j+1] && g[i][j+1] == g[i][j+2]) {
                    cnt[i][j] = cnt[i][j+1] = cnt[i][j+2] = 1;
                    gc[i][j] = gc[i][j+1] = gc[i][j+2] = 0;
                    fine = false;
                }
            }
        }

        debug {
            writefln("%(%s\n%)", gc);
            writeln;
            //writefln("%(%s\n%)", cnt);
        }

        // スコア計算
        foreach (i ; 0 .. H) {
            foreach (j ; 0 .. 5) {
                res += g[i][j] * cnt[i][j];
            }
        }

        auto gg = new int[][](H, 5);

        foreach (j ; 0 .. 5) {
            int pos = H - 1;
            foreach_reverse (i ; 0 .. H) {
                if (gc[i][j] != 0) {
                    gg[pos][j] = gc[i][j];
                    pos--;
                }
            }
        }

        debug {
            writefln("%(%s\n%)", gg);
            writeln;
        }

        g = gg;
    }

    return res;
}



void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


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

int main(){
    ll N,M;
    cin >> N >> M;
    ll sum = N*(N-1)/2 + M*(M-1)/2;


    cout << sum << endl;
    
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

bool solve(){
  int n;
  int score[SIZE];
  
  scanf("%d",&n);

  if(n == 0) return false;
  
  for(int i=0;i<n;i++){
    scanf("%d",score+i);
  }

  sort(score, score+n);

  int sum = 0;

  for(int i=1;i<n-1;i++)
    sum += score[i];

  printf("%d\n",sum/(n-2));

  return true;
}

int main(){

  while(solve());
  
  return 0;
}

Measured memory_bytes: 3268
#include <iostream>

using namespace std;

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

	int max1 = 100 / 4;
	int max2 = 100 / 7;
	for (int i = 0; i <= max1; i++) {
		for (int j = 0; j <= max2; j++) {
			if (i * 4 + j * 7 == n) {
				cout << "Yes" << '\n';
				return 0;
			}
		}
	}
	cout << "No" << '\n';
	return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

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

	llong ans = 0;
	for (llong i = 1; i*i < N; i++) {
		if (N%i == 0) {
			if (i == N%(N/i-1))
				ans += N/i-1;
		}
	}

	cout << ans << endl;

	return 0;
}

/*
2499686339916
2499695822171

*/

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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
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; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
}

int main()
{
    ll H,W,A,B;
    cin >> H >> W >> A >> B;
    rep(i, H) {
      rep(j, W) {
        if (i < B) {
          if (j < A) {
            cout << 0;
          } else {
            cout << 1;
          }
        } else {
          if (j < A) {
            cout << 1;
          } else {
            cout << 0;
          }
        }
        
      }
      cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>

int main() {
  int N, K;
  scanf ("%d %d", &N, &K);
  int scores[N];

  for (int i = 0; i < N; i++) {
    scanf("%d", &scores[i]);
  }
    
  for (int i = 0; i < N-K; i++) {
    (scores[i] < scores[i+K]) ? puts("Yes") : puts("No");
  }
    
  return 0;
}

Measured memory_bytes: 2412
def main():
    n = int(input())
    ans = [0] * n

    for x in range(1,100):
        for y in range(1,100):
            for z in range(1,100):
                m = x**2+y**2+z**2+x*y+y*z+z*x
                if m <= n:
                    ans[m-1] += 1

    for i in range(n):
        print(ans[i])

main()

Measured memory_bytes: 9304
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }


int main() {
    int n, m;
    array<int, 4> dx{-1, 1, 0, 0}, dy{0, 0, -1, 1};
    while(cin >> m >> n, n){
        auto G = make_v(n+4, m+4, -1);
        for (int i = 1; i < n+3; ++i) {
            for (int j = 1; j < m+3; ++j) {
                G[i][j] = 1;
            }
        }
        int gx = 0, gy = 0;
        for (int i = 0; i < n; ++i) {
            string s;
            cin >> s;
            for (int j = 0; j < m; ++j) {
                G[i+2][j+2] = (s[j] != '#');
                if(s[j] == '&'){
                    gy = i+2, gx = j+2;
                }
            }
        }
        auto dp = make_v(n+4, m+4, -1);
        dp[1][1] = 0;
        deque<pair<int, int>> Q;
        Q.emplace_back(1, 1);
        while(!Q.empty()){
            int y, x; tie(y, x) = Q.front(); Q.pop_front();
            for (int k = 0; k < 4; ++k) {
                if(!~G[y+dy[k]][x+dx[k]] || ~dp[y+dy[k]][x+dx[k]]) continue;
                if(G[y][x] == G[y+dy[k]][x+dx[k]]){
                    dp[y+dy[k]][x+dx[k]] = dp[y][x];
                    Q.emplace_front(y+dy[k], x+dx[k]);
                }else {
                    dp[y+dy[k]][x+dx[k]] = dp[y][x]+1;
                    Q.emplace_back(y+dy[k], x+dx[k]);
                }
            }
        }
        cout << dp[gy][gx]/2 << "\n";
    }
    return 0;
}


Measured memory_bytes: 3248
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            while (sc.hasNext()) {
                String line = sc.nextLine();
                int n = Integer.parseInt(line.split(" ")[0]);
                int m = Integer.parseInt(line.split(" ")[1]);
                int x = Integer.parseInt(line.split(" ")[2]);
                String[] a_strs = sc.nextLine().split(" ");
                int l = a_strs.length;
                int counter = 0;
                for(int i=0; i<l; i++){
                    if(Integer.parseInt(a_strs[i]) < x){
                        counter++;
                    }else{
                        break;
                    }
                }
                System.out.println((counter < l-counter) ? counter : l - counter);
            }
        }
    }
}

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

#define rep(i,a,b) for(long long i = (a); i < (b); i++)
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
using ll = long long;

ll lcm(ll a,ll b){

	return (a*b)/(__gcd(a,b));
}


void solve()
{
	
	int  n;
	cin>>n;
	vector<int> v(n);
	rep(i,0,n){
		cin>>v[i];
	}
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			for(int k=j+1;k<n;k++){
				if(v[i]!=v[j]&&v[j]!=v[k]&&v[i]!=v[k]){
					vector<int> h;
					h.push_back(v[i]);
					
					h.push_back(v[j]);
					
					h.push_back(v[k]);
					sort(all(h));
					if(h[0]+h[1]>h[2]){
						ans++;
					}
					
				}
			}
		}
	}
	cout<<ans;
}



int  main(){
	solve();
	cout<<endl;


}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
int main()
{
	int n;
	cin>>n;
	float c,d;
	c=1.*n/3;
	d=c*c*c;
	printf("%.7f",d);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  //if(a>b) swap(a,b);
  rep(i,max(a,b)){
    cout<<min(a,b);
  }
  cout<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main(){
    ll N,K;
    cin >> N >> K;
    ll ans = 0;
    for(ll i = K; i <= N + 1; i++){
        ans += i * (N - i + 1) + 1;
        ans = ans % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <map>
#include <set>
#include <sstream>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;

int main(void)
{
    string s, t;
    cin >> s;
    cin >> t;
    int cnt = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] != t[i])
        {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3860
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mod 1000000007

vector<int> arr;
int k;
unordered_map<int, int> mp;

int dp(int pos, int n)
{
    if(mp.find(pos)!=mp.end())
        return mp[pos];
    if(pos==n)
        return mp[pos]=0;
    if(pos>n)
        return mp[pos]=100000000000;
    int ans=10000000000;
    for(int i=1; i<=k; i++)
    {
        if(pos+i>n)
            break;
        ans=min(ans, abs(arr[pos]-arr[pos+i])+dp(pos+i, n));
    }
    return mp[pos]=ans;
    // return mp[pos]=min(abs(arr[pos]-arr[pos+1])+dp(pos+1, n), abs(arr[pos]-arr[pos+2])+dp(pos+2, n));
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n>>k;
    arr.resize(n+5);
    for(int i=0; i<n; i++)
        cin>>arr[i];
    cout<<dp(0, n-1);
    return 0;
}

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

int main(){ 
  int n, q;
  cin >> n;
  vector<int> a(n);
  ll ans = 0;
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
    ans += a.at(i);
  }
  cin >> q;
  vector<int> b(q);
  vector<int> c(q);
  for(int i = 0; i < q; i++) cin >> b.at(i) >> c.at(i);
  
  vector<int> vec(100001, 0);
  vector<ll> change;
  for(int i = 0; i < n; i++) vec.at(a.at(i))++;
  
  for(int i = 0; i < q; i++){
    vec.at(c.at(i)) += vec.at(b.at(i));
    change.push_back(vec.at(b.at(i))*(c.at(i) - b.at(i)));
    vec.at(b.at(i)) = 0;
  }
  
  for(int i = 0; i < q; i++){
    cout << ans + change.at(i) << endl;
    ans += change.at(i);
  }
  return 0;
}

Measured memory_bytes: 5844
import sys, math,os
from io import BytesIO, IOBase
#data = BytesIO(os.read(0,os.fstat(0).st_size)).readline
# from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
# from itertools import permutations,combinations
from decimal import Decimal
from fractions import Fraction
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var): sys.stdout.write(' '.join(map(str, var)) + '\n')
def out(var): sys.stdout.write(str(var) + '\n')
#sys.setrecursionlimit(100000 + 1)
INF = 10**9
mod = 10**9 + 7


n,k=mdata()
a=mdata()
n1,p=-1,-1
a1=[(abs(a[i]),a[i]) for i in range(n)]
a1.sort(reverse=True)
ans=1
c=1
for i in range(k):
    if a1[i][1]>0:
        p=i
    elif a1[i][1]<0:
        n1=i
        c*=-1
    else:
        c=0
    ans=(ans*a1[i][1])%mod
if c>=0:
    out(ans%mod)
else:
    b1=0
    b2=0
    for i in range(k,n):
        if a1[i][1]>=0 and b1==0:
            u1,v1=a1[n1][1],a1[i][1]
            b1=1
            c=1
        if a1[i][1]<0 and p!=-1 and b2==0:
            u2,v2=a1[p][1],a1[i][1]
            b2=1
            c=1
    if c<0:
        ans=1
        for i in range(k):
            ans = (ans*a1[n-i-1][1])%mod
    else:
        if b1==1 and b2==1:
            if Fraction(v1,u1)<Fraction(v2,u2):
                ans=ans*pow(u1,mod-2,mod)*v1
            else:
                ans = ans * pow(u2, mod - 2, mod) * v2
        elif b1==1:
            ans = ans * pow(u1, mod - 2, mod) * v1
        else:
            ans = ans * pow(u2, mod - 2, mod) * v2
    out(ans%mod)









Measured memory_bytes: 116548
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array, std.functional;

void main() {
  auto N = readln.split[0].to!int;
  auto S = readln.chomp;

  auto dp = new int[][N];
  foreach(ref d; dp) {
    d = new int[N];
  }

  for(int i = N - 2; i >= 0; i--) {
    for(int j = N - 1; j > i; j--) {
      if(S[i] != S[j]) {
        dp[i][j] = 0;
      } else if(j == N - 1) {
        dp[i][j] = 1;
      } else {
        dp[i][j] = 1 + dp[i+1][j+1];
      }
    }
  }

  int m = 0;
  foreach(i; 0..N) {
    foreach(j; (1+i)..N) {
      m = max(m, min(j-i, dp[i][j]));
    }
  }
  m.writeln;
}


Measured memory_bytes: 102396
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int n,m;
	cin>>n>>m;
	cout<<n+1-m<<endl;
	return 0;
}


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

using namespace std;
int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	int h[n];
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	
	for (int i = 0; i < n; i++) {
		if (i == 0) {
			h[i] -= 1;
		}
		if (h[i-1] < h[i]) {
			h[i] -= 1;
		}
	}
	string ans = "Yes";
	for (int i = 0; i < n - 1; i++) {
		if (h[i] > h[i+1]) {
			ans = "No";
			break;
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b)
		printf("a < b\n");
	else if(a>b)
		printf("a > b\n");
	else
		printf("a == b\n");
	return 0;
}

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

int main() {
	string s;
	cin >> s;
	ll n = s.size();
	vector<ll> ans(n, 0);
	for (ll i = 1; i < n; ++i) {
		if (s[i - 1] == 'R' && s[i] == 'L') {
			double lcnt = 0, rcnt = 0;
			for (ll j = i - 1; j >= 0; --j) {
				if (s[j] == 'R')++rcnt;
				else break;
			}
			for (ll j = i; j < n; ++j) {
				if (s[j] == 'L')++lcnt;
				else break;
			}
			ans[i - 1] = ceil(rcnt / 2) + floor(lcnt / 2);
			ans[i] = floor(rcnt / 2) + ceil(lcnt / 2);
		}
	}
	for (auto x : ans)cout << x << " ";
	cout << endl;
}

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

int main(){
        int a,b;
        int ans = 0;
        scanf("%d %d",&a,&b);
        for(int i = 0; i < 2;i++){
                if(a >= b){
                        ans += a;
                        a--;
                }
                else if(a <= b){
                        ans += b;
                        b--;
                }
        }
        printf("%d\n",ans);
        return 0;
}


Measured memory_bytes: 128
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    T=I()
    M=60#60桁まで
    
    #S=1となる全ての数字が，それより後ろのS=0のもので構成できれば良い（それらを組み合わせても，S=0側も同じ組み合わせ方で対応できる）．
    #S=0のものを基底ベクトル(ぽいもの)として持っておく
    #このとき行列の標準形を構成するベクトルをイメージ
    #上位桁が等しいものがある場合，それとxorしておけば良い，これによって上位桁が同じ基底ベクトル(ぽいもの)がなくなる
    
    
    def pipo(x):
        #最上位桁が何処か
        cnt=0
        for i in range(M):
            if x==0:
                return cnt
            else:
                x=x//2
                cnt+=1
    

        
    
    for _ in range(T):
        N=I()
        A=LI()
        S=list(input())
        #後ろから見ていき，S=1の時に「S=0の数だけで作れない数」が出てきたらNG
        Vec=[]#基底管理
        flag=1#ダメなら0になる
        for i in range(N-1,-1,-1):
            #print(i,S[i]) 
            if S[i]=="0":

                now=A[i]
                p=pipo(A[i])
                for v in Vec:
                    if v[1]==p:
                        now=now^v[0]
                        p=pipo(now)
                if now!=0:
                    Vec.append((now,pipo(now)))
                    Vec.sort(reverse=True)
                            
                
            else:
                #print(Vec)
                now=A[i]
                for v in Vec:
                    if v[1]==pipo(now):
                        now=now^v[0]
                if now!=0:
                    flag=0

                    
                
        if flag:
            print(0)
        else:
            print(1)
            
            
        
        
        
        

main()


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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  int x, y;
  cin >> x >> y;

  cout << x + y / 2 << endl;

  return 0;
}


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

using namespace std;

int next(int n, int d)
{
    vector<int> dig;
    for (int i = 0; i < d; i++) {
        dig.push_back(n % 10);
        n /= 10;
    }
    int small = 0;
    sort(dig.begin(), dig.end());
    int m = 1;
    for (int i = d - 1; i >= 0; i--) {
        small += dig[i] * m;
        m *= 10;
    }
    int big = 0;
    m = 1;
    for (int i = 0; i < d; i++) {
        big += dig[i] * m;
        m *= 10;
    }
    return big - small;
}

int main()
{
    while (true) {
        int a0;
        int L;
        cin >> a0 >> L;
        if (a0 == 0 and L == 0) {
            break;
        }
        map<int, int> mp;
        mp.insert(make_pair(a0, 0));
        int j = 0;
        int i_ = 0;
        int ai = 0;
        for (int i = 1;; i++) {
            a0 = next(a0, L);
            if (mp.find(a0) != mp.end()) {
                ai = a0;
                j = (mp.find(a0))->second;
                i_ = i;
                break;
            } else {
                mp.insert(make_pair(a0, i));
            }
        }
        cout << j << " " << ai << " " << i_ - j << endl;
    }

    return 0;
}

Measured memory_bytes: 3024
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail) { cin >> head; in(move(tail)...); }
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

void solve()
{
    IN(x);
    cout << x + x * x + x* x * x << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  bool res = false;
  char S;
  for (int i = 0; i < N; i++){
    cin >> S;
    if (S == 'Y') res = true;
  }
  cout << (res ? "Four" : "Three");
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
  int n;
  cin >> n;
  long long ans = 1e16;
  long long x,y;
  rep(i,n){
    cin >> x >> y;
    ans = min(x+y,ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _USE_MATH_DEFINES
#include <math.h>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;
typedef string ST;
 
 
#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl
#define cmax(a,b) {if(a<b){a=b;}}
#define cmin(a,b) {if(a>b){a=b;}}
//#define cmax(a,b) a = (a>b ? a:b)
//#define cmin(a,b) a = (a<b ? a:b) 

 
LL modpow(LL a, LL n, LL mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

bool isPrime(LL N)
{
  if (N < 2) {
    return false;
  }
  else if (N == 2) {
    return true;
  }
  else if (N % 2 == 0) {
    return false;
  }

  LD sqrtNum = sqrt(N);
  for (LL i = 3; i <= sqrtNum; i += 2)
  {
    if (N % i == 0)
    {
      return false;
    }
  }
  return true;
}

void func() {
  // dp[i][j] := 最初のi枚のコインを投げたときに、表がj枚となる確率
  LL N;
  cin >> N;
  vector<LD> P(N);
  REP(i,N){
    cin >> P[i];
  }

  vector<vector<LD>> dp(N+1,vector<LD>(N+1,0));
  dp[0][0]=1.0;
  for(LL i=0;i<N;i++){
    for(LL j=0;j<i+1;j++){
      //fprintf(stderr,"i=%lld, j=%lld\n ",i,j) ;     
      dp[i+1][j  ] += dp[i][j]*(1.0-P[i]);
      dp[i+1][j+1] += dp[i][j]*(    P[i]);
    }
  }
  for(LL i=0;i<N+1;i++){
    //PRINTSP(dp[i]);
  }
  LD p = 0.0;
  for(LL i=(N+1)/2;i<N+1;i++){
    p += dp[N][i];
  }
  //cout << p;
  printf("%.20Lf",p);

  return;
}



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

Measured memory_bytes: 141056
import java.util.*;

class Man{
  private long money = 1000;
  private long hasStock = 0;
  
  public void buyStock(int price){
    long buys =(long) money / price;
    hasStock += buys;
    money -=(long) buys * price;
  }
  
  public void sellStock(int price){
    money +=(long) hasStock * price;
    hasStock = 0;
  }
  
  public long getMoney(){
    return this.money;
  }
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
      
      List<Integer> rates = new ArrayList<Integer>();
      for(int i=0;i<N;i++){
        rates.add(sc.nextInt());
      }
      
      Man man = new Man();
      for(int i=0;i<N-1;i++){
        if(rates.get(i) < rates.get(i+1)){
          man.buyStock(rates.get(i));
        } else if(rates.get(i) > rates.get(i+1)){
          man.sellStock(rates.get(i));
        }
      }
      man.sellStock(rates.get(N-1));
      System.out.println(String.valueOf(man.getMoney()));
    }
}

Measured memory_bytes: 35880
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define LL long long 
#define LD long double
multiset<int>s;
const int mod=1e9+7;
int n,a[100005];
LL ans=1;
int main()
{
	scanf("%d",&n);		
	for(int i=1;i<=3;i++)
		s.insert(0);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		ans=ans*s.count(a[i])%mod;
		if(s.find(a[i])!=s.end())
		{
			s.erase(s.find(a[i]));
			s.insert(a[i]+1);			
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();

		int A_mod = A / D;
		if (A % D > 0) {
			A_mod++;
		}

		int B_mod = C / B;
		if (C % B > 0) {
			B_mod++;
		}

		if (A_mod >= B_mod) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}
}

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

int main() {
  string S;
  int K;
  cin >> S >> K;
  int N = S.size();
  vector<vector<vector<int>>> DP(N + 1, vector<vector<int>>(K + 1, vector<int>(2)));
  DP.at(0).at(0).at(0) = 1;
  for (int dig = 0; dig < N; dig++) {
    for (int not0 = 0; not0 <= K; not0++) {
      for (int id = 0; id < 2; id++) {
        int tmp = S.at(dig) - '0';
        for (int num = 0; num < 10; num++) {
          int next_dig = dig + 1, next_not0 = not0, next_id = id;
          if (id == 0) {
            if (num > tmp) continue;
            if (num < tmp) next_id = 1;
          }
          if (num != 0) next_not0++;
          if (next_not0 > K) continue;
          DP.at(next_dig).at(next_not0).at(next_id) += DP.at(dig).at(not0).at(id);
        }
      }
    }
  }
  cout << DP.at(N).at(K).at(0) + DP.at(N).at(K).at(1) << "\n";
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (const T &x : v)
		in >> x;
	return in;
}

template <class T>
ostream& operator << (ostream& out, const vector<vector<T>> &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}

template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}

long long gcd (long long a, long long b)
{
	if (b > a)
		swap(a, b);
	return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define per(i,b,a) for (int i = (b); i > (a); i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

signed main()
{
	ios::sync_with_stdio(false);
	#ifdef ONLINE_JUDGE
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.setstate(ios::failbit);
	#endif

	string s;
	cin >> s;
	vi dpp(2019), dp(2019);
	ll ans = 0;
	rep(i,0,s.size())
	{
		rep(j,0,2019)
			dp[(10 * j + (s[i] - '0')) % 2019] += dpp[j];
		dp[s[i] - '0']++;
		ans += dp[0];
		dpp = dp;
		dp = vi(2019);
	}
	cout << ans;
}


Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
typedef signed long long int ll;
ll inf=1000000007;



const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



int main(){
    string s;
    cin>>s;
    
    int n;
    n=(int)s.size();
    
    ll dp[100010][4]={};
    dp[n][3]=1;
    //for(int i=0;i<3;i++) dp[n][i]=0;
    for(int i=n-1;i>=0;i--){
        
        //char c=s[i];
        
        for(int j=3;j>=0;j--){
            if(i==n){
                dp[i][j] = (j == 3 ? 1 : 0);
                //if(j==3) dp[i][j]=1;
                //else dp[i][j]=0;
            }else{
                
                dp[i][j]=dp[i+1][j]*(s[i] =='?' ? 3 : 1);
                if(j < 3 && (s[i] == '?' || s[i] == "ABC"[j])){
                        dp[i][j] += dp[i+1][j+1];

                }
                dp[i][j]%=inf;
            
            }
        
        }
           /* if(s[i]=='?'){
            //j=3
            //何を書くかで三通り
            dp[i][3]=3*dp[i+1][3];
            
            //j=2
            //?にA,B,Cを入れて丸しない
            dp[i][2]=3*dp[i+1][2]+dp[i+1][3];
            //cを入れて丸
            //dp[i][2]+=dp[i+1][3];
            
            //j=1
            //A,B,Cで丸しない
            dp[i][1]=3*dp[i+1][1]+dp[i+1][2];
            //Bで丸
            //dp[i][1]+=dp[i+1][2];
            
            //j=0
            //丸しない
            dp[i][0]=3*dp[i+1][0]+dp[i+1][1];
            //Aで丸
            //dp[i][0]+=dp[i+1][1];
            }else if(s[i]=='C'){
            //j=3
            dp[i][3]=dp[i+1][3];
            //j=2
            //丸をするかしないか
            dp[i][2]=dp[i+1][2]+dp[i+1][3];
            //j=1
            dp[i][1]=dp[i+1][1];
            //j=0;
            dp[i][0]=dp[i+1][0];
            }else if(s[i]=='B'){
            //j=3
            dp[i][3]=dp[i+1][3];
            //j=2
            dp[i][2]=dp[i+1][2];
            //j=1
            dp[i][1]=dp[i+1][1]+dp[i+1][2];
            
            dp[i][0]=dp[i][0];
            
            }else if(s[i]=='A'){
            //j=3
            dp[i][3]=dp[i+1][3];
            //j=2
            dp[i][2]=dp[i+1][2];
            
            dp[i][1]=dp[i+1][1];
            
            dp[i][0]=dp[i+1][0]+dp[i+1][1];
            }
        
        
        dp[i][0]%=inf;
        dp[i][1]%=inf;
        dp[i][2]%=inf;
        dp[i][3]%=inf;*/
    }
    
    cout<<dp[0][0]<<endl;
    
    
    return 0;
}


Measured memory_bytes: 3584
import Control.Applicative
import Control.Monad
import Data.List
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS

main :: IO ()
main = do
  [n, m] <- f
  unless (n == 0 && m == 0) $ do
    solve <$> replicateM m f >>= print
    main
  where
    f = map read <$> words <$> getLine

solve :: [[Int]] -> Int
solve =  IS.size . foldl' f (IS.singleton 1) . sort
  where
    f st [_, s, d]
      | IS.member s st = IS.insert d st
      | otherwise = st



Measured memory_bytes: 40880
#include<bits/stdc++.h>
using namespace std;
int ans=0;
int main()
{
	string s;
	cin>>s;
	int sz=s.size();
	for(int i=0;i<sz;i++)
	{
		int x=s[i]-'0';
		ans+=x;
	}
	if(ans%9==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3720
n = int(input())

p = [2*i+1 for i in range((n+1)//2)]
ans = 0
for i in p:
    j = 1
    cnt = 0
    while j <= i:
        if i%j == 0:
            cnt += 1
        j += 2
    if cnt == 8:
        ans += 1

print(ans)

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

const string YES = "Yes";
const string NO = "No";
using ll = long long;

void solve(long long N, long long K, std::vector<long long> A){
    for(int i = 0;i < N - K;i++){
        if(A[i + K] > A[i]){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


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

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define ll long long
#define pii pair<int, int>
#define ld long double

const int INF = 2e9 + 1;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n + 1);
    for (auto &c : a) cin >> c;
    vector<int> b(n);
    for (auto &c : b) cin >> c;
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans += min(a[i], b[i]);
        b[i] -= min(a[i], b[i]);
        ans += min(a[i + 1], b[i]);
        a[i + 1] -= min(a[i + 1], b[i]);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3940