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

int a[110];

int main() {
	int n,x;
	cin >> n >> x;
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a,a+n);
	int ans = 0;
	for (int i = 0; i < n; i++) if (a[i] <= x) {
		ans++;
		x -= a[i];
	}
	if (ans == n && x > 0) ans--;
	cout << ans << "\n";
}

Measured memory_bytes: 256
import sys
from decimal import Decimal

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    A, B = map(Decimal, readline().split())
    print(int(A * B))

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 71340
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define deb(x) cout<<#x<<" "<<x<<endl;
#define print(arr,n) for(int i=0;i<n;++i) { cout<<arr[i]<<" "; } cout<<endl;
#define ub(x,el) upper_bound(x.begin(),x.end(),el) - x.begin()
#define lb(x,el) lower_bound(x.begin(),x.end(),el) - x.begin();
#define bs(x,el) binary_search(x.begin(),x.end(),el)
#define MOD 1000000007
#define finish return 0
#define all(x) x.begin(),x.end()
using namespace std;
using namespace __gnu_pbds; 
typedef long long int ll;
typedef tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
template<int D, typename T> struct Vec : public vector<Vec<D - 1, T>> { static_assert(D >= 1, "Vector dimension must be greater than zero!"); template<typename... Args> Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) { }}; template<typename T> struct Vec<1, T> : public vector<T> { Vec(int n = 0, T val = T()) : vector<T>(n, val) { } };
inline ll mod(ll x) { return (x%MOD + MOD)%MOD; }
ll gcd(ll a, ll b, ll &x, ll &y){if(a == 0){x = 0, y = 1; return b;} ll x1, y1;  ll d = gcd(b%a, a, x1, y1); x = y1 - (b/a) * x1; y = x1; return d;}
ll power(ll x,ll y, ll p) { ll res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res*x) % p; y = y>>1; x = (x*x) % p;   } return res; } 
ll power(ll x,ll y) { ll res = 1; while (y > 0) { if (y & 1) res = (res*x); y = y>>1; x = (x*x);   } return res; } 
ll mod(ll num, ll den){ return mod(mod(num) * power(den,MOD-2,MOD)); }
ll n,m,x;
vector<ll> c;
vector< vector<ll> > arr;
void bt(ll i, vector<ll> &temp, ll &ans, ll cost)
{
    if(i>=n)
    {
        bool ok = true;
        //print(temp,temp.size());
        for(auto j:temp)
        {
            if(j<x) 
            {
                ok = false;
                break;
            }
        }
        if(ok) ans = min(ans, cost);
        return;

    }
    for(ll j=0;j<m;++j)
    {
        temp[j]+=arr[i][j];
    }
    bt(i+1,temp,ans,cost+c[i]);
    for(ll j=0;j<m;++j)
    {
        temp[j]-=arr[i][j];
    }
    bt(i+1,temp,ans,cost);
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cin>>n>>m>>x;
    c.resize(n);
    arr.resize(n, vector<ll>(m));
    for(ll i=0;i<n;++i)
    {
        cin>>c[i];
        for(ll j=0;j<m;++j)
        {
            cin>>arr[i][j];
        }
    }
    ll ans = INT_MAX;
    vector<ll> temp(m);
    bt(0,temp,ans,0);
    if(ans>=INT_MAX) cout<<-1<<endl;
    else cout<<ans<<endl;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e5;
const int size=1e5;
const int inf=1e9;
int main(){
	int N;cin>>N;
	int P[N],Q[N];
	rep(i,0,N) cin>>P[i];
	rep(i,0,N) cin>>Q[i];
	int A[N];
	rep(i,0,N) A[i]=i+1;
	int a,b;int j=1;
	do{
		bool flag=true;
		rep(i,0,N){
			if(A[i]!=P[i]) flag=false;
		}if(flag) a=j;
        flag=true;
		rep(i,0,N){
			if(A[i]!=Q[i]) flag=false;
		}if(flag) b=j;
		j++;
	}while(next_permutation(A,A+N));
	cout<<abs(a-b)<<endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll from;
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RES(a, n) (a).resize(n)
#define VLCIN(a, n) REP(i,n){cin >> a[i];}
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = (ll)pow(10,7);
/****** define constant end ********/
/****** define variable start ******/
ll n;
/******* define variable end *******/
ll binary_search(ll a, ll b, ll c, ll y){
	ll i = y, j = 100;
	while(j >= i){
		ll m = floor((i + j) / 2);
		if(m * m + a * m + b == c){
			return m;
		}else if(m * m + a * m + b > c){
			j = m - 1;
		}else{
			i = m + 1;
		}
	}
	return -1;
}

int solve() {
	cin >> n;
	for(ll i = 1; i <= n; i++){
		ll ans = 0;
		for(ll x = 1; x <= 100; x++){
			for(ll y = x; y <= 100; y++){
				ll z = binary_search(x + y, x * x + y * y + x * y, i, y);
				if(z == -1){
					continue;
				}
				if(x == y){
					if(y == z){
						ans++;
					}else{
						ans += 3;
					}
				}else{
					if(y == z){
						ans += 3;
					}else{
						ans += 6;
					}
				}
			}
		}
		cout << ans << "\n";
	}
	return 0;
}
int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 3572
n = int(input())

felicidade = []

for x in range(n):
    felicidade.append(list(map(int,input().split())))

dp = []

dp.append([felicidade[0][0],felicidade[0][1],felicidade[0][2]])

for i in range(n-1):
    dp.append([0,0,0])


for dia in range(1,n):
    dp[dia][0] = felicidade[dia][0] + max(dp[dia-1][1], dp[dia-1][2])
    dp[dia][1] = felicidade[dia][1] + max(dp[dia-1][0],dp[dia-1][2])
    dp[dia][2] = felicidade[dia][2] + max(dp[dia-1][0], dp[dia-1][1])


print(max(dp[n-1]))


Measured memory_bytes: 100680
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
struct node{
	int s,v;
}Node;
bool cmp(node a,node b){
	if(a.v!=b.v)return a.v<=b.v;
	else return a.s<b.s;
}
int main() {
	int n,m,a,b,now=0;
	
	long long value=0;
	scanf("%d %d",&n,&m);
	vector<node> ve;
	for(int i=0;i<n;i++){
		scanf("%d %d",&Node.v,&Node.s);
		ve.push_back(Node);
	}
	sort(ve.begin(),ve.end(),cmp);
//	for(int i=0;i<ve.size();i++){
//		printf("%d: v:%d s:%d\n",i,ve[i].s,ve[i].v);
//	}
//	printf("ve.size:%d\n",ve.size());
	for(int i=0;i<n;i++){
		if(now+ve[i].s>=m){
			value+= (long long)(m-now)*ve[i].v;
			break;
		}else{
			value+=(long long)ve[i].s*ve[i].v;
			now+=ve[i].s;
		}
	}
	printf("%lld\n",value);
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T> bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
    for (auto &e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n), b(m), sum(n + 10);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum[i + 1] = sum[i] + a[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    sort(all(a));
    sort(all(b));
    ll tmp = 0, ans = 0;
    for (int i = 0; i < m; i++) {
        if (i > 0 && b[i] == b[i - 1]) {
            ans += tmp;
            continue;
        }
        ll s = 0;
        for (ll j = 0; j <= 200000 / b[i]; j++) {
            int l = lower_bound(all(a), b[i] * j) - a.begin();
            int r = lower_bound(all(a), b[i] * (j + 1)) - a.begin();
            s += (sum[r] - sum[l]) - (r - l) * b[i] * j;
        }
 //       cout << s << endl;
        ans += s;
        tmp = s;
    }
    cout << ans << endl;
}



Measured memory_bytes: 7532
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

int N;

int main(void){
    
    scanf("%d", &N);
    ll ans = 1;
    for(int i = 1; i <= N; ++i) ans *= i, ans %= MOD;
    printf("%lld\n", ans);
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
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;
  cin>>s>>t;
  ll n=sz(s);
  vll ss(n);
  vll tt(n);
  vll a(26);
  rep(i,n){
    ss[i]=s[i]-'a';
    tt[i]=t[i]-'a';
    if(ss[i]==tt[i]){
      a[ss[i]]=1;
    }
  }
  vector<pll> p(n);
  vector<pll> pp(n);
  rep(i,n){
    p[i]=make_pair(ss[i],tt[i]);
    pp[i]=mp(tt[i],ss[i]);
  }
  sort(all(p));
  sort(all(pp));
  ll cu=1;
  rep(i,n-1){
    if(p[i].F==p[i+1].F){
      if(p[i].S==p[i+1].S){
        continue;
      }
      cu=0;
    }
  }
  
  rep(i,n-1){
    if(pp[i].F==pp[i+1].F){
      if(pp[i].S==pp[i+1].S){
        continue;
      }
      cu=0;
    }
  }
  if(cu) COUT("Yes");
  else COUT("No");
}


Measured memory_bytes: 10120
#include<stdio.h>
int main(void){
	int num,a[100],moto,sum=0,smallmoto=100000,num2;
	scanf("%d %d",&num,&moto);
	for(int i=0;num>i;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
		if(smallmoto>a[i]){
		smallmoto=a[i];
		}
	}
	moto-=sum;
	num2=num;
	num2+=moto/smallmoto;
	printf("%d",num2);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <utility>

typedef long long ll;
typedef unsigned long long ull;

#define vi std::vector<int>
#define vl std::vector<ll>
#define floop(n) for(int i = 0; i < n; ++i)
#define print(x) std::cout << x << std::endl;

const ll INF = 1e18;
const ll MOD = 1e9+7;

ll gcd(ll a, ll b) { return a == 0 ? b : gcd(b%a, a); }
ll mod(ll a) { return a % MOD < 0 ? (a % MOD) + MOD : a % MOD; }
ll mod_add(ll a, ll b) { return (a%MOD + b%MOD) % MOD; }
ll mod_sub(ll a, ll b) { return mod((a%MOD - b%MOD) % MOD); }
ll mod_mul(ll a, ll b) { return (a%MOD * b%MOD) % MOD; }
ll mod_pow(ll a, ll b) 
{
    if(b == 0) return 1;
    ll p = mod_pow(a, b/2) % MOD;
    p = mod_mul(p, p);
    return (b%2 == 0) ? p : mod_mul(a, p);
}
ll mod_inv(ll a) { return mod_pow(a, MOD-2); }
ll mod_div(ll a, ll b) { return a%MOD * mod_inv(b) % MOD; }


int main()
{
    int N, u, v, w, x, y, z, res = 0;
    std::cin >> N;

    floop(N)
    {
        if(i == 0)
            std::cin >> u >> v;
        else if(i == 1)
            std::cin >> w >> x;
        else
        {
            std::cin >> y >> z;
            if(u == v && w == x && y == z)
                res++;
            
            u = w;
            v = x;
            w = y;
            x = z;
        }
    }

    if(res > 0)
    {
        print("Yes");
    }
    else
    {
        print("No");
    }
    
    return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
using namespace std;
typedef long long int_;
inline int readint(){
	int x; scanf("%d",&x); return x;
}

const int MaxN = 200005;
map<int,int> cnt;

int main(){
	int n = readint();
	int_ ans = 0;
	for(int i=1,a; i<=n; ++i){
		a = readint();
		ans += cnt[i-a];
		cnt[i+a] ++;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 20788
#include<bits/stdc++.h>
#define ALL(V) V.begin(), V.end()
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;

ll N, M;
ll need[] = {
    0, 2, 5, 5, 4, 5, 6, 3, 7, 6,
};
V<ll> A;
ll cnt = 0;
V<ll> ans;

void dfs(ll now, V<ll> v) {
    if(now == M) {
        ll needm = 0;
        ll dig = 0;
        for(ll i = 1; i <= 9; i++) {
            dig += v[i];
            needm += need[i] * v[i];
        }
        if(needm > N) return;
        ll rest = N - needm;
        if(rest % need[A[0]]) return;
        dig += rest / need[A[0]];
        v[A[0]] = rest / need[A[0]];
        if(dig > cnt) {
            cnt = dig;
            ans = v;
        } else if(dig == cnt) {
            for(ll j = 9; j >= 1; j--) {
                if(v[j] > ans[j]) {
                    ans = v;
                    return;
                }else if(v[j] < ans[j]) {
                    return;
                }
            }
        }
        return;
    }
    for(ll i = 0; i < need[A[0]]; i++) {
        v[A[now]] = i;
        dfs(now + 1, v);
    }
}

int main() {
    cin >> N;
    ll cnt = 0;
    cin >> M;
    A = V<ll>(M);
    for(ll &a : A) cin >> a;
    sort(ALL(A), [&](ll a, ll b){
            if(need[a] != need[b]) return need[a] < need[b];
            else return a > b;
            });
    dfs(1, V<ll>(10));
    for(ll i = 9; i >= 1; i--) for(ll j = 0; j < ans[i]; j++) cout << i;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
ld dp[303][303][303];
int n;
int v[4];

ld search(int a, int b, int c) {
    if (a < 0 || b < 0 || c < 0) {
        return 0;
    }
    if (a == 0 && b == 0 && c == 0) {
        return 0;
    }
    if (dp[a][b][c] > 0) {
        return dp[a][b][c];
    }
    ld ce = (a + b + c) * 1.0 / n;
    ld e = 1 / ce;
    ld t = e;
    t += a * 1.0 / (a + b + c) * search(a - 1, b, c);
    t += b * 1.0 / (a + b + c) * search(a + 1, b - 1, c);
    t += c * 1.0 / (a + b + c) * search(a, b + 1, c - 1);
    return dp[a][b][c] = t;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        v[a[i]]++;
    }
    ld r = search(v[1], v[2], v[3]);
    cout << fixed << setprecision(12) << r << endl;

    return 0;
}


Measured memory_bytes: 432384
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL =LONG_LONG_MAX;
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};

template< typename T >
using Edges =vector< edge<T> >;
template< typename T >
using WeightedGraph =vector< Edges<T> >;
using UnWeightedGraph =vector< vector<int> >;
template< typename T >
using Matrix =vector< vector<T> >;

template< typename T >
///与えられた隣接行列を用いてワーシャルフロイド法によりノード間最短距離を求める。閉路がある場合、ループ後にg[k][k] < 0なるノードkが存在

///gでエッジのない部分をINFにしておくことを忘れないように！

void warshall_floyd(Matrix< T > &g, T INF) {
    for(int k = 0; k < g.size(); k++) {
        for(int i = 0; i < g.size(); i++) {
            for(int j = 0; j < g.size(); j++) {
                if(g[i][k] == INF || g[k][j] == INF) continue;
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
            }
        }
    }
}

int main() {
    int h,w;cin>>h>>w;
    Matrix<int> c(10);
    rep(i,10)c[i].resize(10);
    cin>>c;
    
    warshall_floyd(c,1<<20);
    ll ans = 0;
    
    for(auto i = 0; i<h;i++){
        for(auto j = 0; j<w;j++){
            
            int a;cin>>a;
            if(a==-1)continue;
            ans += c[a][1];
            
        }
    }
    cout<<ans<<endl;
    
    return 0;
}










Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
typedef struct nodetag {
    unsigned int key;
    struct nodetag *next;
    struct nodetag *prev;
} Node;
 
Node *createNode(int key)
{
    Node *node = malloc(sizeof(Node));
    node->key = key;
    node->next = node->prev = NULL;
 
    return node;
}
 
void insert(Node *node, Node **head, Node **tail)
{
    if(*tail == NULL || *head == NULL) {
        node->next = node->prev = NULL;
        *head = *tail = node;
    } else {
        (*tail)->next = node;
        node->prev = *tail;
        node->next = NULL;
        *tail = node; 
    }
}
 
void delete(int key, Node **head, Node **tail)
{
    Node *node = *tail;
 
    while(node != NULL && node->key != key) {
        node = node->prev;
    }
    if(node == NULL)
        return;
    if(node->prev == NULL) {
        (node->next)->prev = NULL;
        *head = node->next;
    } else if(node->next == NULL) {
        (node->prev)->next = NULL;
        *tail = node->prev;
    } else {
        (node->prev)->next = node->next;
        (node->next)->prev = node->prev;
    }
    free(node);
}
 
void deleteFirst(Node **head, Node **tail)
{
    Node *node = *tail;
 
    if(tail == NULL)
        return;
 
    *tail = (*tail)->prev;
    if(*tail == NULL) {
        *head = NULL;
        free(node);
        return;
    }
    (*tail)->next = NULL;
    free(node);
}
 
void deleteLast(Node **head, Node **tail)
{
    Node *node = *head;
 
    if(node == NULL)
        return;
 
    *head = (*head)->next;
    if(*head == NULL) {
        *tail = NULL;
        free(node);
        return;
    }
    (*head)->prev = NULL;
    free(node);
}
 
int main(void)
{
    int i, n, key;
    char command[11];
    Node *tail = NULL, *head = NULL, *node;
 
    scanf("%d", &n);
    for(i = 0; i < n; i++) {
        scanf("%s", command); 
        if(strcmp(command, "insert") == 0) {
            scanf("%d", &key);
            node = createNode(key);
            insert(node, &head, &tail); 
        } else if(strcmp(command, "delete") == 0) {
            scanf("%d", &key);
            delete(key, &head, &tail);
        } else if(strcmp(command, "deleteFirst") == 0) {
            deleteFirst(&head, &tail);
        } else if(strcmp(command, "deleteLast") == 0){
            deleteLast(&head, &tail);
        } else {
            printf("command not found: %s\n", command);
        }
    }
    printf("%d", tail->key);
    tail = tail->prev;
    while(tail != NULL) {
        printf(" %d", tail->key);
        tail = tail->prev;
    }
    printf("\n");
 
    return 0;
}

Measured memory_bytes: 31660
#include <stdio.h>

int main(void)
{
	int a, b, i;
	int count = 1;

	scanf("%d %d", &a, &b);

	if (b == a) //電源タップ一つで済む場合
	{
		printf("1\n");
		return 0;
	}
	else if (b == 1) //電源タップがいらない場合
	{
		printf("0\n");
		return 0;
	}

	//必要なタップ数をカウントする
	i = a;
	while (i < b)
	{
		i += (a - 1);
		count++;
	}

	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int inp[100005];
int dp[100005];
int main() {
	int N, K; scanf("%d %d", &N, &K);
	for (int i = 1; i <= N; i++) {
		scanf("%d", inp + i);
		dp[i] = i == 1 ? 0 : 2e9;
		for (int k = 1; k <= K; k++) {
			if (i - k > 0) {
				dp[i] = min(dp[i], dp[i - k] + abs(inp[i] - inp[i - k]));
			}
		}
	}
	printf("%d", dp[N]);
}

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


int main() {
	int n;
	string s, t;
	cin >> n;
	cin >> s >> t;

	string ans="";

	for (int i = 0; i < n; i++) {
		ans += s[i];
		ans += t[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int i=1,ii=1;
    
    for(i=1;i<=9;i=i+1){
    for(ii=1;ii<=9;ii=ii+1){
            cout<<i<<"x"<<ii<<"="<<i*ii;
            cout<<endl;
    }}
        
    
    
    return 0;
}

Measured memory_bytes: 3052
def main():
    #N,K=map(int,input().split())
    #p=list(map(int,input().split()))
    N=int(input())
    ans=""
    while N!=0:
        tmp=N%26
        N//=26
        if tmp==0:
            ans="z"+ans
            N-=1
        else:
            ans=chr(tmp-1+ord("a"))+ans
    print(ans)

main()

Measured memory_bytes: 9160
#include <stdio.h>

int main(void) {
  int h, w, i, j;
  while (1) {
    scanf(" %d %d", &h, &w);
    if (h == 0 && w == 0)
      return 0;
    for (i = 0; i < h; i++) {
      for (j = 0; j < w; j++) {
	if (i == 0 || j == 0 || i == h - 1 || j == w - 1)
	  printf("#");
	else
	  printf(".");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}



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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  for(int i=0;i<n;i++) cin >> s[i];
  vector<vector<char>> f(n,vector<char>(n));
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
        f[j][k]=s[(j+i)%n][k];
      }
    }
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
        if(f[j][k]!=f[k][j]) goto next;
      }
    }
    ans+=n;
    next:;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
fun main() {
    val (N, M, K) = readLine()!!.split(" ").map { it.toInt() }
    val A = readLine()!!.split(" ").map { it.toInt() }
    val B = readLine()!!.split(" ").map { it.toInt() }
    val ASum = LongArray(A.size + 1)
    for(i in A.indices){
        ASum[i + 1] = A[i] + ASum[i]
    }
    val BSum = LongArray(B.size + 1)
    for(i in B.indices){
        BSum[i + 1] = B[i] + BSum[i]
    }
    var max = 0
    for(i in 0..A.size){
        val readA = ASum[i]
        if(K - readA < 0){
            continue
        }
        val j = BSum.binarySearch(K - readA)
        max = kotlin.math.max(max, i + j - 1)
    }
    println(max)
}

fun LongArray.binarySearch(key: Long): Int {
    var l = -1
    var r = this.size
    while (r - l > 1) {
        val m = l + (r - l) / 2
        if (this[m] > key) {
            r = m
        } else {
            l = m
        }
    }
    return r
}

Measured memory_bytes: 83900
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
#define MIN 999999999
#define MAX -999999999
typedef long long int ll;
typedef unsigned long long int ull;
void llswap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}
int llasc(const void *a,const void *b){return *(ll*)a-*(ll*)b;}
int lldesc(const void *a,const void *b){return *(ll*)b-*(ll*)a;}
int main(void){
    int n;
    int s[1000];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&s[i]);
    }
    qsort(s,n,sizeof(int),asc);
    int sum=0;
    int minno=999999;
    for(int i=0;i<n;i++){
        if(s[i]%10!=0){
            if(minno>s[i]){
                minno=s[i];
            }
        }
    }
    /*
    for(int i=0;i<n;i++){
        printf("%d\n",s[i]);
    }*/
    for(int i=0;i<n;i++){
        sum+=s[i];
    }
    if(sum%10==0){
        if(minno==999999){
            printf("0\n");
            return 0;
        }else{
            sum-=minno;
            printf("%d\n",sum);
            return 0;
        }
        
       
    }else{
        printf("%d\n",sum);
        return 0;
    }
    
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
//        sc.useDelimiter("\n");
//        DecimalFormat df = new DecimalFormat("0.00000000");
        
        int[][] a = new int[3][3];
        for (int i=0; i<3; i++) {
            for (int j=0; j<3; j++) {
                a[i][j] = Integer.parseInt(sc.next());
//                pw.print(a[i][j] + " ");
            }
//            pw.println();
        }
        
        int n = Integer.parseInt(sc.next());
        int[] b = new int[n];
        for (int i=0; i<n; i++) {
            b[i] = Integer.parseInt(sc.next());
//            pw.println(b[i]);
        }
        
        for (int i=0; i<3; i++) {
            for (int j=0; j<3; j++) {
                for (int k=0; k<n; k++) {
                    if (a[i][j] == b[k]) a[i][j] = 0;
                }
//                pw.print(a[i][j] + " ");
            }
//            pw.println();
        }
        
        if ((a[0][0] == 0 && a[0][1] == 0 && a[0][2] == 0)
                || (a[1][0] == 0 && a[1][1] == 0 && a[1][2] == 0)
                || (a[2][0] == 0 && a[2][1] == 0 && a[2][2] == 0)
                || (a[0][0] == 0 && a[1][0] == 0 && a[2][0] == 0)
                || (a[0][1] == 0 && a[1][1] == 0 && a[2][1] == 0)
                || (a[0][2] == 0 && a[1][2] == 0 && a[2][2] == 0)
                || (a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0)
                || (a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0)) {
            pw.println("Yes");
        } else {
            pw.println("No");
        }
        
        pw.flush();
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define PI (acos(-1))
#define ct cout<<
#define cn cin>>
#define spc <<" "<<
#define nl puts("")
#define _fl(x) puts("FLAG " #x);
#define  _(x)  cout<< #x <<" is "<< x <<endl;
#define fs first
#define sc second
#define pb push_back
#define all(v)  (v).begin(), (v).end()
#define _109 (1000000000)
#define _0(arr) memset(arr,0,sizeof ( arr ) )
#define _1(arr) memset(arr,-1,sizeof ( arr ) )
#define _ninp(n,arr) for(int i=0; i<n;i++)cin>>arr[i];
#define _nout(n,arr) for(int i=0; i<n;i++)cout<<arr[i]<<" \n"[i==n-1];
double _eps=1e-6;
long long gcd(long long a, long long b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main() {
       

    





   ll a,b,c;

   cn a>>b>>c;



   c-=a;
   c-=b;
   
   if(c<0){
     ct "No\n";
     return 0;

   }
   if(4*a*b<c*c)ct "Yes\n";
   else ct "No\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char diff(char c){
    if(c == 'a') return 'b';
    return 'a';
}
int get(char c, string s){
    bool has = false;
    for(int i = 0; i < s.length(); i++) {
            if(s[i] == c) has = true;
    }
    if(!has) return 10000000;
    for(int ans = 0; true; ans++){
        int notC = 0;
        for(int i = 0; i < s.length(); i++)
            if(s[i] != c) notC++;
        if(notC == 0) return ans;
        string p;
        for(int i = 1; i < s.length(); i++){
            if(s[i] != c && s[i - 1] != c) p.push_back(diff(c));
            else p.push_back(c);
        }
        s = p;
    }
    assert(false);
    return 0;
}
int main(){
    string s;
    cin >> s;
    int best = get('a', s);
    for(char c = 'b'; c <= 'z'; c++){
        best = min(best, get(c, s));
    }
    cout << best << endl;
    return 0;
}


Measured memory_bytes: 256
// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
//
// See the bottom of file for solution.
// -----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn dfs(n: i64, b3: bool, b5: bool, b7: bool, m: i64) -> i64 {
    if n > m {
        return 0;
    }

    let mut k = 0_i64;

    if b3 && b5 && b7 {
        k += 1;
    }

    k += dfs(n * 10 + 3, true, b5, b7, m);
    k += dfs(n * 10 + 5, b3, true, b7, m);
    k += dfs(n * 10 + 7, b3, b5, true, m);

    k
}

fn main() {
    let m = read!(i64);
    println!("{}", dfs(0, false, false, false, m));
}


Measured memory_bytes: 4352
#include <fstream>
#include <iostream>
#include <string>
#include <iterator>
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
   string s;
   cin>>s;
   bool flag=false;
   rep(i,s.size()){
       if(s.at(i)=='7'){
           flag=true;
       }
   }
   if(flag){
       cout<<"Yes"<<endl;
   }
   else{
       cout<<"No"<<endl;
   }
}


Measured memory_bytes: 3620
from itertools import combinations

p = [1]*555555
p[0] = p[1] = 0
for i in xrange(2, int(555555**0.5) + 1):
    if p[i]:
        p[2*i::i] = [0]*len(p[2*i::i])

ans = []
for i in xrange(55555):
    if p[i] and str(i)[-1] == "1":
        ans.append(i)

N = int(raw_input())
print " ".join(map(str, ans[:N]))


Measured memory_bytes: 11272
#include"bits/stdc++.h"
//#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define print(x) cout<<x<<endl;
typedef long long ll;


int main() {
	int x;
	cin >> x;
	if (x < 1200) { print("ABC"); }
	else { print("ARC"); }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N,R;
		N= sc.nextInt();
		R= sc.nextInt();
		int i=0;
		for (i=1;i<100;i++) {
			N=N/R;
			if (N==0) {
				System.out.println(i);
				return;
			}
		}
	}

}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
int n;
vector<bool> che(300000,0);

void dfs(const Graph &G,int n,int sum,const vector<ll> &x,vector<ll> &ans){
    ans[n] = sum + x[n];
    che[n] = 1;
    for(auto to : G[n]){
        //cout << n << endl;
        //cout << "ans[n] was readed " << endl;
        if(!che[to]) dfs(G,to,ans[n],x,ans);
    }
    //cout << "dfs was end " << endl;
}

int main(){
    int q;
    cin >> n >> q;
    Graph G(n);
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    //cout << "Graph input was success" << endl;
    vector<ll> x(n,0);
    rep(i,q){
        int a,b;
        cin >> a >> b;
        a--;
        x[a] += b;
    }
    //cout << "input success" << endl;
    vector<ll> ans(n);
    che[0] = 1;
    dfs(G,0,0,x,ans);
    rep(i,n){
        cout << ans[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 32128
#include<bits/stdc++.h>                                                                                                                
using namespace std;
int a[100050],b;
int main(){
    int n;
    cin >> n;
    long long cnt = 0;
    for(int i=0;i<=n;i++){
        cin >> a[i];
    }   
    int tmp=0,flg = 0;
    tmp = a[0];
    for(int i=0;i<n;i++){
        cin >> b;
        if(a[i] - b < 0){ 
            if(a[i+1] - (b - a[i]) < 0){ 
                 cnt += a[i] + a[i+1];
                 a[i+1] = 0;
            }
            else{
                 cnt += a[i] + (b - a[i]);
                 a[i+1] -= (b - a[i]);
                 }
        }
        else{
            cnt += b;
        }
}
    cout << cnt << '\n';
    return 0;
}


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

using namespace std;

template <class T = long>
vector<T> heightOfTree(const vector<vector<pair<int, T>>> &g)
{
    int n = g.size();
    auto dfs = [&](auto dfs, int v, vector<T> &dis) -> void {
        for (auto &p : g[v])
        {
            if (dis[p.first] == -1)
            {
                dis[p.first] = dis[v] + p.second;
                dfs(dfs, p.first, dis);
            }
        }
    };
    vector<T> dis(n, -1), dis2(dis);
    dis[0] = 0;
    dfs(dfs, 0, dis);
    int s1 = distance(dis.begin(), max_element(dis.begin(), dis.end()));
    fill(dis.begin(), dis.end(), -1);
    dis[s1] = 0;
    dfs(dfs, s1, dis);
    int s2 = distance(dis.begin(), max_element(dis.begin(), dis.end()));
    dis2[s2] = 0;
    dfs(dfs, s2, dis2);
    //cout << s1 << ' ' << s2 << endl;
    vector<T> res(n);
    for (int i = 0; i < n; i++)
    {
        //cout << dis[i] << ' ' << dis2[i] << endl;
        //cout << max(dis[i], dis2[i]) << '\n';
        res[i] = max(dis[i], dis2[i]);
    }
    return res;
}

void solve()
{
    int n;
    cin >> n;
    vector<vector<pair<int, int>>> g(n);
    for (int i = 0; i < n - 1; i++)
    {
        int s, t, w;
        cin >> s >> t >> w;
        g[s].push_back(make_pair(t, w));
        g[t].push_back(make_pair(s, w));
    }
    auto d = heightOfTree(g);
    for (int i = 0; i < n; i++)
    {
        cout << d[i] << '\n';
    }
}

int main()
{
    solve();
    return 0;
}



Measured memory_bytes: 3976
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vector<int>>;  // int <=> ll
using P = pair<int, int>;  // int <=> ll
const int INFTY = 1e9+7;

int main() {
  ll K, X, Y;
  cin >> K >> X >> Y;
  ll dist = abs(X) + abs(Y);
  
  if (K%2 == 0 && dist%2 == 1) {
    cout << -1 << endl;
    return 0;
  }

  if (K == dist) {
    cout << 1 << endl;
    cout << X << " " << Y << endl;
    return 0;
  }

  bool swaped = false;
  if (abs(X) > abs(Y)) {
    swap(X,Y);
    swaped = true;
  }  // Y != 0

  int xs = 1, ys = 1;
  if (X < 0) xs = -1;
  if (Y < 0) ys = -1;

  int s = dist / K;
  if (K > dist) {
    if (dist%2 == 0) s = 2;
    else s = 3;
  }
  else if (dist%K != 0) {
    if ((K-dist%K)%2 == 0) s += 1;
    else s += 2;
  }

  ll res = (K*s-dist)/2;
  vector<P> coord;

  if (K < res) {
    coord.push_back(P(0, -ys*K));
    coord.push_back(P(-xs*(res%K), -ys*(res%K)));
    coord.push_back(P(X,Y));
  }

  else {
    int x1 = -xs * res;
    int y1 = ys * (K-res);
    P point = P(x1,y1);
    coord.push_back(point);

    rep(i,abs(X-x1)/K) {
      point.first += xs * K;
      coord.push_back(point);
    }
    rep(i,abs(Y-y1)/K) {
      point.second += ys * K;
      coord.push_back(point);
    }
    if (coord.size() != s) coord.push_back(P(X,Y));
  }

  if (swaped) {
    rep(i,s) swap(coord[i].first, coord[i].second);
  }

  cout << s << endl;
  rep(i,s) cout << coord[i].first << " " << coord[i].second << endl;
  return 0;
}


Measured memory_bytes: 3952
// acdart
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <string>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cstdlib>
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second
#define F first
#define S second
#define MOD9 1000000009ll
#define MOD7 1000000007ll
#define MOD
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define SZ(x) ((int)(x).size())
#define MAXN 10010
#define MAXM
#define ALL(x) ((x).begin()),((x).end())
#define RESET(a,b) memset(a,b, sizeof a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define LEN(X) strlen(X)
#define FI(a,b,c) for(int a=b; a<c; a++)
#define FD(a,b,c) for(int a=b; a>c; a--)
using namespace std;
typedef long long ll;
typedef long long LL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
/*********default*********/

int main()
{
	int a, x = 2, y = 1;
	
	for (int i = 0; i < 3; i++){
		scanf("%d", &a);
		if (a == 5){
			x--;
		} else if (a == 7){
			y--;
		}
	}
	if (x == 0 && y == 0){
		puts("YES");
	} else {
		puts("NO");
	} 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,ans=0;string s;
	cin>>n>>s;
	int l=0,r=1;
	while(r<=n){
		string tmp=s.substr(l,r-l);
		if(s.find(tmp,r)<n)ans=max(ans,r-l),r++;
		else l++,r++;
	}
	cout<<ans; 
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
long long int a;
long long int b;
long long int c;
 cin >> a >> b >> c;
 if(a+b>=c)cout << "No" <<endl;
 else{
long long int d= (c-a-b)*(c-a-b);
if(d > 4*a*b)cout << "Yes" <<endl;
 else{cout << "No" << endl;}
}}

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

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

	int N, M; cin >> N >> M;

	vector<vector<int>> J(M);

	for(int i = 0; i < N; ++i) {
		int A, B; cin >> A >> B;

		if(A > M) continue;

		J[M-A].push_back(B);
	}

	int ans = 0;
	priority_queue<int> PQ;

	for(int i = M-1; i >= 0; --i) {

		for(int j : J[i]) PQ.push(j);

		if(!PQ.empty()) {
			int x = PQ.top(); PQ.pop();
			ans += x;
		}
	}

	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 5632
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <string>

using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
static const ll maxLL = (ll)1 << 62;

double W[1000];
ll wp = 0;
double S[10000000];
ll sp = 0;

int main() {
	double A, B, C, D, E, F; cin >> A >> B >> C >> D >> E >> F;

	double maxn = 0;
	double maxws = 0;
	double maxs = 0;

	set<double> w;
	set<double> s;
	repe(a, 0, F / 100 * A) {
		repe(b, 0, F / 100 * A) {
			double W = a * 100 * A + b * 100 * B;
			if (W <= F) {
				repe(c, 0, F / C) {
					repe(d, 0, F / D) {
						double S = c * C + d * D;
						double T = W + S;
						if (W + S <= F) {
							if (T != 0 && (S / T) <= (E / (100 + E))) {
								double n = 100 * S / T;
								if (maxn <= n) {
									maxn = n;
									maxws = T;
									maxs = S;
								}
							}
						}
					}
				}
			}
		}
	}

	cout << maxws << " " << maxs << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	int a,b;
	cin>>a>>b;
	if(a>9 || b>9)
	    printf("-1\n");
	else
	   printf("%d\n",a*b);
	return 0;
}
    

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*
 */

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

signed main() {
  char c;
  cin >> c;

  cout << (char)(c+1) << endl;

  return 0;
}



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

using namespace std;

#define INF 1e9

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

    while(1){
        int n;
        cin>>n;

        if(n==0)break;

        int sum[30]={};
        char ans;
        int t=-1;
        bool f=false;

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

            sum[c-'A']++;
            
            int Max1=0,Max2=0;
            char C;

            for(int i=0;i<26;i++){
                if(Max1<sum[i]){
                    Max2=Max1;
                    Max1=sum[i];
                    C='A'+i;
                }
                else if(Max2<sum[i]){
                    Max2=sum[i];
                }
            }
            
            if(Max1>Max2+n-i-1 && !f){
                ans=C;
                t=i+1;
                f=true;
            }

        }

        if(f){
            cout<<ans<<" "<<t<<endl;
        }
        else cout<<"TIE"<<endl;
    }

}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,a[100010],mi = INF,mii,ma = -INF,mai;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		if(mi > a[i]){
			mi = a[i];
			mii = i;
		}
		if(ma < a[i]){
			ma = a[i];
			mai = i;
		}
	}
	if(mii == mai) mai = (mai + 1) % n;
	vector<P> sousa;
	if(mi >= 0){
		for(int i = 0;i < n;i++){
			if(i != mii && i != mai){
				sousa.emplace_back(a[mii],a[i]);
				a[mii] -= a[i];
			}
		}
		sousa.emplace_back(a[mai],a[mii]);
		a[mai] -= a[mii];
	}else if(ma <= 0){
		for(int i = 0;i < n;i++){
			if(i != mai){
				sousa.emplace_back(a[mai],a[i]);
				a[mai] -= a[i];
			}
		}
	}else{
		for(int i = 0;i < n;i++){
			if(a[i] >= 0 && i != mai){
				sousa.emplace_back(a[mii],a[i]);
				a[mii] -= a[i];
			}
		}
		sousa.emplace_back(a[mai],a[mii]);
		a[mai] -= a[mii];
		for(int i = 0;i < n;i++){
			if(a[i] < 0 && i != mii){
				sousa.emplace_back(a[mai],a[i]);
				a[mai] -= a[i];
			}
		}
	}
	cout << a[mai] << endl;
	for(P p : sousa) cout << p.first << " " << p.second << endl;
}

Measured memory_bytes: 4336
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false ll_MAX ll_MIN insert erase clear pop push compare ll64_MAX ll64_MIN  reverse replace stringstream string::npos length substr front priority_queue

#ifndef ONLINE_JUDGE
#include "debug.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define debug(...) 42
#endif

#define endl '\n'
#define ll long long
#define rint register int
#define minpq priority_queue <int, vector<int>, greater<int> >
#define maxpq  priority_queue <int>

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007

long long gcd (long long a, long long b) {
	return b ? gcd (b, a % b) : a;
}

ll lcm(ll x, ll y) {
	return (x / gcd(x, y)) * y;
}

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

int32_t main() {
	ios::sync_with_stdio(0); 		cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll t, i, x, m, j, y, 	z, k, n;
	cin >> n >> m;
	ll a[n];
	rep(i, 0, n, 1) {
		cin >> a[i];
	}
	x = a[0] / 2;
	ll lc = x;
	t = 0;
	while (x % 2 == 0) {
		t++;
		x /= 2;
	}

	rep(i, 1, n, 1) {
		x = a[i] / 2;
		y = 0;
		lc = lcm(lc, x);
		while (x % 2 == 0) {
			y++;
			x /= 2;
		}
		if (y != t) {
			return cout << 0, 0;
		}
	}


	z = 0;
	// debug("z");


	ll odd = m / lc;
	if (odd % 2 == 0)	odd--;

	z = max(z, (odd + 1) / 2);
	return cout << z, 0;

}



Measured memory_bytes: 4384
n = int(input())

ans = 0
for i in range(2,int(n**0.5)+1):
    count = 1
    loop = 1
    while n % i == 0:
        n = int(n/i)
        count -= 1
        if count == 0:
            ans += 1
            loop += 1
            count = loop

if n > 1:
    ans += 1
print(ans)

Measured memory_bytes: 63332