akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pr;

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

	int g=0, p=0,ans = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'g') {
			if (g >= p + 1) {
				p++;
				ans++;
			}
			else 
				g++;
		}
		else if (s[i] == 'p') {
			if (g >= p + 1) 
				p++;
			else {
				g++;
				ans--;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
int n, ans;
cin >> n;
    ans = n * 32;
cout << ans << endl;
}


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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    freopen ("in.txt", "r", stdin);
#endif
}

int main() {
  //  READ();
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;cin>>n;
    int i=1;
    int ret=0;
    while(i<=n){
        if (i==10 || i==1000 || i==100000) i*=10;
        else {++ret;++i;}
    }
    cout << ret;
    return 0;
}



Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Codes solver = new Codes();
        solver.solve(1, in, out);
        out.close();
    }

    static class Codes {
        static int n;
        static int[] weight;
        static int[] value;
        static Long[][] memo;

        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            n = sc.nextInt();
            int start = sc.nextInt();
            weight = new int[n];
            value = new int[n];
            for (int i = 0; i < n; i++) {
                weight[i] = sc.nextInt();
                value[i] = sc.nextInt();
            }
            memo = new Long[n][(int) 1e5 + 1];
            int ans = 0;
            for (int i = 0; i <= (int) 1e5; i++) {
                long dp = dp(0, i);
                if (dp <= start)
                    ans = i;
            }
            pw.println(ans);
        }

        private long dp(int idx, int cur) {
            if (cur <= 0)
                return 0;
            if (idx == n)
                return (int) 1e15;
            if (memo[idx][cur] != null)
                return memo[idx][cur];
            long take = weight[idx] + dp(idx + 1, cur - value[idx]);
            long leave = dp(idx + 1, cur);
            return memo[idx][cur] = Math.min(take, leave);
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 396616
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, C;
    cin >> n >> C;

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

    vector<vector<int>> M(n, vector<int>(n));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> M[i][j];
            --M[i][j];
        }
    }

    vector<vector<int>> cnts(3, vector<int>(C, 0));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cnts[(i + j) % 3][M[i][j]] += 1;
        }
    }

    const long long INF = 1LL << 50;
    vector<vector<long long>> dp(3, vector<long long>(C, 0));
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < C; ++j) {
            for (int k = 0; k < C; ++k) {
                dp[i][j] += cnts[i][k] * 1LL * D[k][j];
            }
        }
    }

    long long res = INF;
    for (int i = 0; i < C; ++i) {
        for (int j = 0; j < C; ++j) {
            for (int k = 0; k < C; ++k) {
                if (i != j && i != k && j != k) {
                    long long ans = dp[0][i] + dp[1][j] + dp[2][k];
                    res = min(res, ans);
                }
            }
        }
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 1280
# -*- coding: utf-8 -*-

"""
パーティション
"""

N = int(input())
aN = list(map(int, input().split()))

def partition(p, r):
    x = aN[r]
    i = p-1
    for j in range(p, r):
        if aN[j] <= x:
            i = i+1
            aN[i], aN[j] = aN[j], aN[i]
    aN[i+1], aN[r] = aN[r], aN[i+1]
    # 基準となった末尾要素のindex
    return i+1

idx = partition(0, N-1)
aN[idx] = '[' + str(aN[idx]) + ']'
print(*aN)



Measured memory_bytes: 16392
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  int p,q,r;
  p = a.size()-1;
  q = b.size()-1;
  r = c.size()-1;
  if(a[p] == b[0] && b[q] == c[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x
        
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x):
        return -self.parents[self.find(x)]
    
    def isSame(self, x, y):
        return self.find(x) == self.find(y)

def solve():
    N,M = map(int,input().split())
    uf = UnionFind(N)
    for _ in range(M):
        a,b = map(int,input().split())
        a -= 1
        b -= 1

        uf.unite(a,b)
    
    ans = 0
    for i in range(N):
        ans = max(ans,uf.size(i))
    
    print(ans)
        
if __name__ == '__main__':
    solve()


Measured memory_bytes: 79756
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> A(3, vector<int>(3, 0));
vector<vector<bool>> C(3, vector<bool>(3, false));

int main()
{
  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      cin >> A.at(i).at(j);
    }
  }
  int N, b;
  cin >> N;
  for (int i = 0; i < N; i++)
  {
    cin >> b;
    for (int h = 0; h < 3; h++)
    {
      for (int w = 0; w < 3; w++)
      {
        if (b == A.at(h).at(w))
        {
          C.at(h).at(w) = true;
        }
      }
    }
  }
  for (int h = 0; h < 3; h++)
  {
    if (C.at(h).at(0) && C.at(h).at(1) && C.at(h).at(2))
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  for (int w = 0; w < 3; w++)
  {
    if (C.at(0).at(w) && C.at(1).at(w) && C.at(2).at(w))
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  if (C.at(0).at(0) && C.at(1).at(1) && C.at(2).at(2))
  {
    cout << "Yes" << endl;
    return 0;
  }
  if (C.at(0).at(2) && C.at(1).at(1) && C.at(2).at(0))
  {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1e9 + 1;
const int LLINF = 1e18 + 1;
const int mxn = 1010;

int N, M;
int d1[8] = {1, 1, 1, 1, -1, -1, -1, -1};
int d2[8] = {1, 1, -1, -1, 1, 1, -1, -1};
int d3[8] = {1, -1, 1, -1, 1, -1, 1, -1};

int main() {
    cin >> N >> M;
    vector<ll> v[8];
    for(int i = 0; i < N; i++) {
        ll x, y, z;
        cin >> x >> y >> z;
        for(int j = 0; j < 8; j++) {
            v[j].push_back(d1[j] * x + d2[j] * y + d3[j] * z);
        }
    }

    ll ans = -1e18 - 1;
    for(int i = 0; i < 8; i++) {
        sort(v[i].begin(), v[i].end(), greater<ll>());
        ll sum = 0;
        for(int j = 0; j < M; j++) {
            sum += v[i][j];
        }
        ans = max(ans, sum);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b;cin>>a>>b;
  string s;cin>>s;
  ll c;
  bool isok=true;
  if(s[a]!='-') isok=false;
  else {
    rep(i,a) {
      c=s[i]-'0';
      isok=(0<=c&&c<=9);
      if(!isok) break;
    }
    if(isok) {
      rep(i,b) {
        c=s[a+1+i]-'0';
        isok=(0<=c&&c<=9);
        if(!isok) break;
      }
    }
  }
  if(isok) puts("Yes");else puts("No");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll long long
#define rep(i,n) for(int i=0; i<n; ++i)
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  ll a, b, x;
  cin >> a >> b >> x;
  if(a)
    cout << b/x - (a-1)/x << endl;
  else
    cout << b/x + 1<< endl;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <iostream>
#include <algorithm>
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define PER(i,a,b) for(int i=(a);i>=(b);i--)
#define RVC(i,S) for(int i=0;i<(S).size();i++)
#define RAL(i,u) for(int i=fr[u];i!=-1;i=e[i].next)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
     
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
/*============ Header Template ============*/

const int maxn=(int)(2e5)+5;
char s[maxn];
int a[maxn];
int sgn,ps,bnd,n,m;

inline int run_c(int m) {
    REP(c,1,m) {
        if(!(a[ps]^sgn)) a[ps]^=1;
        else {
            sgn^=1;ps++;
            if(ps>n) ps-=n;
        }
    }
}

inline void print() {
    REP(c,1,n) {
        printf("%c",(a[ps]^sgn)+'A');
        ps++;if(ps>n) ps-=n;
    } putchar('\n');
}

int main() {
    read(n);read(m);
    scanf("%s",s+1);
    REP(i,1,n) a[i]=s[i]-'A';
    sgn=0;ps=1;bnd=n<<1;
    if(m&1) bnd++;
    if(m<=bnd) {
        run_c(m);
        print();
        return 0;
    }
    run_c(bnd);print();
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<cstring>
#include<set>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=200010;
int n;
int tr[N];
int res[N];
struct node{
    int x;
    int y;
    int id;
    bool operator < (const node&W)const
    {
        if(x!=W.x)
        return x<W.x;
        return  y<W.y;
    }
}q[N];
int p[N];
int sz[N];
int find(int x)
{
    if(p[x]!=x)
        p[x]=find(p[x]);
    return p[x];
}
set<pair<int,int>>s;
set<pair<int,int>>S;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&q[i].x,&q[i].y),q[i].id=i,p[i]=i,sz[i]=1;
     sort(q+1,q+n+1);
   for(int i=1;i<=n;i++)
   {
            if(s.empty())
            s.insert({q[i].y,q[i].id});
        auto it=s.lower_bound({q[i].y,0});
        int b=q[i].id;
        b=find(b);
        bool flag=false;
        for(set<pair<int,int>>::iterator x=s.begin();x!=it;x++)
        {
            flag=true;
            int a=x->second;
           a=find(a);
            if(a!=b)
            {
                p[a]=b;
                sz[b]+=sz[a];
              //  break;
            }
        }
        if(!flag)
            s.insert({q[i].y,q[i].id});
   }
    for(int i=1;i<=n;i++)
        printf("%d\n",sz[find(i)]);
    return 0;
}

Measured memory_bytes: 12256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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; }

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

    int N,K; cin >> N >> K;
    vel A(N); rep(i,N) cin >> A[i];

    vel check(N, INF);

    ll cnt = 0;
    rep(i,N) {
        if(check[ A[i]-1 ] == INF) {check[ A[i]-1 ] = 0; cnt++;}
        check[ A[i]-1 ]++;
    }

    sort(all(check));

    ll sum = 0;
    if(cnt-K <= 0) {cout << 0 << endl; return 0;}
    rep(i,cnt-K) sum += check[i];
    if(cnt > K) cout << sum << endl;;
    return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define forin(in) for(int i=0; i<(int)in.size(); i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

int main() {
    const int MOD = 1000000007;
    int S; cin>> S;
    vector<int> dp(S);
    dp[0] = 0; dp[1] = 0; dp[2] = 1;
    for(int i = 3; i < S; i++){
        dp[i] = (dp[i - 1] + dp[i - 3]) % MOD;
    }
 
    cout<< dp[S - 1] << endl;
}

Measured memory_bytes: 3608
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

string s;

int main()
{
	cin>>s;
	sort(s.begin(),s.end());
	if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]) puts("Yes");
	else puts("No");
	rt0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b;
    char strx[1],stry[1];
    a=0;b=0;
    scanf("%s%s",strx,stry);
    if(strx[0]=='A'){
        a=1;
    }
    else if(strx[0]=='B'){
        a=2;
    }
    else if(strx[0]=='C'){
        a=3;
    }
    else if(strx[0]=='D'){
        a=4;
    }
    else if(strx[0]=='E'){
        a=5;
    }
    else{
        a=6;
    }

    if(stry[0]=='A'){
        b=1;
    }
    else if(stry[0]=='B'){
        b=2;
    }
    else if(stry[0]=='C'){
        b=3;
    }
    else if(stry[0]=='D'){
        b=4;
    }
    else if(stry[0]=='E'){
        b=5;
    }
    else{
        b=6;
    }
    if(a>b){
        printf(">\n");
    }
    else if (a<b){
        printf("<\n");
    }
    else {
        printf("=\n");
    }
    return 0;
}

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

class union_find  // union find.
{
    int* U;
public:
    union_find(int n){ U = new int [n]; for(int i = 0; i < n; i++) U[i] = i; }
    int root(int a){ if(U[a] == a){ return a; } U[a] = root(U[a]); return U[a]; }
    bool same(int a, int b){ return root(a) == root(b); }
    void join(int a, int b){ int x = root(a), y = root(b); U[x] = y; }
    ~union_find(){ delete [] U; }
};

struct edge{
	int v1, v2, w;
	bool operator < (const edge &e) const{ return w > e.w; }  // const?????????????????????
};

edge init(int ver_1, int ver_2, int weight)
{
	edge e;
	e.v1 = ver_1, e.v2 = ver_2, e.w = weight;
	return e;
}

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

	priority_queue<edge> ES;
	queue<edge> ST;
	union_find VS(n);

	for(i = 0; i < n; i++){
		for(j = 0; j < n; j++){
			scanf("%d", &w);
			if(i >= j || w < 0) continue;
			ES.push(init(i, j, w));
		}
	}
	int size = 0;
	edge e;
	while(!ES.empty() && size < n - 1){
		e = ES.top();
		ES.pop();
		if(!VS.same(e.v1, e.v2)){
			VS.join(e.v1, e.v2);
			ST.push(e);
			size++;
		}
	};
	int sum = 0;
	while(!ST.empty()){ e = ST.front(); sum += e.w; ST.pop(); };
	printf("%d\n", sum);

	return 0;
}

Measured memory_bytes: 1304
#include <bits/stdc++.h>
using namespace std;
using pll = pair<long long, long long>;
const int N = 2e5 + 10;
const int L = 19;
int n, dp[L][L];
long long a[N];

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

int cntFact(long long x, long long d) {
	int ans = 0;
	while (x % d == 0) {
		ans += 1;
		x /= d;
	}
	return ans;
}

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

	cin >> n;

	string num;
	char sep;
	long long x;
	for (int i = 0; i < n; i++) {
		cin >> num;

		if (num.find('.') == string::npos) {
			a[i] = stol(num);
			a[i] *= (long long) 1e9;
			continue;
		}

		string swho = num.substr(0, num.find('.'));
		string sdec = num.substr(num.find('.') + 1);

		while (sdec.size() < 9) {
			sdec += '0';
		}

		long long who = stol(swho);
		long long dec = stol(sdec);

		a[i] = who;
		a[i] *= (long long) 1e9;
		a[i] += dec;
	}

	long long ans = 0;
	for (int i = 0; i < n; i++) {
		int d2 = min(18, cntFact(a[i], 2));
		int d5 = min(18, cntFact(a[i], 5));

		for (int j = 18 - d2; j < L; j++) {
			for (int k = 18 - d5; k < L; k++) {
				ans += dp[j][k];
			}
		}

		dp[d2][d5] += 1;
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 5128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


int main(void){
  ios::sync_with_stdio(false);cin.tie(0);
  ///
  int n;
  cin >> n;
  vi d(n);
  rep(i,n) cin >> d[i];
  int ans=0;
  rep(i,n){
    rep(j,n){
      if(i<=j) continue;
      ans += d[i]*d[j];
    }
  }
  cout << ans << endl;
  ///
  return 0;
}

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

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

int main(){
    ll n;cin>>n;
    ll a[n+1];
    for(ll i=1;i<=n;i++){
        cin>>a[i];
    }
    ll total=0;
    for(ll i=1;i<=n;i=i+2){
        total+=a[i];
    }
    for(ll i=2;i<=n-1;i=i+2){
        total-=a[i];
    }
    ll x[n+1];
    x[1]=total/2;
    for(ll i=2;i<=n;i++){
        x[i]=a[i-1]-x[i-1];
    }
    cout<<x[1]*2;
    for(ll i=2;i<=n;i++){
        cout<<' '<<x[i]*2;
    }
    cout<<endl;
    return 0;
}



Measured memory_bytes: 2816
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;
typedef long long ll;
int main(){
    ll N, M; cin >> N >> M;
    vector<ll> A(N);
    vector<pair<ll, ll>> P(M); //(c, b)
    for(ll i = 0; i < N; i++){
        cin >> A[i];
    }
    for(ll i = 0; i < M; i++){
        ll b, c; cin >> b >> c;
        P[i] = make_pair(c, b);
    }

    sort(A.begin(), A.end());
    sort(P.rbegin(), P.rend());
    int cnt=0;
    for(ll i = 0; i < M; i++){
        //for(ll k = 0; k < N; k++) cout << A[k] << " "; cout << endl;
        ll b = P[i].second;
        if(A[cnt] >= P[i].first) break;
        for(ll j = 0; j < b; j++){
            if(A[cnt] < P[i].first){
                A[cnt] = P[i].first;
                cnt++;
            }
            else break;
        }
        //sort(A.begin(), A.end());

    }

    ll Sum = 0;
    for(ll i = 0; i < N; i++) Sum += A[i];
    cout << Sum << endl;
}

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

using namespace std;

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

    int L,R,d,ans=0;
    cin>>L>>R>>d;

    for(int i=L;i<=R;i++){
        if(i%d==0){
            ans++;
        }
    }
    cout<<ans<<"\n";


    return 0;
}


Measured memory_bytes: 3580
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		b,c,h,i,j,k,l,m,n,x,y;
	ll		ans = 0;
	string	s;
	vector<int>	a(5);
	for(i=0;i<5;i++) cin >> a[i];
	c=10;
	h=0;
	for(i=0;i<5;i++){
		b=a[i]%10;
		if(b!=0){
			a[i]=a[i]-b+10;
			if(b<c){
				c=b;
			}
		}
		h+=a[i];
	}
	printf("%d\n", h-(10-c));
	return 0;
}


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

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(){
    ll N,P; cin >> N >> P;
    ll o=0,e=0;
    rep(i,N){
        ll a;
        cin >> a;
        if(a%2) o++;
        else e++;
    }

    COMinit();
    unsigned long long res = 0;
    ll tmp = pow(2,e);
    if(P){     
        for(int i=1;i<=o;i+=2){
            res += tmp * COM(o,i);
        }
    }else{
        for(int i=0;i<=o;i+=2){
            res += tmp * COM(o,i);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 15972
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> bag(200001,0);
	for (int i = 0; i< n; ++i) {
		int ai;
		cin >> ai;
		bag[ai]++;
	}
	sort(bag.rbegin(), bag.rend());
	int sum = 0;
	for (int i = 0; i < k; ++i) {
		sum += bag[i];
	}
	cout << n - sum << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	int n,p,d1,d2,wa;
	int maxp, maxd = 0;

	while(1) {
		cin >> n;
		maxd = 0;
		if (n == 0) {
			break;
		} else {
			for (int i = 0; i < n; i++) {
				cin >> p >> d1 >> d2;
				wa = d1 + d2;
				if (wa > maxd) {
					maxd = wa;
					maxp = p;
				}
			}
		}

		cout << maxp << " " << maxd << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<cstdio>

int main()
{
	long long int a,b;
	char op;
	scanf("%lld %c %lld",&a, &op, &b);
	if(op == '+')
		printf("%lld\n", a+b);
	else
		printf("%lld\n", a-b);
	
	
	
	return 0;
}

Measured memory_bytes: 128
n,m = map(int,input().split())
D=[1] * (n+1)
for _ in range(m):
    D[int(input())] = 0
for i in range(2, n+1):
    D[i] = (D[i-1] + D[i-2]) % 1000000007 * D[i]
print(D[n])

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

int main()
{ 
  int a, b, c ;
  cin >> a >> b >> c ;

  if(a + b + c >= 22)
  {
    cout << "bust" <<endl ;
  }
  else
  {
    cout << "win" << endl ;
  }
  
}


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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

string s;
int ans, ansi, i, fl, j, fll;
int main(){
	cin >> s;
	ans = 100000;
	for(i='a';i<'z'+1;i++){
		ansi=0;
		fll=0;
		for(j=0;j<s.size();j++){
			if(s[j]==i){
				if(fll==0){
				ansi=max(ansi, j);	
				}
				ansi=max(ansi, j-fl-1);
				fl = j;
				fll = 1;
			}	
		}
		int x =s.length()-fl-1;
		if(fll==1){
			ansi=max(ansi, x);
			ans=min(ans, ansi);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val s = readLine()!!
    var cnt = 0.0
    var wcnt = 0.0
    s.forEachIndexed { index, c ->
        if (c == 'W') {
            cnt += index - wcnt
            wcnt++
        }
    }
    println(String.format("%.0f", cnt))
}

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

int fibonacci(int n){
  int i;
  int F[50];
  F[0] = F[1] = 1;
  for( i = 2; i <= n; i++ ){
    F[i] = F[i-1] + F[i-2];
  }
  return F[n];
}


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

int main()
{
    int d,n;
    cin>>d>>n;
    int ans=0;
    if (n==100)
        n=101;
    if(d==0)
        cout<<n<<endl;
    else
        {
        for(int i=1; i<=d; i++)
        {
            ans=n*100;
            n=ans;
        }
        cout<<ans<<endl;
        }

    return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

typedef long long ll ;
typedef double db;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define sf(a)		 scanf("%d",&a)
#define sfl(a)		scanf("%lld",&a)
#define sff(a,b)	 scanf("%d %d",&a,&b)
#define sffl(a,b)	scanf("%lld %lld",&a,&b)
#define pb(a)         push_back(a)
#define loop0(i,n)          for(int i=0;i<n;i++)
#define loop1(i,n)          for(int i=1;i<=n;i++)
#define loopab(a,b)       for(int i=a;i<=b;i++)
#define gcd(a, b)     __gcd(a, b)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)     cout<<"Case "<<z<<": "<<x<<"\n"
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;
/*ll gcd(ll a, ll b){
	if(a%b==0) return b;
	return (b,a%b);
	}*/
int gcd(int a,int b){
	while(b){
		int c = a%b;
		a = b;
		b = c;
		}
	return a;
	}
int main()
{
	int n,a,b,c,s=0;
	cin>>n;
	loop1(a,n){
		loop1(b,n){
			loop1(c,n){
				s += gcd(gcd(a,b),c);
				}
			}
	}
	cout<<s<<nw;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

int n;
vector<ll> a,d;
int dp[2][801][201];
int dp2[801][201];
ll fac[202],p10[1000],fsum[202];

ll solve(){
  int crt=0,nxt=1;
  memset(dp,0,sizeof(dp));
  dp[crt][0][0]=1;
  n=a.size();
  rep(i,n){
    memset(dp[nxt],0,sizeof(dp[nxt]));
    rep(j,801){
      rep(k,201){
        if(j+d[i]<=800&&k+1<=200)(dp[nxt][j+d[i]][k+1]+=dp[crt][j][k])%=mod;
        (dp[nxt][j][k]+=dp[crt][j][k])%=mod;
      }
    }
    swap(crt,nxt);
  }

  ll res=0;
  rep(i,n){
    memset(dp2,0,sizeof(dp2));
    rep(j,801){
      rep(k,201){
        if(j-d[i]>=0&&k>=1) dp2[j][k]=(dp[crt][j][k]-dp2[j-d[i]][k-1]+mod)%mod;
        else dp2[j][k]=dp[crt][j][k];
        if(n-1-k>=0)(res+=((((a[i]*p10[j])%mod)*fac[k]%mod)*dp2[j][k]%mod)*fsum[n-1-k]%mod)%=mod;
      }
    }
  }

  return res;
}

int main(){
  fac[0]=fac[1]=1;
  repl(i,1,200)fac[i+1]=fac[i]*(i+1)%mod;
  rep(i,201){
    ll p=1;
    rep(j,i+1){
      (fsum[i]+=p)%=mod;
      (p*=i-j)%=mod;
    }
  }
  p10[0]=1;
  rep(i,800)p10[i+1]=p10[i]*10%mod;

  cin>>n;
  rep(i,n){
    ll aa;
    cin>>aa;
    a.push_back(aa);
  }
  sort(all(a)); reverse(all(a));
  rep(i,n){
    d.push_back(to_string(a[i]).size());
  }
  if(a[n-1]==0){
    ll resa=solve();
    a.pop_back(); d.pop_back();
    ll resb=solve();
    cout<<(resa-resb+mod)%mod<<endl;
  }else{
    cout<<solve()<<endl;
  }
  return 0;
}



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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    ll H;
    cin >> H;
    ll ans = 0;

    ll t = 1;
    while (H > 0) {
        H /= 2LL;
        ans += t;
        t *= 2LL;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	int a,b;
	cin>>a>>b;
	if(a+b==15) {
		cout<<"+"<<endl;
	}
	else if(a*b==15) {
		cout<<"*"<<endl;
	}
	else {
		cout<<"x"<<endl;
	}
}

Measured memory_bytes: 256
using System;
    using System.Text;
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            ulong m1 = ulong.Parse(input[0]);

            string[] input2 = Console.ReadLine().Split(' ');
            ulong m2 = ulong.Parse(input2[0]);

            int ret = 0;
            if ( m1 == m2)
            {
                ret = 0;
            }
            else
            {
                ret = 1;
            }

            Console.WriteLine(ret);

        }
    }

Measured memory_bytes: 13140
#include <algorithm>
#include <bitset>
//#include <boost/multiprecision/cpp_int.hpp>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
//namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
// using ll = boost::multiprecision::cpp_int;
using ll = long long;
#define FORi(N) for(ll i = 0; i < N; ++i)
#define FORj(N) for(ll j = 0; j < N; ++j)
#define FORk(N) for(ll k = 0; k < N; ++k)

#define ALL(v) v.begin(),v.end()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}

int main() {
    ll N, D;
    cin >> N >> D;
    ll _2d_1 = 2 * D + 1;
    ll ans = N / _2d_1+1;
    if(N%_2d_1 ==0)
        ans--;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <string.h>

using namespace std;

int main(void)
{
    int a,b;
    cin >> a >> b;

    int t = b - a;

    int sum = 0;
    for (int i = 1; i <= t; i++) {
        sum += i;
    }

    cout << sum - b << endl;

    return 0;
}

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

std::vector<bool> Eratosthenes(int n) {
	std::vector<bool> num(n, true);
	num[0] = num[1] = false;
	for (int i = 0; i*i <= n; ++i) {
		if (num[i]) {
			for (int j = 2; i*j < n; ++j) {
				num[i*j] = false;
			}
		}
	}
	return num;
}

int main() {
	auto p(Eratosthenes(100005));
	std::vector<bool> v(100005, false);
	for (int i = 1; i < 100005; ++i) {
		v[i] = p[i] && p[(i + 1) / 2];
	}
	std::vector<int> c(100005, 0);
	for (int i = 1; i < 100005; ++i) {
		c[i] = c[i - 1] + v[i];
	}
	int Q;
	std::cin >> Q;
	for (int i = 0; i < Q; ++i) {
		int l, r;
		std::cin >> l >> r;
		std::cout << c[r] - c[l - 1] << std::endl;
	}
	return 0;
}

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

int main()
{
	int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0,ans=0;
	//string s;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;

	if (c-a<=0)
	{
		if (-c+a<= d)
		{
			cout << "Yes" << endl;
			return 0;

		}
	}
	else
	{
		if (c - a<=d)
		{
			cout << "Yes" << endl;
			return 0;

		}
	}
	if (b - a<=0)
	{
		if (-b + a<=d)
		{
			if (c - b<=0)
			{
				if (b - c<=d)
				{
					cout << "Yes" << endl;
					return 0;

				}
			}
			else
			{
				if (c - b<=d)
				{
					cout << "Yes" << endl;
					return 0;

				}
			}

		}
	}
	else
	{
		if (b - a<=d)
		{
			if (c - b<=0)
			{
				if (b - c<=d)
				{
					cout << "Yes" << endl;
					return 0;

				}
			}
			else
			{
				if (c - b<=d)
				{
					cout << "Yes" << endl;
					return 0;

				}
			}

		}
	}
	cout << "No" << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    int i = 0;
    int count = 0;
    while(i < n){
        if(s[i] == 'A'){
            i++;
            if(s[i] == 'B'){
                i++;
                if(s[i] == 'C'){
                    count++;
                    i++;
                }
            }
        }else{
            i++;
        }
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 3160
class UnionFind:
    def __init__(self, n):
        self.r = [-1] * n
    
    def root(self, x):
        if self.r[x] < 0:
            return x
        self.r[x] = self.root(self.r[x])
        return self.r[x]

    def merge(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return False
        if self.r[x] > self.r[y]:
            x, y = y, x
        self.r[x] += self.r[y]
        self.r[y] = x
        return True

    def size(self, x):
        return -self.r[self.root(x)]


N, M = map(int, input().split())
f, uf = [set() for i in range(N)], UnionFind(N)

for _ in range(M):
    A, B = map(lambda x: int(x)-1, input().split())
    uf.merge(A, B)

print(max([uf.size(i) for i in range(N)]))


Measured memory_bytes: 104472
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32
from bisect import bisect_left, bisect_right

def solve(N: int, a: "List[int]"):
    
    ans = 0
    for i in range(N):
        if a[a[i]-1] == i+1:
            ans += 1

    print(ans//2)


    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14452
#include <bits/stdc++.h>
using namespace std;
long long dp[3010][3010][4];
int R,C,K;
vector<vector<long long>> vec;
int main(){
  cin>>R>>C>>K;
  vec.resize(R,vector<long long>(C,0));
  for(int i=0;i<R;i++){
    for(int j=0;j<C;j++){
      for(int k=0;k<4;k++){
        dp[i][j][k]=0;
      }
    }
  }
  for(int i=0;i<K;i++){
    int r,c,v;
    cin>>r>>c>>v;
    vec.at(r-1).at(c-1)=v;
  }
  dp[0][0][1]=vec.at(0).at(0);
  for(int y=0;y<R;y++){
    for(int x=0;x<C;x++){
      if(x+1<C){
        dp[y][x+1][3]=max(dp[y][x][3],max(dp[y][x+1][3],dp[y][x][2]+vec.at(y).at(x+1)));
        dp[y][x+1][2]=max(dp[y][x][2],max(dp[y][x+1][2],dp[y][x][1]+vec.at(y).at(x+1)));
        dp[y][x+1][1]=max(dp[y][x][1],max(dp[y][x+1][1],dp[y][x][0]+vec.at(y).at(x+1)));
        dp[y][x+1][0]=max(dp[y][x][0],max(dp[y][x+1][0],dp[y][x][0]));
      }
      if(y+1<R){
        dp[y+1][x][0]=max(dp[y+1][x][0],dp[y][x][0]);
        dp[y+1][x][0]=max(dp[y+1][x][0],dp[y][x][1]);
        dp[y+1][x][0]=max(dp[y+1][x][0],dp[y][x][2]);
        dp[y+1][x][0]=max(dp[y+1][x][0],dp[y][x][3]);
        dp[y+1][x][1]=max(dp[y+1][x][1],dp[y][x][0]+vec.at(y+1).at(x));
        dp[y+1][x][1]=max(dp[y+1][x][1],dp[y][x][1]+vec.at(y+1).at(x));
        dp[y+1][x][1]=max(dp[y+1][x][1],dp[y][x][2]+vec.at(y+1).at(x));
        dp[y+1][x][1]=max(dp[y+1][x][1],dp[y][x][3]+vec.at(y+1).at(x));
      }
    }
  }
  long long ans=0;
  for(int i=0;i<4;i++){
    ans=max(ans,dp[R-1][C-1][i]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 355836
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;
#include<algorithm>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)

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



int main(){
    
    int a,b;
    
    cin>>a>>b;
    if(a+b<10)cout<<a+b<<endl;
    else cout<<"error"<<endl;
        
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	if !sc.Scan() {
		panic("failed scan string")
	}
	return sc.Text()
}

func nextInt() int {
	if !sc.Scan() {
		panic("failed scan int")
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	k := nextInt()

	if ((n - 1) / 2) >= k-1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 640
N, L = list(map(int, input().split()))
resultList = []
tasteList = []
for i in range(N):
    x = int(L + i)
    resultList.append(x)
    tasteList.append(abs(x))

listMin = min(tasteList)
listNum = tasteList.index(listMin)

if resultList[listNum] > 0:
    listSum = sum(resultList) - listMin
else:
    listSum = sum(resultList) + listMin

print(listSum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)

                    
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll mod = 1e9+7;
void chmod(ll &M){
  if(M >= mod) M %= mod;
  else if(M < 0){
     M += (abs(M)/mod + 1)*mod;
    M %= mod;
}
}
ll modpow(ll x, ll n){
   if(n==0) return 1;
  ll res=modpow(x, n/2);
 if(n%2==0) return res*res%mod;
else return res*res%mod*x%mod;
}
int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

using namespace std;
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
int main()
{
    int K, X;
    cin >> K >> X;
    if (K * 500 >= X) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3528
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
static int desc(const void *a, const void *b);
static int asc(const void *a, const void *b);
 
int main (void){
    int n,k,i,j;
    int x,y,z;
    int count = 0;
    double dx;
    int box[200001]={};
    char text[200001]={};
    char s[200001]={};
    char t[200001]={};
    char alf[256] = {"abcdefghijklmnopqrstuvwxyz"};
    char alfb[256] = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
    char sample_text[256];
 
    // Input Area //
    //scanf("%d %d",&x,&y);
    scanf("%s",s);
    //scanf("%d %d",&x,&y);
    //scanf("%s",text);
 
    /*
    if(strcmp(text,s)==0){
        x--;
    }else if(strcmp(text,t)==0){
        y--;
    }
    */
    i = 0;
    n = 0;

        if (s[2] == s[3] && s[4] == s[5]){
            n = 1;
        }

    
    if (n == 1){
        printf("Yes");
    }else{
        printf("No");
    }
    
    //printf("%d %d",x,y);
    //scanf("%s",&sample_text);
    //scanf("%s",&text);
 
    /*
    scanf("%d",&n);
    for(i = 0; i < n; i++){
        scanf("%d",&box[i]);
    }
    for(i = 0; i < n; i++){
        printf("%d",box[i]);
    }
    printf("\n");
    qsort(box,n,sizeof(int),desc);
    
    */
    // Output Area //
    
    /*
    for(i = 0; i < n; i++){
        printf("%d",box[i]);
    }
    */
 
}
 
static int desc(const void *a, const void *b){
    return *(int *) b - *(int *) a;
}
 
static int asc(const void *a, const void *b){
    return *(int *) a - *(int *) b;
}
 
 
/* KonoLvBANK
 
配列降順ソート
qsort(box,n,sizeof(int),desc);
配列昇順ソート
qsort(box,n,sizeof(int),asc);
 
アルファベットを次の単語に変えるやつ
    while(1){
        if (text[i] == '\0'){
            break;
        }
        for(j = 0; j < 26; j++){
            if (text[i] == alf[j]){
                if (j != 25){
                    text[i] = alf[j + 1];
                }else{
                    text[i] = alf[0];
                }
                break;
            }
        }
        i++;
    }
    */


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;

int main()
{
	char s[3333];
	gets(s);
	int len=strlen(s);
	int len1=len-2;
	for(int i=0;i<len;i++)
	{
		if(i==0)
		{
			cout<<s[i];
			cout<<len1;
		}
		if(i==len-1) cout<<s[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
S = [0]*(H+2)
S[0] = ''.join(['#']*(W+2))
S[-1] = ''.join(['#']*(W+2))
for i in range(1,H+1):
  S[i] = '#'+input()+'#'

maxd = 0
import queue
dy = [1,0,-1,0]
dx = [0,1,0,-1]
for h in range(1,H+1):
  for w in range(1,W+1):
    if S[h][w]=='.':
      visited = [[False]*(W+2) for _ in range(H+2)]
      q = queue.Queue()
      visited[h][w] = True
      q.put([h,w,0])
      while not q.empty():
        a,b,c = q.get()
        #print(a,b,c)
        for i in range(4):
          y,x = a+dy[i], b+dx[i]
          if S[y][x]=='.' and visited[y][x]==False:
            q.put([y,x,c+1])
            visited[y][x]=True
      maxd = max(maxd,c)
print(maxd)


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

void self(ll &a,ll b){
    a = max(a,b);
}
    

int main()
{
    int n,w;
    cin>>n>>w;
    
    ll arr[w+1];
    memset(arr,0,sizeof(arr));
    
    for(int i=1;i<=n;i++){
        
        int value,cst;
        cin>>cst>>value;
        
        for(int weight = w-cst;weight >=0;weight--){
            self(arr[weight + cst],(arr[weight] + value));
        } 
    }
    ll ans = 0;
    for(int i=0;i<=w;i++){
        self(ans,arr[i]);
    }
    cout<<ans;
    
       
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int main()
{
  int N, K;
  int64_t count = 0;
  cin >> N >> K;
  vector<int> H(N);
  for(int i = 0; i < N; i++){
    cin >> H.at(i);
  }
  sort(H.begin(), H.end(), 
  [](auto const &l, auto const &r)->bool{
    return l > r;
  });
  
  for(int i = 0; i < N; i++){
    if(i >= K){
      count += H.at(i);
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

ll dp[55][55][55*55]={};

int main(void) {
  ll i, j, k;
  ll N, A;
  cin >> N >> A;
  ll x[55];
  
  for(i=0; i<N; i++) cin >> x[i];
  
  dp[0][0][0]=1;
  for(i=0; i<N; i++) {
    for(j=0; j<=N; j++) {
      for(k=0; k<55*55; k++) {
        dp[i+1][j][k]+=dp[i][j][k];
        dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
      }
    }
  }
  
  ll ans=0;
  for(j=1; j<=N; j++) ans+=dp[N][j][j*A];
  
  pt(ans);
}



Measured memory_bytes: 66560