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

using namespace std;
using ll = long long;

#define gc getchar
int getint() { unsigned int c; int x = 0; while (((c = gc()) - '0') >= 10) { if (c == '-') return -getint(); if (!~c) exit(0); } do { x = (x << 3) + (x << 1) + (c - '0'); } while (((c = gc()) - '0') < 10); return x; }
int getstr(char *s) { int c, n = 0; while ((c = gc()) <= ' ') { if (!~c) exit(0); } do { s[n++] = c; } while ((c = gc()) > ' ' ); s[n] = 0; return n; }
template<class T> inline bool chmin(T &a, T b) { return a > b ? a = b, 1 : 0; }
template<class T> inline bool chmax(T &a, T b) { return a < b ? a = b, 1 : 0; }

int m, n;

char grid[55][55], tmpl[55][55];

int main () {
    m = getint(), n = getint();
    for (auto i = 0; i < m; ++i) getstr(grid[i]);
    for (auto j = 0; j < n; ++j) getstr(tmpl[j]);

    for (auto i = 0; i < m; ++i) {
        for (auto j = 0; j < m; ++j) {
            int ok = 1;
            for (auto ii = 0; ii < n; ++ii) {
                for (auto jj = 0; jj < n; ++jj) {
                    const auto x = j + jj;
                    const auto y = i + ii;
                    if (y >= m || x >= m) {
                        ok = 0;
                        break;
                    }
                    if (grid[y][x] != tmpl[ii][jj]) ok = 0;
                }
            }
            if (ok) {
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define m_k make_pair
#define inf 0x3f3f3f3f
using namespace std;
const int N=2100;
int n,x,y,ans[N];
int main()
{
	scanf("%d%d%d",&n,&x,&y);
	for (int i=1;i<n;i++)
	{
		if (i<=x)
		{
			for (int j=i+1;j<=n;j++)
			{
				if (j<=x) ans[j-i]++;
				if (j>x && j<y) ans[min(x-i+1+y-j,j-i)]++;
				if (j>=y) ans[j-i-(y-x-1)]++;
			}
		}
		if (i>x && i<y)
		{
			for (int j=i+1;j<=n;j++)
			{
				if (j>x && j<y) ans[min(j-i,i-x+1+y-j)]++;
				if (j>=y) ans[min(j-i,i-x+1+j-y)]++;
			}
		}
		if (i>=y)
		{
			for (int j=i+1;j<=n;j++) ans[j-i]++;
		}
	}
	for (int i=1;i<n;i++) printf("%d\n",ans[i]);
	printf("\n");
}

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

#define INF 1001001001
#define MAX 1e18

int main() {
  string s;
  cin >> s;
  if (s[s.size()-1]=='s') s+="es";
  else s+="s";
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 300003
#define MOD 1000000007
#define INF 1000000000000000000
using Graph=vector<vector<int>>;

int dfs(Graph &G,int v){
  int n=G.at(v).size();
  if(n==0){
    return 0;
  }
  vector<int> count(n);
  for(int i=0;i<n;i++){
    count.at(i)=dfs(G,G.at(v).at(i));
  }
  sort(count.begin(),count.end());
  int ans=count.at(0)+n;
  for(int i=1;i<n;i++){
    ans=max(count.at(i)+n-i,ans);
  }
  return ans;
}

int main(){
  int N;
  cin>>N;
  Graph G(N);
  for(int i=1;i<N;i++){
    int a;
    cin>>a;
    a--;
    G.at(a).push_back(i);
  }
  cout<<dfs(G,0)<<endl;
}


Measured memory_bytes: 21376
/*
    I was lying to myself
*/




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

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int>pii;
typedef unsigned long long ull;

#define dbg          cout<<"Freak"<<endl;
#define dbgg(i)      cout<<i<<endl;
#define N            1e9+7
#define pb           push_back
#define pf           push_front
#define pi           acos(-1)
#define all(x)       x.begin(),x.end()
#define fast         ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define INF          0x3f3f3f3f
#define inputfile    freopen("input.txt", "r", stdin)
#define outputfile   freopen("output.txt", "w", stdout)
#define appendfile   freopen("output.txt", "a", stdout)


struct hash_pair
{
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1> {}(p.first);auto hash2 = hash<T2> {}(p.second);return hash1 ^ hash2;
    }
};

ll t;
ll mod=N;
ll BigMod(ll base,ll pow,ll mod)
{
    if(pow==0||base==1)return 1;
    else if(pow==1)return base;
    else if(pow%2)return BigMod(base,pow-1,mod)*base%mod;
    else {ll x=(BigMod(base,pow/2,mod)%mod);x=(x*x)%mod;return x;}
}





vector<ll>v[200005];
ll chk[200005],cnt;

void dfs(ll a,ll num)
{
    chk[a]=num;
    cnt++;
    for(ll i=0;i<v[a].size();i++)
    {
        ll b=v[a][i];
        if(chk[b]==num)continue;
        dfs(b,num);
    }
}

int main()
{
    fast;
    ll a,b,c,d,e,f,g,i,j;
    ll n,m,k;
    cin>>n>>m;
    for(i=1;i<=m;i++)
    {
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }
    f=0;
    for(i=1;i<=n;i++)
    {
        if(chk[i])continue;
        dfs(i,i);
        f=max(f,cnt);
        cnt=0;
    }
    cout<<f<<endl;
    return 0;
}



Measured memory_bytes: 25364
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

using namespace std;

int main()
{
   int N;
   vector<int> a;
   scanf("%d", &N);
   a.resize(N);
   for(int i = 0; i < N; i++) scanf("%d", &a[i]);
   sort(a.begin(), a.end());
   int s = 1;
   int tot = 0;
   for(int i = N-1; i >= 0; i--)
   {
      tot = tot + s*a[i];
      s = -s;
   }
   printf("%d\n", tot);
   return 0;
}

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

const int64_t MOD = 998244353;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int main(){
    int N, S;
    cin >> N >> S;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    static int64_t dp[3001][6001];
    dp[0][0] = 1;
    for(int i=0; i<N; i++) for(int j=0; j<=S; j++){
        add(dp[i+1][j+A[i]], dp[i][j]);
        add(dp[i+1][j], 2*dp[i][j]);
    }
    cout << dp[N][S] << endl;
    return 0;
}


Measured memory_bytes: 97588
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Programminng
{
    class AOJ_Volume0003
    {
        static void Main(string[] args)
        {
            var values = new int[3];
            int i = int.Parse(Console.ReadLine());

            for (int j = 0; j < i; j++)
            {
                string s = Console.ReadLine();
                string[] _str = s.Split(' ');
                values[0] = int.Parse(_str[0]);
                values[1] = int.Parse(_str[1]);
                values[2] = int.Parse(_str[2]);
                Array.Sort(values);

                if (values[0] * values[0] + values[1] * values[1] == values[2] * values[2])
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
        }
    }
}

Measured memory_bytes: 5604
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> X(5);
    int ans;
    rep(i, 0, 5) {
        cin >> X[i];
        if (!X[i]) {
            ans = i;
        }
    }
    cout << ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 3636
N,K,L = map(int, input().split())

#print(N,K,L,D,T)

class UnionFind:
    def __init__(self, n: int) -> None:
        #マイナスならルートでその深さを表す。プラスならルートのノードを指す。
        self.nodes = [-1]*n

    def find_root(self, x: int) -> int:
        if self.nodes[x] < 0:
            return x
        else:
            self.nodes[x] = self.find_root(self.nodes[x])
            return self.nodes[x]

    def unite(self, x: int, y: int) -> None:
        x, y = self.find_root(x), self.find_root(y)
        #浅い方につなぐ
        if (x != y):
            if (x < y):
                self.nodes[y] += self.nodes[x]
                self.nodes[x] = y
            else:
                self.nodes[x] += self.nodes[y]
                self.nodes[y] = x
        
    # 同じ集合に属するか判定
    #def same_check(self, x, y):
    #    return self.find(x) == self.find(y)

def uniteOne(num, uf):
    for _ in range(num):
        d0, d1 = map(int, input().split())
        uf.unite(d0-1, d1-1)
        
uf_D = UnionFind(N)
uf_T = UnionFind(N)

uniteOne(K, uf_D)
uniteOne(L, uf_T)

pairs = []
for i in range(N):
    pairs.append((uf_D.find_root(i), uf_T.find_root(i)))
 
pairs_count = {}
for p in pairs:
    if not p in pairs_count:
        pairs_count[p] = 1
    else:
        pairs_count[p] += 1
 
res = [0] * N
for i in range(N):
    res[i] = pairs_count[pairs[i]]
#print(*(res[i] for i in range(N)))
print(" ".join([str(i) for i in res]))

Measured memory_bytes: 51744
// Example program
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
string a,b;
cin >> a >> b;
int c = 0;
for(unsigned i = 0; i < a.length() ; ++i){
    if( a[i] != b[i]){
        ++c;
        a[i] = b[i];
}

}
cout << c;
}


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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll A,B,K;
    cin >> A >> B >> K;
    ll cnt = 0;
    for (int i = 0; i < K; i++) {
        if(i % 2 == 0){
            if(A % 2 == 1){
                A--;
            }
            A /= 2;
            B += A;
        } else {
            if(B % 2 == 1){
                B--;
            }
            B /= 2;
            A += B;
        }
    }
    cout << A << " " << B << endl;
}

Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <limits>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
int main()
{
    int N; cin >> N;
    cout << ((N % 10 == 9 || (N / 10) % 10 == 9) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n, k;
    cin >> n >> k;
    vector<int> negative, positive;
    positive.push_back(0);
    for(int i = 0; i < n; ++i){
        int x;
        cin >> x;
        if(x < 0)   negative.push_back(-x);
        else if(x == 0) --k;
        else    positive.push_back(x);
    }
    negative.push_back(0);
    reverse(negative.begin(), negative.end());
    int szn = negative.size(), szp = positive.size();
    int ans = INF;
    for(int i = 0; i <= min(szp - 1, k); ++i){
        if(k - i >= szn)    continue;
        int sum = positive[i] * 2 + negative[k - i];
        // cerr << i << " " << k - i << "  ";
        // cerr << positive[i] << " " << negative[k - i] << " " << sum << endl;
        chmin(ans, sum);
    }
    for(int i = 0; i <= min(szn - 1, k); ++i){
        if(k - i >= szp)    continue;
        int sum = negative[i] * 2 + positive[k - i];
        // cerr << i << " " << k - i << "  ";
        // cerr << negative[i] << " " << positive[k - i] << " " << sum << endl;
        chmin(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1020
#include<stdio.h>

static const int MAX = 500;
static const int INFTY = (1<<21);

main(){
  int n, i, j, e, sum;
  int M[MAX][MAX];
  int u, v;
  int minv;
  int d[MAX];
  int p[MAX];
  int vis[MAX];
  int a=100,b;
  
  b=kansu(a);
  if(b == 100){
  scanf("%d", &n);

  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }

  for ( i = 0; i < n; i++ ) {
    d[i] = INFTY;
    p[i] = -1;
    vis[i] = 0;
  }

  d[0] = 0;

  while(1){
    minv = INFTY;
    u = -1;
    for ( i = 0; i < n; i++ ){
      if ( minv > d[i] && !vis[i] ){
	u = i;
	minv = d[i];
      }
    }
    if ( u == -1 ) break;
    vis[u] = 1;
    for ( v = 0; v < n; v++ ){
      if ( !vis[v] && M[u][v] != INFTY ){
	if ( d[v] > M[u][v] ){
	  d[v] =  M[u][v];
	  p[v] = u;
	}
      }
    }
  }

  sum = 0;

  for ( i = 0; i < n; i++ ){
    if ( p[i] != -1 ) sum += M[i][p[i]];
  }

  print(sum);

  return 0;
}
}
void print(int sum){
  printf("%d\n", sum);
}
int kansu(int a){
 int b=0,c=1;
 if(b == 0);
  if(c == 1);
   return a;
}


Measured memory_bytes: 2032
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    };
    // i + a[i] = j - a[j] (i < j) を満たす (i, j) の個数
    let mut ans = 0_usize;
    let mut m = std::collections::BTreeMap::new();
    for (i, &a_i) in a.iter().enumerate() {
        ans += m.get(&(i as i64 - a_i)).unwrap_or(&0);
        *m.entry(i as i64 + a_i).or_insert(0) += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 11680
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//const ll mod=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
ll a,b,k;
cin>>a>>b>>k;
ll l=max<ll>(0,a-k),r=b;
if(l==0){
    k-=a;
    r=max<ll>(0,r-k);
}
cout<<l<<" "<<r<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long 

int main(){
	int n,x,t;
	cin>>n>>x>>t;
	int kotae=n/x;
	if(n%x!=0)kotae++;
	kotae*=t;
	cout<<kotae<<endl;
	return 0;
}

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


// int main(){
//   long long k ,n,sum=0,max1=0;
//   cin >> k >> n;
//   vector<long long> a(n+1);
  
//   rep(i,n) cin >> a[i];

//   rep(i,n-1){
//       if(i==n-1) max1=max(max1,(a.at(0)+k-a.at(i)));
//       max1=max(max1,a.at(i+1)-a.at(i));
//   }


// cout << k-max1 << endl;


// }
typedef long long ll;
int main() {
    ll K;
    int N;
    cin >> K >> N;
    ll A[N];
    
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    ll e[N];
    for (int i = 0; i < N - 1; i++) {
        e[i] = A[i + 1] - A[i];
    }
    e[N - 1] = K - A[N - 1] + A[0];
    ll v = e[0];
    for (ll i : e) {
        v = max(i, v);
    }
    //cout << v << endl;
    cout << K - v << "\n";
    return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<math.h>
using namespace std;
int main(){
        long n;
        cin>>n;
        int b;
        for(int i =1;i <=sqrt(n);i++){
                if(n%i==0){
                        b=n/i;
                }
        }
        int ans=0;
        for(;b>0;){
                b=b/10;
                ans++;
        }
        cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int n,a,b;
  int trcost;
  cin>>n;
  cin>>a;
  cin>>b;
  trcost=n*a;
  if(trcost<b)
  {
    cout<<trcost;
  }
  else
  {
    cout<<b;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll c(0), _max(0);
    rep(i, 0, s.size())
    {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' ||s[i] == 'T')
        {
            c++;    
        }
        else
            c = 0;

        _max = max(_max, c);
    }

    cout << _max << endl;

    return 0;
}


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

int main() {
  int A, B;
  cin >> A >>B;
  
  int count = 0;
  for (int i = A; i <= B; ++i) {
    int d1, d2, d3, d4, d5, work;
    work = i;
    d5 = work / 10000;
    work %= 10000;
    d4 = work / 1000;
    work %= 1000;
    d3 = work / 100;
    work %= 100;
    d2 = work / 10;
    work %= 10;
    d1 = work / 1;
    if (d5 == d1 && d4 == d2) ++count;
  }
  cout << count << endl;
}

Measured memory_bytes: 3616
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
 
Node root;

Node treeMinimum(Node x){
  while(x->left != NIL)
    {
      x = x->left;
    }
  return x;
}
 
Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key)
    {
      return u;
    }
 
  if(k < u->key)
    {
      return treeSearch(u->left, k);
    }
  else
    {
      return treeSearch(u->right, k);
    }
}
 
Node treeSuccessor(Node x){
  Node y;
 
  if(x->right != NIL)
    {
      return treeMinimum(x->right);
    }
  y = x->parent;

  while(y != NIL && x == y->right)
    {
      x = y;
      y = y->parent;
    }

  return y;
}
 
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
 
  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);
 
  if(y->left != NIL) x = y->left;
  else x = y->right;
 
  if(x != NIL) x->parent = y->parent;
 
  if(y->parent == NIL) root = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;

  if(y != z)
    {
      z->key = y->key;
    }

}
 
void insert(int k){
  Node y = NIL; // parent of x
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x != NIL)
    {
      y = x;
      if(z->key < x->key) x = x->left;
      else x = x->right;
    }
  z->parent = y;
  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z; 
}
 
void inorder(Node u){
  if(u != NIL)
    {
      inorder(u->left);
      printf(" %d", u->key);
      inorder(u->right);
    }
}
 
void preorder(Node u){
  if(u != NIL)
    {
      printf(" %d", u->key);
      preorder(u->left);
      preorder(u->right);
    }
} 
 
int main()
{
  int n, i, x;
  char com[20];
  scanf("%d", &n);
   
  for ( i = 0; i < n; i++ )
    {
      scanf("%s", com);
      if ( com[0] == 'f' )
	{
	  scanf("%d", &x);
	  Node t = treeSearch(root, x);
	  if ( t != NIL ) printf("yes\n");
	  else printf("no\n");
	}
      else if ( com[0] == 'i' )
	{
	  scanf("%d", &x);
	  insert(x);
	} 
      else if ( com[0] == 'p' )
	{
	  inorder(root);
	  printf("\n");
	  preorder(root);
	  printf("\n");
	}
      /* 
      else if ( com[0] == 'd' )
	{
	  scanf("%d", &x);
	  treeDelete(treeSearch(root, x));
	}
      */
    }
   
  return 0;
}

Measured memory_bytes: 19360
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f3f3f3f3fll
using namespace std;
typedef long long ll;
const int N=55;
int n,m,s,a[N][N],b[N][N];
ll dp[N*N*2][N],c[N],d[N],ans[N];
bool vis[N*N*2][N];
struct node
{
    int s,id;
    ll v;
    node(int s=0,ll id=0,ll v=0):s(s),id(id),v(v){}
    bool operator<(const node&o)const
    {
        if(s==o.s) return s>o.s;
        return v>o.v;
    }
};
queue<node>q;
int main()
{
    memset(ans,inf,sizeof(ans));
    memset(a,-1,sizeof(a));
    memset(b,-1,sizeof(b));
    scanf("%d%d%d",&n,&m,&s);
    for(int i=1;i<=m;i++)
    {
        int u,v,A,B;scanf("%d%d%d%d",&u,&v,&A,&B);
        a[u][v]=a[v][u]=A;
        b[u][v]=b[v][u]=B;
    }
    for(int i=1;i<=n;i++) scanf("%lld%lld",&c[i],&d[i]);
    memset(dp,inf,sizeof(dp));
    s=min(s,n*50*2);
    dp[s][1]=0;
    q.push(node(s,1,dp[s][1]));
    vis[s][1]=true;
    while(!q.empty())
    {
        int s=q.front().s,i=q.front().id;q.pop();
        ans[i]=min(ans[i],dp[s][i]);
        vis[s][i]=false;
        int up=min(s+(int)c[i],n*50*2);
        if(dp[up][i]>dp[s][i]+d[i])
        {
            dp[up][i]=dp[s][i]+d[i];
            if(!vis[up][i])
                q.push(node(up,i,dp[up][i])),vis[up][i]=true;
        }
        for(int j=1;j<=n;j++)
        {
            if(a[i][j]==-1||s<a[i][j]) continue;
            int up=s-a[i][j];
            if(dp[up][j]>dp[s][i]+b[i][j])
            {
                dp[up][j]=dp[s][i]+b[i][j];
                if(!vis[up][j]) vis[up][j]=true,q.push(node(up,j,dp[up][j]));
            }
        }
    }
    for(int i=2;i<=n;i++) printf("%lld\n",ans[i]);
}


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

int main() {
    ll n, d;
    cin >> n >> d;
    int ans = 0;
    rep(i,n){
        ll x, y;
        cin >> x >> y;
        if(d*d >= x*x + y*y){
            ans++;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int x, y;
	cin >> x >> y;
	rep (i, x + 1) {
	  int r = i * 2 + (x - i) * 4;
	  if (r == y) {
		cout << "Yes" << endl;
		return 0;
	  }
	}
	cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 3640
// #pragma GCC optimize "trapv" Uncomment when dealing with huge numbers
/*<----------PBDS---------->

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
template <typename T>
using order_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

order_set<datatype>oset;
Kth smallest : *oset.find_by_order(k-1); // 0 based index
No of elements less than k : oset.order_of_key(k);
Erase X : oset.erase(x)
<----------PBDS---------->*/
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define pb(x) push_back(x)
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define lcm(a,b) (a*b)/gcd(a,b)
#define bits(x) __builtin_popcountll(x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
	fast;
	int n;
	cin >> n;
	int a[n];
	map<int,int>mp;
	for(int i = 0 ; i < n ; i++ ){
		cin >> a[i];
		mp[a[i]]++;
	}
	int ans = 0;
	for(auto p : mp){
		ans = ans+(p.second*(p.second-1))/2;
	}
	int ans1 = ans;
	for(int i = 0 ; i < n ; i++ ){
		int val = a[i];
		int k = mp[val];
		ans1 = ans-(k*(k-1))/2;
		mp[val]--;
		k = mp[val];
		ans1 +=(k*(k-1))/2;
		cout << ans1 << "\n";
		mp[val]++;
	}
}





Measured memory_bytes: 11136
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////


///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
	int n, k;
	cin >> n >> k;
	double ans = 0;
	
	for(int i = 1; i <= n; i++){
		double temp = 1.0 / n;
		int one = i;
		while(one < k){
			one *= 2;
			temp /= 2;
		}
		ans += temp;
	}
	
	cout << setprecision(12) << fixed << ans << endl;


	
	
	
	return 0;
}


Measured memory_bytes: 256
/***
        ***Fresher***
    Md Mahfujur Rahman Khan
    Dept. of CSE
    CSE-28 Batch
    JU-48 Batch
    Jahangirnagar University

***/
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<set>
#include<map>
#include<climits>
#include<numeric>
#include<utility>
using namespace std;
#define V_ vector
#define Q_ queue
#define S_ set
#define ST_ stack
#define M_ map
#define DQ_ deque
/***PAIR***/
#define pii pair<ll,ll>
#define pci pair<char,ll>
#define psi pair<string, ll>
#define pis pair<ll,string>
#define pic pair<ll, char>
/***MAP***/
#define mii map<ll,ll>
#define msi map<string, ll>
#define mis map<ll, string>
#define mib map<ll,bool>
#define msb map<string,bool>
#define mci map<char, ll>
/***VECTOR***/
#define vi vector<ll>
#define vs vector<string>
/***ITERASTORS***/
#define ivi vector<ll> :: iterator
#define ivs vector<string> :: iterator
#define imii map<ll,ll> :: iterator
#define imsi map<string,ll> :: iterator
#define imis map<ll, string> :: iterator
#define imib map<ll, bool> :: iterator
#define imsb map<string, bool> :: iterator
#define imci map<char, ll> :: iterator
/*** FAST ***/
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/***FUNCTIONS AND MACROS***/
#define F first
#define S second
#define M_P(x, y) make_pair(x, y)
#define PB(x) push_back(x)
#define PP(x) push(x)
#define RSZ(n) resize(n)
#define POB pop_back()
#define P_ pop()
#define CL_ clear()
#define LEN_ length()
#define SZ_ size()
#define CNT(x) count(x)
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second
#define B_ begin()
#define E_ end()
#define F_ front()
#define t_ top()
#define IN_ insert
#define ER_  erase
#define GT(x) getline(cin , x)
#define NL_   "\n"
#define SP_ " "
#define R_0 return 0
#define R_ return

#define ul unsigned long long int
#define ll long long int
/***
//prime fact
#define most_prime_loop 10001
#define most_prime_number 20000010
#define prime_MAX_arr 20000010/2
ll PRIME[prime_MAX_arr];
void seive()
{
    PRIME[0] = 0;
    for(auto &x: PRIME )
        x = 1;
    for(ll i= 3; i <= most_prime_loop; i+=2)
    {
        for(ll j = i*i; j <= most_prime_number; j+=2*i)
            PRIME[j/2] = 0;
    }
}
***/
#define fr(i, n) for( ll i = 0; i < n; i++)
#define fe(x, n) for( ll i = x; i <= n; i++)
#define fa(x,a)    for(auto &x : a)

#define pi acos(-1)

#define SR(x) sqrt(x)
#define IC   (ll)

const ll  inf = 1000000000;
ll i=0, T=0, N=0, tc =0, t= 0;
ll n=0, k=0;

int main()
{
 ll a, b;
 cin >> a >> b;
 ll i= 10;
 while(b/i > 0)
 {
     i*=10;
 }
 a*= i;
 a+=b;
 if(sqrt(a)==(ll)sqrt(a)) cout <<"Yes";
 else cout <<"No";
    R_0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int Nmax = 1e5 + 5;

vector <int> c;

int a[Nmax];
int pos[Nmax];
int b[Nmax];
int maxx[Nmax];
int T[Nmax];
int num[Nmax];
int ans[Nmax];
int n,N;

void updatesum(int i, int val)
{
    while (i <= N)
    {
        T[i] += val;
        i += i & -i;
    }
}

int getsum(int i)
{
    int res = 0;
    while (i > 0)
    {
        res += T[i];
        i -= i & -i;
    }
    return res;
}

void updatenum(int i, int val)
{
    while (i <= N)
    {
        num[i] += val;
        i += i & -i;
    }
}

int getnum(int i)
{
    int res = 0;
    while (i > 0)
    {
        res += num[i];
        i -= i & -i;
    }
    return res;
}

signed main()
{
    //freopen("file.inp","r",stdin);
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        c.push_back(a[i]);
    }
    sort(c.begin(), c.end());
    for (int i = 0; i < c.size(); i++)
    {
        if (c[i] != b[N]) b[++N] = c[i];
    }
    for (int i = 1; i <= n; i++)
    {
        int l = 1;
        int r = N + 1;
        while (r - l > 1)
        {
            int mid = (l + r) >> 1;
            if (b[mid] <= a[i]) l = mid;
            else r = mid;
        }
        pos[i] = l;
        updatesum(pos[i], a[i]);
        updatenum(pos[i], 1);
        maxx[i] = max(pos[i], maxx[i - 1]);
    }
    for (int i = 1; i <= n; i++)
    {
        if (maxx[i - 1] >= pos[i]) continue;
        ans[i] += (a[i] - b[maxx[i - 1]]) * (getnum(N) - getnum(pos[i] - 1));
        int x = getsum(pos[i] - 1) - getsum(maxx[i - 1]);
        int y = b[maxx[i - 1]] * (getnum(pos[i] - 1) - getnum(maxx[i - 1]));
        ans[i] += x - y;
        updatesum(pos[i], -a[i]);
        updatenum(pos[i], -1);
    }
    for (int i = 1; i <= n; i++)
    {
        cout << ans[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 7412
import unittest


def solve(h1, m1, h2, m2, k):
    return (h2-h1)*60+(m2-m1) - k


def main():
    h, m, h2, m2, k = map(int, input().split())
    result = solve(h, m, h2, m2, k)
    print(result)


class Test(unittest.TestCase):
    def test_solve(self):
        self.assertEqual(1, 1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 16112
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    B = sorted(A)
    M1 = B[-1]
    M2 = B[-2]
    for a in A:
        if a == M1:
            print(M2)
        else:
            print(M1)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 65244
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();
		System.out.println(Math.min(A, B) + " " +Math.max(0, A + B - N));
	}
}

Measured memory_bytes: 21972
n=int(input())
l=[]
while n!=1 and n!=0:
  l.append(abs(n)%2)
  if n>0:
    n=-n
    n//=(-2)
    n=-n
  elif n<0:
    n=abs(n)
    n//=(-2)
    n=-n
l.append(n)
l=l[::-1]
ans=str()
for i in l:
  ans+=str(i)
print(ans)

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

using namespace std;
int n;
int a[1005];
int gcd(int a,int b)
{
    return b==0?a:gcd(b,a%b);
}
int main()
{
    int sum1=1,sum2=0;
    double ans=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
    {
        sum1=sum1*a[i]/gcd(sum1,a[i]);
    }
    for(int i=1;i<=n;i++)
    {
        sum2=sum2+sum1/a[i];
    }
    ans=1.0*sum1/sum2;
    printf("%.10f",ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// Still trying to be normal
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e17 + 9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    ll mod[2019];
    ll mod2[2019];
    memset(mod,0,sizeof mod);
    memset(mod2,0,sizeof mod2);
    mod[0]=1;
    ll num1=0,num2=0;
    ll ans=0;
    rep(i,0,sz(s)){
        rep(j,0,2019){
            int ant=mod[j];
            mod2[j*10%2019]+=ant;
        }
        rep(j,0,2019){
            mod[j]=mod2[j];
            mod2[j]=0;
        }
        num1=num1*10%2019;
        num1=(num1+(s[i]-'0'))%2019;
        // cout<<num1<<endl;
        ans+=mod[num1];
        mod[num1]++;
    }
    cout<<ans<<'\n';
    return 0;   
}

Measured memory_bytes: 3772
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count=0;
		while(sc.hasNextLine()){
			String str = sc.nextLine();
			StringBuffer s = new StringBuffer(str);
			s = s.reverse();
			if(str.equals(s.toString())) count++;
		}
		System.out.println(count);
	}
}



Measured memory_bytes: 26068
#include<stdio.h>
#include<stdlib.h>
#include<memory.h>
#include<math.h>

int sprInput(char *retstr, char *str, int strnum)
{
	char buf[256]={};
	int h, i, j;

	i = 0;
	for(h=0;h<strnum;h++){
		memset(buf, '\0', sizeof(buf));
		j = 0;
		if (str[i] == '\0') break;
		while(str[i] != ' ' && str[i] != '\n' && str[i] != '\0')
		{
			buf[j] = str[i];
			i++;
			j++;
		}
		i++;
	}
	memcpy(retstr, buf, sizeof(buf));

	return (retstr[0] == '\0' ? 0 : 1);
}

int main(int argc, char *argv[])
{
	int sInput;
	int a, b;
	char str[256]={};
	char buf[256]={};

	fgets(str, 256, stdin);

	sprInput(buf, str, 1);
	a = atoi(buf);
	sprInput(buf, str, 2);
	b = atoi(buf);

	if (a == b) {
		printf("a == b\n");
	}
	else if (a < b) {
		printf("a < b\n");
	}
	else {
		printf("a > b\n");
	}

	return 0;
}

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

#define int long long int
const int mxN = 2e5+10;
vector<int> g[mxN];
int indeg[mxN], len[mxN], n, m;

int dfs(int u) {
    if(len[u] != -1)
        return len[u];
    
    for(auto v: g[u])
        len[u] = max(len[u], dfs(v));
    
    len[u] = len[u]+1;
    return len[u];
}   

void solve() {
    int x, y;
    cin >> n >> m;
    for(int i=0; i<m; i++) {
        cin >> x >> y;
        --x, --y;
        g[x].push_back(y);          // x ---> y
        ++indeg[y];
    }

    int ans = 0;
    memset(len, -1, sizeof(len));
    for(int i=0; i<n; i++)
        if(indeg[i] == 0)
            ans = max(ans, dfs(i));

    cout << ans << endl;
}

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

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

inline int In(){
	char c=getchar(); int x=0,ft=1;
	for(;c<'0'||c>'9';c=getchar()) if(c=='-') ft=-1;
	for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';
	return x*ft;
}

const int N=2e5+5;
int n,h[N],e_tot=0;
struct Edge{
	int to,nex;
	Edge(){}
	Edge(int to,int nex):to(to),nex(nex){}
}e[N<<1];

inline void add(int u,int v){
	e[++e_tot]=Edge(v,h[u]); h[u]=e_tot;
}

int sz[N],cnt[N],fac[N],inv[N];

void dfs(int u,int pre){
	sz[u]=1;
	for(int i=h[u],v;i;i=e[i].nex){
		v=e[i].to; if(v==pre) continue;
		dfs(v,u); sz[u]+=sz[v];
	}
	if(u!=1) ++cnt[sz[u]],++cnt[n-sz[u]];
}

const int P=924844033;
int L,C,r[N<<2],F[N<<2],G[N<<2],H[N<<2];

inline void Add(int& x,int y){
	x+=y; if(x>=P) x-=P;
}

inline int Mul(int x,int y){
	return 1ll*x*y%P;
}

inline int fpow(int x,int k){
	int res=1;
	for(;k;k>>=1,x=Mul(x,x)) if(k&1) res=Mul(res,x);
	return res;
}

inline void NTT_prepare(int len){
	for(L=1,C=0;L<=len;L<<=1,++C);
	for(int i=0;i<L;++i) r[i]=(r[i>>1]>>1)|((i&1)<<(C-1));
}

void NTT(int* A,int op){
	for(int i=0;i<L;++i) if(i<r[i]) swap(A[i],A[r[i]]);
	for(int i=1;i<L;i<<=1){
		int Wn=fpow(5,(P-1)/(i<<1));
		if(op==-1) Wn=fpow(Wn,P-2);
		for(int j=0;j<L;j+=i<<1){
			int w=1;
			for(int k=0;k<i;++k,w=Mul(w,Wn)){
				int p=A[j+k],q=Mul(w,A[j+i+k]);
				A[j+k]=(p+q)%P; A[j+i+k]=((p-q)%P+P)%P;
			}
		}
	}
	if(op==-1){
		int inv_L=fpow(L,P-2);
		for(int i=0;i<L;++i) A[i]=Mul(A[i],inv_L);
	}
}

int main(){
	n=In();
	for(int i=1,u,v;i<n;++i){
		u=In(); v=In();
		add(u,v); add(v,u);
	}
	dfs(1,0); fac[0]=inv[0]=inv[1]=1;
	for(int i=1;i<=n;++i) fac[i]=Mul(fac[i-1],i);
	for(int i=2;i<=n;++i) inv[i]=Mul(P-P/i,inv[P%i]);
	for(int i=1;i<=n;++i) inv[i]=Mul(inv[i-1],inv[i]);
	for(int i=0;i<=n;++i) G[i]=Mul(cnt[i],fac[i]);
	for(int i=0;i<=n;++i) H[i]=inv[n-i];
	NTT_prepare(n+n); NTT(G,1); NTT(H,1);
	for(int i=0;i<L;++i) F[i]=Mul(G[i],H[i]); NTT(F,-1);
	for(int i=1;i<=n;++i){
		int res=Mul(n,Mul(fac[n],Mul(inv[i],inv[n-i])));
		Add(res,P-Mul(inv[i],F[n+i])); printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 29696
#include<bits/stdc++.h>
using namespace std;
int h,w,col;
char mp[600][600],a[600][600],b[600][600];
int main()
{
    scanf("%d%d",&h,&w);
    for(int i=1;i<=h;i++)
        scanf("%s",mp[i]+1);
    memset(a,'.',sizeof(a));
    memset(b,'.',sizeof(b));
    col=0;
    for(int i=1;i<=h;i++)
    {
        col=1-col;
        if(col)
        {
            for(int j=1;j<=w;j++)
            {
                a[i][j]='#';
                if(mp[i][j]=='#') b[i][j]='#';
            }
        }
        else
        {
            for(int j=1;j<=w;j++)
            {
                b[i][j]='#';
                if(mp[i][j]=='#') a[i][j]='#';
            }
        }
    }
    for(int i=1;i<=h;i++)
    {
        printf("#");
        for(int j=2;j<w;j++)
            printf("%c",a[i][j]);
        printf(".");
        puts("");
    }
    puts("");
    for(int i=1;i<=h;i++)
    {
    	printf(".");
        for(int j=2;j<w;j++)
            printf("%c",b[i][j]);
        printf("#");
        puts("");
    }
}

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

typedef long long lli;
const int MAX = 100;
int a[MAX][MAX][MAX];

int main(){
  int n,m;
  while(cin >> n >> m){
    lli v[50][6], ans = 0;
    vector<lli> v2[3];
    set<lli> s[3];
    map<lli,int> v3[3];
    for(int i=0;i<n;i++){
      for(int j=0;j<6;j++){
        cin >> v[i][j];
        s[j%3].insert(v[i][j]);
      }
    }

    for(int i=0;i<MAX;i++) for(int j=0;j<MAX;j++) for(int k=0;k<MAX;k++) a[i][j][k] = 0;
    for(int i=0;i<3;i++){
      for(set<lli>::iterator it = s[i].begin(); it != s[i].end(); it++){
        v2[i].push_back(*it);
        v3[i][*it] = v2[i].size()-1;
      }
    }

    for(int i=0;i<n;i++)
      for(int j=v3[0][v[i][0]];j<v3[0][v[i][3]];j++)
        for(int k=v3[1][v[i][1]];k<v3[1][v[i][4]];k++)
          for(int l=v3[2][v[i][2]];l<v3[2][v[i][5]];l++)
            a[j][k][l]++;

    for(int i=0;i<MAX-1;i++)
      for(int j=0;j<MAX-1;j++)
        for(int k=0;k<MAX-1;k++)
          if(a[i][j][k] >= m)
            ans += (v2[0][i+1]-v2[0][i]) * (v2[1][j+1]-v2[1][j]) * (v2[2][k+1]-v2[2][k]);

    cout << ans << endl;
  }
}

Measured memory_bytes: 5160
#!/usr/bin/env python3
import sys
import math


def solve(X: int):
    ans = 100
    cnt = 0
    while ans < X:
        ans += math.floor(ans * 0.01)
        cnt += 1
    print(cnt)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


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

namespace ConsoleApp111 {
    class Program {
        static void Main(string[] args)
        {
            int[] input = new int[6];
            for(int i = 0; i < 6; i++)
            {
                input[i] = int.Parse(Console.ReadLine());
            }

            bool trueOrFalse = true;
            for (int i = 0; i < 5; i++)
            {
                int kyori = 0;
                for(int j = 0; j < 5; j++)
                {
                    kyori = input[j + 1] - input[i];
                    if(kyori > input[5])
                    {
                        trueOrFalse = false;
                    }
                }
            }
            if(trueOrFalse == true)
            {
                Console.WriteLine("Yay!");
            } else
            {
                Console.WriteLine(":(");
            }
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define INFTY 10000000000
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
using ipair = pair<ll,ll>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int main(){
  string s,t,ans;
  cin>>s>>t;
  int ok = 0;
  int sz = s.length(),tz = t.length();
  reverse(s.begin(),s.end());
  reverse(t.begin(),t.end());
  rep(i,sz-tz+1){
    if(s[i]==t[0]||s[i]=='?'){
      int ch = 1;
      rep(j,tz){
        if(s[i+j]!=t[j]&&s[i+j]!='?')ch = 0;
      }
      if(ch){
        rep(j,tz){
        if(s[i+j]=='?')s[i+j] = t[j];
        }
        ok=1;break;
      }
    }
  }
  
  if(ok){
    rep(j,sz){
    if(s[j]=='?')s[j] = 'a';
    }
    reverse(s.begin(),s.end());
    cout<<s;
  }
  else cout<<"UNRESTORABLE"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <stack>

using namespace std;

int main()
{
	stack<int> st;
	int in;

	while (~scanf("%d", &in)){
		if (in) st.push(in);
		else {
			printf("%d\n", st.top());
			st.pop();
		}
	}

	return (0);
}

Measured memory_bytes: 1036
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>

#define F first
#define S second

using namespace std;

typedef pair<int,int> P;
const int MAX = 101;
int N;
vector<P> V;

int dp[MAX][MAX];

int rec(int l, int r){

  if(dp[l][r] != -1) return dp[l][r];
  if(l+1 == r) return dp[l][r] = V[l].F*V[l].S*V[r].F*V[r].S;
  if(l == r) return dp[l][r] = 0;

  for(int c = l; c < r; c++){
    if(dp[l][r] == -1) dp[l][r] = rec(l,c)+rec(c+1,r)+V[l].F*V[c].S*V[c+1].F*V[r].S;
    else dp[l][r] = min(dp[l][r], rec(l,c)+rec(c+1,r)+V[l].F*V[c].S*V[c+1].F*V[r].S);
  }
  return dp[l][r];
}

int main(){
  memset(dp,-1,sizeof(dp));
  cin >> N;
  V.resize(N);
  for(int i = 0; i < N; i++) cin >> V[i].first >> V[i].second;
  cout << rec(0,N-1) << endl;
  return 0;
}

Measured memory_bytes: 1252
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) assert(type(default_val) ~= 'table') local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
-----------------------
local X, N = read.nn()
local P = {}
for i=1,N do
    P[read.n()] = true
end
local ans = -1
local best = math.abs(ans - X)
for i=0,101 do
    if P[i] then
    else
        if math.abs(i - X) < best then
            ans = i
            best = math.abs(i - X)
        end
    end
end
print(ans)

Measured memory_bytes: 2800
n = int(input())
h = list(map(int,input().split()))
b = []
inf = 10**10
start = 0
end = 0
ans = 0

for ii in range(inf):
    if max(h) == 0:
        break

    while h[0] == 0:
        del h[0]

    for i in range(len(h)):
        if h[i] == 0:
            end = i
            #print(b)
            break
        end = len(h)
        b.append(h[i])

    #print(b)
    sa = min(b)
    b.clear()
    #print(sa)

    for j in range(end):
        h[j] = h[j] - sa
        #print(h)

    ans = ans + sa
        

print(ans)


Measured memory_bytes: 3064