akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;
using ll = long long ;

const double pi=3.14159265358979323846;

int main() {

    int a,b,h,m ; 
    cin >> a >> b >> h >> m  ;

    double hour = 0.5 ;
    double n = 30*h+hour*m ;
    //cout << n << endl ;
    double min = 6.0*m ;
    //cout << min << endl ;
    double ans = abs(n-min) ;
    //cout << ans << endl ;

    if(ans>180) ans = 360-ans ;
    //cout << ans << endl ;

    double l ; 
    l = a*a + b*b -2*b*a*cos(pi*ans/180.0) ;

    cout << setprecision(15) << fixed << sqrt(l) << endl ;


  return 0 ;
}

Measured memory_bytes: 4196
import math as M
k = int(input())
a, b = map(int, input().split())

a_1 = M.floor(a/k)
b_1 = M.floor(b/k)

if a%k == 0 or b%k == 0:
    print('OK')
elif b_1 - a_1 < 1:
    print('NG')

else :
    print('OK')

Measured memory_bytes: 9168
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n, k, c;
  cin>>n>>k>>c;
  string s;
  cin>>s;
  
  int l[k], r[k];
  int now = 0;
  int i = 0;
  while(i < n){
    if(s[i] == 'x'){
      i++;
      continue;
    }
    if(now == k) break;
    l[now] = i;
    now++;
    i += c + 1;
  }
  i = n - 1;
  now = k - 1;
  while(i >= 0){
    if(s[i] == 'x'){
      i--;
      continue;
    }
    if(now < 0) break;
    r[now] = i;
    now--;
    i -= c + 1;
  }
  
  vector<int> ans;
  REP(i, k) if(l[i] == r[i]) ans.push_back(l[i] + 1);
  for(int& x: ans) cout << x << endl;
  return 0;
}


Measured memory_bytes: 5896
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}



///////////////////////////

ll keta(ll n) {
	ll ret = 0;
	while (n > 0) {
		n /= 10;
		ret++;
	}
	return ret;
}


ll p(ll n) {
	if (n == 0) { return 1; }
	return 10 * p(n - 1);
}

ll count(ll n, ll a, ll b) {
	ll ret = 0;

	repn(i, keta(n)) {
		if (i == 1) {
			if (a == b && a <= n) { ret++;}
			continue;
		}

		ll x = a * p(i - 1) + b;

		if (x > n) { continue; }
		else { ret += min(p(i - 2), (n - x) / 10 + 1); }

	}

	return ret;
}

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

	ll ans = 0;

	repn(a, 9)repn(b, 9) {
		ans += count(N, a, b) * count(N, b, a);
	}

	cout << ans;
	
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int N, K;
	long long ans, t;
	scanf("%d %d", &N, &K);

	t = N / K;
	ans = t * t * t;
	if (!(K & 1)) {
		t = N / (K / 2) - t;
		ans += t * t * t;
	}

	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
int siz[100010];
int par[100010];
int depth[100010];
void init(int n){
  for(int i=0;i<=n;i++){
      par[i]=i;
      depth[i]=0;
  }
  rep(i,n+1){
      siz[i]=1;
  }
}
int root(int x){
  return par[x]==x?x:par[x]=root(par[x]);
}
bool same(int x,int y){
  return root(x)==root(y);
}
void unite(int x,int y){
  x=root(x);
  y=root(y);
  ll sx=siz[x];
  ll sy=siz[y];
  if(x==y)return;
  if(depth[x]<depth[y]){
      par[x]=y;
  }else{
      par[y]=x;
      if(depth[x]==depth[y])depth[x]++;
  }
  siz[root(x)]=sx+sy;
}
signed main(){
    ll n;cin>>n;
    init(n);
    vector<pll>p(n);
    vector<pll>pp(n);
    rep(i,n){
        ll a;cin>>a;
        p[i].se=a;
    }
    rep(i,n){
        ll b;cin>>b;
        p[i].fi=b;
    }
    sort(all(p));
    rep(i,n){
        pp[i].fi=p[i].se;
        pp[i].se=i;
    }
    sort(all(pp));
    bool f=1;
    rep(i,n){
        if(p[i].fi<pp[i].fi)f=0;
    }
    if(!f){
        cout<<"No"<<endl;
        return 0;
    }
    bool b=0;
    rep(i,n){
        if(i){
            if(p[i-1].fi>=pp[i].fi)b=1;
        }
    }
    rep(i,n){
        unite(pp[i].se+1,i+1);
    }
    if(siz[root(1)]<n-1)b=1;
    if(b){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

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

template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}

namespace {
  const int mo = 1e9 + 7;
  inline int add(int x, int y) {
    if((x += y) >= mo) x -= mo;
    return x;
  }
  inline int sub(int x, int y) {
    if((x -= y) < 0) x += mo;
    return x;
  }
  inline int mul(int x, int y) {
    return 1LL * x * y % mo;
  }
  inline int pw(int a, int k, int mo) {
    int ans = 1;
    for (; k; k >>= 1, a = mul(a, a))
      if (k & 1) ans = mul(ans, a);
    return ans;
  }
}
const int N = 3e5 + 233;
int n, m, K, ans = 1;
int fac[N], ifac[N];
int dfn[N], dfs_clock = 0;
int cnt = 0, sz[N], pre[N], fa[N], col[N], cir[N];
vector<int> g[N];

inline int find(int x) {
  return x == pre[x] ? x : pre[x] = find(pre[x]);
}

inline void init(void) {
  fac[0] = 1;
  for (int i = 1; i <= N - 1; i ++)
    fac[i] = mul(fac[i - 1], i);
  ifac[N - 1] = pw(fac[N - 1], mo - 2, mo);
  for (int i = N - 2; i >= 0; i --)
    ifac[i] = mul(ifac[i + 1], i + 1);         
}

inline int C(int n, int m) {
  if (n < 0) return 0;
  else if (n == m || m == 0) return 1;
  else return mul(fac[n], mul(ifac[m], ifac[n - m]));
}

inline int polya(int n) {
  int ans = 0;
  for (int i = 1; i <= n; i ++)
    ans = add(ans, pw(K, __gcd(i, n), mo));
  ans = mul(ans, pw(n, mo - 2, mo));
  return ans;
}

inline void dfs(int u, int fat) {
  dfn[u] = ++ dfs_clock; fa[u] = fat;
  for (auto v : g[u]) if (v != fat) {
      if (!dfn[v]) {
        dfs(v, u);
      } else {
        if (dfn[v] > dfn[u]) continue;
        ++ cnt; sz[cnt] = 1; pre[cnt] = cnt;
        for (int t = u; t != v; t = fa[t]) {
          if (col[t]) {
            int fx = find(col[t]);
            int fy = find(cnt);
            if (fx != fy) {
              pre[fx] = fy;
              sz[fy] += sz[fx];
            }
          } else {
            col[t] = cnt;
            sz[cnt] ++;
          }
        }
      }
    }
}

main(void) {
  init();
  read(n); read(m); read(K);
  for (int i = 1; i <= m; i ++) {
    int x, y; read(x); read(y);
    g[x].push_back(y); g[y].push_back(x);
  }
  for (int i = 1; i <= n; i ++)
    if (!dfn[i]) dfs(i, 0), col[i] = -1;
  for (int i = 1; i <= cnt; i ++)
    ++ cir[find(i)];
  for (int i = 1; i <= n; i ++)
    if (!col[i]) ans = mul(ans, K);
  for (int i = 1; i <= cnt; i ++) if (pre[i] == i) {
      if (cir[i] >= 2) ans = mul(ans, C(sz[i] + K - 1, K - 1));
      else ans = mul(ans, polya(sz[i]));
    }
  cout << ans << "\n";
}


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

int main(void)
{
	char moji[101] = { 0 };
	int count[26] = { 0 };
	int i;
	int t=0;
	int n;
	int no = 0;


	scanf("%s", moji);
	n = strlen(moji);

	for (i = 0;i < n;i++)
	{
		t = moji[i] - 'a';
		if (t >= 0 && t < 26)
		{
			count[t] = count[t] + 1;
		}
	}

	for (t = 0;t < 26;t++)
	{
		if ((count[t] % 2) != 0)
		{
			no = no + 1;
		}
	}

	if (no == 0)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}


}

Measured memory_bytes: 1728
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)

typedef long long ll;

const ll INFL = 1e18;

ll hs[16];

void solve(void){
    int N, K;
    cin >> N >> K;
    vector <ll> v(N);
    rep(N, i) cin >> v.at(i);
    int cnt = 1;
    while (cnt < N && v[cnt-1] < v[cnt]) cnt++;
    K -= cnt;
    N -= cnt;
    if (K <= 0) {
        cout << 0 << endl;
        return;
    }
    ll ans = INFL;
    rep((1<<N), n) {
        if (bitcnt(n) != K) continue;
        ll cost = 0LL, h = v[cnt-1];
        rep(N, i) {
            if (n >> i & 1) {
                if (v[cnt+i] <= h) {
                    h++;
                    cost += h - v[i+cnt];
                }
                else {
                    h = v[cnt+i];
                }
            }
            else h = max(h, v[cnt+i]);
        }
        ans = min(ans, cost);
    }
    cout << ans << endl;
}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}


Measured memory_bytes: 256
// JOI - Prelim  0513
// カードの並び替え
#include <bits/stdc++.h>

using namespace std;

template <typename T>
using vec1 = vector<T>;

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

template <typename T>
vec1<T> cin2vec(size_t size)
{
    vec1<T> vec1(size);
    for (auto& v : vec1) {
        v = cin2var<T>();
    }
    return vec1;
}

void cut(int64_t k, deque<int64_t>& cards)
{
    for (auto i = 0; i < k; ++i) {
        const auto& c = cards.front();
        cards.push_back(c);
        cards.pop_front();
    }
}

void ri_full_shuffle(int64_t n, deque<int64_t>& cards)
{
    auto iteA(cards.cbegin());
    auto iteB(next(iteA, n));

    deque<int64_t> new_cards;
    while (iteB != cards.cend()) {
        new_cards.push_back(*iteA++);
        new_cards.push_back(*iteB++);
    }
    swap(cards, new_cards);
}

void sub()
{
    const auto N(cin2var<size_t>());
    const auto M(cin2var<size_t>());
    const auto Ms(cin2vec<int64_t>(M));

    deque<int64_t> cards;
    for (size_t i = 0; i < N * 2; ++i) {
        cards.push_back(i + 1);
    }
    for (const auto& m : Ms) {
        if (m) {
            cut(m, cards);
        }
        else {
            ri_full_shuffle(N, cards);
        }
    }
    for (const auto& n : cards) {
        cout << n << endl;
    }
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    sub();
    return 0;
}


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

int main(){
  vector<int> vec(3);
  for(int i=0;i<3;i++)
  cin >> vec.at(i);
  sort(vec.begin(),vec.end());
  int dif;
  dif=vec.at(2)*10+vec.at(1)+vec.at(0);
  cout << dif << endl;
}
 
  

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

#define MAX 100005
#define NINF INT_MIN
using namespace std;

bitset<MAX> inicios, visitado;

map<int, int> grafo[MAX];
stack<int> pilha;
int dist[MAX];

void toposort(int nodo){
    visitado[nodo] = 1;
    
    for(auto u: grafo[nodo]){
        if (visitado[u.first] == 0)
            toposort(u.first);
    
    }
    
    pilha.push(nodo);
}


int longestPath(int n){

    for(int v=1; v<=n; v++){
        if(visitado[v] == 0)
            toposort(v);
            
        if(inicios[v] == 1)
            dist[v] = 0;
    }
    
    while(!pilha.empty()){
        int u = pilha.top();
        pilha.pop();
        
        for(auto v: grafo[u]){
            dist[v.first] = max(dist[u] + grafo[u][v.first], dist[v.first]);
            
        }
    }
    
    int m = 0;
    for(int a: dist){
        m = max(m, a);
    }
    return m;
}


int main(){
    
    int n,m;
    
    inicios.set();
    visitado.reset();
    
    cin >> n >> m;
    
    for(int i=0; i<n; i++)
        dist[i] = NINF;
    
    for (int i=0; i<m; i++){
        int a,b;
        cin >> a >> b;
        grafo[a][b] = 1;
        inicios[b] = 0;
    }
    
    cout << longestPath(n) << endl;

}

Measured memory_bytes: 13184
# coding: utf-8
# Your code here!

def MI():return map(int,input().split())
def LI():return list(MI())

n=int(input())

import math
from collections import Counter

# def gcd(*numbers):
    # return reduce(math.gcd, numbers)

ans=0
t=[]
for i in range(1,n+1):
    for j in range(1,n+1):
        t.append(math.gcd(i,j))
        
c=Counter(t).items()

for (i,j) in c:
    for k in range(1,n+1):
        ans+=math.gcd(i,k)*j
        # p\rint(c)
print(ans)

Measured memory_bytes: 9776
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int a,b,c;
    while(cin>>a>>b>>c){
        int cnt=0,rslt=a;
        while(cnt<c && rslt<=b){
            rslt+=a;
            cnt++;
        }
        cout<<cnt<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    vector<int> ans(n,INT_MAX);
    ans[0]=0;
    for(int i=1;i<n;i++)
    {
        ans[i]=min(ans[i],ans[i-1]+abs(a[i]-a[i-1]));
        if(i-2>=0)
            ans[i]=min(ans[i],ans[i-2]+abs(a[i]-a[i-2]));
        
    }
    cout<<ans[n-1];
    return 0;
}


Measured memory_bytes: 4060
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
 
int main(void) {
    int N,ans;
    cin >> N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    for(int i=0;i<N;i++){
        if(i%2==0){
            ans += a[i];
        }else{
            ans -= a[i];
        }
    }
    cout << ans << endl;
}

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

int main(){
    ll n; cin >> n;
    vector<ll> l(n);
    rep(i, 0, n) cin >> l[i];
    sort(l.begin(), l.end());
    if(l[n-1] < accumulate(l.begin(), l.end()-1, 0)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,h,h1,c=0;
  cin>>n>>h;
  for(int i=0;i<n;i++)
  {
    cin>>h1;
    if(h1>=h)
    {
      c++;
    }
  }
  cout<<c;
  return 0;
}

Measured memory_bytes: 256
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:usize x:i64)(list:[i64]));
    let list = list.into_iter().map(|i| (i - x).abs()).collect::<Vec<_>>();
    let mut res = list[0];
    for x in list {
        res = gcd(std::cmp::max(res, x), std::cmp::min(res, x));
    }
    res.to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

tests! {
    test1: "3 3\n1 7 11" => "2",
    test2: "3 81\n33 105 57" => "24",
    test3: "1 1\n1000000000" => "999999999",
}


Measured memory_bytes: 10492
/*
 * Pawan Harendra Mishra
 */

/*
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
*/

/*
 * Windows Powershell
 * Get-Content input.txt | ./a.exe > output.txt
 */

#include <bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define mod 1000000007
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define N 100001

ll n;
vector<pll> e[N];
bool visited[N];
ll color[N];

void dfs(ll u) {
    if (!visited[u]) {
        visited[u]=true;
        for (ll i=0; i<e[u].size(); i++) {
            if (e[u][i].Y%2==0) {
                color[e[u][i].X] = color[u];
            }
            else color[e[u][i].X] = color[u]==1?0:1;
            dfs(e[u][i].X);
        }
    }
}

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

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // //freopen("output.txt", "w", stdout);
    // #else
    // // online submission
    // #endif
    
    cin >> n;
    ll u, v, w;
    for (ll i=1; i<n; i++) {
        cin >> u >> v >> w;
        e[u].push_back(pll(v,w));
        e[v].push_back(pll(u,w));
    }

    // cout << endl;
    // for (ll i=1; i<=n; i++) {
    //     cout << i << " -> ";
    //     for (ll j=0; j<e[i].size(); j++) cout << e[i][j].X << '-' << e[i][j].Y << ' ';
    //     cout << endl; 
    // }
    // cout << endl;

    memset(color, -1, sizeof(color));
    memset(visited, false, sizeof(visited));
    color[1] = 0;
    dfs(1);
    for (ll i=1; i<=n; i++) cout << color[i] << endl;
    return 0;
}

Measured memory_bytes: 10368
#include<cmath>
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<bitset>
#define int long long
using namespace std;
const int maxn=100005,mod=1e9+7;
string a;
inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')
			f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
inline void write(int a)
{
	if(a<0)
	{
		putchar('-');
		write(-a);
	}
	else
	{
		if(a>=10)
			write(a/10);
		putchar(a%10+'0');
	}
}
signed main()
{
	cin>>a;
	if(a[0]==a[1]&&a[1]==a[2])
		puts("No");
	else
		puts("Yes");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    int K = sc.nextInt();
    char[][] a = new char[H][W];
    boolean[][] b = new boolean[H][W];
    // Arrays.fill(b, true);
    for (int i=0; i < H; i++) {
      String tmp = sc.next();
      for (int j=0; j < W; j++) {
        a[i][j] = tmp.charAt(j);
        b[i][j] = true;
      }
    }
    int ans = 0;
    for(int i=0; i <Math.pow(2,(H+W));i++){
      int count = 0;
      for(int j=0; j<H; j++){
        if((1&i>>j)==1){
          for(int k=0; k<W; k++){
            b[j][k] = false;
          }
        }
      }
      for(int j=H; j<H+W; j++){
        if((1&i>>j)==1){
          for(int k=0; k<H; k++){
            b[k][j-H] = false;
          }
        }
      }
      for (int i1=0; i1 < H; i1++) {
        for (int j1=0; j1 < W; j1++) {
          if(a[i1][j1] == '#' && b[i1][j1]==true){
              count++;
          }
          b[i1][j1] = true;
        }
      }
      if(count==K){
        ans++;
      }
      // Arrays.fill(b, true);
      // System.out.println("b");

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



Measured memory_bytes: 37420
using System;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var five = 0;
        var seven = 0;
        foreach(var str in input)
        {
            if (str=="5") five++;
            if (str == "7") seven++;
        }
        var result = five == 2 && seven == 1 ? "YES" : "NO";
        Console.WriteLine(result);
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;

using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
#define endl        	"\n"
#define int         	long long int  
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007



const int N = 200005;

int vis[N];

void solve()
{
	ll n,k;
	
	cin>>n>>k;
	
	int a[n+1];
	
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	
	ll tot = 1;
	
	vis[1] = 1;
	
	int id = 1;
	
	while(vis[a[id]] == 0)
	{
		id = a[id];
		
		vis[id] = 1;
		
		tot++;
	}
	
	if(k < tot)
	{
		
		fill(vis,0);
		
		vis[1] = 1;
	
		id = 1;
		
		k--;
		
		while(vis[a[id]] == 0)
		{
			if(k == 0)	
			{
				cout<<a[id];
				return;
			}
			
			id = a[id];
			
			vis[id] = 1;
			
			k--;
		}
	}
	else
	{
		fill(vis,0);
		
		vis[1] = 1;
	
		id = 1;
		
		while(vis[a[id]] == 0)
		{
			id = a[id];
			
			vis[id] = 1;
		}
		
		fill(vis,0);
		
		id = a[id];
		
		vis[id] = 1;
		
		vector<int> seq;
		
		seq.pb(id);
		
		while(vis[a[id]] == 0)
		{
			id = a[id];
			
			vis[id] = 1;
			
			seq.pb(id);
		}
		
		k = k - tot + seq.size();
		
		cout<<seq[k%seq.size()];
		
		return;
	}
}


signed main()
{
 
    fast;
 
    ll t;
    
    t=1;
    
    //cin>>t;
    
    while(t--)
    {
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 8384
#include<bits/stdc++.h>
using namespace std;
signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  if(a-b<0){
    cout<<"0\n";
  }else{
    cout<<a-b<<"\n";
  }
}


Measured memory_bytes: 256
fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun main(args: Array<String>) {
    val (n, m) = intList()
    val map = hashMapOf<Int, Int>()
    repeat(n) {
        intList().drop(1).forEach { i ->
            map[i] = map[i]?.let { it + 1 } ?: 1
        }
    }
    println(map.values.count { it == n }.toString())
}

Measured memory_bytes: 38124
# coding: utf-8

# In[1]:


N=int(input())


# In[2]:


T,A = map(int,input().split())


# In[3]:


HList = list(map(int,input().split()))


# In[4]:


BestPoint = 0
SaishoSabun=100000000

for i in range(N):
    aaa = T - HList[i] * 0.006
    Sabun = abs(A - aaa)
    
    if SaishoSabun > Sabun:
        BestPoint = i
        SaishoSabun = Sabun

print(BestPoint+1)



Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) for(auto x:obj)cout<<x<<' ';cout<<endl;
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N;
	ll ans = 0LL;
	cin>>N;
	vector<ll> in(3*N);
	rep(i,3*N)cin>>in[i];
	sort(all(in));
	for(int i = 1; i<=N; ++i){
		ans += in[3*N-i*2];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int n = s.length();
        String x = "";
        for(int i = 0; i<n ; i++){
            x = x + "x";
        }
        System.out.println(x);

    }
}
    

Measured memory_bytes: 21716
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <utility>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto&e:c)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif
template<class T> ostream& operator<<(ostream& os, vector<T> const& v){
    rep(i,v.size()) os << v[i] << (i+1==v.size()?"":" ");
    return os;
}


int main() {
    int n,r;
    while (cin >> r >> n && r) {
        int mh_[50]={};
        auto mh = mh_+25;
        rep(i,n){
            int xl, xr, h;
            cin >> xl >> xr >> h;
            loop(j,xl,xr) mh[j] = max(mh[j], h);
        }
        double ans = 1e200;
        loop(x,-r,r){
            double dx = x;
            if(x<0) dx++;
            double dy = r-sqrt(r*r-dx*dx);
            ans = min(ans, mh[x]+dy);
        }
        printf("%.4lf\n", ans);
    }
}

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

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

    bool c=true;
    for(int i=0;i<N;i++){
        if(A[i]%2==0){
            if(A[i]%3==0 || A[i]%5==0) continue;
            else c=false;
        }
    }
    if(c==false){
        cout << "DENIED" << endl;
    }
    else cout << "APPROVED" << endl;
    
    return 0;

}

Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e2+50;
const int mod=1e9+7;
using namespace std;
ll x,y;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>x>>y;
	cout<<x*y/__gcd(x,y)<<endl;
	return 0;
}


Measured memory_bytes: 256
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let N = read int64
    let AS = reads int64

    let negs =
        List.filter (fun x -> x < 0L) AS
        |> List.length

    if negs % 2 = 0 then
        printfn "%i" (List.sumBy abs AS)
    else
        let x :: xs =
            List.map abs AS
            |> List.sort
        printfn "%i" (List.sum xs - x)
    0

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<int> arr(n);
	for(int& x : arr) cin >> x;
	bool ok = true;
	for(int x : arr)
		if(x % 2 == 0)
			ok &= x % 3 == 0 || x % 5 == 0;
	
	cout << (ok ? "APPROVED" : "DENIED") << endl;
}


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

ll power(ll a, ll b){
    ll result=1;
    while(b>0){
        if((b&1)==1){
            result=result*a;
        }
        a=a*a;
        b=b>>1;
    }
    return result;
}
void solve(){
    ll k;
    cin>>k;
    string s="";
    while((k--)>0){
        s+="ACL";
    }
    cout<<s;
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
     
    solve();
}


Measured memory_bytes: 3656
#include <iostream>
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
long long dp[1<<13][1005];
vector < int >vec;
int  c[1005];
int  n,m;
bool ones(int mask){
    if(mask+1==1<<(n))return true;
    return false;
}
int updatemask(int mask , int a){
    int p=mask;
    mask=mask|vec[a];
  if(mask==p)return -1;
  return mask;
}
long long solve(int a , int mask){
   if(a==m){
    if(ones(mask))return 0;
    return 10000000000;
   }
   if(dp[mask][a]!=0)return dp[mask][a];
   long long x=solve(a+1,mask);
   int maskupdate=updatemask(mask,a);
   if(maskupdate==-1)return dp[mask][a]= x;
   return dp[mask][a]=min( c[a]+solve(a+1,maskupdate), x);

}
int main()
{
   // cin>>n>>m;
           int k;
           int o;
   scanf("%d %d",&n,&m);
    vec.resize(m);
    for(int i=0;i<m;i++){
        //cin>>c[i];
        scanf("%d",&c[i]);
        //cin>>k;
        scanf("%d",&k);
        int y=0;
        for(int j=0;j<k;j++){
           // cin>>o;
           scanf("%d",&o);
           y=y|(1<<(o-1));
        }
        vec[i]=y;
    }
    long long ans=solve(0,0);
    if(ans>=10000000000)cout<<-1;
    else cout<<ans;
    return 0;
}


Measured memory_bytes: 33024
/*
    ALWAYS REMMEMBER:
        NEVER GIVE UP !
        DON'T MESS WITH ME !!!
        "" THE EXPERT IN ANYTHING WAS ONCE A BEGINNER ""
*/

#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e7+5,INF=1e18;

void solve()
{
    ll n;
    cin >> n;
    vll a(n);
    bool is=true;

    f(i,0,n-1)
        cin >> a[i];
    
    f(i,0,n-1)
    {
        if(a[i]%2==0)
        {
            if(a[i]%3!=0 && a[i]%5!=0)
                is=false;
        }
    }

    if(is)
        cout << "APPROVED";
    else 
        cout << "DENIED" ;
}

int32_t main()
{
    FIO
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int a , b, c;
 /* ????????°a ?????¢?????¬?????????????????¢?????¨?????¢?????\?????????????????´??°????????????????´???????????????????????????????*/
      scanf("%d %d %d", &a ,&b, &c);
    if (a < b && b < c)
      {
        printf("Yes\n");}
      else  
        {
          printf("No\n");
    };
    return 0;
}

Measured memory_bytes: 1012
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,X; cin >> N >> X;
    int bounceCount = 0;
    int AddToBounce = 0;
    for(int i=0; i<=N; i++){
        if(i == 0) continue;
        else{
        int temp; cin>> temp;
        if(i == 0){
            AddToBounce += 0;
        }else{
            AddToBounce += temp;
        }
        if(AddToBounce <= X) bounceCount++;
        }
    }
    cout << bounceCount + 1 << endl;
}




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

int main(){
  int a,b;
  cin>>a>>b;
  if(a>8 or b>8)cout<<":("<<endl;
  else cout<<"Yay!"<<endl;
  
  return 0;
}

Measured memory_bytes: 3564
n,i,j,u,v=1,a[2][3];long dp[25000005];solve(){for(i=n;i;)dp[i]=i--;for(;i<=n;++i)for(j=0;j<3;++j)a[v][j]>a[u][j]&&i>=a[u][j]&&(dp[i]=fmax(dp[i],dp[i-a[u][j]]+a[v][j]));}main(){for(scanf("%d",&n);i<2;i++)for(j=0;j<3;)scanf("%d",a[i]+j++);solve(),n=dp[n],u=1,v=0,solve();printf("%lld\n",dp[n]);}

Measured memory_bytes: 195456
#include <bits/stdc++.h>
using namespace std;
int main() {
long long counter=0;
long long n;
cin>>n;
long long b[n+2]={};
long long a[n+2]={};
long long c[n+2]={};
long long d[n]={};
for(long long i=0; i<n; i++){
cin>>a[i+1];}
for(long long i=0; i<n; i++){
b[i]=abs(a[i+1]-a[i]);
c[i]=abs(a[i+2]-a[i]);
counter+=b[i];}
b[n]=abs(a[n]);
counter+=b[n];
for(long long i=0; i<n; i++){
cout<<counter+c[i]-b[i]-b[i+1]<<endl;}
}


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

typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end(),greater<ll>());
    bool s=false;
    bool t=false;
    ll ans1=0;
    ll ans2=0;
    ll ans=0;
    for(int i=0;i<n;i++){
        if(s==true&&t==true){
            s=false;
            t=false;
        }
        if(a[i]==a[i+1]&&s==false){
            s=true;
            ans1=a[i];
            i++;
            continue;
        }else if(a[i]==a[i+1]&&s==true){
            t=true;
            ans2=a[i];
            i++;
        }
        ans=max(ans,ans1*ans2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
typedef long long ll;

ll n;
ll a[105];
ll ans;

int main()
{
    scanf("%lld", &n);
    for (ll i = 1; i <= n; i++) {
        scanf("%lld", &a[i]);
    }

    ll i, j;
    i = 1;
    while (i <= n) {
        j = 1;
        while (a[j + i] == a[j + i - 1]) {
            j++;
        }

        ans += j / 2;
        i += j;
    }

    printf("%lld\n", ans);

    return 0;
}


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

template <typename T>
inline T read(){
	T x=0,f=1;char c=getchar();
	while(!isdigit(c)){	if(c=='-') f=-f;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint
#define readint read<int>()
#define readlint read<lint>()
const int inf=1e9+1e7,MAXN=2e5+1e1;
const double eps=1e-10;

struct Node{
	int w2,w5,p;
};

Node a[MAXN<<1];
int b[3100][3100],n;
lint ans=0;

void Read(int id){
	int x=0,f=1,X=0,F=1,cnt=0;char c=getchar();
	while(!isdigit(c)){	if(c=='-') f=-f;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	if(c=='.'){
		while(!isdigit(c)){	if(c=='-') F=-F;c=getchar();}
		while(isdigit(c)){X=(X<<3)+(X<<1)+(c-48);++cnt;c=getchar();}
	}
	lint k3=X*F;
	if(k3==0) cnt=0;
	while((k3) && (k3%10==0)) k3/=10,--cnt;
	lint k1=x*f;
	a[id].p=cnt;
	while(cnt--) k1*=10;
	lint k2=k1+k3;
	while((k2) && (k2%2==0)) ++a[id].w2,k2/=2;
	while((k2) && (k2%5==0)) ++a[id].w5,k2/=5;
	return;
}

int main(void){

	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);

	scanf("%d",&n);
	for(int i=1;i<=n;i++) Read(i);
	// for(int i=1;i<=n;i++) printf("%d %d %d\n",a[i].w2,a[i].w5,a[i].p);
	for(int i=1;i<=n;i++){
		lint res=0;
		int w2=a[i].w2,w5=a[i].w5,p=a[i].p;
		for(int j=0;j<=w2-p+48;j++) for(int k=0;k<=w5-p+48;k++) res+=b[j][k];
		++b[p-w2+48][p-w5+48];
		ans+=res;
		// printf("%lld ",res);
		// printf("%d %d\n",max(a[i].p-a[i].w2,0),max(a[i].p-a[i].w5,0));
	}
	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 6228
#include <stdio.h>
#include <math.h>

void ToiB(void);

int main(void)
{   
    ToiB();
    return 0;
}

void ToiB(void){
    int N; scanf("%d", &N);
    int max;
    int a;
    for(int i = N; N > 0; i--){
        a = (int)sqrt((double)i);
        if(a*a == i){
            max = i;
            break;
        }

    }

    printf("%d", max);
}

Measured memory_bytes: 128
def apply(a,b):
  if a>b:
    return (a, a-1, b)
  else:
    return (b, a, b-1)

if __name__ == '__main__':
  a,b = map(int,input().split())
  res = 0
  tmp, a, b = apply(a,b)
  res += tmp
  tmp, a, b = apply(a,b)
  res += tmp
  print(res)

Measured memory_bytes: 3064
n = int(input())
Taro = 0
Hanako = 0

for i in range(n):
    t,h = input().split()
    if t == h:
        Hanako += 1
        Taro += 1
    elif t> h:
        Taro += 3
    else:
         Hanako += 3
print("{} {}".format(Taro,Hanako))

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

int main(){
  int A,B,C,D,E,F;
  cin >> A >> B >> C >> D >> E >> F;
  
  int w,s;
  int ans_ws = 0;
  int ans_s = 0;
  
  for(int a=0;100*A*a<=F;a++){
    for(int b=0;100*A*a+100*B*b<=F;b++){
      for(int c=0;100*A*a+100*B*b+C*c<=F;c++){
        for(int d=0;100*A*a+100*B*b+C*c+D*d<=F;d++){
          w = 100*A*a + 100*B*b;
          s = C*c + D*d;
          if(E*w >= s*100 && s*ans_ws >= (w+s)*ans_s){
            ans_ws = w + s;
            ans_s = s; 
          }
        }
      }
    }
  }
  
  cout << ans_ws << " " << ans_s << "\n"; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;

void solve(){
	lli n;
	cin >> n;
	lli summ = 0;
	for(int i = 1;i <= n;++i){
		summ = summ + (lli)i * (n / i) * (n / i + 1) / 2;
	}
	cout << summ << newl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


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

food = list(range(1, m+1))

for _ in range(n):
    A = list(map(int, input().split()))
    A.pop(0)
    for i in range(1, 31):
        if not i in A and i in food:
            food.remove(i)

print(len(food))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  string S; cin>>S;
  int s=0,t=0;
  rep(i,0,S.size()){
    if(S[i]=='S')
      s++;
    else{
      if(s==0)
        t++;
      else 
        s--;
    }
  }
  cout<<t*2<<endl;
  }



Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<vector>
using namespace std;
#define read freopen("in.in","r",stdin)
#define write freopen("out.out","w",stdout)
#define FastIO ios::sync_with_stdio(0)
#define Mod 1000000007
typedef long long ll;
int dp[100005];
int main() {
	FastIO;
#ifndef ONLINE_JUDGE
	//write; read;
#endif 
	int n, W; cin >> n >> W;
	int sol = 0;
	for (int i = 0; i < 100005; i++)
		dp[i] = Mod;
	dp[0] = 0;
	for (int i = 0; i < n; i++)
	{
		int val, w; cin >> w >> val;
		for (int j = 100000; j >= val; j--) {
			dp[j] = min(dp[j], dp[j - val] + w);
			if (dp[j] <=W)sol = max(sol, j);
		}

	}
	cout << sol << endl;
	return 0;
}

Measured memory_bytes: 640
import java.io.InputStream;
import java.util.Scanner;

public class Main {


	public static void main(String args[]) {
        InputStream inputStream = System.in;
        Scanner sc = new Scanner(inputStream);
        String out;
        int A = sc.nextInt();
        boolean flag=true;
        int check=0;
        int j=0;
        int[] N=new int[A];
        for(int i=0;i<A;i++) {
        	 N[i]=sc.nextInt();
        }
        while(flag==true) {
        	if(N[j]%2==0) {N[j]/=2;check++;}
        	else {j++;if(j>=A) {flag=false;}}

        }
        System.out.print(check);
	}

}


Measured memory_bytes: 34136
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
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};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int n, b, c;
int a[10000];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> b>>c;
	if(b<=9&&c<=9){
      cout<<b*c<<"\n";
      return 0;
    }
    cout << -1 << "\n";
}



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

int main() {
  char Q;
  cin>>Q;
  if(Q=='A'){
    cout<<'T'<<endl;
  }
  else if(Q=='T'){
    cout<<'A'<<endl;
  }
  else if(Q=='G'){
    cout<<'C'<<endl;
  }
  else if(Q=='C'){
    cout<<'G'<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define watch(x) std::cout << (#x) << " is " << (x) << std::endl
#define print(x) std::cout << (x) << std::endl
using LL = long long;

int main() {
	//freopen("in","r",stdin);
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	LL a, b, c, d;
	std::cin >> a >> b >> c >> d;
	std::vector<LL> x{a*c, a*d, b*c, b*d};
	print(*std::max_element(x.begin(), x.end()));
	return 0;
}

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


int N;
int A[(int)1e5];

int main() {
    cin >> N;
    rep(i, N) cin >> A[i];

    int ans = A[0];
    for (int i = 1; i <= N - 1; i++) {
        ans = std::__gcd(ans, A[i]); 
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
class MyHeapQ
  def initialize(array = [])
    @data = []
    array.each{|a| push(a)}
  end

  def push(element)
    @data.push(element)
    bottom_up
  end

  def pop
    if size == 0
      return nil
    elsif size == 1
      return @data.pop
    else
      top = @data[0]
      @data[0] = @data.pop
      top_down
      return top
    end
  end

  def size
    @data.size
  end

  def data
    @data
  end

  private

  def swap(i, j)
    @data[i], @data[j] = @data[j], @data[i]
  end

  def parent_idx(target_idx)
    (target_idx - 1) / 2
  end

  def bottom_up
    target_idx = size - 1
    return if target_idx == 0
    parent_idx = parent_idx(target_idx)
    while ((@data[parent_idx][1] <=> @data[target_idx][1])>0)
      swap(parent_idx, target_idx)
      break if parent_idx == 0
      target_idx = parent_idx
      parent_idx = parent_idx(target_idx)
    end
  end

  def top_down
    target_idx = 0

    # child がある場合
    while (target_idx * 2 + 1 < @data.size)	# has_child?

      a = target_idx * 2 + 1		# left_child_idx
      b = target_idx * 2 + 2		# right_child_idx

      if @data[b].nil?
        c = a
      else
        c = (@data[a][1] <=> @data[b][1])<1 ? a : b
      end

      if (@data[target_idx][1] <=> @data[c][1])>0
        swap(target_idx, c)
        target_idx = c
      else
        return
      end
    end
  end
end

t = gets.strip.to_i
t.times do
  n = gets.strip.to_i
  klr = []
  s = []
  m = []
  ans = 0
  n.times do |i|
    k,l,r = gets.strip.split.map(&:to_i)
    if l == r
      ans += l
    elsif l > r
      s.push [k, l-r]
      ans += r
    else
      m.push [n-k, r-l]
      ans += l
    end
  end
  s.sort!
  m.sort!
  q = MyHeapQ.new
  c = 1
  s.each do |e|
    if e[0] > c
      while q.size > c
        q.pop
      end
      c = e[0]
    end
    q.push e
  end
  while q.size > c
    q.pop
  end
  while q.size > 0
    ans += q.data.pop[1]
  end
  c = 0
  m.each do |e|
    if e[0] > c
      while q.size > c
        q.pop
      end
      c = e[0]
    end
    q.push e
  end
  while q.size > c
    q.pop
  end
  while q.size > 0
    ans += q.data.pop[1]
  end
  p ans
end


Measured memory_bytes: 32012
n, m = map(int, input().split())
parents = [[] for _ in range(n)]
outdegree = [0] * n
indegree = [0] * n
path_root = [0] * n
for _ in range(m):
  x, y = map(int, input().split())
  x -= 1
  y -= 1
  parents[y].append(x)
  outdegree[x] += 1
  indegree[y] += 1
stack = [i for i in range(n) if outdegree[i] == 0]
while stack:
  vertex = stack.pop()
  path_length = path_root[vertex] + 1
  for parent in parents[vertex]:
    outdegree[parent] -= 1
    indegree[vertex] -= 1
    path_root[parent] = max(path_root[parent], path_length)
    if outdegree[parent] == 0:
      stack.append(parent)
print(max(path_root))

Measured memory_bytes: 23424