akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
int main( ) {
    
       int NumberOfElements;
       int readScan = scanf("%d ", &NumberOfElements);
      
       if(readScan != 1)
    {
        printf("data format error!");
        return(EXIT_FAILURE);
    }
   
      
        int array[NumberOfElements];

        for( int ix=0; ix < NumberOfElements; ix++ )
       {
            int readScan = scanf("%d", &array[ix]);
            if(readScan != 1)
            {
                 printf("data format error!");
                 exit;
            }
            if(ix<NumberOfElements-1)
                  printf("%d ", array[ix]);
            if(ix==NumberOfElements-1)
                  printf("%d", array[ix]);
        }
        printf("\n");

        if(NumberOfElements > 100 || NumberOfElements <1)
            return(EXIT_FAILURE);
      
        int key;
        
        for(int i = 1; i< NumberOfElements; i++)
        {
            key = array[i];
            int j = i - 1;
            while( j >= 0 && array[j] > key)
            {
                array[j+1] = array[j];
                j--;
            }     
             array[j+1] = key;
         
             for(int k=0; k<NumberOfElements; k++)
            {
                 if(k<NumberOfElements-1)
                  printf("%d ", array[k]);
                 if(k==NumberOfElements-1)
                  printf("%d", array[k]);
            }
            printf("\n");
        }
        
    return (EXIT_SUCCESS);
}






Measured memory_bytes: 2072
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int n;
  cin>>n;
  int INF = n;
  vector<vecint> m(n, vecint(n, INF));
  for(auto&& i:irange(0,n)) {
    string s;
    cin>>s;
    for(auto&& j:irange(0,n)) {
      if(s[j]=='1') m[i][j] = 1;
    }
  }
  for(auto&& k:irange(0,n)) {
    for(auto&& i:irange(0,n)) {
      for(auto&& j:irange(0,n)) {
        m[i][j] = min(m[i][j], m[i][k] + m[k][j]);
      }
    }
  }
  bool ok = true;
  int mx = 0;
  for(auto&& i:irange(0,n)) {
    for(auto&& j:irange(0,i)) {
      if (m[i][j] == 1) {
        if ((m[i][0] + m[j][0]) % 2 == 0) ok = false;
      }
      mx = max(mx, m[i][j]);
    }
  }
  if (ok) {
    cout<<mx+1<<endl;
  } else {
    cout<<-1<<endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
const int N = 100100;
const int MOD = 1e9 + 7;
int main()
{
	int n, i;
	vector<int> x;
	int have[N] = { 0 };
	ll pos = -1;
	scanf("%d", &n);
	for (i = 1; i <= n + 1; i++)
	{
		int t;
		scanf("%d", &t);
		if (have[t] != 0)
		{
			pos = n - i + have[t];
			break;
		}
		have[t] = i;
	}

	// fast binomial coefficient
	ll bin[N] = { 0 };
	bin[1] = 1;
	for (auto len = 2; len <= n + 1; len++)
		bin[len] = MOD - (MOD / len)*bin[MOD%len] % MOD;
	printf("%d\n", n);
	ll cur = n + 1, tmp = 1, total = n + 1;
	for (i = 1; i <= n; i++)
	{
		cur = (((cur*(total - i)) % MOD) * bin[i + 1]) % MOD;
		if (i > pos)
			tmp = 0;
		else
			tmp = (((tmp*(pos - i + 1)) % MOD)*bin[i]) % MOD;
		printf("%d\n", (cur - tmp + MOD) % MOD);
		//printf("cur=%d pos=%d\n", cur, pos);
	}
	return 0;
}

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

void print(int a[],int size){
    for(int i = 0; i < size; ++i){
        cout << a[i] << " ";
    }
    cout << endl;
}

int c = 0,cp = 0,cq = 0;

void per(int p[],int q[],int s[],int a[],bool z[],int pos,int size){
    if(size == pos){
        //print(a,size);
        c++;
        bool f = true;
        for(int i = 0; i < size; ++i){
            if(p[i] != a[i])f = false;
        }
        if(f){cp = c;/*cout << "p";cout << cp << "p" << endl;*/}
        f = true;
        for(int i = 0; i < size; ++i){
            if(q[i] != a[i])f = false;
        }
        if(f){cq = c;/*cout << "q";cout << cq << "q" << endl;*/}
        return ;
    }else{
        for(int i = 0; i < size; ++i){
            if(z[i] == false){
                a[pos] = s[i];
                z[i] = true;
                per(p,q,s,a,z,pos + 1,size);
                z[i] = false;
            }
        }
    }
}


int main(){
    const int N = 8;
    int a[N] = {};
    bool z[N] = {};

    int n;
    cin >> n;

    int p[N] = {},q[N] = {},s[N] = {};

    for(int i = 0; i < n; ++i){
        cin >> p[i];
        s[i] = p[i];
    }
    for(int i = 0; i < n; ++i)cin >> q[i];

    sort(s,s+n);

    per(p,q,s,a,z,0,n);

    cout << abs(cq - cp) << endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin >>a>>b;
    int A=0;
    int x;
    x=(b-a);
    
    for (int i=1;i<=x;i++){
        A+=i;
    }
    cout << A-b <<endl;
}


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

int main(){
  int N;
  cin >> N;
  vector<long long> S(N);
  for(int i = 0; i < N; ++i) cin >> S[i];
  long long ans = 0;
  for(int i = 1; i < N; ++i){
    vector<long long> A(1,0), B(1,0);
    int r = (N-1)%i;
    //if(not r) continue;
    for(int j = 0; j <= (N-1)/i; ++j){
      A.push_back(S[j*i]);
      B.push_back(S[j*i+r]);
    }
    for(size_t i = 1; i < A.size(); ++i) A[i] += A[i-1], B[i] += B[i-1];
    int M = A.size();
    // if(not r){
    //   continue;
    //   for(int j = 1; j < M; ++j){
    //     long long a = i*j+r, b = a - i;
    //     if(a <= b) continue;
    //     if(b <= 0) continue;
    //     long long s = A[M-j];
    //     cerr << a << "!" << b << "!" << s << endl;
    //     ans = max(ans,s);
    //   }
    //   continue;
    // }
    for(int j = 0; j < M; ++j){
      long long a = i*j+r, b = a - i;
      if(a <= b) continue;
      if(b <= 0) continue;
      if(r == 0 and (a/i-1)*i+a < N-1) continue;
      long long s = A[M-j-1] + B.back() - B[j];
      //cerr << a << " " << b << " " << s << endl;
      ans = max(ans,s);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 2924
#include<stdio.h>
int main()
{
    int N,a,b,c,d,e,f,g,h,i,j;
    scanf("%d",&N);
    if(N%1000==0){

        printf("0\n");
    }
    else if(N<1000){
        j=1000-N;
         printf("%d\n",j);
    }

    else if(N>1000 && N<2000)
    {
        a=2000-N;
        printf("%d\n",a);
    }

    else if(N>2000 && N<3000)
    {
        b=3000-N;
        printf("%d\n",b);
    }

    else if(N>3000 && N<4000)
    {
        c=4000-N;
         printf("%d\n",c);
    }

    else if(N>4000 && N<5000)
    {
        d=5000-N;
         printf("%d\n",d);
    }

    else if(N>5000 && N<6000)
    {
        e=6000-N;
        printf("%d\n",e);
    }

    else if(N>6000 && N<7000)
    {
        f=7000-N;
          printf("%d\n",f);
    }

    else if(N>7000 && N<8000)
    {
        g=8000-N;
        printf("%d\n",g);
    }

    else if(N>8000 && N<9000)
    {
        h=9000-N;
        printf("%d\n",h);
    }

    else if(N>9000 && N<10000)
    {
        i=10000-N;
         printf("%d\n",i);

    }

    return 0;




}


Measured memory_bytes: 1736
#include <cstdio>
#include <vector>


#define maxn 120000
#define ll long long


int main()
{

    int n;
    int x;
    int s = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &x);
        while (x % 2 == 0)
        {
            s++;
            x = x / 2;
        }
    }
    printf("%d", s);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<string,string> Pstring;
typedef pair<double,double> Pdouble;


#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define Precision13 cout << fixed << setprecision(13)
const double PI=3.14159265358979323846;
const int MAX = 510000;
const int MOD = 1000000007;
const int INF = 1<<29;
using Graph = vector<vector<int>>;


int main()
{
  ll a,v,b,w,t;
  cin >> a >> v >> b >> w >> t;

  if(w>=v){
    cout << "NO" << endl;
    return 0;
  }

  double kyori = abs(a-b);
  double sokudo = abs(v-w);

  double tsuka = kyori/sokudo;

  if(tsuka<=t){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

  
  
}


Measured memory_bytes: 3636
def ifif(s):
  if s:print("Yes")
  else:print("No")
u=1
s=input()
for k in range(len(s)):
  if s[k]=="L" and k%2==0:
    u=0
  elif s[k]=="R" and k%2==1:
    u=0

ifif(u)

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n,a,b,c,x;
int y[111];

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>n>>a>>b>>c>>x;
		if(n==0)break;
		rep(i,n)cin>>y[i];
		int cnt=0,i=0;
		while(cnt<=10000){
			if(x==y[i])i++;
			if(i==n)break;
			x=(a*x+b)%c;
			cnt++;
		}
		if(cnt>10000)cout<<-1<<endl;
		else cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define int ll
typedef pair<int, int> pii;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
constexpr int INF = 1e9;
constexpr int MOD = 1e9+7;

signed main() {
    ios::sync_with_stdio(false);cin.tie(0);
    string s;
    cin >> s;

    int ans = 10000;
    REP(i,s.size()-2) {
        string x = s.substr(i, 3);
        int num = stoi(x);
        int sub = abs(num-753);
        ans = min(ans, sub);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
a,b,c,x,y = gets.split.map(&:to_i)

ans = 0
if a + b > c * 2
    m = [x,y].min
    ans += c * 2 * m
    x -= m
    y -= m
end

if x > 0 && a > c * 2
    ans += c * 2 * x
    y -= x
    x = 0
end

if y > 0 && b > c * 2
    ans += c * 2 * y
    x -= y
    y = 0
end

puts ans + a * [x,0].max + b * [y,0].max

Measured memory_bytes: 1916
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>
#include <random>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

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

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

random_device seed_gen;
mt19937 engine(seed_gen());
// 0, 1, 2 のどれかが得られる一様分布
// uniform_int_distribution<> dist(0, 2);
// cout << dist(engine) << endl;
// みたいに、先に確率分布を宣言して、そこにengineを与えて使う。

// =========ここまでテンプレ============

int main()
{
    ll d, t, s;
    cin >> d >> t >> s;
    if (s * t >= d)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3128
#include <iostream>
#include <string>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
static int const max_size = 100;

int main()
{
	int X, A, B; cin >> X >> A >> B;
	int b = (X - A) / B;
	cout << X - A - B * b << endl;
	return 0;
}

Measured memory_bytes: 764
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]

card_min = 0
card_max = N
ans = N
#print(card_min, card_max)
for l, r in LR:
    if l > card_min:
        card_min = l
    if r < card_max:
        card_max = r
    #print(card_min, card_max)
    ans = card_max - card_min + 1
    if ans <= 0:
        ans = 0
        break
print(ans)

Measured memory_bytes: 59992
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <stack>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-6
#define inf LLONG_MAX
using namespace std;

int main() {
	speed;
	int n;
	string s;
	cin >> n >> s;
	if (n < 3200)
		cout << "red";
	else
		cout << s;
}

Measured memory_bytes: 256
def F(a, b):
    # def _(n):
    #     c = 0
    #     while n:
    #         n //= 10
    #         c += 1
    #     return c

    # return _(max(a, b))
    return len(str(max(a, b)))


N = int(input())
ans = float('inf')
n = int(N**0.5) + 1
for a in range(1, n):
    b = N // a
    if b != N / a:
        continue
    ans = min(ans, F(a, b))
print(ans)


Measured memory_bytes: 2940
// 基本テンプレート (縮小版)

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
typedef pair<int, int> pii;
typedef long long ll;
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, M;
map<pii, int> id;
vector<int> stations[100010];
vector<pii> G[600010];
int dist[600010];
int cnt = 0;

int getId(int p, int a) {
    pii pr = make_pair(p, a);
    if(id.count(pr)) return id[pr];
    else return id[pr] = cnt++;
}

signed main() {
    cin >> N >> M;
    rep(i,0,M) {
        int p, q, c; cin >> p >> q >> c;
        p--; q--;
        int u = getId(p, c), v = getId(q, c);
        G[u].push_back(make_pair(v, 0));
        G[v].push_back(make_pair(u, 0));
        stations[p].push_back(c);
        stations[q].push_back(c);
    }
    rep(i,0,N) {
        rep(j,0,stations[i].size()) {
            int cmp = stations[i][j];
            int u = getId(i, cmp), v = getId(i, 0);
            G[u].push_back(make_pair(v, 0));
            G[v].push_back(make_pair(u, 1));
        }
    }

    rep(i,0,600010) dist[i] = INF;
    int init = getId(0, 0), goal = getId(N-1, 0);
    priority_queue< pii, vector<pii>, greater<pii> > q;
    dist[init] = 0;
    q.push(make_pair(0, init));
    while(!q.empty()) {
        pii t = q.top();
        q.pop();
        int cur = t.second, cost = dist[cur];
        for(auto to : G[cur]) {
            if(dist[to.first] > dist[cur] + to.second) {
                dist[to.first] = dist[cur] + to.second;
                q.push(make_pair(dist[to.first], to.first));
            }
        }
    }
    cout << (dist[goal] == INF ? -1 : dist[goal]) << endl;
}

Measured memory_bytes: 93432
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<int,int>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i,n) for (ll i=(ll)n-1;i>=0;i--)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}//最大公約数
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}//最小公倍数
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
const int MOD = 998244353;
inline ll mod_add(ll a,ll b){return (a+b)%MOD;}
inline ll mod_sub(ll a,ll b){return (a+MOD-b)%MOD;}
inline ll mod_mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
inline ll mod_pow(ll x,ll n,ll mod=(ll)MOD){ll res=1;while(n>0){
if(n&1)res=res*x%mod;
x=x*x%mod;n>>=1;}return res;}
inline ll mod_inv(ll x){return mod_pow(x,MOD-2);}
inline ll mod_div(ll a, ll b){return mod_mul(a,mod_inv(b));}
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back
ll n,a,b;
VI h;
bool isOK(ll times){
   VI x=h;
   rep(i,n){
      x[i]-=b*times;
   }
   rep(i,n){
      if(x[i]>0 && times>0){
         times-=(x[i]+a-b-1)/(a-b);
      }
      else if(x[i]>0){
         return false;
      }
   }
   if(times<0)return false;
   return true;
}
int main(){
   cin>>n>>a>>b;
   h.resize(n);
   rep(i,n)cin>>h[i];
ll left=0,right=1000000000;
   while(right-left>1){
      ll mid=left+(right-left)/2;
      if(isOK(mid)){
         right=mid;
      }
      else{
         left=mid;
      }
   }
   cout<<right<<endl;
}

Measured memory_bytes: 4776
#include <bits/stdc++.h>
#define RANGE(i,n) for(int i=0;i<n;i++)
typedef long long ll;
struct P{
    ll var1;
    ll var2;
};
bool operator< ( const P &one, const P &two){
    return one.var1 < two.var1;
};
bool operator> ( const P &one, const P &two){
    return one.var1 > two.var1;
};

using namespace std;

signed main() {
    int N, K;
    cin >> N >> K;
    vector<ll> p(N);
    RANGE(i,N){
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    ll sum = 0;
    RANGE(i,K){
        sum = sum + p[i];
    }
    cout << sum << endl;
}


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

int main(){
    
    // 1. 入力情報取得.
    int N;
    scanf("%d", &N);
    int L[N];
    for(int i = 0; i < N; i++) scanf("%d", &L[i]);
    
    // 2. sort.
    sort(L, L + N);
    
    // 3. 三角形をカウント.
    // ex.
    // 10
    // 1 2 2 3 3 3 4 4 4 4
    // -> 90 が正解のはず.
    // (234系)24 + (443, 442, 441系)36 + (433系)12 + (332, 331系)9 + (322系)3 + (221系)1 + (444系)4 + (333系)1 = 90
    LL ans = 0;
    int a = 0, b = 0, c = 0, minC = 0, maxC = 0, s = 0, e = 0;
    for(int i = 0; i < N - 2; i++){
        for(int j = i + 1; j < N - 1; j++){
            // 3-1. 棒の長さ a, b を 取得.
            a = L[i], b = L[j];
            
            // 3-2. 棒の長さ c を 取得.
            // minC = abs(a - b) + 1;    // 2重カウントとなってしまうので却下.
            // maxC = a + b - 1;         // lower_bound で取得するインデックスの都合から, 修正.
            // minC = max(a + 1, b + 1); // カウント漏れが発生するため却下.
            minC = b;
            maxC = a + b;
            
            // 3-3. c となり得る個数をカウント.
            s = lower_bound(L, L + N, minC) - L;
            e = lower_bound(L, L + N, maxC) - L;
            // printf("i=%d j=%d minC=%d s=%d maxC=%d e=%d\n", i, j, minC, s, maxC, e);
            s = max(s, j + 1); // 2重カウント回避.
            ans += (LL)(e - s);
        }
    }
    
    // 4. 出力 ～ 後処理.
    printf("%lld\n", ans);
    return 0;
    
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int N;
  int A[100000]={0};
  short nums[100000]={0};
  int i,j,k;
  const int mod=(int)1E9+7;

  scanf("%d",&N);

  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
    nums[A[i]]++;
  }
  
  for(i=0;i<N;i++){
    if(i%2==N%2 && nums[i]!=0){
      puts("0");
      return 0;
    }else if(i%2!=N%2 && ((i!=0 && nums[i]!=2) || (i==0 && nums[i]!=1))){
      puts("0");
      return 0;
    }
  }

  k=1;
  N/=2;
  for(i=0;i<N;i++){
    k*=2;
    k%=mod;
  }
  printf("%d\n",k);
  return 0;
}


Measured memory_bytes: 768
import java.util.Arrays;
import java.util.Scanner;

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

    void solve(Scanner sc) {
        int n = sc.nextInt();
        int k = sc.nextInt();
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            ans += Math.min(x, k - x) * 2;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using P = pair<lint, int>;

const lint INF = 1e18;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n, m, s, t; cin >> n >> m >> s >> t;
  s--; t--;
  struct edge { int to, y, s; };
  vector< vector<edge> > G(n, vector<edge>());
  for (int i = 0; i < m; i++) {
    int u, v, a, b; cin >> u >> v >> a >> b;
    u--; v--;
    G[u].push_back(edge{v, a, b});
    G[v].push_back(edge{u, a, b});
  }
  
  vector<lint> dy(n, INF), ds(n, INF);
  priority_queue<P, vector<P>, greater<P> > pq;
  dy[s] = 0;
  pq.push(P(0, s));
  while (not pq.empty()) {
    P p = pq.top(); pq.pop();
    int v = p.second;
    if (dy[v] < p.first) continue;
    for (auto&& e : G[v]) {
      if (dy[v] + e.y < dy[e.to]) {
        dy[e.to] = dy[v] + e.y;
        pq.push(P(dy[e.to], e.to));
      }
    }
  }

  ds[t] = 0;
  pq.push(P(0, t));
  while (not pq.empty()) {
    P p = pq.top(); pq.pop();
    int v = p.second;
    if (ds[v] < p.first) continue;
    for (auto&& e : G[v]) {
      if (ds[v] + e.s < ds[e.to]) {
        ds[e.to] = ds[v] + e.s;
        pq.push(P(ds[e.to], e.to));
      }
    }
  }

  vector<lint> res(n);
  const lint N = 1e15;
  for (int i = 0; i < n; i++) {
    res[i] = N - dy[i] - ds[i];
  }
  for (int i = n - 2; i >= 0; i--) {
    res[i] = max(res[i], res[i + 1]);
  }
  for (int i = 0; i < n; i++) {
    cout << res[i] << '\n';
  }
  return 0;
}

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

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

int main(){
int n;
cin>>n;
ll T,t[n];
cin>>T;
ll count=T;
cin>>t[0];
for(int i=1;i<n;i++){
cin>>t[i];
if(t[i]-t[i-1]>T){
count+=T;

}
else
{
  count+=t[i]-t[i-1];
}

}
cout<<count<<endl;



  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
using namespace std;
const int INT_MAX = 1e+7;

int main(){
	int m[5001];
	for(int i=0 ; i < 5001 ; i++ ){
		m[i] = INT_MAX;
	}
	for(int a=0 ; a < 20 ; a++ ){
		for(int b=0 ; b < 20 ; b++ ){
			for(int c=0 ; c < 20 ; c++ ){
				int cost = (a*380) - (a/5*380) + (b*550) - (b/4*330) + (c*850) - (c/3*306);
				int w = a*200 + b*300 + c*500;
				if( w <= 5000 ){
					m[w] = min( m[w] , cost );
				}
			}
		}
	}
	int n;
	while( cin >> n , n ){
		cout << m[n] << endl;
	}
}

Measured memory_bytes: 0
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N, M;
    cin >> N >> M;

    vector<ll> A(N);
    priority_queue<ll> pq;
    ll s=0;  // sum
    rep(i, N) {
        ll tmp;
        cin >> tmp;
        s += tmp;
        pq.push(tmp);
    }
    rep(i, M) {
        ll t = pq.top();
        s -= (t - t / 2);
        pq.pop();
        pq.push(t/2);
    }
    cout << s << endl;
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

template <typename T>
inline void read(T &x)
{
    T data = 0, f = 1;
    char ch = getchar();
    while (!isdigit(ch))
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (isdigit(ch))
    {
        data = (data << 3) + (data << 1) + ch - '0';
        ch = getchar();
    }
    x = f * data;
}

const int inf = 0x3f3f3f3f;
const double eps = 1e-8;
const int maxn = 1e5 + 9;
int m[109];
signed main()
{
    //freopen("in.txt","r",stdin);
    //freopen("data.txt","w",stdout);
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    //std::cout.tie(0);
    string s;
    cin >> s;
    ll t = 0;
    for (int i = 0; i < s.length(); ++i)
        t += s[i] - '0';
    if (t % 9)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    //fclose(stdin);
    //fclose(stdout);
    return 0;
}

Measured memory_bytes: 3720
from math import floor

# input process
inputData = input().split()
# A秒後
A = int(inputData[0])
# B枚ずつ
B = int(inputData[1])
# T+0.5秒後まで
T = int(inputData[2])

# calculation process
prodCount = int(floor((float(T) + 0.5) // float(A)))
biscuitTotal = prodCount * B

# output process
print(biscuitTotal)

Measured memory_bytes: 3060
def num(N, M):
    return min(N, M//2)

N, M = map(int, input().split())
if 2*N >= M:
    print(M//2)
else:
    a = (M - 2*N) // 4
    cand = []
    for i in range(a, a+4):
        cand.append(num(N+i, M-2*i))
    print(max(cand))


Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
#define MAX 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
bool isprime(int x){
    for(int i=2;i<x;i++){
        if(x%i==0)return 0;
    }
    return 1;
}

int main(){
    int n;cin>>n;
    while(!isprime(n))n++;
    cout<<n<<endl;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
const int nax=1e5+5;
int vis[nax]={0};
int p[nax]={0};
int d[nax];
vector<vector<int>> v(nax);
int lev[nax];
void dfs(int ci, int l1){
    vis[ci]=1;
    int l=0;
    lev[ci]=l1;
    for(auto x: v[ci]){
        if(vis[x]==1) continue;
        p[x]=ci;
        dfs(x,l1+1);
        l=max(l,d[x]);
    }
    d[ci]=l+1;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n;
    cin>>n;
    int u,v1;
    cin>>u>>v1;
    u--; v1--;
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        a--; b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    dfs(v1,0);
    int ans=0;
    if(u==v1){
        cout<<"0";
        return 0;
    }
    int t=u;
    int d1=lev[t];
    int d2=0;
    while(true){
        if(d1 <= d2) break;
        ans=max(ans,d1+d[t]-2);
        d1--;
        d2++;
        t=p[t];
    }
    cout<<ans;
}


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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define sfl(i,a,n) for (int i=a;i<n;i++)
#define ufl(i,a,n) for (int i=n-1;i>=a;i--)
#define SZ(x) ((int)(x).size())
#define endl '\n'
typedef long long ll;

ll power(ll a, ll b){
    ll res = 1;
    for(int i = 0; i<b; i++)
        res *= a;

    return res;
}

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}


int main()
{
    init();
    string s;
    cin>>s;
    int len = s.length();
    string ans="";
    sfl(i,0,len)
    {
        if(s[i]=='0'||s[i]=='1')
        {
            ans+=s[i];
        }
        else if(s[i]=='B'&&ans.size()!=0)
            ans.pop_back();
    }
    cout <<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, a, b, c, ans = 0;
    string s, t, res = "";
    cin >> s;
    if(s[0] == s[1] && s[1] == s[2]) cout << "Yes" << endl;
    else if(s[1] == s[2] && s[2] == s[3]) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int m;
    cin >>n>>m;
    int a=0;
    for(int i=0;i<m;i++){
        int x;
        cin>>x;
        a+=x;
    }
    if(a>n){
        cout<<-1;
    }
    else{
        cout<<n-a;
    }
}

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

int main(){
	char a[10];
	for(int i=1;i<=3;i++){
		scanf("%c",&a[i]);
	}
	int s=0;
	for(int i=1;i<=3;i++){
		if(a[i]=='1'){
			s++;
		}
	}
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int N,A[10],i,odd=0,even=0,total=1,kisu=1;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&A[i]);
		if(A[i]%2==0){
			even++;
			kisu=kisu*2;
		}else  odd++;
		total=total*3;
	}
	printf("%d\n",total-kisu);
	return 0;
}

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


int main(){
  int a,b;
  cin >> a >> b;
  int c =a+b; 
  if(c%3 ==0 || a%3 == 0 || b%3 == 0){
    cout <<"Possible" << endl;
  }
  else {
    cout <<"Impossible"<<endl;
  }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pi 3.1415926535897932384
#define mod 1000000007
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const ll inf=1e18 ;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    ll i,a,b,c,r,k,n,s1=0;
    cin>>s;
    n=s.size()+1;
    ll arr[n];
    c=0;
    memset(arr,-1,sizeof(arr));
    for(i=n-2;i>=0;i--)
    {
        if(s[i]=='<')
        {
            c=0;
            continue;
        }
        else
        {
            if(c==0)
                arr[i+1]=0,c++;
            arr[i]=c;
            c++;
        }
    }
    c=0;
   for(i=0;i<=n-2;i++)
   {
       if(s[i]=='>')
       {
           c=0;
           continue;
       }
       else
       {
           if(c==0)
            arr[i]=max(c,arr[i]),c++;
           arr[i+1]=max(arr[i+1],c);
           c++;
       }
   }
   for(i=0;i<n;i++)
   {
       s1=s1+arr[i];
   }
   cout<<s1<<endl;;
    //>>>>..cout<<accumulate(arr,arr+n,0)<<endl;
}


Measured memory_bytes: 4764
#include <iostream>
#include <string>

using namespace std;

void sringSearch(string , string );
void kmpSearch(string T, string P);

int main() {
    string T, P;
    cin >> T >> P;

    kmpSearch(T, P);

    return 0;
}

void sringSearch(string T, string P) {
    int k = T.length() - P.length() + 1;
    for (int i = 0; i < k; ++i) {
        if(T.substr(i, P.length()) == P) {
            cout << i << endl;
        }
    }
}

void kmpSearch(string T, string P){
    // construct dfs
    int dfa[P.length() + 1][256] = {0};
    int x = 0;
    dfa[0][P[0]] = 1;
    for (int i = 1; i < P.length(); ++i) {
        // mismatch case
        for (int j = 0; j < 256; ++j) {
            dfa[i][j] = dfa[x][j];
        }
        // match case
        dfa[i][P[i]] = i + 1;
        // restart state
        x = dfa[x][P[i]];
    }
    // final mismatch case
    for (int j = 0; j < 256; ++j) {
        dfa[P.length()][j] = dfa[x][j];
    }

    // search
    int s = 0;
    for (int k = 0; k < T.length(); ++k) {
        s = dfa[s][T[k]];
        if(s == P.length())
            cout << k - P.length() + 1 << endl;
    }
}



Measured memory_bytes: 14984
;;; Utils (quoted from https://competitive12.blogspot.com/2020/03/common-lisp.html)


;; Read fixnum

(declaim (ftype (function * (values fixnum &optional)) read-fixnum))
(defun read-fixnum (&optional (in *standard-input*))
  (declare (inline read-byte)
           #-swank (sb-kernel:ansi-stream in))
  (macrolet ((%read-byte ()
               `(the (unsigned-byte 8)
                     #+swank (char-code (read-char in nil #\Nul))
                     #-swank (read-byte in nil 0))))
    (let* ((minus nil)
           (result (loop (let ((byte (%read-byte)))
                           (cond ((<= 48 byte 57)
                                  (return (- byte 48)))
                                 ((zerop byte) ; #\Nul
                                  (error "Read EOF or #\Nul."))
                                 ((= byte #.(char-code #\-))
                                  (setq minus t)))))))
      (declare ((integer 0 #.most-positive-fixnum) result))
      (loop
        (let* ((byte (%read-byte)))
          (if (<= 48 byte 57)
              (setq result (+ (- byte 48) (the (integer 0 #.(floor most-positive-fixnum 10)) (* result 10))))
              (return (if minus (- result) result))))))))

;; fast read-line

(defmacro buffered-read-line (&optional (buffer-size 30) (in '*standard-input*) (term-char #\Space))
  (let ((buffer (gensym))
        (character (gensym))
        (idx (gensym)))
    `(let* ((,buffer (load-time-value (make-string ,buffer-size :element-type 'base-char))))
       (declare (simple-base-string ,buffer)
                (inline read-byte))
       (loop for ,character of-type base-char =
             ,(if (member :swank *features*)
                  `(read-char ,in nil #\Newline) ; on SLIME
                `(code-char (read-byte ,in nil #.(char-code #\Newline))))
             for ,idx from 0
             until (char= ,character #\Newline)
             do (setf (schar ,buffer ,idx) ,character)
             finally (when (< ,idx ,buffer-size)
                       (setf (schar ,buffer ,idx) ,term-char))
             (return (values ,buffer ,idx))))))


;;; invoke child process

#-swank
(unless (member :child-sbcl *features*)
  (quit
    :unix-status
    (process-exit-code
      (run-program *runtime-pathname*
                   `("--control-stack-size" "128MB"
                     "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                     "--eval" "(push :child-sbcl *features*)"
                     "--script" ,(namestring *load-pathname*))
                                                                 :output t :error t :input t))))



;-------------------
; Write code here
;-------------------



(defun solve (n p a)
  (let ((a-odd (count-if #'oddp a))
        (a-even (count-if #'evenp a)))
    (if (zerop a-odd)
        (if (zerop p)
            (expt 2 n)
            0)
        (expt 2 (1- n)))))

(defun main ()
  (let ((n (read))
        (p (read))
        (a (read-from-string (concatenate 'string "(" (read-line)")"))))
    (princ (solve n p a))
    (fresh-line)))

(main)


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

string strrev(string a){
	string ans = "";
	for(int i=a.size()-1;i>=0;i--){
		ans += a[i];
	}
	return ans;
}
int main(){
	string s,t;
	cin>>s>>t;
	int n = s.size();
	int m = t.size();
	int dp[n+1][m+1];
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			dp[i][j] = 0;
		}
	}
	string ans="";
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			if(i == 0 || j == 0){
				dp[i][j] = 0;
			}
			else if(s[i-1] == t[j-1]){
				dp[i][j] = dp[i-1][j-1] + 1;
			}
			else{
				dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	// cout<<dp[n][m]<<endl;
	int i=n,j=m;
	while(i>0 && j>0){
		// cout<<dp[i-1][j]<<" "<<dp[i][j-1]<<endl;
		if(s[i-1]==t[j-1]){
			ans += s[i-1];
			i--,j--;
		}
		else if(dp[i-1][j] > dp[i][j-1]){
			i--;
		}
		else{
			j--;
		}
		// cout<<ans<<endl;
	}
	ans = ans.substr(0,dp[n][m]);
	ans = strrev(ans);
	cout<<ans<<endl;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
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<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main(){
    gearup;
    ll n;cin >> n;
    vl a(n);
    rep(i,n)cin>>a[i];
    sort(rall(a));
    queue<int> q;
    int j = 0;
    while(j+1<n){
        if(a[j] == a[j+1]){
            q.push(a[j]);
            j+=2;
        }
        else{
            j++;
        }
    }
    ll res = 0;
    if(q.size() >= 2){
        ll a = q.front();q.pop();
        ll b = q.front();q.pop();
        res = a*b;
    }
    out(res);
}



Measured memory_bytes: 1280
#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <map>
#include <random>
#include <string>
#include<vector>

using namespace std;

int main() {

	int n;
	map<string, int> m;
	string tmp;
	int cnt=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		m[tmp] ++;
		if (m[tmp] == 1) {
			cnt++;
		}
	}
	cout << cnt;


	return 0;
}

Measured memory_bytes: 18736
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  ll n;
  cin >> n;
  vector<ll> A(n);
  loop(i,0,n) cin >> A[i];
  set<ll> S;
  for (auto &&a: A) {
    if (S.count(a)) {
      S.erase(a);
    } else {
      S.insert(a);
    }
  }
  cout << S.size() << endl;
  return 0;
}


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

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

	int n;
	while(cin >> n) {
		int ans = 0;
		for (int a = 0; a < 10; a++) {
			for (int b = 0; b < 10; b++) {
				for (int c = 0; c < 10; c++) {
					for (int d = 0; d < 10; d++) {
						if(a + b + c + d == n) ans++;
					}
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define IOS ios::sync_with_stdio(0);
signed main()
{
	int a,b;
	while(cin>>a>>b)
	{
		cout<<a*(a-1)/2+b*(b-1)/2<<"\n"; 
	}
 } 

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

int main() {
  int A; cin >>A;
  int ans = A;
  cin >> A;
  ans += A;
  cin >> A;
  ans += A;
  if (ans >= 22) cout << "bust" << endl;
  else cout << "win" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    int a, b, c, k;
    cin >> a >> b >> c >> k;

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

    cout << nmax*pow(2, k) + a + b + c - nmax<< endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); ++i)
#define all(v) v.begin(), v.end()
#define mp make_pair
#define INF 1e9

void init()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
}

int main()
{
    init();
    int x;
    cin >> x;
    if (400 <=  x && x <= 599)
        cout << 8 << endl;
    if (600 <=  x && x <= 799)
        cout << 7 << endl;
    if (800 <=  x && x <= 999)
        cout << 6 << endl;
    if (1000 <=  x && x <= 1199)
        cout << 5 << endl;
    if (1200 <=  x && x <= 1399)
        cout << 4 << endl;
    if (1400 <= x && x <= 1599)
        cout << 3 << endl;
    if (1600 <= x && x <= 1799)
        cout << 2 << endl;
    if (1800 <= x && x <= 1999)
        cout << 1 << endl;
}


Measured memory_bytes: 3640
"use strict";

const fs = require("fs");

const lines = fs.readFileSync(0).toString().split("\n");
const data = lines[0].split(" ").map(x => Number(x));
const n = data[0];
const length = data[1];
const strs = lines.slice(1, 1 + n).map(s => s.substring(0, length));
process.stdout.write(strs.sort().join("") + "\n");


Measured memory_bytes: 7500
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ull INF = 8001001001001001001LL;
const ll MOD = 1000000007LL;

int N, K;
int w[100010], d[100010];

bool solve(ull x) {
    // x 以下に K 個以上植えられたら true
    ull sum = 0;
    rep(i,0,N) {
        if(x < (ull)w[i]) continue;
        else {
            ull y = (ull)x - w[i];
            sum += y / d[i] + 1;
        }
    }
    return sum >= (ull)K;
}

signed main() {
    cin >> N >> K;
    rep(i,0,N) {
        cin >> w[i] >> d[i];
    }

    ull ub = INF, lb = 0;
    while(ub - lb > 1) {
        ull mid = (ub + lb) / 2;
        if(solve(mid)) ub = mid;
        else lb = mid;
    }
    cout << ub << endl;
    return 0;
}

Measured memory_bytes: 1792
import numpy as np

N, K = map(int, input().split())
A = np.array(input().split(), np.int64)
F = np.array(input().split(), np.int64)
A.sort()
F.sort()
F = F[::-1]

l = 0
r = (A * F).max()

while l < r:
    m = (l + r) // 2
    if np.maximum(A - m // F, 0).sum() <= K:
        r = m
    else:
        l = m + 1

print(r)


Measured memory_bytes: 37200
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll A, B;
    cin >> A >> B;
    vector<vector<ll>> d(A + 1, vector<ll>(B + 1));
    for (ll i = 1; i <= A; i++) {
        for (ll j = 1; j <= B; j++) {
            cin >> d[i][j];
        }
    }

    constexpr ll MAX = 100;
    vector<vector<ll>> f(MAX + 1, vector<ll>(MAX + 1, 0));
    for (ll a = 0; a <= MAX; a++) {
        for (ll b = 0; b <= MAX; b++) {
            for (ll x = 1; x <= A; x++) {
                for (ll y = 1; y <= B; y++) {
                    f[a][b] = max(f[a][b], d[x][y] - x * a - y * b);
                }
            }
        }
    }

    for (ll x = 1; x <= A; x++) {
        for (ll y = 1; y <= B; y++) {
            ll D = LLONG_MAX;
            for (ll a = 0; a <= MAX; a++) {
                for (ll b = 0; b <= MAX; b++) {
                    D = min(D, x * a + y * b + f[a][b]);
                }
            }
            if (D != d[x][y]) {
                cout << "Impossible" << endl;
                return 0;
            }
        }
    }

    cout << "Possible" << endl;
    const ll N = (MAX + 1) * 2;
    const ll M = MAX * (MAX + 2) + 2 * MAX + 1;
    cout << N << " " << M << endl;
    for (ll i = 1; i <= MAX; i++) {
        cout << i << ' ' << i + 1 << " X" << endl;
    }
    for (ll i = 1; i <= MAX; i++) {
        cout << i + MAX + 1 << ' ' << i + MAX + 2 << " Y" << endl;
    }

    for (ll a = 0; a <= MAX; a++) {
        for (ll b = 0; b <= MAX; b++) {
            cout << a + 1 << ' ' << b + 102 << ' ' << f[a][MAX - b] << endl;
        }
    }

    cout << "1 202" << endl;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main() {
	int b, r, g, c, s, t;
	while (cin >> b >> r >> g >> c >> s >> t, b || r || g || c || s || t) {
		int ans = 100;
		int bonus = 5 * b + 3 * r;

		ans += 15 * b + 15 * r + 7 * g + 2 * c + 3 * s;
		ans += bonus * 16;
		ans -= 3 * t;

		cout << ans << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
static const int MAX = 1000;

int main() {
    int A[MAX], N;
    int i;

    cin >> N;
    for (i = 0; i < N; i++ ) cin >> A[i];

    for (i = 0; i < N-1; i++ ) cout << A[i] << " ";
    cout << A[i] << endl;

    for (i = 1; i < N; i++ ) {
        int v = A[i];
        int j = i - 1;
        while ( j >= 0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;

        int k;
        for (k = 0; k < N-1; k++ ) cout << A[k] << " ";
        cout << A[k] << endl;

    }
    return 0;
}


Measured memory_bytes: 3076