akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(){
  long long h, w;
  long long num_odd_line, odd_able_sq, ans;
  
  scanf("%lld %lld", &h, &w);
  
  if(h == 1 || w == 1){
    printf("1");
    return 0;
  }
  
  odd_able_sq = (w+1)/2;
  num_odd_line = (h+1)/2;
  
  ans = odd_able_sq * num_odd_line + (w - odd_able_sq) * (h - num_odd_line);
  printf("%lld", ans);
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);  //EX: (a1^a2^a3)

  REP(i,n) cin >> a[i];
  int s = 0;  //a[1]-a[n]のXORの総和
  REP(i,n) s ^= a[i]; //^=：XOR
  REP(i,n) a[i] ^= s;
  //EX: (a1^a2^a3^a4) ^ (a1^a2^a3) = a4
  //s = (a1^a2^a3^a4)
  REP(i,n-1) cout << a[i] << " ";
  cout << a[n-1] << endl;
  return 0;
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e18L + 5;
int main() {
    int n;
    long long int w;
    scanf("%d %lld",&n,&w);
    vector<long long int> weight(n);
    vector<int> value(n);
    int sum = 0;
    for(int i = 0; i < n;i++){
        scanf("%lld %d",&weight[i],&value[i]);
        sum += value[i];
    }

    vector<long long int> dp(sum +1,INF);
    dp[0] = 0;
    for(int item = 0;item < n;++item){
        for(int value_already = sum - value[item]; value_already >= 0;--value_already){
            dp[value_already + value[item]] = min(dp[value_already + value[item]], dp[value_already] + weight[item]);
        }
    }
    for( int i = sum;i >=0; --i){
        if(dp[i] <= w){
            printf("%d\n",i);
            break;
        }
    }
}


Measured memory_bytes: 1024
#include <iostream>
#include <array>
#include <vector>

using namespace std;

int main() {
	vector <array <int, 2>> nums;

	int x = 0;
	int y = 0;

	int key = 0;

	while (true) {
		cin >> x >> y;
		if ((x == 0) && (y == 0)) {
			break;
		}
		nums.push_back(array <int, 2> {x, y});
	}
	for (int i = 0; i < nums.size(); i++) {
		if (nums[i][0] > nums[i][1]) {
			key = nums[i][1];
			nums[i][1] = nums[i][0];
			nums[i][0] = key;
		}
	}
	for (int i = 0; i < nums.size(); i++) {
		cout << nums[i][0] << ' ' << nums[i][1] << endl;
	}
}



Measured memory_bytes: 3160
#include <iostream>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <vector>
#define llint long long

using namespace std;

struct edge{
	llint to, cost;
	edge(){}
	edge(llint a, llint b){
		to = a, cost = b;
	}
};

llint n, m, p;
vector<edge> G[2505];
vector<llint> revG[2505];
llint dist[2505];
bool used[2505], used2[2505];

bool BellmanFord()
{
	for(int i = 1; i <= n; i++) dist[i] = 1e12;
	dist[1] = 0;
	
	llint cnt = 0;
	bool update = true;
	while(update){
		update = false;
		for(int i = 1; i <= n; i++){
			if(!used[i] || !used2[i]) continue;
			for(int j = 0; j < G[i].size(); j++){
				if(!used[G[i][j].to]) continue;
				if(dist[G[i][j].to] > dist[i] + G[i][j].cost){
					dist[G[i][j].to] = dist[i] + G[i][j].cost;
					update = true;
				}
			}
		}
		cnt++;
		if(cnt >= n+m+1) return false;
	}
	return true;
}

void dfs(llint v)
{
	used[v] = true;
	for(int i = 0; i < revG[v].size(); i++){
		if(used[revG[v][i]]) continue;
		dfs(revG[v][i]);
	}
}

void dfs2(llint v)
{
	used2[v] = true;
	for(int i = 0; i < G[v].size(); i++){
		if(used2[G[v][i].to]) continue;
		dfs2(G[v][i].to);
	}
}


int main(void)
{
	cin >> n >> m >> p;
	llint a, b, c;
	for(int i = 1; i <= m; i++){
		cin >> a >> b >> c;
		G[a].push_back(edge(b, p-c));
		revG[b].push_back(a);
	}
	
	dfs(n);
	dfs2(1);
	
	if(!BellmanFord()) cout << -1 << endl;
	else cout << max(0LL, -dist[n]) << endl;
	
	return 0;
}

Measured memory_bytes: 768
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

template <typename T>
struct Min {
    T operator()(T x, T y) {
        return min(x, y);
    }
};

template <class T, class Functor>
struct SegmentTree {
    size_t n;
    T e;
    vector<T> tree;
    Functor F;
    SegmentTree(size_t m, T e=T()): n(1), e(e) {
        while (n < m) n <<= 1;
        tree.assign(n<<1, e);
    }
    T range_query(size_t a, size_t b, size_t i=1, size_t l=0, size_t r=-1) {
        if (!~r) r = n;
        if (a<=l && r<=b) return tree[i];

        T vl=e, vr=e;
        size_t c=(l+r)>>1;

        if (a < c) vl=F(e, range_query(a, b, i<<1|0, l, c));
        if (c < b) vr=F(e, range_query(a, b, i<<1|1, c, r));

        return F(vl, vr);
    }
    void update(size_t i, T x) {
        i += n;
        tree[i] = x;
        while (i>>=1)
            tree[i] = F(tree[i<<1|0], tree[i<<1|1]);
    }
};

int main() {
    size_t n, q;
    scanf("%zu %zu", &n, &q);

    SegmentTree<int, Min<int>> tree(n, (1LL<<31)-1);
    for (size_t i=0; i<q; ++i) {
        int com;
        scanf("%d", &com);
        if (com) {
            size_t s, t;
            scanf("%zu %zu", &s, &t);
            printf("%d\n", tree.range_query(s, t+1));
        } else {
            size_t i;
            int x;
            scanf("%zu %d", &i, &x);
            tree.update(i, x);
        }
    }

    return 0;
}

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

#define ld long double
#define eps 1e-9

bool cmp(ld A , ld B){return A + eps > B && A - eps < B;}

class vec{
public:
	ld x , y;
	vec(ld _x = 0 , ld _y = 0) : x(_x) , y(_y){}
	friend vec operator +(vec A , vec B){return vec(A.x + B.x , A.y + B.y);}
	friend vec operator -(vec A , vec B){return vec(A.x - B.x , A.y - B.y);}
	friend ld operator *(vec A , vec B){return A.x * B.x + A.y * B.y;}
	friend ld operator %(vec A , vec B){return A.x * B.y - A.y * B.x;}
	friend vec operator *(vec A , ld B){return vec(A.x * B , A.y * B);}
	ld len(){return sqrt(x * x + y * y);}
	ld len2(){return x * x + y * y;}
	ld angle(){return atan2(y , x);}
};
vec getvec(){ld x , y; cin >> x >> y; return vec(x , y);}

class segment{
public:
	vec st , ed , dir;
	segment(vec _a = vec() , vec _b = vec()) : st(_a) , ed(_b) , dir(_b - _a){}
	friend bool havesect(segment A , segment B){
		ld P = A.st.x , Q = A.ed.x , X = B.st.x , Y = B.ed.x;
		if(Q < P) swap(P , Q);
		if(Y < X) swap(X , Y);
		if(X - eps > Q || P - eps > Y) return 0;
		P = A.st.y , Q = A.ed.y , X = B.st.y , Y = B.ed.y;
		if(Q < P) swap(P , Q);
		if(Y < X) swap(X , Y);
		if(X - eps > Q || P - eps > Y) return 0;
		return
			((B.st - A.st) % A.dir) * (A.dir % (B.ed - A.st)) > -eps &&
			((B.st - A.ed) % A.dir) * (A.dir % (B.ed - A.ed)) > -eps &&
			((A.st - B.st) % B.dir) * (B.dir % (A.ed - B.st)) > -eps &&
			((A.st - B.ed) % B.dir) * (B.dir % (A.ed - B.ed)) > -eps;
	}
	friend vec getsect(segment A , segment B){
		ld t = ((A.st - B.st) % B.dir) / (B.dir % A.dir);
		return A.st + (A.dir * t);
	}
	ld len(){return dir.len();}
	ld len2(){return dir.len2();}
};
segment getseg(){vec A = getvec() , B = getvec(); return segment(A , B);}

ld dist(vec P , segment seg){//minimum dist from a point to a segment
	ld T = ((P - seg.st) * seg.dir) / seg.len2();
	if(T < 0) return (seg.st - P).len();
	else if(T > 1) return (seg.ed - P).len();
	else return (seg.st + (seg.dir * T) - P).len();
}

class polygon{//counter-clockwise
public:
	vector < vec > point; int sz;
	void input(){
		cin >> sz; for(int i = 1 ; i <= sz ; ++i) point.push_back(getvec());
		for(int i = 0 ; i < sz ; ++i) point.push_back(point[i]);
	}
	ld area(){
		ld sum = 0;
		for(int i = 0 ; i < sz ; ++i) sum += point[i] % point[i + 1];
		return sum / 2;
	}
	bool isconvex(){
		for(int i = 1 ; i <= sz ; ++i)
			if((point[i - 1] - point[i]) % (point[i + 1] - point[i]) > eps) return 0;
		return 1;
	}
};

class convex : public polygon{
public:
	bool checkin(vec P){
		return 0;
	}
};

int main(){
	polygon T; T.input(); cout << fixed << setprecision(1) << T.isconvex() << endl;
	return 0;
}



Measured memory_bytes: 3240
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

main :: IO ()
main = do
  (n:m:_) <- map read . words <$> getLine :: IO [Int]
  abs <- map ((\(a:b:_) -> (a,b)) . map (fst . fromJust . B.readInt) . B.words) . B.lines <$> B.getContents
  print $ solve n m abs

solve n m abs = go (0, 0) initial wvs
  where
    initial = empty (\x y -> compare (snd y) (snd x))
    wvs = sortOn fst $ abs
    go (mm, mv) heap wvs
      | mm > m = mv
      | isEmpty heap = go (mm+1, mv) (foldr insertHeap heap next) newWvs
      | otherwise = go (mm+1, mv + maxb) (foldr insertHeap (removeRoot heap) next) newWvs
      where
        next = takeWhile (\x -> fst x == mm + 1) wvs
        newWvs = dropWhile (\x -> fst x == mm + 1) wvs
        maxb = snd $ root heap


data Heap a = Heap (a -> a -> Ordering) (Tree a)
data Tree a = Null | Fork !a (Tree a) (Tree a) deriving (Show)

instance (Show a) => Show (Heap a) where
  show (Heap _ a) = show a

empty :: (a -> a -> Ordering) -> Heap a
empty pred = Heap pred Null

isEmpty :: Heap a -> Bool
isEmpty (Heap _ Null) = True
isEmpty _ = False

root :: Heap a -> a
root (Heap _ (Fork x _ _)) = x

rootNode :: Tree a -> a
rootNode (Fork x _ _) = x

removeRoot :: Heap a -> Heap a
removeRoot (Heap c (Fork _ a b)) = Heap c $ merge c a b

insertHeap :: a -> Heap a -> Heap a
insertHeap !x (Heap c t) = Heap c $ merge c (singleton x) t

merge :: (a -> a -> Ordering) -> Tree a -> Tree a -> Tree a
merge _ a Null = a
merge _ Null b = b
merge c a b
  | c (rootNode a) (rootNode b) == LT = joinHeap c a b
  | otherwise = joinHeap c b a

joinHeap :: (a -> a -> Ordering) -> Tree a -> Tree a -> Tree a
joinHeap c (Fork x l r) a = Fork x r (merge c l a)

singleton :: a -> Tree a
singleton a = Fork a Null Null

fromList :: (a -> a -> Ordering) -> [a] -> Heap a
fromList c = foldl' (flip insertHeap) (Heap c Null)


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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<pair<char, char>> query(q);
    for(int i = 0; i < q; ++i){
        cin >> query[i].first >> query[i].second;
    }
    int ok = 0, ng = n;
    while(ng - ok > 1){
        int mid = (ok + ng) / 2;
        int now = mid;
        bool flg = false;
        for(int i = 0; i < q; ++i){
            if(s[now] == query[i].first){
                if(query[i].second == 'L') --now;
                else ++now;
            }
            if(now < 0){
                ok = mid;
                flg = true;
                break;
            }
            if(now == n){
                ng = mid;
                flg = true;
                break;
            }
        }
        if(!flg) ng = mid;
    }
    int l = ok;

    ok = n, ng = 0;
    while(ok - ng > 1){
        int mid = (ok + ng) / 2;
        int now = mid;
        bool flg = false;
        for(int i = 0; i < q; ++i){
            if(s[now] == query[i].first){
                if(query[i].second == 'L') --now;
                else ++now;
            }
            if(now < 0){
                ng = mid;
                flg = true;
                break;
            }
            if(now == n){
                ok = mid;
                flg = true;
                break;
            }
        }
        if(!flg) ng = mid;
    }
    int r = ok;
    cout << r - l - 1 << "\n";
    return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  //vector<vector<char>> matrix(H, vector<char>(W));
  //cout << hoge << endl;
  //vector<bool> hflag(0);
  int itr = 0;

  while (A > 0 && C >0){
    if(itr % 2 == 0){
        C -= B;
    } else{
        A -= D;
    }
    itr ++;
  }

  if(itr % 2 == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}

int main() {
    int N;
    cin >> N;
    vector<int> s(N);
    int n = 0;
    for (int j=2; n < N; j++) {
        if ((j-1) % 10 == 0 && IsPrime(j)) {
            s[n] = j;
            n++;
        }
    }
    for (int j=0; j < N; j++) {
        if (j==N-1) {
            cout << s[j] << endl;
        } else {
            cout << s[j] << " ";
        }
    }
}

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


int main(){
	int S,h,m,s;
	cin >> S;
	h=S/3600;
	m=(S-(h*3600))/60;
	s=(S-(h*3600))%60;
	cout << h << ':' << m << ':' << s << endl;
	
}


Measured memory_bytes: 3072
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 ans = 1;
		for(int i = (M / N); i >= 1; i--) {
			if(M % i == 0) {
				ans = i;
				break;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23636
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int x;
    cin >> x;

    int money = 100;
    int year = 1;

    for (year = 1;; year++) {
        money += money / 100;
        if (money >= x) break;
    }

    cout << year << endl;
}


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int iter = 0; iter < k; ++iter) {
        vector<int> b(n);
        for (int i = 0; i < n; ++i) {
            int l = max(0, i - a[i]);
            int r = i + a[i] + 1;
            ++b[l];
            if (r < n)
                --b[r];
        }
        a[0] = b[0];
        bool done = true;
        if (a[0] != n)
            done = false;
        for (int i = 1; i < n; ++i) {
            a[i] = a[i - 1] + b[i];
            if (a[i] != n)
                done = false;
        }
        if (done)
            break;
    }
    for (int v: a)
        cout << v << " ";
    cout << "\n";
    return 0;
}


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

int ar[3], tmp[6], u = 0;

int main() {
	for (int i = 0; i < 3; i++)
		cin >> ar[i];
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 3; j++)
			for (int k = 0; k < 3; k++) {
				if (i != j && i != k && j != k) {
					tmp[u] = abs(ar[j] - ar[i]) + abs(ar[k] - ar[j]);
					u++;
				}
			}
	sort(tmp, tmp + 6);
	cout << tmp[0];
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;
const double PI = 3.14159265359;

int main()
{
    int a, b; cin >> a >> b;
    if (a <= 0 && 0 <= b)
    {
        cout << "Zero\n";
    }
    else if(0 < a)
    {
        cout << "Positive\n";
    }
    else
    {
        if ((b - a + 1) % 2 == 1)
        {
            cout << "Negative\n";
        }
        else
        {
            cout << "Positive\n";
        }
    }
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false) ; cin.tie(NULL) ; cout.tie(NULL);
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007
#define N 100000

int32_t main(){
IOS;
int n,k;
cin>>n>>k;
int a[n];
for(int i=0;i<n;i++)
cin>>a[i];

vector<int > dp(k+1 , 0);
for(int i=0;i<=k;i++)
{
if(!dp[i])
for(int j=0;j<n;j++)
{
  if(i+a[j] <= k)  
  dp[i+a[j]] = 1;
}
}
if(dp[k])
cout<<"First"<<endl;
else
{
    cout<<"Second"<<endl;
}


}


Measured memory_bytes: 1024
#include<cstdio>
#include<cmath>
#include<algorithm>
#define MAXN 1000

using namespace std;
bool prime[MAXN]={0};//0是素数，1,不是素数
int zhishu[MAXN]={0};//a[i]表示以i为因数的个数

void sushu(){//素数打表
    for(int i=2;i<MAXN;i++){
        if(prime[i]==0){//i是素数
            int j=i;
            while(j+i<MAXN) prime[j+i]=1,j+=i;//i的倍数都不是素数
        }
    }
}
int yinshu(int x){//将x分解为质数的乘积
    for(int i=2;i<=x;i++){
        if(prime[i]==0){
            while(x%i==0){
                zhishu[i]++;
                x/=i;
            }
        }
    }

}

int ai[1000005];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=2;i<=n;i++){
        yinshu(i);
    }
    long long num=1;
    for(int i=2;i<=n;i++){
        if(zhishu[i]!=0){
            num*=zhishu[i]+1;
            num%=(1000000007);
        }
    }
    printf("%lld\n",num);
    return 0;
}



Measured memory_bytes: 128
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll 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 MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,ans=0;
  cin>>n;
  ll a[100001];
  Rep(i,n+1){
    ll x;
    cin>>x;
    if(a[x]==i) ans++;
    a[i]=x;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
/*
        Author: Prokash
                CSE48, JU

*/

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

typedef long long ll;
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int ara[2005];
int main()
{
    FAST;
    ll coin;
    cin>>coin;
    ll d1=coin/500;
    coin=coin-(d1*500);
    ll d2=coin/5;
    coin=coin-(d2*5);
    cout<<(d1*1000)+(d2*5)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
    #define LL long long int
    using namespace std;

    int main()
    {
        // get a integer
      LL a,b,c,d,n,ans=0;
        cin >>n>>a>>b;

      for(int i=1;i<=n;i++)
      {
          LL sum = 0;
          LL tmp = i;
          while(tmp>0)
          {
              sum+=tmp%10;
              tmp/=10;
          }
          if(sum>=a && sum<=b)
            ans+=i;

      }
     cout<<ans;

        return 0;
    }


Measured memory_bytes: 256
import math
N = int(input())
a = list(map(int,input().split()))
s = 0
t = 0
for i in range(N):
    s += a[i]
    t += (a[i])**2
a = math.floor(s/N)
if (s/N) - a > 0.5:
    a += 1
ans = N*a**2 - 2*s*a + t
print(ans)


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

int main(){
  int x,y,a,b,c;
  cin >> x >> y >> a >> b >> c;
  vector<int> p(a),q(b),r(c);
  for(int i=0;i<a;i++) cin >> p.at(i);
  for(int i=0;i<b;i++) cin >> q.at(i);
  for(int i=0;i<c;i++) cin >> r.at(i);
  sort(p.begin(),p.end());
  sort(q.begin(),q.end());
  sort(r.begin(),r.end());
  reverse(p.begin(),p.end());
  reverse(q.begin(),q.end());
  reverse(r.begin(),r.end());
  
  for(int i=0;i<a-x;i++) p.pop_back();
  for(int i=0;i<b-y;i++) q.pop_back();
  vector<int> apples(x+y+c);
  
  for(int i=0;i<x;i++) apples.at(i) = p.at(i);
  for(int i=0;i<y;i++) apples.at(x+i) = q.at(i);
  for(int i=0;i<c;i++) apples.at(x+y+i) = r.at(i);
  sort(apples.begin(),apples.end());
  int64_t ans=0;
  for(int i=0;i<x+y;i++){
    ans += apples.at(x+y+c-1-i);
  }
  cout << ans << endl;
}
    

Measured memory_bytes: 2560
import std.stdio;
import std.string;
import std.algorithm;
import std.conv;
 
void main()
{
    int A, B, r, K;
    auto input = readln.split.to!(int[]);
    A = input[0];
    B = input[1];
    K = input[2];
    while(A%B)
    {
        r = A%B;
        A = B;
        B = r;
    }
  	int[] ans = new int[100];
  	ans[0] = B;
  	int j = 1;
  	for(int i = 2; i <= B; i++) {
    	if(B%i == 0)
        {
          	ans[j] = B / i;
          	j++;
        }
    }
  	writeln(ans[K-1]);
}

Measured memory_bytes: 256
x,n = list(map(int,input().split()))
a = list(map(int,input().split()))
xp = x
xm = x
for i in range(n//2+2):
  if xm not in a:
    print(xm)
    exit(0)
  if xp not in a:
    print(xp)
    exit(0)    
  xp += 1
  xm -= 1

Measured memory_bytes: 9060
from bisect import bisect_right
s = input()
t = input()
sc = [ [] for _ in range(26)]

n = len(s)
for i in range(n):
    p = ord(s[i]) - ord('a')
    sc[p].append(i+1)

for c in t:
    p = ord(c) - ord('a')
    if len(sc[p]) == 0:
        print(-1)
        exit()

ans = 0
x = 0
for c in t:
    p = ord(c) - ord('a')
    if len(sc[p]) == 0:
        print(-1)
        exit()
    tmp = bisect_right(sc[p], x)
    if tmp == len(sc[p]):
        px = x
        x = sc[p][0]
        ans += n - px + x
    else:
        px = x
        x = sc[p][tmp]
        ans += x - px
print(ans)

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

void testcase()
{
	int n, x, t;
	scanf("%d%d%d", &n, &x, &t);
	printf("%d", (n/x + (n%x!=0))*t);
}

int main()
{
	int t = 1;
	//scanf("%d", &t);
	while(t--) {
		testcase();
		puts("");
	}
}


Measured memory_bytes: 3756
n,m=map(int,input().split())
lst=[list(map(int,input().split())) for i in range(m)]

x=[]
y=[]

for i in lst:
  if i[0]==1:
    x+=[i[1]]
    
for i in lst:
  if i[1]==n:
    y+=[i[0]]
    
ans='POSSIBLE'

if len(list(set(x)))+len(list(set(y)))==len(list(set(x+y))):
  ans='IMPOSSIBLE'
    
print(ans)


Measured memory_bytes: 186368
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))


int h, w;
char field[1000][1000];
vector<int> px[30];
vector<int> py[30];
vector<pair<int, int> > cand[30];

void PrintField() {
  REP(y, h) {
    printf("%s\n", field[y]);
  }
}

bool DontHave(int sx, int sy, int ex, int ey, int c) {
  if (sx == ex && sy == ey) { return false; }
  if (sx > ex && sy == ey) { swap(sx, ex); }
  if (sx == ex && sy > ey) { swap(sy, ey); }
  int dx = 0;
  int dy = 0;
  if (sx != ex) { dx++; }
  else { dy++; }
  if (field[sy][sx] == c) { sx += dx; sy += dy; }
  while (sx != ex || sy != ey) {
    if (field[sy][sx] != '.') { return false; }
    sx += dx;
    sy += dy;
  }
  return true;
}

int main() {
  while (scanf("%d %d", &h, &w) > 0) {
    REP(i, 30) {
      cand[i].clear();
      px[i].clear();
      py[i].clear();
    }
    REP(y, h) {
      scanf("%s", field[y]);
    }
    REP(y, h) {
      REP(x, w) {
        if (isupper(field[y][x])) {
          int c = field[y][x] - 'A';
          px[c].push_back(x);
          py[c].push_back(y);
        }
      }
    }
    REP(i, 30) {
      if (px[i].size() == 0) { continue; }
      if (px[i][0] == px[i][1]) {
        int sy = min(py[i][0], py[i][1]) + 1;
        cand[i].push_back(make_pair(px[i][0], sy));
      } else if (py[i][0] == py[i][1]) {
        int sx = min(px[i][0], px[i][1]) + 1;
        cand[i].push_back(make_pair(sx, py[i][0]));
      } else {
        cand[i].push_back(make_pair(px[i][0], py[i][1]));
        cand[i].push_back(make_pair(px[i][1], py[i][0]));
      }
    }

    int ans = 0;
    while (true) {
      bool end = true;
      REP(i, 30) {
        if (px[i].size() == 0) { continue; }
        FORIT(it, cand[i]) {
          if (field[it->second][it->first] != '.') { continue; }
          if (DontHave(px[i][0], py[i][0], it->first, it->second, i + 'A') &&
              DontHave(px[i][1], py[i][1], it->first, it->second, i + 'A')) {
            field[py[i][0]][px[i][0]] = '.';
            field[py[i][1]][px[i][1]] = '.';
            px[i].clear();
            py[i].clear();
            cand[i].clear();
            ans++;
            end = false;
            break;
          }
        }
      }
      if (end) { break; }
    }
    //PrintField();
    printf("%d\n", ans * 2);
  }
}

Measured memory_bytes: 0
def gcd(x, y):
    if x<y:x,y=y,x
    while x % y != 0:
        x, y = y, x % y
    return y
a,b,c,d=map(int,input().split())
c_div=b//c-(a-1)//c
d_div=b//d-(a-1)//d
cd_div=b//(c*d//gcd(c,d))-(a-1)//(c*d//gcd(c,d))
print(b-a+1-c_div-d_div+cd_div)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <vector>
#include <map>

using namespace std;

int main(){
  vector<string> tmpwords;
  map<string, int> words;
  string tmp;
  while(cin >> tmp){

    auto itr = words.find(tmp);
    if(itr!=words.end()){
      words[tmp]++;
    }
    else{
      words.insert( map<string, int>::value_type(tmp, 1));
      // cout << tmp << endl;
    }

  }

  // cout << "here" << endl;
  
  int max=0;
  string maxStr;
  int frequence=0;
  string freStr;
  for(auto itr=words.begin();itr != words.end(); ++itr){
    if(max < (itr->first.size())){
      max = (itr->first.size());
      maxStr = itr->first;
    }
    if(frequence < (itr->second)){
      frequence = itr->second;
      freStr = itr->first;
    }
  }

  cout << freStr << " " << maxStr << endl;
  
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(), v.end()
using namespace std;

ll a,b,c,k,ans,d;

int main()
{

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

    cin >> a >> b >> c >> k;
    d = min( a , k );
    ans+=d;
    k-=d;
    d = min( b , k );
    k-=d;
    cout << ans-k;

    return 0;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int A, B, C; cin >> A >> B >> C;
    if(A + B >= C) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

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

sumL = 0
sumR = sum(W)
mindiff = 100000
for i in W:
  sumL += i
  sumR -= i
  if abs(sumL - sumR) < mindiff:
    mindiff = abs(sumL - sumR)
print(mindiff)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
int n, l, j, u, k, tmp;
int list[100][100];
int lengthlist[100];

void search(int y, int length){
  int i;
  length++;
  lengthlist[y] = length;


  for( i = 0 ; i < n ; i++){
    if( list[y][i] == 1 ){
      if( lengthlist[i] <= length && lengthlist[i] >= 0 ){
        continue;
      }
      search(i, length);
    }
  }
}

int main(){
  scanf("%d", &n);
  for(l = 0 ; l < n ; l++){
    scanf("%d", &u);
    scanf("%d", &k);
    for( j = 0 ; j < k ; j++){
      scanf("%d", &tmp);
      list[u-1][tmp-1] = 1;
    }
  }
  for( l = 0 ; l < n ; l++){
    lengthlist[l] = -1;
  }
  search(0, -1);

  for(j = 0 ; j < n ; j++){
    printf("%d %d\n", j+1, lengthlist[j]);
  }

  return 0;
}



Measured memory_bytes: 2052
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 0;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
bitset<200>dp, dp2;
signed main() {
	dp.set(0);
	for (int i = 0; i < 100; i++) {
		dp2 = dp;
		dp2 <<= 4;
		dp |= dp2;
	}
	for (int i = 0; i < 100; i++) {
		dp2 = dp;
		dp2 <<= 7;
		dp |= dp2;
	}
	if (dp.test(read())) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}

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

int check(int p[],int data[])
{
  int cnt=0;
  for(int i=0;i<8;i++)
    cnt+=max(0,data[i]-p[i]);
  
  return cnt;
}

int makeint(int p[])
{
  int ans=0;
  for(int i=0;i<8;i++)
    {
      ans*=10;
      ans+=p[i];
    }
  return ans;
}

int main()
{
  int p[8];
  for(;cin>>p[0]>>p[1]>>p[2]>>p[3]>>p[4]>>p[5]>>p[6]>>p[7];)
    {
      int data[]={4,1,4,1,2,1,2,1};
      int anscnt=check(p,data);
      int ans[8];
      for(int i=0;i<8;i++)
	  ans[i]=data[i];
      int buf=makeint(data);
      for(int i=0;i<7;i++)
	{	 
	  int tt=data[0];
	  for(int i=0;i<7;i++)
	    data[i]=data[i+1];
	  data[7]=tt;
	  int tmp=check(p,data);
	  int tbuf=makeint(data);
	  if(tmp<anscnt || (tmp==anscnt&&tbuf<buf))
	    {
	      anscnt=tmp;
	      buf=tbuf;
	      for(int i=0;i<8;i++)
		ans[i]=data[i];
	    }
	}
      for(int i=0;i<8;i++)
	{
	  cout<<ans[i];
	  if(i==7)
	    cout<<endl;
	  else
	    cout<<" ";
	}
    }

}

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

int main() {
    int n, k;
    string s;
    cin >> n >> s >> k;
    char c = s[k-1];
    for (int i=0; i<n; i++) {
        if (s[i] != c) s[i] = '*';
    }
    cout << s << endl;
}

Measured memory_bytes: 256
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll					long long
#define MOD					1000000007
#define MAX					1e9
#define MIN                 -1e9
#define PI					acos(-1.0)
#define vi					vector<int>
#define vii					vector<vi>
#define vll					vector<ll>
#define mid(s,e)			(s+(e-s)/2)
#define clz(n)				__builtin_clzll(n))

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
template<typename T>
void printVec(const T &v, char sep=' ') {for (auto &i: v) cout << i << sep;}
template<typename T>
void printVecPair(const T &v, char sep=' ') {for (auto &i: v) cout << i.first <<" " << i.second<< sep;}


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
	int n;
	cin>>n;
	vii dp(2,vi(3));
	for(int i=0;i<n;i++) {
			int c[3];
			for(int j=0;j<3;cin>>c[j++]);
			for(int j=0;j<3;j++) {
					for(int k=0;k<3;k++) {
							if(j!=k) {
									dp[i&1][j] = max(dp[(i+1)&1][k] + c[j],dp[i&1][j]);

							}
					}
			}
			debug(dp);
			
	}
	cout<<max({dp[(n-1)&1][0], dp[(n-1)&1][1], dp[(n-1)&1][2]});
	return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define deb(x) cout << #x << " = "<< x << "\n";

const int maxn = 1e7 + 1;
int a[maxn];

signed main() {
	//freopen("in.txt", "r",stdin);
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int n; cin >> n;
	fill(a, a+n+1, 1);
	for(int i = 2; i <= n; i++) {
		for(int j = i; j <= n; j += i)
			a[j]++;
		a[i] *= i;
	}
	cout << accumulate(a+1, a+n+1, 0ll);
}


Measured memory_bytes: 81716
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

ll dp[44][444][444];
//40*400*400
//2^6*10^5
//6*10^6

int main(){
	ll n, ma, mb, ans=INF;
	cin>>n>>ma>>mb;
	vector<ll> a(n),b(n),c(n);
	rep(i,n){
		cin>>a[i]>>b[i]>>c[i];
	}
	//dpで考える.ここで変数は
	//番号と2の値とvalueであるので
	//3次元dp
	//最小値を出したいのでINFで初期化.
	rep(i,44){
		rep(j,444){
			rep(k,444){
				dp[i][j][k]=INF;
			}		
		}
	}
		
	//何も持たない時のvalueは0
	dp[0][0][0]=0;
	rep(i,n){
		rep(j,401){
			rep(k,401){
				//iを加えない場合.足さないでコストが下がるのか.
				dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
				//iを加える場合.足してコストが下がるのか.
				dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
			}
		}
	}
	rep(i,n+1){
		FOR(j,1,401){
			FOR(k,1,401){
				if(j*mb-k*ma==0){
					ans=min(ans,dp[i][j][k]);
				}
			}
		}
	}


	if(ans==INF){
		cout<<-1<<endl;
	}else{
		cout<<ans<<endl;
	}


	return 0;
}














Measured memory_bytes: 67968
from collections import Counter, deque # https://note.nkmk.me/python-scipy-connected-components/
# from copy import copy, deepcopy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N=int(input())
    A=[int(input()) for i in range(N)]
    AA=Counter(A)

    cnt=0
    for i in AA.values():
        if i%2==1:
            cnt+=1
    print(cnt)



resolve()

Measured memory_bytes: 16628
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define rt return
using dbl = double;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

struct WF {
    int n;
    static const long long INF = 1ll << 60;
    vector<vector<long long>> d;
    WF(int _n) :n(_n), d(_n, vector<long long>(_n, INF)) {
        rep(i, n) d[i][i] = 0;
    }
    void add_edge(int u, int v, long long w) {
        d[u][v] = w;
    }
    void calc() {
        for (int k = 0; k<n; ++k) for (int u = 0; u<n; ++u) for (int v = 0; v<n; ++v)
            if (d[u][k] != INF&&d[k][v] != INF)
                d[u][v] = min(d[u][v], d[u][k] + d[k][v]);
    }
    bool has_negative_cycle() {
        rep(i, n) if (d[i][i]<0) return 1;
        return 0;
    }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M, R;
    cin >> N >> M >> R;
    vi r(R), id(N, -1);
    rep(i, R) {
        cin >> r[i];
        --r[i];
        id[r[i]] = i;
    }
    WF wf(N);
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        --a; --b;
        wf.add_edge(a, b, c);
        wf.add_edge(b, a, c);
    }
    wf.calc();

    const ll INF = LLONG_MAX / 3;
    vector<vll> dp(1ll<<R, vll(N, INF));
    rep(i, N) {
        int S = 0;
        if (id[i] != -1)S = 1 << id[i];
        dp[S][i] = 0;
    }
    rep(S, 1 << R) {
        rep(i, N) {
            rep(j, N)if (i != j) {
                int T = S;
                if (id[j] != -1)T |= 1 << id[j];
                smin(dp[T][j], dp[S][i] + wf.d[i][j]);
            }
        }
    }

    ll ans = INF;
    rep(i, N)smin(ans, dp.back()[i]);
    cout << ans << endl;
}


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

using namespace std;
#define Pi acos(-1)
#define _terminated return 0
#define endl "\n"
#define yes cout << "Yes" << endl 
#define no cout << "No" << endl 
#define booster ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<long> > v2l;

const int mod = 1e+5;
const int mx = 2e+5;
const ll inf = 1e18;

void upper_bubble_sort(){
     int i,j,temp,number_of_input;
     int array[100];
     cin >> number_of_input;
     for(i=0; i<number_of_input; i++)
         cin >> array[i];
         for(i=0; i<number_of_input; i++){
             for(j=0; j<(number_of_input-i-1); j++){
               if(array[j] > array[j+1]){
                 temp = array[j];
                 array[j] = array[j+1];
                 array[j+1] = temp;
                }
              }
         }
    for(i=0; i<number_of_input; i++)
      cout << array[i] << endl;
}
void bst(void){
          int low,high,mid,keynum,num,array[100];
          cin >> keynum;
          low = 1;
	         high = num;
         	do{
		        mid = (low + high) / 2;
		         if(keynum < array[mid])
			         high = mid - 1;
		         else if (keynum > array[mid])
			         low = mid + 1;
	         } 
          while (keynum != array[mid] && low <= high);
	        if(keynum == array[mid]){
            cout << "number located at " << mid +1 << endl;}
         else
           no;
}

void solvio(void){
     long long a,b,k;
     cin >> a >> b >> k;
     long long ans = 0;
     long long temp = max(ans,a-k);
     long long temp1 = max(ans,min(b,a+b-k));
     cout << temp << " " << temp1 << endl;
}

int main(){
    booster;
    solvio();
    _terminated;
} 

Measured memory_bytes: 3620
#include<iostream>
using namespace std;
 
long X,a,b;
 
int main(){
	scanf("%d %d %d",&X,&a,&b);
	     
	
	if(a-b >= 0) printf("delicious\n");
	else if(X+a-b>= 0) printf("safe\n");
	else printf("dangerous\n");
	
	return 0;
}

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

int main(){

    int n;
    cin >> n;
    vector<string> s(n);

    rep(i,n){
        cin >> s[i];
    }

    vector<int> a(26,60);

    for(int i=0;i<n;i++){
        vector<int> b(26,0);
        rep(j,s[i].size()){
            b[s[i][j]-'a']++;
        }
        rep(j,26){
            a[j]=min(a[j],b[j]);
        }
    }

    string AL="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string al="abcdefghijklmnopqrstuvwxyz";

    for(int i=0;i<26;i++){
        for(int j=0;j<a[i];j++){
            cout << al[i];
        }
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,pas;
string s,h;
pair <int, pair <int, int> > dp[3001][3001],l[3009],ll[3009];
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>s>>h;
	if(s.size()==0||h.size()==0){
		return 0;
	}
	for(b=s.size()-1; b>=0; b--){
		for(c=h.size()-1; c>=0; c--){
			if(s[b]!=h[c]) continue;
			if(l[c+1].first!=0){
				dp[b][c].first=1+l[c+1].first;
				dp[b][c].second.first=l[c+1].second.first;
				dp[b][c].second.second=l[c+1].second.second;
			}else{
				dp[b][c].first=1;
			}
			if(ll[c].first<dp[b][c].first){
				ll[c].first=dp[b][c].first;
				ll[c].second.first=b;
				ll[c].second.second=c;
			}
		}
		for(c=h.size()-1; c>=0; c--){
			if(l[c].first<ll[c].first){
				l[c]=ll[c];
			}
      ll[c].first=0;ll[c].second.first=0;ll[c].second.second=0;
			if(c!=h.size()-1&&l[c].first<l[c+1].first){
				l[c]=l[c+1];
			}
		}
	}
	for(b=0; b<s.size(); b++){
		for(c=0; c<h.size(); c++){
			if(dp[b][c].first>pas) pas=dp[b][c].first;
		}
	}
	if(pas==0){
	    return 0;
	}
	for(b=0; b<s.size(); b++){
		for(c=0; c<h.size(); c++){
			if(dp[b][c].first==pas){
				while(1){
					cout<<s[b];
					d=b;
					b=dp[b][c].second.first;
					c=dp[d][c].second.second;
          if(b==0) break;
				}
				return 0;
			}
		}
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
ll H, W;
ll ans = 1e11;
ll fact[100001];

		       
int main() {

  cin >> H >> W;

  for(ll i = 1; i <= min(H,W); i++) fact[i] = i * i;
  
  for(ll i = 1; i <= H/2; i++) {
    ll s1 = i * W;
    ll i_1 = (H-i)/2;
    ll i_2 = H-i_1-i;
    
    ll max_S = max(max(s1,i_1*W),i_2*W);
    ll min_S = min(min(s1,i_1*W),i_2*W);
    ans = min(ans,max_S-min_S);
  }
  

  for(ll i = 1; i <= W/2; i++) {
    ll s1 = i * H;
    ll i_1 = (W-i)/2;
    ll i_2 = W-i_1-i;
 
      ll max_S = max(max(s1,i_1*H),i_2*H);
      ll min_S = min(min(s1,i_1*H),i_2*H);
      ans = min(ans,max_S-min_S);
    }
  
  
  for(ll i = 1; i < W; i++) {
    ll s1 = i * H;
    ll i_1 = H/2;
    ll i_2 = H-i_1;
    ll s2 = i_1 * (W-i);
    ll s3 = i_2 * (W-i);
  
      ll max_S = max(max(s1,s2),s3);
      ll min_S = min(min(s1,s2),s3);
      ans = min(ans,max_S - min_S);
    }
  

  for(ll i = 1; i < H; i++) {
    ll s1 = i * W;
    ll i_1 = W/2;
    ll i_2 = W-i_1;
    ll s2 = i_1 * (H-i);
    ll s3 = i_2 * (H-i);
  
      ll max_S = max(max(s1,s2),s3);
      ll min_S = min(min(s1,s2),s3);
      ans = min(ans,max_S - min_S);
    }
  

  cout << ans << endl;
}


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

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<>());

    if (s < t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
const int mxn=1e5+100;
int dp[mxn][3],n,act[mxn][3],hlp;
bool cal[mxn][3];
int dpf (int d, int a)
{
    ///d==day , a==activity
    if (cal[d][a]==true)
        return dp[d][a];
    cal[d][a]=true;
    for (int i=0;i<3;i++)
        if (i!=a)
        {
            hlp=dpf(d-1,i)+act[d][a];
            dp[d][a]=max(dp[d][a],hlp);
        }
    return dp[d][a];
}
int main()
{
    cal[0][0]=cal[0][1]=cal[0][2]=true;
    cin>>n;
    for (int i=0;i<n;i++)
        for (int j=0;j<3;j++)
        cin>>act[i][j];
    dp[0][0]=act[0][0];
    dp[0][1]=act[0][1];
    dp[0][2]=act[0][2];
    cout<<max(dpf(n-1,0),max(dpf(n-1,1),dpf(n-1,2)))<<endl;
    return 0;
}


Measured memory_bytes: 9088
mod=10**9+7
n,k=map(int,input().split())
ans=0
comb1=1
comb2=1
for i in range(min(k+1,n)):
  ans+=comb1*comb2
  ans%=mod
  comb1*=(n-i)*pow(i+1,mod-2,mod)
  comb1%=mod
  comb2*=(n-1-i)*pow(i+1,mod-2,mod)
  comb2%=mod
print(ans)

Measured memory_bytes: 3064