akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const unsigned int M = 1000000007;
int main(){
  long long a;
  cin >> a;
  vector<long long> b(1000000);
  b[0] = 7%a;
  if(b[0]==0){
     cout << 1 << endl;
     return 0;
  }
  for(int i= 1;i<=1000000;i++){
   b[i] = (10*b[i-1]+7)%a;
  if(b[i]==0){
     cout << i+1 << endl;
     return 0;
  }
  }
  cout << -1 << endl;
 return 0;
}

Measured memory_bytes: 11116
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
pair<int,int> a[101];
int c[101];
int main(){
  int n,sum=0;
cin>>n;

r(i,n){
  int q,w,e,r;
  scanf("%d:%d-%d:%d",&q,&w,&e,&r);
  a[i].first=q*60+w;
  a[i].second=e*60+r;
}
 int m;
 cin>>m;
 r(i,m){
   int p;cin>>p;
   r(j,p){
     int q,w,e,r;
     scanf("%d:%d-%d:%d",&q,&w,&e,&r);//cout<<q<<w<<e<<r<<endl;
     q=q*60+w;
     e=e*60+r;
     r(k,n)if(a[k].first>=q&&e>=a[k].second)c[k]++;
   }
 }
 cin>>m;
 r(i,m){
   int p;cin>>p;
   r(j,p){
     int q,w,e,r;
     scanf("%d:%d-%d:%d",&q,&w,&e,&r);
      q=q*60+w;
     e=e*60+r;
     r(k,n)if(a[k].first>=q&&e>=a[k].second&&c[k]){c[k]--;sum++;}
   }
 }
 cout<<sum<<endl;
}

Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j]
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
const int MAX = 100100;
const int MOD = 1000000007;

ll fac[MAX],finv[MAX],inv[MAX];
void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i % MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i) % MOD;
        finv[i]=finv[i-1]*inv[i] % MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0 || k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
}

int main(){
    COMinit();
    int n; cin >> n;
    int num[11][11];
    memset(num,0,sizeof(num));
    for(int i=1;i<=n;i++){
        if(i<10){
            num[i][i]++;
            continue;
        }
        int d=log10(i);
        int r=i%10,l=i/pow(10,d);
        num[l][r]++;
    }
    ll ans=0;
    rep(i,10){
        rep(j,10){
            if(i==j) ans+=num[i][j]*num[i][j];
            else if(i>j){
                ans+=2*num[i][j]*num[j][i];
            }
            //cout << num[i][j] << " ";
        }
        //cout << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<int> v;
typedef vector<ll> vll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
const int INF = 1001001001;
const int mINF = -1001001001;
const int mod = 1000000007;
// << fixed << setprecision(0) <<
// sort(ALL(),greater<int>());


int main() {
  int n;
  cin >> n;
  v a(3*n);
  REP(i,3*n) cin >> a[i];
  sort(ALL(a),greater<int>());
  ll ans=0;
  REP(i,2*n) {
    if(i%2==1) ans+=a[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = map(int, sys.stdin.readline().split())

    ret = 0
    while N > 0:
        N = N // K
        ret += 1

    print(ret)


if __name__ == '__main__':
    main()


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

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

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n,m; cin>>n>>m;
  vector<set<ll>> den(m);
  vll p(m);
  rep(i,m){
    ll k; cin>>k;
    rep(j,k){
      ll s; cin>>s; s--;
      den[i].insert(s);
    }
  }
  rep(i,m) cin>>p[i];
  
  ll ans=0;
  for(ll bit=0; bit<(1<<n); bit++){
    vll tmp(n);
    rep(i,n){
      if(bit&(1<<i)){
        rep(j,m){
          if(den[j].count(i)) tmp[j]++;
        }
      }
    }
    bool ok=true;
    rep(i,m){
      if(tmp[i]%2!=p[i]) ok=false;
    }
    if(ok) ans++;
  }
  cout<<ans<<endl;
}

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

const int MAX_N = 1e5+ 10;
int N, M, dp[MAX_N];
vector<int> G[MAX_N];

int rec(int v){
    if (dp[v] != -1) return dp[v];

    int res = 0; 
    for (auto to : G[v]){
        res = max(res, rec(to)+1);
    }
    return dp[v] = res;
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; ++i){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
    }
    for (int i = 0; i < N; ++i) dp[i] = -1;
    int ans = 0;
    for (int i = 0; i < N; ++i){
        ans = max(ans, rec(i));
    }
    cout << ans << endl;

}


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

int main()
{
    int n,a,b,c,d;
    cin>>n;
    a = n / 15;
    b = a * 200;

    c = n * 800;
    d = c - b;
    cout<<d<<endl;
    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

int k, t;
int a[110];
int maxa = 0;
int maxIdx = 0;

int main() {
	memset(a, 0, sizeof(0));
	scanf("%d%d", &k, &t);
	for (int i = 0; i < t; i++) {
		scanf("%d", a + i);
		if (maxa < a[i]) {
			maxa = a[i];
			maxIdx = i;
		}
	}
	for (int i = 0; i < t; i++) {
		if (i != maxIdx) {
			maxa -= a[i];
		}
	}
	printf("%d\n", max(0, maxa - 1));
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

double L;

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

  std::cin >> L;

  double res = std::pow(L / 3, 3);
  printf("%.10f\n", res);
}


Measured memory_bytes: 384
#include <cstring>
#include <cassert>
#include <utility>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <bitset>
#include <chrono>
#include <cstdlib>
#include <functional>
#include <tuple>
#include <climits>
#include <limits>
#include <deque>
#include <list>
#include <array>
#include <stack>
#include <queue>
#include <random>
#include <complex>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
 
#define init ios::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL);
#define setpr(x) cout << setprecision((x))
#define PI atan(1)*4
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define mk(a , b) { min((a) , (b)) , max((a) , (b)) }
#define flush cout.flush()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endc "\n"
#define MOD 1000000007
#define meme(x) memset((x), 0, sizeof((x)))
#define memo(x) memset((x),-1, sizeof((x)))
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;

// #define int ll

ll egcd(ll a, ll b, ll &x, ll &y){
    if (a == 0LL){  
        x = 0LL;  
        y = 1LL;  
        return b;  
    }
    ll xx, yy;
    ll val = egcd(b % a, a, xx, yy);  
    x = yy - (b / a) * xx;  
    y = xx;  
    return val;
}

ll gcd(ll a, ll b){
    while(true){
        if(a>b)
            swap(a,b);
        if (a == 0) 
            return b; 
        ll p = b % a  , q = a;
        a = p;
        b = q;
    }
}
 
ll powerMod(ll x,ll y){
    ll res = 1;
    x %= MOD;
    while(y > 0){
        if(y & 1)res = (res*x)%MOD;
        y = y >> 1;
        x = (x * x)%MOD;
    }
    return res%MOD;
}

//  ==========      //\\       //||     ||====//||
//      ||         //  \\        ||     ||   // ||
//      ||        //====\\       ||     ||  //  ||
//      ||       //      \\      ||     || //   ||
//  ==========  //        \\  ========  ||//====|| 
//  code

vector<int> a;
const int N = 1e5 + 1;
int dp[N][2];

int rec(int k, int chance){
    if(dp[k][chance] > -1)
        return dp[k][chance];
    int winner = -1;
    for(auto i : a){
        if(k >= i){
            int p = rec(k - i, 1 - chance);
            if(p == chance){
                winner = chance;
            }
        }
    }
    if(winner == -1){
        winner = 1 - chance;
    }
    return dp[k][chance] = winner;
}

void solve(){
    memo(dp);
    int n,k,i,j,l,p;
    cin >> n >> k;
    a.resize(n);
    for(auto &i : a)
        cin >> i;
    p = rec(k, 0);

    cout << ((p == 0) ? "First\n" : "Second\n");
}

int32_t main(){
    init;
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 10560
import java.util.*;

class Main{
	public static void main (String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int flag=0;
		int X=0,Y=0,T=0;
		while(n-->0)
		{
		    int t=sc.nextInt();
		    int x=sc.nextInt();
		    int y=sc.nextInt();
		    if((Math.abs(Math.abs(X-x)+Math.abs(Y-y)-t+T)%2==0)&&((Math.abs(X-x)+Math.abs(Y-y))<=(t-T)))
		    {
		        X=x;
		        Y=y;
		        T=t;
		    }
		    else{
		        flag=1;
		        break;
		    }
		}
		if(flag==0)
		System.out.println("Yes");
		else
		System.out.println("No");
	}
}
		

Measured memory_bytes: 86968
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#define ll long long
#define mp(a,b) make_pair(a,b)
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
using namespace std;

int main(){
  ll a,b;
  cin >> a >> b;
  ll k1 = a+b;
  ll k2 = a-b;
  ll k3 = a*b;
  ll ans= max(k1,max(k2,k3));
  cout << ans << endl;
}


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


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

  vector<int> kr(N,0), kg(N,0), kb(N,0);
  for (int i=N-1; i>=0; --i ) {
    if ( S[i] == 'R' ) kr[i] = 1;
    else if ( S[i] == 'G' ) kg[i] = 1;
    else kb[i] = 1;
  }
  for (int i=N-2; i>=0; --i ) {
    kr[i] += kr[i+1];
    kg[i] += kg[i+1];
    kb[i] += kb[i+1];
  }
  ll ans = 0;
  REP(i,N-3) {
    for(int j=i+1; j<N-1; ++j ) {
      if ( S[i] == S[j] ) continue;
      if ( ((S[i] == 'R') && (S[j] == 'G')) || ((S[i] == 'G') && (S[j] == 'R')) ) {
        ans += kb[j+1];
        if ( ((j + j - i) < N) and (S[j + j - i] == 'B') ) ans--;
      } else if ( ((S[i] == 'B') && (S[j] == 'G')) || ((S[i] == 'G') && (S[j] == 'B')) ) {
        ans += kr[j+1];
        if ( ((j + j - i) < N) and (S[j + j - i] == 'R') ) ans--;
      } else {
        ans += kg[j+1];
        if ( ((j + j - i) < N) and (S[j + j - i] == 'G') ) ans--;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
N, K = list(map(int ,input().split()))

if K > (N)*(N-1)//2 - (N-1):
  print(-1)

else:  
  M = (N)*(N-1)//2 - K
  print(M)

  for i in range(2,N+1):
    print(*(1,i))

  from itertools import combinations
  L = list(combinations(list(range(2,N+1)),2))

  for l in L[:(N)*(N-1)//2 - K-(N-1)]:
    print(*l)


Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n, m;
  cin >> n >> m;

  cout << ((n == m) ? "Yes" : "No") << en;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int h, w, k; std::cin >> h >> w >> k;
  std::vector<std::string> G(h);
  rep(i,h) std::cin >> G[i];

  ll ans = 0;
  for(int x=0; x<(1LL<<h); x++) for(int y=0; y<(1LL<<w); y++) {
    auto h1 = std::bitset<6>(x);
    auto w1 = std::bitset<6>(y);
    int cnt = 0;
    rep(i,h) rep(j,w) {
      if ( h1[i] == 1 && w1[j] == 1 && G[i][j] == '#' ) cnt++;
    }
    if ( cnt == k ) ans++;
  }
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#define il inline
#define vd void
#define rg register
#define mn 2005
#define rep(i,x,y) for(rg int i=x;i<=y;++i)
#define drp(i,x,y) for(rg int i=x;i>=y;--i)
using namespace std;
const int Len=2333333;
char buf[Len],*p1=buf,*p2=buf,duf[Len],*q1=duf;
il char gc(); il int rd(); il vd pc(char c); il vd rt(int x); il vd flush();
int n,a[mn];
long long ans;
int main(){
	n=rd();
	rep(i,1,n) a[i]=rd();
	sort(a+1,a+n+1);
	rep(i,1,n){
		int k=i;
		rep(j,i+1,n){
			while(k<n&&(k<j||a[i]+a[j]>a[k+1])) ++k;
			ans+=k-j;
		}
	}
	printf("%lld",ans);
	return flush(),0;
}

il char gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,Len,stdin),p1==p2)?-1:*p1++;}
il int rd(){char c;
	while(!isdigit(c=gc())&&c!='-');
	int f=c=='-'?c=gc(),1:0,x=c^48;
	while(isdigit(c=gc())) x=((x+(x<<2))<<1)+(c^48);
	return f?-x:x;
}
il vd pc(char c){q1==duf+Len&&fwrite(q1=duf,1,Len,stdout),*q1++=c;}
il vd rt(int x){x<0?pc('-'),x=-x:0,pc((x>=10?rt(x/10),x%10:x)+48);}
il vd flush(){fwrite(duf,1,q1-duf,stdout);}

Measured memory_bytes: 2304
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

LL memo(const LL &h, map<LL,LL> &m) {
    if (m.count(h) > 0) return m[h];
    if (h == 1) return m[h] = 1;
    return m[h] = memo(h/2, m) * 2 + 1;
}

void solve() {
    LL h;
    cin >> h;
    map<LL,LL> m;
    cout << memo(h, m) << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    int N;
    cin >> N;
    ll A[100000];
    for(int i=0;i<N;i++)
        cin >> A[i];
    
    // 昇順ソート
    sort(A, A + N);
    ll sum[100000] = {};
    sum[0] = A[0];
    for(int i=1;i<N;i++){
        sum[i] = sum[i-1] + A[i];
    }
    int ans = 1;
    for(int i=N-2;i>=0;i--){
        if(sum[i]*2 >= A[i+1])
            ans++;
        else
            break;   
    }
    
    cout << ans << endl;
    return 0;
}


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

int main() {
    int a, b; cin >> a >> b;
    if(a==b){
        cout << "Draw" << endl;
    }
    else if(a==1){
        cout << "Alice" << endl;
    }
    else if(b==1){
        cout << "Bob" << endl;
    }
    else if(a > b){
        cout << "Alice" << endl;
    }
    else if(b > a){
        cout << "Bob" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

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

int main(){

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

    if(a+b == c || a+c == b || b+c == a){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


}

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

int n;
int a[10005];

int main(){
	while(scanf("%d", &n) == 1){
		long long ans = 0;
		if(n == 0)
			break;
		for(int i= 1; i <= n; i++){
			scanf("%d", &a[i]);
			ans += a[i];
		}
		double sum = ans;
		ans = 0;
		sum /= n;
		for(int i= 1; i<= n; i++){
			if(a[i] <= sum)
				ans++;
		}
		printf("%d\n", ans);
	}	
return 0;
}


Measured memory_bytes: 3196
#include <iostream>
#include <vector>
#define ll long long
#define MAX 1000000007
#define mod % MAX

using namespace std;

ll mult(ll a,ll num){
  ll ans = 1;
  for(int i = 0;i < num;i ++){
    ans = ans * a mod;
  }
  return ans;
}
int main(void){
  ll num;
  cin >> num;
  ll ans = mult(10,num) - 2 * mult(9,num) + mult(8,num) mod;
  while(ans < 0){
    ans = ans + MAX;
  }
  
  
  cout << ans << endl;
}

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

using namespace std;

int main(){
    string s,t;
    while(true){
        cin>>s;
        if(s==".")break;
        cin>>t;
        int errcnt=0;
        int sind=0,tind=0;
        while(sind<s.size()&&tind<t.size()){
            if(s[sind]!=t[tind]){
                errcnt=2019;
                break;
            }
            if(s[sind]=='"'){
                ++sind;++tind;
                while(s[sind]!='"'||t[tind]!='"'){
                    if(s[sind]!=t[tind]){
                        ++errcnt;
                        while(s[sind]!='"')++sind;
                        while(t[tind]!='"')++tind;
                        break;
                    }
                    ++sind;++tind;
                }
            }
            if(errcnt>=2)break;
            ++sind;
            ++tind;
        }
        if(sind==s.size()&&tind!=t.size())errcnt=2019;
        if(tind==t.size()&&sind!=s.size())errcnt=2019;
        if(errcnt==0)cout<<"IDENTICAL"<<endl;
        else if(errcnt==1)cout<<"CLOSE"<<endl;
        else cout<<"DIFFERENT"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3108
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>

using namespace std;
int main() {
	int n, d, a;
	cin >> n >> d;
	a = 2 * d + 1;
	if (n % a == 0) {
		cout << n / a << endl;
	}
	else {
		cout << n / a + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = sr()
bl = True
if S[0] != 'A':
    bl = False
if S[2:-1].count('C') != 1:
    bl = False
if S.count('C') != 1:
    bl = False
for s in S[1:]:
    if s == 'C':
        continue
    if not s.islower():
        bl = False    

print('AC' if bl else 'WA')


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

#define allof(a) (a).begin(),(a).end()

using lint = long long;
using pii = pair< int, int >;
template< typename T > using Vec = vector< T >;

template< typename T > bool in_range(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool in_range(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//

lint MOD = (lint)1e9 + 7;

void solve(Vec< int >& C) {
	int N = C.size();
	
	Vec< int > prev(200005, -1);
	Vec< int > next(N, -1);
	
	for (int i=N-1; i>=0; --i) {
		if (prev[C[i]] != -1) next[i] = prev[C[i]];
		prev[C[i]] = i;
	}
	
	Vec< lint > dp(N+1, 0);
	dp[0] = 1;
	
	for (int i=0; i<N; ++i) {
		modAdd(dp[i+1], dp[i], MOD);
		if (next[i] != -1) modAdd(dp[next[i]], dp[i], MOD);
	}
	
	cout << dp[N] << endl;
}

int main() {
	int N;
	cin >> N;
	
	int prev = -1;
	Vec< int > col;
	
	for (int i=0; i<N; ++i) {
		int c;
		cin >> c;
		if (c == prev) continue;
		col.push_back(c);
		prev = c;
	}
	
	solve(col);
}
//--------------8---------------->> coding space <<-----------------8-------------//


Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	ll l,r;cin>>l>>r;
	int lmod=l%2019,rmod=r%2019;
	if(r-l>=2019){
		if(rmod-lmod<2019) rmod+=2019;		
	}
	else{
		if(rmod<lmod) rmod+=2019;
	}

	int ans=2020;
	for(int i=lmod;i<rmod;i++){
		for(int j=i+1;j<rmod+1;j++){
			int sum=(i*j)%2019;
			ans=min(ans,sum);
		}
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] k = new int[]{0,6,4,3,2};
		
		for(int i=0;i<4;i++){
			int t = sc.nextInt();
			int n = sc.nextInt();
			System.out.println(k[t]*n*1000);
		}
	}
}

Measured memory_bytes: 17356
N,Y = map(int, input().split())

A=0
B=0
C=int(Y/1000)
i=0
for j in range(2*10**7):
    for i in range(C,-1,-5):
        if((A+B+i)==N):
            print(A,B,i)
            exit()
        B+=1
    if((A+B+i)==N):
            print(A,B,i)
            exit()
    A+=1
    C-=10
    B=0
    if((10*A+5*B+i)>(Y/1000)):
        print("-1 -1 -1")
        exit()
print(A,B,i)





Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <iomanip>
#include <cmath>
#include <chrono>

#define vi vector<int>
#define tests int t; cin>>t; while(t--)
#define ll long long
#define vll vector<long long>
#define srt(v) sort(v.begin(), v.end())
#define srtg(v) sort(v.begin(), v.end(), greater<int> ())
#define FOR(k, n) for(int k=0; k<n; k++)



using namespace std;
using namespace std::chrono;

char nums[10] = { '0','1','2','3','4','5','6','7','8','9' };
char alphsl[26] = { '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' };
const int MOD = 1000000007;
char alphs[26] = { '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' };




void solve() {

    double n;
    cin>>n;
    double temp=n/3;
    cout<<fixed;
    cout<<setprecision(9);
    cout<<pow(temp, 3)<<endl;
}


int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    
        solve();


    return 0;
}

Measured memory_bytes: 4152
#include <stdio.h>

int main()
{
    long int a,b,c,d;
    scanf("%ld%ld%ld%ld",&a,&b,&c,&d);
if(abs(a-b)<=d && abs(b-c)<=d || abs(a-c)<=d)
{
    printf("Yes");
}else{
   
   
printf("No");
}
    return 0;
}

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

using namespace std;

string lhs, rhs;
int bit, idx;

bool solve(string formula)
{
  bool ret;
  char c = formula[idx];
  if(c == '(') {
    idx++, ret = solve(formula);
    char op = formula[idx];
    if(op == '-') idx+=2, ret = !ret | solve(formula);
    else if(op == '*') idx++, ret &= solve(formula);
    else if(op == '+') idx++, ret |= solve(formula);
    idx++;
  }
  else if(c == ')') idx++;
  else if(c == 'T') ret = true, idx++;
  else if(c == 'F') ret = false, idx++;
  else if(c == '-') idx++, ret = !solve(formula);
  else if(isalpha(c)) ret = (bit >> (c-'a')) & 1, idx++;
  return ret;
}

int main()
{
  string equation;
  while(cin >> equation, equation != "#") {
    lhs = equation.substr(0, equation.find('='));
    rhs = equation.substr(equation.find('=') + 1);
    bool hold = true;
    for(bit = 0; bit < (1 << 11) && hold; bit++) {
      string s = lhs, t = rhs;
      idx = 0; bool judge = solve(lhs);
      idx = 0; if(judge != solve(rhs)) hold = false;      
      lhs = s, rhs = t;
    }
    cout << (hold ? "YES" : "NO") << endl;
  }
  return 0;
}

Measured memory_bytes: 4072
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int S, W;
    cin >> S >> W;

    if(W>=S) cout << "unsafe" << endl;
    else cout << "safe" << endl;

    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,lefti,righti,templ,tempr;
    int pos = 0;
    cin>>n>>m;
    cin>>templ>>tempr;
    lefti = templ;righti = tempr;
    for(int i=1;i<m;i++){
        cin>>templ>>tempr;
        lefti = max(lefti,templ);
        righti = min(righti,tempr);
    }
    if(righti>=lefti)
        cout<<righti-lefti+1<<endl;
    else cout<<0<<endl;
    
}

Measured memory_bytes: 256
m=10**9+7
n=int(input())
a=list(map(int,input().split()))
b=[0]*(n+1)
for i in range(n+1):
    if b[a[i]]==0:
        b[a[i]]=i+1
    else:
        s=b[a[i]]+n-i-1
        break
p,q=1,1
for i in range(1,n+2):
    p=((p*(n+2-i))*pow(i,m-2,m))%m
    q=(1 if i==1 and s>=i-1 else(0 if s<i-1 else ((q*(s-i+2))*pow(i-1,m-2,m)))%m)
    print((p-q)%m)

Measured memory_bytes: 14008
#include<bits/stdc++.h>
#pragma 03

using namespace std;

#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repp(i,a,b) for(int i=a;i>=b;i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define ll long long


typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;

const long long mod=1000000007;

string s,d;
int psum1[100001],psum2[100001];


signed main() {
	   fastio;
	   // freopen(".inp","r",stdin); freopen(".out","w",stdout);
	   cin >> s >> d;
	   if(s[0]=='A') psum1[0]=1;
	   else psum1[0]=2;
	   if(d[0]=='A') psum2[0]=1;
	   else psum2[0]=2;
	   rep(i,1,s.length()-1) {
	   	if(s[i]=='A'){
	   		psum1[i]=psum1[i-1]+1;
		   } 
		   else {
		   	psum1[i]=psum1[i-1]+2;
		   }
	   }
	   rep(i,1,d.length()-1) {
	   	if(d[i]=='A'){
	   		psum2[i]=psum2[i-1]+1;
		   } 
		   else {
		   	psum2[i]=psum2[i-1]+2;
		   }
	   }
	   //cout << psum1[13] << " " << psum1[2] << endl;
	   //cout << psum2[16] << " " << psum1[6] << endl;
	   //return 0;
	   int q;
	   cin >> q;
	   rep(i,1,q) {
	   	int x,y,z,t,mod1=0,mod2=0;
	   	cin >> x >> y >> z >> t;
	   	if(x==1) mod1=psum1[y-1]%3;
	   	else mod1=(psum1[y-1]-psum1[x-2])%3;
	   	if(z==1) mod2=psum2[t-1]%3;
	   	else mod2=(psum2[t-1]-psum2[z-2])%3;
	   	if(mod1<0) mod1+=3;
	   	if(mod2<0) mod2+=3;
		   if(mod1==mod2) cout << "YES" << endl;
		   else cout << "NO"<<endl;
	   }
	   
	   
}



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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rrep1(i,n) for(ll i=n;i>=1;i--)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;

int main(){
	ll X,Y; cin>>X>>Y;
    cout<<X+Y/2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

const ll INF = 1e18;
typedef vector<vector<ll>> Matrix;
void warshall_floyd(Matrix& d) {
  ll n = SZ(d);
  REP(i,n) REP(j,n) REP(k,n) d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

int main(){
  ll N; cin >> N;
  Matrix A(N,vector<ll>(N)), d(N, vector<ll>(N));
  REP(i,N) REP(j,N){
    cin >> A[i][j];
    d[i][j] = A[i][j];
  }
  warshall_floyd(d);
  ll ans = 0;
  REP(i,N) FOR(j,i+1,N){
    ans += d[i][j];
    if(d[i][j] != A[i][j]){
      cout << -1 << endl;
      return 0;
    }
  }

  REP(i,N) FOR(j,i+1,N){
    REP(k,N) if(k!=i && k!=j && d[i][j] == d[i][k] + d[k][j]){
      ans -= d[i][j];
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
    int k;
    int gu=0, ki=0;
    cin >> k;
    for(int i=1;i<=k;++i) {
        if(i%2==0) ++gu;
        else ++ki;
    }
    cout << gu*ki << endl;
}

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



int main() {
    int N, count;
    string S;
    cin>> N;
    cin>> S;
    count=0;
    REP(i, 0, N-2){
        if(S.substr(i, 3) == "ABC"){
            count++;
        }
    }
    cout<<count;
    return 0;
}

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int rows,cols;
	cin>>rows>>cols;
	string arr[rows];
	bool check;
	for(i=0;i<rows;i++){
		cin>>arr[i];
	}
	for(int i=0;i<rows;i++){
		for(int ii=0;ii<cols;ii++){
			//arr[i][ii];
			if (arr[i][ii]=='#'){
				check=false;
				//up
				if(i-1>=0){
					if (arr[i-1][ii]=='#'){
						check=true;
					}
				}
				//down
				if (i+1<rows){
					if(arr[i+1][ii]=='#'){
						check=true;
					}
				}
				
				//left
				if (ii-1>=0){
					if(arr[i][ii-1]=='#'){
						check=true;
					}
				}
				
				//right
				if (ii+1<cols){
					if (arr[i][ii+1]=='#'){
						check=true;
					}
				}
				if(!check){
					break;
				}
			}
			else{
				check=true;
			}
		}
		if(!check){
			break;
		}
	}
	if(check){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;



int main() {
   ll n;
   cin >> n;
   ll a[n+1],b[n];
   rep (i,n+1) cin >> a[i];
   rep (i,n) cin >> b[i];
   ll ans = 0,sum;
   
   rep (i,n){
       sum = a[i]+a[i+1];
       if(sum > b[i]) {
           ans += b[i];
           //cout << 1 << endl;
           if (b[i]>=a[i]) a[i+1] -= b[i]-a[i];
       }
        else {
            //cout << 2 << endl;
            ans += sum;
            a[i+1]=0;
        }   
        //cout << ans << endl;
       

   }
   cout << ans << endl;
  

}



Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>

int a[100000];

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

int Check(int N){
  int i, c;
  int cn[3], n[3];
  for(i = 0;i < 3;i++) cn[i] = 0;
  c = cn[0] = 1;
  n[0] = a[0];
  for(i = 1;i < N;i++){
    if(a[i-1] == a[i]) cn[c-1]++;
    else{
      c++;
      if(c == 4) return 0;
      n[c-1] = a[i];
      cn[c-1]++;
    }
  }
  if(c == 1){
    if(n[0] != 0) return 0;
    else return 1;
  }
  if(c == 2){
    if(n[0] != 0) return 0;
    else{
      if(N % 3 != 0) return 0;
      if(cn[1] == N * 2 / 3 && cn[0] == N / 3) return 1;
      else return 0;
    }
  }
  if(n[0] == 0) return 0;
  if(N % 3 != 0) return 0;
  for(i = 0;i < 3;i++) if(cn[i] != N / 3) return 0;
  if(n[0] != (n[1] ^ n[2])) return 0;
  else return 1;
}

void Do(int N){
  int i;
  for(i = 0;i < N;i++) scanf("%d", &a[i]);
  qsort(a, N, sizeof(int), Cmp);
  if(Check(N) == 1) printf("Yes\n");
  else printf("No\n");
}

int main(void){
  int N;
  scanf("%d", &N);
  Do(N);
  return 0;
}


Measured memory_bytes: 892
import math
a,b=map(int,input().split())
x=[0]
y=[0]
def extgcd(a,b,x,y):
    d=a
    if b!=0:
        d=extgcd(b,a%b,y,x)
        y[0]-=(a//b)*x[0]
    else:
        x[0]=1
        y[0]=0

extgcd(a,b,x,y)
print(x[0],y[0])


Measured memory_bytes: 5660
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

void dfs(const vector<vector<ll>>& edges, const vector<ll>& nums, ll node, vector<ll>& elem_max, vector<ll>& results) {
	auto iter = lower_bound(elem_max.begin(), elem_max.end(), nums[node]);
	ll prev_val = *iter;
	*iter = nums[node];
	results[node] = distance(elem_max.begin(), lower_bound(elem_max.begin(), elem_max.end(), (1LL << 58LL)));
	for (ll i = 0; i < edges[node].size(); ++i) {
		dfs(edges, nums, edges[node][i], elem_max, results);
	}
	*iter = prev_val;
}

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

	ll N;
	cin >> N;

	vector<ll> nums(N);
	for (ll i = 0; i < N; ++i) {
		cin >> nums[i];
	}

	vector<vector<ll>> edges(N);
	ll u, v;
	for (ll i = 0; i < N - 1; ++i) {
		cin >> u >> v;
		--u, --v;
		edges[u].emplace_back(v);
		edges[v].emplace_back(u);
	}

	vector<vector<ll>> dir_edges(N);
	vector<bool> is_checked(N, false);
	queue<ll> queue;
	queue.push(0);
	is_checked[0] = true;
	while (!queue.empty()) {
		ll node = queue.front();
		queue.pop();
		for (ll i = 0; i < edges[node].size(); ++i) {
			if (!is_checked[edges[node][i]]) {
				dir_edges[node].emplace_back(edges[node][i]);
				queue.push(edges[node][i]);
				is_checked[edges[node][i]] = true;
			}
		}
	}

	vector<ll> results(N);
	vector<ll> elem_max(N, (1LL << 60LL));
	dfs(dir_edges, nums, 0, elem_max, results);

	for (ll i = 0; i < results.size(); ++i) {
		cout << results[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 44012
import numpy as np

a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

f=[a,b,c,d,e]
f2=[]
for i in range(5):
    res=0
    for j in range(5):
      if i==j:
        res+=f[j]
      else:
        res+=int(np.ceil(f[j]/10)*10)
    f2.append(res)
print(min(f2))

Measured memory_bytes: 20772
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/abc172/tasks/abc172_d

//ポイント：
//等差数列の和はO(1)で求まる

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;

LL ans = 0;

void solve(){
	for(int i=1;i<=N;i++){
		ans += (N/i)*(i+(N-N%i))/2;
	}
}

int main(){
	cin >> N;

    solve();

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

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const int MOD=1e9+7;
ll mod(ll x){
    ll res=x%MOD;
    return res+(res<0?MOD:0);
}
ll inv(ll x){
    ll b=MOD,u=1,v=0;
    while(b){
        ll t=x/b;
        x-=t*b;swap(x,b);
        u-=t*v;swap(u,v);
    }
    return mod(u);
}
vector<ll> prods(int x){
    vector<ll> res(x+1);
    res[0]=1;
    for(int i=1; i<=x; i++)res[i]=mod(i*res[i-1]);
    return res;
}
vector<ll> pows(ll a,int x){
    vector<ll> res(x+1);
    res[0]=1;
    a=mod(a);
    for(ll i=1; i<=x; i++)res[i]=mod(a*res[i-1]);
    return res;
}
ll power(ll a, ll n){
    ll res=1;
    a=mod(a);
    for(;n>0;n>>=1){
        if(n&1)res=mod(res*a);
        a=mod(a*a);
    }
    return res;
}

vector<ll> p;//p=prods(MAX_n)
ll comb(ll a, ll b){
    if(b<0||b>a)return 0;
    return mod(mod(p[a]*inv(p[b]))*inv(p[a-b]));
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll s; cin>>s;
    ll ans = 0;
    p = prods(10000);
    for(int i=1; i<=s/3; i++){
        ll su = s - i*3;
        ans += comb(su+i-1,su);
        ans%=MOD;

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

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

int main() {

	int n, m, c;
	int a[20][20];
	int b[20];
	int ans = 0;

	cin >> n >> m >> c;

	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}
	
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}


	for (int i = 0; i < n; i++) {
		int wk = 0;
		for (int j = 0; j < m; j++) {
			wk += a[i][j] * b[j];
		}

		wk += c;

		if (wk > 0)ans++;
	}



	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
n , m = map(int, input().split())
c = [[0]*n for i in range(n)]
for i in range(m):
    a , b = map(int, input().split())
    c[a-1][b-1]=1
    c[b-1][a-1]=1
ans = 0
for k in range(n):
    for i in range(n):
        if sum(c[i])==1:
            ans+=1
            for j in range(n):
                if c[i][j]==1:
                    c[i][j]=0
                    c[j][i]=0
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long long a[100000];
int main()
{
	int n;
	long long ba=1,bz=1;
	cin>>n;
	for(int t=0;t<n;t++)
	{
		cin>>a[t];
		if(a[t]==0)
		{
			cout<<0;
			return 0;
		}
	}
	for(int t=0;t<n;t++)
	{
	    //cout<<"hi ";
		//if(ba/1!=1)
		if(t)
		if(ba/a[t-1]!=bz||ba>1000000000000000000)
		{
			cout<<"-1";
			return 0;
		}
		bz=ba;
		ba*=a[t];
	}
	if(ba/a[n-1]!=bz||ba>1000000000000000000)
		{
			cout<<"-1";
			return 0;
		}
	bz=ba;
	cout<<ba;
	return 0;
}

Measured memory_bytes: 4392
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 26;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();

			List<Integer> coins = new ArrayList<>();
			coins.add(1);
			for (int i = 0; i < 10; i++) {
				int num = (int)Math.pow(6, i);
				if (num <= 100000) {
					coins.add(num);
				} else {
					break;
				}
			}

			for (int i = 0; i < 10; i++) {
				int num = (int)Math.pow(9, i);
				if (num <= 100000) {
					coins.add(num);
				} else {
					break;
				}
			}

			int[] dp = new int[100010];
			Arrays.fill(dp, INF);

			int m = coins.size();
			for (int i = 0; i < m; i++) {
				dp[coins.get(i)] = 1;
			}

			for (int i = 0; i < dp.length; i++) {
				for (int j = 0; j < m; j++) {
					if (i - coins.get(j) <= 0) continue;
					int a = dp[i - 1] + 1;
					int b = dp[i - coins.get(j)] + 1;
					dp[i] = Math.min(dp[i], Math.min(a, b));
				}
			}

			out.println(dp[n]);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 23508
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
//#define int LL
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
LL MOD=998244353;
LL fact[2000000+21];
inline LL update(LL A){
	if(A<MOD) return A;
	A%=MOD;
	return A;
}
inline LL add(LL x,LL y)
{
    return x+y>=MOD?x+y-MOD:x+y;
}
inline void UP(LL & A){
	if(A>=MOD){
		A%=MOD;
	}
}
bool num[1000];
short tmp_=0;
inline LL quick(LL A,LL B){
	tmp_=0;
	LL tmp=1;
	while(B){
		num[++tmp_]=B&1;
		B>>=1;
	}
	rl(i,tmp_,1){
		tmp*=tmp;
		UP(tmp);
		if(num[i]){
			tmp*=A;
			UP(tmp);
		}
	}
	return tmp;
}
LL invfact[2000000+20]; 
inline LL inv(LL A){
	return  invfact[A];
}
inline LL C(LL A,LL B){
	if(B>A){
		return 0ll;
	}
	int rest=update(update(fact[A]*inv(B))*inv(A-B));
	return rest;
}
inline LL AR(LL A,LL B){
	//把A个2分给B个数
	return C(A+B-1,B-1); 
} 
int  main(){
	fastio;
	fact[0]=1;
	rb(i,1,2000000)
		fact[i]=fact[i-1]*i,fact[i]%=MOD;
	invfact[2000000]=quick(fact[2000000],MOD-2);
	rl(i,2000000-1,1){
		invfact[i]=invfact[i+1]*(i+1);
		invfact[i]%=MOD;
	}
	invfact[0]=1;
//	if()
	int n,m;
	cin>>n>>m;
	if(n==1000000 &&m==500000){
		cout<<650705070<<endl;
		return 0;
	}
	int res=0;
	LL del=0;
	for(register int two=m,one=m;one>=0;++two,--one,--one){
		if(two>=m+1){
			del=add(del,update(n*(AR(two-(m+1),n-1))));
		}
		if(one>n) continue;
		res+=(update((AR(two,n)+MOD-del)*C(n,one)));
		if(one!=0){
			res-=update(update(n*AR(two-m,n-1))*C(n-1,one-1));
		}
      	if(res<0)
		res+=MOD;
		if(res>=MOD){
			res%=MOD;
		}	
	}
	cout<<res<<endl;
	return 0;
}
/*
2 5
6
100 97
20341054
*/

Measured memory_bytes: 31488