akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;

int main() 
{

 fast();
  

  ll n,w;
  cin>>n>>w;
  ll dp[n+1][w+1];
  ll val[n+1],wt[n+1];
  memset(dp,0,sizeof(dp));
  memset(val,0,sizeof(val));
  memset(wt,0,sizeof(wt));
  f(i,1,n+1)
  {
    cin>>wt[i]>>val[i];
  }

  f(i,1,n+1)
  {
        f(j,1,w+1)
        {
            dp[i][j]=max(dp[i-1][j],dp[i][j]);
            if(wt[i]<=j)
            {
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-wt[i]]+val[i]);
            }
        }
  }
  cout<<dp[n][w];

 
  cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
  
  return 0;
}
 

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N);
  VEC(int, p, N);
  vi a(N);
  rep(i, 0, N) a[i] = i + 1;
  int ans = 0;
  rep(i, 0, N - 1) {
    if (a[i] == p[i]) {
      swap(a[i], a[i + 1]);
      ans++;
    }
  }
  if (a[N - 1] == p[N - 1]) ans++;
  print(ans);
}


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

int main() {
  int w, h, x, y;
  cin >> w >> h >> x >> y;
  double ans = (double)w*h/2;
  int num = (w==x*2 && h==y*2) ? 1 : 0;
  printf("%.10f %d\n", ans, num);
  return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
 
main :: IO ()
main = do
    [n, d] <- getIntList
    xl <- getIntNList n
    putStrLn . show $ length [x | x <- map (\a -> snd . properFraction . distance (a !! 0) $ (a !! 1)) (combination 2 xl), x == 0.0]
 
 
distance :: (Integral a, Show a) => [a] -> [a] -> Float
distance i j = sqrt (fromIntegral(sum (zipWith (\x y -> (x-y) * (x-y)) i j)))
 
combination :: Int -> [a] -> [[a]]
combination 0 _ = [[]]
combination _ [] = []
combination n (x:xs) = (zipWith (:) (repeat x) (combination (n - 1) xs)) ++ (combination n xs)
 
readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine

Measured memory_bytes: 636
#ここまでテンプレ
from sys import stdin
from sys import setrecursionlimit


setrecursionlimit(10 ** 7)

n,k = map(int,stdin.readline().rstrip().split())

li = [i for i in range(n+1)]

point = 0

mod = 10**9+7

for i in range(k,n+2):
    mi = ((li[0]+li[i-1])//2)*i%mod
    ma = ((li[n-i+1]+li[-1])//2)*i%mod
    point += (ma-mi+1)%mod
    point %= mod

print(point)

Measured memory_bytes: 16956
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
#define PI  acos(-1)
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  string S;cin>>S;
  int N=S.size();
  stack<char> stk;
  REP(i,0,N){
    if(S.at(i)=='S')stk.push('S');
    else {
      if(stk.size()==0||stk.top()=='T')stk.push('T');
      else stk.pop();
    }
  }
  print(stk.size());



}


Measured memory_bytes: 720
#include <iostream>
#define Nmax 100005
#define ll long long
using namespace std;

int main()
{
    ll n, dp[Nmax] = {0}, h[Nmax];

    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> h[i];
    }

    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);
    for (int i = 3; i <= n; ++i) {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[n];
    return 0;
}


Measured memory_bytes: 1792
import datetime as dt
S_T='2019/04/30'
S_T=dt.datetime.strptime(S_T,'%Y/%m/%d')

S=input()
S=dt.datetime.strptime(S,'%Y/%m/%d')

t_delta=S-S_T
if t_delta.days <= 0:
    print('Heisei')
else:
    print('TBD')

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



int main(){
  int N,K;
  cin >> N >> K;
  
  vector<int> all;
  
  for(int i =0; i < N ; i++){
    int x;
    cin >> x; 
    all.push_back(x);
  }
  
  sort(all.begin(),all.end(),greater<int>());
  int ans = 0;
  for(int i = 0; i < K; i++){
   ans += all.at(i);
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
//=============================================================
// Name        : c
// Date        : Wed Jul  3 22:45:26 CST 2019
// Accepted    : Wed Jul  3 22:48:09 CST 2019
// Author      : landcold7
// Description : Actions speak louder more than words
//=============================================================
#include <bits/stdc++.h>
using namespace std;

#define x first
#define y second
#define sz(x) ((int)(x).size())
#ifndef _has_trace
#define trace(...)
#endif
typedef long long ll;

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int hi = a[n / 2];
  int lo = a[n / 2 - 1];
  int ans = hi - lo;
  cout << ans << "\n";
}

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


Measured memory_bytes: 640
N, W = map(int, input().split())

dp = [[0 for i in range(W+1)] for j in range(N+1)]
for i in range(1, N+1):
    w, v = map(int, input().split())
    for j in range(0, W+1):
        if j >= w:
            dp[i][j] = max(dp[i][j], dp[i-1][j-w] + v)
        dp[i][j] = max(dp[i][j], dp[i-1][j])

print(dp[N][W])

Measured memory_bytes: 171528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  string s[N];
  rep(i,N) cin >> s[i];
  rep(i,N){
    if(s[i][0]=='Y'){
      cout << "Four" <<endl;
      return 0;
    }
  }
  cout << "Three" <<endl;
  return 0;
    

}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=4999999996000000001;
ll frac[200100];

ll modpow(ll a, ll n, ll mod){
    ll ret=1;
    while(n>0){
        if(n&1) ret=ret*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ret;
}

ll comb(ll n, ll r){
    ll res=1;
    res*=frac[n];
    res*=modpow(frac[r],MOD-2,MOD);
    res%=MOD;
    res*=modpow(frac[n-r],MOD-2,MOD);
    res%=MOD;
    return res;
}

int main(){
    int n;
    cin>>n;
    vector<ll> a(n),b(n);
    for(int i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
        a[i]=x-y;
        b[i]=x+y;
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    ll ans=a[n-1]-a[0];
    ans=max(ans,b[n-1]-b[0]);
    cout<<ans<<endl;
}

Measured memory_bytes: 5988
import sys
import collections

N = int(input())
A = list(map(int, sys.stdin.readline().split()))
Q = int(input())
BC = [list(map(int, sys.stdin.readline().split())) for _ in range(Q)]

A_dic = collections.Counter(A) 
S = sum(A)
for i in range(Q):
    num = A_dic[BC[i][0]]
    A_dic[BC[i][0]] = 0
    A_dic[BC[i][1]] += num
    S += (BC[i][1] - BC[i][0]) * num
    print(S)
    

Measured memory_bytes: 40324
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const long long INF = 1e15;
int main(){
  int N, M;
  cin >> N >> M;
  vector<long long int> X(N), Y(N), Z(N);
  for(int i = 0; i < N; ++i){
    cin >> X[i] >> Y[i] >> Z[i];
  }
  long long int ans = -INF;
  for(long long i = -1; i < 2; i += 2){
    for(long long j = -1; j < 2; j += 2){
      for(long long k = -1; k < 2; k += 2){
        vector<long long int> V(N);
        for(int l = 0; l < N; ++l){
          V[l] = X[l]*i + Y[l]*j + Z[l]*k;
        }
        sort(V.begin(), V.end(), greater<long long>());
        long long int t = 0;
        for(int l = 0; l < M; ++l) t += V[l];
        ans = max(t, ans);
      }
    }
  }
  
  cout << ans << endl;
  return 0;
}


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

int main(){

  char str[1002],ho[]="Hoshino";
  int n,i;
  char *a;

  scanf("%d\n",&n);
  for(i=0;i<n;i++)
    {
      fgets(str,sizeof(str),stdin);
      while((a=strstr(str,ho)) != NULL)
	{
	  a[6] = 'a';
	}
      printf("%s",str);
    }
  return 0;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
#define Size(n) (n).size()

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}
//long long int ruizyo(long long int aa, long long int bb){
  //  if(aa==0){
    //    return 1;
    //}
    //else if(aa%2==0){
      //  long long int tt=ruizyo(aa/2,bb);
        //return (tt*tt)%MOD;
    //}
    //else{
      //  return (ruizyo(aa-1,bb)*bb)%MOD;
    //}
//}フェルマ－のア


//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

//visited=vector<vector<bool>>(10,vector<bool>(10,false));アを全部falseに


long long int n,cnt=0,ans=0,a,b,c,cmp=0,cmpp=0,m,h,W,k,x,y,sum=0,pos,len=0,le=0,ww,dp[4][101];
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;

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

    
       cin>>n>>W;
       vector<ll> w[4];
       rep(i,n){
           cin>>a>>b;
           if(i==0){
                ww=a;
               w[0].pb(b);
           }
           else if(a==ww){
               w[0].pb(b);
           }
           else if(a==ww+1){
               w[1].pb(b);
           }
           else if(a==ww+2){
               w[2].pb(b);
           }
           else{
               w[3].pb(b);
           }
           
       }
       rep(i,4){
           sort(w[i].rbegin(),w[i].rend());
       }
       rep(i,4){
           rep(j,Size(w[i])){
               dp[i][j+1]=dp[i][j]+w[i][j];
           }
       }
       rep(i,Size(w[0])+1){
           rep(j,Size(w[1])+1){
               rep(k,Size(w[2])+1){
                   rep(l,Size(w[3])+1){
                      cmp=ww*i+(ww+1)*j+(ww+2)*k+(ww+3)*l;
                      cmpp=dp[0][i]+dp[1][j]+dp[2][k]+dp[3][l];
                      if(W>=cmp){
                          ans=max(ans,cmpp);
                      }
                   }
               }
           }
       }
       
       Cout(ans);
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    string S;
    cin >> S;
    int n = S.size();
    REP(i, n){
        cout << "x";
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int S[100005];
int n;
int binarySearch(int key){
  int left = 0;
  int right = n - 1;
  int mid;
  while(left <= right){
    mid = (left + right) / 2;
    if(S[mid] == key){
      return 1;
    }
    else if(S[mid] < key)
      left = mid + 1;
    else
      right = mid - 1;

  }
  return 0;
}
int main(){
  int q;
  scanf("%d", &n);
  for(int i = 0; i < n; ++i){
    scanf("%d", &S[i]);
  }
  scanf("%d", &q);
  int count = 0;
  int key;
  for(int i = 0; i < q; ++i){
    scanf("%d", &key);
    count += binarySearch(key);
  }

  printf("%d\n", count);
  return 0;
}



Measured memory_bytes: 2116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod=1000000007;
const double PI = 3.14159265359;
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define INF 1000000000000
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define FOR(i,n) for(int i=0;i<(n);i++)
#define FORA(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define count_1(n)  __builtin_popcountll(n)
#define parity(n)   __builtin_parityll(n)   //Even parity 0 as output
void show    (int a[], int arraysize) { for (int i = 0; i < arraysize; ++i)  {cout << a[i] << " ";}	cout<<endl;}
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);}
void sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}
int main()
{FAST
int c=0;
ll n,d,x,y;
cin>>n>>d;
FOR(i,n)
{    
	cin>>x>>y;
if(x*x+y*y<=d*d)
{
	c++;
}

}
cout<<c<<endl;
return  0;
}






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

using namespace std;

typedef long long ll;

ll g(ll x)
{
    return x * (x + 1) / 2;
}

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

    int n;
    cin >> n;
    cout << g(n) - 3 * g(n / 3) - 5 * g(n / 5) + 15 * g(n / 15) << "\n";
}


Measured memory_bytes: 3600
import java.io.BufferedReader;
import java.io.InputStreamReader;
/*
 * 提出用Mainクラス
 */
public class Main {
    public static void main(String args[] ) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N;
        int result;
        String readLine = br.readLine();
        N = Integer.parseInt(readLine);
        result = N * N * N;
        System.out.println(result);
    }
}

Measured memory_bytes: 23900
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

int N,M,start,goal;

struct Info{
	Info(){
		town = pre_town = 0;
		speed = time = 0.0;
	}

	Info(int arg_town,int arg_speed,double arg_time,int arg_pre_town){
		town = arg_town;
		speed = arg_speed;
		time = arg_time;
		pre_town = arg_pre_town;
	}
	bool operator<(const struct Info &arg) const{
			return time > arg.time;
	};
	int town,speed,pre_town;
	double time;
};

struct Road{
	Road(int arg_to,double arg_dist,int arg_speed_limit){
		to = arg_to;
		dist = arg_dist;
		speed_limit = arg_speed_limit;
	}
	int to,speed_limit;
	double dist;
};

void func(){

	double min_Time[N+1][N+1][31];

	for(int i = 1; i <= N; i++){
		for(int k = 1; k <= N; k++){
			for(int p = 1; p <= 30; p++)min_Time[i][k][p] = DBL_MAX;
		}
	}

	scanf("%d %d",&start,&goal);

	vector<Road> V[N+1];

	int from,to,limit;
	double dist;
	for(int i = 0; i < M; i++){
		scanf("%d %d %lf %d",&from,&to,&dist,&limit);
		V[from].push_back(Road(to,dist,limit));
		V[to].push_back(Road(from,dist,limit));
	}

	Info first;
	first.speed = 0;
	first.time = 0.0;
	first.town = start;
	first.pre_town = -1;

	priority_queue<Info> Q;
	Q.push(first);

	int next_town,next_speed;
	double distance;

	while(!Q.empty()){

		if(Q.top().town == goal && Q.top().speed == 1){
			Q.pop();
		}else if(Q.top().time > min_Time[Q.top().town][Q.top().pre_town][Q.top().speed]){
			Q.pop();
		}else{

			for(int i = 0; i < V[Q.top().town].size();i++){
				next_town = V[Q.top().town][i].to;
				if(next_town == Q.top().pre_town)continue;

				limit = V[Q.top().town][i].speed_limit;
				distance = V[Q.top().town][i].dist;

				for(int k = -1;k <= 1; k++){
					next_speed = Q.top().speed + k;
					if(next_speed <= 0 || next_speed > limit)continue;

					if(min_Time[next_town][Q.top().town][next_speed] > Q.top().time + distance/(double)next_speed){
						min_Time[next_town][Q.top().town][next_speed] = Q.top().time + distance/(double)next_speed;
						Q.push(Info(next_town,next_speed,Q.top().time+distance/(double)next_speed,Q.top().town));
					}
				}
			}

			Q.pop();
		}
	}

	double minimum = DBL_MAX;
	for(int i = 1; i <= N; i++){
		minimum = min(minimum,min_Time[goal][i][1]);
	}
	if(minimum == DBL_MAX){
		printf("unreachable\n");
	}else{
		printf("%.6lf\n",minimum);
	}
}

int main(){

	while(true){
		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 3208
n,m = map(int,input().split())

kaidan = [-1] * (n+1)

for i in range(m):
  a = int(input())
  kaidan[a] = 0
  
kaidan[0] = 1
if kaidan[1] == -1:
  kaidan[1] = kaidan[0]
  
for i in range(2,len(kaidan)):
  if kaidan[i] == -1:
    kaidan[i] = (kaidan[i-2] + kaidan[i-1]) % 1000000007

print(kaidan[-1])

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

#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  ll a;
  cin >> a;
  cout << 3 * a * a << '\n';
  return (0);
}


Measured memory_bytes: 256
from collections import Counter

N = int(input())
counter = Counter()
for i in range(0, N):
    counter[str(input())] += 1
A = max(counter.values())
S = []
for a, b in counter.items():
    if A == b:
        S.append(a)
S.sort()
for s in S:
    print(s)


Measured memory_bytes: 32444
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

int c[3][3];

int main()
{
    rep(i, 3) {
        rep(j, 3) cin >> c[i][j];
    } 
    vector<int> x(3);
    rep(i, 3) x[i] = c[i][1] - c[i][0]; 
    vector<int> y(3);
    rep(i, 3) y[i] = c[i][2] - c[i][1]; 
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    if(x[0] == x[2] && y[0] == y[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;
int main(){
  ll A,B;char op;cin>>A>>op>>B;
  if(op=='+')cout<<A+B<<endl;
  else cout<<A-B<<endl;
}




Measured memory_bytes: 256
#include<stdio.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
int main(void)
{
  int N,x,A[200001]={0};
  x=scanf("%d",&N);
  rep(i,N-1)while(scanf("%d",&x)>0)A[x-1]++;
  rep(i,N)printf("%d\n",A[i]);
}

Measured memory_bytes: 2488
#include<iostream>
#include<cstdlib>
#include<cstdio>
using namespace std;
int t[100010],x[100010],y[100010];
#define gabs(a) ((a)>0?(a):-(a))
int main()
{
	int n,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d%d%d",&t[i],&x[i],&y[i]);
		if((t[i]-t[i-1]&1)==(gabs(x[i]-x[i-1])+gabs(y[i]-y[i-1])&1)&&t[i]-t[i-1]>=gabs(x[i]-x[i-1])+gabs(y[i]-y[i-1]));
		else
		{
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 1408
while True:
  h, w = map(int, raw_input().split())
  if (h == 0 and w == 0):
    break
  for i in range(0,h):
    if i == 0 or i == h-1:
      print ('#' * w)
    else: 
      print ('#' + '.' * (w - 2) + '#' )
  print

  

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

int main(){
  int N,M;
  cin >> N >> M;
  int n=0,m=0;
  vector<int> v(N);
  rep(i,N){
    cin >> v.at(i);
    n += v.at(i);
  }
  rep(i,N){
    if (v.at(i)*M*4>=n){
      m++;
    }
  }
  if (m>=M){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll maxn=3001;
ll n,a[maxn],memo[maxn][maxn][2];

ll go(ll i,ll j,ll par){
    if(i>j){
        return 0;
    }
    ll ans=0;
    if(memo[i][j][par]!=-1) return memo[i][j][par];
    if(par==0){
        ans+=max(a[i]+go(i+1,j,!par),a[j]+go(i,j-1,!par));
    }
    else{
        ans+=min(go(i+1,j,!par)-a[i],go(i,j-1,!par)-a[j]);
    }
    return memo[i][j][par]=ans;
}


int main(){
    cin>>n;
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    memset(memo,-1,sizeof(memo));
    cout<<go(0,n-1,0);
}

Measured memory_bytes: 141184
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		for(int i = 1; i < N; i++) {
			A[i] = sc.nextInt() - 1;
		}
		int ans[] = new int[N];
		for(int i = N - 1; i > 0; i--) {
			ans[A[i]]++;
		}
		for(int i = 0; i < N; i++) {
			System.out.println(ans[i]);
		}
	}
}


Measured memory_bytes: 61388
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
using P = pair<ll, int>;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k, idx = 1;
    cin >> n >> k;
    vector<P> ts;
    map<int, int> mp;
    rep(i, 0, n) {
        int t;
        ll d;
        cin >> t >> d;
        if (mp[t] == 0) {
            mp[t] = idx;
            idx++;
        }
        ts.push_back(make_pair(-d, mp[t]));
    }
    sort(ts.begin(), ts.end());
    rep(i, 0, n) ts[i].first *= -1;

    set<int> used;
    priority_queue<ll, vector<ll>, greater<ll>> pq;
    priority_queue<ll> pqb;
    ll ans = 0;
    ll sum = 0;

    rep(i, 0, k) {
        if (used.find(ts[i].second) != used.end())
            pq.push(ts[i].first);
        sum += ts[i].first;
        used.insert(ts[i].second);
    }
    ll sz = used.size();

    rep(i, k, n) {
        if (used.find(ts[i].second) == used.end())
            pqb.push(ts[i].first);
        used.insert(ts[i].second);
    }

    ans = sum + sz * sz;
    while ((!pqb.empty()) && (!pq.empty())) {
        sz++;
        sum += pqb.top() - pq.top();

        pqb.pop();
        pq.pop();
        ans = max(ans, sum + sz * sz);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11632
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
        int n = sc.nextInt();
        int a = 1,b = n - 1;
        int check1 = 0, check2 = 0;
        int ans = 9999999;
        for(int i = 0; i < n;i++){
			check1 = a / 100000 + (a / 10000) % 10 + (a / 1000) % 10 
              + (a / 100) % 10 + (a / 10) % 10 + a % 10;
            check2 = b / 100000 + (b / 10000) % 10 + (b / 1000) % 10 
              + (b / 100) % 10 + (b / 10) % 10 + b % 10;
          if(check1 + check2 < ans && check1 * check2 != 0){
            ans = check1 + check2;
          }
          a++;
          b--;
        }
      
        
      	System.out.println(ans);
 
    }
}

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

int main() {
    long long K, A, B;
    cin >> K >> A >> B;

    if (A > B || (B - A) < 2) {
        cout << 1 + K << endl;
        return 0;
    }

    long long countHandle = A - 1;
    if (countHandle >= K) {
        cout << 1 + K << endl;
        return 0;
    }
    long long countBis = A;
    long long tmp = K - countHandle;
    long long tmp2 = tmp / 2;
    countBis = countBis + ((B - A) * tmp2);
    if (tmp % 2 == 1) {
        countBis += 1;
    }
    cout << countBis << endl;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    int a, b;
    cin >> a >> b;

    bool ok = true;
    if((a > 8) || (b > 8)) ok = false;

    if(ok) cout << "Yay!" << endl;
    else cout << ":(" << endl;
     
    return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

int n;

bool check(int x, bool print=false) {
  int cur = 0;
  for (int i = x; i >= 0 && cur < n; --i) {
    if (cur+i <= n) {
      if (print) printf("%d\n", i);
      cur += i;
    }
  }
  return cur == n;
}

void solve() {
  scanf("%d", &n);
  int lo = 0, hi = n+1;
  while (lo+1 < hi) {
    int mid = (lo+hi)/2;
    if (check(mid)) hi = mid;
    else lo = mid;
  }
  check(hi, true);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3784
import java.lang.Math.*

fun main(args: Array<String>){
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val outEdge = Array(n + 1){ mutableListOf<Int>() }
    val inEdge = Array(n + 1){ mutableListOf<Int>() }
    repeat(m){
        readLine()!!.split(" ").map { it.toInt() }.let {
            outEdge[it[0]].add(it[1])
            inEdge[it[1]].add(it[0])
        }
    }

    val visited = BooleanArray(n + 1){false}
    val order = mutableListOf<Int>()
    for (i in 1..n){
        if (!visited[i]) dfs(i, outEdge, visited, order)
    }
    order.reverse()

    val dp = IntArray(n + 1)
    for (i in order){
        var max = 0
        for (v in inEdge[i]){
            max = max(max, dp[v] + 1)
        }
        dp[i] = max
    }
    println(dp.max())
}

fun dfs(v: Int, outEdge: Array<MutableList<Int>>, visited: BooleanArray, order: MutableList<Int>){
    visited[v] = true
    for (e in outEdge[v]){
        if(!visited[e]) dfs(e, outEdge, visited, order)
    }
    order.add(v)
}

Measured memory_bytes: 87516
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n,a,b = LI()
    print(min(a*n,b))
    return

#B
def B():
    n = I()

    return

#C
def C():
    n = I()

    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return


#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 39152
N = int(input())
s = [input() for i in range(N)]
l1 = [s[i].count('AB') for i in range(N)]
l2 = [1 if s[i][0] == 'B' else 0 for i in range(N)]
l3 = [1 if s[i][-1] == 'A' else 0 for i in range(N)]
l4 = [l2[i]*l3[i] for i in range(N)]
if max(sum(l2),sum(l3)) == sum(l4):
    a = max(min(sum(l2),sum(l3))-1,0)
else:
    a = min(sum(l2),sum(l3))
print(sum(l1) + a)

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

/*
int ds[100];

int frep(int x)
{
	if (ds[x] == x) return x;
	return ds[x] = frep(ds[x]);
}

void join(int a, int b)
{
	a = frep(a); b = frep(b);
	ds[b] = a;
}

void brute()
{
	int n;
	cin >> n;

	pair<int,int> edges[100];
	for (int i = 0; i < n-1; ++i)
	{
		cin >> edges[i].first >> edges[i].second;
		if (edges[i].first > edges[i].second)
			swap(edges[i].first, edges[i].second);
	}

	int res = 0;
	for (int i = 1; i <= n; ++i)
	{
		for (int j = i; j <= n;  ++j)
		{
			for (int k = i; k <= j; ++k)
				ds[k] = k;

			for (int k = 0; k < n-1; ++k)
				if (i <= edges[k].first && edges[k].second <= j)
					join(edges[k].first, edges[k].second);

			set<int> st;
			for (int k = i; k <= j; ++k)
				st.insert(frep(k));

			res += st.size();
		}
	}
	cout << res << '\n';
}
*/

typedef long long ll;

int const N = 2e5 + 7;
ll ar[N] = {};
int main()
{
	//brute();

	int n;
	cin >> n;

	ll u, v;
	for (int i = 1; i < n; ++i)
	{
		cin >> u >> v;
		ar[max(u, v)] += min(u, v);
	}

	ll res = 0;
	ll ctr = 0;

	for (int i = 1; i <= n; ++i)
	{
		ctr += i - ar[i];
		res += ctr;
	}
	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 5196
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        HashSet<Integer> s = new HashSet<>();
        for (int i = 0; i < N; i++) {
            int d = scan.nextInt();
            s.add(d);
        }
        System.out.println(s.size());
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

const int dx[] = { -1, 0, 0, 1 }, dy[] = { 0, -1, 1, 0 };
//[const int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 }, dy[] = { 0, -1, 1, -1, 1, 0, -1, 1 };
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
int place(int x, int y, int w) { return w*x + y; }


int n, h, w;

int main()
{
	cin >> n;
	vector<pii> v;
	REP(i, n)
	{
		int a, b; cin >> a >> b;
		v.emplace_back(a, b);
	}
	int fld[4][4];
	REP(i, 4)REP(j, 4)
	{
		char c; cin >> c;
		if (c == 'R') fld[i][j] = 0;
		else if (c == 'G') fld[i][j] = 1;
		else fld[i][j] = 2;
	}
	vi d(1 << 16, INF);
	d[0] = 0;
	queue<int> que;
	que.push(0);
	while (!que.empty())
	{
		int t = que.front(); que.pop();
		if (t == (1 << 16) - 1)
		{
			cout << d[t] << endl;
			break;
		}
		REP(i, n)REP(j, 3)
		{
			int h = v[i].first, w = v[i].second;
			FOR(u, 1 - h, 4)FOR(l, 1 - w, 4)
			{
				int tmp = t;
				FOR(x, max(0, u), min(4, u + h))FOR(y, max(0, l), min(4, l + w ))
				{
					if (fld[x][y] == j)
					{
						tmp |= (1 << (x * 4 + y));
					}
					else
					{
						if ((tmp >> (x * 4 + y)) & 1) tmp ^= (1 << (x * 4 + y));
					}
				}
				if (d[tmp] == INF)
				{
					d[tmp] = d[t] + 1;
					que.push(tmp);
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3376
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n= scan.nextInt();
		int k= scan.nextInt();
		int r= scan.nextInt();
		int s= scan.nextInt();
		int p= scan.nextInt();
		String t =scan.next();
		scan.close();
		char arr[]=new char[n];
		int score=0;
		for(int i=0;i<n;i++) {
			if(i<k) {
				if(t.charAt(i)=='r') {
					score+=p;
					arr[i]='p';
				}else if(t.charAt(i)=='s') {
					score+=r;
					arr[i]='r';
				}else {
					score+=s;
					arr[i]='s';
				}
			} else {
				if(arr[i-k]=='p') {
					if(t.charAt(i)=='s') {
						score+=r;
						arr[i]='r';
					}
					else if(t.charAt(i)=='p') {
						score+=s;
						arr[i]='s';
					}else {
						if(i+k<n&&(t.charAt(i+k)=='p'||t.charAt(i+k)=='r'))arr[i]='r';
						else arr[i]='p';
					}
				}else if(arr[i-k]=='s') {
					if(t.charAt(i)=='s') {
						score+=r;
						arr[i]='r';
					}else if(t.charAt(i)=='r') {
						score+=p;
						arr[i]='p';
					}else {
						if(i+k<n&&(t.charAt(i+k)=='r'))arr[i]='r';
						else arr[i]='p';
					}
				}else if(arr[i-k]=='r') {
					if(t.charAt(i)=='p') {
						score+=s;
						arr[i]='s';
					}
					else if(t.charAt(i)=='r') {
						score+=p;
						arr[i]='p';
					}else {
						if(i+k<n&&(t.charAt(i+k)=='p'))arr[i]='p';
						else arr[i]='s';
					}
				}
			}
		}
		System.out.println(score);
	}

}


Measured memory_bytes: 27752
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+100;
int dp[MAXN];
vector<int>E[MAXN];
int dfs(int t)
{
	if(dp[t]!=-1) return dp[t];
	if(E[t].empty()) return dp[t]=0;
	for(int i=0;i<E[t].size();i++)
		dp[t]=max(dp[t],dfs(E[t][i])+1);
	return dp[t];
}
int main()
{
	int n,m; 
	scanf("%d%d",&n,&m);
	memset(dp,-1,sizeof(dp));
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		E[x].push_back(y);
	}
	for(int i=1;i<=n;i++)
		dfs(i);
	printf("%d\n",*max_element(dp+1,dp+n+1));
	return 0;
}
/*
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
queue<int>q;
vector<int>E[N];
int n,m,ans;
int dp[N],indegree[N];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) 
	{
		int x,y;
		scanf("%d%d",&x,&y);
		E[x].push_back(y); 
		indegree[y]++;
	}
    for(int i=1;i<=n;i++) 
		if(!indegree[i]) 
			q.push(i);
    while(!q.empty()) 
	{
    	int u=q.front(); 
		q.pop();
    	for(int i=0;i<E[u].size();i++) 
		{
			int uu=E[u][i];
			indegree[uu]--;
			if(!indegree[uu]) 
			{
				dp[uu]=dp[u]+1;
				q.push(uu);
			}
		}
	}
	int maxn=0;
	for(int i=1;i<=n;i++) 
		maxn=max(maxn,dp[i]);
	printf("%d\n", maxn);
	return 0;
}
*/

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int K,S;
    cin>>K>>S;
    //X,Yが決まれば自動的にZは決まるので、X,Yが何組あるかを数える
    //K>=S-X-Y>=0なるX,Yの組を数える
    long long ans=0;
    rep(i,S+1){
        rep(j,S+1){
            if(0<=S-i-j&&S-i-j<=K&&i<=K&&j<=K){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>
#include <queue>

void failed () {
	std::cout << -1 << '\n';
	exit(0);
}

int main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n), b(n);
	for (int &e : a) std::cin >> e;
	for (int &e : b) std::cin >> e;
	
	long long ans = 0;
	std::priority_queue<std::pair<int, int>> que;
	for (int i = 0; i < n; i++) {
		if (a[i] != b[i]) que.emplace(b[i], i);
		if (a[i] > b[i]) failed();
	}
	
	while (not que.empty()) {
		auto [value, i] = que.top(); que.pop();
		const int l = (i == n - 1 ? 0 : i + 1);
		const int r = (i == 0 ? n - 1 : i - 1);
		const int s = b[l] + b[r];
		if (b[i] < s) failed();
		
		const int count = (b[i] - std::max(s, a[i]) + s - 1) / s;
		if ((b[i] -= (count * s)) < a[i]) failed();
		if (b[i] != a[i]) que.emplace(b[i], i);
		ans += count;
	}
	
	std::cout << ans << '\n';
	
	return 0;
}

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i, s.size() - t.size() + 1){
    string sub = s.substr(i, t.size());
    int cnt = 0;
    rep(j,t.size()){
      if(sub[j] == t[j]) cnt++;
    }
    ans = max(ans, cnt);
  }
  ans = t.size() - ans;
  cout << ans << endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

//typedef tuple<int, int, int> T;
// get<K>(tuple型の変数)

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

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

    int a, b; cin >> a >> b;

    cout << max(0, a-2*b) << endl;
    

    return 0;
} 

Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] str){
	Scanner in= new Scanner(System.in);
	int s=in.nextInt(),m=s/60,h=m/60;
	s=s%60; m=m%60;
	System.out.printf("%d:%d:%d\n",h,m,s);
    }
}



Measured memory_bytes: 26092
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x, y;
	cin >> x >> y;
	vector<int> a = { 1,3,5,7,8,10,12 };
	vector<int> b = { 4,6,9,11 };
	int c = 2;
	for (int i = 0; i < a.size(); ++i) {
		if (x == a[i]) {
			rep(j, a.size()) {
				if (y == a[j]) {
					puts("Yes");
					return 0;
				}
			}
		}
	}
	rep(i, b.size()) {
		if (x == b[i]) {
			rep(j, b.size()) {
				if (y == b[j]) {
					puts("Yes");
					return 0;
				}
			}
		}
	}
	if (x == y) puts("Yes");
	else puts("No");
	return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

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

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

map<llong, int> prime_factorization(llong n) {
  map<llong, int> ret;
  while (n % 2 == 0) {
    ret[2]++;
    n /= 2;
  }
  for (llong i = 3; i*i <= n; i += 2) {
    while (n%i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n]++;

  return ret;
}

int main() {
  llong N;
  cin >> N;

  auto pf = prime_factorization(N);
  llong ans = 0;
  for (auto it: pf) {
    for (int i = 1; i <= it.second; ++i) {
      it.second -= i;
      ++ans;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3632
#include <iostream>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>

#include <map>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(NULL);

   map<llong, int> freq;

   int N;
   cin >> N;
   REP(i, N) {
      int a;
      cin >> a;
      ++freq[a];
   }

   llong res = 0;

   vector<llong> V;
   for (auto it : freq) {
      if (it.second >= 2)
         V.push_back(it.first);
      if (it.second >= 4)
         res = max(res, it.first * it.first);
   }

   sort(V.begin(), V.end(), greater<int>());
   if (SZ(V) >= 2)
      res = max(res, V[0] * V[1]);

   cout << res << endl;

   return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lint X;
    cin >> X;
    lint now = 100;
    int idx = 1;
    while(true) {
        now = now * 1.01;
        if(now>= X) {
            cout << idx << endl;
            return 0;
        }
        idx++;
    }
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<algorithm>
using namespace std;
char*p,s[1048576];
int main()
{
	int J,O,I,r,x=-1;
	J=O=I=r=0;
	for(scanf("%s",p=s);*p;++p)
	{
		if(*p=='J')
		{
			if(x)x=0,J=1;
			else ++J;
		}
		if(*p=='O')
		{
			if(x==1)++O;
			else if(!x)x=O=1;
			else x=-1,O=0;
		}
		if(*p=='I')
		{
			if(x==1)x=2,I=1;
			else if(x==2)++I;
			else x=-1,I=0;
			if(O<=min(J,I))
				r=max(r,O);
		}
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 0