akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// typedef long long LL;
// typedef unsigned long long UL;
// typedef pair<int, int> P;
// typedef pair<int, P> PPI;
// typedef pair<LL, LL> PL;
// typedef long long LL;
// // LLONG_MIN, INT_MIN
// #define xx first
// #define yy second
// const LL INF = 1000000000;
#define RG register int
#define LL long long
struct edge
{
    LL to, cost;
    edge(int a, int b):to(a), cost(b){}
};

void debug(vector<int>& db){
  for(auto x:db)
    cout<<x<<" ";
  cout<<endl;
}

LL mod = 1000000007;
LL my_pow(LL a, LL b){
  LL re = 1;
  while(b){
    if(b&1)re = (re*a)%mod;
    a = (a*a)%mod;
    b >>= 1;
  }
  return re;
}


int main()
{
    //freopen("input", "r", stdin);
    //freopen("output", "w", stdout);
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    LL n,k;
    cin>>n>>k;
    LL ans = my_pow(k, n);
    vector<LL> cnt(k+1);
    for(LL i=k;i>=2;i--){
      cnt[i] = my_pow(k/i, n);
      for(LL j = i*2;j<=k;j+=i)
        cnt[i] = (cnt[i] - cnt[j]+mod)%mod;
      ans += cnt[i]*(i-1);
      ans %= mod;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3968
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int n;
int p[200];
int main()
{
    while (scanf("%d",&n)>0)
    {
        for (int i=1; i<=n; i++) scanf("%d",&p[i]);
        sort(p+1,p+1+n);
        int ans=0;
        for (int i=1; i<=n; i++)
        ans+=(n-i+1)*p[i];
        printf("%d\n",ans);
    }
}

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

#define pb push_back
#define fi first
#define se second
#define ll long long
#define pq priority_queue
#define mp make_pair
#define pii pair<int,int>
#define mod 998244353

int lowbit(int x) {return x&(-x);}

int n,W;
int w[111],v[111];
ll f[111911];

int main(){
	scanf("%d%d",&n,&W);
	for (int i=1;i<=n;i++) scanf("%d%d",&w[i],&v[i]);
	ll ans=0ll;
	for (int i=1;i<=n;i++)
		for (int j=W;j>=w[i];j--) 
			f[j]=max(f[j],f[j-w[i]]+(ll)v[i]),ans=max(ans,f[j]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#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;

class Solution {
public:
    long long solve(vector<int>& A) {
        int n = A.size();
        vector<int> ord(n, 0);
        iota(ord.begin(), ord.end(), 0);
        sort(ord.begin(), ord.end(), [&](int l, int r) {
            return A[l] > A[r];
        });

        const long long INF = 1LL << 60;
        vector<vector<long long>> dp(n + 1, vector<long long>(n + 1, -INF));
        dp[0][0] = 0;

        for (int s = 0; s < n; ++s) {
            int x = ord[s];
            long long v = A[x];
            for (int i = 0; i <= s; ++i) {
                int j = s - i;
                if (dp[i][j] < 0) {
                    continue;
                }

                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + v * abs(x - i));
                dp[i][j + 1] = max(dp[i][j + 1], dp[i][j] + v * abs(n - 1 - j - x));
            }
        }

        long long res = -INF;
        for (int i = 0; i <= n; ++i) {
            res = max(res, dp[i][n - i]);
        }
        return res;
    }


};

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

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

    Solution sol;
    cout << sol.solve(A) << "\n";

    return 0;
}

Measured memory_bytes: 34584
let (a,b,c,d) = Scanf.scanf "%d %d %d %d\n" (fun x y z w -> (x,y,z,w))

let () = let tmp = a + b - c - d in
         if tmp > 0 then print_endline "Left"
         else if tmp = 0 then print_endline "Balanced"
         else print_endline "Right"

Measured memory_bytes: 384
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <queue>
#include <iostream>
#include <cmath>

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
typedef long long ll;
using namespace std;


void solve(std::string S){
    if(S[S.size() - 1] != 's')  { 
        cout << S << "s" << endl;
    } else { 
        cout << S << "es"  << endl;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 3628
//・。・v
#include<iostream>
using namespace std;
int h,a[2000001];

void maxHeapify(int i){
  int l,r,largest;
  l=2*i;
  r=2*i+1;
  //左の子、自分、右の子で値が最大のノードを見る
  if(l<=h && a[l]>a[i]) largest=l;
  else largest=i;
  if(r<=h && a[r]>a[largest]) largest=r;
  if(largest!=i){
    swap(a[i],a[largest]);
    maxHeapify(largest);
  }
}

int main(){
  cin>>h;
  for(int i=1;i<=h;++i) cin>>a[i];
  for(int i=h/2;i>=1;--i) maxHeapify(i);
  for(int i=1;i<=h;++i){
    cout<<" "<<a[i];
  }
  cout<<endl;
  return 0;
}



Measured memory_bytes: 5028
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
struct A{
    int a[2][2];
    A(){}
    A(string A,string B){
        r(i,2)r(j,2)a[i][j]=0;
        if(A[0]=='#')a[0][0]=1;
        if(B[0]=='#')a[0][1]=1;
        if(A[1]=='#')a[1][0]=1;
        if(B[1]=='#')a[1][1]=1;
    }
};
int dx[]={0,0,1,1,1,0,-1,-1,-1};
int dy[]={0,-1,-1,0,1,1,1,0,-1};
A init=A("..","..");
string s1,s2;
int ans,h,n;
bool check(vector<A> &v,A &a1,A &a2,int dep){
    r(i,2){
        r(j,2){
            if(v[dep].a[i][j]&&a1.a[i][j])return 0;
            if(v[dep+1].a[i][j]&&a2.a[i][j])return 0;
        }
    }
    return 1;
}
int CNT(vector<A> &v,int dep){
    int sum=0;
    r(i,2){
        r(j,2){
            sum+=v[dep].a[i][j];
        }
    }
    return sum;
}
int SET(vector<A> &v,A &a1,A &a2,int dep){
    int sum=0;
    r(i,2){
        r(j,2){
            v[dep].a[i][j]+=a1.a[i][j];
            v[dep+1].a[i][j]+=a2.a[i][j];
        }
    }

    if(CNT(v,dep)==4)sum++,v[dep]=init;
    if(CNT(v,dep+1)==4)sum++,v[dep+1]=init;

    for(int i=0;i<19;i++){
        for(int j=0;j<19;j++){
            if(CNT(v,j)==0&&CNT(v,j+1))swap(v[j],v[j+1]);
        }
    }
    return sum;
}
int result(vector<A> &v){
    int pp=0;
    r(i,20)if(CNT(v,i)==4)pp++;
    return pp;
}
void dfs(int d,vector<A> v,const vector<A> &a,int SUM){
    if(d==n){
        ans=max(ans,SUM+result(v));
        return;
    }
    r(k,9){
        int flag=0,sum=0;
        r(i,2)r(j,2){
            int y=i+dy[k];
            int x=j+dx[k];
            if((a[d*2].a[i][j]||a[d*2+1].a[i][j])&&(y<0||x<0||y>1||x>1))flag=1;
        }
        if(flag)continue;
        A a1=init,a2=init,a3=init,a4=init;
        r(i,2)r(j,2){
            a1.a[i][j]=a[d*2].a[i][j];
            a2.a[i][j]=a[d*2+1].a[i][j];
            sum+=a1.a[i][j];
        }
        if(!sum)swap(a1,a2);
        r(i,2)r(j,2){
            int y=i+dy[k];
            int x=j+dx[k];
            if(y<0||x<0||y>1||x>1)continue;
            a3.a[y][x]=a1.a[i][j];
            a4.a[y][x]=a2.a[i][j];
        }
        a1=a3;
        a2=a4;
        sum=0;
        int depth;
        vector<A>V=v;
        for(int i=18;i>=0;i--){
            if(i==0){
                if(!check(V,a1,a2,0))sum+=SET(V,a1,a2,i+1);
                else sum+=SET(V,a1,a2,i);
            }
            else if(!check(V,a1,a2,i)){
                sum+=SET(V,a1,a2,i+1);
                break;
            }
        }
        dfs(d+1,V,a,sum+SUM);
    }
}
signed main(){
    while(cin>>h>>n,n){
        vector<A>v(20),a;
        r(i,20)v[i]=init;
        r(i,h){
            cin>>s1>>s2;
            v[i]=A(s1,s2);
        }
        r(i,n*2){
            cin>>s1>>s2;
            a.push_back(A(s1,s2));
        }
        ans=0;
        dfs(0,v,a,0);
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    reverse(all(a));
    ll ans=a[0];
    n-=2;
    int now=1;
    while(n){
        if(n==1){
            ans+=a[now];
            break;
        }
        ans+=a[now]*2;
        now++;
        n-=2;
    }
    cout << ans << endl;
    return 0;
}


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

int n,tot=0,sumv=0;
int a[100005],b[100005];

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>b[i];
		tot+=b[i];
		b[i]*=2;
	}	
	for (int i=1;i<n;i+=2)  sumv+=b[i];
	a[n]=tot-sumv;

	for (int i=n-1;i>=1;i--)  a[i]=b[i]-a[i+1];
	for (int i=1;i<=n;i++)  cout<<a[i]<<' ';
	
	return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <queue>
#include <cstring>
using namespace std;
typedef pair<int,int> P;

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

int main() {
  int h,w;
  int ans = 0;
  cin >> h >> w;
  queue<P> q;
  for(int i = 0; i < h; i++) {
    string s;
    cin >> s;
    for(int j = 0; j < s.size(); j++) {
      grid[i][j] = s[j];
      if(s[j] == '#') q.push(P(i,j)); 
    }
  }

  while(true) {
    if(q.size() == 0) break;
    int k = q.size();
    // cout <<"k = "<< k << endl;
    for(int i = 0; i < k; i++) {
      P p = q.front();
      q.pop();
      for(int j = 0; j < 4; j++) {
	int nx = p.first + dx[j];
	int ny = p.second + dy[j];
	if(nx >= 0 && nx < h && ny >= 0 && ny < w && grid[nx][ny] == '.') {
	  q.push(P(nx,ny));
	  grid[nx][ny] = '#';
	}
      }
    }
    ans++;
  }

  cout << ans - 1<< endl;
}
  
  


Measured memory_bytes: 9488
#include <stdio.h>
int main()
{
    char a[1250];
    int i=0,j;

    while (1)
    {
        scanf("%c",&a[i]);
        if (a[i]=='\n')
        {
            break;
        }

        i++;
    }
    for (j=0; j<i; j++)
    {
        if (a[j]>='a' && a[j]<='z')
        {
            a[j]-=32;
        }
        else if (a[j]>='A' && a[j]<='Z')
        {
            a[j]+=32;
        }
        printf("%c",a[j]);
        if(j+1==i)
        {
            printf("\n");
        }
    }



    return 0;
}



Measured memory_bytes: 2056
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
using namespace std;

const double EPS = 1e-9;

double calc( double* sinv, int x )
{
	double xv = 0.0;
	int angle = 360;
	for( int i = 0; i < x - 1; ++i ){
		int a;
		cin >> a;
		xv += sinv[ a ];
		angle -= a;
	}
	xv += sinv[ angle ];
	return xv;
}

int main()
{
	double sinv[ 180 ] = {0.0};
	for( int i = 1; i <= 90; ++i ){
		sinv[ i ] = sinv[ 180 - i ] = sin( i * M_PI / 180.0 );
	}

	int m, n;
	while( cin >> m && m ){
		double mv = calc( sinv, m );
		cin >> n;
		double nv = calc( sinv, n );
		int ans = 0;
		if( fabs( mv - nv ) < EPS ){
			ans = 0;
		}else if( mv > nv ){
			ans = 1;
		}else{
			ans = 2;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <stack>
#include <string>
using namespace std;

int main(){
	char buf[11],res[11];
	cin >> buf;
	int j=0;
	for(int i=0;buf[i] != '\0';i++){
		if(buf[i] != 'B'){
			res[j++] = buf[i];
		}else{
			j--;
			if(j<0) j=0;
		}
	}
	res[j] = '\0';
	cout << res << endl;
}

Measured memory_bytes: 256
import itertools

n = int(input())
s = list(input())
ans = 0

li = [[] for _ in range(10)]
for i in range(n):
    t = int(s[i])
    li[t].append(i)
    

for i in range(0,10):
    for j in range(0,10):
        for k in range(0,10):
            a = 0
            b = 0
            
            if len(li[i]) > 0:
                a = li[i][0]
                
                for d in li[j]:
                    if d > a:
                        b = d
                        break
                else:
                    break
                
                for e in li[k]:
                    if e > b:
                        ans += 1
                        break
                    
print(ans)

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> vecL(M);
    vector<int> vecR(M);
    for (int i = 0; i < M; i++){
        cin >> vecL.at(i) >> vecR.at(i);
    }
    std::sort(vecL.begin(), vecL.end() );
    std::sort(vecR.begin(), vecR.end() );
    if (vecR.at(0) >= vecL.at(M-1)){
        cout <<  vecR.at(0) - vecL.at(M-1) + 1 << endl;
    }
    else {
        cout << 0 << endl;
    }
    
}


Measured memory_bytes: 1024
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//priority_queue<int> pque;
//priority_queue<int, vector<int>, greater<int>> pque;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;


int main(void){
    int a,b;
    cin >> a >> b;
    if(a == 1){
        a += 13;
    }
    if(b == 1){
        b += 13;
    }
    if(a > b){
        cout << "Alice";
    }else if(a  == b){
        cout << "Draw";
    }else{
        cout << "Bob";
    }
    cout << endl;
}


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

  int n;
  cin>>n;
  int64_t x,y;
  x=0;
  for(int i=1;i<n+1;i++){
    y=n/i;
    x+=(i*y*(y+1))/2;
  }
  cout<<x<<endl;

}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007

Int diver = 998244353;


Int calc(Int ipt) {
	if (ipt > 0)return ipt %= diver;
	else if (ipt == 0)return 0;
	else return ipt + diver;
}

Int dp[90050];



int main() {
	int N, K; cin >> N >> K;
	vector<int> l;
	for (int i = 0; i < N; i++) {
		int ipt;
		cin >> ipt;
		l.push_back(ipt);
	}

	sort(l.begin(), l.end());

	int ans = 0;


	for (int i = 0; i < K; i++) {
		ans += l.back();
		l.pop_back();

	}
	print(ans);







	



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[1010][1010];
string p,q;
string b="JOI";
int ans,res;
int cnt(int x,int y){
	if(s[x][y]==p[0]&&s[x][y+1]==p[1]&&s[x+1][y]==q[0]&&s[x+1][y+1]==q[1]){
		return 1;
	}
	return 0;
}
int sq(int x,int y){
	return cnt(x-1,y-1)+cnt(x-1,y)+cnt(x,y-1)+cnt(x,y);
}
int main(){
	int h,w; cin >> h >> w;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin >> s[i][j];
		}
	}
	cin >> p >> q;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			ans+=cnt(i,j);
			int v=sq(i,j);
			for(int k=0;k<3;k++){
				char cp=s[i][j];
				s[i][j]=b[k];
				res=max(res,sq(i,j)-v);
				s[i][j]=cp;
			}
		}
	}
	cout << ans+res << endl;
}



Measured memory_bytes: 4204
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl endl

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int ceil_(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); }
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * ceil_(a, b)); }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class CSkillUp {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));
    rep(i, N) {
      cin >> C[i];
      rep(j, M) {
        cin >> A[i][j];
      }
    }
    int ans = INF;
    rep(i, bpm(2, N)) {
      int ret = 0;
      vector<int> temp(M, 0);
      rep(j, N) {
        if ((i >> j) & 1) {
          ret += C[j];
          rep(k, M) {
            temp[k] += A[j][k];
          }
        }
      }
      rep(j, M) {
        if (temp[j] < X) {
          break;
        } else if (j == M - 1) {
          ans = min(ans, ret);
        }
      }
    }
    if (ans != INF) {
      cout << ans << Endl;

    } else {
      cout << -1 << endl;
    }
  }
};


signed main() {
  CSkillUp solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3856
import sys

while True:
    n = int(sys.stdin.readline().rstrip())
    if n == 0:
        break;
    x = {}
    for i in range(n):
        k,v = sys.stdin.readline().rstrip().split(' ')
        x[k] = v
    n = int(sys.stdin.readline().rstrip())
    y = []
    for i in range(n):
        a = sys.stdin.readline().rstrip()
        if a in x.keys():
            y.append(x[a])
        else:
            y.append(a)
    print(''.join(y))

Measured memory_bytes: 8712
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define fo(i,n) for(int i=0;i<n;i++)
#define eb emplace_back
#define M 1000000007
#define vi vector<int>
#define vlli vector<lli>
#define pi pair<int,int>
#define mp make_pair
#define mapi map<int,int>
int main()
{
  //ios_base::sync_with_stdio(false);
  //cin.tie(NULL);
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int b[n+1]={0};
	b[0]=0;
	b[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++)
	{
		b[i]=min(abs(b[i-1]+abs(a[i-1]-a[i])),abs(b[i-2]+abs(a[i-2]-a[i])));
	}
	cout<<b[n-1];
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>            //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x) // also valid for set and multiset
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
//string binary = bitset<32>(n).to_string(); 
lli mod=1000000007;
int main()
{
 	ios::sync_with_stdio(0);
    cin.tie(0);
 lli n,m;
    cin>>n>>m;
    lli a[n+1];
    loop(i,0,n+1)a[i]=0;
    for(lli i=0;i<m;i++){
    	lli x;
    	cin>>x;
    	a[x]=-1;
    }
    if(a[1]==0)a[1]=1;else a[1]=-1;
    if(a[2]==-1);
    else{
    	if(a[1]==-1)a[2]=1;
    	else a[2]=2;
    }
    for(lli i=3;i<n+1;i++){
    	if(a[i]==-1)continue;
    	if(a[i-1]!=-1)a[i]=(a[i-1]+a[i])%mod;
    	if(a[i-2]!=-1)a[i]=(a[i-2]+a[i])%mod;
    	a[i]%=mod;
    	//cout<<i<<endl;
    }
    //for(lli i=1;i<=n;i++)cout<<a[i]<<" ";
    cout<<a[n]%mod;

	return 0;
}

Measured memory_bytes: 1024
N = int(input())
ans = [0]*N
if N > 3:
    n = int((N-3)**(0.5))+1
    nums = [i for i in range(1, n)]
    for x in range(1, n):
        for y in range(1, n):
            for z in range(1, n):
                i = x**2+y**2+z**2+x*y+x*z+y*z
                if i > N:
                    break
                else:
                    ans[i-1] += 1
for a in ans:
    print(a)

Measured memory_bytes: 9504
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
 
using namespace std;

int main() {
    long long X;

    cin >> X;

    long long y = 100;
    int sum = 0;

    while(X > y){
        y *= 1.01;

        sum++;
    }

    cout << sum << endl;

    return 0;
}


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

struct Node {
    int64_t value;
    int64_t prop_value;

    Node (int64_t _value, int64_t _prop_value) {
        value = _value;
        prop_value = _prop_value;
    }
};

struct Aint {
    int n;
    vector<Node> tree;

    Aint(int _n) {
        n = _n;
        tree = vector<Node> (4 * (n + 1), Node(numeric_limits<int64_t> :: min() / 2, 0));
    }

    void propagate(int idx) {
        if (tree[idx].prop_value == 0)
            return;
        tree[idx].value += tree[idx].prop_value;
        for (int d = 0; d < 2; d += 1)
            if (2 * idx + d < (int) tree.size())
                tree[2 * idx + d].prop_value += tree[idx].prop_value;
        tree[idx].prop_value = 0;
    };

    int64_t getMax() {
        return tree[1].value;
    }

    void add(int node, int st, int dr, int left, int right, int64_t delta) {
        if (st >= left and dr <= right) {
            tree[node].prop_value += delta;
            propagate(node);
            return;
        }
        
        int mid = (st + dr) / 2;
        propagate(node);

        if (left <= mid)
            add(2 * node, st, mid, left, right, delta);
        if (right > mid)
            add(2 * node + 1, mid + 1, dr, left, right, delta);

        propagate(2 * node);
        propagate(2 * node + 1);
        tree[node].value = max(tree[2 * node].value, tree[2 * node + 1].value);
    }

    void update(int node, int st, int dr, int poz, int64_t new_value) {
        if (st == dr) {
            tree[node].value = new_value;
            return;
        }
        
        int mid = (st + dr) / 2;
        propagate(node);

        if (poz <= mid)
            update(2 * node, st, mid, poz, new_value);
        if (poz > mid)
            update(2 * node + 1, mid + 1, dr, poz, new_value);
        
        propagate(2 * node);
        propagate(2 * node + 1);
        tree[node].value = max(tree[2 * node].value, tree[2 * node + 1].value);
    }

    int get(int node, int st, int dr, int poz) {
        propagate(node);
        if (st == dr)
            return tree[node].value;
        int mid = (st + dr) / 2;
        if (poz <= mid)
            return get(2 * node, st, mid, poz);
        return get(2 * node + 1, mid + 1, dr, poz);
    }
};

int main() {
    ios_base :: sync_with_stdio(false);
    int n, m; cin >> n >> m;
    vector<int> x(m, 0), y(m, 0), cost(m, 0);
    
    vector<vector<int>> in(n + 1), out(n + 1);

    for (int i = 0; i < m; i += 1) {
        cin >> x[i] >> y[i] >> cost[i];
        in[x[i]].push_back(i);
        out[y[i]].push_back(i);
    }
    
    vector<int64_t> dp(n + 2, 0);
    
    Aint T(n + 2);
    T.update(1, 1, n + 1, 1, 0);
    
    for (int i = 2; i <= n + 1; i += 1) {
        for (int idx : in[i - 1]) {
            T.add(1, 1, n + 1, 1, x[idx], cost[idx]);
        }
        
        dp[i] = T.getMax();
        T.update(1, 1, n + 1, i, dp[i]);

        for (int idx : out[i - 1])
            T.add(1, 1, n + 1, 1, x[idx], -cost[idx]);   
    }

    cout << *max_element(dp.begin(), dp.end()) << "\n";
}

Measured memory_bytes: 38528
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int n = scan.nextInt();
			if (n == 0)
				return;
			int[] w = new int[n];
			for (int i = 0; i < n; i++)
				w[i] = scan.nextInt();
			int[][] dp = new int[n][n];
//			int count = 1;
			for (int j = 1; j < n; j++) {
				for (int i = 0; i + j < n; i++) {

//					for (int _i = 0; _i < n; _i++) for (int _j = 0; _j < n; _j++) dp[_i][_j] = 0;
//					dp[i][i + j] = count++;
//					int count2 = 1;

					// 区間(i + 1, i + j - 1)のブロックが全て落とされている場合，ブロック i とブロック i + j が落とせるか判定
//					System.out.println((dp[i + 1][i + j - 1]) + " == " + ((i + j) - i - 1));
					if (dp[i + 1][i + j - 1] == (i + j) - i - 1) {
						if (Math.abs(w[i] - w[i + j]) <= 1) {
							dp[i][i + j] = dp[i + 1][i + j - 1] + 2;
						}
					}
					for (int k = i; k < i + j; k++) {
//						dp[i][k] = dp[k + 1][i + j] = count2++;
						// 区間(i, k)と区間(k + 1, i + j)で落とされたブロックをマージする
						dp[i][i + j] = Math.max(dp[i][i + j], dp[i][k] + dp[k + 1][i + j]);
					}

//					for (int _i = 0; _i < n; _i++) {
//						for (int _j = 0; _j < n; _j++) System.out.print(dp[_i][_j] + " ");
//						System.out.println();
//					}
//					System.out.println();
				}
			}
//			for (int _i = 0; _i < n; _i++) {
//				for (int _j = 0; _j < n; _j++) System.out.print(dp[_i][_j] + " ");
//				System.out.println();
//			}
//			System.out.println();
			System.out.println(dp[0][n - 1]);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}



Measured memory_bytes: 57828
inp = input()
n = int(inp)

if  n < 105:
  print(0)
elif 105 <= n <135:
  print(1)
elif 135 <= n <165:
  print(2)
elif 165 <= n <189:
  print(3)
elif 189 <= n <195:
  print(4)
elif 195 <= n:
  print(5)

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#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()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n,k;cin>>n>>k;
    vin j(n+1);
    rep(i,n){
        int a;cin>>a;
        j[a]++;
    }
    sort(all(j),greater<int>());
    int sum=0;
    rep2(i,k,n+1){
        if(j[i]!=0)sum+=j[i];
        else break;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main() {
	// var a, b, c, d, e int
	// fmt.Scan(&a, &b, &c, &d, &e)
	ts := make([]int, 5)
	for i := 0; i < 5; i++ {
		fmt.Scan(&ts[i])
	}

	min := 10
	sum := 0
	for i := 0; i < 5; i++ {
		t := (ts[i] % 10)
		if t != 0 && t < min {
			min = t
		}
		if t == 0 {
			sum += ts[i]
		} else {
			sum += ts[i] + 10 - t
		}
	}
	sum = sum - (10 - min)

	fmt.Println(sum)
}


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

int main(int argc, char const *argv[])
{
	string s; cin >> s;
	if (s == "Sunny")
		cout << "Cloudy" << endl;
	else if (s == "Cloudy")
		cout << "Rainy" << endl;
	else
		cout << "Sunny" << endl;
	return 0;
}


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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll HIGHINF = (ll)1e18;
const ll LOWINF = (ll)1e15;
const long double PI = 3.1415926535897932384626433;

template<typename T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template<typename... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	int N,M; cin >> N >> M;
	map<ll,ll> mp;
	for(int i = 0; i < N; ++i){
		ll A; cin >> A;
		mp[A]++;
	}
	for(int i = 0; i < M; ++i){
		ll B,C; cin >> B >> C;
		mp[C] += B;
	}
	ll ans = 0;
	for(auto itr = mp.rbegin(); itr != mp.rend(); ++itr){
		ll val = (*itr).first;
		ll cnt = (*itr).second;
		if(N>=cnt){
			N -= cnt;
			ans += val*cnt;
		}
		else{
			ans += val*N;
			N = 0;
		}
		corner(N==0,ans);
	}
	

  
    return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int D,N;
  cin >> D >> N;
  if(D==0&&N!=100)
  {
    cout << N << endl;
  }
  else if(D==0&&N==100)
  {
    cout << 101 << endl;
  }
  else if(D==1&&N!=100)
  {
    cout << 100*N << endl;
  }
  else if(D==1&&N==100)
  {
    cout << 10100 << endl;
  }
  else if(D==2&&N!=100)
  {
    cout << 10000*N << endl;
  }
  else if(D==2&&N==100)
  {
    cout << 1010000 << endl;
  }
  return 0;
}


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

main() {
  int N; cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int k = upper_bound(A.begin(), A.end(), A[i]) - lower_bound(A.begin(), A.end(), A[i]);
    ans += k % 2;
    i += k - 1;
  }
  cout << ans << endl;
}


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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
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(a>b){a=b;return 1;}return 0;}
//end

struct UnionFind{
   vector<int> par; int n;
   UnionFind(){}
   UnionFind(int _n):par(_n,-1),n(_n){}
   int root(int x){return par[x]<0?x:par[x]=root(par[x]);}
   bool same(int x,int y){return root(x)==root(y);}
   int size(int x){return -par[root(x)];}
   bool unite(int x,int y){
      x=root(x),y=root(y); if(x==y)return false;
      if(size(x)>size(y))swap(x,y);
      par[y]+=par[x]; par[x]=y; n--; return true;
   }
};

int main(){
   int n,m; cin>>n>>m;
   UnionFind uni(n);
   rep(i,0,m){
      int x,y; cin>>x>>y; x--; y--;
      uni.unite(x,y);
   }
   int res=0;
   rep(i,0,n)chmax(res,uni.size(i));
   cout<<res<<endl;
   return 0;
}

Measured memory_bytes: 3988
#include<cstdio>
const int MAXN=100010;
int x[MAXN],y[MAXN],t[MAXN];
int main()
{
	int n,i,time=0,x0=0,y0=0,p;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d %d %d",&t[i],&x[i],&y[i]);
	for(i=1;i<=n;i++)
	{
		while(x0!=x[i]||y0!=y[i])
		{
			if(x[i]>x0)
			{
				x0+=1;
				time++;
			}
			if(x[i]<x0)
			{
				x0-=1;
				time++;
			}
			if(y[i]>y0)
			{
				y0+=1;
				time++;
			}
			if(y[i]<y0)
			{
				y0-=1;
				time++;
			}
		}
		p=0;
		if(x0==x[i]&&y0==y[i]&&time<t[i])
		{
			while(time<t[i])
			{
				p++;
				if(p%2!=0)
				{
					y0-=1;
					time++;
				}
				else
				{
					y0+=1;
					time++;
				}
			}
		}
		if(x0!=x[i]||y0!=y[i]||time>t[i])
			{
				printf("No\n");
				return 0;
			}
	}
	printf("Yes\n");
	return 0;
}


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

#define int long long
const int INF = 1e9;

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

  vector<char> c(2*N);
  vector<int> a(2*N);
  vector<int> wp(N), bp(N);
  for ( int i = 0; i < N*2; i++ ) {
    cin >> c[i] >> a[i];
    a[i]--;
    if ( c[i] == 'W' ) wp[a[i]] = i;
    else bp[a[i]] = i;
  }

  vector<vector<int> >
    ww(N+1, vector<int>(N+1, 0)),
    wb(N+1, vector<int>(N+1, 0)),
    bb(N+1, vector<int>(N+1, 0)),
    bw(N+1, vector<int>(N+1, 0));
  for ( int i = 0; i < N; i++ ) {
    for ( int j = 0; j < N; j++ ) {
      ww[i][j+1] = ww[i][j]+(wp[i]<wp[j]);
      wb[i][j+1] = wb[i][j]+(wp[i]<bp[j]);
      bb[i][j+1] = bb[i][j]+(bp[i]<bp[j]);
      bw[i][j+1] = bw[i][j]+(bp[i]<wp[j]);
    }
}

  vector<vector<int> > dp(N+1, vector<int>(N+1, INF));
  dp[0][0] = 0;
  for ( int i = 0; i < N+1; i++ ) {
    for ( int j = 0; j < N+1; j++ ) {
      if ( i < N ) dp[i+1][j] = min(dp[i+1][j], dp[i][j]+ww[i][i]+wb[i][j]);
      if ( j < N ) dp[i][j+1] = min(dp[i][j+1], dp[i][j]+bb[j][j]+bw[j][i]);
    }
  }

  cout << dp[N][N] << endl;
  
  return 0;
}


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

typedef long long int ll;
int main(){
    string S;
    cin >> S;
    int N = S.size();
    int R = 0,B = 0;
    for(int i = 0;i < N;i++){
        if(S[i] == '1'){
            B++;
        }else{
            R++;
        }
    }
    cout << min(R,B) * 2 << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
int string_length(string);
int main()
{
	string S;
	cin >> S;
	for (int i = 0; i < string_length(S); i++)
	{
		cout << "x";
	}
}
int string_length(string x)
{
	int conter = 0;
	for (int i = 0; i < 100; i++)
	{
		if (x[i] != NULL)
		{
			conter++;
		}
		else
		{
			break;
		}
	}
	return conter;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int q;
    cin>>q;
    priority_queue<int> q1;
    priority_queue<int,vector<int>,greater<int>> q2;
    ll sum1=0,sum2=0;
    for(int i=0;i<q;i++){
        int id;
        cin>>id;
        if(id==1){
            int a,b;
            cin>>a>>b;
            int l=a,r=a;
            if(q1.size()){
                l=q1.top();
                r=q2.top();
            }
            if(a<=l){
                q1.push(a);
                q1.push(a);
                int tmp=q1.top();
                q1.pop();
                q2.push(tmp);
            }else{
                q2.push(a);
                q2.push(a);
                int tmp=q2.top();
                q2.pop();
                q1.push(tmp);
            }
            if(!(l<=a&&a<=r)){
                sum1+=min(abs(a-l),abs(a-r));
            }
            sum2+=b;
        }else{
            cout<<q1.top()<<" "<<sum1+sum2<<endl;
        }
    }
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<ll,int> P;
typedef pair<ll,P> PP;

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

int n;
int l,r,mid;
string L,R,M;

string ask(int i) {
	cout<<i<<endl;
	string res;cin>>res;
	return res;
}

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

	cin>>n;
	l=0,r=n-1;
	L=ask(l);
	if(L=="Vacant") return 0;
	R=ask(r);
	if(R=="Vacant") return 0;
	while(M!="Vacant") {
		mid=(r+l)/2;
		M=ask(mid);
		if(((mid-l)%2==0&&M==L)||((mid-l)%2==1&&M!=L)) l=mid,L=M;
		else r=mid,R=M;
		//cout<<"l,r "<<l<<' '<<r<<endl;
	}

	return 0;
}


Measured memory_bytes: 852
#include <iostream>
#include <algorithm>

using namespace std;

int n;
int *A, *B;

void countingSort(int *A, int *B, int k)
{
	int *C = new int[k + 1];
	for (int i = 0; i <= k; i++)
	{
		C[i] = 0;
	}
	for (int j = 1; j <= n; j++)
	{
		C[A[j]]++;
	}
	for (int i = 1; i <= k; i++)
	{
		C[i] = C[i] + C[i - 1];
	}
	for (int j = n; j >= 1; j--)
	{
		B[C[A[j]]] = A[j];
		C[A[j]]--;
	}
}

int main() {
	int maxAi = 0;
	cin >> n;
	A = new int[n + 1];
	for (int i = 1; i <= n; i++)
	{
		cin >> A[i];
		maxAi = max(maxAi, A[i]);
	}
	B = new int[n + 1];
	countingSort(A, B, maxAi);
	for (int i = 1; i <= n; i++)
	{
		cout << B[i];
		if (i == n)
		{
			cout << endl;
		}
		else
		{
			cout << " ";
		}
	}
	return 0;
}


Measured memory_bytes: 18764
#include <stdio.h>

int main(){
    int M,D,count=0;
    int i,k,j;
    scanf("%d%d",&M,&D);
    for(int i=4;i<M+1;i++){
        for(int j=22;j<D+1;j++){
            if(j%10==1){
                continue;
            }
            if(i==(j%10)*(j-j%10)/10){
                count++;
            }
        }
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep_a(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007
//#define long long ll


int main(){

 ll a,b,c;
 cin>>a>>b>>c;

  int maxi = max(max(a,b),c);

   if((3*maxi-a-b-c)%2 == 0)
    cout<<(3*maxi-a-b-c)/2<<endl;
   else
    cout<<(3*(maxi+1)-a-b-c)/2<<endl;

 return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <random>
using namespace std;
typedef long long int ll;

ll mod=1e9+7;
ll dp[2010][2010],sum[2010][2010];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,m; cin >> n >> m;
	vector<int> s(n),t(m);
	for(int i=0;i<n;i++){
		cin >> s[i];
	}
	for(int i=0;i<m;i++){
		cin >> t[i];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(i){
				(sum[i][j]+=sum[i-1][j])%=mod;
			}
			if(j){
				(sum[i][j]+=sum[i][j-1])%=mod;
			}
			if(i&&j){
				(sum[i][j]-=sum[i-1][j-1]-mod)%=mod;
				dp[i][j]+=sum[i-1][j-1];
			}
			dp[i][j]++;
			dp[i][j]%=mod;
			if(s[i]!=t[j])dp[i][j]=0;
			(sum[i][j]+=dp[i][j])%=mod;
		}
	}
	cout << (sum[n-1][m-1]+1)%mod << endl;
}

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

using ll = long long;
vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};

int h, w;

ll f(int i, int j, vector<vector<char>> &s, vector<vector<bool>> &used) {
  ll black = 0, white = 0;
  queue<pair<int, int>> q;
  q.push(make_pair(i, j));
  used.at(i).at(j) = true;
  if (s.at(i).at(j) == '#') black++;
  else white++;
  
  while (!q.empty()) {
    pair<int, int> p = q.front();
    q.pop();
    for (int i = 0; i < 4; i++) {
      if (p.first + dx[i] >= 0 && p.first + dx[i] < h
       && p.second + dy[i] >= 0 && p.second + dy[i] < w) {
        if (used.at(p.first + dx[i]).at(p.second + dy[i]) == false
         && s.at(p.first).at(p.second) != s.at(p.first + dx[i]).at(p.second + dy[i])) {
          used.at(p.first + dx[i]).at(p.second + dy[i]) = true;
          if (s.at(p.first + dx[i]).at(p.second + dy[i]) == '#') black++;
          else white++;
          q.push(make_pair(p.first + dx[i], p.second + dy[i]));
        }
      }
    }
  }
  
  return black * white;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  cin >> h >> w;
  
  vector<vector<char>> s(h, vector<char>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> s.at(i).at(j);
    }
  }
  
  ll ans = 0;
  vector<vector<bool>> used(h, vector<bool>(w, false));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (used.at(i).at(j) == false) ans += f(i, j, s, used);
    }
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

template<typename F>
struct FixPoint : F{
  FixPoint(F&& f):F(forward<F>(f)){}
  template<typename... Args>
  decltype(auto) operator()(Args&&... args) const{
    return F::operator()(*this,forward<Args>(args)...);
  }
};
template<typename F>
inline decltype(auto) MFP(F&& f){
  return FixPoint<F>{forward<F>(f)};
}

__int128_t abs128(__int128_t val){return val<0?-val:val;}

ostream &operator<<(ostream &os,__int128_t val){
  if(ostream::sentry(os)){
    __uint128_t tmp=abs128(val);
    char buf[64];
    char *d=end(buf);
    do{
      --d;
      *d=char(tmp%10+'0');
      tmp/=10;
    }while(tmp);
    if(val<0) *--d='-';
    int len=end(buf)-d;
    if(os.rdbuf()->sputn(d,len)!=len){
      os.setstate(ios_base::badbit);
    }
  }
  return os;
}

istream &operator>>(istream &is,__int128_t &val){
  string s;
  is>>s;
  val=0;
  for(int i=0;i<(int)s.size();i++)
    if(isdigit(s[i])) val=val*10+s[i]-'0';
  if(s[0]=='-') val*=-1;
  return is;
}

//INSERT ABOVE HERE
signed main(){
  using ll = __int128_t;

  ll d;
  cin>>d;
  const ll MAX = 37;
  ll ans=0;

  vector<ll> po(MAX,1);
  for(int i=0;i+1<MAX;i++)
    po[i+1]=po[i]*10;

  vector<ll> c1(12,0),c2(12,0);
  for(int i=1;i<10;i++)
    for(int j=1;j<=i;j++)
      c1[abs(i-j)]++;

  for(int i=0;i<10;i++)
    for(int j=0;j<=i;j++)
      c2[abs(i-j)]++;

  for(int l=2;l<=MAX;l++){
    // [s, t]
    ans+=
      MFP([&](auto dfs,ll s,ll t,ll w)->ll{
            if(s>=t){
              if(w!=0) return 0;
              return s==t?10:1;
            }
            ll dif=po[t]-po[s];
            ll x=w/dif;
            if(x>=10) return 0;

            ll res=0;
            res+=(s==0?c1:c2)[x+0]*dfs(s+1,t-1,abs128(w-(x+0)*dif));
            res+=(s==0?c1:c2)[x+1]*dfs(s+1,t-1,abs128(w-(x+1)*dif));
            return res;
          })(0,l-1,d);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
def fib n
  dp = Array.new(n + 1)
  0.upto(n) do |i|
    dp[i] = if i == 0 || i == 1
              1
            else
              dp[i - 1] + dp[i - 2]
            end
  end
  dp[n]
end

n = gets.chomp.to_i
puts fib(n)


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

int main() {
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int time1, time2;
  time1 = h1 * 60 + m1;
  if (h1 > h2)
    time2 = h2 * 60 + m2 + 1440;
  else
    time2 = h2 * 60 + m2;
  
  int x = time2 -time1 - k;
  
  cout << x << endl;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in) ;
		// (500,100,50)=(A,B,C)
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		sc.close();
		int ans =0;


		for (int i=0; i<=A; i++) {
			for(int j=0; j<=B; j++){
				for (int k=0;k<=C; k++){
					if (500*i+100*j+50*k==X) {
						ans ++;
					}
				}
			}
		}
		System.out.println(ans);



	}
}


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

int INF = 1e10;

int main(){
  int H, N;
  vector<int> A(1010, 0), B(1010, 0);

  cin >> H >> N;
  for(int i=1; i<=N; i++){
    cin >> A[i] >> B[i];
  }

  // dp[i][j]: i番目の魔法までで体力jの敵を倒すときの最小値
  vector<vector<int>> dp(1010, vector<int>(10010, 0));

  dp[0][0] = 0;
  for(int i=1; i<=H; i++) dp[0][i] = INF;


  for(int i=1; i<=N; i++){
    for(int j=0; j<=H; j++){
      dp[i][j] = dp[i-1][j];
      dp[i][j] = min(dp[i][j], dp[i][max(j-A[i], 0)]+B[i]);
      //cout << dp[i][j] << " ";
    }
    //cout << endl;
  }

  cout << dp[N][H] << endl;
}
  
  

Measured memory_bytes: 39808
lines = []
while true
  line = STDIN.gets
  if line == nil then
    break
  end
  lines << line
end

line = lines.join ("")
# puts line

element = line.downcase.chars.group_by{
  |item| item.chr
}

# p element

for c in "a".."z" do
  output = 0
  if element[c] != nil then
    output = element[c].length
  end
  puts "#{c} : #{output}"
end

Measured memory_bytes: 6092
#include<stdio.h>
#define N 100
#define INF 100000000
#define A 0
#define B 1
#define C 2

int a,T[N][N];

int k(){
  int i,b,c=0,d;
  int e[N],f[N],g[N];

  for(i=0;i<a;i++){
    e[i]=INF;
    f[i]=-1;
    g[i]=A;
  }

  e[0]=0;

  while(1){
    d=INF;
    b=-1;
    for(i=0;i<a;i++){
      if(d>e[i] && g[i]!=B){
	b=i;
	d=e[i];
      }
    }
    if(b==-1)break;
    g[b]=B;

    for(i=0;i<a;i++){
      if(g[i]!=B&&T[b][i]!=INF){
	if(e[i]>T[b][i]){
	  e[i]=T[b][i];
	  f[i]=b;
	  g[i]=C;
	}
      }
    }
  }
  for(i=0;i<a;i++){
    if(f[i]!=-1)c+=T[i][f[i]];
		  }
  return c;
}

int main(){
  int i,j,b;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    for(j=0;j<a;j++){
      scanf("%d",&b);
      T[i][j]=(b==-1)?INF :b;
    }
  }
  printf("%d\n",k());
  return 0;
}
  



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

int		main()
{
	int N; cin >> N;
	int res = 0;
	unordered_map<string, int> m;
	for (int i = 0; i < N; i++)
	{
		string s; cin >> s;
		if (m[s] == 0)
		{
			res++;
		}
		m[s]++;
	}
	cout << res << endl;
}



Measured memory_bytes: 17612
# from math import factorial,sqrt,ceil
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# strlist = "abcdefghijklmnopqrstuvwxyz"
n,m,c = map(int,input().split())
B = np.array(input().split(),dtype=np.int64)
times = n
table = []
for _ in range(times):
    table.append(list(map(int,input().split()))) # 行列の場合
A = np.array(table)

lis = np.dot(A,B) +c
anslis = np.bincount(lis > 0,minlength=2)
ans = anslis[1]

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 12504