akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
#define n_max 100000
#define N_max 100

#define rep(i, a, n) for(int i = a; i < n; i++)
#define lrep(i, a, n) for(long int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

int digits(int n)
{
    int digits=1;

    while(n) {
        if(n/=10) digits++;
    }
    return digits;
}



int main()
{
    long int N;
    long int B;
    int ans = 1000000;

    in(N);

    int lim = sqrt(N);
    //cout << lim << endl;
    lrep(A, 1, lim + 1) {

        if((N % A) != 0) continue;
        B = N / A;
        //out(digits(A));
        //cout << "A" << A << "digits" << digits(A) << endl;
        //cout << "B" << B << "digits" << digits(B) << endl;
        ans = min(ans, max(digits(A), digits(B)));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
int sx,sy,tx,ty;
ll a[200003];
ll b[2003];
bool vis[1009][1009];
struct threeElements{
int f,s,t;
};
int main()
{
   // freopen ("jumping.in","r",stdin);
   _IOS();
   string s,t;
   cin>>s>>t;
   if(t.substr(0,s.length())==s)
    cout<<"Yes"<<endl;
   else
    cout<<"No";
}


Measured memory_bytes: 3620
/*
 * author :Sadik Hassan
 *
*/
#include "bits/stdc++.h"
using namespace std;
using   ll =          long long;
#define nl            "\n"
#define pb            push_back
#define fi            first
#define se            second
#define PI            (acos(-1.0))
#define repp(i,a,n)   for(int i=a;i<n;i++)
#define rep(i,n)      for(int i=0;i<n;i++)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
#define w(t)          int t;cin>>t;while(t--)
#define TSFL(s)       transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSFH(s)       transform(s.begin(),s.end(),s.begin(),::tolower);
#define _SAD()     	  ios::sync_with_stdio(0),cin.tie(0),cout.tie(0),cout<<fixed<<setprecision(15);
typedef vector<int> vi;
typedef vector<ll> vii;
typedef set<int> si;
typedef set<ll> sii;
/*---------------------------------------------------------------------*/

const int N = 2e5+5;
const int MOD =(int)1e9+7;
const int INF = (int)1e9+5;

int main()
{
    _SAD()
    int a,b;cin>>a>>b;
    if(a*2<=b&&b<=a*4&&b%2==0)cout<<"Yes"<<nl;
    else cout<<"No"<<nl;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int n,m;

int main()
{
    int a,b;
    IO
    int flag=0;
    cin>>n>>m>>a>>b;
    while(1)
    {
        if(n<=0){cout<<"No"<<endl;return 0;}
        else if(a<=0){cout<<"Yes"<<endl;return 0;}
        if(flag==0)
        {
            a-=m;
            flag=1;
        }
        else
        {
            n-=b;
            flag=0;
        }
    }
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main () {
    int k, t;
    cin >> k >> t;
    vector<int> a(t);
    for (int i = 0; i < t; i++) {
        cin >> a[i];
    }
    while (a.size()) {
        if (a.size() == 1) {
            cout << a[0] - 1 << endl;
            return 0;
        }
        sort(a.begin(), a.end());
        a.front()--, a.back()--;
        if (!a.front()) {
            a.erase(a.begin());
        }
        if (!a.back()) {
            a.erase(a.end() - 1);
        }
   }
    puts("0");
}

Measured memory_bytes: 256
#include <stdio.h>
int n,G[101][101];
int d[101];
int T = 0;
int F[101] = {0};
int k = 0;

void visit(int u) {
  int i,j,v;
  T++;  
  d[u] = T;

  for(v=0;v<n;v++) {
    if(G[u][v] == 1 && d[v] == 0 ) {
      visit(v);
    }
  }
  
  T++;
  F[u] = T;

}



int main() {
  
  
  int i,j,k,l,u,a,t;

  for(i=0;i<n;i++) d[i] = 0;

  scanf("%d",&n);

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

    }

  for(i=0;i<n;i++){

    scanf("%d %d ",&k,&u);
    //    printf("u = %d\n",u);

    for(j=0;j<u;j++) {
      scanf("%d",&a);
      G[k -1][a-1] = 1;
      // printf("G[%d][%d] = 1\n",i,k-1);
    }
  }
  for(i=0;i<n;i++) {
    if(d[i] == 0) 
    visit (i);
  }
    
  for(i=0;i<n;i++) {
    printf("%d %d %d\n",i+1,d[i],F[i]);
  }
  return 0;

    
    
}

Measured memory_bytes: 636
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import qualified Data.Map as Map
import Data.List

import Control.Monad
import Control.Monad.State

import Data.Char
import Data.Ord

import Text.Printf

getInts :: IO [Int]
getInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

main :: IO ()
main = do
  [n, m] <- getInts
  ps <- replicateM m $ do
    (\[p, s] -> (fst . fromJust . BS.readInt $ p, BS.unpack s)) . BS.words  <$> BS.getLine

  let temp = filter (elem "AC") . map (map snd) . groupBy (\(x,_) (y,_) -> x == y) . sortBy (\(x,_) (y,_) -> compare x y) $ ps

  let ac = length temp

  let penalty = sum $ map (length . takeWhile (== "WA")) temp

  printf "%d %d\n" ac penalty


Measured memory_bytes: 55676
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long lint;

int main(){
	string s;
	cin >> s;
	bool flag=true;
	int n = (int)(s.size());
	REP(i,(n-1)/2){
		if(s[i]!=s[(n-1)-i]){
			flag = false;
			break;
		}
	}
	REP(i,((n-1)/2)/2){
		if(s[i]!=s[((n-1)/2)-1-i]){
			flag = false;
			break;
		}
	}
	if(flag)cout << "Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
// author:-*mdragneell*

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define pi  pair<int,int>
#define pl  pair<ll,ll>

int const N=305;
ll min(ll x,ll y) { if(x<y) return x; else return y; }
ll max(ll x,ll y) { if(x>y) return x; else return y; }

ll vis[N][N][N];
double cache[N][N][N];
ll n,cnt[4];

double sol(ll a,ll b,ll c)
{
        if(a<0||b<0||c<0) return 0;
        if(a==0&&b==0&&c==0) return 0;

        if(vis[a][b][c]) return cache[a][b][c];
        vis[a][b][c]=1;

        ll k=a+b+c;
        //cout<<k<<endl;
        double temp=((a*sol(a-1,b,c))+(b*sol(a+1,b-1,c))+(c*sol(a,b+1,c-1))+n-k)/k+1;
        return cache[a][b][c]=temp;

}

int main()
{
    ll i,j;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++) {
        cin>>a[i];
        cnt[a[i]]++;
    }

    cout<<fixed<<setprecision(10)<<sol(cnt[1],cnt[2],cnt[3])<<endl;

}


Measured memory_bytes: 438528
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
using namespace std;
long long ai[200010],bi[200010];
int n;
long long ans;

int main()
{
    int i,j;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%lld",&ai[i]);
        ai[i]-=i;
        bi[i]=ai[i];
    }
    sort(bi+1,bi+n+1);
    long long b=bi[(n+1)/2];
    //cout<<b<<endl;
    for(i=1;i<=n;i++)
    {
        long long now=ai[i]-b;
        if(now>=0) ans+=now;
        else ans+=(-now);
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;
using ll = long long;

int main() {
    ll A, B, K;
    cin >> A >> B >> K;
    if(A > K) {
        cout << A - K << ' ' << B << endl;
    } else if(A + B > K) {
        cout << 0 << ' ' << A + B - K << endl;
    } else {
        cout << 0 << ' ' << 0 << endl;
    }
    

    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
 
using namespace std;
int main() 
{
	int n;
	cin >> n;
	int arr[n];
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			ans += (arr[i] * arr[j]);
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int b[100000];
signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a>=c){
    cout<<"delicious\n";
  }
  else{
    if(a+b>=c){
      cout<<"safe\n";
    }
    else{
      cout<<"dangerous\n";
	}
  }
  return(0);
}

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

int main() {
  int S, A, B;
  cin >> S;
  A = S / 100;
  B = S % 100;
  if (A > 12 || A == 0) {
    if (B > 12 || B == 0) {
      cout << "NA";
    }
    else {
      cout << "YYMM";
    }
  }
  else {
    if (B > 12 || B == 0) {
      cout << "MMYY";
    }
    else {
      cout << "AMBIGUOUS";
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::vector<long long> a(n + 1), b(n);
    for (int i = 0; i < n + 1; i++) std::cin >> a[i];
    for (int i = 0; i < n; i++) std::cin >> b[i];
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        ans += std::min(a[i], b[i]);
        b[i] -= std::min(a[i], b[i]);
        ans += std::min(a[i + 1], b[i]);
        a[i + 1] -= std::min(a[i + 1], b[i]);
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    ll digit = 0;

    ll nTmp = n;
    while(nTmp != 0){
        digit += nTmp%10;
        nTmp /= 10;
    }

    if(n%digit == 0) Yes();
    else No();
}

Measured memory_bytes: 256
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    auto abc = aryread();
    // writeln(abc);
    long cnt5;
    long cnt7;
    foreach (i; 0 .. (abc.length))
    {
        if (abc[i] == 5)
        {
            cnt5 += 1;
        }
        else if (abc[i] == 7)
        {
            cnt7 += 1;
        }
    }
    if (cnt5 == 2 && cnt7 == 1)
    {
        writeln("YES");
    }
    else
    {
        writeln("NO");
    }
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 3560
# https://atcoder.jp/contests/abc140/submissions/7411285
# 写経

def main():
    N = int(input())
    *p, = map(int, input().split())

    xtoi = [-1] * (N + 1)
    for i, x in enumerate(p):
        xtoi[x] = i

    L = [-1] * (N + 2)
    R = [N] * (N + 2)
    for i in range(N):
        L[i] = i - 1
        R[i] = i + 1

    iter_inds = iter(xtoi)
    next(iter_inds)

    ans = 0
    for x, ind in enumerate(iter_inds, start=1):
        # l2, ..., l1, ..., x, ..., r1, ..., r2
        # (l2,r1) or (l1,r2)
        l1 = L[ind]
        l2 = L[l1]
        r1 = R[ind]
        r2 = R[r1]
        ans += x * ((l1 - l2) * (r1 - ind) + (r2 - r1) * (ind - l1))
        L[r1] = l1
        R[l1] = r1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19192
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr= input.trim().split("");
var cnt=0;
var r=0;
arr.forEach(v=>{
   if(v=="R")r++;
   else if(v=="L")r--;
   if(r==4){
      cnt++;
      r=0;
   }else if(r==-4){
      r=0;
   }
});
console.log(cnt);


Measured memory_bytes: 15528
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define x first
#define y second
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
#define plll pair <pair <ll, ll>, ll>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
#define psl pair <string, ll>
#define all(a) a.begin(), a.end()

typedef long long ll;

typedef long double ld;

using namespace std;

const ll maxn = 1e6;

ll n, m, k, t;

ll A[maxn];

int main() {
    pyshnapyshnakaa;
    ll q, w, e, a, b, c;
    string s;
    cin >> s;
    vector <ll> I;
    n = s.length() + 1;
    // for (q = 0; q < n; q++) {
    //     if (q == 0) {
    //         if (s[q] == '<') {
    //             I.pb(q);
    //         }
    //         continue;
    //     }
    //     if (q == n - 1) {
    //         if (s[q - 1] == '>') {
    //             I.pb(q);
    //         }
    //         continue;
    //     }
    //     if (s[q - 1] == '>' && s[q] == '<') {
    //         I.pb(q);
    //     }
    // }
    for (q = 1; q < n; q++) {
        if (s[q - 1] == '<') {
            A[q] = max(A[q - 1] + 1, A[q]);
        }
    }
    for (q = n - 2; q >= 0; q--) {
        if (s[q] == '>') {
            A[q] = max(A[q + 1] + 1, A[q]); 
        }
    }
    ll ans = 0;
    for (q = 0; q < n; q++) {
        ans += A[q];
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 5020
N = int(input())
A = list(map(int, input().split()))
X = 0
ans = 0
for j in range(0, N):
    X += A[j]
for i in range(0, N-1):
    X = X - A[i]
    ans += A[i] * X
ans = ans % (10**9 + 7)
print(ans)

Measured memory_bytes: 31572
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
aa = 10 * ((a + 9) // 10)
bb = 10 * ((b + 9) // 10)
cc = 10 * ((c + 9) // 10)
dd = 10 * ((d + 9) // 10)
ee = 10 * ((e + 9) // 10)
if len(set([a%10,b%10,c%10,d%10,e%10]) - {0}) > 0:
    x = min(set([a%10,b%10,c%10,d%10,e%10]) - {0})
else:
    x = 10
# print(x)
print(aa+bb+cc+dd+ee-(10-x))


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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int H,W;
    cin >> H >> W;
    
    vector<string> s(H);
    int cnt=0;
    rep(i,0,H){
        cin >> s[i];
        rep(j,0,W) if(s[i][j]=='.') ++cnt;
    }

    vector<vector<int>> d(H,vector<int>(W,-1));
    d[0][0]=0;
    queue<pair<int,int>> q;
    q.push(make_pair(0,0));
    vector<int> dy={0,-1,0,1},dx={1,0,-1,0};
    while(!q.empty()){
        auto p=q.front();
        q.pop();
        int y=p.first,x=p.second;
        rep(i,0,4){
            int ny=y+dy[i],nx=x+dx[i];
            if(ny<0 or H<=ny or nx<0 or W<=nx) continue;
            if(d[ny][nx]!=-1) continue;
            if(s[ny][nx]=='#') continue;
            d[ny][nx]=d[y][x]+1;
            q.push(make_pair(ny,nx));
        }
    }

    if(d[H-1][W-1]==-1){
        cout << -1 << endl;
        return;
    }

    print(cnt);
    print(d[H-1][W-1]);
    cout << cnt-d[H-1][W-1]+1-2 << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;

const int maxn = 3010;
char s[maxn], t[maxn];
int n, m, dp[maxn][maxn];

int solve(int i, int j){
   int &dp = ::dp[i][j];
   if (dp != -1) return dp;
   if (i == n || j == m) return dp = 0;
   dp = max(solve(i + 1, j), solve(i, j + 1));
   if (s[i] == t[j])
      dp = max(dp, 1 + solve(i + 1, j + 1));
   return dp;
}

int main(){
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.precision(10);
   cout << fixed;
   cin >> s >> t;
   n = strlen(s), m = strlen(t);
   memset(dp, -1, sizeof(dp));
   solve(0, 0);
   int i = 0, j = 0;
   while (dp[i][j] != 0){
      if (dp[i][j] == 1 + dp[i + 1][j + 1] && s[i] == t[j]){
         cout << s[i];
         ++i, ++j;
      }
      else if (dp[i][j] == dp[i + 1][j])
         ++i;
      else
         ++j;
   }
   cout << '\n';
   return 0;
}

Measured memory_bytes: 36224
#include "bits/stdc++.h"
#include <random>
using namespace std; typedef unsigned long long _ulong; typedef long long int lint; typedef pair<lint, lint> plint; typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define endk '\n'
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const lint MOD = 1e9 + 7, INF = 1e18;
lint dx[8] = { 0, -1, 1, 0, 1, -1, 1, -1 }, dy[8] = { 1, 0, 0, -1, -1, -1, 1, 1 };

lint H, W, dp[1000][1000], sy, sx, gy, gx;
char mp[1000][1000];

struct tlint {
	lint y;
	lint x;
};

int main() {
	cin >> H >> W;
	cin >> sy >> sx; sy--; sx--;
	cin >> gy >> gx; gy--; gx--;
	REP(i, H) {
		REP(j, W) {
			cin >> mp[i][j];
			dp[i][j] = INF;
		}
	}

	deque<tlint> que;
	dp[sy][sx] = 0;
	que.push_front({ sy, sx });
	while (!que.empty()) {
		tlint curr = que.front(); que.pop_front();
		if (curr.y == gy && curr.x == gx) break;
		REP(k, 4) {
			lint ny = curr.y + dy[k], nx = curr.x + dx[k];
			if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
			if (mp[ny][nx] == '#') continue;
			if (dp[ny][nx] > dp[curr.y][curr.x]) {
				dp[ny][nx] = dp[curr.y][curr.x];
				que.push_front({ ny, nx });
			}
		}
		REP(i, 5) {
			REP(j, 5) {
				lint ny = curr.y - 2 + i, nx = curr.x - 2 + j;
				if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
				if (mp[ny][nx] == '#') continue;
				if (dp[ny][nx] > dp[curr.y][curr.x] + 1) {
					dp[ny][nx] = dp[curr.y][curr.x] + 1;
					que.push_back({ ny, nx });
				}
			}
		}
	}

	if (dp[gy][gx] == INF) cout << -1 << endk;
	else cout << dp[gy][gx] << endk;
}


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

using namespace std;
using ll = long long;
using ld = long double;
using Vec = vector<int>;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}


int main(){

string s,t;
int ans=10000;
cin>>s>>t; //tがちいさい
int x=t.size();
for(int i=0;i<s.size()-x+1;i++){
    string p=s.substr(i,x);
    int count=0;
    for(int j=0;j<x;j++){
        if(p[j]!=t[j]){
            count++;
        }

    }
    ans=min(ans,count);
}
cout<<ans<<endl;




}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;

//深さ優先
vector<int> seen;
vector<ll> h;

//普通の深さ優先探索seenを返す感じ
void dfs(const Graph &G,int v){
    seen[v] = 0; //v探索済み

    P good=make_pair(v,h[v]);
    for(auto next_v :G[v]){
        if(seen[next_v]!=-1) continue;//もう探索していた
        if(h[next_v]>good.second){
            good=make_pair(next_v,h[next_v]);
        }
        dfs(G,next_v);
    }

    if(!(h[v]==good.second && v==good.first)){
        seen[good.first]=1;
    }
}

int main(){
    /*
    int n,m;
    cin>>n>>m;

    h.assign(n,0);
    rep(i,0,n) cin>>h[i];

    Graph G(n);
    rep(i,0,m){
        int a,b; cin>>a>>b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    seen.assign(n,-1);

    rep(i,0,n){
        if(seen[i]==-1){
            dfs(G,i);
        }
    }

    int sum=accumulate(all(seen),0);

    cout<<sum<<endl;*/

    int n,m; cin>>n>>m;
    ll h[n];
    rep(i,0,n) cin>>h[i];
    Graph G(n);
    rep(i,0,m){
        int a,b; cin>>a>>b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    int ans=0;
    for(int i=0;i<n;i++){
        int len=G[i].size();
        bool able=true;
        for(int j=0;j<len;j++){
            if(h[i]<=h[G[i][j]]){
                able=false;
                break;
            }
        }

        if(able) ans++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 9064
#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, w, k; cin >> h >> w >> k;
  vector<string> c(h, "");
  for (int i = 0; i < h; i++)
    cin >> c[i];

  int t = 0;
  for (int b = 0; b < (1 << (w + h)); b++) {
    int kk = 0;
    for (int y = 0; y < h; y++) {
      int m = b >> (w + y);
      if (!(m & 1)) continue;
      for (int x = 0; x < w; x++) {
        int m = b >> x;
        if ((m & 1) && c[y][x] == '#') kk++;
      }
    }
    if (kk == k) t++;
  }
  cout << t << endl;
  return 0;
}

Measured memory_bytes: 3636
#!/usr/bin/node
// Generated by CoffeeScript 1.3.3 (minified manually)
(function() {
  var a=[],stdin;
  stdin=process.openStdin();
  stdin.setEncoding('utf8');

  stdin.on('data', function(input) {
    var x;
    x = input.split("\n");
    if(x.length > 2 || x[1] !== '')a = x;
    else a.push(x[0]);
  });

  stdin.on('end', function(z) {
    var b, e, i, m, n, r, y, _i, _results;
    n = parseInt(a.shift());
    _results = [];
    for (i = _i = 0; 0 <= n ? _i < n : _i > n; i = 0 <= n ? ++_i : --_i) {
      b = (function() {
        var _j, _len, _ref, _results1;
        _ref = a[i].split(" ");
        _results1 = [];
        for (_j = 0, _len = _ref.length; _j < _len; _j++) {
          e = _ref[_j];
          _results1.push(parseInt(e));
        }
        return _results1;
      })();
      y = b[0] - 1;
      m = b[1] - 1;
      r = 0;
      if (y % 3 !== 2) {
        r = Math.floor(m / 2);
      }
      console.log(196471 - y * 195 - Math.floor(y / 3) * 5 - m * 20 + r - b[2]);
    }
  });
}).call(this);

Measured memory_bytes: 8952
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int main(){
  int n,l;
  cin >> n;
  int c=-1;
  for(int i=1;i<=n;i++){
    int k=i;
    int kk=k;
    int j=0;
    while(k%2==0){
      k=k/2;
      j++;
    }
    if(c<j){
      c=j;
      l=kk;
    }
  }
  cout << l << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_multiset tree<long long , null_type,less_equal<long long >, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree<long long , null_type,less<long long >, rb_tree_tag,tree_order_statistics_node_update>
*/
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define ld     long double 
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=a;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define pre(n) cout<<fixed<<setprecision(n);
#define      gcd(a,b)    __gcd(a,b)
#define bs            binary_search
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define pi 3.14159265358979323846
#define all(x) x.begin(),x.end()
#define re return 0;
// *#######################################################################################*

/*
bool isp(ll n)
{
    ll i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            return false;
        }
        
    }
}
  */
  
  ll powerm(ll x, unsigned ll y, ll p)  
{  
    ll res = 1;    
  
    x = x % p; 
   
    if (x == 0) return 0;
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
   
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}
  long long lcm(long long a, long long b){//?????????
   return a * b / gcd(a, b);
}

/*
ll po(ll z,ll z1)
{
    ll rer=0;
    rer=     ((z*(z-1))/2+(z1*(z1-1))/2);
    return rer;

}
*/
/*
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
*/
/*
bool is_prime(ll n){
    for(ll i = 2;i*i<=n;i++){
        if(n%i == 0) return false;
    }
    return true;
}
*/
int inv(int a){
    return powerm(a,mod-2,mod);
}

ll const N=1e5;
ll fact[N], invfact[N];
 
void precompute(){
    fact[0] = 1;
    for(int i=1;i<N;i++) fact[i] = (fact[i-1]*i)%mod;
    invfact[N-1] = inv(fact[N-1])%mod;
    for(int i=N-2;i>=0;i--) invfact[i] = (invfact[i+1]*(i+1))%mod;
}
 
ll ncr(ll n, ll r){
    if(n<r) return 0;
    return (((fact[n]*invfact[r])%mod)*invfact[n-r])%mod;
}


//*88888*********5555555555555555******88888888$$$$$$$$$$******!!!!!!!!!!
//%%%%%%%%%%%%%%55


       int main()
       {
           //????????
    fast
        
        ll n;
        cin>>n;
        ll a[n],i,s=0,ans=0;
        f(i,n)
        {
            cin>>a[i];
            s+=a[i];
        }  
    
         f(i,n)
         {
             s-=a[i];
             ans=(ans%mod+((s%mod)*a[i])%mod)%mod;
         }


           o(ans)









//?????????
re}

Measured memory_bytes: 5224
n,k=map(int,input().split())
a=list(map(int,input().split()))
ok=10**10
ng=1
for i in range(40):
    chk=(ok+ng)//2
    cnt=0
    for j in range(n):
        cnt+=(a[j]+chk-1)//chk-1
    if cnt > k:
        ng = chk
    else:
        ok = chk
print(ok)

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

long long int a,b,c,d,r1,r2;

cin>>a>>b>>c>>d;

if( a*c <= a*d){
	r1 = a*d;
}
else{
	r1 = a*c;
}

if(b*c <= b*d){
	r2 = b*d;
}
else{
	r2 = b*c;
}

if(r1>r2){
	cout<<r1;
}
else{
	cout<<r2;
}
//cout<<r1*r2;
   return 0;
}


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

d = {}

for a in A:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1

l = sorted(d.values(), reverse=True)

if len(l) <= K:
    print(0)
else:
    print(sum(l[K:]))


Measured memory_bytes: 32184
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  int n, c, k; cin >> n >> c >> k;
  vector<int> t(n); rep(i, n) cin >> t[i];
  sort(t);
  int cnt = 1, min = t[0], ans = 0;
  for (int i = 1; i < n; i++) {
    // debug3(cnt, min, ans);
    if (t[i] - min <= k && cnt + 1 <= c) cnt++;
    else {
      ans++;
      min = t[i];
      cnt = 1;
    }
  }
  if (cnt > 0) ans++;
  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 640
<?php
$n = intval(fgets(STDIN));
for($i = 0; $i < $n; $i++){
  $a[$i] = intval(fgets(STDIN));
  for($j = 0; $j < $a[$i]; $j++){
    list($b, $c) = array_map("intval", explode(" ", trim(fgets(STDIN))));
    $map[$i][$b-1] = $c; 
  }
}
$max = 0;
for($i = 0, $I = 2**$n; $i < $I; $i++){
  $bits = sprintf("%0".$n."b", $i);
  $flag = true;
  foreach($map as $from => $row){
    if($bits[$from] == "1"){ 
      foreach($row as $to => $v){
        if($bits[$to] != $v){ 
          $flag = false;
        }
      }
    }
  }
  if($flag){
    $sum = 0;
    for($j = 0; $j < $n; $j++){
      $sum+=$bits[$j];
    }
    $max = max($max, $sum);
  }
}
echo $max;


Measured memory_bytes: 4604
INF = 10000000000

def merge(A, left, mid, right):
    count = 0
    L = A[left:mid] + [INF]
    R = A[mid:right] + [INF]
    
    i, j = 0, 0
    for k in range(left, right):
        count = count + 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i = i + 1
        else:
            A[k] = R[j]
            j = j + 1
    return count

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        countL = mergeSort(A, left, mid)
        countR = mergeSort(A, mid, right)
        return merge(A, left, mid, right) + countL + countR
    return 0
        

n = int(input())
A = [int(i) for i in input().split()]
count = mergeSort(A, 0, n)
for i in range(n):
    if i:
        print(" ", end = "")
    print(A[i], end = "")
print()
print(count)



Measured memory_bytes: 63696
n=int(input())
a=list(map(int,input().split()))

from collections import Counter

kaburi=0
c=Counter(a).most_common()
for i in c:
  if i[1]>=2:
    kaburi+=i[1]-1

if kaburi%2:
  w=n-kaburi-1
else:
  w=n-kaburi

print(w)

Measured memory_bytes: 21360
{-
HOME- ITP1-ITP1_3-B
Discussion Solution Statistics Submit
 
Repetitive Processing - Print Test Cases
????????¶??? : 1 sec, ?????¢?????¶??? : 65536 KB
???????????±???????????????

????????????????????£????????§?????????????????????????????°??????????????°?????\??????????????????????????????????????£????????????????????£??????????????????????????????????????????????????\????????????????????????????????°???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????´???????????§??????

???????????´??° x ???????????????????????????????????????????????????????????°?????????????????????????????????

?????????????????????????????\?????????????????????????????????????????????????????????????????????????????¨?????¨?????????????????????
Input

??\???????????°????????????????????????????§????????????????????????????????????????????????????????????´??° x ??????????????????????§?????????????????????????

x ??? 0 ?????¨?????\?????????????????????????????????????????????????????????????????????????????£????????????????????????
Output

??????????????????????????¨????????\????????¢?????§ x ???????????????????????????

Case i: x

????????§???i ?????????????§????????????????????????????????????????????????????Case??¨?????? i?????????????????????????????\???????????????????????????:?????????????????¨??´??° x ?????????????????????????????\????????????????????????????????\????????????????????????????????????
Sample Input

3
5
11
7
8
19
0

Sample Output

Case 1: 3
Case 2: 5
Case 3: 11
Case 4: 7
Case 5: 8
Case 6: 19
-}

main = prtln 1
prtln :: Int -> IO ()
prtln n = do
  s <- getLine
  let t = aux s n
  if t == "" then return ()
    else do putStrLn t
            prtln (n+1)

aux :: String -> Int -> String
aux s n = if s ==  "0" then ""
          else "Case " ++ (show n) ++ ": "  ++ s

Measured memory_bytes: 3992
import math
n, d = map(int,input().split())
x = [[0]*d]*n

for i in range(n):
    x[i] = list(map(int,input().split()))

ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        dis = 0
        for k in range(d):
            dis += abs(x[i][k] - x[j][k])*abs(x[i][k] - x[j][k])
        a, _ = math.modf(math.sqrt(dis))
        if a == 0:
            ans += 1
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <string>
using namespace std;

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int n;
    while(cin>>n && n!=-1){
        int t = 0;
        if(n==0){
            cout << 0 << endl;
        }else{
            while(n){
                t*=10;
                t+=n%4+1;
                n/=4;
            }
            stringstream ss;
            ss << t;
            string str = ss.str();
            reverse(str.begin(),str.end());
            rep(i,str.size())str[i]--;
            cout << str << endl;
        }
    }
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int num = 1;
  for(int i = 0; i < N; i ++){
    if (num * 2 > num + K)
      num += K;
    else
      num *= 2;
  }
  cout << num << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void swaps(int *a,int *b)
{
	int p;
	p= *a;
	*a=*b;
	*b = p;
}
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	printf("%d %d %d",c,a,b);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;

int N,M;
int main (){
    cin >> N >> M;
    int left=1;
    int right = N;
    for(int i=0;i<M; i++) {
        int l,r;
        cin >> l >> r;
        left = max(l,left);
        right = min(r,right);
    }
    cout << (right >= left ? right - left + 1 : 0 ) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main 
{
	public static void main(String[] args)
	{
		class Area
		{
			double x, y, z;
		}
		ArrayList<Area> area = new ArrayList<>();
		Scanner scanner = new Scanner(System.in);
		
		double total_angle = 0;
		for(int i=0; i<1000; i++)
		{
			Area a = new Area();
			double v = 1;
			if(i > 0)
			{
				double z = area.get(i-1).z;
				a.z = Math.sqrt(z*z + 1);
				v = a.z;
				total_angle += Math.asin(1/a.z);
			}
			else
			{
				a.z = 1;
			}		
			a.x = v * Math.cos(total_angle);
			a.y = v * Math.sin(total_angle);		
			area.add(a);
		}
		
		for(; ;)
		{
			int n = scanner.nextInt();
			if(n == -1)
			{
				break;
			}
			
			System.out.printf("%1$.2f\n", area.get(n-1).x);
			System.out.printf("%1$.2f\n", area.get(n-1).y);
		}
	}
}

Measured memory_bytes: 26472
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long int
#define ii pair<int,int>
#define lli pair<ll,ll>
#define pii pair<int,int>
#include<limits>
#define deb(x) cout<<#x<<'='<<(x)<<endl
#define deb2(x,y) cout<<'['<<#x<<'='<<(x)<<','<<#y<<'='<<(y)<<']'<<endl
#define debarr(a,n) {cout<<#a<<'='; for(int i=0;i<n;i++) cout << a[i] << ' '; cout<<endl;}
#define debvec(v) {cout<<#v<<'=';for(auto itr=v.begin();itr!=v.end();itr++)cout<<*itr<<' ';cout<<endl;}
#define INF numeric_limits<int>::max()
#define NINF numeric_limits<int>::min()
#define endl "\n"
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define MOD (ll)(pow(10,9)+7)
using namespace std;

int binomialCoeff(int n, int k)  
{  
    if (k == 0 || k == n)  
        return 1;  
  
    return binomialCoeff(n - 1, k - 1) +  
                binomialCoeff(n - 1, k);  
}  
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    for(ll i=k;i<=n+1;i++)
    {
        ll minn = i*(i-1)/2;
        ll maxx = (i*n-minn);
        ans+=(maxx-minn+1)%MOD;
        ans=ans%MOD;
    }
        cout<<ans<<endl;
        
    return 0;
}

Measured memory_bytes: 3648
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
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...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
//------------------------------//

typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;

#define  ff           first
#define  ss           second
#define  pb           push_back
#define  IOS          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  all(x)       (x).begin(), (x).end()
#define  ps(x,y)      fixed<<setprecision(y)<<x
#define  rep(i,a,b)   for(ll i=a ; i<b ; ++i)

const ll MOD = 998244353;
const ll INF = 1e18;
const ll maxn = 2e5 + 5;


void solve(){
  int n,k;
  cin >> n >> k;
  vpi segs(k);
  vll cells(maxn),pref(maxn);
  for(int i=0;i<k;i++){
     cin >> segs[i].ff >> segs[i].ss;
  }
  for(int i=1;i<=n;i++){
    pref[i] = (pref[i-1]+pref[i])%MOD;
    cells[i] = pref[i];
    if(i==1)cells[i]=1;
    // deb(vector<int>(pref.begin(),pref.begin()+n+1));
    for(pi p:segs){
      if(i+p.ff < maxn){
        pref[i+p.ff] = (pref[i+p.ff]+cells[i])%MOD;
      }
      if(i+p.ss+1<maxn){
        pref[i+p.ss+1] = ((pref[i+p.ss+1]-cells[i])%MOD+MOD)%MOD;
      }
    }
  }
  // deb(vector<int>(cells.begin(),cells.begin()+n+1));
  cout << cells[n];
}  

int main(){
  IOS
  	solve();
  //cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
}

// integer overflow

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

int x, y, z, k;
int A[1010], B[1010], C[1010];
vector<int> ans;


int32_t main(){
     cin>>x>>y>>z>>k;
    for(int i=0;i<x;i++){
        cin>>A[i];
        A[i]=-1*A[i];
    }
    for(int i=0;i<y;i++){
        cin>>B[i];
        B[i]=-1*B[i];
    }
    for(int i=0;i<z;i++){
        cin>>C[i];
        C[i]=-1*C[i];
    }
    
     sort(A, A+x);
     sort(B, B+y);
     sort(C, C+z);

     for(int i=0;i<x;i++){
          for(int j=0;j<y;j++){
               for(int l=0;l<z;l++){
                    int temp=(i+1)*(j+1)*(l+1);
                    ans.push_back((A[i]+B[j]+C[l]));
                    if(temp>k)break;
               }
          }
     }
     sort(ans.begin(), ans.end());
     for(int i=0;i<k;i++)cout<<-1*ans[i]<<endl;
     
}

Measured memory_bytes: 18792
#include<stdio.h>
int main(){
    int n,i,cou=0;
    scanf("%d",&n);
    int arr[26]={0};
    char ch;
    for(i=0;i<n;i++){
        getchar();
        ch=getchar();
        if(!arr[ch-'A']){
            cou++;
            arr[ch-'A']++;
        }
    }
    if(cou==3) printf("Three");
    else printf("Four");
    return 0;
}


Measured memory_bytes: 128
package main

import (
	"fmt"
	"sort"
)

func pow(x, n, mod int64) int64 {
	if n == 0 {
		return 1
	}
	xx := x * x % mod
	r := pow(xx, n/2, mod)
	if n%2 == 1 {
		r = x * r % mod
	}
	return r
}

const mod = 1e9 + 7

func main() {
	var n int
	fmt.Scan(&n)
	var a []int
	for i := 0; i < n; i++ {
		var t int
		fmt.Scan(&t)
		a = append(a, -t)
	}
	var b []int
	for _, t := range a {
		i := sort.SearchInts(b, t)
		bl := len(b)
		// fmt.Println(b, t, i)
		if i == bl {
			b = append(b, t-1)
		} else {
			b[i] = t - 1
		}
	}
	fmt.Println(len(b))
}


Measured memory_bytes: 7552
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
//typedef __int128_t lll;
using namespace std;

//-------------------------------------------------------------------
const int MAX_V = 51;
vvi G = vv(MAX_V, 0, 0, int);
int root;
int parent[30][MAX_V];
vector<int> depth(MAX_V);

void dfs(int v, int p, int d){
  parent[0][v] = p, depth[v] = d;
  for(int i=0;i<G[v].size();i++) if(G[v][i] != p) dfs(G[v][i], v, d+1);
}
void init(int V){
  dfs(root, -1, 0);
  for(int k=0;k+1<30;k++){
    for(int v=0;v<V;v++){
      if(parent[k][v]<0) parent[k+1][v] = -1;
      else parent[k+1][v] = parent[k][parent[k][v]];
    }
  }
}
int lca(int u, int v){
  if(depth[u]>depth[v]) swap(u, v);
  for(int k=0;k<30;k++)if((depth[v]-depth[u])>>k & 1) v = parent[k][v];
  if(u==v) return u;
  for(int k=30-1;k>=0;k--){
    if(parent[k][u] != parent[k][v]){
      u = parent[k][u];
      v = parent[k][v];
    }
  }
  return parent[0][u];
}
map<vll, ll> edge_search;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vvl e = vv(n-1, 2, 0, ll);
  re(i, n-1){
    scanf("%lld %lld", &e[i][0], &e[i][1]);
    e[i][0]--, e[i][1]--;
    G[e[i][0]].push_back(e[i][1]);
    G[e[i][1]].push_back(e[i][0]);
    edge_search.emplace(vll{e[i][0], e[i][1]}, i);
    edge_search.emplace(vll{e[i][1], e[i][0]}, i);
  }
  init(n+1);

  ll m;std::cin >> m;
  vector<ll> c(n-1, 0);
  ll a, b;

  re(i, m){
    scanf("%lld %lld", &a, &b);a--, b--;
    ll l = lca(a, b);

    while(a!=l){
      ll edge_num = edge_search.at(vll{a, parent[0][a]});
      c[edge_num] |= (1<<i);
      a = parent[0][a];
    }

    while(b!=l){
      ll edge_num = edge_search.at(vll{b, parent[0][b]});
      c[edge_num] |= (1<<i);
      b = parent[0][b];
    }
  }

  /*
  re(i, n-1){
    bitset<20> b = c[i];
    std::cout << b << '\n';
  }
  */
  vvl dp = vv(n, (1<<m), 0, ll);

  dp[0][0] = 1;
  for(int i=0;i<n-1;i++){
    for(int j=0;j<(1<<m);j++){
      // use e[i]
      dp[i+1][j|c[i]] += dp[i][j];
      // not use e[i]
      dp[i+1][j] += dp[i][j];
    }
  }
  std::cout << dp[n-1][(1<<m)-1] << '\n';
  return 0;
}


Measured memory_bytes: 418304
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

long keta(long a) {
  long ret = 0;
  while (a) {
    ret++;
    a /= 10;
  }
  return ret;
}

void solve() {
  long N;
  cin >> N;

  long ans = keta(N);

  for (long i = 1; i * i <= N; i++) {
    if (N % i) continue;
    long j = N / i;
    long tmp = max(keta(i), keta(j));
    ans = min(ans, tmp);
  }

  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

int main(void) {
	long long count;
	int n;

	cin >> n;
	count = 0;
	for(int i = 0; i < n; i++) {
		char c;
		int a;

		cin >> c >> a;
		if(c == '(')
			count += a;
		else {
			count -= a;
			if(count < 0) {
				cout << "NO" << endl;
				return 0;
			}
		}
	}

	if(count)
		cout << "NO" << endl;
	else
		cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <utility>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef pair<int, int> Segment;
typedef unsigned long long ULL;

enum EventType {
    EVENT_OPEN,
    EVENT_CLOSE,
    EVENT_SPLIT,
    EVENT_NUM
};

struct Event {
    EventType type;
    int pos;
    int data;

    Event() {}
    Event(EventType t, int p) : type(t), pos(p) {}
    Event(EventType t, int p, int d) : type(t), pos(p), data(d) {}

    bool operator < (const Event &e) const {
        if(pos != e.pos) return pos < e.pos;

        if(type == EVENT_SPLIT) return false;
        if(e.type == EVENT_SPLIT) return true;
        return type < e.type;
    }
};

ostream& operator << (ostream &os, const Event &e) {
    os << '(' << e.type << ' ' << e.pos << ' ' << e.data << ')';
    return os;
}

int main() {
    int N, M;
    scanf("%d %d", &N, &M);

    vector<Segment> segments;
    vector<int> splits;
    vector<Event> events;
    for(int i = 0; i < N; ++i) {
        int s, t;
        scanf("%d %d", &s, &t);
        segments.push_back(Segment(s, t));
        events.push_back(Event(EVENT_OPEN, min(s, t), i));
        events.push_back(Event(EVENT_CLOSE, max(s, t), i));
    }
    for(int i = 0; i < M; ++i) {
        int p;
        scanf("%d", &p);
        splits.push_back(p);
        events.push_back(Event(EVENT_SPLIT, p));
    }
    sort(events.begin(), events.end());

    vector<int> spcnt(N, 0);
    {
        int acc = 0;
        for(int i = 0; i < events.size(); ++i) {
            const Event &e = events[i];
            if(e.type == EVENT_SPLIT) ++acc;
            else if(e.type == EVENT_OPEN) spcnt[e.data] = acc;
            else spcnt[e.data] = acc - spcnt[e.data];
        }
    }

    events.clear();
    for(int i = 0; i < N; ++i) {
        const Segment &s = segments[i];
        bool open_is_on = (s.first < s.second || spcnt[i] % 2 == 0);
        bool close_is_on = (s.second < s.first || spcnt[i] % 2 == 0);

        events.push_back(Event(EVENT_OPEN, min(s.first, s.second), open_is_on));
        events.push_back(Event(EVENT_CLOSE, max(s.first, s.second), close_is_on));
    }
    for(int i = 0; i < splits.size(); ++i) {
        events.push_back(Event(EVENT_SPLIT, splits[i]));
    }
    sort(events.begin(), events.end());

    int on = 0;
    int off = 0;
    int prev = 0;
    ULL ans = 0;
    for(int i = 0; i < events.size(); ++i) {
        const Event &e = events[i];
        //cout << e << endl;

        ans += on * (ULL)(e.pos - prev);
        if(e.type == EVENT_OPEN) {
            if(e.data) ++on;
            else ++off;
        }
        else if(e.type == EVENT_CLOSE) {
            if(e.data) --on;
            else --off;
        }
        else {
            swap(on, off);
        }
        //cout << on << ' ' << off << endl;
        prev = e.pos;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7996