akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
int main(){
  char s[11];
  int l, max = 0, k = 0;
  scanf("%s", s);
  l = strlen(s);
  for(int i = 0; i < l; ++i){
    if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
      ++k;
      if(max < k) max = k;
    }else k = 0;
  }
  printf("%d\n", max);
  return 0;
}

Measured memory_bytes: 128
MAX = 100000
MOD = 10 ** 9 + 7
 
def mod_power(n, p, m)
  #フェルマーの小定理
  return 1 if p == 0
  if p % 2 == 0
    t = mod_power(n, p / 2, m)
    return t * t % m
  else
    return n * mod_power(n, p - 1, m) % m
  end
end
 
def cominit()
  #階乗と階乗の逆元を用意する
  @fac = []
  @fac[0] = 1
  @fac[1] = 1
  @finv = []
  @finv[0] = 1
  @finv[1] = 1
 
  2.upto(MAX) do |i|
    @fac[i] = @fac[i-1] * i % MOD
  end
 
  @finv[MAX] = mod_power(@fac[MAX], MOD - 2, MOD)
  (MAX-1).downto(2) do |i|
    @finv[i] = @finv[i+1] * (i + 1) % MOD
  end
end
 
def comb(n, r)
  return 0 if n < r
  return 1 if n == r
  return @fac[n] * @finv[r] * @finv[n - r] % MOD
end
 
def main
  n, k = gets.chomp.split.map(&:to_i)
  array = gets.chomp.split().map(&:to_i).sort.reverse
  cominit()
  ans = 0
  #各Ciについてmax, minを求める
  array.each_with_index do |c, i|
    next if i > n - k
    ans += c * comb(n - i - 1, k - 1) % MOD 
  end
 
  array.sort!
 
  array.each_with_index do |c, i|
    #ciより低いもののカウント
    next if i > n - k
    ans -= c * comb(n - i - 1, k - 1) % MOD
  end
 
  return ans % MOD
end
 
puts main

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

#define     str             string
#define     PB              push_back
#define     FOR(i,a,n)      for(int i=a;i<=n;i++)
#define     FORA(i,a,n)     for(int i=a;i<n;i++)
#define     srt(a)          sort(a.begin(),a.end())
#define     rev(a)          reverse(a.begin(),a.end())

#define     c1(a)           cin>>a
#define     c2(a,b)         cin>>a>>b
#define     c3(a,b,c)       cin>>a>>b>>c
#define     c4(a,b,c,d)     cin>>a>>b>>c>>d

#define     p(a)            cout<<a<<endl


#define     sci1(a)         scanf("%d",&a)
#define     sci2(a,b)       scanf("%d %d",&a,&b)
#define     sci3(a,b,c)     scanf("%d %d %d",&a,&b,&c)
#define     sci4(a,b,c,d)   scanf("%d %d %d %d",&a,&b,&c,&d)

#define     pri1(a)         printf("%d\n",a)
#define     pri2(a,b)       printf("%d %d\n",a,b)
#define     pri3(a,b,c)     printf("%d %d %d\n",a,b,c)
#define     pri4(a,b,c,d)   printf("%d %d %d %d\n",a,b,c,d)

#define     fast            ios_base::sync_with_stdio(false);cin.tie(NULL)

#define     intahn          int a,b,c,d,e,f,g,h,n

#define     pi              acos(-1)

typedef     long long int   ll;
typedef     vector<ll>      vi;
typedef     vector<str>     vs;
typedef     pair<ll,ll>     paii;
typedef     pair<ll,str>    pais;
int main(){
    intahn;

    cin>>a>>b;

    c=b-a+1;
    d=b+a-1;
    for(int i=c;i<=d;i++){
        cout<<i<<" ";
    }

}


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

void solve() {
	string s1, s2;
	cin >> s1 >> s2;
	int n = s1.size();
	int m = s2.size();
	int dp[n + 1][m + 1];
	int i, j;
	for (i = 0; i <= n; i++) {
		for (j = 0; j <= m; j++) {
			if (i == 0 || j == 0) {
				dp[i][j] = 0;
				continue;
			}
			else if (s1[i - 1] == s2[j - 1])dp[i][j] = 1 + dp[i - 1][j - 1];
			else dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
		}
	}
	int len = dp[n][m];

	i = n, j = m;

	string str = "";

	while (i > 0 && j > 0) {
		if (s1[i - 1] == s2[j - 1]) {
			str += s1[i - 1];
			i --;
			j --;
		}
		else {
			if (dp[i - 1][j] > dp[i][j - 1])i --;
			else j --;
		}
	}

	reverse(str.begin(), str.end());

	cout << str << endl;
	return;
}

int32_t main() {
	std::ios::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 73944
#include <iostream>
#include <vector>

int main() {
  unsigned N;
  std::cin >> N;
  std::string s;
  std::cin >> s;
  std::vector<bool> sheep(N);
  auto same = [] (bool which, char c) {
    return (which == (c == 'o'));
  };
  for (unsigned i = 0; i < 4; ++i) {
    sheep[0] = i % 2 == 0;
    sheep[1] = i / 2 == 0;
    for (unsigned j = 2; j < N; ++j) {
      if (same(sheep[j-1], s[j-1])) {
        sheep[j] = sheep[j-2];
      } else {
        sheep[j] = !sheep[j-2];
      }
    }
    if (same(sheep[N-1], s[N-1]) == (sheep[N-2] == sheep[0])) {
      if (same(sheep[0], s[0]) == (sheep[N-1] == sheep[1])) {
        for (auto p = sheep.begin(); p < sheep.end(); ++p) {
          if (*p) { std::cout << "S"; }
          else { std::cout << "W"; }
        }
        return 0;
      }
    }
  }
  std::cout << -1;
  return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

ll GCD(ll a, ll b) {
    return (b > 0) ? GCD(b, a % b) : a;
}

ll LCM(ll a, ll b) {
    return a / GCD(a, b) * b;
}

int main() {
    ll n, k;
    cin >> n >> k;
    if(n < k){
        cout << min(n, abs(n - k)) << endl;
        return 0;
    }else if(n == k){
        cout << 0 << endl;
        return 0;
    }else{
        if(n % k == 0){
            cout << 0 << endl;
            return 0;
        }else{
            cout << min(n % k, k - n % k) << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
#define fst first
#define snd second
using ll = long long;
using I = pair<int, int>;
const int D = 16;

ll g(ll n, int k) {
  vector<int> dig(D, 0), sum(D + 1, 0);
  for (int i = 0; i < D; i++) {
    dig[i] = n % 10;
    sum[i + 1] = sum[i] + dig[i];
    n /= 10;
  }
  ll m = 0;
  bool eq = true;
  for (int i = D - 1, j = D - 1; i > 0; i--) {
    j = min(i - 1, j);
    while (j >= 0 && dig[j] == 9) --j;
    for (int d = eq ? dig[i] : 0; d <= 9; d++) {
      bool neq = eq & (d == dig[i]);
      int mn = 0, mx = 9 * i;
      if (neq) {
        mn += 9 * (i - j - 1);
        if (j >= 0) {
          mn += sum[j + 1] == dig[j] ? dig[j] : dig[j] + 1;
        }
      }
      if (mn <= k - d && k - d <= mx) {
        m = m * 10 + d;
        k -= d;
        eq = neq;
        break;
      }
    }
  }
  m = m * 10 + k;
  return m;
}

ll f(ll n) {
  ll p = 1, q = 0;
  for (ll k = 1; k <= D * 9; k++) {
    ll m = g(n, k);
    if (p * k > m * q || (p * k == m * q && m < p)) {
      p = m;
      q = k;
    }
  }
  return p;
}

int main() {
  int K;
  while (cin >> K) {
    vector<ll> res;
    res.push_back(1);
    while (res.size() < K) {
      ll n = res.back();
      res.push_back(f(n + 1));
    }
    for (ll x : res) cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 256
package main

import (
        "fmt"
        "strings"
)

func PlacingMarbles(td string) int {
        slice := strings.Split(td,"")
        var result int
        for _, str:=range slice {
                if str == "1" {
                        result += 1
                }
        }
        return result
}




func main() {
        var hoge string
        fmt.Scan(&hoge)
        defer fmt.Println(PlacingMarbles(hoge))
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>

using namespace std;

int main(){
    string S,T;
    cin>>S>>T;
    int s,t;
    for(s=0,t=0;s<S.size();s+=2){
        while(t<T.size()&&T[t]!=S[s])t++;
        if(t>=T.size()) break;
        t++;
    }
    if(s>=S.size()){
        cout<<"Yes"<<endl;
        return 0;
    }
    for(s=1,t=0;s<S.size();s+=2){
        while(t<T.size()&&T[t]!=S[s])t++;
        if(t>=T.size()) break;
        t++;
    }
    if(s>=S.size()){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3188
package main

import (
  "fmt"
  _ "sort"
  _ "math"
)

func main() {
  var n int
  fmt.Scan(&n)

  a := make([]int, n)
  r := make([]int, n)
  k := 0

  for i:=0; i<n; i++ {
    fmt.Scan(&a[i])
    k += a[i]
  }

  s := 0
  for i:=0; i<n; i++ {
    t := i * 2 % n
    u := (i * 2 + 1) % n
    v := (i * 2 + 2) % n
    r[v] = r[t] + (a[u] - a[t]) * 2
    s += r[v]
  }

  v := (k-s) / n
  for i:=0; i<n; i++ {
    r[i] += v
    if i < n-1 {
      fmt.Printf("%d ", r[i])
    } else {
      fmt.Printf("%d\n", r[i])
    }
  }
}


Measured memory_bytes: 6528
#include<stdio.h> 
int main(){
    int a,b,c,tmp,i,j; 
    scanf("%d",&i);

    for(j=1;j<=i;j++){
        scanf("%d %d %d",&a,&b,&c);

        if(a>b){
            tmp=a;
            a=b;
            b=tmp;
        }

        if(b>c){
            tmp=b;
            b=c;
            c=tmp;
        } 

        if(a>b){
            tmp=a;
            a=b;
            b=tmp;
        } 

        if(a*a+b*b==c*c)
            printf("YES\n"); 
        else
            printf("NO\n");
    }

    return 0; 
} 


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

#define sz(x) int(x.size())
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin); freopen(Task".out", "w", stdout);
  int a, b, c; cin >> a >> b >> c;
  cout << (a + b + c >= 22 ? "bust" : "win");
}



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



ll get_max(vector<ll>& bit,int i)
{
    ll res=0;
    while(i>0)
    {
        res=max(res,bit[i]);
        i-=i & -i;
    }
    return res;
}

void update(int n,vector<ll>& bit,int i,ll x)
{
    ll res=x;
    while(i<=n)
    {
        bit[i]=max(res,bit[i]);
        i+=i & -i;
    }
}

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

    vector<ll>bit(n+1,0);

    for(int i=0;i<n;i++)
    {
        ll sum=get_max(bit,h[i]);
        update(n,bit,h[i],a[i]+sum);
    }
    cout<<get_max(bit,n);
}

Measured memory_bytes: 8012
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    ll a, ans = 0;
    rep(0, i, N)
    {
        cin >> a;
        if ((i % 2 == 0) && (a % 2 == 1))
        {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
//const long long INF = 1LL << 60;
//const int MOD = 1000000007;
signed main(void){
    int n,qr; cin>>n>>qr;
    vector <vector<int>> g(n,vector <int>());
    
    vector <int> data(n); 
    vector <int> ans(n); 
    for(int i=1;i<=n-1;i++){
        int a,b; cin>>a>>b; a--; b--;
        g[a].push_back(b);
        
    }
    rep(i,qr){
        int a,b; cin>>a>>b;
        a--;
        data[a] += b;
    }
    queue <int> q;
    q.push(0);
    while(!q.empty()){
        int now = q.front(); q.pop();
        ans[now] += data[now];
        rep(i, g[now].size()){
            int ne = g[now][i];
            q.push(ne);
            ans[ne] += ans[now];
        }
    }
    rep(i,n) cout<<ans[i]<<' ';
}


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

int main(void){
    int D, N, i, j, k, x, y, z, count;
    double result, sum;
    scanf("%d %d", &D, &N);
    if(N > 10|N < 2|D > 10|D < 1){
    
    //    return 0;
    }
    int dim[D][N];
    for(i = 0; i < D; i++){
        for(j = 0; j < N; j++){
            scanf("%d", &dim[i][j]);
            if(dim[i][j] > 20| dim[i][j] < -20){
    
    //            return 0;
            }
        }
    }
    
    i = 0;
    j = 0;
    count = 0;
    for(j=0; j<D-1; j++){
        for(k=j+1; k<D; k++){
            sum = 0;
            for(i=0; i<N; i++){
                x = dim[j][i];
                y = dim[k][i];
                z = abs(x - y);
                sum = sum + z * z;
                
            }result = sqrt(sum);
            if(ceil(result) != floor(result)){
            } else{
                count++;
            }
        }
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 128
<?php
$input = explode(' ',trim(fgets(STDIN)));
$w = $input[0]; 
$h = $input[1];
$x = $input[2];
$y = $input[3];
$r = $input[4];

$rx1 = $x+$r;
$rx2 = $x-$r;
$ry1 = $y+$r;
$ry2 = $y-$r;

if(($rx1<=$w and $ry1<=$h) and ($rx2>=0 and $ry2>=0)){
    echo 'Yes';
}else{
    echo 'No';
}
?>

Measured memory_bytes: 15416
// chalo phir code karthe hh bina koi backchodi ke 
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int vis[N];
int dp[N];
int ans[N];
vector<int>v[N];
void bfs(int s){
  queue < int> q;
  q.push(s);
  vis[s]=1;
  while(!q.empty()){
    int x = q.front();
    q.pop();
    for(auto i : v[x]){
      if(!vis[i]){
        dp[i] = 1 + dp[x];
        ans[i]= x;
        vis[i]=1;
        q.push(i);
      }
    }
  }
}
signed main(){
  // #ifndef ONLINE_JUDGE
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  // #endif
  IOS;
  int T=1;
  // cin >> T;
  while(T--){
    int n , m;
    cin >> n >> m;
    fm{
      int x ,y;
      cin >> x>> y;
      v[x].pb(y);
      v[y].pb(x);
    }
    bfs(1);
    int f =1;
    for(int i =2;i<=n;i++){
      if(!vis[i])f =0; 
    }
    if(!f)cout<<"No";
    else{
      cout<<"Yes\n";
      for(int i =2;i<=n;i++){
        cout<<ans[i]<<endl; 
      } 
    }
  
  }
  return 0;
}

Measured memory_bytes: 59044
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Vec  = vector<int>;
using Graph = vector<Vec>;

int		main(void)
{
	ld a, b, n;
	cin >> a >> b >> n;
	ld x;
	if (b - 1 < n)
		x = b - 1;
	else
		x = n;
	cout << floor(a * x / b) << endl;
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
ll n, k, d = 0, a, p[105], di;
 
int main()
{
  	ios_base::sync_with_stdio(false);
  	cin.tie(NULL); cout.tie(NULL);
  	memset(p, 0, sizeof(p));
	cin >> n >> k;
  	for (ll i = 1; i <= k; i++)
    {
    	cin >> di;
      	for (ll j = 1; j <= di; j++)
        {
        	cin >> a;
          	p[a] ++;
        }
    }
  	for (ll i = 1; i <= n; i++)
      	if (p[i] == 0) d++;
  	cout << d;
}




Measured memory_bytes: 3644
a,b,c = list(map(int, input().split()))

if c - b - a > 0:
  if c**2 + a**2 + b**2 - 2*a*c - 2*b*c - 2*a*b > 0:
    print("Yes")
  else:
    print("No")
else:
  print("No")
  

Measured memory_bytes: 2940
from collections import deque

from sys import stdin, setrecursionlimit


def main():
    h, w = map(int, stdin.readline().split())
    g = [list(map(str, list(input()))) for _ in range(h)]

    ans = 0

    for i in range(h):
        for j in range(w):
            if g[i][j] == '.':
                d = [[-1 for _ in range(w)] for _ in range(h)]
                q = deque()

                d[i][j] = 0
                q.append([i, j])

                while q:
                    vi, vj = q.popleft()

                    if vi > 0:
                        if g[vi - 1][vj] == '.' and d[vi - 1][vj] == -1:
                            d[vi - 1][vj] = d[vi][vj] + 1
                            q.append([vi - 1, vj])
                    if vi < h - 1:
                        if g[vi + 1][vj] == '.' and d[vi + 1][vj] == -1:
                            d[vi + 1][vj] = d[vi][vj] + 1
                            q.append([vi + 1, vj])
                    if vj > 0:
                        if g[vi][vj - 1] == '.' and d[vi][vj - 1] == -1:
                            d[vi][vj - 1] = d[vi][vj] + 1
                            q.append([vi, vj - 1])
                    if vj < w - 1:
                        if g[vi][vj + 1] == '.' and d[vi][vj + 1] == -1:
                            d[vi][vj + 1] = d[vi][vj] + 1
                            q.append([vi, vj + 1])
                tmp_max = 0
                for hi in range(h):
                    for wj in range(w):
                        tmp_max = max(tmp_max, d[hi][wj])
                ans = max(ans, tmp_max)

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 61552
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

signed main(){
	ll N,A,B;
	cin >> N >> A >> B;
	cout << min(A,B) << ' ' << max(0,A+B-N) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <set>
#include <stack>
#include <string>
#include <utility>

using namespace std;

int main() {
  int n;

  cin >> n;

  cout << (n + n * n + n * n * n) << endl;

  return 0;
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = (int)1e9+7;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int k,x;
	cin>>k>>x;
	k = k*500;
	if(k>=x){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	
	
	
	return 0;
}
	
	
	
	
	
	
	
	
	
	
	

























Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(){
  ll n;
  cin>>n;
  vector<pair<string ,pair<ll,ll> > > vp;
  rep(i,0,n){
    string s;
    ll p;
    cin>>s>>p;
    vp.pb(mp(s,mp(-p,i+1)));
  }
  sort(all(vp));
  rep(i,0,vp.sz){
    cout << vp[i].se.se << endl;
  }
  return 0;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define FORalld(it, a) for (__typeof((a).rbegin()) it = (a).rbegin(); it != (a).rend(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
template<class T> inline T isqrt(T k) {T r = sqrt(k) + 1; while (r * r > k) r--; return r;}
template<class T> inline T icbrt(T k) {T r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}

const int maxn = 100000 + 10;
int n;
long long a[maxn];
int b[maxn];

void solve() {
	cin >> n;
	FOR(i, 0, n) cin >> a[i] >> b[i];
	long long ans = 0, tot = 0;
	FORd(i, n, 0) {
		a[i] += tot;
		long long k = (a[i] + b[i] - 1) / b[i] * b[i];
		ans += k - a[i];
		tot += k - a[i];
		a[i] = k;
	}
	cout << ans << "\n";
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
	solve();
#ifdef _LOCAL_
	//printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
#include <bitset>
#include <string>
using namespace std;
// #define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

const int MOD = 998244353;

long long modpow(long long x, long long n) {
    if (n == 0) {
        return 1;
    } else if (n % 2 == 0) {
        long long h = modpow(x, n / 2);
        return h * h % MOD;
    } else {
        return x * modpow(x, n - 1) % MOD;
    }
}

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    int s = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        s += a[i];
    }
    vector<vector<long long>> dp1(N + 1, vector<long long>(s + 1, 0));
    auto dp2 = dp1;
    dp1[0][0] = 1, dp2[0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= s; j++) {
            dp1[i + 1][j] += dp1[i][j] * 2;
            dp1[i + 1][j] %= MOD;
            dp2[i + 1][j] += dp2[i][j];
            dp2[i + 1][j] %= MOD;
            if (j - a[i] < 0) {
                continue;
            }
            dp1[i + 1][j] += dp1[i][j - a[i]];
            dp1[i + 1][j] %= MOD;
            dp2[i + 1][j] += dp2[i][j - a[i]];
            dp2[i + 1][j] %= MOD;
        }
    }
    long long res = modpow(3, N);
    for (int j = 0; j <= s; j++) {
        if (2 * j < s) {
            continue;
        }
        res -= dp1[N][j] * 3;
        res %= MOD;
        if (res < 0) {
            res += MOD;
        }
    }
    if (s % 2 == 0) {
        res += dp2[N][s / 2] * 3;
        res %= MOD;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 423104
use io::*;
use std::*;

const YES: &'static str = "Yes";
const NO: &'static str = "No";
fn solve(N: i64, K: i64, Q: i64, A: Vec<i64>) {
    let mut counter = vec![0i64; N as usize];
    for i in A {
        counter[(i-1) as usize] += 1;
    }
    for i in 0..N {
        println!("{}", if counter[i as usize] > Q-K { YES } else { NO });
    }
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
fn main() {
    let con = read_string();
    let mut scanner = Scanner::new(&con);
    let mut N: i64;
    N = scanner.next();
    let mut K: i64;
    K = scanner.next();
    let mut Q: i64;
    Q = scanner.next();
    let mut A: Vec<i64> = vec![0i64; (Q) as usize];
    for i in 0..(Q) as usize {
        A[i] = scanner.next();
    }
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(move || solve(N, K, Q, A)).unwrap().join().unwrap();
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 11004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    priority_queue<ll> pq;
    rep(i, n) pq.push(a[i]);
    rep(i, m) {
        ll v = pq.top(); pq.pop();
        v /= 2;
        pq.push(v);
    }
    ll ans = 0;
    while(!pq.empty()) {
        ans += pq.top();
        pq.pop();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2168
import heapq

def d():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    h = []
    for i in range(N):
        heapq.heappush(h, -A[i])

    for _ in range(M):
        val = -1 * heapq.heappop(h)
        heapq.heappush(h, -1 * (val // 2))

    print(-1 * sum(h))


if __name__ == '__main__':
    d()


Measured memory_bytes: 64792
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	map<int, int> occs;
	int a;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		++occs[a];
	}

	if (occs.size() > 3) {
		cout << "No\n";
	} else {
		if (occs.size() == 3) {
			auto it = occs.begin();
			int x = it->first;
			int xc = it->second;
			++it;
			int y = it->first;
			int yc = it->second;
			++it;
			int z = it->first;
			int zc = it->second;
			if (xc != yc || xc != zc || yc != zc || (x ^ y ^ z) != 0) {
				cout << "No\n";
			} else {
				cout << "Yes\n";
			}
		}
		else if (occs.size() == 2) {
			auto it = occs.begin();
			int x = it->first;
			int xc = it->second;
			++it;
			int y = it->first;
			int yc = it->second;
			if ((!x && 2 * xc == yc) || (!y && 2 * yc == xc)) {
				cout << "Yes\n";
			} else {
				cout << "No\n";
			}
		} else {
			if ((occs.begin())->first != 0) {
				cout << "No\n";
			} else {
				cout << "Yes\n";
			}
		}
	}

	return 0;

}

Measured memory_bytes: 3840
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
using namespace std;

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int lowerC_AB;
  lowerC_AB = 2 * c < (a + b) ? 2 * c : a + b;
  int smaller;
  smaller = x < y ? x : y;
  int total = 0;
  total += smaller * lowerC_AB;
  if (x < y) {
    int lowerB_C = b < c * 2 ? b : c * 2;
    total += (y - x) * lowerB_C;
  } else {
    int lowerA_C = a < c * 2 ? a : c * 2;
    total += (x - y) * lowerA_C;
  }
  cout << total << endl;
  return 0;
}

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

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

typedef long long ll;

using namespace std;

const ll MOD=1000000007;

ll xgcd(ll a,ll b,ll &x,ll &y){
	if(b==0){ x=1; y=0; return a; }
	ll g=xgcd(b,a%b,y,x); y-=a/b*x;
	return g;
}

ll modinv(ll a,ll m){
	ll x,y;
	if(xgcd(a,m,x,y)==1) return (x+m)%m;
	return -1;
}

int main(){
	ll h,w,k; cin>>h>>w>>k;

	ll a=1; // hw-2 choose k-2
	rep(i,k-2) a=a*(h*w%MOD-i-2)%MOD*modinv(k-i-2,MOD)%MOD;

	ll b=0; // sum_{i=1}^{w-1} i(w-i)
	rep(i,w-1) b=(b+(i+1)*(w-i-1)%MOD)%MOD;

	ll c=0; // sum_{i=1}^{h-1} i(h-i)
	rep(i,h-1) c=(c+(i+1)*(h-i-1)%MOD)%MOD;

	cout<<a*(h*h%MOD*b%MOD+w*w%MOD*c%MOD)%MOD<<endl;

	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main(void) {
	int n, a, b, c, d, e;  
	cin >> n >> a >> b >> c >> d >> e;
	cout << n + a + b + c + d + e - min(a, min(b, min(c, n))) - min(d, e) << endl;
}


Measured memory_bytes: 3096
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Mll = M<ll, ll>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin(),ie=(c).rend();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n;

int main() {
    cin >> n;
    Vi a(n);
    REP(i, n) cin >> a[i];
    sort(ALL(a));

    cout << a.back() << ' ';
    int v; double d = 1e9;
    REP(i, n-1) {
        double diff = abs(a.back() / 2.0 - a[i]);
        if (d > diff) {
            v = a[i];
            d = diff;
        }
    }
    cout << v << '\n';

    return 0;
}


Measured memory_bytes: 640
n,m,v,p=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
ans=p
S=[A[p-1]]
for i in range(p,n):
    S.append(S[-1]+A[i])
for i in range(p,n):
    if v<=p+n-i-1:
        if A[p-1]-A[i]<=m:
            ans+=1
    else:
        if A[p-1]-A[i]<=m and S[i-p]-A[i]*(i-p+1)<=(n-v)*m:
            ans+=1
        else:
            break
print(ans)

Measured memory_bytes: 14964
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		String str = scanner.nextLine();
		String str2 = "";
		for(char c : str.toCharArray()){
			if(c == 'B'){
				if(!str2.equals("")){
				str2 = str2.substring(0,str2.length()-1);
				}
			}
			else{
				str2 += c;
			}
		}
		System.out.println(str2);
	}

}


Measured memory_bytes: 9424
input = input()
split = input.split()
H1 = split[0]
M1 = split[1]
H2 = split[2]
M2 = split[3]
K = split[4]
h = int(H2)*60 - int(H1)*60 + int(M2) - int(M1) - int(K)
print(h)

Measured memory_bytes: 9164
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
  vector<string> S(8);
  for(int i = 0; i < 8; ++i){
    cin >> S[i];
  }
  bool f = true, g = true, h = true;
  int player = -1, M, m, x, y, s, t, u, v, pass = 0;
  char mark, opponent;
  vector<int> dx, dy;
  dx = {0,1,-1}; dy = {0,1,-1};
  while (f&&g&&h&&pass<2){
    f = false; g = false; h = false;
    M = 0;
    s = -1;
    t = -1;
    if (player > 0) {
      mark = 'x';
      opponent = 'o';
    }else{
      mark = 'o';
      opponent = 'x';
    }
    for (int i = 0; i < 8; ++i){
      for (int j = 0; j < 8; ++j){
	if (S[i][j] == 'x') f = true;
	else if (S[i][j] == 'o') g = true;
	else{//S[i][j] == '.'
	  h = true;
	  m = 0;
	  for (int k = 0; k < 3; ++k){//8??????????????????
	    for (int l = 0; l < 3; ++l) {
	      if (k || l){
		x = i; y = j;
		while (0 <= x+dx[k] && x+dx[k] < 8 && 0 <= y+dy[l] && y+dy[l] < 8 && S[x+dx[k]][y+dy[l]] == opponent){
		  x += dx[k];
		  y += dy[l];
		}
		if (0 <= x+dx[k] && x+dx[k] < 8 && 0 <= y+dy[l] && y+dy[l] < 8 && S[x+dx[k]][y+dy[l]] == mark){
		  m += max(abs(x-i), abs(y-j));
		}
	      }
	    }
	  }
	  if ((m >= M && player > 0)||(m > M && player < 0)) {
	    s = i;
	    t = j;
	    M = m;
	  }
	}
      }
    }
    if (M > 0){//??????????????????????????´?????¶????????´??°
      S[s][t] = mark;
      pass = 0;
      for (int k = 0; k < 3; ++k){//8??????????????????
	for (int l = 0; l < 3; ++l) {
	  if (k || l){
	    x = s; y = t;
	    while (0 <= x+dx[k] && x+dx[k] < 8 && 0 <= y+dy[l] && y+dy[l] < 8 && S[x+dx[k]][y+dy[l]] == opponent){
	      x += dx[k];
	      y += dy[l];
	    }
	    if (0 <= x+dx[k] && x+dx[k] < 8 && 0 <= y+dy[l] && y+dy[l] < 8 && S[x+dx[k]][y+dy[l]] == mark){
	      while (x != s || y != t) {
		S[x][y] = mark;
		x -= dx[k];
		y -= dy[l];
	      }
	    }
	  }
	}
      }
    }else ++pass;
    player *= -1;
    //    for (int i = 0; i < 8; ++i) cout << S[i] << endl;
  }
  for (int i = 0; i < 8; ++i) cout << S[i] << endl;
  return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
 
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

int main(){

ios::sync_with_stdio(false);
cin.tie(0);
long long int n,k;
cin>>n>>k;

long long int pre1=0;
long long int pre2=0;
long long int pre3=0;

long long int count=0;

long long int mini=n;

if(n>k){
n=n%k;
}


while(true){
count++;
if(count==1){pre1=n;}
else if(count==2){pre2=pre1;pre1=n;}
else if(count>=3){pre3=pre2;pre2=pre1;pre1=n;}


n=abs(k-n);
mini=min(n,mini);
if(count>=4){

if(pre3==pre1 && pre2==n)
break;
}

}


cout<<mini<<endl;


}


Measured memory_bytes: 256
#include <stdio.h>
typedef long long int64;
int main(int argc, const char *argv[])
{
  int64 n;
  int64 a[5];
  scanf("%lld", &n);
  for (int i = 0; i < 5; i++)
    scanf("%lld", &a[i]);
  int64 min = 1000000000000001;
  for (int i = 0; i < 5; i++) {
    if (a[i] < min) {
      min = a[i];
    }
  }
  int64 v;
  if ( min < n ) {
    // 切り上げ割り算
    v = (n + ( min - 1)) / min;
    printf("%lld\n", v + 4);
  } else {
    printf("5\n");
  }

  return 0;
}

Measured memory_bytes: 128
while 1:
    H, W = map(int, raw_input().split())
    
    if H == 0 and W == 0:
        break
    else:
        print "#" * W
        for i in xrange(H - 2):
            print "#" + "." * (W - 2) + "#"
        print "#" * W
        print ""

Measured memory_bytes: 6364
import java.util.Scanner;

public class Main {

  public static void main(String[] args)  {

    //Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner (System.in);

    int a = cin.nextInt();
    int b = cin.nextInt();

    if (a*b%2==0) System.out.println("No");
    else System.out.println("Yes");


  }

}

Measured memory_bytes: 22612
import sys
input = sys.stdin.readline
#bfsするからdequeじゃないとだめ
from collections import deque
n,m=map(int,input().split())
infi=10**10
#topological sort
#通常のグラフ構成のグラフ
graph1=[[]for _ in range(n+1)]
#入ってくる辺の数を記録するグラフ
graph2=[ 0 for _ in range(n+1)]
for _ in range(m):
    x,y=map(int,input().split())
    graph1[x].append(y)
    graph2[y]+=1
#start地点になるのは入ってくる辺の数が0の点
start=deque([])
for i in range(1,n+1):
    if graph2[i]==0:
        start.append(i)
#start地点から
#①topoリストに加える
#②隣接点の入ってくる辺の数を減らす
#③入ってくる辺の数が0になったらstartに加える
#を繰り返す
#※今回はtopoに加えるのは本質ではない。
#topoに加えていく順序で見ていきながら距離を入れていく。
# topo=[]
dist=[infi]*(n+1)
for i in start:
    dist[i]=0
while start:
    a=start.popleft()
    kyori=dist[a]
#     topo.append(a)
    for b in graph1[a]:
        graph2[b]-=1
        if graph2[b]==0:
            start.append(b)
            dist[b]=min(dist[b],dist[a]+1)
print(max(dist[1:]))

Measured memory_bytes: 23832
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>

int main(){
    std::vector<int> s(3);
    std::cin >> s[0] >> s[1] >> s[2];
    std::sort(s.begin(), s.end());
    printf("%d %d %d\n", s[0], s[1], s[2]);
    // for(int x : s){
    //     printf("%d ", x);
    // }
}


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

using namespace std;

int main() {
    int n, k;
    long long a[10005], sum = 0;

    cin >> n >> k;
    for (int i=0; i<n; ++i) {
        cin >> a[i];
    }
    sort(a, a + n);
    for (int i=0; i<k; ++i) {
        sum += a[i];
    }

    cout << sum << "\n";
}


Measured memory_bytes: 3480
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	int k, s;
	cin >> k >> s;
	int cnt = 0;
	for(int i=0;i<=k;++i) {
		for(int j=0;j<=k;++j){
			int z = s - (i + j);
			if (0<=z&&z<=k) cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 256
import numpy as np

x, y = input().split()
wk = {"A":10, "B":11, "C":12, "D":13, "E":14, "F":15}
if wk[x]<wk[y]:
    print("<")
elif wk[x]>wk[y]:
    print(">")
else:
    print("=")

Measured memory_bytes: 12484
#include<bits/stdc++.h>
#define ll long long
#define maxn 100005
using namespace std;
const ll inf=1e9+7;
ll a[maxn],b[maxn],c[maxn];
vector<ll> v;
int main()
{
    //freopen("input.txt","r",stdin);
    int X,Y,A,B,C;cin>>X>>Y>>A>>B>>C;
    for(int i=0;i<A;i++) cin>>a[i];
    for(int i=0;i<B;i++) cin>>b[i];
    for(int i=0;i<C;i++) cin>>c[i];
    sort(a,a+A);
    sort(b,b+B);
    sort(c,c+C);
    ll sum=0;
    for(int i=0;i<X;i++)
        v.push_back(a[A-1-i]);
    for(int i=0;i<Y;i++)
        v.push_back(b[B-1-i]);
    for(int i=0;i<C;i++)
        v.push_back(c[i]);
    sort(v.begin(),v.end());
    int len=v.size();
    for(int i=0;i<X+Y;i++)
        sum+=v[len-i-1];
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 8432
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>

int lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}
ll INF = 10010001010;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    int N;
    cin >> N;
    int K;
    cin >> K;
    vector<ll> H(N);
    for (int i = 0; i < N;i++)
    {
        cin >> H[i];
    }
    ll ans = INF;
    sort(H.begin(), H.end());
    for (int i = 0; i < N - K+1;i++)
    {
        ans = min(ans, H[i + K - 1] - H[i]);
    }
    cout << ans << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);

	int n, k;
	cin >> n >> k;

	if (n < 2*k-1) {
		cout << "-1\n";
		return 0;
	}

	if (n % 2 == 1) {
		for (int i=0; i<n/2; i++) {
			cout << k+i << ' ' << k+2*n-n/2+i << ' ' << k+2*n+2*i+1 << '\n';
		}
		for (int i=n/2; i<n; i++) {
			cout << k+i << ' ' << k+n-n/2+i << ' ' << k+n+2*i+1 << '\n';
		}
	} else {
		for (int i=0; i<n/2; i++) {
			cout << k+i << ' ' << k+2*n-n/2+i << ' ' << k+2*n+2*i << '\n';
		}
		for (int i=n/2; i<n; i++) {
			cout << k+i << ' ' << k+n-n/2+i << ' ' << k+n+2*i+1 << '\n';
		}
	}
}

Measured memory_bytes: 2304
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>
#include <bitset>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int rev_mod(long long int num){
	long long int pow_num = MOD - 2;
	long long int mod_num = MOD;
	long long int pow_cur = num;
	long long int ret = 1;
	while(pow_num > 0){
		if(pow_num % 2 == 1){
			ret *= pow_cur;
			ret %= mod_num;
		}
		pow_cur *= pow_cur;
		pow_cur %= mod_num;
		pow_num /= 2;
	}
	return ret;
}

vector<int> E[210000];
map<int, int> sz[210000];
long long int p2[210000], p2m[210000];
int memo[210000];

int func(int pos, int pre){
	if(memo[pos] != 0){
		return memo[pos] - sz[pos][pre];
	}
	int ret = 1;
	bool flag = true;
	for(int i = 0; i < E[pos].size(); i++){
		int to = E[pos][i];
		if(to == pre){
			continue;
		}
		if(sz[pos].find(to) != sz[pos].end()){
			ret += sz[pos][to];
		}else{
			sz[pos][to] = func(to, pos);
			ret += sz[pos][to];
			flag = false;
		}
	}
	if(flag && E[pos].size() != 1){
		memo[pos] = 1;
		for(P p : sz[pos]){
			memo[pos] += p.second;
		}
	}
	return ret;
}

int main(){
	p2[0] = p2m[0] = 1;
	for(int i = 1; i < 210000; i++){
		p2[i] = p2[i - 1] * 2 % MOD;
		p2m[i] = p2m[i - 1] * rev_mod(2) % MOD;
	}
	long long int N;
	cin >> N;
	for(int i = 0; i < N - 1; i++){
		int A, B;
		cin >> A >> B;
		E[A].push_back(B);
		E[B].push_back(A);
	}
	long long int ans = 0;
	for(int i = 1; i <= N; i++){
		func(i, -1);
		long long int S = p2[N - 1] + (MOD - 1);
		S %= MOD;
		for(P p : sz[i]){
			S += MOD - (p2[p.second] - 1);
			S %= MOD;
			//cout << p.first << " " << p.second << endl;
		}
		ans += S;
		ans %= MOD;
	}
	ans *= p2m[N];
	ans %= MOD;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 62336
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a =  readLine()!!.split(" ").map(String::toInt)

    op142c(a)
}

fun op142c(a: List<Int>) {
    val map = mutableMapOf<Int,Int>()
    IntRange(1,a.size).forEach { map[it] = a[it-1] }
    val orderedMap = map.toList().sortedBy { it.second }.toMap()
    orderedMap.forEach{
        print(it.key)
        print(" ")
    }
}


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

int main(){
    int W;
    int H;
    int x;
    int y;
    int r;
    cin >> W >> H >> x >> y >> r;
    if(x-r >= 0 && y-r >= 0 && x+r <= W && y+r <= H){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
N,S = map(int,input().split())
A = list(map(int,input().split()))
dp = [[0]*(S+2) for i in range(N+1)]
dp[0][0] = 1
mod = 998244353
for i,a in enumerate(A):
    for j in range(S+1):
        if j-a >= 0:
            dp[i+1][j] = (dp[i][j]*2+dp[i][j-a])%mod
        else:
            dp[i+1][j] = dp[i][j]*2%mod
print(dp[N][S])


Measured memory_bytes: 132284
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        long ans = (long)Math.ceil(Math.sqrt(x)) *3;
        while(true){
            long tmp = ans;
            tmp--;
            if(tmp * (tmp + 1) / 2 < x) break;
            ans = tmp;
        }

        System.out.println(ans);
        sc.close();
    }

}


Measured memory_bytes: 23124