akhauriyash/Code-Regression huggingface dataset:
// ------------------------------------
// Date:2018/ 3/ 2
// Problem:AOJ DPL 0-1 Knapsack Problem 1_b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

//static const int MOD = 1000000007;

// dp[今見てる品物の個数][まだ詰め込める量]
int dp[101][10101];

// v:value / w:weight
int v[1010];
int w[1010];

// N:品物の個数 / W:ナップサックの容量
int N, W;

int main()
{
  // 初期化
  memset(dp, 0, sizeof(dp));
  memset(v, 0, sizeof(v));
  memset(w, 0, sizeof(w));
  scanf("%d %d", &N, &W);
  REP(i, N) {
    scanf("%d %d", &v[i], &w[i]);
  }
  
  RREP(num, N) {
    REP(weight, W+1) {
      if (weight < w[num]) {
        // 見ている品物の重さが、まだ詰め込める量より多いとき
        dp[num][weight] = dp[num + 1][weight];
      } else {
        // 詰め込むことが可能な状態で、max(詰め込まない or 詰め込む
        dp[num][weight] = max(dp[num + 1][weight],
                              dp[num + 1][weight - w[num]] + v[num]);
      }
    }
  }
  
  int ans = dp[0][W];
  printf("%d\n", ans);
  
  return 0;
}



Measured memory_bytes: 7216
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i=0; i < n; i++){
        cin >> v[n-i-1];
    }
    int L = 2, R = 2;
    for (int i=0; i < n; i++){
        int l, r;
        int x = v[i];
        if (L % x == 0) l = L/x;
        else l = L/x + 1;
        R++;
        if (R % x == 0) r = R/x;
        else r = R/x + 1;
        r--;
        //cout << l << " " << r << endl;
        if (l > r){
            cout << -1 << endl;
            return 0;
        }
        L = l*x;
        R = (r+1) * x - 1;
       // cout << L << " " << R << endl;
    }
    cout << L << " " << R << endl;
    return 0;
}





Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b){
        cout<<c<<endl;
    }else if(b==c){
        cout<<a<<endl;
    }else{
        cout<<b<<endl;
    }
    return 0;
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N;
  cin >> N;
  vector< int64 > A(N);
  cin >> A;

  auto check = [&](int64 bits) {
    bitset< 61 > X;
    vector< bitset< 61 > > tap(N);
    for(int i = 0; i < 61; i++) {
      if((bits >> i) & 1) {
        X[i] = 1;
        for(int j = 0; j < N; j++) {
          if((A[j] >> i) & 1) tap[j][i] = 1;
        }
      }
    }
    bitset< 61 > bit[61];
    for(int i = 0; i < N; i++) {
      for(int j = 0; j < 61; j++) {
        if(tap[i][j]) {
          if(bit[j][j]) {
            tap[i] ^= bit[j];
          } else {
            bit[j] = tap[i];
            break;
          }
        }
      }
    }
    for(int j = 0; j < 61; j++) {
      if(X[j]) X ^= bit[j];
    }
    return X.none();
  };

  int64 bit = 0;
  int64 uku = 0;

  for(int i = 60; i >= 0; i--) {
    int one = 0;
    for(int j = 0; j < N; j++) {
      if((A[j] >> i) & 1) one++;
    }
    if(one == 0) continue;
    if(one % 2 == 1) bit |= 1LL << i; // どうやって分けてもうくちゃん
    else {
      if(check(uku | (1LL << i))) uku |= 1LL << i; // 1にできるときやる
    }
  }

  cout << (uku * 2) + bit << endl;
}








Measured memory_bytes: 1920
/*input
7 26
10
20
30
40
30
20
10
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

const int N = 2e5+1;
map<int,int> nice;
vector<int> all;
int pref[N];
int bit[N];
int n,k;
int cur = 1;
int ans = 0;

void upd(int ind){
	while(ind <= cur){
		bit[ind]++;
		ind += ind&(-ind);
	}
}

int prefs(int ind){
	int res = 0;
	while(ind){
		res += bit[ind];
		ind -= ind&(-ind);
	}
	return res;
}

void solve(){
  	pref[0] = 0;
  	all.pb(0);
  	cin >> n >> k;
  	RE(i,n){
  		int x;cin >> x;
  		pref[i] = pref[i-1]+x-k;
  		all.pb(pref[i]);
  	}
  	sort(all(all));
  	REP(i,all.size()){
  		if(i and all[i] != all[i-1])cur++;
  		nice[all[i]] = cur;
  	}
  	REP(i,n+1){
  		pref[i] = nice[pref[i]];
  	}
  	upd(pref[0]);
  	RE(i,n){
  		ans += prefs(pref[i]);
  		upd(pref[i]);
  	}
  	cout << ans;

}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 17392
import java.util.Scanner;

//Surface Area of Quadrangular Pyramid
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			double x = sc.nextDouble();
			double h = sc.nextDouble();
			if(x==0&&h==0)break;
			double r = Math.sqrt(h*h+(x/2)*(x/2));
			System.out.println((x*x+2*r*x));
		}
	}
}

Measured memory_bytes: 12000
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, A;
vector <int> Graph[int(2e5 + 5)];

int main(){
  scanf("%d", &N);
  for (int i = 2; i <= N; i++){
    scanf("%d", &A);
    Graph[A].push_back(i);
  }
  
  for (int i = 1; i <= N; i++){
    printf("%d\n", Graph[i].size());
  }
  
  return 0;
}


Measured memory_bytes: 14520
#include <algorithm>
#include <iostream>
#include <vector>

struct Card {
  char suit;
  int num;
};

void printArray(std::vector<Card> cards) {
  int n = (int)cards.size();
  for (int i = 0; i < n; i++) {
    std::cout << cards[i].suit << cards[i].num;
    if (i < n - 1)
      std::cout << " ";
    else
      std::cout << std::endl;
  }
}

void bubbleSort(std::vector<Card> &a) {
  bool flag = true;
  int count = 0;
  while (flag) {
    flag = false;
    for (int i = (int)a.size() - 1; i >= 0; i--) {
      if (a[i].num < a[i - 1].num) {
        std::swap(a[i], a[i - 1]);
        count++;
        flag = true;
      }
    }
  }
}

void selectionSort(std::vector<Card> &a) {
  int min, n = (int)a.size(), count = 0;
  for (int i = 0; i < n; i++) {
    min = i;
    for (int j = i; j < n; j++) {
      if (a[j].num < a[min].num) {
        min = j;
      }
    }
    if (i != min) {
      std::swap(a[i], a[min]);
      count++;
    }
  }
}

int main() {
  int n;
  std::cin >> n;
  std::vector<Card> cards(n), cards2(n);
  char suit;
  int num;
  for (int i = 0; i < n; i++) {
    std::cin >> suit >> num;
    Card c = {suit, num};
    cards[i] = c;
    cards2[i] = c;
  }

  bubbleSort(cards);
  printArray(cards);
  std::cout << "Stable" << std::endl;

  selectionSort(cards2);
  printArray(cards2);
  for (int i = 0; i < n; i++) {
    if (cards[i].suit != cards2[i].suit) {
      std::cout << "Not stable" << std::endl;
      return 0;
    }
  }
  std::cout << "Stable" << std::endl;
}



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

int main(){
    int N,K,Q;
    cin>>N>>K>>Q;
    vector<int> Per(N,K-Q);
    vector<int> A(Q);
    for(int i=0; i<Q; i++){
        cin>>A[i];
    }
    for(int i=0; i<Q; i++){
        Per[A[i]-1]++;
    }
    for(int i=0; i<N; i++){
        if(Per[i]>0){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
}

Measured memory_bytes: 1408
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        mut a:[u64;n],
    }
    let mut tmp = 0;
    let mut before = 0;
    for x in a {
        if x > before {
            before = x;
        } else {
            tmp += before - x;
        }
    }
    println!("{}",tmp);
}


Measured memory_bytes: 5624
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    int x = 0;
    bool ok = true;
    for(int i=0; i<n; i++){
        string state;
        cin >> state;
        if(state == "A") x+=1;
        if(state == "Un") x-=1;
        if(x<0){
            ok = false;
            break;
        }
    }
    if(x+=0) ok = false;
    if(ok) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 3156
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
    long long a,b;
    cin >> a >> b;
    long long ans;
    int count=0;
    long long i;
    if(a%2!=b%2) cout << "IMPOSSIBLE" << endl;
    else cout << (a+b)/2 << endl;
 }


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

//組み合わせを線形で
//参考:https://drken1215.hatenablog.com/entry/2018/06/08/210000

const int MXN=1000003;//変更可
ll fac[MXN],inv[MXN],finv[MXN];

void COMinit(int M) {
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(int i=2;i<MXN;i++){
        fac[i]=fac[i-1]*i%M;
        inv[i]=M-M/i*inv[M%i]%M;
        finv[i]=finv[i-1]*inv[i]%M;
    }
}

ll pow_tousa(ll x,ll y){
    if(x>=1000003){
        return 0;
    }
    else{
        return fac[x]*finv[x-y];
    }
}

ll pow_mod(ll x,ll y,ll m){
    if(y==0){
        return 1;
    }
    if(y%2){
        return x*pow_mod(x,y-1,m)%m;
    }
    ll t=pow_mod(x,y/2,m);
    return t*t%m;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int mod=1000003;
    COMinit(mod);
    ll Q;
    cin >> Q;
    rep(t,Q){
        ll x,d,n;
        cin >> x >> d >> n;
        if(d==0){
            cout << pow_mod(x,n,mod) << endl;
        }
        else{
        	ll nx=x*inv[d];
        	nx%=mod;
        	cout << pow_tousa(nx+n-1,n)*pow_mod(d,n,mod)%mod << endl;
        }
    }
}

Measured memory_bytes: 27072
n = int(input())
info = [[int(i) for i in input().split()] for j in range(n)]
info.sort(key=lambda x:x[2])
if n == 1:
    print(info[0][0], info[0][1], info[0][2])
else:
    for i in range(n):
        if info[i][2] > 0:
            r = i
    for x in range(101):
        for y in range(101):
            h = info[r][2] + abs(x - info[r][0]) + abs(y - info[r][1])
            for i in range(n):
                if i < n-1 :
                    if info[i][2] == 0:
                        if h > abs(x - info[i][0]) + abs(y - info[i][1]):
                            break
                    else:
                        if h != info[i][2] + abs(x - info[i][0]) + abs(y - info[i][1]):
                            break
                elif i == n-1:
                    if h == info[i][2] + abs(x - info[i][0]) + abs(y - info[i][1]):
                        cx = x
                        cy = y
                        ch = h
    print(cx, cy, ch)


Measured memory_bytes: 3064
data class Sc(val s: Int, val c: Int) {
    constructor(sc: List<Int>): this(sc[0] - 1, sc[1])
}
fun main(args: Array<String>) {
    val (N, M) = listOfInt()
    val SC = Array(M) { Sc(listOfInt()) }
    fun d2c(D: Int): List<Int> {
        if (D == 0) return intArrayOf(0).asList()
        var d = D
        val a = mutableListOf<Int>()
        while (d > 0) {
            a.add(d % 10)
            d /= 10
        }
        return a.reversed()
    }
    for (n in 0 .. 999) {
        val d = d2c(n)
        if (d.size != N) continue
        var ans = true
        for (m in 0 until M) {
            if (d[SC[m].s] != SC[m].c) ans = false
        }
        if (ans) {
            println(n)
            return
        }
    }
    println(-1)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt(offset: Int = 0) = listOfString().map { Integer.parseInt(it) + offset }

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

struct Restaurant {
    string name;
    int score;
    int id;
};

int main()
{
    int n;
    cin >> n;

    vector<Restaurant> v(n);
    for (int i = 0; i < n; i++) {
        Restaurant r;
        cin >> r.name >> r.score;
        r.id = i + 1;
        v[i] = r;
    }
    sort(v.begin(), v.end(), [](const auto& r1, const auto& r2) {
        if (r1.name == r2.name) {
            return r1.score > r2.score;
        } else {
            return r1.name < r2.name;
        }
    });
    for (int i = 0; i < n; i++) {
        cout << v[i].id << endl;
    }
    return 0;
}

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

using namespace std;

int main() {
    int a;
    vector<char> s;

    cin >> a;
    if (a < 3200)
    {
        cout << "red";
        return 0;
    } else {
        char x;
        while (cin >> x)
        {
            cout << x;
        }
    }
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

public class Don
{
    public Don() { }
    private Reader r = new Reader();

    public void Solve()
    {
        var S = r.next();
        var ret = "";
        for(var i = 0; i < S.Length; i++)
        {
            switch (S[i])
            {
                case '0':
                    ret += '0';
                    break;
                case '1':
                    ret += '1';
                    break;
                case 'B':
                    if (ret.Length != 0)
                    {
                        ret = ret.Substring(0, ret.Length - 1);
                    }
                    break;

            }

        }
        Console.WriteLine(ret);
    }

    public static void Main(string[] args)
    {
        new Don().Solve();
    }

}

class Reader
{
    string[] s;
    int i;
    char[] cs = new char[] { ' ' };

    public Reader()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length)
            return s[i++];
        var input = Console.ReadLine();
        while (input == "")
            input = Console.ReadLine();
        s = input.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return next();
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 2772
/*

Coded and Decoded by : Yash Kapoor

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

// s.find_by_order(index);
// s.order_of_key(value);

#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair
#define pll pair<ll, ll>
#define vl vector<ll>
#define sl set<ll>
#define vll vector<pll>
#define ml map<ll, ll>
#define mll map<pll, ll>
#define all(a) a.begin(), a.end()
#define x first
#define y second
#define sz(x) (ll) x.size()
#define dl '\n'
#define why (ll)1000000007
//#define why         (ll)998244353
#define lp(i, a, b) for (ll i = a; i < b; ++i)
#define lpr(i, a, b) for (ll i = a; i >= b; i--)
#define lpd(i, x) for (auto i : x)
#define ios                                                                                                            \
  ios_base::sync_with_stdio(false);                                                                                    \
  cin.tie(0);                                                                                                          \
  cout.tie(0);

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

ll inf = 1e18;
ld pi = 3.141592653589;
ll mod = why;
ll fast_power(ll base, ll power, ll mod)
{
  ll result = 1;
  while (power) {
    if (power % 2)
      result = (result * base) % mod;
    base = (base * base) % mod;
    power /= 2;
  }
  return result;
}

ll inverse(ll base, ll mod) { return fast_power(base, mod - 2, mod); }
int test = 1;
void solve() 
{
   ll n,d; cin >> n >> d;
   ll ans = 0;
   vl x(n),y(n); lp(i,0,n) cin >> x[i] >> y[i];
   lp(i,0,n){
    if(x[i]*x[i] + y[i]*y[i] <= d*d){
        ans ++;
    }
   }
   cout << ans ;
}

int main()
{
  // #ifndef ONLINE_JUDGE 
  //   freopen("input.txt", "r", stdin);
  //   freopen("output.txt", "w", stdout);
  // #endif
  ios 
  ll t = 1;
  //cin >> t;
  while (t--) 
  {
    //cout << "Case #" << test++ << ": ";
    solve();
  }
}

Measured memory_bytes: 6348
#include <iostream>
#include <vector>
using namespace std;
const int nmax=1e5+5,mod=1e9+7;
vector <int> muchii[nmax];
long long dp[nmax][2];
long long dfs(int nod,int tata,int culoare)
{
    if (dp[nod][culoare]!=-1)
        return dp[nod][culoare];
    dp[nod][culoare]=1;
    for (int i=0;i<muchii[nod].size();i++)
    {
        int vecin=muchii[nod][i];
        if (vecin!=tata)
        {
            long long nrSubarbori=1;
            if (culoare==0)
                nrSubarbori=dfs(vecin,nod,1)%mod;
            else
                nrSubarbori=(dfs(vecin,nod,0)+dfs(vecin,nod,1))%mod;
            dp[nod][culoare]=(dp[nod][culoare]*nrSubarbori)%mod;
        }
    }
    return dp[nod][culoare];
}
int main()
{
    int n;
    cin >> n;
    for (int i=1;i<n;i++)
    {
        int x,y;
        cin >> x >> y;
        muchii[x].push_back(y);
        muchii[y].push_back(x);
    }
    for (int i=1;i<=n;i++)
    {
        dp[i][0]=-1;
        dp[i][1]=-1;
    }
    cout << (dfs(1,-1,0)+dfs(1,-1,1))%mod;
}

Measured memory_bytes: 17024
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner (System.in);
		int num = sc.nextInt();
		HashSet<Integer> type = new HashSet<>();

		for(int i=0 ; i<num ; i++) {
			type.add(sc.nextInt());
		}

		System.out.println(type.size() < num ? "NO" : "YES");
	}
}


Measured memory_bytes: 102664
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 2e5 + 5;

int n;
int a[N];
unordered_map<int, int> M;

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i], M[a[i]]++;
	if (M.find(1) != M.end()) {
		if (M[1] == 1)
			cout << 1 << endl;
		else
			cout << 0 << endl;
		return 0;
	}
	int res = 0;
	for (auto it : M) {
		if (it.second == 1) {
			bool f = 1;
			for (int i = 2; i * i <= it.first; i++) {
				if (it.first % i == 0 && M.find(i) != M.end()) {
					f = 0;
					break;
				}
				int j = it.first / i;
				if (it.first % j == 0 && M.find(j) != M.end()) {
					f = 0;
					break;
				}
			}
			res += f;
		}
	}
	cout << res << endl;
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n;
  cin >> n;
  int k = 0, g = 0;
  rep(i, 0, n) {
    int a;
    cin >> a;
    if(a % 2) k++;
  }
  if(k % 2) cout << "NO" << endl;
  else cout << "YES" << endl;
}


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

int main(){
  int N,K;
  string S;
  cin >> N >> S >> K;
  char x = S[K-1];
  for(int i=0;i<N;i++){
    if(S[i]==x){
      cout << S[i];
    }else{
      cout << "*";
    }
  }
  cout <<endl;
}

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

using namespace std;

double mem[305][305][305];
int n;
int co[4];

// mem[x][y][z] = (n-(x+y+z))/n * mem[x][y][z] + 7aga;
// mem[x][y][z] - (n-(x+y+z))/n * mem[x][y][z] = 7aga
// (1- (n-(x+y+z))/n) * mem[x][y][z] = 7aga
// (x+y+z)/n * mem[x][y][z] = 7aga
//mem[x][y][z] = 7aga * n /(x+y+z)


double go(int x,int y,int z)
{
	//cout << x << " " << y << " " << z << endl;
	if(x+y+z==0) return 0;
	if(mem[x][y][z]==mem[x][y][z]) return mem[x][y][z];
	mem[x][y][z]=1;
	if(x) mem[x][y][z]+=(x*1.0/n)*go(x-1,y,z);
	if(y) mem[x][y][z]+=(y*1.0/n)*go(x+1,y-1,z);
	if(z) mem[x][y][z]+=(z*1.0/n)*go(x,y+1,z-1);
	mem[x][y][z] *=(1.0*n/(x+y+z+0.0));
	return mem[x][y][z];
}

int main()
{
	cin >> n;
	for(int i=0;i<n;i++)
	{
		int x;
		cin >> x;
		co[x]++;
	}
	memset(mem,-1,sizeof mem);
	cout << fixed << setprecision(12) << go(co[1],co[2],co[3]) << endl;
}

Measured memory_bytes: 221952
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String line = null;
        while ((line = reader.readLine()) != null) {
            if (line.isEmpty()) {
                continue;
            }
            int n = Integer.parseInt(line);
            if (n == 0) {
                break;
            }
            int[][] result = new int[n][n];
            int x = n / 2;
            int y = n / 2 + 1;
            for (int i = 1; i <= n * n; i++) {
                while (true) {
                    if (x >= n) {
                        x = 0;
                        continue;
                    }
                    if (x < 0) {
                        x = n - 1;
                        continue;
                    }
                    if (y >= n) {
                        y = 0;
                        continue;
                    }
                    if (result[y][x] > 0) {
                        x--;
                        y++;
                        continue;
                    }
                    break;
                }
                result[y][x] = i;
                x += 1;
                y += 1;
            }
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    out.print(String.format("%4d", result[i][j]));
                }
                out.println();
            }
        }
    }
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define maxn 100010
using namespace std;
int a[maxn],b[maxn],c[maxn];
int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    for(int i=0;i<n;i++)cin>>c[i];
    sort(a,a+n);
    sort(c,c+n);
    long long ans=0;
    for(int i=0;i<n;i++)
    {
        long long u=lower_bound(a,a+n,b[i])-a;
        long long v=upper_bound(c,c+n,b[i])-c;
        v=n-v;
        ans+=u*v;
    }
    cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 1408
main :: IO ()
main = getContents >>= loop . map (map read . words) . lines
  where loop [] = return ()
        loop (as:bs:rs) = do
          printResult $ solve as bs
          loop rs

        printResult (h, b) = putStrLn $ show h ++ " " ++ show b

solve :: [Int] -> [Int] -> (Int, Int)
solve as bs = foldl f (0, 0) $ zip as bs
  where f hb@(h, b) (ai, bi)
          | ai == bi      = (h + 1, b)
          | bi `elem` as  = (h, b + 1)
          | otherwise     = hb

Measured memory_bytes: 4088
#include <iostream>
#include <vector>
#include <iterator>
#define rep(i, cc, n) for (int i = cc; i < n; ++i)
using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;

    vector<int> fruit(N);

    rep(i, 0, N)
    {
        int p;
        cin >> p;

        fruit[i] = p;
    }

    sort(fruit.begin(), fruit.end());

    int ans = 0;

    rep(i,0,K){
        ans += fruit[i];
    }

    cout << ans << endl;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	int n,m; cin >> n >> m;
	std::vector<int> A(m);

	for (int i = 0; i < n; ++i)
	{
		int k; cin >> k;
		for (int i = 0; i < k; ++i)
		{
			int a; cin >> a;
			A[a - 1]++;
		}
	}

	int ans = 0;
	for (int i = 0; i < m; ++i)
	{
		if(A[i]==n) ans++;
	}

	cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
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; }
const int MOD = 1e9 + 7;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

int main() {
    const int MAX = 10000;
    vector<int> cnt(MAX + 1);
    for (ll x = 1; x <= MAX; x++) {
        for (ll y = 1; y <= MAX ; y++) {
            for (ll z = 1; z <= MAX; z++) {
                ll value = x * x + y * y + z * z + x * y + y * z + z * x;
                if (value > MAX) break;
                cnt[value]++;
            }
        }
    }
    int N;
    cin >> N;
    for (int i = 1; i <= N; i++) {
        cout << cnt[i] << endl;
    }
}


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

#define LL long long
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VVVVI vector<vector<vector<vector<int>>>>
#define VL vector<LL>
#define VVL vector<vector<LL>>
#define VVVL vector<vector<vector<LL>>>
#define VVVVL vector<vector<vector<vector<LL>>>>
#define VB vector<bool>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

template<class T> T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> void print(T x) { std::cout << x << std::endl; }

const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy = { 0, -1, 0, 1 }, dx = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）

using namespace std;

const int MOD = 100000;

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

    int D, N;
    cin >> D >> N;

    vector<int> T(D);
    vector<tuple<int, int, int>> C(N);
    FOR(i, 0, D) {
        cin >> T[i];
    }
    FOR(i, 0, N) {
        int a, b, c;
        cin >> a >> b >> c;
        C[i] = make_tuple(a, b, c);
    }

    VVI dp(D, VI(N, -1));

    FOR(i, 0, N) {
        int a, b, c;
        tie(a, b, c) = C[i];
        if (a <= T[0] and T[0] <= b) {
            dp[0][i] = 0;
        }
    }

    FOR(d, 0, D - 1) {
        FOR(c1, 0, N) {
            if (dp[d][c1] == -1) { continue; }

            // d + 1日目に服c2を着る
            FOR(c2, 0, N) {
                int a, b, c;
                tie(a, b, c) = C[c2];

                if (a <= T[d + 1] and T[d + 1] <= b) {
                    int cost = abs(get<2>(C[c1]) - get<2>(C[c2]));
                    dp[d + 1][c2] = max(dp[d + 1][c2], dp[d][c1] + cost);
                }
            }
        }
    }

    print(MAX(dp[D - 1]));

    return 0;
}


Measured memory_bytes: 3352
#include <iostream>
#include <algorithm>
#include <time.h>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cassert>

using namespace std;

const int N = 100005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

int n,answ;
int a[N];

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=n;i++){
        int st = i;
        while(st <= n && a[st] == st){
            st++;
        }
        int len = st - i;
        answ += len / 2 + len % 2;
        i = st;
    }
    cout<<answ<<endl;
    return 0;
}


Measured memory_bytes: 640
A,B,K=[int(s) for s in input().split()]
if (B-A+1)<=2*K:
  for i in range(A,B+1):
    print(i)
else:
  for i in range(K):
    print(A+i)
  for i in range(K):
    print(B+i-K+1)
  
  


Measured memory_bytes: 3060
N,K=map(int,input().split())
D=list(map(int,input().split()))
def solve():
  for i in range(10*N+2):
    if i>=N:
      s=str(i)
      for j in range(len(s)):
        if int(s[j]) in D: break
      else:
        print(i)
        return 0
 
solve()

Measured memory_bytes: 3060
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

// AOJ 0074
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (true) {
			int h = sc.nextInt(), m = sc.nextInt(), s = sc.nextInt();
			if (h == -1) break;
			int rest = 120 * 60 - (h * 60 * 60 + m * 60 + s);
			int rest3 = rest * 3;
			disp(rest);
			disp(rest3);
		}
	}
	
	public static void disp(int r) {
		int h, m;
		h = r / (60 * 60);
		r -= h * 60 * 60;
		m = r / 60;
		r -= m * 60;
		System.out.printf("%02d:%02d:%02d", h, m, r);
		System.out.println();
	}
}

Measured memory_bytes: 12000
#!/usr/bin/env python3
import sys

def E(N):
    SUM = N*(N+1)/2
    return SUM / N

def solve(N: int, K: int, p: "List[int]"):
    P = [E(val) for val in p]

    group_sum = sum(P[:K])
    memo = [group_sum]

    for n in range(N-K):
        group_sum = group_sum - P[n] + P[n+K]
        memo.append(group_sum)

    print(max(memo))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, p)

if __name__ == '__main__':
    main()


Measured memory_bytes: 35420
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s1,s2;
    int s=0;
    s1="CODEFESTIVAL2016";
    cin>>s2;
    for(int i=0;i<=s1.length();i++)
    if(s1[i]!=s2[i])s++;
    cout<<s<<endl;
    return 0;
} 

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


int main(){
    int n; cin>>n;
    vector<int> a(n);
    int mi=10000000,ma=0;
    rep(i,n){
        cin>>a[i];
        mi=min(mi,a[i]);
        ma=max(ma,a[i]);
    }
    if(ma-mi>=2) cout<<"No";
    else if(ma==mi){
        if(ma==n-1|| ma*2<=n) cout<<"Yes";
        else cout<<"No";
    }
    else{
        int k=0,l;
        rep(i,n) if(a[i]==ma) k++;
        l=n-k;
        if(l<ma&&(ma-l)*2<=k) cout<<"Yes";
        else cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p;
    cin >> x;
    a = 100;
    while(a < x){
        a += a/100;
        sum++;
    }
    cout << sum;

    return 0;
}


Measured memory_bytes: 3600
#include<stdio.h>
#include<string>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    int ans;
    if(b==1){
        ans=0;
    }
    else{
        ans=a-b;
    }
    printf("%d\n",ans);
    return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &A[i]);
  }
  sort(A.begin(), A.end());
  int ans = 0;
  for (int i = 0; i < N; ) {
    int j = i;
    while (j < N and A[i] == A[j]) { ++j; }
    ans += (j - i) & 1;
    i = j;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
const int mod = 1e9 + 7;
int main(){
    int n,m;
    cin >> n >> m;
    int a[m];
    for(int i=0;i<m;i++) cin >> a[i];

    int mcur = 0;
    long dp[n+1] = {};
    dp[0]=1;
    for(int i=1;i<n+1;i++){
        if(mcur < m && i == a[mcur]){
            mcur++;
            continue;
        }
        dp[i] = ((i>0?dp[i-1]:0) + (i>1?dp[i-2]:0)) % mod;
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 1408
n,a,b = [int(x) for x in input().split()]
s = input()
count = 0
b_count = 0
for st in s:
    if (st == 'a') & (count < (a+b)):
        count += 1
        print('Yes')
    elif (st == 'b') & (count < (a+b)) &(b_count < b):
        count += 1
        b_count += 1
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 4016
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

class Edge{
public:
    int from, to, cost;
    Edge(int from = 0, int to = 0, int cost = 0) :
            from(from), to(to), cost(cost){}

    bool operator < (const Edge &e) const{
        return cost < e.cost;
    }
    bool operator >(const Edge &e) const{
        return cost > e.cost;
    }

};

static const int INFTY = (1 << 21);

class Node{
public:
    vector<Edge> edges;
    int dist;
    Node(){
        dist = INFTY;
    }
};

class Graph{
public:
    vector<Node> nodes;
    Graph(int n) {
        rep(i, n) { Node n;  nodes.push_back(n); }
    }
    Node& operator[](int i){
        return nodes[i];
    }
};

class Data{

public:
    int dist;
    Edge *edge;
    Data(int dist, Edge *edge) {
        this->dist = dist;
        this->edge = edge;
    }

    bool operator < (const Data &d) const{
        return dist < d.dist;
    }
    bool operator >(const Data &d) const{
        return dist > d.dist;
    }
};

Graph G(0);
int N;

struct Info{ int idx, dist;};

Info bfs(int start){

    priority_queue<Data, vector<Data>, greater<Data>> q;

    rep(i, N){
        G[i].dist = INFTY;
    }

    Edge e0(-1, start, 0);
    q.push(Data(0, &e0));

    while(!q.empty()){
        Data d = q.top(); q.pop();
        Edge& e = *d.edge;
        Node& n = G[e.to];
        // printf("-- %d %d %d %d ", e.from, e.to, e.cost, n.dist);
        // cout << addressof(e) << endl;

        if(n.dist != INFTY) continue;

        n.dist = d.dist;

/*
        for(vector<Edge>::iterator itr = n.edges.begin(); itr != n.edges.end(); ++itr) {
            Edge& ed = *itr;
            q.push(Data(n.dist + ed.cost, &ed));
            // printf("// %d %d %d %d ", ed.from, ed.to, ed.cost, n.dist);
            // cout << addressof(ed) << endl;
        }
*/

        for(Edge &ed : n.edges) {
            q.push(Data(n.dist + ed.cost, &ed));
        }

    }

    int dist = -1;
    int idx = -1;
    rep(i, N){
        if(G[i].dist > dist){
            dist = G[i].dist;
            idx = i;
        }
    }

    Info info;
    info.idx = idx; info.dist = dist;
    // printf("%d %d\n", idx, dist);
    return info;

}

int main() {
    cin >> N;
    G = Graph(N);
    rep(i, N-1){
        int from, to, cost;
        cin >> from >> to >> cost;
        G[from].edges.push_back(Edge(from, to, cost));
        G[to].edges.push_back(Edge(to, from, cost));
// printf("++ %d %d %d\n", from, to, cost);
    }

    Info info = bfs(0);
    info = bfs(info.idx);

    cout << info.dist << endl;
}

Measured memory_bytes: 11660
#pragma warning(disable: 4996)
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;


int N, M, K;
int main() {
	cin >> N >> M >> K;
	
	int m = max( max(N, M), K);
	cout << N + M + K - m;

	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;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 repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	string ans="";
	cin >>n;
	switch(n%10){
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
		ans="hon";
		break;
		case 3:
		ans="bon";
		break;
		default:
		ans="pon";
		break;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/

int n, m, s, t;
vector<int>G[114514];
void bfs() {
	queue<P>que;
	int far[333333];
	fill(far, far + n * 3, -1);
	far[s] = 0; que.push({ s, 0 });
	while (!que.empty()) {
		P p = que.front(); que.pop();
		rep(i, G[p.first].size()) {
			if (far[G[p.first][i] + n * ((p.second + 1) % 3)] == -1) {
				far[G[p.first][i] + n * ((p.second + 1) % 3)] = far[p.first + p.second * n] + 1;
				que.push({ G[p.first][i],(p.second + 1) % 3 });
			}
		}
	}
	if (far[t] != -1)cout << far[t] / 3 << endl;
	else cout << -1 << endl;
}
signed main() {
	cin >> n >> m;
	rep(i, m) {
		int a, b; cin >> a >> b;
		G[a - 1].push_back(b - 1);
	}
	cin >> s >> t; s--; t--;
	bfs();
}

Measured memory_bytes: 8448
#include <iostream>

using namespace std;
int F[100];
int main() {
	int n;
	cin >> n;
	F[0] = 1;
	F[1] = 1;
	for (int i=2; i<=n; ++i) {
		F[i] = F[i-2] + F[i-1];
	}
	cout << F[n] << endl;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

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; }
constexpr int INF = 1001001001;
constexpr long long INFL = (1LL<<60);
constexpr double eps = (1e-9);

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

  int n, x, t;
  cin >> n >> x >> t;

  cout << ((n + x - 1) / x) * t << endl;

  return 0;
}


Measured memory_bytes: 3644