akhauriyash/Code-Regression huggingface dataset:
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust, fromMaybe )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.IntMap.Lazy            as IML
import qualified Data.Map.Strict               as M
import           Data.Char
import qualified Data.Array.IArray as A
import qualified Data.Array.Unboxed as UA
import Data.Bits
import Control.Monad.State.Strict
import qualified Data.Array.ST as STA
import qualified Data.Array.IO as IOA
import qualified Data.Array.MArray as MA
import Control.Monad.ST
import System.IO (stdin)
import Control.Arrow
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as UV
import qualified Data.Vector.Generic as GV
import qualified Data.Vector.Mutable as MV
import Data.Ix
import Data.Ord (Down(Down))
import qualified Data.Sequence as Seq
import Data.Foldable (toList)
import Data.Fixed
-- import Control.Lens

debug = False

ts :: Show a => a -> a
ts a = if debug then traceShowId a else a


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- readInts
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- readInts
    return (a, b, c)


readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

readIntV :: Int -> IO (UV.Vector Int)
readIntV n = GV.unfoldrN n (fmap (fmap BC.tail) . BC.readInt) <$> BC.getLine

readIntegersV :: Int -> IO (V.Vector Integer)
readIntegersV n = GV.unfoldrN n (fmap (fmap BC.tail) . BC.readInteger) <$> BC.getLine

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . BC.readInteger) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las

m = 1000000000000000000

main :: IO ()
main = do
  [a, b] <- words <$> getLine
  let a' = read a :: Int
  let b' = read b :: Fixed E2
  let ans = floor $ fromIntegral a' * b'
  print ans





Measured memory_bytes: 4520
#include <bits/stdc++.h>
 
#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;
 
#define int long long int
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
 
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
 
typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int n;
int a[100];
int dp[100001][2];

int play(int k, int p) {
	if (k < 0)
		return 1;
	if (k == 0)
		return 0;
	if (dp[k][p] != -1)
		return dp[k][p];
	dp[k][p] = 0;
	for (int i = 0; i < n; i++) {
		int win = play(k-a[i], p^1);
		if (win == 0) {
			dp[k][p] = 1;
			break;
		}
	}
	return dp[k][p];
}

void solve() {
	int k;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i <= k; i++) {
		for (int j = 0; j < 2; j++)
			dp[i][j] = -1;
	}
	if (play(k, 1))
		cout << "First";
	else
		cout << "Second";
}
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 11456
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> PII;
#define MOD (1000000007ll)

int main(void){
	string s,t;
	cin >> s >> t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end());
	reverse(t.begin(),t.end());
	cout << ((s<t)?"Yes":"No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

string S;
int main() {
  cin >> S;
  int n = S.length();
  int ans =0 ;
  rep(i,n) rep(j,n){
    if (i+j >= n) break;
    if (S[i+j] != 'A' && S[i+j] != 'G' && S[i+j] != 'C' && S[i+j] != 'T') break;
    chmax(ans, j+1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<cassert>
#include<algorithm>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)
#define MAX 16
using namespace std;

int n;
int cost[MAX][MAX];
string s[MAX];
int dp[1<<MAX][MAX];

int getCost(string a,string b)
{//from a to b
  int res = inf;
  for(int i=a.size()-1,st = 0;i>=0 && st < b.size();i--,st++)
    {
      string ca = a.substr(i,a.size()-i);      
      string cb = b.substr(0,st+1);
      if(ca == cb)res = st+1; 
    }
  return res;
}

int main()
{
  /*
  string a,b;
  while(1)
    {
  cin >> a >> b;
  cout << getCost(a,b) << endl;
    }
  */

  while(cin >> n,n)
    {
      rep(i,n)rep(j,n)cost[i][j] = inf;
      rep(i,n)cin >> s[i];
      vector<string> ss;
      rep(i,n)
	{
	  bool contain = false;
	  rep(j,n)
	    {
	      if(i == j)continue;
	      if(s[j].find(s[i]) != string::npos)
		{

		  contain = true;
		  break;
		}
	    }
	  if(!contain)ss.push_back(s[i]);
	}

      n = ss.size();
      rep(i,n)
	{
	  rep(j,n)
	    {
	      if(i == j)
		{
		  cost[i][j] = ss[i].size();
		  continue;
		}
	      int ct = getCost(ss[i],ss[j]);
	      if(ct == inf)cost[i][j] = ss[j].size();
	      else cost[i][j] = ss[j].size() - ct;
	      //assert(cost[i][j] >= 0);
	    }
	}
      rep(i,1<<n)rep(j,n)dp[i][j] = inf;
      rep(i,n)dp[1<<i][i] = ss[i].length();
      /*
      cout << "cost----" << endl;
      rep(i,n)
	{
	  rep(j,n)
	    {
	      cout << cost[i][j] << " ";
	    }
	  cout << endl;
	}
      cout << "-------" << endl;
      */
      rep(S,(1<<n))
	{
	  rep(from,n)
	    {
	      if(!((S>>from) & 1))continue;
	      rep(to,n)
		{
		  if((S>>to) & 1)continue;
		  dp[S|(1<<to)][to] = min(dp[S|(1<<to)][to],
					  dp[S][from] + cost[from][to]);
		}
	    }
	}
      int ans = inf;
      rep(i,n)
	{
ans = min(ans,dp[(1<<n)-1][i]);

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

Measured memory_bytes: 2248
/*
读题不规范，爆零两行泪。
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
const int N=200000;
int n;
int a[N+1];
vector<int> nums;
void discrete(){
	sort(nums.begin(),nums.end());
	nums.resize(unique(nums.begin(),nums.end())-nums.begin());
	for(int i=1;i<=n;i++)a[i]=lower_bound(nums.begin(),nums.end(),a[i])-nums.begin();
}
vector<int> nei[N+1];
multiset<int> st[N];
struct segtree{
	struct node{int l,r,mx;}nd[N<<2];
	#define l(p) nd[p].l
	#define r(p) nd[p].r
	#define mx(p) nd[p].mx
	void bld(int l=0,int r=nums.size()-1,int p=1){
		l(p)=l;r(p)=r;mx(p)=0;
		if(l==r)return;
		int mid=l+r>>1;
		bld(l,mid,p<<1);bld(mid+1,r,p<<1|1);
	}
	void init(){bld();}
	void sprup(int p){mx(p)=max(mx(p<<1),mx(p<<1|1));}
	void chg(int x,int v,int p=1){
		if(l(p)==r(p))return mx(p)=v,void();
		int mid=l(p)+r(p)>>1;
		chg(x,v,p<<1|(x>mid));
		sprup(p);
	}
	int _mx(int l,int r,int p=1){
		if(l>r)return 0;
		if(l<=l(p)&&r>=r(p))return mx(p);
		int mid=l(p)+r(p)>>1,res=0;
		if(l<=mid)res=max(res,_mx(l,r,p<<1));
		if(r>mid)res=max(res,_mx(l,r,p<<1|1));
		return res;
	}
}segt;
int dp[N+1],ans[N+1];
void dfs(int x=1,int fa=0){
	dp[x]=segt._mx(0,a[x]-1)+1;
	ans[x]=max(ans[fa],dp[x]);
	st[a[x]].insert(dp[x]);
	segt.chg(a[x],*--st[a[x]].end());
	for(int i=0;i<nei[x].size();i++){
		int y=nei[x][i];
		if(y==fa)continue;
		dfs(y,x);
	}
	st[a[x]].erase(st[a[x]].find(dp[x]));
	segt.chg(a[x],*--st[a[x]].end());
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i],nums.pb(a[i]);
	discrete();
	for(int i=1;i<n;i++){
		int x,y;
		cin>>x>>y;
		nei[x].pb(y);nei[y].pb(x);
	}
	for(int i=0;i<nums.size();i++)st[i].insert(0);
	segt.init();
	dfs();
	for(int i=1;i<=n;i++)cout<<ans[i]<<"\n";
	return 0;
}
/*1
10
1 2 5 3 4 6 7 3 2 4
1 2
2 3
3 4
4 5
3 6
6 7
1 8
8 9
9 10
*/

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

int main(){
  int k,x;
  cin>>k>>x;
  for(int i=0;i<2*k-1;i++){
    if(i!=2*k-2)cout<<x-k+i+1<<" ";
    else cout<<x-k+i+1<<endl;
    
  }
  
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//typedef int ll;
typedef long double ld;
//#define int ll
#define pb push_back
using vint = vector<int>;
using pii = pair<int,int>;
using pdd = pair<ld,ld>;
using vpii = vector<pii>;
#define F first
#define S second
const int N = 2e5+5;//(1 << 18) + 5;
//const ll inf = 1e18+7;
const int mod = 998244353;
const int Inf = 1e9+7;
const ld eps = 1e-9;
#ifndef M_PI
#define M_PI 3.1415926535
#endif
 
void io()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cerr.tie(NULL);
//	freopen("game.in", "r", stdin);
//	freopen("game.out", "w", stdout);
//  cout << setprecision(10) << fixed;
}
 
int n;//, k, a[N];

signed main()
{
	io();
	string s1, s2;
	cin >> s1 >> s2;
	n = s1.size();
	int cnt = 0;
	for (int i = 0; i < n; ++i)
	{
		cnt += s1[i] != s2[i];
	}
	cout << cnt;
}

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

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

    bool flag = false;
    for(int i = 1; i < 10; i++) {
        if(n % i == 0 && n / i < 10) {
            cout << "Yes" << endl;
            flag = true;
            break;
        }
    }

    if(!flag) cout << "No" << endl;

    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 N = sc.nextInt();
            int K = sc.nextInt();
            int Ln[] = new int[N];
            
            for(int i = 0;i < N;i++){
                Ln[i] = sc.nextInt();
            }
            Arrays.sort(Ln);
            int sum = 0;
            for(int i = Ln.length-1;i > Ln.length-K-1;i--){
                sum +=Ln[i];
            }
            System.out.println(sum);

    }
}

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int pow(int i)
{
    int ans = 1;
    rep(j, i) ans *= 2;
    return ans;
}

int main()
{
    int n;
    while (cin >> n)
    {
        rep(i, 10)
        {
            if (n & 0b1 == 1)
            {
                cout << pow(i);
                if(n!=1) cout<<" ";
            }
            n = n >> 1;
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3044
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
public static void main(String[] args)throws IOException{

BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String str = reader.readLine();
String[]array =str.split(" ",0);
int a =Integer.parseInt(array[0]);
int b =Integer.parseInt(array[1]);
int c = Integer.parseInt(array[2]);

if(a<b && b<c){
System.out.println("Yes");
}else{
System.out.println("No");
}
}
}

Measured memory_bytes: 24180
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
int dp[100010];
int main(){
    int n;cin>>n;
    vector<int>h(n);
    rep(i,n)cin>>h[i];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    REP(i,2,n)dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
    cout<<dp[n-1];
}

Measured memory_bytes: 1024
use proconio::{input, fastout};
use std::cmp::Ordering;

macro_rules! echo {
  ($val:expr) => {
    println!("{}", $val);
  }
}


fn lower_bound(v: &Vec<usize>, x: &usize) -> usize {
    let mut low = 0;
    let mut high = v.len();

    while low != high {
        let mid = (low + high) / 2;
        match v[mid].cmp(x) {
            Ordering::Less | Ordering::Equal => {
                low = mid + 1;
            }
            Ordering::Greater => {
                high = mid;
            }
        }
    }
    low
}

#[fastout]
fn main() {
  input!{
    n: usize,
    m:usize,
    k: usize,
    mut aa: [usize; n],
    mut bb: [usize; m]
  };

  let mut cusum = 0;
  for i in 0..n {
    cusum += aa[i];
    aa[i] = cusum;
  }
  let mut cusum = 0;
  for i in 0..m {
    cusum += bb[i];
    bb[i] = cusum;
  }
  let mut ans = 0;
  for i in 0..n {
    if aa[i] > k {
      break;
    }
    let less = k - aa[i];
    let bi = lower_bound(&bb, &less);
    if ans < i + 1 + bi {
      ans = i + 1 + bi;
    }
  }
  let bi = lower_bound(&bb, &k);
  if ans < bi {
    ans = bi;
  }
  echo!(ans);
}


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

using namespace std;

#ifndef ONLINE_JUDGE
  #define pr_debug(...) do { printf("DEBUG: line %d: %s: ", __LINE__, __PRETTY_FUNCTION__); printf(__VA_ARGS__); } while(0)
  #define pr_vars(...) do { pr_debug(" "); pr_var(split(#__VA_ARGS__, ',').begin(), __VA_ARGS__); } while(0)
#else
  __attribute__ ((constructor)) static void fast_cin() { ios_base::sync_with_stdio(false); cin.tie(0); }
  #define pr_debug(...) do { } while(0)
  #define pr_vars(...) do { } while(0)
#endif /* ONLINE_JUDGE */

using ll = int64_t;
using ull = uint64_t;

template<typename T> ostream &operator<< (ostream &fout, const vector<T> &vec)
{ for (const auto &el : vec) fout << el << ' '; return fout; }

template<typename T> istream &operator>> (istream &fin, vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fin >> vec[i]; return fin; }

vector<string> split(const string &s, char c) { vector<string> v; ull st = 0, fn = 0, lvl = 0;
for ( ; fn < s.size(); fn++ ) { if (s[fn] == c && lvl == 0) { v.push_back(s.substr(st, fn - st)); st = fn + 1; }
if (s[fn] == '(') { lvl++; } if (s[fn] == ')') { lvl--; } } v.push_back(s.substr(st, fn - st)); return v; }

void pr_var(vector<string>::iterator it) { (void) it; cout << endl; }
template<typename T, typename... Args> void pr_var(vector<string>::iterator it, T a, Args... args)
{ cout << *it << "=" << a << "  "; pr_var(++it, args...); }

ll div_ceil(ll n, ll d) { ll res = n / d; if (res >= 0) res += n % d ? 1 : 0; return res; }
ll gcd(ll a, ll b) { a = llabs(a); b = llabs(b); while (a && b) a > b ? a %= b : b %= a; return a + b; }
ll lcm(ll a, ll b) { ll c = gcd(a, b); return c == 0 ? 0 : llabs(a / c * b); }

#define setp(a) fixed << setprecision(a)
const double PI = acos(-1.0);
constexpr double EPS = 1e-9;
constexpr double INF = 2e18;

using mp = pair<ll, ll>;
using mt = tuple<ll, ll, ll>;    // unpack: tie(ll, ll, ll) = mt;

constexpr ll MAX = 1e5 + 5;

int main()
{
    ll n; cin >> n;
    vector<ll> d(n); cin >> d;
    sort(d.begin(), d.end());
    auto it = unique(d.begin(), d.end());
    d.resize(distance(d.begin(), it));
    cout << d.size() << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

int main() {
	double n, m, d;
	cin >> n >> m >> d;
	if (d == 0) {
		printf("%.15lf\n", (m - 1) / n);
	}
	else {
		double sum = (n - d) * 2 / (n*n);
		printf("%.15lf\n", sum*(m - 1));
	}
}

Measured memory_bytes: 256
<?php

list($n, $m) = explode(' ', trim(fgets(STDIN)));

$waAns = 0;
$waCnt = 0;
$acCheck = [];
$waCount = [];
for ($i=0; $i<$m; $i++) {
    list($p, $s) = explode(' ', trim(fgets(STDIN)));

    // AC済ならスキップ
    if (isset($acCheck[$p])) {
        continue;
    }

    // 初回AC数を数える
    // 初回AC時点でのその問題のWA数も加算する
    if ($s == 'AC') {
        $acCnt++;
        $acCheck[$p] = true;
        $waCnt += $waCount[$p];
    } else {
        $waCount[$p]++;
    }
}

echo sprintf("%s %s\n", count($acCheck), $waCnt);



Measured memory_bytes: 13048
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

// Manages Union-Find Forest.
class UnionFindForest {
  std::vector<int> parent_;
  std::vector<int> rank_;
  std::vector<int> size_;

public:
  // Initialize forest.
  // parent_[i]=i, rank_[i]=0, size_[i]=1.
  UnionFindForest(const int &n);
  // Get the number of the root of the node q.
  int Root(const int &q);
  // Return true if the roots of x and y is same.
  bool IsSame(const int &x, const int &y);
  // Unite the tree x and tree y.
  void Unite(int x, int y);
  // Get the number of nodes which are the same group as node q.
  int Size(const int &q);
};
UnionFindForest::UnionFindForest(const int &n) {
  parent_.resize(n);
  rank_.resize(n);
  size_.resize(n);
  for (int i = 0; i < n; i++) {
    parent_[i] = i;
    rank_[i]   = 0;
    size_[i]   = 1;
  }
}
int UnionFindForest::Size(const int &q) {
  return size_[Root(q)];
}

int UnionFindForest::Root(const int &q) {
  if (parent_[q] == q) {
    return q;
  } else {
    return parent_[q] = Root(parent_[q]);
  }
}

bool UnionFindForest::IsSame(const int &x, const int &y) {
  return Root(x) == Root(y);
}

void UnionFindForest::Unite(int x, int y) {
  x = Root(x);
  y = Root(y);
  if (x == y) return;
  if (rank_[x] < rank_[y]) {
    parent_[x] = y;
    size_[y] += size_[x];
    size_[x] = 0;

  } else {
    parent_[y] = x;
    size_[x] += size_[y];
    size_[y] = 0;
    if (rank_[x] == rank_[y]) rank_[x]++;
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n,m;
  cin>>n>>m;

  std::vector<int> talkative_list[100001];
  for(int i=1;i<=m;i++){
    talkative_list[i].resize(0);
  }
  for(int i=0;i<n;i++){
    int k;
    cin>>k;
    for(int j=0;j<k;j++){
      int l;
      cin>>l;
      talkative_list[l].push_back(i);
    }
  }

  UnionFindForest uf(n);
  for(int i=1;i<=m;i++){
    for(int j=0;j<(int)talkative_list[i].size()-1;j++){
      uf.Unite(talkative_list[i][j],talkative_list[i][j+1]);
    }
  }

  for(int i=0;i<n;i++){
    if(uf.Root(i)!=uf.Root(0)){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;

  return 0;
}

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

int idx, a[30], b[30], p[30], q[30], one, zero;

inline void plus(int src1, int src2, int dst) {
	printf("+ %d %d %d\n", src1, src2, dst);
}
inline void less(int src1, int src2, int dst) {
	printf("< %d %d %d\n", src1, src2, dst);
}
void prepare() {
	idx = 5;
	for (int i = 0; i < 30; i++) {
		a[i] = ++idx;
	}
	for (int i = 0; i < 30; i++) {
		b[i] = ++idx;
	}
	for (int i = 0; i < 30; i++) {
		p[i] = ++idx;
	}
	for (int i = 0; i < 30; i++) {
		q[i] = ++idx;
	}
	one = p[0];
	zero = q[0];
	plus(0, 1, 3);
	less(0, 3, 4);
	less(1, 3, 5);
	plus(4, 5, one);
	less(zero, one, one);
	for (int i = 1; i < 30; i++) {
		plus(p[i - 1], p[i - 1], p[i]);
	}
	for (int i = 1; i < 30; i++) {
		plus(q[i - 1], p[i - 1], q[i]);
	}
}
inline void getBit(int *bit, int src) {
	int tmp = ++idx, cmp = ++idx, pow = ++idx;
	for (int i = 29; i >= 0; i--) {
		plus(tmp, q[i], cmp);
		less(cmp, src, bit[i]);
		plus(bit[i], zero, pow);
		for (int j = 0; j < i; j++) {
			plus(pow, pow, pow);
		}
		plus(tmp, pow, tmp);
	}
}
inline void calc() {
	int tmp = ++idx;
	for (int i = 0; i < 30; i++) {
		for (int j = 0; j < 30; j++) {
			plus(a[i], b[j], tmp);
			less(one, tmp, tmp);
			for (int k = 0; k < i + j; k++) {
				plus(tmp, tmp, tmp);
			}
			plus(2, tmp, 2);
		}
	}
}
int main() {
	printf("29973\n");
	prepare();
	getBit(a, 0);
	getBit(b, 1);
	calc();
	return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;

void Main()
{
    mp::cpp_int n;
    cin >> n; 
    
    if (n%9 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3764
s = int(input())

a_n = s
a_set = {a_n}
i = 1
while True:
    a_n_1 = (3 * a_n + 1 if a_n % 2 else a_n // 2)
    if a_n_1 in a_set:
        print(i + 1)
        break
    else:
        a_set.add(a_n_1)
        a_n = a_n_1
        i += 1


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define mod 1000000007  
#define int long long int
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
using namespace std;

signed main(){
  fast_cin();
   #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
   #endif
        float d,t,s;
        cin>>d>>t>>s;
        if((d/s)<=t){
          cout<<"Yes";
        }
        else{
          cout<<"No";
        }

          

    
        }
        
    
          

    

      
        


      
       
    
    
  
      

      




Measured memory_bytes: 3692
#include<bits/stdc++.h>
#define dd(x) cout<<#x<<" = "<<x<<" "
#define de(x) cout<<#x<<" = "<<x<<"\n"
#define sz(x) int(x.size())
#define All(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef priority_queue<int> BQ;
typedef priority_queue<int,vector<int>,greater<int> > SQ;
const int maxn=3e5+10,mod=1e9+7,INF=0x3f3f3f3f;

int main()
{
	string t="...";
	string s;
	int k;
	cin>>k>>s;
	if (s.size()<=k)
		cout<<s;
	else{
		for (int i=0;i<k;++i)
			cout<<s[i];
		cout<<t;
	}
	return 0;
}


Measured memory_bytes: 3624
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int data[] = new int[m+1];
    int count = 0;

    for (int i = 0; i < n; i++) {
      int k = sc.nextInt();
      for (int j = 0; j < k; j++) {
        int a = sc.nextInt();
        data[a]++;
      }
    }

    for (int i = 0; i < m+1; i++) {
      if (data[i] == n) {
        count++;
      }
    }

    System.out.println(count);

  }

}


Measured memory_bytes: 22868
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
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); }
int B[100][100];
int solve(){
  int n;
  cin >> n;
  ll ans = 0;
  REP(i,1,n + 1){
    string tmp = to_string(i);
    int a = tmp[0] - '0',b = tmp.back() - '0';
    B[a][b]++;
  }
  REP(i,1,n + 1){
    string tmp = to_string(i);
    int b = tmp[0] - '0',a = tmp.back() - '0';
    ans += B[a][b];
  }
  cout << ans << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
} 

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

using ll = long long;
using P  = pair<ll,ll>;

struct Edge{
    using Cost = ll;
    ll to;
    Cost cost;
    Edge(ll t, Cost c) : to(t), cost(c){} 
};
using Edges = vector<Edge>;
using Graph = vector<vector<Edge>>;

bool operator < (const Edge &e,const Edge &f){
    return e.cost != f.cost ? e.cost > f.cost:
        e.to > f.to;
}

ll MST(const Graph &g, int r=0){
    ll n=g.size();
    ll total=0;

    vector<bool> visited(n);
    priority_queue<Edge> q;
    q.push(Edge(r,0));
    while(!q.empty()){
        Edge e=q.top();q.pop();
        if(visited[e.to]) continue;
        //cout<<e.to<<" "<<e.cost<<endl;
        total += e.cost;
        visited[e.to] = true;
        for(int i=0;i<(int)g[e.to].size();i++){
            if(!visited[g[e.to][i].to]) q.push(g[e.to][i]);
        }
    }
    return total;
}

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

    int n;cin>>n;
    Graph g(n);
    vector<P> x,y;
    for(int i=0;i<n;i++){
        ll xtmp,ytmp;cin>>xtmp>>ytmp;
        x.push_back(P(xtmp,i));
        y.push_back(P(ytmp,i));
    }
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    for(int i=1;i<n;i++){
        ll s=x[i-1].second,t=x[i].second;
        ll c=x[i].first-x[i-1].first;
        g[s].push_back(Edge(t,c));
        g[t].push_back(Edge(s,c));
        //cout<<s<<" "<<t<<" "<<c<<endl;
        
        s=y[i-1].second;t=y[i].second;
        c=y[i].first-y[i-1].first;
        g[s].push_back(Edge(t,c));
        g[t].push_back(Edge(s,c));
        //cout<<s<<" "<<t<<" "<<c<<endl;
    }
    //cout<<endl;
    cout<<MST(g)<<endl;
}


Measured memory_bytes: 17380
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		Console.WriteLine(A >= 13 ? B : A <= 5 ? 0 : B / 2);
		
		
	}
	int A,B;
	
	public Sol(){
		var d = ria();
		A = d[0]; B = d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13140
def chmin(a,b):
    if a<b:
        return a
    else:
        return b


N = int(input())
INF = 1<<30
H = [int(i) for i in input().split()]+[INF,INF]
DP = [INF]*(N+1)
DP[0] = 0
for i in range(N-1):
    DP[i+1] = chmin(DP[i+1],DP[i]+abs(H[i+1]-H[i]))
    DP[i+2] = chmin(DP[i+2],DP[i]+abs(H[i+2]-H[i]))
print(DP[N-1])

Measured memory_bytes: 13976
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

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

class BBalance {
 public:
  void solve(std::istream &in, std::ostream &out) {
    int n;
    in >> n;
    vector<int> v(n);
    int sum = 0;
    forn(i, n) {
      in >> v[i];
      sum += v[i];
    }

    int s1 = 0;
    int ans = sum;
    for (int e : v) {
      s1 += e;
      ans = min(ans, abs(2 * s1 - sum));
    }
    out << ans << endl;
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  BBalance solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

using namespace std;

int main(void)
{
    int N, M, K;
    cin >> N >> M >> K;
    vector<int> A(N);
    vector<int> B(M);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    for(int i = 0; i < M; i++){
        cin >> B[i];
    }

    vector<unsigned long long> a(N+1, 0);
    vector<unsigned long long> b(M+1, 0);
    for(int i = 1; i <= N; i++){
        a[i] = A[i-1] + a[i-1];
    }
    for(int i = 1; i <= M; i++){
        b[i] = B[i-1]+b[i-1];
    }


    int ans = 0;
    int i, j = M;
    for(i = 0; i <= N; i++){
        int t = K - a[i];
        if(t < 0)   break;
        while(b[j] > t){
            j--;
        }
        ans = max(ans, i + j);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8008
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mat vector<vector<int>>
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll


auto max(auto a){auto ans=a[0];for(auto i:a)if(i>ans)ans=i;return ans;}
auto min(auto a){auto ans=a[0];for(auto i:a)if(i<ans)ans=i;return ans;}
void print(auto a){for(auto i:a)cerr<<i<<' ';cerr<<'\n';}



signed main()
{
	fio
	inp(n)
	inpa(a,n)
	sort(all(a));
	int ans=0;
	// print(a);
	fo(i,n)
	{
		for(int j=i+1;j<n;j++)
		{
			int ind1=lower_bound(all(a),a[j]-a[i]+1)-a.begin();
			int ind2=lower_bound(all(a),a[i]+a[j])-a.begin();
			// cout<<i<<','<<j<<' '<<ind1<<','<<ind2<<endl;
			ans+=ind2-ind1;
			if(a[ind1]<=a[i] && ((ind2<a.size() && a[i]<a[ind2]) || (ind2==a.size())))
				ans--;
			if(a[ind1]<=a[j] && ((ind2<a.size() && a[j]<a[ind2]) || (ind2==a.size())))
				ans--;
			// cout<<i<<','<<j<<' '<<ans<<endl;
		}
	}
	
	cout<<ans/3<<'\n';
	printclock;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
char s[101];
int w,h;
int main()
{
    scanf("%d%d",&h,&w);
    for(int i=0;i<h;i++)
    {
        scanf("%s",s);
        printf("%s\n%s\n",s,s);
    }
    return 0;
}

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

int main() {
  string S, T; cin >> S; int N=S.length();
    for(int i=0;i<N;){
      if(i==0&&S[i]!='d'&&S[i]!='e'){
        cout << "NO" << endl;
        return 0;
      }
      else if(S[i]=='d'){
        if(i==S.find("dream",i)){
          if(i+5==N) break;
          else if(i+5<N&&S[i+5]=='d'){
            i+=5; continue;
          }
          else if(S[i+5]=='e'){
            if(i+6<N&&S[i+6]!='r'){
              cout << "NO" << endl;
              return 0;
            }
            else if(i+7<N&&S[i+7]=='a'){
              i+=5; continue;
            }
            else if(i+7<N&&(S[i+7]=='d'||S[i+7]=='e')){
              i+=7; continue;
            }
            else if(i+7==N){
              i+=7; continue;
            }
            else{
              cout << "NO" << endl;
              return 0;
            }
          }
          else{
            cout << "NO" << endl;
            return 0;
          }
        }
        else{
          cout << "NO" << endl;
          return 0;
        }
      }
      else if(S[i]=='e'){
        if(i==S.find("erase",i)){
          if(i+5==N)break;
          else if(i+5<N&&S[i+5]=='d'){
            i+=5; continue;
          }
          else if(i+5<N&&S[i+5]=='e'){
            i+=5; continue;
          }
          else if(i+5<N&&S[i+5]=='r'){
            i+=6; continue;
          }
          else{
            cout << "NO" << endl;
            return 0;
          }
        }
        else{
          cout << "NO" << endl;
          return 0;
        }
      }
      else{
        cout << "NO" << endl;
        return 0;
      }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
        char c;
        cin >> c;
        switch (c) {
                case 'a':
                case 'i':
                case 'u':
                case 'e':
                case 'o':
                        cout << "vowel" << endl;
                        break;
                default:
                        cout << "consonant" << endl;
                        break;
        }
        return 0;
}

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

struct Rect {
    int h;
    int pos;
};

int c[500][501];
int h, w;

int main() {
    while (cin >> h >> w, h|w) {
        vector<string> ms(h);
        for (int i = 0; i < h; i++) {
            cin >> ms[i];
        }
        for (int x = 0; x < w; x++) {
            c[0][x] = (ms[0][x] == '*') ? 0 : 1;
        }
        for (int y = 1; y < h; y++) {
            for (int x = 0; x < w; x++) {
                c[y][x] = (ms[y][x] == '*') ? 0 : c[y-1][x] + 1;
            }
        }
        int ans = 0;
        for (int y = 0; y < h; y++) {
            stack<Rect> s;
            c[y][w] = 0;
            for (int x = 0; x <= w; x++) {
                Rect r;
                r.h = c[y][x];
                r.pos = x;
                if (s.empty() || s.top().h < r.h) {
                    s.push(r);
                } else if (s.top().h > r.h) {
                    int j = x;
                    while (!s.empty() && s.top().h >= r.h) {
                        Rect r0 = s.top(); s.pop();
                        ans = max(ans, r0.h * (x - r0.pos));
                        j = r0.pos;
                    }
                    r.pos = j;
                    s.push(r);
                }
            }
        }
        cout << ans << endl;
   }
}

Measured memory_bytes: 2324
#include<iostream>
using namespace std;
int main(){
  int n,i,ans;cin >> n;ans = 0;
  int v[n];
  int c[n];
  for (i=0;i<n;i++) cin >> v[i];
  for (i=0;i<n;i++) cin >> c[i];
  for (i=0;i<n;i++){
    if (v[i] > c[i]) ans += v[i]-c[i];
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 256
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my ($n, $k) = split / /, <STDIN>);
chomp (my @p = split / /, <STDIN>);
my @q;
$q[0] = 0;
for my $i (1..$n) {
  $q[$i] = $p[$i-1] + $q[$i-1];
}
my $max = 0;
for my $i (0..$n-$k) {
  my $m = $q[$k+$i] - $q[$i];
	$max = $m if $max < $m;
}
say (($max+$k)/2);

Measured memory_bytes: 34980
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  ll K;
  ll tmp=7;
  cin>>K;
  rep(i,K){
    if(tmp%K==0){
      cout<<i+1<<endl;
      return 0;
    }
    tmp=(tmp*10+7)%K;
  }
  cout<<"-1"<<endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N; cin >> N;
  string ans="";
  if (N==0){ ans="0";}
  while(N!=0){
    if(N%2!=0){
      ans="1"+ans;
      N--;
    }
    else ans="0"+ans;
    N/=-2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def primeFactor(n):
    res = {}
    i = 2
    while i*i <= n:
        while n % i == 0:
            key = str(i)
            res.update({key : 1+int(res.get(key,0))})
            n=n//i
        i=i+1    
    if n!=1:
        key = str(n)
        res.update({key : 1+int(res.get(key,0))})
    return res

N, P = map(int, input().split())
max = 1
for divisor, count in primeFactor(P).items():
    while count >= N:
        max *= int(divisor)
        count -= N
print(max)


Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<tuple>
#include<utility>

using namespace std;



int main() {

	int a, b, c;

	cin >> a >> b >> c;

	cout << min(min(a + b, b + c), c + a) << endl;

	return 0;
}




Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem A

if __name__ == '__main__':
    a, b, c, d = list(map(int, input().split()))

    if abs(a - b) <= d and abs(b - c) <= d:
        print('Yes')
    elif abs(a - c) <= d:
        print('Yes')
    else:
        print('No')


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

using namespace std;

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

int main(){
    int i;
    //入力
    long a,b;
    cin>>a>>b;
    //処理
    long x;
    x = a * b;
    long tmp;
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  long r;
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }

    //出力
    cout<<x/b<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<string>s(3);
  int i[3];
  i[0] = 0;
  i[1] = 0;
  i[2] = 0;
  cin >> s[0]>>s[1]>>s[2];
  int next = 0;
  while(true){
    int cur = next;
    if(i[cur]>=s[cur].length()){
      cout<<(char)('A'+cur)<<endl;
      break;
    }
    next = (int)(s[cur][i[cur]]-'a');
    i[cur]++;
  }
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main { //REMEMBER TO USE MAIN//
	public static void main(String[] args) throws Exception{
		BufferedReader in = new BufferedReader( new InputStreamReader(System.in));//
		String line;
		while((line=in.readLine())!=null){//
			String s = "";
			for (int i=line.length()-1;i>-1;i--){
				s+= line.charAt(i);
			}
			System.out.println(s);
			////Some code
		}//while#1
	}//static main
}//class

Measured memory_bytes: 24020
#include <iostream>
#include <cstring>
#include <cmath>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x

int main(){

  int A,B;

  cin >> A >> B;

  if( A < 2 * B ) cout << 0 << endl;
  else cout << A - ( 2 * B ) << endl;


  return 0;

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

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

int main() {
    int a, b, k; cin >> a >> b >> k;
    for (int i=0; i<k; ++i) {
        int na, nb;
        if (i%2 == 0) {
            na = a/2;
            nb = b + a/2;
        } else {
            nb = b/2;
            na = a + b/2;
        }
        a = na;
        b = nb;
    }
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct ModInt {
	long long val;
	constexpr ModInt(long long v = 0) noexcept : val(v % MOD) {
		if (val < 0) val += MOD;
	}
	constexpr int getmod() { return MOD; }
	constexpr ModInt operator - () const noexcept {
		return val ? MOD - val : 0;
	}
	constexpr ModInt operator + (const ModInt& r) const noexcept { return ModInt(*this) += r; }
	constexpr ModInt operator - (const ModInt& r) const noexcept { return ModInt(*this) -= r; }
	constexpr ModInt operator * (const ModInt& r) const noexcept { return ModInt(*this) *= r; }
	constexpr ModInt operator / (const ModInt& r) const noexcept { return ModInt(*this) /= r; }
	constexpr ModInt& operator += (const ModInt& r) noexcept {
		val += r.val;
		if (val >= MOD) val -= MOD;
		return *this;
	}
	constexpr ModInt& operator -= (const ModInt& r) noexcept {
		val -= r.val;
		if (val < 0) val += MOD;
		return *this;
	}
	constexpr ModInt& operator *= (const ModInt& r) noexcept {
		val = val * r.val % MOD;
		return *this;
	}
	constexpr ModInt& operator /= (const ModInt& r) noexcept {
		long long a = r.val, b = MOD, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % MOD;
		if (val < 0) val += MOD;
		return *this;
	}
	constexpr bool operator == (const ModInt& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const ModInt& r) const noexcept {
		return this->val != r.val;
	}
	friend constexpr ostream& operator << (ostream &os, const ModInt<MOD>& x) noexcept {
		return os << x.val;
	}
	friend constexpr ModInt<MOD> modpow(const ModInt<MOD> &a, long long n) noexcept {
		if (n == 0) return 1;
		auto t = modpow(a, n / 2);
		t = t * t;
		if (n & 1) t = t * a;
		return t;
	}
};

class Comb {
private:
	int MOD;
	long long* fac;
	long long* finv;
	long long* inv;
public:
	// 事前にテーブルを作成
	Comb(int MAX, int MOD) {
		this->MOD = MOD;

		fac = new long long[MAX + 1];
		finv = new long long[MAX + 1];
		inv = new long long[MAX + 1];

		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		for (int i = 2; i <= MAX; i++) {
			fac[i] = fac[i - 1] * i % MOD;
			inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
			finv[i] = finv[i - 1] * inv[i] % MOD;
		}
	}

	~Comb() {
		delete[] fac, finv, inv;
	}

	// 二項係数計算
	long long calc(int n, int k){
		if (n < k) return 0;
		if (n < 0 || k < 0) return 0;
		return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
	}
};

const int MOD = 1000000007;
using mint = ModInt<MOD>;

int A[100000];

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

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

	sort(A, A+N);

	Comb comb = Comb(N, MOD);

	mint ans = 0;

	for (int i=N-1; i >= K-1; i--) {
		ans += mint(A[i]) * comb.calc(i, K-1);
		//cout << i << " " << K-1 << endl; // **** debug ****
	}

	for (int i=0; N-i-1 >= K-1; i++) {
		ans -= mint(A[i]) * comb.calc(N-i-1, K-1);
		//cout << N-i-1 << " " << K-1 << endl; // **** debug ****
	}

	cout << ans << endl;

	return 0;
}

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  ll a, b, c;
  cin >> a >> b >> c;

  string result = "No";
  if ((a + sqrtl(a * b) < sqrtl(a * c)) && (sqrtl(a * b) + b < sqrtl(b * c))) {
    result = "Yes";
  }
  cout << result << endl;

  return 0;
}


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

using namespace std;
using ll = long long;

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

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


ll N, K;
ll A[100010];

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> A[i];
	
	ll res = 0LL;
	for(int d = 40; d >= -1; d--)//KとXが変わる位置で全探索。
	{
		if(d!=-1&&(~K&(1LL<<d)))continue; //Kのdビット目が0なら飛ばす。

		ll t=0;
		for(int x = 40; x >= 0; x--)
		{
			ll mask = 1LL<<x, cnt = 0;
			for(int i = 0; i < N; i++) if(A[i]&mask)++cnt;
			if(x>d){
				if(K&mask)t+=mask*(N-cnt); //dビット目より上位のビットではKとビットを揃える。
				else t+=mask*cnt;
			}
			else if(x==d){
				t+=mask*cnt;
			}
			else{
				t+=mask*max(cnt, N-cnt);
			}
		}
		res=max(res, t);
	}
	cout<<res<<endl;

	return 0;
}


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

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;}
template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){return a/GCD(a,b)*b;}

const int INF=1e9;
const double eps=0.0000000001;


int main(){

  ll n,num,v,x,ans=100;
  cin >> n;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      num=i;
      v=0;
      while(num){
        v++;
        num/=10;
      }
      x=0;
      num=n/i;
      while(num){
        x++;
        num/=10;
      }
      chmin(ans,max(v,x));
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
K = int(input())

N = 50
a = [N-1]*N
d = K//N
m = K % N
for i in range(N):
    a[i] += d

for i in range(m):
    for j in range(N):
        if j == i:
            a[j] += N
        else:
            a[j] -= 1
print(N)
print(' '.join(map(str, a)))



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

int main() {
    string s;
    cin >> s;
    int l = s.size() - 1;
    if(s[l] == 's') {
        s += "es";
    }
    else {
        s += "s";
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
int main(){
	while(1){
		int n,max=0,a,b,p,tmp;
		scanf("%d",&n);
		if(!n) break;
		for(int i=0;i<n;i++){
			scanf("%d%d%d",&tmp,&a,&b);
			if(max<a+b){
				max=a+b;
				p=tmp;
			}
		}
		printf("%d %d\n",p,max);
	}
	return 0;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  
  vector<int>a(M);
  for(int i=0;i<M;i++){
    cin >> a.at(i); 
  }
  
  for(int i=0;i<M;i++){
    N -= a.at(i);
  }
  
  if(N<0)N=-1;
  
  cout << N << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include<algorithm>
#include <numeric>
using namespace std;
 int main(){
   int K;
   cin >> K;
   long long C=0;
   for(int i=1;i<=K;i++){
     for(int j=1;j<=K;j++){
       for(int k=1;k<=K;k++){
         C+=gcd(gcd(i,j),k);
       }
     }
   }
   cout << C << endl;
 }

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int a,b;
double upa,doa,upb,dob;
int main()
{
	cin>>a>>b;
	upa=(a+1)/0.08;
	doa=a/0.08;
	upb=(b+1)/0.1;
	dob=b/0.1;
	if(upb-doa<1 || upa-dob<1)
		cout<<-1<<endl;
	else
	{
		if(doa<=dob)
			cout<<ceil(dob)<<endl;
		else if(doa>dob && doa<upb)
			cout<<ceil(doa)<<endl;
	}
	return 0;
}


Measured memory_bytes: 256