akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int N;
vector<vector<int> > graph(N, vector<int>(0));
vector<vector<int> > children(N, vector<int>(0));
vector<long long> cnt(N, 0);
vector<bool> seen(N, false);

void child(int id, int parent)
{
    //cout << "child呼び出し: " << id << endl;
    for (int i=0; i<graph[id].size(); i++)
    {
        if (graph[id][i]!=parent)
        {
            children[id].push_back(graph[id][i]);
            child(graph[id][i], id);
        }
    }
}

void flow(int id)
{
    if (!seen[id])
    {
        seen[id] = true;
        for (int i=0; i<children[id].size(); i++)
        {
            int child = children[id][i];
            cnt[child] += cnt[id];
            flow(child);
        }
    }
}

int main()
{
    int Q;
    cin >> N >> Q;
    graph = vector<vector<int> > (N, vector<int>(0));
    children = vector<vector<int> > (N, vector<int>(0));
    cnt = vector<long long> (N, 0);
    seen = vector<bool> (N, false);
    for (int i=0; i<N-1; i++)
    {
        int a, b;
        cin >> a >> b;
        graph[a-1].push_back(b-1);
        graph[b-1].push_back(a-1);
    }

    child(0, -1);
    /*
    for (int i=0; i<N; i++)
    {
        cout << i <<"の子供: ";
        for (int j=0; j<children[i].size(); j++)
        {
            cout << children[i][j] << " ";
        }
        cout << endl;
    }
    */
    seen = vector<bool> (N, false);

    for (int i=0; i<Q; i++)
    {
        seen = vector<bool> (N, false);
        int p, x;
        cin >> p >> x;
        cnt[p-1] += x;
    }
    flow(0);
    for (int i=0; i<N; i++) cout << cnt[i] << " ";
    cout << endl;
}

Measured memory_bytes: 48648
n=int(input())
P=[2]
for i in range(3,n+1):
  flag=1
  for p in P:
    if i%p==0:
      flag=0
  if flag==1:
    P.append(i)
ans=1
for p in P:
  np=0
  x=1
  while p**x<=n:
    np+=n//(p**x)
    x+=1
  ans*=(1+np)
print(ans%(10**9+7))


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n;
string s;

int main(){
	cin >> n;
	cin.ignore();
	REP(i, n){
		getline(cin, s);
		while (s.find("Hoshino") != -1){
			s[s.find("Hoshino") + 6] = 'a';
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 1204
#ifndef ONLINE_JUDGE
  #include "Debug.h"
#else
  #define debug(...) 42
#endif
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7, N = 5e5 + 10;
const int LINF = LLONG_MAX;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h,w,m;
    cin >> h >> w >> m;
    map<pair<int,int>,int>maps;
    f(i,1,m+1){
        int x,y;
        cin >> x >> y;
        maps[{x,y}] = 1;
    }
    vector<int>row(h+1,0),col(w+1,0);
    for(auto s : maps){
        row[s.first.first]++;
        col[s.first.second]++;
    }
    vector<int>x,y;
    int ans = 0;
    for(auto s : maps){
        x.push_back(s.first.first);
        y.push_back(s.first.second);
    }
    int a = x.size();
    int b = y.size();
    int ind_x,ind_y;
    int ma_x = 0,ma_y = 0;
    f(i,1,h+1){
        if(row[i] > ma_x){
            ma_x = row[i];
            ind_x = i;
        }
    }
    f(i,1,w+1){
        ans = max(ans,col[i] + ma_x - maps[{ind_x,i}]);
    }
    f(i,1,w+1){
        if(col[i] > ma_y){
            ma_y = col[i];
            ind_y = i;
        }
    }
    debug(ans,ma_y,ind_y);
    f(i,1,h+1){
        ans = max(ans,row[i] + ma_y - maps[{i,ind_y}]);
    }
    cout << ans << "\n";

    return 0;
}
 


Measured memory_bytes: 68856
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val x = sc.nextInt()
    val y = sc.nextInt()
    println(problem160d(n, x, y))
}

fun problem160d(n: Int, x: Int, y: Int): String {
    val routes = Array(n) { mutableListOf<Int>() }
    for (i in 0 until n - 1) {
        routes[i].add(i + 1)
        routes[i + 1].add(i)
    }
    routes[x - 1].add(y - 1)
    routes[y - 1].add(x - 1)

    val distances= Array(n - 1) { IntArray(n) { -1 } }
    val counts = hashMapOf<Int, Int>()

    for (i in 0 until n - 1) {
        val queue = ArrayDeque<Int>()
        queue.offer(i)
        distances[i][i] = 0

        while(!queue.isEmpty()) {
            val current = queue.poll()
            for (j in 0 until routes[current].size) {
                val next = routes[current][j]
                if (distances[i][next] != -1) continue
                distances[i][next] = distances[i][current] + 1
                queue.offer(next)
            }
        }
        distances[i] = distances[i].drop(i + 1).toIntArray()
        for (j in 0 until distances[i].size) {
            counts[distances[i][j] + 1] = (counts[distances[i][j] + 1] ?: 0) + 1
        }
    }

    val ans = Array(n - 1) { 0 }
    var count = 0
    for (i in counts) {
        ans[count] = i.value
        count++
    }

    return ans.joinToString("\n")
}

Measured memory_bytes: 87360
#include "bits/stdc++.h"
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint A, B, C;
int main() {
	cin >> A >> B >> C;
	cout << B / C - (A - 1) / C << endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll n, m, k, a, b, c, d, ans;
vector<ll> to(100000);
vector<vector<ll>> block(100000);

struct UnionFind {
	vector<ll> d;
	UnionFind(int n) :d(n, -1){}
	ll find(ll x) {
		if (d[x] < 0)return x;
		return d[x] = find(d[x]);
	}
	bool unite(ll x, ll y) {
		x = find(x);
		y = find(y);
		if (x == y)return false;
		if (d[x] < d[y])swap(x, y);
		d[y] += d[x];
		d[x] = y;
		return true;
	}
	ll size(ll x) {
		return -d[find(x)];
	}
	bool same(ll x, ll y){
		return find(x) == find(y);
	}
};

int main() {
	cin >> n >> m >> k;
	UnionFind uf(n);
	rep(i, m) {
		cin >> a >> b;
		a--;
		b--;
		to[a]++;
		to[b]++;
		uf.unite(a, b);
	}
	rep(i, k) {
		cin >> c >> d;
		c--;
		d--;
		block[c].push_back(d);
		block[d].push_back(c);
	}
	rep(i, n) {
		ans = uf.size(i) - to[i] - 1;
		rep(j, sz(block[i])) {
			if (uf.same(i, block[i][j]))ans--;
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
	int n, k, q; cin >> n >> k >> q;
	vector<int>answers(n, k-q);
	vector<int>a(q); 
	for (auto&& x : a) {
		cin >> x;
		answers[x-1]++;
	}

	for (auto&& x : answers) {
		if (x <= 0)cout << "No" << endl;
		else cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 1408
function Main(input) {
  let n = parseInput(input)[0][0];
  console.log(Math.ceil(n/2) / n);
}

function parseInput(input) {
  const lines = input.trim().split('\n');
  return lines.map(line => line.split(' '));
}

Main(require('fs').readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
<?php

class UnionFind
{
    private $parents = [];

    public function __construct($n)
    {
        $this->parents = array_fill(0, $n, -1);
    }

    public function size($A)
    {
        return -1 * $this->parents[$this->root($A)];
    }

    public function root($A)
    {
        if ($this->parents[$A] < 0) {
            return $A;
        }

        $this->parents[$A] = $this->root($this->parents[$A]);
        return $this->parents[$A];
    }

    public function connect($A, $B)
    {
        $ra = $this->root($A);
        $rb = $this->root($B);

        if ($ra == $rb) {
            return false;
        }

        if ($this->size($ra) > $this->size($rb)) {
            $this->parents[$ra] += $this->parents[$rb];
            $this->parents[$rb] = $ra;
        } else {
            $this->parents[$rb] += $this->parents[$ra];
            $this->parents[$ra] = $rb;
        }
        return true;
    }
}

fscanf(STDIN, "%d %d", $n, $m);
$A = [];
$B = [];
for ($i = 0; $i < $m; ++$i) {
    fscanf(STDIN, "%d %d", $a, $b);
    --$a;
    --$b;
    $A[] = $a;
    $B[] = $b;
}

$uni = new UnionFind($n);
$ans = [];
$ans[$m - 1] = $n * ($n - 1) / 2;

for ($i = $m - 2; $i >= 0; --$i) {
    if ($uni->root($A[$i + 1]) != $uni->root($B[$i + 1])) {
        $ans[$i] = $ans[$i + 1] - $uni->size($A[$i + 1]) * $uni->size($B[$i + 1]);
        $uni->connect($A[$i + 1], $B[$i + 1]);
    } else {
        $ans[$i] = $ans[$i + 1];
    }
}

for ($i = 0; $i < $m; ++$i) {
    echo $ans[$i], PHP_EOL;
}


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

int n, k;
int rnk[1000001];
int tmp[1000001];

bool compare_sa(int i, int j){
    if(rnk[i] != rnk[j]){
        return rnk[i] < rnk[j];
    }else{
        int ri = i+k <= n ? rnk[i+k] : -1;
        int rj = j+k <= n ? rnk[j+k] : -1;
        return ri < rj;
    }
}

void construct_sa(string s, int *sa){
    n = s.length();
    for(int i = 0; i <= n; i++){
        sa[i] = i;
        rnk[i] = i < n ? s[i] : -1;
    }
    for(k = 1; k <= n; k *= 2){
        sort(sa, sa+n+1, compare_sa);
        tmp[sa[0]] = 0;
        for(int i = 1; i <= n; i++){
            tmp[sa[i]] = tmp[sa[i-1]] + (compare_sa(sa[i-1], sa[i]) ? 1 : 0);
        }
        for(int i = 0; i <= n; i++){
            rnk[i] = tmp[i];
        }
    }
}

bool contain(string s, int *sa, string t){
    int a = 0, b = s.length();
    while(b - a > 1){
        int c = (a+b)/2;
        if(s.compare(sa[c], t.length(), t) < 0) a = c;
        else    b = c;
    }
    return s.compare(sa[b], t.length(), t) == 0;
}

int main(){
    string s;
    cin >> s;
    n = s.length();
    int sa[n];
    construct_sa(s, sa);
    int q;
    cin >> q;
    while(q-- > 0){
        string t;
        cin >> t;
        cout << contain(s, sa, t) << endl;
    }
    return 0;
}


Measured memory_bytes: 16620
#include<map>
#include<set>
#include<cmath>
#include<ctime>
#include<queue>
#include<tuple>
#include<cstdio>
#include<string>
#include<vector>
#include<cassert>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
long long H, W, a, b, x[900][900];
int main() {
	cin >> H >> W >> a >> b; if (a == 1 && b == 1) { cout << "No" << endl; return 0; }
	long long c = 999999999 / (a*b - 1);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (i%a == (a - 1) && j%b == (b - 1))x[i][j] = -(a*b*c) + (c - 1);
			else x[i][j] = c;
		}
	}
	long long sum = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			sum += x[i][j];
		}
	}
	if (sum <= 0)cout << "No" << endl;
	else {
		cout << "Yes" << endl;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (j)cout << ' '; cout << x[i][j];
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 7040
# A - Frog 1
def main():
    N, *H = map(int, open(0).read().split())
    H = [0] + H + [0, 0]
    dp = [1 << 30] * (N + 3)
    dp[1] = 0
    for i, a in enumerate(H[1:N + 1], 1):
        for j, b in enumerate(H[i + 1:i + 3], i + 1):
            dp[j] = min(dp[j], dp[i] + abs(a - b))
    print(dp[N])


if __name__ == "__main__":
    main()


Measured memory_bytes: 13876
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        //int n = Integer.parseInt(sc.nextLine());
        
        String  str[] = new String[3];
        
        
        //for(int i = 0; i < 3 ; i++){
        //    str[i] = sc.next();
        //}
        //
        //int A= Integer.parseInt(str[0]);
        //int B= Integer.parseInt(str[1]);
        //int C= Integer.parseInt(str[2]);

       //for(int i = 0; i < 3 ; i++){
       //    System.out.println(str[i]);
       // }
        
        int A = sc.nextInt();
        int B =sc.nextInt();
        int C = sc.nextInt();
        
        int k = sc.nextInt();
        
        //System.out.println(A);  
        //System.out.println(B);  
        //System.out.println(C);  
        //System.out.println(k);  
        
        int nokori = k;
        
        for(int i = 0; i < k ; i++){
            if( B > A){
                break;  
            }else{
                B = B + B;
                nokori = nokori - 1;
            }
       }
       
       if(nokori >0){
           for(int i = 0; i < nokori ; i++){
               if( C > B){
                   break;  
               }else{
                   C = C + C;
               }
               
           }
          
       }
           
           //System.out.println("totyu");  
   
           //System.out.println(A);  
           //System.out.println(B);  
           //System.out.println(C); 
           
           
       if( A < B ){
           
           if(B<C){
               System.out.println("Yes");  
           }else{
               System.out.println("No");  
           }
       }else{
           System.out.println("No");  
       }
       
       }
       
           

}



Measured memory_bytes: 35928
s = gets.chomp

ans = "Yes"
s.length.times do |i|
  nows =  s[i]
  if((i+1)%2 == 1)
    ans = "No" if(nows !~ /[RUD]/)
  else
    ans = "No" if(nows !~ /[LUD]/)
  end
end

puts ans

Measured memory_bytes: 3836
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9;
static const ll INF = 1LL << 50;
using namespace std;

int main() {//bit全探索
	ll d, g;
	ll minv = INF;
	cin >> d >> g;
	vector<ll>p(d), c(d);
	repp(i, 0, d) {
		cin >> p[i] >> c[i];
	}
	for (int bit = 0; bit < (1 << d); ++bit) {
		ll sum = 0; ll count = 0;
		for (ll i = 0; i < d; ++i) {
			if (bit & 1 << i) {
				sum += (i + 1) * 100*p[i] + c[i];
				count += p[i];
			}
		}
		if (sum >= g)minv = min(count, minv);
		else {
			for (ll i = d - 1; i >= 0; --i) {
				if (bit & 1 << i)continue;
				for (ll j = 0; j < p[i]; ++j) {
					if (sum >= g)break;//breakでは一つのループからしか抜けられないので何も足さないでbreakも可にする
					sum += (i + 1) * 100;
					++count;
				}
			}
				minv = min(count, minv);
		}
	}
	cout << minv << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
int main() {
    int n;cin >> n;
    vi a(n+1);
    vi ans;
    ll sum = 0;
    a[0] = 0;
    rep1(i, n) {
        cin >> a[i];
        int k = abs(a[i]-a[i-1]);
        sum += k;
        ans.pb(k);
        if(i==n) {
            ans.pb(abs(a[i]));
            sum += abs(a[i]);
        }
    }
    a.pb(0);
    /*for(auto p:a) cout << p << ' ';
    cout << endl;
    cout << sum << endl;
    for(auto p:ans) cout << p << ' '; // 確認済
    cout << endl;*/
    rep1(i, n) {
        int Sum = sum;
        Sum -= ans[i]+ans[i-1];
        Sum += abs(a[i+1]-a[i-1]);
        cout << Sum << endl;
    }
    return 0;
}

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

N = int(input())
S = input()

num_of_slimes = 1
color_of_left = S[0]

for i in range(1, N):
    if S[i] != color_of_left:
        num_of_slimes += 1
    color_of_left = S[i]

print(num_of_slimes)

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

typedef long long ll;
const int N = 1e5+5;

int n;

int sum(int x){
	int ans = 0;
	while(x){
		ans += x % 10;
		x /= 10;
	}
	return ans;
}

int main(){
	cin >> n;
	int ans = 1e5;
	for(int a = 1;a < n;a++){
		int b = n - a;
		ans = min(ans , sum(a) + sum(b));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int jc[524288],injc[524288];
int sol1(int x,int y)
{
	if(x<0||y<0)
	{
		return 0;
	}
	int ans=jc[x+y];
	ans=(long long)ans*injc[x]%998244353;
	ans=(long long)ans*injc[y]%998244353;
	return ans;
}
int sol(int x,int y,int lim)
{
	if(x<0||y<0||lim<0)
	{
		return 0;
	}
	lim++;
	int ans=sol1(x,y);
	ans-=sol1(y-lim,x+lim);
	if(ans<0)
	{
		ans+=998244353;
	}
	return ans;
}
int main()
{
	injc[1]=1;
	for(int i=2;i<=500000;i++)
	{
		injc[i]=(long long)998244353/i*injc[998244353%i]%998244353;
		injc[i]=998244353-injc[i];
	}
	jc[0]=1;
	injc[0]=1;
	for(int i=1;i<=500000;i++)
	{
		jc[i]=(long long)jc[i-1]*i%998244353;
		injc[i]=(long long)injc[i-1]*injc[i]%998244353;
	}
	int n,k;
	scanf("%d%d",&n,&k);
	int ans=0;
	for(int r=0;r<=k;r++)
	{
		int b=k-r;
		if(b>r)
		{
			continue;
		}
		if(b==r)
		{
			ans+=sol(r,r-1,b-n);
		}
		else
		{
			ans+=sol(r,b,b-(n-(r-b)));
		}
		if(ans>=998244353)
		{
			ans-=998244353;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <utility>
#include <tuple>
using namespace std;
int main() {
    int N; cin >> N;
    vector<tuple<string, int, int>> T(N);
    for (int i=0;i<N;i++){
        string s; cin >> s;
        int p; cin >> p;
        T[i] = make_tuple(s, -1*p, i+1);
    } 
    sort(T.begin(),T.end());
    for (int i=0;i<N;i++){
        cout << get<2>(T[i]) << endl;
    }

    return 0;
}

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

using ll = long long;
const int MOD = 998244353;

ll powmod(ll a, ll b) {
  a %= MOD;
  ll res = 1;
  while (b > 0) {
    if (b % 2 == 1) res = res * a % MOD;
    a = a * a % MOD;
    b /= 2;
  }
  return res;
}
ll f[210000];
void cominit() {
  f[0] = 1;
  for (int i = 0; i < 200000; i++) {
    f[i + 1] = f[i] * (i + 1) % MOD;
  }
}

ll nCr(ll n, ll r) {
  if (n < r) return 0;
  if (n < 0 or r < 0) return 0;
  return f[n] * powmod(f[r] * f[n - r], MOD - 2) % MOD;
}

ll nPr(ll n, ll r) {
  if (n < r) return 0;
  if (n < 0 or r < 0) return 0;
  return f[n] * powmod(f[n - r], MOD - 2) % MOD;
}

ll nHr(ll n, ll r) {
  if (n < r) return 0;
  if (n < 0 or r < 0) return 0;
  return nCr(n + r - 1, r);
}

int main() {
  ll n, m, k;
  cin >> n >> m >> k;
  cominit();
  ll ans = 0;
  for (int i = 0; i < k + 1; i++) {
    ll res = nCr(n - 1, i);
    res *= m * powmod(m - 1, n - i - 1) % MOD;
    res %= MOD;
    ans = (ans + res) % MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 5208
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
#define pb push_back
#define ll long long int
# define pll pair<ll,ll>
# define fio ios_base::sync_with_stdio(false); cin.tie(NULL)
# define ft first
# define sec second
ll a[200009];
ll  k ;
int n;
bool f(ll t)
{   int cnt= 0 ;
    for(int i= 1 ; i<= n ; i++)
    {
        if(a[i]>t) cnt += (a[i]-1)/t;
    }
    return cnt<=k ;
}
ll upper_bound(ll l , ll r)
{
    if(l<r)
    {
        ll mid=(l+r)/2;

        if(f(mid)) return upper_bound(l,mid);
        return upper_bound(mid+1,r);
    }
     return l;

}
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n ; i++) cin>>a[i];
    cout<<upper_bound(1,1e9);
}



Measured memory_bytes: 4688
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> p(n), q(n), pp;
    for(auto &i : p) {
        cin >> i;
    }

    for(auto &i : q) {
        cin >> i;
    }

    // # fill pp
    for(int i = 1; i <= n; i++) {
        pp.push_back(i);
    }

    int a = 0, b = 0, curr = 0;
    do {
        curr++;
        if(p == pp) a = curr;
        if(q == pp) b = curr;
    }while(next_permutation(pp.begin(), pp.end()));

    cout << abs(a-b);
    return 0;
}

Measured memory_bytes: 256
import numpy as np

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

N = N_W[0]
W = N_W[1]

w = []
v = []

for i in range(N):
    w_v =  list(map(int,input().split()))
    w.append(w_v[0])
    v.append(w_v[1])

dp = np.zeros(W+1,int)

for w1,v1 in zip(w,v):

    dp[w1:] = np.maximum(dp[w1:],dp[:W-w1 + 1] + v1)

print(dp.max())

Measured memory_bytes: 15496
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

const ll U = 1e18;

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

ll mul(ll a, ll b) {
  ll ret = 0;
  while (b) {
    if (b & 1)
      ret = (ret + a) % U;
    b >>= 1;
    a = (a + a) % U;
  }
  return ret;
}

int main() {
#ifdef ELEGIA
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  map<ll, int> mp;
  ll ans = 0;
  while (n--) {
    string s;
    cin >> s;
    ll y;
    if (s.find('.') == s.npos) {
      sscanf(s.c_str(), "%lld", &y);
      y *= 1e9;
    } else {
      int a, b;
      int pos = s.find('.');
      sscanf(s.substr(0, pos).c_str(), "%d", &a);
      sscanf(s.substr(pos + 1).c_str(), "%d", &b);
      y = a * (ll) 1e9;
      int t = s.length() - 1, cn = 1e9;
      while (s[t] != '.') {
        --t;
        cn /= 10;
      }
      y += b * cn;
    }
    cerr << y << '\n';
    y = gcd(U, y);
    ++mp[y];
  }
  for (auto pr : mp)
    for (auto qr : mp) {
      if (mul(pr.first, qr.first) == 0) {
        if (pr.first == qr.first)
          ans += pr.second * (pr.second - 1LL) / 2;
        else if (pr.first < qr.first)
          ans += pr.second * (ll) qr.second;
      }
    }
  cout << ans << '\n';

#ifdef ELEGIA
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P = pair<int, int>;

template <class T>
bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    } else {
        return false;
    }
}
template <class T>
bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    } else {
        return false;
    }
}

template <class T>
void dump_vec(const vector<T>& v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} FASTIO;

//---------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------

signed main() {
    int N;
    cin >> N;
    vector<int> ans(N);
    rep(i, 0, N - 1) {
        int a;
        cin >> a;
        a--;
        ans[a]++;
    }

    for (auto a : ans) {
        cout << a << "\n";
    }
}


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

int main() {
    int a, b;
    scanf("%d%d", &a, &b);
    int r = 0;
    for (int i = a; i <= b; i++) {
        int s = i % 10, t = i / 10000 % 10;
        int u = i / 10 % 10, v = i / 1000 % 10;
        if (s == t && u == v) r++;
    }
    printf("%d\n ", r);
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n;
  cin >> n;
  vector<LL> a(n),hugou(n,0);
  for(LL i=0;i<n;i++){
    cin >> a[i];
    a[i]-=i+1;
  }
  sort(a.begin(),a.end());
  LL ans=0;
  for(LL i=0;i<n;i++){
    ans+=max(a[i]-a[n/2],a[n/2]-a[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int i[11111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=1,f=0;
  string s;
  cin >>a>>b;
  cout  <<max(a+b,max(a-b,a*b))<<'\n';
  return (0);
}


Measured memory_bytes: 256
//we'll get thru it believe me 
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rep2(r, aa, bb) for (int r = (aa)-1; r >= (bb); r--)
#define be(x) (x.begin(), x.end())
#define pb(t) push_back(t)
#define ll long long
#define mp(a, b) make_pair(a, b)
int n, m, maxi=0;
const int MAX=1e5+1;
vector<vector<int>>A(MAX);
vector<int>dp(MAX, 1),vis(MAX);
void dfs(int v){
	vis[v]=1;
	for(int u:A[v]){
		if(!vis[u])dfs(u);
		dp[v]=max(dp[v], dp[u]+1);
	}
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	cin>>n>>m;
	for(int i=0, a, b; i<m; i++){
		cin>>a>>b;
		A[a].push_back(b);
	}
	for(int i=1; i<=n; i++){
		if(!vis[i])dfs(i);
		maxi=max(maxi, dp[i]);
	}
	cout<<maxi-1<<"\n";
}


Measured memory_bytes: 8576
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};



int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;
	cin >> a >> b;
	
	cout << max(max(a + b, a - b), a * b);
	
	
		
	
	
	
	
}
	

Measured memory_bytes: 256
#include <iostream>

using namespace std;


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

    for (int i=0; i<100; i++) {
        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            break;
        }
        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void) {
	int a,b,c;
	int cnt = 0;
	int i = 0;
	scanf("%d%d%d", &a, &b, &c);
	while(a <= b) {
		i = c%a;
		if (i == 0) cnt++;
		a++;
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
  string station;

  cin >> station;
  if (station[0]==station[1]&&station[1]==station[2]){
    cout << "No"<< endl;
  }else{
    cout << "Yes" << endl;
      }
  
  return 0;
}

Measured memory_bytes: 256
N = int(input())
ST = []
cnt = 0
for _ in range(N):
    s, t = input().split()
    ST.append([s, t])
    cnt += int(t)
X = input()

for i in range(N):
    s, t = ST[i]
    cnt -= int(t)
    if s == X:
        break
print(cnt)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
inline ll LCM(ll a, ll b){return a / GCD(a, b) * b;}
inline ll powint(ll x, ll y){ll r=1;while(y){if(y&1)r*=x;x*=x;y>>=1;}return r;}
inline ll powmod(ll x, ll y, ll m = MOD){ll r=1;while(y){if(y&1)r*=x;x*=x;r%=m;x%=m;y>>=1;}return r;}
/* END OF TEMPLATE */

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    vll a(6);
    rep(i, 6){
        cin >> a[i];
    }
    repr(i, 1, 5){
        if(count(ALL(a), i) == 3){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int sum=0;
    sum+=min(a,k);
    k-=min(a,k);
    sum+=0*min(b,k);
    k-=min(b,k);
    sum+=-1*min(c,k);
    k-=min(c,k);
    cout << sum;
}

Measured memory_bytes: 3652
using System;

namespace ABC106_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            if (N >= 195)
            {
                Console.WriteLine(5);
            }
            else if (N >= 189)
            {
                Console.WriteLine(4);
            }
            else if (N >= 165)
            {
                Console.WriteLine(3);
            }
            else if (N >= 135)
            {
                Console.WriteLine(2);
            }
            else if (N >= 105)
            {
                Console.WriteLine(1);
            }
            else
            {
                Console.WriteLine(0);
            }
        }
    }
}



Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();

		int ans = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'R') {
				ans++;
			} else {
				ans--;
			}
		}

		System.out.println(ans > 0 ? "Yes" : "No");

		sc.close();
	}
}


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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  for (int i=0; i<N; i++){
    cin >> h.at(i);
  }

  vector<int> cost(N);
  cost[0] = 0;
  cost[1] = abs(h[1] - h[0]);
  for(int i=2; i<N; i++) {
    int c1 = abs(h[i] - h[i-2]) + cost[i-2];
    int c2 = abs(h[i] - h[i-1]) + cost[i-1];
    if (c1 < c2) {
      cost[i] = c1;
    } else {
      cost[i] = c2;
    }
  }

  cout << cost[N-1] <<endl;

  return 0;
}

Measured memory_bytes: 1024
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compw(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}

uint32_t nextpint(void){ char c=getchar(); while(c<'0'||'9'<c) c=getchar(); uint_fast32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return x; }

int gcd2(int a, int b){ int t; if(a>b) t=a, a=b, b=t; t = b % a; while(t!=0){ b = a; a = t; t = b % a; } return a; }

int lcm[1000001];

void p(u_int a){
	int g, i, j;
	i=2; g=0; while(a%i==0){a/=i; g++;} if(g>lcm[i]){lcm[i]=g;}
	i=3; g=0; while(a%i==0){a/=i; g++;} if(g>lcm[i]){lcm[i]=g;}
	i=5; g=0; while(a%i==0){a/=i; g++;} if(g>lcm[i]){lcm[i]=g;}
	if(a==1) return;
	int l=sqrt(a);
	for(j=6; j<l; j+=6){
		i=j+1; g=0; while(a%i==0){a/=i; g++;} if(g>lcm[i]){lcm[i]=g;}
		i=j+5; g=0; while(a%i==0){a/=i; g++;} if(g>lcm[i]){lcm[i]=g;}
	}
	if(a!=1){
		if(lcm[a]==0) lcm[a]=1;
	}
}

int r[1000001];
int a[10000];
int main(int argc, char *argv[], char *envp[]){
	r[1]=1;
	for(int i=2; i<=1000000; i++){
		r[i]=P-((long)P/i*r[P%i])%P;
	}
	int n=nextpint();
	for(int i=0; i<n; i++){
		a[i]=nextpint();
		p(a[i]);
	}
	unsigned long f=1;
	for(int i=2; i<=1000000; i++){
		for(int j=lcm[i]-1; j>=0; j--){
			f=f*i%P;
		}
	}
	unsigned long ans=0;
	for(int i=0; i<n; i++){
		ans = (ans + f * r[a[i]]) %P;
	}
	printf("%ld\n", ans);
}


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

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

    vector<int> cnt(100001);
    for (int i = 0; i < N; i++)
        cnt[A[i]]++;

    int res = 0;
    for (int i = 1; i < 100000; i++)
        res = max(res, cnt[i - 1] + cnt[i] + cnt[i + 1]);

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
#define n_max 100000

#define rep(i, a, n) for(int i = a; i < n; i++)
#define rep2(i, a, n) for(int i = a; i <= n; i++)
#define rrep(i, a, n) for(int i = a; i > n; i--)
#define rrep2(i, a, n) for(int i = a; i >= n; i--)
#define lrep(i, a, n) for(long int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

int main()
{
    int ans=0;
    int A, B;
    int useable = 1;
    bool loop = true;
    int tap = 0;

    cin >> A >> B;

    while (loop) {
        if(useable >= B) { loop = false; break;} 
        for(int i = 1; i <= useable; i++) {
            tap++;
            int socket = A * i;
            if((socket + useable - i) >= B) { 
                loop = false;
                break;
            }
        }
        useable *= A;
    }
    
    cout << tap << endl;

    return 0;
}


Measured memory_bytes: 256
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
const int MOD = 1000000007;

#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()
#define s_exists(elem, s) s.find(elem)!=s.end()
#define mod_mul(x, y) x*y%MOD
#define mod_add(x, y) (x+y)%MOD
#define mod_sub(x, y) (x-y)%MOD
#define INF_INT 2147483647

typedef std::vector<std::vector<int>> Matrix;

long gcd(long a, long b) {
    return b == 0 ? a : gcd(b, a % b);
}

long lcm( long m, long n ){
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n);
}


long nCr(long n, long r){
    if(n==r || r==0){
        return 1;
    } else {
        return mod_add(nCr(n-1,r),nCr(n-1,r-1));
    }
}


Matrix dist;
std::vector<int> r;
int N,M,R;
int ans = INF_INT;

void warshall_floyd(int n){
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            for (int k = 0; k < n; k++) {
                dist[j][k] = min(dist[j][k], dist[j][i]+dist[i][k]);
            }
        }
    }
}




int main(){
    string N; cin >> N;
    int ans = 0;
    for (int i = 0; i < N.length(); i++) {
        /* code */
        if(N[i] == '2'){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 256
def solve(A, inc):

    ans = 1
    N = len(A)
    l = []
    for i in range(1, N):
        if A[i] > A[i-1]:
            l.append(1)
        elif A[i] < A[i-1]:
            l.append(-1)

    for i in range(1, len(l)):
        if l[i]*l[i-1] < 0:
            l[i] = 0
            ans += 1
    return ans


N = int(input())
A = list(map(int, input().split()))

print(solve(A, True))


Measured memory_bytes: 14252
import sys
import os


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

    n,k,x,y = (int(sys.stdin.readline().rstrip()) for i in range(4))

    print(k*x+(min(0,(n-k)*x))+(max(0,(n-k)*y)))


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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;
}

signed main() {
  int N; cin >> N;
  vector<int> data(N);
  int sumxor = 0;
  rep(i,N){
    cin >> data[i];
    sumxor = sumxor xor data[i];
  }
  rep(i, N) {
    cout << (data[i] xor sumxor) << endl;
  }
  
}

Measured memory_bytes: 4760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vpi = vector<pii>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpl = vector<pll>;
using vs = vector<string>;

int main()
{
    ll n, k;
    cin >> n >> k;
    vl hs(n);
    for(int i=0; i<n; i++) cin >> hs.at(i);

    sort(hs.begin(), hs.end(), greater<int>());

    ll cnt = 0;
    for(auto h : hs)
    {
        if(k>0) k--;
        else
        {
            cnt += h;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int sz=1e5+9;
int n,m;
char a[sz];
ll dp[sz];
vector<int> ans;
int nxt[sz];

int main(){
    scanf("%d %d\n",&n,&m);
    for(int i=0;i<=n;i++) scanf("%c",&a[i]);
	for(int i=0;i<=n;i++) dp[i]=1e9;    
	dp[n]=0;
	priority_queue<pll> pq;
	pq.push(mp(0,-n));
	for(int i=n-1;i>=0;i--){
		while(a[i]=='0'&&!pq.empty()){
			auto t=pq.top();
			if(-t.y>i+m||a[-t.y]=='1') pq.pop();
			else{
				dp[i]=1-t.x;
				nxt[i]=-t.y;
				break;
			}
		}
		pq.push(mp(-dp[i],-i));
	}
	if(dp[0]>=1e9){
		printf("-1");
		return 0;
	}
	int curr=0;
	while(curr!=n){
		cout<<nxt[curr]-curr<< " ";
		curr=nxt[curr]; 
	}
    return 0;
}


Measured memory_bytes: 3700
n=int(input())
s=0
L=list(map(int,input().split()))
#a,b=map(int,input().split())
#A=[[0 for i in range()] for j in range()]
#l = [int(input()) for i in range(N)]

for i in range(n):
  s+=1/L[i]
  
print(1/s)

Measured memory_bytes: 2940
a, b = map(int, input().split())
if a != 1 and b != 1 :
  if a > b :
    print('Alice')
  elif a < b :
    print('Bob')
  else :
    print('Draw')
elif a == 1 and b != 1 :
  print('Alice')
elif a != 1 and b == 1 :
  print('Bob')
else :
  print('Draw')

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

using namespace std;

void solve(){
    int n,k;
    cin>>n>>k;
    vector<int> ht(n), dp(n, 2e9);
    for(auto& i:ht)
        cin>>i;
    dp[0] =0;
    for(int i =1; i<n; ++i){
        for(int j=0; j<min(i,k); ++j){
            dp[i] = min(dp[i],dp[i-j-1] + abs(ht[i]- ht[i-j-1]));
        }
    }
    cout<<dp.back();
}

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

    // int t; cin>>t;
    // while(t--)
        solve();
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define ZERO (1e-10)
#define INF int(1e9+1)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define DEB printf("DEB!\n");
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define EQ(A,B) (A+ZERO>B&&A-ZERO<B)
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
#define IN(n) int n;scanf("%d",&n);
#define FOR(i, m, n) for (int i(m); i < n; i++)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)
#define FT(m, n) FOR(k, m, n)
#define aa first
#define bb second
void ga(int N,int *A){F(N)scanf("%d",A+i);}
#define MOD 1000000007
#define MX 2048
int dp[MX][MX][2][2],N,M,A[MX],B[MX];
int dyn(int a,int b,bool x,bool y){
    if(a==N||b==M)return !x&&!y;
    int&v=dp[a][b][x][y];
    if(~v)return v;
    v=0;
    if(A[a]==B[b])v=dyn(a+1,b+1,0,0);
    if(!x&&!y)v=(v+dyn(a+1,b+1,0,0))%MOD;
    if(x)v=(v+dyn(a,b+1,1,0))%MOD;
    if(y)v=(v+dyn(a+1,b,0,1))%MOD;
    if(!x&&!y)v=(v+ll(dyn(a+1,b,0,1))+dyn(a,b+1,1,0))%MOD;
    return v;
}
int main(void){
    scanf("%d%d",&N,&M),ga(N,A),ga(M,B),CL(dp,-1);
    printf("%d\n",dyn(0,0,0,0));
    return 0;
}


Measured memory_bytes: 66176
import java.util.*;

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

        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int T = sc.nextInt();

        int bic = 0;
        double t = (T+0.5)/A;
        for(int i=1;i<=t;i++){
               bic +=B;
        }
        System.out.println(bic);
    }
}

Measured memory_bytes: 21844
#include <iostream>

using namespace std;

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

	int* R = new int[n];

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

	int maxv = R[1] - R[0], minv = R[0];
	for (int j = 1; j <= n - 1; j++) {
		maxv = maxv > (R[j] - minv) ? maxv : R[j] - minv;
		minv = minv < R[j] ? minv : R[j];
	}

	cout << maxv << endl;

	delete[] R;
}

Measured memory_bytes: 1796
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << a*b/2;
    cout << endl;
}


Measured memory_bytes: 256
while True:

    n,x = map(int, input().split()) 
    count = 0

    if n == 0 and x == 0:
        break

    for a in range(1,n):
        if a + (a+1) + (a+2) > x:
            continue
        for b in range(a+1,n+1):
            for c in range(b+1,n+1):
                if a + b + c == x:
                    count += 1
    print(count)





Measured memory_bytes: 5592
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

int a[10];
bool b[10];

int main() {
	int tmp;
	cin >> tmp;
	for (int i = 3; i >= 0; i--) {
		a[i] = tmp % 10;
//		cout << "a[i]:" << a[i] << endl;
		tmp /= 10;
	}
	REP(i, 8) {
		int tmp = i;
		REP(j, 3) {
			b[j] = tmp % 2;
			tmp /= 2;
		}
		int ans = a[0];
		REP(j, 3) {
			if (b[j]) ans += a[j + 1];
			else ans -= a[j + 1];
		}
		if (ans == 7) break;
	}
	cout << a[0];
	REP(i, 3) {
		if (b[i]) cout << "+";
		else cout << "-";
		cout << a[i + 1];
	}
	cout << "=7" << endl;
}

Measured memory_bytes: 256
# import sys
# sys.setrecursionlimit(10**5)
# from collections import defaultdict
geta = lambda fn: list(map(fn, input().split()))
gete = lambda fn: fn(input())

def main():
    N, K = geta(int)
    h = geta(int)

    INF = 1 << 60
    dp = [INF]*N
    dp[0], dp[1] = 0, abs(h[0] - h[1])

    for i in range(2, N):
        lb = i - K if i > K else 0
        for j in range(lb, i):
            tmp = dp[j] + abs(h[j] - h[i])
            if tmp < dp[i]:
                dp[i] = tmp

    print(dp[N - 1])

if __name__ == "__main__":
    main()


Measured memory_bytes: 52448