akhauriyash/Code-Regression huggingface dataset:
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int n;
    readf("%s", &n);
    readln;
    
    auto arr = readln.chomp.split.map!(to!double).array;
    
    auto ans = arr.sort().reduce!((x, a) => (x + a) / 2);
    
    writefln("%.12f", ans);
}

Measured memory_bytes: 256
fun main(args: Array<String>) {

    val n = readLine()!!.toInt()
    val h = readLine()!!.split(" ").map { it.toInt() }

    val dp = Array(100005){ Int.MAX_VALUE}

    dp[0] = 0
    dp[1] = Math.abs(h[0]-h[1])
    for(i in 2 until n){
        dp[i] = dp[i-1] + Math.abs(h[i] - h[i-1])
        if(dp[i] > dp[i-2] + Math.abs(h[i] - h[i-2])) dp[i] = dp[i-2] + Math.abs(h[i] - h[i-2])
    }

    println(dp[n-1])
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{

	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; ll k;
	cin >>n  >>k;
	
	VI a(n);
	rep(i, n) cin >>a[i];
	
	VI b(n), c(n);
	rep(i, n){
		rep(j,  n) if(a[i] < a[j]) b[i]++;
	}
	rep(i, n){
		rep(j, i) if(a[i] < a[j]) c[i]++;
	}
	

	ll ans=0;
	
	rep(i, n) (ans += (ll)b[i] * ((k *(k-1)/2)%MD)) %=MD;
	rep(i, n) (ans += c[i] * k) %=MD;
	cout << ans%MD <<"\n";
	


	return 0;
	
	
}


Measured memory_bytes: 256
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<map>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const int mod=1000000007;
const llint big=1e18+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-9;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
int gcd(int a,int b){if(a%b==0){return b;}else return gcd(b,a%b);}//a>b
class in_t{public:
	int a;in_t(){cin>>a;}
	operator int() {return a;}
};
class ld_t{public:
	long double a;ld_t(){cin>>a;}
	operator long double() {return a;}
};
int main(void){
	in_t n;
	int i,j;
	vector<int>bas(n);//あるべき場所
	vector<pair<int,int>>zyu(n);//場所、数字
	vector<int>ans(n*n,-1);
	deque<int>suu;
	vector<int>ikt(n);//それまでの数
	for(i=0;i<n;i++){
		int x;
		cin>>x;x--;
		ans[x]=i;
		bas[i]=x;
		zyu[i]=mp(x,i);
	}
	sort(zyu.begin(),zyu.end());
	for(i=0;i<n;i++){
		for(j=0;j<zyu[i].sec;j++){suu.pub(zyu[i].sec);}
		
	}
	for(i=0;i<n;i++){
		for(j=zyu[i].sec+1;j<n;j++){suu.pub(zyu[i].sec);}
	}
	//前がない->あと
	for(i=0;i<n*n;i++){
		int kore;
		if(ans[i]!=-1){kore=ans[i];}
		else{kore=suu.front();suu.pof();}
		if(ikt[kore]==kore){
			if(bas[kore]!=i){cout<<"No"<<endl;return 0;}
		}ikt[kore]++;
		ans[i]=kore;
	}
	cout<<"Yes"<<endl;
	for(i=0;i<n*n;i++){cout<<ans[i]+1<<" ";}
	return 0;
}

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	ll a[3 * n];
	ll f[n + 1], s[n + 1];
	f[0] = 0; s[n] = 0;
	
	priority_queue<ll, vector<ll>, greater<ll>> fh;
	priority_queue<ll> sh;
	
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		fh.push(a[i]);
		f[0] += a[i];
	}
	for (int i = n; i < 2 * n; i++) {
		cin >> a[i];
		if (a[i] > fh.top()) {
			f[i - n + 1] = f[i - n] + a[i] - fh.top();
			fh.pop();
			fh.push(a[i]);
		} else f[i - n + 1] = f[i - n];
	}
	for (int i = 2 * n; i < 3 * n; i++) {
		cin >> a[i];
		sh.push(a[i]);
		s[n] += a[i];
	}
	for (int i = 2 * n - 1; i >= n; i--) {
		if (a[i] < sh.top()) {
			s[i - n] = s[i - n + 1] + a[i] - sh.top();
			sh.pop();
			sh.push(a[i]);
		} else s[i - n] = s[i - n + 1];
	}

	ll ans = f[0] - s[0];
	for (int i = 1; i <= n; i++)
		ans = max(ans, f[i] - s[i]);
	cout << ans;
}

Measured memory_bytes: 5876
from collections import deque

if __name__ == "__main__":
	N = int(input())
	AB = []
	for _ in range(N - 1):
		a, b = map(int, input().split())
		AB.append((a, b))

	graph = [[] for _ in range(N + 1)]
	for a, b in AB:
		graph[a].append(b)
		graph[b].append(a)

	root = 1
	parent = [0] * (N + 1)
	order = []
	stack = [root]
	# make ordered tree
	while stack:
		x = stack.pop()
		order.append(x)
		for y in graph[x]:
			if parent[x] == y:
				continue
			parent[y] = x
			stack.append(y)

	# assign color
	color = [-1] * (N + 1)
	for x in order:
		ng = color[x] # cannot assign the color of edge(x, parent[x])
		c = 1
		for y in graph[x]:
			if parent[x] == y:
				continue
			if c == ng:
				c += 1
			color[y] = c
			c += 1

	answer = []
	for a, b in AB:
		if parent[a] == b:
			answer.append(color[a])
		else:
			answer.append(color[b])
	K = max(answer)
	print(K)
	print('\n'.join(map(str, answer)))


Measured memory_bytes: 38512
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<iomanip>
#include<string>
#include<cstring>
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define INF 1e18

using namespace std;
using ll = long long int;

int main(void) {
    string S, T;
    cin >> S >> T;
    vector<vector<int>> dp(S.size() + 1, vector<int>(T.size() + 1));
    REP(i, S.size()) {
        REP(j, T.size()) {
            if (S[i] == T[j]) dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j]);
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1]);
        }
    }
    int i = S.size() - 1, j = T.size() - 1;
    string lcs = "";
    //REP(i, S.size() + 1) {
    //    REP(j, T.size() + 1) cout << dp[i][j];
    //    cout << endl;
    //}
    while (i >= 0 && j >= 0) {
        if(S[i] == T[j]) {
            lcs += S[i];
            i--; j--;
        }
        else {
            if (dp[i][j + 1] > dp[i + 1][j]) i--;
            else j--;
        }
    }
    REP(i, lcs.size()) cout << lcs[lcs.size() - 1 - i];
    cout << endl;
}

Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    string s;
    cin >> s;
    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
        cout << "Bad" << endl;
    } else {
        cout << "Good" << endl;
    }
}


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

int main(void){
    int N,A,B;
    cin >> N >> A >> B;

    static int num,tmp,total,sum;
    for(int i = 0; i <= N; i++){
        num = i;
        while(1){
            tmp = num % 10;
            sum += tmp;
            if(num < 10) break;
            num = num / 10;
        }
        if(A <= sum && sum <= B){
            total += i;
        }
        sum = 0;
    }
    cout << total <<endl;
    return 0;
}

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

int main() {
	int a;
	cin >> a;
	for (int i = 3; i <= a; ++i) {

		if (i % 3 == 0 || i % 10==3||i/10%10==3||i/100%10==3||i/1000%10==3||i/10000%10==3) {
			cout <<' '<<i;
		}
	}cout<<endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

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

	ll N, K;
	ll ans = 0;

	cin >> N >> K;

	deque<ll> V(N);
	rep(i, N) cin >> V[i];

	multiset<ll> h;
	deque<ll> dq;

	ll num = min(N, K);
	ll sum;

	ans = -1;
	rep(a, num + 1)rep(b, num + 1- a) {
		h.clear();
		dq = V;
		rep(i, a) {
			h.insert(*dq.begin());
			dq.pop_front();
		}
		rep(i, b) {
			h.insert(*dq.rbegin());
			dq.pop_back();
		}
		rep(i, K - a - b) {
			if (h.size()>0 && *h.begin() < 0) {
				h.erase(h.begin());
			}
		}
		sum = 0;
		auto itr = h.begin();
		rep(i, h.size()) {
			sum += *(itr++);
		}
		if (sum > ans) {
			ans = sum;
		}
	}

	cout << ans << "\n";

	return 0;
}

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

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<long long>; using vvll = vector<vll>;
template <class T> using min_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
template <class T> struct Inf { static constexpr T inf() { return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : std::numeric_limits<T>::max(); } };
template <> struct Inf<int> { static constexpr int inf() { return 0x3f3f3f3f; } };
template <> struct Inf<long long> { static constexpr long long inf() { return 0x3f3f3f3f3f3f3f3fLL; } };
constexpr int INF = Inf<int>::inf(); constexpr ll BINF = Inf<ll>::inf();
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}
// Preprocessing & "Global" variables {{{
struct Solver {
	Solver() {}
	int solve();
};
// }}}

int Solver::solve() {
	int n, m; cin >> n >> m;
	vvi g(n);
	for (int i = 0; i < m; i++) {
		int u, v; cin >> u >> v; u--, v--;
		g[u].push_back(v); g[v].push_back(u);
	}
	vi dist(n, INF);
	vi par(n, -1);
	queue<int> q;
	dist[0] = 0; q.push(0);
	while (!q.empty()) {
		int u = q.front(); q.pop();
		for (int v : g[u]) {
			if (dist[v] != INF) continue;
			dist[v] = dist[u] + 1;
			par[v] = u;
			q.push(v);
		}
	}
	for (int i = 0; i < n; i++) if (dist[i] >= INF) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	for (int i = 1; i < n; i++) cout << par[i] + 1 << endl;
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	Solver solver;
	#ifdef JUDGE_MULTI_CASE
		int t; cin >> t; for (int i = 1; i <= t; i++)
	#endif
	solver.solve();
	// cout << "Case #" << i << ": ", solve();
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto it=v.begin();it!=v.end();) os << *it, os << " \n"[++it==v.end()];
	return os;
}

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) {
	return os << p.first << ' ' << p.second;
}
// }}}

// vim: fdm=marker


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

ll inf=9223372036854775806,ans=0;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n,d,x,i,j,a[101]={0},ans=0,t;
	cin>>n>>d>>x;
	for (i=0;i<n;i++){
		cin>>t;
		for (j=1;j<=d;j+=t){
			a[j]++;
		}
	}
	for (i=1;i<=d;i++){
		ans+=a[i];
	}
	cout<<ans+x;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <stack>
#include <set>
#include <algorithm>
using namespace std;
#define ll long long int

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if ( a < c && c < b ) {
    cout << "Yes" << endl;  
  } else if ( b < c && c < a) {
    cout << "Yes" << endl;  
  }else {
    cout << "No" << endl;  
  }
  return 0;
}



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

struct RMQ{
  int n;
  vector<int> dat;
  const int def=INT_MAX;
  RMQ(){}
  RMQ(int n_){init(n_);}
  RMQ(int n_,int* a){init(n_);build(n_,a);}
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(2*n-1,def);
  }
  void build(int n_, int* a){
    for(int i=0;i<n_;i++) dat[i+n-1]=a[i];
    for(int i=n-2;i>=0;i--)
      dat[i]=min(dat[i*2+1],dat[i*2+2]);
  }
  void update(int k,int a){
    k+=n-1;
    dat[k]=a;
    while(k>0){
      k=(k-1)/2;
      dat[k]=min(dat[k*2+1],dat[k*2+2]);
    }
  }
  int query(int a,int b,int k,int l,int r){
    if(r<=a||b<=l) return def;
    if(a<=l&&r<=b) return dat[k];
    int vl=query(a,b,k*2+1,l,(l+r)/2);
    int vr=query(a,b,k*2+2,(l+r)/2,r);
    return min(vl,vr);
  }
  int query(int a,int b){
    return query(a,b,0,0,n);
  }
};

signed main(){
  int n,l;
  cin>>n>>l;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  RMQ rmq(n,a);
  for(int i=0;i<n-l+1;i++){
    if(i) cout<<" ";
    cout<<rmq.query(i,i+l);
  }
  cout<<endl;
  return 0;
}

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

int gcd(int a, int b){
  if (a > b){
    if (b == 0){
      return a;
    }
    return gcd(b, a % b);
  } else{
    if (a == 0){
      return b;
    }
    return gcd(a, b % a);
  }
}

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

  // if (N == 2){
  //   if (A[0] < A[1]){
  //     cout << A[1] << endl;
  //   } else{
  //     cout << A[0] << endl;
  //   }
  //   return 0;
  // }
  //
  // int output = 0;
  // // 一つのぞいた時の最大公約数
  // for (int j=0; j<N; j++){
  //   int tmp = 0;
  //   if (j==0){
  //     tmp = A[1];
  //     for (int i=2; i<N; i++){
  //       tmp = gcd(tmp, A[i]);
  //     }
  //   } else{
  //     tmp = A[0];
  //     for (int i=1; i<N; i++){
  //       if (i == j){
  //         continue;
  //       } else{
  //         tmp = gcd(tmp, A[i]);
  //       }
  //     }
  //   }
  //   if (output < tmp){
  //     output = tmp;
  //   }
  // }

  // 順番に公約数を求めるとはやい
  int L[N+1];
  int R[N+1];
  L[0] = 0;
  R[N] = 0;

  for (int i=0; i<N; i++){
    L[i+1] = gcd(L[i], A[i]);
  }
  for (int i=N-1; i>=0; i--){
    R[i] = gcd(R[i+1], A[i]);
  }

  int output = 0;
  for (int i=0; i<N; i++){
    int m = gcd(L[i], R[i+1]);
    if (output < m){
      output = m;
    }
  }
  cout << output << endl;
  return 0;
}


Measured memory_bytes: 1408
a=int(input())
l=list(map(int,input().split()))
ok=False
if sorted(l) == l:
    print("YES")
    exit(0)
for i in range(len(l)-1):

    for j in range(i+1,len(l)):
        aux=l[i]
        l[i]=l[j]
        l[j]=aux
        if sorted(l) == l:
            ok=True
        else:
            aux = l[j]
            l[j] = l[i]
            l[i] = aux
    if ok == True:
        print("YES")
        break
if ok ==False:print("NO")


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

#define ll long long
#define ull unsigned long long
#define inf 0x3f3f3f3f
#define met(a, x) memset(a,x,sizeof(a))
#define mp make_pair;

using namespace std;
const int mod = 19e+7;
const int N = 3e4 + 10;
const int M = 2e5 + 10;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
char a[900][900];
bool vis[900][900];

int h, w, k;
struct node {
    int x, y, step = 0;
} s, t;
queue<node> q;

int cnt=inf;

void bfs(int xx, int yy, int step) {
    met(vis, false);
    while (!q.empty()) {
        q.pop();
    }
    s.x = xx, s.y = yy, s.step = step;
    q.push(s);
    cnt = min(cnt, xx - 1);
    cnt = min(cnt, h - xx);
    cnt = min(cnt, yy - 1);
    cnt = min(cnt, w - yy);
    while (!q.empty()) {
        t = q.front();
        q.pop();
        for (int i = 0; i < 4; i++) {
            int x = t.x + dx[i];
            int y = t.y + dy[i];
            int num = t.step + 1;
            if (x >= 1 && y >= 1 && x <= h && y <= w && !vis[x][y] && a[x][y] == '.' && num <= k) {
                vis[x][y] = 1;
                s.x = x, s.y = y, s.step = num;
                cnt = min(cnt, x - 1);
                cnt = min(cnt, h - x);
                cnt = min(cnt, y - 1);
                cnt = min(cnt, w - y);
                q.push(s);
            }
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> h >> w >> k;
    int x, y;
    for (int i = 1; i <= h; i++)
        for (int j = 1; j <= w; j++) {
            cin >> a[i][j];
            if (a[i][j] == 'S') {
                x = i, y = j;
            }
        }
    bfs(x, y, 0);
    int ans = 1;
    ans+=ceil(1.0*cnt/k);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
import java.io.*;
class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String s[] = br.readLine().trim().split(" ");
    double n = Double.parseDouble(s[0]);
    double d = Double.parseDouble(s[1]);
    int count =  0;
    while(n-- >0){
      s = br.readLine().trim().split(" ");
      double x1 = Double.parseDouble(s[0]);
      double x2 = Double.parseDouble(s[1]);
      double r = (x1*x1) + (x2*x2);
      r = Math.sqrt(r);
      if(r <= d)
        count++;
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 58472
#include <iostream>
using namespace std;
long long n, ans=1, M=1e9+7, cnt[1005];
int main() {
    int i, j, k;
    cin >> n;
    for (i=2; i<=n; i++) {
        for (k=i, j=2; k>1; ) {
            if (k%j==0) k/=j, cnt[j]++;
            else j++;
        }
    }
    for (i=2; i<=n; i++) ans = ans * (cnt[i]+1) % M;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
X=list(map(int, input().split()))
t=0
for i in range(len(X)):
  if X[i]==1:
    t+=300000
  elif X[i]==2:
    t+=200000
  elif X[i]==3:
    t+=100000
if X[0]==X[1] and X[0]==1:
  t+=400000
print(t)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int all = a * b;
		int road = (1 * a) + (1 * b) - (1 * 1);
		System.out.println(all - road);
	}
}

Measured memory_bytes: 19924
n,t=map(int,input().split())
c_t=[list(map(int,input().split())) for _ in range(n)]
ans=[]
for i in range(n):
    if c_t[i][1]<=t:
        ans.append(c_t[i][0])
print(min(ans) if sum(ans)>0 else "TLE")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll TLE = 1000000000;

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

  map<int,int> deg;
  for(int i=2;i<(int)s.size();i+=4){
    deg[s[i]-'0']++;
  }

  ll ans = 0;
  for(auto p : deg){
    ll tmp = 1;
    for(int i=0;i<p.first;i++){
      tmp *= n;
      if(tmp>TLE){
	ans = TLE+1;
	break;
      }
    }
    if(p.second*tmp>TLE){
      ans = TLE+1;
      break;
    }
    ans += p.second*tmp;
    if(ans>TLE)break;
  }

  if(ans>TLE || ans*t>TLE)cout << "TLE" << endl;
  else cout << ans*t << endl;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

ll power(ll x, ll pw, ll mod=1e9+7) {
    ll res = 1;
    x = x % mod;  // if it x >= p
    while (pw > 0) {
        if (pw & 1)
            res = (res*x) % mod;
        pw /= 2;
        x = (x*x) % mod;
    }
    return res;
}

int main() {
    // group perpendicular class
    int n; 
    cin >> n;
    map<pair<ll,ll>, ll> cnt;
    ll mod = 1e9 + 7;
    ll all_zero = 0, a, b;
    for(int i = 0; i < n; i++) {
        cin >> a >> b;
        if (a == 0 && b == 0) {
            all_zero += 1;
            continue;
        } else if (a == 0 && b != 0) {
            cnt[{0, 1}] += 1;
            continue;
        } else if (a != 0 && b == 0) {
            cnt[{-1, 0}] += 1;
            continue;
        }
        
        ll g = __gcd(a, b);
        if (b/g < 0) {
            cnt[{-(a/g), -(b/g)}] += 1;
        } else {
            cnt[{a/g, b/g}] += 1;
        }
        
    }
    ll ans = 1;
    // (2^a-1)+(2^b-1) + 1
    set<pair<ll, ll>> used;
    for(auto p: cnt) {
        // cout << p.first.first << ", " << p.first.second << endl;
        if (p.first.first < 0) {
            ll rev0 = p.first.second;
            ll rev1 = -p.first.first;
            if (cnt.count({rev0, rev1}) > 0) { // find pair
                ll tmp = power(2, p.second)-1 + power(2, cnt[{rev0, rev1}])-1 + 1;
                used.insert({rev0, rev1});
                ans *= ((tmp+mod) % mod);                
            } else {
                ll tmp = power(2, p.second) -1 + 1;
                ans *= (tmp % mod);
            }
            ans %= mod;
        } else {
            if (used.count(p.first) > 0) // paired
                continue;
            ll tmp = power(2, p.second) -1 + 1;
            ans *= (tmp % mod);
            ans %= mod;
        }
    }
    cout << ((ans-1)+all_zero+mod) %mod << endl;
    return 0;
}


Measured memory_bytes: 16008
#include<bits/stdc++.h>
using namespace std;
const int N=105;
int n,m,ans;
char G[N][N];
bitset<N> vis[N];
const int move[4][2]={
	{0,1},{0,-1},{1,0},{-1,0}	
};
void dfs(int x,int y,char k){
	if(x<1||x>n||y<1||y>m||G[x][y]!=k||vis[x][y])
		return;
	vis[x][y]=1;
	for(int i=0;i<4;i++)
		dfs(x+move[i][0],y+move[i][1],k);
}
signed main(void){
	ios::sync_with_stdio(false);
	while(cin>>n>>m&&n){
		memset(G,0,sizeof(G)),ans=0;
		for(int i=1;i<=n;vis[i++].reset())
			for(int j=1;j<=m;j++)
				cin>>G[i][j];
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++)
				if(!vis[i][j])
					dfs(i,j,G[i][j]),ans++;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1684
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		long n = scanner.nextLong();
		long d = scanner.nextLong();
//		int[] x=new int[n];
//		int[] y=new int[n];
		long[] x= new long[(int)n];
		long[] y= new long[(int)n];
		double dis=0;
		int count=0;

		for(int i=0 ; i<n ; i++) {
			x[i] = scanner.nextInt();
			y[i] = scanner.nextInt();
		}

		for(int i=0 ; i<n ; i++) {
			dis = Math.sqrt(x[i]*x[i] + y[i]*y[i]);
			if(dis <= d) {
				count++;
			}
		}

		System.out.println(count);

		scanner.close();

	}

}



Measured memory_bytes: 62772
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        int[] dp = new int[n];
        final int INT_MAX = Integer.MAX_VALUE;

        for (int i = 0; i < n; i++) {
            dp[i] = INT_MAX;
        }
        dp[0] = 0;
        for (int i = 1; i < n; i++) {
            dp[i] = Math.min(dp[i], dp[i-1]+Math.abs(h[i] - h[i-1]));
            if (i > 1) dp[i] = Math.min(dp[i], dp[i-2]+Math.abs(h[i] - h[i-2]));
        }
        System.out.println(dp[n-1]);
    }
}

Measured memory_bytes: 50168
import sys
input = sys.stdin.readline
import numpy as np
N = int(input())
s = []
for _ in range(N):
    s.append(int(input()))
max_s = sum(s)
if max_s % 10 != 0:
    print(max_s)
    sys.exit()
check = np.array(s)
check %= 10
if np.count_nonzero(check) == 0:
    print(0)
    sys.exit()
else:
    s.sort()
    for i in s:
        if i % 10 != 0:
            print(max_s - i)
            sys.exit()


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

using namespace std;

int main() {
	int h ,w;
	string s[50];
	cin >> h >> w;
	for (int i = 0; i < h; i++)cin >> s[i];
	for (int y = 0; y < h; y++) {
		for (int x = 0; x < w; x++) {
			if (s[y][x] == '.') {
				int bomb = 0;
				for (int dy = -1; dy <= 1; dy++) {
					if (y + dy < 0 || y + dy >= h)continue;
					for (int dx = -1; dx <= 1; dx++) {
						if (x + dx < 0 || x + dx >= w)continue;
						if (s[y + dy][x + dx] == '#')bomb++;
					}
				}
				cout << bomb;
			}
			else cout << "#";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
def main():
    n, k = map(int, input().split())
    hs = sorted(int(input()) for _ in range(n))
    res = hs[k - 1] - hs[0]
    for i in range(1, n - k + 1):
        res = min(res, hs[i + k - 1] - hs[i])
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 7396
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 998244353
INF = float('inf')


N, A = MI()
a = [0, *list(map(int, input().split()))]

# dp[i][j] := i番目までの数字を使って総和をjとする場合の数
# dp[i][j] = dp[i - 1][j - a[i]] + dp[i - 1][j]
dp = [[0] * (A + 1) for _ in range(N + 1)]
dp[0][0] = 1

for i in range(1, N + 1):
    for j in range(A + 1):
        if j - a[i] < 0:  # j - a[i] が負の数になってしまう時はa[i]を使用することはできない
            dp[i][j] = 2 * dp[i - 1][j] % MOD
            continue
        dp[i][j] = (dp[i - 1][j - a[i]] + 2 * dp[i - 1][j]) % MOD
print(dp[N][A])

Measured memory_bytes: 132400
n = int(input())
S = [int(x) for x in input().split()]
q = int(input())
T = [int(y) for y in input().split()]

cnt = 0
for t in T :
    left = 0
    right = n

    while (right - left) > 1:
        mid = (left+right)//2 
        if t >= S[mid]:
            left = mid
        else:
            right = mid
    if t == S[left]:
        cnt += 1
print(cnt)


Measured memory_bytes: 16896
n, m = map(int, input().split())
d = [0] * m

for i in range(n):
    a = list(map(int, input().split()))
    for j in range(a[0]):
        d[a[j+1]-1] += 1

c = 0
for num in d:
    if num == n:
        c += 1
print(c)

Measured memory_bytes: 9136
n = int(input())
s = input() #sys.stdin.readlineは最後が改行

right=0
ans = 0
for left in range(n):
    while right<n:
        word = s[left:right+1]
        if word in s[right+1:]:
            ans = max(ans, len(word))
        else:
            break
        right+=1

print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int solve(int i,int a[],vector<int> &dp,int n)
{
	if(i>n-2)
		return 0;
  	if(dp[i]!=-1)
      	return dp[i];
	if(i==n-2)
	{
		return dp[i]=abs(a[n-1]-a[n-2]);
	}
	return dp[i]=min((abs(a[i]-a[i+1])+solve(i+1,a,dp,n)),(abs(a[i]-a[i+2])+solve(i+2,a,dp,n)));
}
int main()
{
	int n;
	cin>>n;
	int a[n];
	vector<int> dp(n,-1);
	for(int i=0;i<n;i++)
		cin>>a[i];
	int m=solve(0,a,dp,n);
	cout<<m;
	return 0;
}

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

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000
//3
typedef long long ll;
typedef pair<int,int> pii;
priority_queue< int > pq;
priority_queue< int , vector<int> , greater<int> > rpq;
set<int>s;
set <int > :: iterator itr; 
vector<int> vec[1001];
int r,n,m,inp,tc;
int arr[1000007]= {};
int w;
ll dp[107][100100];
ll solve(ll cost[], ll weight[]){
	for(int i=0 ; i<= n; i++){
		for(int j=0 ; j<= w ;j++){
			if(i ==0 || j==0) dp[i][j] = 0;
			else{
				if(weight[i] <= j){
					dp[i][j] = max(dp[i-1][j] , cost[i] + dp[i-1][j-weight[i]]);
				} 
				else dp[i][j] = dp[i-1][j];
			}
		}
	}
//	for(int i=0 ; i<= n; i++){
//		for(int j=0 ; j<= w ;j++){
//			cout<<dp[i][j]<<" ";
//		}
//		cout<<endl;
//	}
	return dp[n][w];
}

int main()
{
	cin>>n>>w;
	ll cost[n+7],weight[w+7];
	for(int i=1 ;i<=n ;i++){
		cin>>weight[i]>>cost[i];
	}
	cout<<solve(cost,weight)<<endl;
	return 0;
}

//65 900 17 13

Measured memory_bytes: 82176
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 1000000;
#define all(v) v.begin(), v.end()

int main(){
  string S,T;
  cin >> S >> T;
  ll s=S.size(),t=T.size(),y=0;
  rep(i,s-t+1){
    ll x=0;
    rep(j,t){
      if(!(T.at(t-1-j)==S.at(s-1-i-j)||S.at(s-1-i-j)=='?')){
        x=1;
        break;
      }
    }
    if(x==0){
      rep(j,t){
        S.at(s-1-i-j)=T.at(t-1-j);
      }
      rep(j,s-t+1-i){
        if(S.at(j)=='?'){
          S.at(j)='a';
        }
      }
      y=1;
      break;
    }else{
      if(S.at(s-1-i)=='?'){
        S.at(s-1-i)='a';
      }
    }
  }
  if(y==1){
    cout << S << endl;
  }else{
    cout << "UNRESTORABLE" << endl;
  }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  string a,b,c,d;
  a=s[0]; b=s[1]; c=s[2]; d=s[3];
  if((a==b && a==c) || (b==c && b==d)){
    cout << "Yes" << endl;
  }else{
      cout << "No" << endl;
  }
}
  

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long m;
	cin >> m;
	long long s = 0;
	for(int i = 0;i < m;i++){
		long long d, c;
		cin >> d >> c;
		s += d * c;
		s += c * 9;
	}
	cout << ((s-1) / 9) - 1;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

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

//prototype declaration
int iin();
long long llin();
double din();
char cin();
void stin(char *s);
void iout(int i);
void llout(long long i);
void dout(double i);
void cout(char c);
void stout(char *s);
int gcd(int a, int b);
int lcm(int a, int b);
long long llgcd(long long a, long long b);
long long lllcm(long long a, long long b);
int asc(const void *a, const void *b);
int desc(const void *a, const void *b);

//main function
int main() {
    int a = iin();
    getchar();
    char op = cin();
    int b = iin();
    iout((op == '+' ? a + b : a - b));
    return 0;
}

//body function
int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

/*
    int型の最大公約数
*/

int gcd(int a, int b) {
    int r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

/*
    int型の最小公倍数
*/

int lcm(int a, int b) {
    int r = llgcd(a, b);
    a /= r;
    return a * b;
}

/*
    long long型の最大公約数
*/

long long llgcd(long long a, long long b) {
    long long r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

/*
    long long型の最小公倍数
*/

long long lllcm(long long a, long long b) {
    long long r = llgcd(a, b);
    a /= r;
    return a * b;
}

/*
    int型の昇順用比較関数
*/

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

/*
    int型の降順用比較関数
*/

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
//#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<double,double> P;
const ll INF = 4*1e18;
const int MOD = 1000000007;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 



signed main(){
  int n,m;cin>>n>>m;
  cout << (n*(n-1))/2 + (m*(m-1))/2 << endl;
}

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

namespace AtCoder
{
    static class Program
    {
        static void Main()
        {
            //ここから

            var vs = IO.ReadLineToIntList();
            var ans = vs.All(v => v > 0 && 10 > v) ? vs[0] * vs[1] : -1;

            //ここまで
            Console.WriteLine(ans);
            Console.ReadKey();
        }

        public static double ToAngle(this double radian)
        {
            return (double)(radian * 180 / Math.PI);
        }

        public static double ToRadian(this double angle)
        {
            return (double)(angle * Math.PI / 180);
        }
    }

    static class Func
    {
        static long mod = 1000000007;
        static public void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }
        static public long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }
        static public long LCM(long a, long b) { return (long)a * b / GCD(a, b); }
        static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); }

        static public long Conbination(int n,int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * Conbination(n - 1, m - 1) / m;
        }

        static public void Factoring(long num, ref long[] vs)
        {
            if (num == 1)
            {
                vs[1]++;
            }
            for (long i = 2; i < (long)Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    vs[i]++;
                    Factoring(num / i, ref vs);
                }
            }
            vs[1]++;
        }
    }

    static class IO
    {
        static public string ReadLineToString() { return Console.ReadLine(); }
        static public int ReadLineToInt() { return int.Parse(Console.ReadLine()); }
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public List<string> ReadLineToStringList() { return Console.ReadLine().Split(' ').ToList(); }
        static public List<int> ReadLineToIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }

        static public void WriteStrings(object[] strings) { foreach (var o in strings) { Console.Write(o + " "); } }
    }
}

Measured memory_bytes: 13396
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;

using pii = pair<int, int>;
int n, m, a[1000], b[1000];
int ac[1000001], bc[1000001];
vector<int> f;
int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++)
		scanf("%d", a + i);
	sort(a, a + n);
	for (int i = 0; i < m; i++)
		scanf("%d", b + i);
	sort(b, b + m);

	bool uniq = true;
	for (int i = 0; i + 1 < n; i++)
		if (a[i] == a[i + 1])
			uniq = false;
	for (int i = 0; i + 1 < m; i++)
		if (b[i] == b[i + 1])
			uniq = false;
	if (!uniq) {
		printf("0\n");
		return 0;
	}

	f.reserve(n*m);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++) {\
			if (a[i] <= b[j])
				ac[a[i]]++;
			if (a[i] >= b[j])
				bc[b[j]]++;
			f.emplace_back(min(a[i], b[j]));
		}
	sort(f.begin(), f.end());
	ll pat = 1, fre = 0;
	for (int i = n * m; 1 <= i; i--) {
		while (!f.empty() && i <= f.back())
			fre++, f.pop_back();
		if (ac[i] && bc[i])
			pat *= 1;
		else if (ac[i])
			pat *= ac[i];
		else if (bc[i])
			pat *= bc[i];
		else
			pat *= fre;
		pat %= (ll)(1e9 + 7);
		fre--;
	}
	printf("%lld\n", pat);
}

Measured memory_bytes: 6272
/*input
5 2
1 0 0 1 0
*/
/*

**************************
*						 *
* AUTHOR :: knight_coder *
*						 *
**************************

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rrep(i,m,n)	for(lld i=m;i>=n;i--)
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; 
//change null_type to get ordered_map
#define N  200005
lld a[N],b[N];
void solve()
{	
	lld n,k;
	cin >> n >> k;
	rep(i,0,n){
		cin >> a[i];
	}
	while(k>0){
		rep(i,0,n){
			lld t=min(n-1,a[i]+i);
			lld r=max(0LL,i-a[i]);
			b[r]++,b[t+1]--;
		}	
		rep(i,1,n){
			b[i]+=b[i-1];
		}
		bool f=1;
		rep(i,0,n){
			a[i]=b[i];
			if(a[i]!=n){
				f=0;
			}
			b[i]=0;
		}
		b[n]=0;
		k--;
		if(f){
			break;
		}
	}
	rep(i,0,n){
		cout << a[i] << ' ';
	}
	cout << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}


Measured memory_bytes: 6704
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<random>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vt>vvt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"


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

	int a;
	cin>>a;
	cout<<a+a*a+a*a*a<<endl;
}


Measured memory_bytes: 3628
N = int(input())
A = sorted(list(map(int,input().split())))[::-1]
if N%2 == 1:
    ans = sum(A[0:N//2])
    ans += sum(A[1:N//2 + 1])
else:
    ans = sum(A[0:N//2-1])
    ans += sum(A[1:N//2])
    ans += A[N//2 - 1]
print(ans)

Measured memory_bytes: 31492
//! ----------------------------------------------
//! 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, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[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()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[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()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

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

fn main() {
    let (A, B) = read!(i64, i64);

    println!(
        "{}",
        if A <= 5 {
            0
        } else if A <= 12 {
            B / 2
        } else {
            B
        }
    )
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main(){
    int h,w; cin>>h>>w;
    vector<string> G(100);
    for(int i=0;i<h;i++) cin>>G[i];
    int dx[8] = {1,1,1,0,-1,-1,-1,0};
    int dy[8] = {-1,0,1,1,1,0,-1,-1};
    for(int y=0;y<h;y++){
        for(int x=0;x<w;x++){
            if(G[y][x]=='#')cout<<'#';
            else{
                int cnt = 0;
                for(int i=0;i<8;i++){
                    int ny = y+dy[i];
                    int nx = x+dx[i];
                    if(0<=ny&&ny<h&&0<=nx&&nx<w){
                        if(G[ny][nx]=='#')cnt++;
                    }
                }
                cout<<cnt;
            }
            if(x==w-1)cout<<endl;
        }
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	int cnt[];
	int ans[];
	int info[][];
	boolean judge;
	boolean judge2;
	int n, x, m;
	int max = 0;

	void run() {
		n = sc.nextInt();
		x = sc.nextInt();
		m = sc.nextInt();
		cnt = new int[n + 1];
		ans = new int[n + 1];
		info = new int[m][3];
		judge = false;
		for (int i = 0; i < m; i++) {
			info[i][0] = sc.nextInt();
			info[i][1] = sc.nextInt();
			info[i][2] = sc.nextInt();
		}
		dfs(0);
		if (!judge2) {
			System.out.println(-1);
		} else {
			for (int j = 1; j < n; j++) {
				System.out.print(ans[j] + " ");
			}
			System.out.println(ans[n]);
		}
	}

	void dfs(int oriCnt) {
		if (oriCnt == n + 1) {
			boolean use[] = new boolean[n + 1];
			judge = false;
			for (int i = 0; i < m; i++) {
				int sum = 0;
				for (int j = info[i][0]; j <= info[i][1]; j++) {
					use[j] = true;
					sum += cnt[j];
				}
				if (sum == info[i][2]) {
					judge = true;
				} else {
					judge = false;
				}
				if (!judge) {
					return;
				}
			}
			if (judge) {
				judge2 = true;
				int sum = 0;
				for (int j = 1; j <= n; j++) {
					if (!use[j]) {
						cnt[j] = x;
					}
					sum += cnt[j];
				}
				if (sum > max) {
					for (int k = 1; k <= n; k++) {
						ans[k] = cnt[k];
					}
				}
			}
			return;
		} else {
			for (int i = 0; i <= x; i++) {
				cnt[oriCnt] = i;
				dfs(oriCnt + 1);
			}
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 155372
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <unordered_set>

using namespace std;
typedef long long ll;

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

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  unordered_map<int,int>mp;
  int a;
  REP(i,N){
    cin>>a;
    mp[a]++;
  }
  int ans=0;
  REP(i,100000){
    chmax(ans,mp[i-1]+mp[i]+mp[i+1]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4388
s = gets.strip.split("")
ary = ["A", "C", "G", "T"]
count = 0
max = []
s.each do |i|
  if ary.include?(i)
    count += 1
    max.push(count)
  else
    max.push(count)
    count = 0
  end
end
puts max.max

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

//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//template <typename T> using orderSet =
//tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef unsigned long long llu;
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout)
#define inf 1e9
#define mod 132021913
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define FastRead ios_base::sync_with_stdio(0);cin.tie(nullptr);
ll power(ll b,ll p) {ll res=1,x=b; while(p > 0){if(p&1ll)res=res*x;x=x*x;p >>= 1;} return res;}

#define MX 10000007
bool mark[MX];
ll divs[MX], val[MX], cm[MX];

void sieve()
{
	for(ll i = 1; i < MX; i++) {
		val[i] = i;
		divs[i] = 1;
	}

	for(ll i = 2; i < MX; i+=2) {
		ll cnt = 0;
		while(val[i]%2==0) {
			val[i]/=2;
			cnt++;
		}
		divs[i] *= (cnt+1);
	}

	for(ll i = 3; i*i < MX; i+=2) {
		if(!mark[i]) {
			for(ll j = i; j < MX; j+=i) {
				ll cnt = 0;
				while(val[j]%i == 0) {
					val[j]/=i;
					cnt++;
				}
				divs[j] *= (cnt+1);
			}
		}
	}

	for(int i = 1; i < MX; i++) {
		if(val[i] != 1) divs[i] *= 2;
		cm[i] = cm[i-1] + (i*divs[i]);
	}

}

int main()
{
	sieve();

	ll n;
	cin>>n;

	cout<<cm[n]<<endl;
}










Measured memory_bytes: 238000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int x;cin>>x;
    int a=0;
    if(x%2==0||x%5==0){puts("-1");exit(0);}
    for(int i=1;;i++){
        a=(a*10+7)%x;
        if(a==0) {cout<<i;break;}
    }
}


Measured memory_bytes: 3628
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

def check():
    for i in range(N-M+1):
        for j in range(N-M+1):
            if B[0] == A[i][j:j+M]:
                for k in range(1,M):
                    if B[k] != A[i+k][j:j+M]:
                        break
                else:
                    return True
    return False

if check():
    print('Yes')
else:
    print('No')



Measured memory_bytes: 38256