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

int main() {
  int n;
  cin>>n;
  long long ans=1;
  vector<long long>a(n);
  bool zero=false;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]==0) zero=true;
  }
  for(int i=0;i<n;i++){
    long long x=1000000000000000000/ans;
    if(a[i]>x){
      ans=-1;
      break;
    }
    else ans*=a[i];
  }
  if(zero) cout<<0<<endl;
  else cout<<ans<<endl;
}

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

int main() {
  long long h, w;
  cin >> h >> w;
  long long ans = 99999999999;
  long long s1, s2, s3, smax, smin;
  for (int i = 1; i <= h - 1; i++) {
    s1 = w*i;
    if (((h - i)*w)%2 == 0) {
      s2 = ((h - i)*w)/2;
      s3 = (h - i)*w - s2;
    }
    else {
      if (h - i >= w) {
        s2 = ((h - i)/2)*w;
        s3 = (h - i)*w - s2;
      }
      else {
        s2 = (h - i)*(w/2);
        s3 = (h - i)*w - s2;
      }
    }
    smax = max({s1, s2, s3});
    smin = min({s1, s2, s3});
    if (smax - smin < ans) {
      ans = smax - smin;
    }
  }
  for (int i = 1; i <= w - 1; i++) {
    s1 = h*i;
    if ((h*(w - i))%2 == 0) {
      s2 = h*(w - i)/2;
      s3 = h*(w - i) - s2;
    }
    else {
      if (h >= w - i) {
        s2 = (h/2)*(w - i);
        s3 = h*(w - i) - s2;
      }
      else {
        s2 = h*((w - i)/2);
        s3 = h*(w - i) - s2;
      }
    }
    smax = max({s1, s2, s3});
    smin = min({s1, s2, s3});
    if (smax - smin < ans) {
      ans = smax - smin;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int>mochi(N);
  for(int i; i<N; i++){
    cin >> mochi.at(i);
  }
  
  sort(mochi.begin(), mochi.end());
  reverse(mochi.begin(), mochi.end());
 
  int count = 0;
  for(int i=0; i<N; i++){
    if(N != 1){
    	if(mochi[i] == mochi[i-1]){ count--; }
    }
    count++;
  } 
  
  cout << count << endl;
}


Measured memory_bytes: 256
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n, x;
    while (cin >> n >> x, n != 0) {
        int res = 0;
        reps(i, 1, n+1) {
            reps(j, i+1, n+1) {
                reps(k, j+1, n+1) {
                    if (i+j+k == x) res++;
                }
            }
        }
        cout << res << endl;
    }
}



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

int main() {
  int N, A, B;
  cin >> N >> A >> B;

  string ans = "";
  int d = B - A - 1;
  if (d > 0) {
    if (d % 2 == 0) {
      ans = "Borys";
    } else {
      ans = "Alice";
    }
  } else { // 最初から隣り合っている
    ans = "Borys";
  }

  cout << ans << endl;

  return 0;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    ll ans = 1;
    rep(i, N){
        ll t; cin >> t;
        ans = (ans/__gcd(ans, t))*t;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define int long long
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

string s;

signed main() {
	cin >> s;
	if (s == "ABC")cout << "ARC" << endl;
	else cout << "ABC" << endl;
}

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

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin >> n;
    ll mod = 1e9 + 7, res = 0, p;
    cin >> p;
    for(int i=1; i<n; i++) {
        ll num;
        cin >> num;
        res = (res + num * p) % mod;
        p = (p + num) % mod;
    }
    cout << res << endl;

    return 0;
}

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

long long modexp(int x, long long e, int m) {
    long long ans = 1, p = x % m;
    while (e > 0) {
        if (e % 2 != 0) ans = (ans * p) % m;
        p = (p * p) % m;
        e >>= 1;
    }
    return ans;
}

int main() {
    int n, m; cin >> n >> m;
    long long f = 1, fi[3*n+1];
    for (int i = 1; i <= 3*n; i++) f = f * i % m;
    fi[3*n] = modexp(f, m-2, m);
    for (int i = 3*n-1; i >= 0; i--) fi[i] = (fi[i+1] * (i+1)) % m;
    int inv3 = modexp(3, m-2, m), inv2 = modexp(2, m-2, m);
    long long ans = 0, A = 1;
    for (int a = 0; a <= n; a++, A = A * inv3 % m) {
        long long C = A * fi[a] % m;
        for (int b = 0; a + b <= n && 3*a + 2*b <= 3*n; b++, C = C * inv2 % m) {
            ans += C * fi[3*(n-a)-2*b] % m * fi[b] % m;
        }
    }
    cout << ans % m * f % m << endl;
}


Measured memory_bytes: 3248
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, alice, bob int
	fmt.Scan(&n)
	a := make([]int, n)
	for i, _ := range a {
		fmt.Scan(&a[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	for i, _ := range a {
		if i%2 == 0 {
			alice += a[i]
			continue
		}
		bob += a[i]
	}
	fmt.Println(alice - bob)
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

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

inline int topbit(unsigned long long x){
    return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
    return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
    return __builtin_parity(x);
}

/*
x=xx-yy;
y=xx+yy;


xx=(x+y)/2;
yy=(y-x)/2;
*/

string solve(int xx,int yy){
    int x=xx-yy;
    int y=xx+yy;
    bool revX=false,revY=false;
    if(x<0){
        x*=-1;
        revX=true;
    }
    if(y<0){
        y*=-1;
        revY=true;
    }

    vint xs,ys;
    xs.pb(0);ys.pb(0);
    int ox=x+(1ll<<35)-1;
    int oy=y+(1ll<<35);
    rep(i,35){
        int nowx=xs.back();
        int nowy=ys.back();
        if((ox>>i+1)&1){
            nowx+=1ll<<i;
        }
        else{
            nowx-=1ll<<i;
        }
        if((oy>>i+1)&1){
            nowy+=1ll<<i;
        }
        else{
            nowy-=1ll<<i;
        }
        xs.pb(nowx);
        ys.pb(nowy);
    }

    rep(i,xs.size()){
        if(revX)xs[i]*=-1;
        if(revY)ys[i]*=-1;
        int tmpx=(xs[i]+ys[i])/2;
        int tmpy=(ys[i]-xs[i])/2;
        ys[i]=tmpy;
        xs[i]=tmpx;
    }

    string ans;
    for(int i=0;i+1<xs.size();i++){
        if(xs[i]<xs[i+1])ans+="R";
        else if(xs[i]>xs[i+1])ans+="L";
        else if(ys[i]<ys[i+1])ans+="U";
        else ans+="D";
    }

    return ans;
}

signed main(){
    int N;
    cin>>N;
    vint X(N),Y(N);
    rep(i,N)cin>>X[i]>>Y[i];

    for(int i=1;i<N;i++){
        if((X[0]+Y[0]+X[i]+Y[i])%2){
            cout<<-1<<endl;
            return 0;
        }
    }

    vint lis;
    vector<string>ans(N);
    if((X[0]+Y[0])%2==0){
        lis.pb(1);
        for(int i=0;i<N;i++){
            ans[i]+="U";
            Y[i]--;
        }
    }

    for(int i=0;i<35;i++)lis.pb(1ll<<i);
    for(int i=0;i<N;i++){
        ans[i]+=solve(X[i],Y[i]);
    }

    cout<<lis.size()<<endl;
    rep(i,lis.size()){
        if(i)cout<<" ";
        cout<<lis[i];
    }
    cout<<endl;
    rep(i,N)cout<<ans[i]<<endl;


    return 0;
}

Measured memory_bytes: 384
n=1<<18;N,m;L[1<<18],p;first[1<<18],next[1<<18];
long dat[1<<20],lazy[1<<20],A[1<<18];
eval(i,l,r){
	if(lazy[i]){
		dat[i]+=lazy[i];
		lazy[2*i+1]+=lazy[i];
		lazy[2*i+2]+=lazy[i];
		lazy[i]=0;
	}
}
update(a,b,x,k,l,r)long x;{
	eval(k,l,r);
	if(a<=l&r<=b){
		lazy[k]+=x;
		eval(k,l,r);
	}
	else if(l<b&a<r){
		update(a,b,x,2*k+1,l,(l+r)/2);
		update(a,b,x,2*k+2,(l+r)/2,r);
		dat[k]=fmax(dat[2*k+1],dat[2*k+2]);
	}
}
long query(a,b,k,l,r){
	eval(k,l,r);
	return a<=l&r<=b?dat[k]:l<b&a<r?fmax(
		query(a,b,2*k+1,l,(l+r)/2),
		query(a,b,2*k+2,(l+r)/2,r)
	):0;
}
main(i){
	for(scanf("%d%d",&N,&m);~scanf("%d%d%ld",L+i,&p,A+i);first[p]=i++)next[i]=first[p];
	for(i=1;i<=N;i++){
		update(i,i+1,query(0,i,0,0,n),0,0,n);
		for(p=first[i];p!=0;p=next[p])update(L[p],i+1,A[p],0,0,n);
	}
	printf("%ld",query(0,N+1,0,0,n));
}

Measured memory_bytes: 18944
#include <iostream>
#include <cmath>
#include <functional>
#include <algorithm>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>

template <class Integer>
auto boost_irange(Integer last) { return boost::irange(static_cast<Integer>(0), last); }
template <class Integer>
auto boost_irange(Integer first, Integer last) { return boost::irange(first, last); }

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { cout << std::endl; }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << val << ' ';
            return *this;
        }
    };

public:
    output() : cout(std::cout) {}
    template <class T>
    proxy operator<<(T&& val)
    {
        cout << val << ' ';
        return {};
    }
};

template <class T, std::size_t n>
class StaticVector : public boost::container::static_vector<T, n>
{
    using Parent = boost::container::static_vector<T, n>;

public:
    // is_constructible_v >= C++17
    template <class... Args, std::enable_if_t<std::is_constructible<Parent, Args&&...>::value, std::nullptr_t> = nullptr>
    StaticVector(Args&&... args) : Parent(std::forward<Args>(args)...) {}
    StaticVector(input& in, std::size_t n_) : Parent(n_)
    {
        for (std::size_t i = 0; i < n_; ++i) in >> static_cast<Parent&>(*this)[i];
    }
};

int main()
{
    input in;
    output out;
    std::string S, T;
    in >> S, T;

    int res = 0;
    for (int i : boost_irange(3))
        if (S[i] == T[i]) ++res;

    out << res;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    vector<int> v(3);
    rep(i, 3) cin >> v[i];

    sort(v.begin(), v.end(), greater<int>());
    cout << stoi(to_string(v[0]) + to_string(v[1])) + v[2] << endl;
}


Measured memory_bytes: 256
<?php

while (($line = trim(fgets(STDIN))) !== '') {
    //横
    for ($i = 0; $i < 9; $i += 3) {
        $a = $line[$i];
        if ($a === $line[$i + 1] && $a === $line[$i + 2] && $a !== 's') {
            echo $a, PHP_EOL;
            continue 2;
        }
    }

    //縦
    for ($i = 0; $i < 3; $i++) {
        $a = $line[$i];
        if ($a === $line[$i + 3] && $a === $line[$i + 6] && $a !== 's') {
            echo $a, PHP_EOL;
            continue 2;
        }
    }

    //斜め1
    if ($line[0] === $line[4] && $line[0] === $line[8] && $line[0] !== 's') {
        echo $line[0], PHP_EOL;
    //斜め2
    } elseif ($line[2] === $line[4] && $line[2] === $line[6] && $line[2] !== 's') {
        echo $line[2], PHP_EOL;
    //引き分け
    } else {
        echo "d\n";
    }
}

Measured memory_bytes: 6600
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        new Main();
    }
    Scanner in = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);

    int n, odd;
    int[] twos;

    Main() {
        n = in.nextInt(); odd = 0;
        twos = new int[2];
        for (int i = 0; i < n; i++) {
            int a = in.nextInt();
            if (a%2 == 0 && a%4 != 0)
                twos[0]++;
            else if (a%4 == 0)
                twos[1]++;
            else if (a%2 == 1)
                odd++;
        }

        int at = 0;
        if (odd <= twos[1] || (odd == twos[1]+1 && twos[0] == 0))
            out.println("Yes");
        else
            out.println("No");
        out.close();
    }
}

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

using namespace std;
mt19937_64 rng(58);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int x, y;
    cin >> x >> y;
    bool ans = false;
    if ((4 * x - y) % 2 == 0 && (4 * x - y) / 2 >= 0 && (4 * x - y) / 2 <= x) {
        ans = true;
    }
    cout << (ans ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 3648
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll sx,sy,tx,ty;
	while(cin>>sx>>sy>>tx>>ty) {
		tx-=sx;
		ty-=sy;
		string s;
		REP(i, ty) s.PB('U');
		REP(i, tx) s.PB('R');
		REP(i, ty) s.PB('D');
		REP(i, tx) s.PB('L');
		s.PB('L');
		REP(i, ty+1) s.PB('U');
		REP(i, tx+1) s.PB('R');
		s.PB('D');
		s.PB('R');
		REP(i, ty+1) s.PB('D');
		REP(i, tx+1) s.PB('L');
		s.PB('U');
		cout<<s<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define djfs first
#define akdk second
#define N 100000000
#define fo(i,m,n) for(int i=m;i<n;i++)
#define M 7
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=long long;
using ul=unsigned long long;
using pii=pair<int,int>;
using vvi=vector<vector<int>>;
using vi=vector<int>;
using pll=pair<ll,ll>;
using vsi=vector<set<int>>;
using vll=vector<ll>;

ll power(ll a,ll n){
    ll j=0;
    ll x=1;
    while(1ll<<j<=n){
        if(1ll<<j&n)
            x=(x*a)%mod;

        a=a*a%mod;
        j++;
    }

    return x;
}

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}

int lb(vi &a,int x){
    int n=a.size();
    int l=0;
    int r=n-1;
    int ind=-1;
    while(l<=r){
        int mid=(l+r)/2;
        if(x>=a[mid]){
            l=mid+1;
            ind=mid;
        }
        else
            r=mid-1;

    }

    return ind+1;

}

int up(vll &a,ll x){
    int n=a.size();
    int l=0;
    int r=n-1;
    int ind=-1;

    while(l<=r){
        int mid=(l+r)/2;
        if(a[mid]>x){
            r=mid-1;
            ind=mid;
        }
        else
            l=mid+1;

    }

    return ind;
}

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

}

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

}

void yn(bool a){
    if(a)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;

}


bool isodd(int a,int b,int agx,int agy){

    return (abs(a-agx)+abs(b-agy))%2;

}
int fap(vi &par,int x){
    if(par[x]!=x)
        par[x]=fap(par,par[x]);

    return par[x];
}

void unin(vi &par,vi &rank,int x,int y){
    int px=fap(par,x);
    int py=fap(par,y);

    if(px!=py){
        if(rank[px]<rank[py])
            swap(px,py);

        par[py]=px;
        rank[px]+=rank[py];
    }
}

struct fenwick_tree
{
    vll bit;
    int n;
    fenwick_tree(int n){
        this->n=n;
        bit=vll(n+1);
    }

    void update(int idx,ll val){
        while(idx<=n){
            bit[idx]+=val;
            idx+=idx&-idx;
        }
    }

    void rupdate(int l,int r,int x){
        update(l,x);
        update(r+1,-x);
    }

    ll query(int idx){
        ll tot=0;
        while(idx){
            tot+=bit[idx];
            idx-=idx&-idx;
        }

        return tot;
    }

};


int main(){
    ll s;
    cin>>s;


    vector<vll> c(2*s+1,vll(2*s+1));
    c[0][0]=1;
    for(int i=1;i<=2*s;i++){
        c[i][0]=1;
        c[i][i]=1;
        for(int j=1;j<i;j++)
            c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;

    }


    ll tot=0;
    for(int i=1;i<=s;i++){
        if(s-3*i<0)
            break;
        else{
            ll temp=s-3*i;
            tot+=c[temp+i-1][i-1];
         //   cout<<tot<<endl;
            tot%=mod;
        }
    }

    cout<<tot<<endl;

}


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

#define SIZE_OF_ARRAY(array) sizeof(array)/sizeof(array[0])

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> sunuke;
    for(int k = 0; k < K; k++){
        int d;
        cin >> d;
        for(int i = 0; i < d; i++){
            int num;
            cin >> num;
            sunuke.push_back(num);
        }
    }
    std::sort(sunuke.begin(),sunuke.end());
    int count = 1;
    for(int i = 1; i < sunuke.size(); i++){
        if(sunuke.at(i)!=sunuke.at(i-1)){
            count++;
        }
    }
    cout << N - count;
}

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

typedef long long ll;
typedef long double ld;

#define X first
#define Y second
#define pb push_back
#define all(x) x.begin(), x.end()

using namespace std;

const int MAXN = 1e5 + 7;
int n;

ld dist(pair<ld, ld> a, pair<ld, ld> b){
    return sqrt(pow(a.X - b.X, 2) + pow(a.Y - b.Y, 2));
}

ld CirTrip(pair<ld, ld> r, pair<ld, ld> q, pair<ld, ld> c,
        pair<ld, ld>& O, ld d){
    ld ma, mb, x;
    ma = (q.Y - r.Y) / (q.X - r.X);
    mb = (c.Y - q.Y) / (c.X - q.X);
    O.X = (ma * mb * (r.Y - c.Y) + mb * (r.X + q.X) - ma * (q.X + c.X))
        / 2 * (mb - ma);
    O.Y = -ma * (r.X - (q.X + c.X) / 2) + (q.X + c.X) / 2;
    d = dist(O, c);
    return d;
}

ld MinDisc2(vector<pair<ld, ld> > p, pair<ld, ld> q,
        pair<ld, ld> r){
    random_shuffle(all(p));
    ld d = dist(r, q);
    pair<ld, ld> O;
    O.X = (q.X + r.X) / 2;
    O.Y = (q.Y + r.Y) / 2;
    for (int i = 0; i < n; i++){
        if (p[i] == q || p[i] == r) continue;
        if (dist(O, p[i]) <= d) continue;
        d = CirTrip(r, q, p[i], O, d);
    }
    return d;
}

ld MinDisc1(vector<pair<ld, ld> > p, pair<ld, ld> q){
    random_shuffle(all(p));
    ld d = dist(p[0], q);
    pair<ld, ld> O;
    O.X = (q.X + p[0].X) / 2;
    O.Y = (q.Y + p[0].Y) / 2;
    for (int i = 1; i < n; i++){
        if (dist(O, p[i]) <= d) continue;
        d = MinDisc2(p, q, p[i]); 
    }
    return d;
}

ld MinDisc(vector<pair<ld, ld> > p){
    random_shuffle(all(p));
    ld d = dist(p[1], p[0]);
    pair<ld, ld> O;
    O.X = (p[1].X + p[0].X) / 2;
    O.Y = (p[1].Y + p[0].Y) / 2;
    for (int i = 2; i < n; i++){
        if (dist(p[i], O) <= d) continue;
        d = MinDisc1(p, p[i]);
    }
    return d;
}

void pudge(){
    cin >> n;
    vector<pair<ld, ld> > a(n);
    for (auto& i : a)
        cin >> i.X >> i.Y;
    cout << setprecision(10) << fixed << MinDisc(a) / 2;
}

void durka(){
    int n, m, answa = 0, ansac = 0;
    cin >> n >> m;
    map<int, int> a;
    bitset<MAXN> b;
    while(m--){
        string s;
        int x;
        cin >> x >> s;
        if (s == "WA") a[x]++;
        else {
            if (!b[x]){
                b[x] = 1;
                ansac++;
                answa += a[x];
            }
        }
    }
    cout << ansac << " " << answa;
}

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

    int q = 1;
    //cin >> q;
    //while(q--) pudge();
    durka();

    return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<map>
#include<cmath>
#include<set>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
int table[6][8]={
  {0,1,2,3,4,5,6,7},
  {4,7,6,5,0,3,2,1},
  {0,4,5,1,3,7,6,2},
  {1,5,6,2,0,4,7,3},
  {2,6,7,3,1,5,4,0},
  {3,7,4,0,2,6,5,1}
};



class state{
public:
  char data[8];
  bool operator<(const state & a)const {
    rep(i,8)
      if( data[i] != a.data[i])return data[i]<a.data[i];
    return false;
  }
};


bool check_duplicate(state & a,set<state> &S){
  state check[4];
  rep(i,4){
    rep(j,4){
      check[i].data[j]    =a.data[(i+j)%4];
      check[i].data[4+j]  =a.data[4+(4+i+j)%4];
    }
  }
  
  rep(i,8)if ( S.find(check[i]) !=S.end())return true;
  return false;
}

int cpy[8]={4,7,6,5,0,3,2,1};

void make_set(state & a,set<state> & S){
  state check;
  state check2;
  rep(i,6){
    rep(j,8)check.data[j]=a.data[table[i][j]];
    if (check_duplicate(check,S))return;
    rep(j,8)check2.data[j]=check.data[cpy[j]];
    if (check_duplicate(check,S))return;
  }
  
  S.insert(a);
}


void generate(int num,int *rem,state &a,int now,set<state>&S){
  if ( now == 8){
    make_set(a,S);
    return;
  }
  rep(i,num){
    if( rem[i] == 0)continue;
    rem[i]--;
    a.data[now]=i;
    generate(num,rem,a,now+1,S);
    rem[i]++;
  }

} 


main(){
  string a;
  while(cin>>a ){
    char index=0;
    int rem[8]={0};
    map<string,char> M;
    M[a]=(char)index++;
    rem[M[a]]++;
    REP(i,1,8){
      cin>>a;
      if ( M.find(a) == M.end())
      M[a]=(char)index++;
      rem[M[a]]++;
    }
    state ini;
    set<state> S;
    generate(M.size(),rem,ini,0,S);
    cout << S.size() << endl;
    /*
    set<state>::iterator itr = S.begin();
    while(itr != S.end()){
      puts("upper");
      rep(i,4)
	cout << (int)(*itr).data[i];
      puts("");
      puts("lower");
      rep(i,4)cout << (int)(*itr).data[i+4];
      puts("");
      itr++;
    }
    */
  }
  return false;
}
  

Measured memory_bytes: 972
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
#define ll long long int
using namespace std;
ll fun(vector<ll>&w,vector<ll>&v,ll n,ll W)
{
    ll dp[n+1][W+1];
    for(ll i=0;i<n+1;i++)
    {
        for(ll j=0;j<W+1;j++)
        {
            if(i==0 || j==0)
            {
                dp[i][j]=0;
            }
        }
    }
    for(ll i=1;i<n+1;i++)
    {
        for(ll j=1;j<W+1;j++)
        {
            
             if(w[i-1]<=j)
            {
                dp[i][j]=max(v[i-1]+dp[i-1][j-w[i-1]],dp[i-1][j]);
            }
            else
            {
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    return dp[n][W];
}
int main()
{
    ll n,W;
    cin>>n>>W;
    vector<ll>w;
    vector<ll>v;
    for(ll i=0;i<n;i++)
    {
        int a,b;
        cin>>a>>b;
        w.push_back(a);
        v.push_back(b);
    }
    
cout<<fun(w,v,n,W)<<endl;
    return 0;
}


Measured memory_bytes: 82552
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
    cin>>s;
    if(s[0]==s[1] && s[1]==s[2] || s[1]==s[2] && s[2]==s[3])
    	cout<<"Yes"<<endl;
    else
    	cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

int abs(int a){
    return max(a,-a);
}

int main() {
    int N, X, Y; cin >> N >> X >> Y;
    X--;
  	Y--;
    vector<int> cnt(N);
    rep(i, N-1){
        for(int j = i+1; j < N; j++){
            cnt.at(min(abs(j-i), min(abs(X-i)+1+abs(j-Y), abs(Y-i)+1+abs(j-X)))-1)++;
        }
    }

    rep(i, N-1){
        cout << cnt.at(i) << endl;
    }
}

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

int main() {
    map<int, int> alphabet;
    string S;
    cin >> S;

    for (int i = 0; i < S.length(); i++) {
        alphabet[S[i]]++;
    }

    if (S.size() != 26) {
        for (int i = 'a'; i <= 'z'; i++) {
            if (alphabet[i] == 0) {
                S += i;
                break;
            }
        }
    } else {
        for (int i = 25; i >= 0; i--) {
            for (int j = S[i] + 1; j <= 'z'; j++) {
                if (alphabet[j] == 0) {
                    S[i] = j;
                    S = S.substr(0, i + 1);
                    cout << S << endl;
                    return 0;
                }
            }
            alphabet[S[i]]--;
        }
        cout << -1 << endl;
        return 0;
    }
    cout << S << endl;

    return 0;
}


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

int main(){
  ll N,A,B;
  cin>>N>>A>>B;
  if(A>B){
    cout<<0<<endl;
  }else if(N==1&&A!=B){
    cout<<0<<endl;
  }else{
    ll x=B*(N-1)+A;
    ll y=A*(N-1)+B;
    cout<<x-y+1<<endl;
  }
}


Measured memory_bytes: 256
from collections import defaultdict

d = defaultdict(list)
for i in range(-120, 121):
  for j in range(-120, 121):
    x = i**5 - j**5
    if x >= 1:
      d[x] = [i, j]
    
X = int(input())

print('{0[0]} {0[1]}'.format(d[X]))

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

double len(int x1, int y1, int x2, int y2){
  return pow( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2), 0.5 );
}

int main(){
  int n;cin>>n;
  vector<int> x(n), y(n);
  rep(i, n)cin>>x[i]>>y[i];

  vector<int> arr(n);
  rep(i, n)arr[i]=i;

  double d = 1;
  rep(i, n)d *= (i+1);

  double u = 0.0;
  while(true){
    rep(i, n-1){
      int l=arr[i];
      int r = arr[i+1];
      u += len(x[l], y[l], x[r], y[r]);
    }
    if( !next_permutation(arr.begin(), arr.end()) )break;
  }
  cout<<fixed<<setprecision(12)<<u/d<<endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int coin[]={500,100,50,10,5,1};
		int change,i,count,n;
		while(true){
			count=0;
			n=sc.nextInt();
			if(n==0) break;
			change=1000-n;
			for(i=0;i<6;i++){
				for(;;){
					if(coin[i]<=change){
						change-=coin[i];
						count++;
					}
					else break;
				}
				if(change==0) break;
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 12000
#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++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<string> vs;
const long long INF = 1LL << 58;
const int INT_INF = 1 << 28;
const double PI = acos(-1.0);

int main() {
    int n, m;
    cin >> n >> m;
    vvi s(m);
    rep(i, m) {
        int k;
        cin >> k;
        rep(j, k) {
            int t;
            cin >> t;
            s[i].push_back(t);
        }
    }
    vi p(m);
    rep(i, m) cin >> p[i];
    int ans = 0;
    for (int bit = 0; bit < (1 << n); bit++) {
        bool flag = true;
        rep(i, m) {
            int sum = 0;
            rep(j, s[i].size()) {
                if (bit & (1 << (s[i][j] - 1))) sum++;
            }
            if (sum % 2 != p[i]) flag = false;
        }
        if (flag) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)

# lis_of_lis = [[] for _ in range(N)]


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


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


N, D = zz()
ans = 0
D_lis = np.zeros(N)
for i in range(N):
    x, y = zz()
    D_lis[i] = np.sqrt(x**2 + y**2)

for d in D_lis:
    if (d <= D):
        ans += 1
print(ans)


Measured memory_bytes: 43668
local mmi, mma, mab, mfl = math.min, math.max, math.abs, math.floor
local function solve()
  local n = io.read("*n")
  local iszero = false
  local cnt = {}
  for i = 1, 12 do cnt[i] = 0 end
  for i = 1, n do
    local d = io.read("*n")
    if d == 0 then iszero = true
    else
      cnt[d] = cnt[d] + 1
      if 3 <= cnt[d] then iszero = true end
    end
  end
  if iszero then return 0 end
  local fix, float = {}, {}
  local minval = 12
  for i = 12, 1, -1 do
    if 0 < cnt[i] then
      minval = i
    end
    if cnt[i] == 1 then
      table.insert(float, i)
    elseif cnt[i] == 2 then
      table.insert(fix, i)
    end
  end
  --fix_fix
  for i = 1, #fix - 1 do
    for j = i + 1, #fix do
      minval = mmi(minval, fix[i] - fix[j])
    end
  end
  for i = 1, #fix do
    minval = mmi(minval, fix[i] * 2)
    minval = mmi(minval, (12 - fix[i]) * 2)
  end
  --fix_float
  for i = 1, #fix do
    for j = 1, #float do
      minval = mmi(minval, mab(fix[i] - float[j]))
    end
  end
  --float_float
  if 0 < #float then
    local mul = 1
    local z = {}
    for i = 1, #float do mul = mul * 2 end
    local partmax = 0
    for i = 0, mul - 1 do
      local partmin = 12
      for j = 1, #float do
        if i % 2 == 0 then
          z[j] = float[j]
        else
          z[j] = -float[j]
        end
        i = mfl(i / 2)
      end
      for j = 1, #float - 1 do
        for k = j + 1, #float do
          local v = mab(z[j] - z[k])
          v = mmi(v, 24 - v)
          partmin = mmi(partmin, v)
        end
      end
      partmax = mma(partmax, partmin)
    end
    minval = mmi(minval, partmax)
  end
  return minval
end
print(solve())


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){

 bool isUsed[26];
 string S;		cin >> S;

 for(int i = 0 ; i < 26 ; i++)	isUsed[i] = false;
  
 for(int i = 0 ; i < S.length() ; i++)
  isUsed[S[i] - 97] = true;

 for(int i = 0 ; i < 26 ; i++){
  if(isUsed[i] == false){
	printf("%c\n", i + 97);	
	break;
  }
  if(i == 25)	cout << "None" << endl;
 }

 return 0;
}


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

namespace みんプロ
{
    class B
    {
        static void Main(string[] args)
        {
            int[][] ab = new int[3][];
            int[] fig = new int[4];
            for (int i = 0; i < 3; i++)
            {
                ab[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
                switch (ab[i][0])
                {
                    case 1: fig[0]++; break;
                    case 2: fig[1]++; break;
                    case 3: fig[2]++; break;
                    case 4: fig[3]++; break;
                }
                switch (ab[i][1])
                {
                    case 1: fig[0]++; break;
                    case 2: fig[1]++; break;
                    case 3: fig[2]++; break;
                    case 4: fig[3]++; break;
                }
            }
            string ans = "YES";
            if(fig[0]==3|| fig[1] == 3|| fig[2] == 3|| fig[3] == 3) { ans = "NO"; }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 2001;
int n, v[N];
ll dp[N][N];
vector<pair<int,int> > x;


bool srt(pair<int,int> a, pair<int,int> b){
     if(a.first > b.first)return true;
     return a.first == b.first? a.second < b.second: 0;
}

ll go(int cur, int l, int r){
    if(l > r)return 0;
    ll &ret = dp[l][r];
    if(ret + 1)return ret;
    ret = go(cur+1, l+1, r) + (x[cur].first * abs(l - x[cur].second));
    ret = max(ret, go(cur+1, l, r-1) + (x[cur].first * abs(r - x[cur].second)));
    return ret;
}

int main(){
    scanf("%d", &n);
    for(int i = 0; i<n; ++i){
        scanf("%d", v+i);
        x.push_back({v[i], i});
    }
    memset(dp, -1, sizeof dp);
    sort(all(x), srt);
   // sort(x.begin(),x.end(),greater<pair<int,int>>());   
    ll an = go(0, 0, n-1);
    printf("%lld\n", an);
}

Measured memory_bytes: 34704
#include<math.h>
#include<time.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
int dice[10];
void roll(char command);
void tophome(int top)
{
	if(top==dice[2])
		roll('N');
	if(top==dice[3])
		roll('W');
	if(top==dice[4])
		roll('E');
	if(top==dice[5])
		roll('S');
	if(top==dice[6])
	{
		roll('W');
		roll('W');
	}
	return;
}
void fronthome(int front)
{
	if(front==dice[3])
		roll('R');
	if(front==dice[4])
		roll('L');
	if(front==dice[5])
	{
		roll('R');
		roll('R');
	}
	return;
}
void roll(char command)
{
	char t;
	if(command=='W')
	{
		t=dice[1];
		dice[1]=dice[3];
		dice[3]=dice[6];
		dice[6]=dice[4];
		dice[4]=t;
	}
	if(command=='S')
	{
		t=dice[1];
		dice[1]=dice[5];
		dice[5]=dice[6];
		dice[6]=dice[2];
		dice[2]=t;
	}
	if(command=='E')
	{
		t=dice[1];
		dice[1]=dice[4];
		dice[4]=dice[6];
		dice[6]=dice[3];
		dice[3]=t;
	}
	if(command=='N')
	{
		t=dice[1];
		dice[1]=dice[2];
		dice[2]=dice[6];
		dice[6]=dice[5];
		dice[5]=t;
	}
	if(command=='L')
	{
		t=dice[2];
		dice[2]=dice[4];
		dice[4]=dice[5];
		dice[5]=dice[3];
		dice[3]=t;
	}
	if(command=='R')
	{
		t=dice[2];
		dice[2]=dice[3];
		dice[3]=dice[5];
		dice[5]=dice[4];
		dice[4]=t;
	}
	return;
}
int main()
{
	int i,q,a,b,c[30];
	scanf("%d %d %d %d %d %d",&dice[1],&dice[2],&dice[3],&dice[4],&dice[5],&dice[6]);
	scanf("%d",&q);
	for(i=1;i<=q;i++)
	{
		scanf("%d %d",&a,&b);
		tophome(a);
		fronthome(b);
		c[i]=dice[3];
	}
	for(i=1;i<=q;i++)
		printf("%d\n",c[i]);
	return 0;
}


Measured memory_bytes: 2060
N=int(input())
A=list(map(int,input().split()))

sa=[0]*N
sa[0]=A[0]
for i in range(1,N):
  sa[i]=sa[i-1]+A[i]
  
pm=1
ans=0
d=0
for i in range(N):
  if sa[i]+d!=pm*abs(sa[i]+d) or sa[i]+d==0:
    ans+=abs(pm-sa[i]-d)
    d+=pm-sa[i]-d
  pm*=-1
  
pm=-1
ans2=0
d=0
for i in range(N):
  if sa[i]+d!=pm*abs(sa[i]+d) or sa[i]+d==0:
    ans2+=abs(pm-sa[i]-d)
    d+=pm-sa[i]-d
  pm*=-1

print(min(ans,ans2))

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

int main(){
  int n, x, i, d=0;
  cin >> n >> x;
  vector<int> l(n);
  for(i=0; i<n; i++) cin >> l[i];

  for(i=2; i<=n+1; i++){
    d = d + l[i-2];
    if(x<d) break;
  }

  cout << i-1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
int n;
bool F[246914];

for(int i=0;i<246914;i++)
for(int j=2;j*j<=i;j++){
if(i%j==0){F[i]=false;break;}
else if(i%j!=0)F[i]=true;}

F[2]=true;F[3]=true;
while(1){
scanf("%d",&n);if(n==0)break;
int c=0;
for(int i=n+1;i<=2*n;i++)
	if(F[i]==true){c++;}//printf("%d",i);}
printf("%d\n",c);
}

return 0;
}

Measured memory_bytes: 1268
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	string a;
	cin>>a;
	int se[n],sw[n];
	for(int i=0;i<n;++i){
		se[i]=0;
		sw[i]=0;
	}
	if(a[0]=='E')
	    se[0]=1;
	else
		sw[0]=1;
	for(int i=0;i<n;i++){
		if(a[i]=='E'){
			se[i]=se[i-1]+1;
			sw[i]=sw[i-1];
		}
		else {
			sw[i]=sw[i-1]+1;
			se[i]=se[i-1];
		}
	}
	int minv=300000000;
	for(int i=0;i<n;++i){
		int mmm=0;
		if(i==0)
			mmm=se[n-1]-se[i];
		else if(i==n-1)
			mmm=sw[n-2];
		mmm=sw[i-1]+(se[n-1]-se[i]);
		minv=min(minv,mmm);
	}
	cout<<minv<<endl;
	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
using namespace std;


int main (int argc, char const *argv[])
{
    int X,t;
    cin>>X>>t;

if (X>=t) {
    cout<<X-t<<endl;
}

else
{
    cout<<0<<endl;

}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

#define MAX 1000000007

using namespace std;

int main(void) {
	long long i, ans;
	long N;
	cin >> N;
	ans = 1;
	for (i = 2; i <= N; i++) {
		ans = ans * i % MAX;
	}
	cout << ans << endl;
	return 0;
}





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

int main() {
 int n, m;
 cin >> n >> m;
 long long int D[n-1];
 long long int S[n];
 long long int M[m];
 for (int i=0; i<n-1; ++i) {
  cin >> D[i];
 }
 S[0] = 0;
 for (int i=0; i<n-1; ++i) {
  S[i+1] = S[i] + D[i];
 }
 for (int i=0; i<m; ++i) {
  cin >> M[i];
 }
 long long int ans = 0;
 long long int now = 0;
 for (int i=0; i<m; ++i) {
  ans += abs(S[M[i]+now] - S[now]);
  now += M[i];
 }
 cout << (ans % 100000) << endl;
}


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

int main(){
    int a,b;
    int k;
    int r,n;
    cin>>a>>b;
    k=a+b;
    r=k%2;
    if(r!=0){
        cout<<"IMPOSSIBLE"<<endl;
    }
    if(r==0){
        n=k/2;
        cout<<n<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

use std::cmp::min;

fn main() {
    let n: usize = read();
    let w: Vec<u32> = read_vec();
    let mut s1 = w[0];
    let mut s2 = w.iter().fold(0, |x, y| x + y) - w[0];
    let mut tmp = s2 - s1;
    for i in 1..(n - 1) {
        s1 += w[i];
        s2 -= w[i];
        if s1 > s2 {
            break;
        }
        tmp = s2 - s1;
    }
    println!("{}", min(tmp, s1 - s2));
}


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

using namespace std;
using ll = long long;

void FastIO ()
{
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
}

int main ()
{
  FastIO();
  
  ll n, k;
  cin >> n >> k;
  
  vector<ll> v(k);
  for(ll& x: v) cin >> x;
  
  ll ans = v[k-1] - v[0];
  for(int i=1; i<k; ++i) ans = min(ans, n - (v[i] - v[i-1]));
  cout << ans;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{

	double r;
	double s, l;

	scanf("%lf", &r);

	s = r * r * (double)3.1415926535898;
	l = 2 * r * (double)3.1415926535898;
	printf("%lf %lf\n", s, l);

	return 0;
}

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

#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define sz size()
#define endl "\n"
#define pb push_back
#define pp pop_back
#define mp make_pair
#define REP(I,n) for(int I = 0; I < n; I++)
#define REP_1(I,n) for(int I = 1; I <= n; I++)
#define FOR(I,A,B) for(int I = A; I < B; I++)
#define DWN(I,B,A) for(int I = B-1; I >= A; I++)
#define FOR_1(I,A,B) for(int I = A; I <= B; I++)
#define DWN_1(I,B,A) for(int I = B; I >= A; I++)
#define Read() freopen("input1.txt", "r", stdin)
#define Write() freopen("output1.txt", "w", stdout)

#define ll long long
#define ull unsigned long long

#define MOD 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef map<int,string> mis;
typedef set<int> si;
typedef set<string> ss;
typedef map<char,int> mci;


void f_i_o() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}
void c_r_w() {
	#ifndef ONLINE_JUDGE
		Read();
		Write();
	#endif
}
int main()
{				
	//c_r_w();
	//f_i_o();
	int A,B,C;
	cin>>A>>B>>C;
	A = A + B;
	B = A - B;
	A = A - B;

	A = A + C;
	C = A - C;
	A = A - C;

	cout<<A<<" "<<B<<" "<<C;
}

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

using namespace std;
const int MAXN = 3001;

int n; 
double a[MAXN], dp[MAXN][MAXN];

double solve (int i, int qt) {

    if (i >= n) {
        if (n & 1) return (qt >= (n / 2 + 1));
        else return (qt >= (n / 2));
    }

    double &p = dp[i][qt];
    if (p + 1 != 0) return p;

    return p = ( (double) 1 - a[i] ) * solve (i + 1, qt) + a[i] * solve (i + 1, qt + 1);

}


int main () {

    scanf("%d", &n);

    for (int i = 0, x; i < n; ++i) {
        scanf("%lf", &a[i]);
    }

    for (int i = 0; i < MAXN; ++i) 
        for (int j = 0; j < MAXN; ++j) dp[i][j] = double (-1);

    printf("%.10lf\n", solve (0, 0));

    return 0;
}


Measured memory_bytes: 70784
#include<cstdio>
#include<vector>
#include<algorithm>
#include<iostream>
#include<string>
#include<cctype>
#include<cstdlib>
using namespace std;
int main(){
    string str;char type;
    while(cin>>str>>type,str!="EndOfInput"||type!='X'){
        vector<char>ans;ans.push_back(tolower(str[0]));
        for(int i=1;i<str.length();i++){
            if(str[i]!='_'&&islower(str[i])){
                ans.push_back(str[i]);
                continue;
            }
            if(isupper(str[i])){
                if(type=='L'||type=='U')ans.push_back(str[i]);
                else{
                    ans.push_back('_');
                    ans.push_back(tolower(str[i]));
                }
            }
            else{
                i++;
                if(type=='L'||type=='U')ans.push_back(toupper(str[i]));
                else{
                    ans.push_back('_');
                    ans.push_back(str[i]);
                }
            }
        }
        if(type=='U')ans[0]=toupper(ans[0]);
        for(int i=0;i<ans.size();i++)cout<<ans[i];cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 1212
#include<stdio.h>
int main()
{
  int A,B,C;
  int i;
  
  scanf("%d %d %d",&A,&B,&C);
  
  for(i=1;i<=B;i++)
    if(A*i%B==C) {
      printf("YES");
      break;
    }
  if(i==B+1) printf("NO");
  
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
//大きい順にソート
int c[100002];
void merge(int i,int j,int *s){
  if(i!=j){
    merge(i,(i+j)/2,s);
    merge((i+j)/2+1,j,s);
    int a=i,b=(i+j)/2+1;
    int d;
    for(d=i;d<=j;d++){
      if((i+j)/2<a){
        c[d]=s[b];
        b++;
      }
      else if(j<b){
        c[d]=s[a];
        a++;
      }
      else if(s[a]>s[b]){
        c[d]=s[a];
        a++;
      }
      else{
        c[d]=s[b];
        b++;
      }
    }
    for(d=i;d<=j;d++)
      s[d]=c[d];
  }
}

int main(){
  int n,i;
  scanf("%d",&n);
  int a[n+1];
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  merge(0,n-1,a);
  long long s=0;
  for(i=0;i<n-1;i++){
    if(a[i]==a[i+3] && i<n-3 && s==0){
      s=a[i];
      s*=s;
      printf("%lld\n",s);
      return 0;
    }
    else if(a[i]==a[i+1] && s!=0){
      s*=(long long)a[i];
      printf("%lld\n",s);
      return 0;
    }
    else if(a[i]==a[i+1]){
      s=a[i];
      i++;
    }
  }
  puts("0");
  return 0;
}

Measured memory_bytes: 2476
function main(arg) {
  var K = parseInt(arg[0]);
  var [A,B] = arg[1].split(" ")
  var result = "NG";
  for(var i = parseInt(A); i <=　parseInt(B); i ++) {
  	if(i % K == 0) {
      result = "OK"
    }
  }
  console.log(result)
}

main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n"));


Measured memory_bytes: 29628