akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>
#include <map>
using namespace std;

typedef long long ll;

// vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

map<int, vector<int>> goods;
int values[4][101];
int W;
int w0;

int limit(int w) {
  if (goods.find(w) == goods.end()) return 0;
  else return goods[w].size();
}

int value(int i, int j, int k, int l) {
  int ret = 0;
  ll w = 0;
  w += (ll)i*w0;
  w += (ll)j*(w0+1);
  w += (ll)k*(w0+2);
  w += (ll)l*(w0+3);
  if (w > (ll)W) return 0;
  ret += values[0][i];
  ret += values[1][j];
  ret += values[2][k];
  ret += values[3][l];
  return ret;
}

int main() {
  int n;
  cin >> n >> W;
  for (int i = 0; i < n; ++i) {
    int w, v;
    cin >> w >> v;
    if (i == 0) w0 = w;
    goods[w].push_back(v);
  }
  for (auto it: goods) {
    int w = it.first;
    vector<int> &g = it.second;
    sort(g.begin(), g.end(), greater<int>());
    int v = 0;
    for (int i = 0; i < g.size(); ++i) {
      values[w-w0][i+1] = values[w-w0][i] + g[i];
    }
  }
  int ans = 0;
  for (int i = 0; i <= limit(w0); ++i) {
    for (int j = 0; j <= limit(w0+1); ++j) {
      for (int k = 0; k <= limit(w0+2); ++k) {
        for (int l = 0; l <= limit(w0+3); ++l) {
          int v = value(i, j, k, l);
          ans = max(ans, v);
        }
      }
    }
  }
  cout << ans << endl;
}



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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  VL a(n), b(n+1, 0), c(n+1, 0);
  rep(i, n){
    cin >> a[i];
  }
  rep(i, n) {
    b[i+1] = b[i] + a[i];
    c[i+1] = c[i] + max<ll>(0, a[i]);
  }
  ll ans = -LINF;
  for(int i = 0; i + k <= n; ++i) {
    ll left = c[i] - c[0];
    ll right = c[n] - c[i + k];
    if(b[i + k] - b[i] >= 0) {
      ans = max<ll>(ans, b[i + k] - b[i] + left + right);
    }
    else {
      ans = max<ll>(ans, left + right);
    }
  }
  out(ans);

  return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>
#include <cmath>
#include <limits>

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


int main() {
    int n;
    cin >> n;
    int ans = n * (n + 1) / 2;
    cout << ans << endl;
}


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

#include <iostream>
 
int main(void)
{
    std::string S;
    std::cin >> S;

    std::map<char, int64_t> map;

    for (auto&& c : S) {
        map[c]++; 
    }

    for (auto it = map.begin(); it != map.end(); ++it) {
        if (it->second != 2) {
            std::cout << "No" << std::endl;
            return 0;
        }
    }

    std::cout << "Yes" << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(void) {
    long X, n, money;
    std::cin >> X;
    
    money = 100;
    
    for(n = 0; money < X; n++) {
        money *= 1.01;
    }
    
    std::cout << n << std::endl;
    
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define count count1
#define NIL -1
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
// std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
// int myRand(int R) {
// 	int val=rng() % R;
//       assert(val>=0);
//       return val;
// }
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=3e18;
const int32_t LOG=21;
const int32_t MOD=MOD1;

int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      { 
           int x;
           cin>>x;
           cout<<x+x*x+x*x*x<<endl;
      }
      return 0;                         
}

/*
 TIPS:
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



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

#define all(x) (x).begin(),(x).end()

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin>>s;
  rep(i,s.length()){
    cout<<"x";
  }
  cout<<endl;
  return 0;

}


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

using namespace std;

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  vector<vector<int>> G(n);
  for (int i=0; i<n-1; i++) {
    G.at(i).push_back(i+1);
    G.at(i+1).push_back(i);
  }
  G.at(x-1).push_back(y-1);
  G.at(y-1).push_back(x-1);
  
  vector<int> cnt(n, 0);
  for (int i=0; i<n; i++) {
    vector<int> dis(n, 1e8);
    dis.at(i) = 0;
    queue<int> que;
    que.push(i);
    while (!que.empty()) {
      int cur = que.front(); que.pop();
      for (int nex : G.at(cur)) {
        if (dis.at(nex) > dis.at(cur) + 1) {
          dis.at(nex) = dis.at(cur) + 1;
          que.push(nex);
        }
      }
    }
    for (int j=0; j<n; j++) {
      cnt.at(dis.at(j))++;
    }
  }
  
  for (int i=1; i<n; i++) {
    cout << cnt.at(i) / 2 << endl;
  }
  
  return 0;
}


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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int C[N - 1], S[N - 1], F[N - 1];
	rep(i, 0, N - 1) cin >> C[i] >> S[i] >> F[i];

	rep(i, 0, N - 1) {
		ll tmp = C[i] + S[i];
		rep(j, i + 1, N - 1) {
			if(tmp >= S[j]) {
				if(tmp % F[j] == 0) tmp += C[j];
				else tmp += (C[j] + (F[j] - tmp % F[j]));
			} else {
				tmp = S[j] + C[j];
			}
		}
		cout << tmp << endl;
	}

	cout << 0 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int H,W;
	cin >> H >> W;
	V<string> s(H);
	rep(i,H) cin >> s[i];
	int inf = 1e9;
	VV<int> d(H,V<int>(W,inf));
	queue<int> qx,qy;
	rep(i,H) rep(j,W) if(s[i][j] == '#'){
		d[i][j] = 0;
		qx.push(i);
		qy.push(j);
	}
	V<int> dx = {1,0,-1,0};
	V<int> dy = {0,1,0,-1};
	while(!qx.empty()){
		int x = qx.front(), y = qy.front();
		qx.pop();qy.pop();
		rep(dd,4){
			int nx = x + dx[dd], ny = y + dy[dd];
			if(0<=nx&&nx<H&&0<=ny&&ny<W && d[nx][ny] == inf){
				d[nx][ny] = d[x][y] + 1;
				qx.push(nx);qy.push(ny);
			}
		}
	}
	int mx = 0;
	rep(i,H) rep(j,W) chmax(mx,d[i][j]);
	cout << mx << endl;
}


Measured memory_bytes: 13440
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=100005;
//i_am_noob
int a,b,c;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> a >> b >> c;
	print3(c,a,b);
	return 0;
}


Measured memory_bytes: 256
fn main() {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  let nm = s.trim().split_whitespace().map(|e|e.parse::<i32>().unwrap()).collect::<Vec<i32>>();
  if nm.first().unwrap() <= nm.last().unwrap() {
    println!("Yes")
  } else {
    println!("No")
  }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n, k;
	cin >> n >> k;
	
	vector<int> ng(10, 0);
	for(int i = 0; i < k; ++i) {
		int a;
		cin >> a;
		ng[a] = 1;
	}
	
	for(int i = n; i < 100000; ++i) {
		int tmp = i;
		bool ok = true;
		
		while( tmp ) {
			if( ng[tmp % 10] == 1 ) {
				ok = false;
				break;
			}
			
			tmp /= 10;
		}
		
		if( ok && n <= i ) {
			cout << i << endl;
			break;
		}
	}
	
	return 0;
}


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


int main() {
    int N, Y;
    cin >> N >> Y;
    
    int flag = false;
    for(int i=0; i<=N; i++){
      for(int j=0; j<=N-i; j++){
        int k = N - i - j;
        if(10000*i + 5000*j + 1000*k == Y){
          cout << i << " " << j << " " << k << endl;
          return 0;
        }
      }
    }
    
    cout << "-1 -1 -1" << endl;
}

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

int main() {
  int a, b, c, d;
  
  cin >> a >> b >> c >> d;
  if ((a + b) > (c + d))
    cout << "Left" << endl;
  else if ((a + b) == (c + d))
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
}

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

using namespace std;

int main() {
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int a,b;
	char o;
	
	cin >> a >> o >> b;
	
	switch(o){
		case '+':
			cout << a+b << '\n';
			break;
		case '-':
			cout << a-b << '\n';
			break;
	}
	
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = [int(a) for a in input().split()]    
L = [2, 5, 5, 4, 5, 6, 3, 7, 6]
B = [[A[i], L[A[i]-1]] for i in range(M)]

best = sorted(B, key = lambda x: x[1]*10-x[0])[0]

adj = 0
if N > 500:
    adj = (N - 500)//best[1]
    N -= best[1] * adj

X = [0] + [-10**9] * N
for i in range(1, N+1):
    if i > 50 and i < N-50:
        X[i] = X[i-best[1]]*10 + best[0]
    else:
        for b in B:
            if b[1] <= i:
                if X[i-b[1]] == 0:
                    X[i] = max(X[i], b[0])
                else:
                    X[i] = max(X[i], X[i-b[1]]*10 + b[0])

ans = str(X[N])
if adj > 0:
    ans = ans[:50] + str(best[0]) * adj + ans[50:]

print(ans)

Measured memory_bytes: 3064
import numpy as np
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


a,b = map(int,input().split())
gcd = gcd(a ,b)
print(len(np.unique(prime_decomposition(gcd)))+1)

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

template <typename InputIterator>
typename InputIterator::value_type
summation(InputIterator first, InputIterator last) {
  using T = typename InputIterator::value_type;
  T *p = new T();
  const auto sum = std::accumulate(first, last, *p);
  delete p;
  return sum;
}
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t h, w;
  std::cin >> h >> w;

  std::vector<std::vector<bool>> a(h, std::vector<bool>(w, false));

  for (int64_t i = 0; i < h; i++) {
    for (int64_t j = 0; j < w; j++) {
      char c;
      std::cin >> c;
      if (c == '#') {
        a[i][j] = true;
      } else {
        a[i][j] = false;
      }
    }
  }

  std::set<std::pair<int64_t, int64_t>> q1, tmp;

  for (int64_t i = 0; i < h; i++) {
    for (int64_t j = 0; j < w; j++) {
      if (a[i][j]) {
        if (0 < i && !a[i - 1][j]) {
          q1.insert({i - 1, j});
        }

        if (0 < j && !a[i][j - 1]) {
          q1.insert({i, j - 1});
        }

        if (i < h - 1 && !a[i + 1][j]) {
          q1.insert({i + 1, j});
        }

        if (j < w - 1 && !a[i][j + 1]) {
          q1.insert({i, j + 1});
        }
      }
    }
  }

  int64_t c = 0;
  while (!q1.empty()) {
    c++;

    for (const auto &i : q1) {
      a[i.first][i.second] = true;
    }

    for (const auto &p : q1) {
      const auto i = p.first;
      const auto j = p.second;
      if (0 < i && !a[i - 1][j]) {
        tmp.insert({i - 1, j});
      }

      if (0 < j && !a[i][j - 1]) {
        tmp.insert({i, j - 1});
      }

      if (i < h - 1 && !a[i + 1][j]) {
        tmp.insert({i + 1, j});
      }

      if (j < w - 1 && !a[i][j + 1]) {
        tmp.insert({i, j + 1});
      }
    }
    q1.clear();
    std::swap(q1, tmp);
  }
  std::cout << c << std::endl;
  return 0;
}

Measured memory_bytes: 41856
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl

int main() {
    ll n; cin >> n;
    ll sum = 0;
    ll N = n;
    while(N!=0){
        int d = N%10;
        sum += d;
        N /= 10;
    }

    if(n%sum == 0){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}


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

int main() {
    int n,k;cin>>n>>k;
    pair<int,int> a[n];
    for (int i=0;i<n;i++) {
        int b,c;cin>>b>>c;
        b--;
        a[i]={c,b};
    }
    sort(a,a+n,greater<pair<int,int>>());
    int used[n]{};
    stack<int> dup;
    ll sum=0;
    ll c=0;
    for (int i=0;i<k;i++) {
        sum+=a[i].first;
        if (used[a[i].second])
            dup.push(a[i].first);
        else {
            used[a[i].second]=1;
            c++;
        }
    }
    ll mx=sum+c*c;
    for (int i=k;i<n;i++)
        if (!used[a[i].second]&&dup.size()) {
            sum-=dup.top();
            dup.pop();
            sum+=a[i].first;
            used[a[i].second]=1;
            c++;
            mx=max(mx,sum+c*c);
        }
    cout<<mx<<endl;
    return 0;
}

Measured memory_bytes: 1536
from collections import Counter

n = int(input())
s = []
for i in range(n):
    s.append(input())

cnt = Counter(s).most_common()

res = [cnt[0][0]]
if len(cnt) > 1:
    for i in range(1, n):
        if cnt[i-1][1] == cnt[i][1]:
            res.append(cnt[i][0])
        else:
            break

res.sort()
print('\n'.join(res))


Measured memory_bytes: 45084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[100500][3];
void solve() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}
	int x = 0, y = 0, t = 0;
	for (int i = 0; i < n; i++) {
		int time = a[i][0] - t;
		int s = abs(x - a[i][1]) + abs(y - a[i][2]);
		if (time == s || (time > s && (time - s) % 2 == 0)) {
			t = a[i][0];
			x = a[i][1];
			y = a[i][2];
		}
		else {
			cout << "No";
			return;
		}
	}
	cout << "Yes";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	for (int i = 1; i <= t; i++) {
		solve();
	}
}

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

int main() {
  string S;
  cin >> S;
  int start;
  long sum, ans;
  ans = 0;
  for(int bit = 0; bit < (1 << S.size() - 1); bit++) {
    start = 0;
    sum = 0;
    for(int i = 0; i < S.size() - 1; i++) {
      if(bit & (1 << i)) {
        sum += stol(S.substr(start, i - start + 1));
        start = i + 1;
      }
    }
    sum += stol(S.substr(start));
    ans += sum;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
N=int(input())
ans=1
S=[1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, \
   100, 121, 125, 128, 144, 169, 196, 216, 225, \
   243, 256, 289, 324, 343, 361, 400, 441, 484, \
   512, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1000]
    
i=0
while S[i] <= N:
    i+=1
    if len(S)<=i:
        break
    
print(S[i-1])

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
    void InsertSort(int arr[],int n);
    void show(int arr[],int n);
    int n;
    cin>>n;
    int *arr = new int[n+1];
    for(int i = 0;i<n;i++)
        cin>>arr[i];
    show(arr,n);
    InsertSort(arr,n);
    return 0;
}
void show(int arr[],int n)
{
    for(int i = 0;i< n;i++)
    {
        cout<<arr[i];
        if(i<n-1)
            cout<<" ";
    }
    cout<<endl;
}
void InsertSort(int arr[],int n)
{
    int temp,j;
    for(int i = 1;i<n;i++)//下标是从0开始！
    {
        temp = arr[i];
        j = i - 1;
        while(j>=0&&arr[j]>temp)
        {
            arr[j+1] = arr[j];
            j--;
        }
        arr[j+1] = temp;
        show(arr,n);
    }
}



Measured memory_bytes: 3076
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   char s[3][3];
   for(int i = 0; i < 3; i++){
      for(int j = 0; j < 3; j++){
         cin >> s[i][j];
      }
   }
   cout << s[0][0] << s[1][1] << s[2][2] << endl;

   return 0;
}

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

signed main() {
  string S, T;
  cin >> S >> T;
  
  map<char, char> hikaku;
  for( int i = 0; i < S.size(); i++ ){
    if( hikaku.count(S.at(i)) ){ //以前にその文字が出てきていたら
      if( hikaku.at(S.at(i)) != T.at(i) ){
        cout << "No" << endl;
        return 0;
      }
    }else{
      hikaku[S.at(i)] = T.at(i);
    }
  }
  
  map<char, char> hikaku2;
  for( int i = 0; i < T.size(); i++ ){
    if( hikaku2.count(T.at(i)) ){
      if( hikaku2.at(T.at(i)) != S.at(i) ){
        cout << "No" << endl;
        return 0;
      }
    }else{
      hikaku2[T.at(i)] = S.at(i);
    }
  }
  
  cout << "Yes" << endl;
}



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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }



int n,m;
bool b[101010];
int c[101010];
void solve(){
	cin >> n >> m;
	b[1] = 1;
	fill(c,c+n+1,1);
	for(int i = 0; i < m; i++){
		int x,y;
		cin >> x >> y;
		if(b[x]) b[y] = 1;
		c[x]--; c[y]++;
		if(!c[x]) b[x] = 0;
	}
	
	int cnt = 0;
	for(int i = 1; i <= n; i++){
		cnt += b[i];
	}
	cout << cnt << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 768
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    s: chars,
  }
  let mut ans = true;
  for (i, &c) in s.iter().enumerate() {
    if i % 2 == 0 {
      if c == 'L' {
        ans = false;
        break;
      }
    } else {
      if c == 'R' {
        ans = false;
        break;
      }
    }
  }

  puts!("{}\n", if ans { "Yes" } else { "No" });
}


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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

vector<int> a, ans;
vector<int> g[201010];

int dp[201010];

void dfs(int v, int p=-1) {
    int i = lower_bound(dp, dp + 201010, a[v]) - dp;
    int old = dp[i];
    dp[i] = a[v];
    ans[v] = i;
    if (p != -1) ans[v] = max(ans[v], ans[p]);
    for (int u : g[v]) {
        if (u == p) continue;
        dfs(u, v);
    }
    dp[i] = old;
}

int main() {
    int n;
    cin >> n;
    a = ans = vector<int>(n);
    rep(i, n) cin >> a[i];
    rep(i, n-1) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    fill(dp, dp+201010, INF);
    dp[0] = -INF;
    dfs(0);

    rep(i, n) cout << ans[i] << endl;
}


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

int main() {
  int N, A, B, C;
  cin >> N >> A;
  B = N/500;
  C = N-B*500;

  if (A >= C) {
    cout << "Yes" << endl;
  }
  else {
      cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import math

res_x, res_y = 0, 0
r = 90
while 1:
    x, y = list(map(int, input().split(',')))
    if x == 0 and y == 0:
        break
    r2 = math.radians(r)
    res_x += x * math.cos(r2)
    res_y += x * math.sin(r2)
    r = r - y

print(int(res_x))
print(int(res_y))

Measured memory_bytes: 7932
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#define MIN -1000000
using namespace std;
typedef long long ll;
typedef pair <int, int> pll;
bool visited[100005];
const int max_N = 1e5 + 10;

int a, b, c, d, e, k;


int main(void) {
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;
	cin >> e;
	cin >> k;

	if(e-a>k)	cout << ":(" << endl;
	else cout << "Yay!" << endl;


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int cnt=0;
  for(int i=0;i<n;i++){
    int a;cin >> a;
    if(a%2==1){
      cnt++;
    }
  }
  if(cnt%2==0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lines = line.split(" ");

		int A = Integer.parseInt(lines[0]);
		int P = Integer.parseInt(lines[1]);

		System.out.println((3 * A + P) / 2);
	}

}


Measured memory_bytes: 35792
(function underscore(undefined) {
	'use strict';
	var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;

	var push = ArrayProto.push,
	slice = ArrayProto.slice,
	concat = ArrayProto.concat,
	toString = ObjProto.toString,
	hasOwnProperty = ObjProto.hasOwnProperty;

	var nativeForEach = ArrayProto.forEach,
	nativeMap = ArrayProto.map,
	nativeReduce = ArrayProto.reduce,
	nativeReduceRight = ArrayProto.reduceRight,
	nativeFilter = ArrayProto.filter,
	nativeEvery = ArrayProto.every,
	nativeSome = ArrayProto.some,
	nativeIndexOf = ArrayProto.indexOf,
	nativeLastIndexOf = ArrayProto.lastIndexOf,
	nativeIsArray = Array.isArray,
	nativeKeys = Object.keys,
	nativeBind = FuncProto.bind;

	this._ = {};
	var each = _.each = _.forEach = function(obj, iterator, context) {
		if (obj == null) return;
		if (nativeForEach && obj.forEach === nativeForEach) {
			obj.forEach(iterator, context);
		} else if (obj.length === +obj.length) {
			for (var i = 0, l = obj.length; i < l; i++) {
				if (iterator.call(context, obj[i], i, obj) === breaker) return;
			}
		} else {
			for (var key in obj) {
				if (_.has(obj, key)) {
					if (iterator.call(context, obj[key], key, obj) === breaker) return;
				}
			}
		}
	};

	_.extend = function(obj) {
		each(slice.call(arguments, 1), function(source) {
			if (source) {
				for (var prop in source) {
					obj[prop] = source[prop];
				}
			}
		});
		return obj;
	};
}).call(global);

(function(undefined){
	'use strict';

	var INPUT_TYPE = 'number';

	var Solver = {
		fire: function() {
			setTimeout( Solver.solve, 0, this );
		},
		solve: function solve() {
			var n = input_number();
			var res = 0;
			for ( var a = 0; a <= 9; ++ a ) {
				for ( var b = 0; b <= 9; ++ b ) {
					for ( var c = 0; c <= 9; ++ c ) {
						for ( var d = 0; d <= 9; ++ d ) {
							if ( a + b + c + d === n )
								res ++;
						}
					}
				}
			}
			output(res);
			if ( ! has_next() )
				setTimeout( Solver.solve, 0, this );
		}
	};

	(function init() {
		_.extend( this, {
			output: function() {
				console.log.apply( console, arguments );
			},
			stdin: process.openStdin(),
			input_list: [],
			input_number: function() {
				return parseInt( input_list.splice(0,1)[0] );
			},
			input_text: function() {
				return input_list.splice(0,1)[0];
			},
			has_next: function() {
				return ! input_list.length;
			}
		} );

		var INPUT_REGEXP_LIST = {};
		INPUT_REGEXP_LIST['string'] = /\w*/g;
		INPUT_REGEXP_LIST['number'] = /[-]?\d+/g;
		var INPUT_REGEXP = INPUT_REGEXP_LIST[INPUT_TYPE];

		stdin.setEncoding('utf8');
		stdin.on('data', function(chunk){
			var result = chunk.match(INPUT_REGEXP);
			input_list = input_list.concat(result.filter(function(line){
				return line.length;
			}));
		});
		stdin.on('end', function(){
			Solver.fire.call(this);
		});
	}).call( this );

}).call(global);

Measured memory_bytes: 9140
X, N = map(int, input().split())

try:
    p = list(map(int, input().split()))
except EOFError:
    print(X)
    exit()

i = 0
while True:
    tmp1 = X - i
    tmp2 = X + i

    if tmp1 not in p:
        print(tmp1)
        exit()
    if tmp2 not in p:
        print(tmp2)
        exit()

    i += 1

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

int main(void){
   int H1,M1,H2,M2,K;
   cin>>H1>>M1>>H2>>M2>>K;
   int ans=(H2-H1)*60+(M2-M1)-K;
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#undef int
#define mk make_pair
#define pb push_back
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;
const long long INFL = 1000000000000000018ll;

int N;
double p[3030], q[3030], dp[3030][3030];

signed main()
{
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> p[i];
        q[i] = 1.0 - p[i];
    }
    dp[0][0] = 1.0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j <= N; j++){
            dp[i + 1][j] += dp[i][j] * q[i];
            if(j > 0){
                dp[i + 1][j] += dp[i][j - 1] * p[i];
            }
        }
    }
    double ans = 0.0;
    for(int i = N; i > N / 2; i--){
        ans += dp[N][i];
    }
    printf("%.10lf\n", ans);


    return 0;
}
/*



*/



Measured memory_bytes: 71936
fun main() {
    var (x, k, d) = readLine()!!.split(" ").map { it.toLong() }
    when {
        // xが正の時
        x > 0L -> {
            val a = x / d
            if (k >= a) {
                x -= (d * a)
                if ((k - a) % 2L == 0L) {
                    println(x)
                } else {
                    println(-(x - d))
                }
            } else {
                x -= (d * k)
                println(x)
            }
        }
        x < 0L -> {
            val b = - (x / d)
            if (k >= b) {
                x += (d * b)
                if ((k - b) % 2L == 0L) {
                    println(-x)
                } else {
                    println(x + d)
                }
            } else {
                x += (d * k)
                println(-x)
            }
        }
        x == 0L -> {
            if (k % 2L == 0L) {
                println(0)
            } else {
                println(d)
            }
        }
    }
}

Measured memory_bytes: 36396
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  int no_of_input,input;
  cin >> no_of_input;
  vector<int> vect1(no_of_input+1,0);
  for(int i=0;i<no_of_input;i++){
    cin >> input;
    vect1[input] = i+1;
  }
  for(int i=1;i<vect1.size();i++){
    cout << vect1[i] << ' ';
  }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int main(void){
    string S;
    cin >> S;

    for(int i = 0; i < 1<<3; i++){
        int sum = S[0] - '0';
        for(int j = 0; j < 3; j++){
            int num = S[j + 1] - '0';
            if(i & 1<<j) sum += num;
            else sum -= num;
        }

        if(sum == 7){
            cout << S[0];
            for(int j = 0; j < 3; j++){
                if(i & 1<<j) cout << '+';
                else cout << '-';

                cout << S[j+1];
            }
            cout << "=7" << '\n';
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f first
#define se second
#define pb push_back
#define pf push_front
#define eb emplace_back
#define emp emplace
#define ins insert
#define sz(s) (int)s.size()
#define rep(i,a,b) for( int i=a;i<b;i++)
#define repr(i,a,b) for( int i=a;i>=b;i--)
#define bitcount __builtin_popcount
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(n,m) memset(n,m,sizeof(n))
#define ii pair<int,int>
#define iii tuple<int, int, int>
#define si set<int>
#define vi vector<int>
#define vii vector<ii>
#define mi map<int,int>
#define lb lower_bound
#define ub upper_bound
#define present(s,x) (s.find(x) != s.end())
#define ford(container, it) for(auto it:container)
#define fors(container, it, a, b) for(auto it = a; it != b; it++)
#define Anurag_Gupta ios_base::sync_with_stdio(0);
#define IIIT_ALLD cin.tie(0);cout.tie(0);
#define mod 987654319
#define EPSILON 1e-9
#define PI acos(-1)
#define inf 1e17
#define int long long
#define debug(a) cerr<<#a<<": ";for(auto i:a)cerr<<i<<" ";cerr<<'\n';
#define trace(a) cerr<<#a<<": "<<a<<"\n"
#define gcd(a,b) __gcd(a,b)
using namespace std;
int add(int a, int b, int c){int res=a+b;return(res>=c?res-c:res);}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
int mul(int a, int b, int c){int res=(int)a*b;return(res>=c?res%c:res);}
template<typename T>T power(T e, T n){T x=1,p=e;while(n){if(n&1)x=x*p;p=p*p;n>>=1;}return x;}
template<typename T>T mdpower(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
/*------------------------------------------------------------------------------------------------------------------*/

int32_t main()
{
    Anurag_Gupta
    IIIT_ALLD
 
   
  
    string s;
    cin>>s;

    if(s[0]=='7' or s[1]=='7' or s[2]=='7')
    cout<<"Yes\n";
    else cout<<"No\n";

 






 
#ifndef LOCAL_DEFINE
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}


Measured memory_bytes: 3796
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;
const double PI=3.141592;
int main(){
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  int K, A, B;
  cin >> K >> A >> B;
  if (B % K == 0 || A % K == 0 || B / K > A / K) {
    cout << "OK" << endl;
  } else {
    cout << "NG" << endl;
  }
  return 0;

}



Measured memory_bytes: 3648
#include <stdio.h>


int main(void)
{
	int S, h, m, s, a;
	
	scanf("%d", &S);
	
	h = S / 3600;
	
	a = S % 3600;
	
	m = a / 60;
	
	s = a % 60;
	
	printf("%d:%d:%d\n", h, m, s);
	
	
	return 0;
}

Measured memory_bytes: 1800
<?php
fscanf(STDIN, '%d %d', $a, $b);
$ans = lcm($a, $b);
echo $ans . PHP_EOL;

// 最大公約数（2つ）
function gcd($m, $n)
{
    if (!$n) return $m;
    return gcd($n, $m % $n);
}

// 最大公約数（3つ以上）
function gcdAll($arr)
{
    $gcd = $arr[0];
    for ($i = 0; $i < count($arr); $i++) {
        $gcd = gcd($gcd, $arr[$i]);
    }
    return $gcd;
}

// 最小公倍数（2つ）
function lcm($m, $n)
{
    return $m * $n / gcd($m, $n);
}

// 最小公倍数（3つ以上）
function lcmAll($arr)
{
    $lcm = $arr[0];
    for ($i = 0; $i < count($arr); $i++) {
        $lcm = lcm($lcm, $arr[$i]);
    }
    return $lcm;
}

Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	string a, b; cin >> a >> b;
	int na = a.size(), nb = b.size();
	if(na != nb){
		cout << "No" << endl;
		return 0;
	}else if(a == b){
		cout << "Yes\n";
		return 0;
	}
	for(int i = 0; i < na; i++){
		string s1 = a.substr(0, i);
		string s2 = a.substr(i);
		string s3 = b.substr(nb - i);
		string s4 = b.substr(0, nb - i);
		if(s1 == s3 && s2 == s4){
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
N, M = [int(i) for i in input().split()]
pS = {}

for _ in range(M):
    a, s = [i for i in input().split()]
    if a not in pS:
        pS[a] = {}
        if s == 'AC':
            pS[a]['AC'] = True
        else:
            pS[a]['count'] = 1
    else:
        if s == 'AC':
            pS[a]['AC'] = True
        elif 'AC' not in pS[a]:
            pS[a]['count'] += 1

s = 0
a = 0
for v in pS.values():
    if 'AC' in v and 'count' in v:
        s += v['count']
    if 'AC' in v:
        a += 1
    
print(a, s)

Measured memory_bytes: 44452
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string ans = "";
    for (int i = 0; i < 9; i++)
    {
        char c;
        cin >> c;
        if (i == 0 || i == 4 || i == 8)
        {
            ans += c;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>

using namespace std;

void disp_map (vector <vector <int> > m )
{
	int n = m.size();
	int i,j;

	for (i = 0; i < n; ++i){
		for (j = 0; j < n; ++j){
			cout << setw(2) << m[i][j];
		} // end for
		cout << endl;
	} // end for
	cout << endl;
}

int main()
{
	string str = "";

	while (getline (cin, str ) ){
		int n;
		stringstream ssn(str);
		ssn >> n;

		if (n == 0){
			break;
		} // end if	

		vector <vector <int> > dp (n, vector <int> (n, INT_MAX ) );
		
		int i,j;
		for (i = 0; i < n; ++i){
			getline (cin, str );
			for (j = 0; j < str.length(); ++j){
				if (str[j] == '*'){
					dp[i][j] = 0;
				}else if (i == 0 || j == 0){
					dp[i][j] = 1;
				} // end if
			} // end for
		} // end for
	
		for (i = 1; i < n; ++i){
			for (j = 1; j < n; ++j){
				if (dp[i][j] != 0){
					dp[i][j] = min (min (dp[i-1][j], dp[i][j-1]), dp[i-1][j-1] ) + 1;
				} // end if
			} // end for
		} // end for

		int res = 0;
		for (i = 0; i < n*n; ++i){
			if (dp[i/n][i%n] != INT_MAX){
				res = max (res, dp[i/n][i%n]);
			} // end if
		} // end for

		cout << res << endl;

	} // end while 

	return 0;
}

Measured memory_bytes: 3308
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;

ll calc(ll now,int a,int b,int c){
    if(now>n) return 0;
    int res = ( a > 0 && b > 0 && c > 0);
    res+=calc(now*10+3,a+1,b,c);
    res+=calc(now*10+5,a,b+1,c);
    res+=calc(now*10+7,a,b,c+1);
    return res;  
}

int main(){

    cin>>n;
    cout<<calc(0,0,0,0)<<endl;
    return 0;

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ss = Console.ReadLine().Split();
            var x = int.Parse(ss[0]);
            var a = int.Parse(ss[1]);
            var b = int.Parse(ss[2]);

            if (b <= a)
                Console.WriteLine("delicious");
            else if (b <= a + x)
                Console.WriteLine("safe");
            else
                Console.WriteLine("dangerous");
        }
    }
}

Measured memory_bytes: 11092
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int s,w;
  cin>>s>>w;
  cout<<(w>=s?"unsafe":"safe")<<endl;

  return 0;
}




Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));		
		String test = br.readLine();
		
		String[] res1 = test.split(" ");
		
		String c = null;
		
		if(Integer.parseInt(res1[0]) > Integer.parseInt(res1[1])){
			c = res1[0];
			res1[0] = res1[1];
			res1[1] = c;
		}
		
		if(Integer.parseInt(res1[1]) > Integer.parseInt(res1[2])){
			c = res1[1];
			res1[1] = res1[2];
			res1[2] = c;	
		}
		
		if(Integer.parseInt(res1[0]) > Integer.parseInt(res1[1])){
			c = res1[0];
			res1[0] = res1[1];
			res1[1] = c;
		}
		System.out.println(res1[0] + " " + res1[1] + " " + res1[2]);
	}
}

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

const int MOD = 1000000007;

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int A, P;
    cin >> A >> P;
    cout << (3 * A + P) / 2 << endl;
}

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

int INF = (1 << 30);

int N, M;
string str[10101];

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		cin >> str[i];
	}

	int C[10101];

	for (int i = 0; i < N; ++i) {
		int count = 0;
		for (int j = 0; j < M; ++j) {
			count += str[j][i] == 'W' ? 1 : 0;
		}
		C[i] = count;
	}


	int dif = 0; for (int i = 0; i < N; ++i) { dif += C[i]; }

	int ret = 0;
	int min_dif = dif;

	for (int i = 0; i < N; ++i) {
		dif += M - 2 * C[i];
		if (dif < min_dif) {
			min_dif = dif;
			ret = i + 1;
		}
	}
	cout << ret << ' ' << ret + 1 << endl;
	return 0;
}

Measured memory_bytes: 4688
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl '\n'
#define ld long double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
 
/*
░░░░░░░░░░░░░░░░░░░░░░░░░
░░█▀▀▄░░░░░░░░░░░▄▀▀█░░░░
░░█░░░▀▄░▄▄▄▄▄░▄▀░░░█░░░░
░░░▀▄░░░▀░░░░░▀░░░▄▀░░░░░
░░░░░▌░▄▄░░░▄▄░▐▀▀░░░░░░░
░░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█░
░░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█░
░▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█░
░█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀░
░░▀▄░░▀░░▀▀▀░░▀░░░▄█▀░░░░
░░░░█░░░░░░░░░░░▄▀▄░▀▄░░░
░░░░█░░░░░░░░░▄▀█░░█░░█░░
░░░░█░░░░░░░░░░░█▄█░░▄▀░░
░░░░█░░░░░░░░░░░████▀░░░░
░░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░
*/
 
// I want to be the very best, like no one ever was, I will battle everyday to claim my rightful place
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
// I am questioning life and universe and 
// everything else after looking at this

const ll MAXN = 1e5 + 10;
const ll LOG_A = 61;
ll a[MAXN];
ll basis[LOG_A];

void insertVector(ll mask){
    
    for(ll i=LOG_A-1;i>=0;i--){
        if((mask&(1LL<<i)) == 0) continue;
        if(basis[i] == 0){
            basis[i] = mask;
            return;
        }
        mask ^= basis[i];
    }
}

void solve(){
    ll n; cin>>n;
    ll ans = 0;
    FOR(i,1,n) cin>>a[i];

    FOR(bit,0,LOG_A-1){
        ll cnt = 0;
        ll val = (1LL<<bit);
        FOR(i,1,n){
            if((a[i]&val)) cnt++;
        }
        
        if(cnt&1){
            FOR(i,1,n){
                if((a[i]&val)) a[i] = a[i]^val;
            }

            ans += val;
        }
    }

    FOR(i,1,n) insertVector(a[i]);

    ll max_val = 0;

    for(ll i=LOG_A-1;i>=0;i--){
        if(basis[i] == 0) continue;
        if((max_val&(1LL<<i))) continue;
        max_val = max_val^basis[i];
    }

    ans = ans + max_val*2;
    cout<<ans<<endl;
}   

signed main(){
 
   FastRead;    


    ll t;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 1024