akhauriyash/Code-Regression huggingface dataset:
n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).map(&:pred)
h = Hash.new(0)
s = 0

k.times do
  if h[s] == 2
    one = h.count { |k, v| v == 1 }
    two = h.count { |k, v| v == 2 }
    mod = (k - one) % two

    mod.times do
      s = a[s]
    end

    puts s + 1
    exit
  end

  h[s] += 1
  s = a[s]
end

puts s + 1

Measured memory_bytes: 38644
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define sz(s) ((int) ((s).size()))
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif

typedef long long ll;
typedef long double ld;

const int inf = (int) 1e9 + 100;
const ld eps = 1e-11;
const ld pi = acos(-1.0L);

mt19937 mrand(random_device{} ());
int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

int a, b, c;

bool read() {
  if (scanf("%d%d%d", &a, &b, &c) < 3) {
    return false;
  }
  return true;
}

void solve() {
  if (!(a & 1) || !(b & 1) || !(c & 1)) {
    printf("%d\n", 0);
    return;
  }
  printf("%lld\n", min(min((long long)a * b, (long long)b * c), (long long)c * a));
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen("text.in", "r", stdin));
  assert(freopen("text.out", "w", stdout));
#endif

  while (true) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time: %.18f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

vector<vector<int>> v;
int ans=0;

void dfs(vector<bool> &visit,int cnt) {
    visit[cnt] = true;
    bool all = true;
    REP(i,visit.size()) {
        if (!visit[i]) {
            all = false;
            break;
        }
    }
    if (all) {
        ans++;
        return;
    }
    for(auto x: v[cnt]) {
        if (!visit[x]) {
            vector<bool> vi(visit);
            dfs(vi,x);
        }
    }
    return;
}

int main(void)
{
    IOS
    int n, m;
    cin >> n >> m;
    v.resize(n);
    REP(i,m) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    
    vector<bool> vi(n);
    dfs(vi,0);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

int h,w,x;
char s[1000][1000];
bool visited [1000][1000];
pair<int,int> start,goal;
queue<pair<int,pair<int,int>>> q;
vector<pair<int,int>> ino;

int main(){
  int a,b,c,d;cin>>a>>b>>c>>d;
  if(a==b||b==c||c==a){
    if(a==b&&a==c){
      cout<<1;
      return 0;
    }
      cout<<2;
  }else{
    cout<<3;
  }
}


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

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in(gcu());}
_sc(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename H,typename... T> _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
template <typename T>
_vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for (char c: s) pcu(c);}
template <typename H,typename... T> _vo(H&& h, T&&... t){out(h);out(move(t)...);}
//template <typename T> _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
_vl(){out('\n');}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	int n = in(), s = in();
	unordered_map<int, long> a = {{s, 1}}, b;
	auto insert = [&b](int c, long n) {
		if (c >= 0 && c <= 20)
			b[c] += n;};
	for (int i = 2; i < n; i++) {
		int x = in();
		b = {};
		for (auto j: a) {
			insert(j.first + x, j.second);
			insert(j.first - x, j.second);
		}
		a = move(b);
	}
	outl(a[in()]);
}


Measured memory_bytes: 3020
from collections import Counter, defaultdict
S = input()
T = input()

S_count = Counter(S)
T_count = Counter(T)

d_S = defaultdict(int)
d_T = defaultdict(int)
for i in range(len(S)):
    d_S[S_count[S[i]]] += 1
    d_T[T_count[T[i]]] += 1

if (d_S == d_T):
    print('Yes')
else:
    print('No')


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

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "yes" << endl) : (cout << "no" << endl))
#define Yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

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

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

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

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

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

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

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

template<typename T>
ostream& operator << (ostream& os, const set<T>& s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/

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

	ll ans = 1;
	for (int i = 1; i <= N; i++)
		ans = (ans * i) % MOD;

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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int H, W, N;
    cin >> H >> W >> N;
    if(H < W) swap(H, W);
    output((N + H - 1) / H);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include <iomanip>
#include<utility>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
#define S 21 
llfor;
const ll mod=1000000007;
/*pi*/const double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;ans%=mod;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)*fact(n-r)/fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
/*行列のコピー*/void matcpy(ll a[S][S],ll b[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)b[i][j]=a[i][j];/*(aをbに)*/i=t;}
/*行列のリセット*/void matrst(ll a[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)a[i][j]=0;i=t;}
/*行列の2乗*/void matpow(ll a[S][S]){ll ans[S][S];matrst(ans);ll t=i,k;rep(i,0,S)rep(j,0,S)rep(k,0,S)ans[i][j]+=a[i][k]*a[k][j];matcpy(ans,a);i=t;}
/*行列の乗算*/void matmul(ll a[S][S],ll b[S][S], ll as[S][S]){ll t=i,k;matrst(as);rep(i,0,S)rep(j,0,S)rep(k,0,S)as[i][j]+=a[i][k]*b[k][j];i=t;}
//ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 ll n;cin>>n; 
 ll a[n+10]={0},b;
 rep(i,0,n){
  cin>>b;
  a[b]++;
 }
 ll p;
 if(n%2==0)p=1;
 else p=0;
 
 if(p==0&&a[0]!=1){
  pr(0);return 0;
 }
 if(p==1){
  rep(i,0,n/2){
   if(a[2*i+1]!=2){
    pr(0);return 0;
   }
  }
 }
 else{
  rep(i,1,n/2){
   if(a[2*i]!=2){
    pr(0);return 0;
   }
  }
 }
 ll ans=llpow(2,n/2);
 ans%=mod;
 pr(ans);
return 0;}


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

const int M = 1000000007;
int A, B, C;
long D[600001];
long f[900001];
long g[900001];

long powmod(long b, long e) {
	if (e == 0) return 1;
	if (e % 2 == 1) return b * powmod(b, e - 1) % M;
	long t = powmod(b, e / 2);
	return t * t % M;
}

void pre() {
	D[0] = 1;
	for (int i = 0; i < B + C; ++i) {
		D[i + 1] = D[i] * 3 % M;
	}
	const int N = A + B + C;
	
	f[0] = 1;
	for (int i = 0; i <= N; ++i) {
		f[i + 1] = f[i] * (i + 1) % M;
	}
	
	g[N] = powmod(f[N], M - 2);
	for (int i = N; i > 0; --i) {
		g[i - 1] = g[i] * i % M;
	}
}

long combi(long n, long r) {
	if (r < 0 || r > n) return 0;
	return f[n] * g[r] % M * g[n - r] % M;
}

int main() {
	cin >> A >> B >> C;
	--A;

	pre();

	long sum = 0;
	long k = 1;
	for (int s = 0; s <= B + C; ++s) {
		sum += D[B + C - s] * f[A + s] % M * g[s] % M * k % M;
    	sum %= M;
    	k = 2 * (k + M) - combi(s, B) - combi(s, C);
    	k %= M;
	}

	cout << sum * g[A] % M << endl;
	return 0;
}


Measured memory_bytes: 18944
n = int(input())
A = [0] + list(map(int, input().split())) + [0]

costs = [0]
for a, b in zip(A[:-1], A[1:]):
    costs.append(abs(a-b))

from itertools import accumulate
costs_acc = list(accumulate(costs))

for i in range(1, n+1):
    s =  costs_acc[i-1] + abs(A[i-1] - A[i+1]) + costs_acc[-1] - costs_acc[i+1]
    print(s)
    

Measured memory_bytes: 17600
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;

ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
	}
	
	mod& operator=(const ll & tx) {
		x = tx;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return (x + m2.x) % MOD;
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return (x - m2.x + MOD) % MOD;
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return (x * m2.x) % MOD;
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return mod(((*this).x * (*this).inv().x) % MOD);
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}

/* TEMPLATE ENDS HERE */

int main() {
	cout << fixed << setprecision(12);	
	int n, k;
	cin >> n >> k;
	if (k > 1) {
		cout << n - k << endl;
	} else {
		cout << 0 << endl;
	}
	return 0;
}


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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 10;

const int f[] = {1, 2, 4, 7, 12, 20, 29, 38, 52};

int n, p[N];
long long w[N][N];

int main() {
	read(n);
	long long mx = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < i; ++j) {
			w[i][j] = w[j][i] = (mx + 1) * f[j];
		}
		mx = 0;
		for (int j = 0; j <= i; ++j) {
			p[j] = j;
		}
		while (1) {
			long long sum = 0;
			for (int j = 1; j <= i; ++j) {
				sum += w[p[j - 1]][p[j]];
			}
			mx = std::max(mx, sum);
			if (!std::next_permutation(p, p + i + 1)) {
				break;
			}
		}
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			print(w[i][j], ' ');
		}
		putchar('\n');
	}
	debug("%lld\n", mx);
}


Measured memory_bytes: 3732
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

type Item struct {
	a int
	b int

	Index int
}

type PriorityQueue []*Item

func (pq PriorityQueue) Len() int { return len(pq) }

func (pq PriorityQueue) Less(i, j int) bool {
	return pq[i].a > pq[j].a
}

func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	item.Index = -1
	*pq = old[0 : n-1]
	return item
}

func (pq *PriorityQueue) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Item)
	item.Index = n
	*pq = append(*pq, item)
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].Index = i
	pq[j].Index = j
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	N := nextInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = nextInt()
	}

	sort.Ints(A)

	pq := make(PriorityQueue, 0)
	heap.Init(&pq)
	heap.Push(&pq, &Item{A[N-2], A[N-1], -1})
	heap.Push(&pq, &Item{A[N-2], A[N-1], -1})
	conf := A[N-1]

	for i := N - 3; i >= 0; i-- {
		pair := heap.Pop(&pq).(*Item)
		// fmt.Fprintf(out, "%d-%d\n", pair.a, pair.b)
		conf += pair.a
		heap.Push(&pq, &Item{A[i], pair.a, -1})
		heap.Push(&pq, &Item{A[i], pair.b, -1})
	}

	fmt.Fprintf(out, "%d\n", conf)
}


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

#define MAX_N 100000

int N;
int H[MAX_N];

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

    int max = 0;

    long long res = 0;
    long long s = 0, t = 0, sum = 0;
    for (int i = 0; i <= N - 1; i++) {
        int tmp = 0;
        for (int j = i; j <= N - 2; j++) {
            if (H[j] >= H[j + 1]) {
                tmp++;
            } else {
                break;
            }
        }

        if (tmp > max) {
            max = tmp;
        }
        if (tmp > 0) {
            i += tmp - 1;
        }
    }

    cout << max << endl;
}

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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int leftwest[n];
    int righteast[n+1];
    leftwest[0] = 0;
    for(int i=0;i<n-1;i++){
        if(s[i] == 'W'){
            leftwest[i+1] = leftwest[i]+1;
        }
        else{
            leftwest[i+1] = leftwest[i];
        }
    }
    righteast[n-1] = 0;
    for(int i=n-1;i>0;i--){
        if(s[i] == 'E'){
            righteast[i-1] = righteast[i]+1;
        }
        else{
            righteast[i-1] = righteast[i];
        }
    }
/*
    for(int i=0;i<n;i++){
        cout << leftwest[i];
    }
    cout << endl;
    for(int i=0;i<n;i++){
        cout << righteast[i];
    }
    cout << endl;
*/
    int ans=1000000000;
    for(int i=0;i<n;i++){   
        int tmp = leftwest[i]+righteast[i];
        if(ans > tmp){
            ans = tmp;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3076
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
static string[] input = Console.ReadLine().Split(' ');
static long n = long.Parse(input[1]);
static long k = long.Parse(input[0]);
static long p = 1000000007;
static long[] factorials = new long[n+1];//i!(mod p)を先にメモ
static long[] factorialRs = new long[n+1];//i!^-1(mod p), pは素数

	static void Main()
	{
		factorials[0] = 1;
		factorialRs[n] = DivideModFactorial(n,p);
		for(long i = 1; i <= n; i++)
		{
			factorials[i] = (factorials[i-1]*i)%p;//i!(mod p)
			factorialRs[n-i] = (factorialRs[n+1-i]*(n+1-i))%p;//逆元も先にメモ
		}

		if(n >= k) Console.WriteLine(Comb(n, k, p));//nCk(mod p),pは素数
		else Console.WriteLine(0);
	
	}

  static long DivideMod(long x, long a, long p)//戻り値はx^a(mod p)
  {
    long num = 2;
    long answer = 1;
    long check = a;
    long memo = x%p;
    
    while(check > 0)
    {
      if(check % num == num / 2)
      {
        check -= num / 2;
        answer *= memo;
        answer %= p;
      }
    memo *= memo;
    memo %= p;
    num *= 2;
    }
    return answer;
  }

  static long DivideModReverse(long x, long p)//戻り値はx^-1(mod p), pは素数
  {
    long answer = DivideMod(x, p-2, p);
    return answer;
  }

  static long DivideModFactorial(long x, long p)//戻り値はx!^-1(mod p), pは素数
  {
    long answer = 1;
    for(long i = x; i >= 2; i--)
    {
      answer *= DivideModReverse(i, p);
      answer %= p;
    }
    return answer;
  }

	static long Comb(long a, long b, long p)//戻り値は組み合わせC(a,b)のmod p
  {
    long answer = 1;
    answer *= factorials[a];
    answer %= p;
    answer *= factorialRs[a-b];//引数a-bは負にならないようにする
    answer %= p;
    answer *= factorialRs[b];
    answer %= p;
    return answer;
  }
  
}



Measured memory_bytes: 18024
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main() {
    ll N, A, B;
    cin >> N >> A >> B;

    ll ans = 0;
    ans += N / (A + B) * A;
    ans += min(A, N % (A + B));

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
 
 
int main() {
	int A, B;
 
	cin >> A >> B;


	int K = (A + B) / 2;

	if (abs(A-K) == abs(B - K)) cout << K;
	else  cout << "IMPOSSIBLE";
 
}

Measured memory_bytes: 256
import sys
 
l = sys.stdin.readlines()
minv = int(l[1])
maxv = -1000000000

for r in map(int,l[2:]):
  m = r-minv
  if maxv < m: 
    maxv = m
    if m < 0: minv = r
  elif m < 0: minv = r
 
print(maxv)

Measured memory_bytes: 23408
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Rep(i, N) for(int i = 0; i < N; i++)
#define Reps(i, x, N) for(int i = x; i < N; i++)

const int LLINF = 1LL << 60;

signed main()
{
  int N, A, B, C, X;
  int Y;

  while(cin >> N >> A >> B >> C >> X, N || A || B || C || X) {

    int cnt = 0;
    Rep(i, N) {
      cin >> Y;
      while(X != Y && cnt <= 10000) {
	X = (A * X + B) % C, cnt++;
      }
      if(i < N - 1) X = (A * X + B) % C, cnt++; 
    }

    if(cnt > 10000) cout << -1 << endl;
    else cout << cnt << endl;

  }

  return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LLP;

bool check(int N, int M, vector<vector<int>> a, int x) {
    vector<deque<int>> list(M);
    vector<bool> playable(M, true);
    vector<deque<int>> A(N);
    rep(i,N) rep(j,M) A[i].push_back(a[i][j]);
    rep(i,N) {
        int k = A[i].front(); A[i].pop_front();
        list[k].push_back(i);
    }
    while (true) {
        int flag = -1;
        int max_count = x;
        rep(i,M) {
            if (list[i].size() > max_count) {
                flag = i;
                max_count = list[i].size();
            }
        }
        if (flag < 0) {
            return true;
        }
        playable[flag] = false;

        while (!list[flag].empty()) {
            int i = list[flag].front(); list[flag].pop_front();
            while (true) {
                if (A[i].empty()) return false;
                int k = A[i].front(); A[i].pop_front();
                if (playable[k]) {
                    list[k].push_back(i);
                    break;
                }
            }
        }
    }
}

int main() {

    int N, M;
    cin >> N >> M;
    vector<vector<int>> A(N, vector<int>(M));
    rep(i,N) rep(j,M) {
        cin >> A[i][j];
        A[i][j]--;
    }

    int bottom = 1;
    int top = N;
    while (bottom < top) {
        int x = bottom + (top - bottom) / 2;
        if (check(N, M, A, x)) top = x;
        else bottom = x + 1;
    }

    cout << bottom << endl;
    
    return 0;
}

Measured memory_bytes: 5032
#include<bits/stdc++.h>
using namespace std;
int main()
{
  char s[100];
  int count=0;
  cin>>s;
  for(int i=0;i<strlen(s);i++)
  {
if(s[i]!=s[strlen(s)-1-i])
  count++;
  }
  cout<<count/2;
}
    


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

int main(){
    ll h, w;
    ll ans = 0;
    cin >> h >> w;
    if (h == 1 || w == 1) cout << 1 << endl;
    else if (h % 2 == 0) cout << h * w / 2 << endl;
    else {
        ans += (h - 1) / 2 * w;
        ans += (w + 1) / 2;
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0);
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
	ll r=1;
	a=a%m;
	while(b>0)
	{
	if(b&1)
		r=(r*a)%m;
	b=b/2;
	a=(a*a)%m;
	}
	return r%m;
}


int main() {
   ll a,b,k; cin>>a>>b>>k;
   ll z = 0;
   if(k>=a)
   {
       cout<<0<<" "<<max(z,b+a-k)<<endl;
   }
   else
   {
       cout<<a-k<<" "<<b<<endl;
   }
   return 0;
}
/*

*/


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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

int main(void){
    int H, W, K; cin >> H >> W >> K;
    string grid[H]; rep(i, H) cin >> grid[i];
    //各行で一番左にあるイチゴは,左端まで伸ばせばいい
    //その後、各行の全てのイチゴについて次にイチゴが現れるか右端に着くまで右に伸ばせばいい
    //すると、イチゴのある行は埋まる
    int ans[H][W]; rep(i, H) rep(j, W) ans[i][j] = -1;
    int cnt = 1;
    for(int i = 0; i < H; i++){
        bool first = true;
        for(int j = 0; j < W; j++){
            if(grid[i][j] == '#' && first){
                for(int k = j; k >= 0; k--){
                    ans[i][k] = cnt;
                }
                first = false;
            }
            if(grid[i][j] == '#'){
                ans[i][j] = cnt;
                while(j+1 < W && grid[i][j+1] == '.'){
                    ans[i][j+1] = cnt;
                    j++;
                }
            }
            if(!first) cnt++;
        }
    }
    int first_exist_row = 0;
    rep(i, H){
        if(ans[i][0] != -1){
            first_exist_row = i;
            break;
        }
    }
    rep(i, H){
        if(ans[i][0] == -1){
            if(i == 0){
                rep(j, W){
                    ans[0][j] = ans[first_exist_row][j];
                }
            }
            else{
                rep(j, W){
                    ans[i][j] = ans[i-1][j];
                }
            }
        }
    }
    
    rep(i, H){
        rep(j, W){
            if(j == W-1) cout << ans[i][j] << endl;
            else cout << ans[i][j] << " ";
        }
    }
    
    return 0;
}

Measured memory_bytes: 1280
import sys
sys.setrecursionlimit(10**6)
n, u, v = map(int, input().split())
u -= 1
v -= 1
graph = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
pre = [None]*n
def dfs(node, p_node=-1):
    for c_node in graph[node]:
        if c_node==p_node:
            continue
        pre[c_node] = node
        dfs(c_node, node)
dfs(u)
path = [v]
now = v
while now!=u:
    now = pre[now]
    path.append(now)
s1 = path[len(path)//2]
p1 = path[len(path)//2-1]
def dfs2(node, depth, p_node):
    mx = depth
    for c_node in graph[node]:
        if c_node==p_node:
            continue
        mx = max(mx, dfs2(c_node, depth+1, node))
    return mx
print(dfs2(s1, 0, p1)+len(path)//2-1)

Measured memory_bytes: 108836
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

int main() {
	int N,x=0; cin >> N;
	vector<int> s(N);
	for (int i = 0; i < N; i++) {
		cin >> s[i]; x += s[i];
	}
	if (x % 10 != 0)cout << x << endl;
	else {
		sort(s.begin(), s.end());
		int y; bool z = 0;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] % 10 != 0) { y = s[i]; z = 1; break; }
		}
		if (z)cout << x - y << endl;
		else cout << 0 << endl;
	}

}



Measured memory_bytes: 256
S = input()
l = len(S)
ans = 0

for i in range(2**(l-1)):
    T = S[0]
    for j in range(l-1):
        if i>>j & 1:
            T = T + "-"
        else:
            T = T + "+"
        T = T+S[j+1]
    if eval(T) == 7:
        print(T+"=7")
        exit()

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl


int main(){
    int n;
    cin>>n;
    vi a(n),b(n);

    REP(i,n){
        cin>>a[i];
    }
    REP(i,n){
        cin>>b[i];
    }
    REP(i,1,n){
        a[i]+=a[i-1];
    }
    for(int i=n-2;i>=0;i--){
        b[i]+=b[i+1];
    }
    int ma=-INF;
    REP(i,n){
        chmax(ma,a[i]+b[i]);
    }
    cout<<ma<<endl;
    return 0;
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int a,b;
	cin >> a >> b;
	cout << a * b << endl;
	return 0;
}

Measured memory_bytes: 3608
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC132A
{
    class Program
    {
        public static void Main()
        {
            var s = Console.ReadLine();
            var g = s.GroupBy(i => i);
            var ans = "Yes";

            if (g.Count() != 2) {
                ans = "No";
            }
            else {
                foreach (var e in g) {
                    if (e.Count() != 2) {
                        ans = "No";
                    }    
                }
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13280
n = int(input())
d = {"M": 0, "A": 0,"R": 0,"C": 0,"H": 0}

for i in range(n):
  s = input()
  d[s[0]] = d.get(s[0], 0) + 1

x = 0
x += d["M"] * d["A"] * d["R"]
x += d["M"] * d["A"] * d["C"]
x += d["M"] * d["A"] * d["H"]
x += d["M"] * d["R"] * d["C"]
x += d["M"] * d["R"] * d["H"]
x += d["M"] * d["C"] * d["H"]
x += d["A"] * d["R"] * d["C"]
x += d["A"] * d["R"] * d["H"]
x += d["A"] * d["C"] * d["H"]
x += d["R"] * d["C"] * d["H"]
print(x)

Measured memory_bytes: 9260
// Author:: MUKUL KUMAR RAI
// Institution:: Jalpaiguri Government Engineering College
//If you are not doing well now just stick to it and learn new things one day you will be...
//Compete with yourself 
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define fi first
#define se second
#define pb push_back
///*template{{{
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
#define trav(a,x) for(auto &a:x)
#define fr(i,a,b)  for(ll i=a;i<=b;i++)
#define fr1(i,a)   for(ll i=0;i<a;i++)
#define frr(i,a,b) for(ll i=b;i>=a;i--)
#define frr1(i,a)   for(ll i=a-1;i>=0;i--)
#define sorta(a,n) sort(a,a+n)
#define sortd(a,n) sort(a,a+n,greater<ll>())
#define sortva(a) sort(a.begin(),a.end())
#define sortvd(a) sort(a.begin(),a.end(),greater<ll>())
#define tc(t) while(t--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
using vi= vector<ll>;
using vvi= vector<vi>;
using vb =vector<bool>;
using vc =vector<char>;
using vs =vector<string>;
using vld =vector<ld>;
using pii =pair<ll,ll>;
using psi =pair<string,ll>;
using pci =pair<char,ll>;
using vpii =vector<pii>;
//}}}template*/
ll mod=1e9+7;
ll const maxn=1e6+5;
ll const inf=1e18;
bool ss(const pair<ll,ll> &a, const pair<ll,ll> &b) { 
    return a.first*b.second+a.second<b.first*a.second+b.second;
}
ll add(ll a,ll b){
    return ((a%mod)+(b%mod))%mod;
}
ll mul(ll a,ll b){
    return ((a%mod)*(b%mod))%mod;
}
ll powm(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}
ll modinverse(ll a, ll m){
    return powm(a,m-2,m);
}
bool prime(ll x){
    if(x<=1)return false;
    for(int i=2;i<=sqrt(x);i++)if(x%i==0)return false;
    return true;
}
ll divisor(ll x){
    ll cnt=0;
    for(int i=1;i<=sqrt(x);i++){
        if(x%i==0){
            if(i!=x/i)cnt+=2;
            else cnt+=1;
        }
    }
    return cnt;
}
vector<ll> sieve(ll n) {     
    bool prim[n+1]; 
    memset(prim, true, sizeof(prim)); 
  
    for (ll p=2; p*p<=n; p++) {
        if (prim[p] == true) { 
            for (int i=p*p; i<=n; i += p) 
                prim[i] = false; 
        } 
    }
    vector<ll>v;
    for(int i=2;i<=n;i++)if(prim[i])v.push_back(i);
    return v; 
}
bool check(string s){
    ll l=0,r=sz(s)-1;
    while(l<=r){
        if(s[l]!=s[r])return false;
        l++;
        r--;
    }
    return true;
}
int main(){

    fio;
    ll a,b;
    cin>>a>>b;
    cout<<max(0LL,a-2*b);
    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())

    nums = ['-1']
    res = 'No'

    for num in str(N):
        if nums[0] == num:
            nums.append(num)
            if len(nums) == 3:
                res = 'Yes'
                break
        else:
            nums = [num]
    
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9036
#include <bits/stdc++.h>
using namespace std;
long long sum(long long n){
	return n*(n-1)/2;
}
int main(){
	int n;
	cin >> n;
	map<long long,long long> mp, mp1, mp2;
	for(long long i=0; i<n; ++i){
		long long a;
		cin >> a;
		++mp[i+a];
		++mp[i-a];
		++mp1[i+a];
		++mp2[i-a];
	}

	long long ans=0;
	for(auto i: mp) ans += sum(i.second);
	for(auto i: mp1) ans -= sum(i.second);
	for(auto i: mp2) ans -= sum(i.second);
	
	cout << ans << endl;
}

Measured memory_bytes: 49388
#define _CRT_SECURE_NO_WARNINGS
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <array>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <utility>
#include <assert.h>
#include <regex>
#include <numeric>
using namespace std;

typedef unsigned long long ull;
typedef signed long long ll;
#define INF (1LL << 48)

struct PT { ll x; ll y; };
string to_s(ull x) { return to_string(x); }
string to_s(ll x) { return to_string(x); }
ll to_ll(const string& x) { return stoll(x); }
ull to_ull(const string& x) { return stoull(x); }




int main(int argc, char* argv[])
{
	for (;;) {
		string S;
		cin >> S;
		if (cin.fail()) break;

		int len = (int) S.length();
		array<int, 3> cnt{};
		for (int i = 0; i < len; i++) {
			cnt[S[i] - 'a']++;
		}
		sort(cnt.begin(), cnt.end(), greater<int>());
		cnt[0] -= len / 3;
		cnt[1] -= len / 3;
		cnt[2] -= len / 3;
		switch (len % 3) {
		case 0: break;
		case 1: cnt[0]--; break;
		case 2: cnt[0]--; cnt[1]--; break;
		}
		cout << ((cnt[0] | cnt[1] | cnt[2]) ? "NO" : "YES") << endl;
	}

	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;  
#define ordered_set tree<ll, null_type , less<ll> , rb_tree_tag , tree_order_statistics_Node_update> 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
#define setbits __builtin_popcount
#define endl '\n'
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main()
{
    ll x,y,z;
    cin>>x>>y>>z;
    ll val,val1;
    val=y/x;
    val1=min(val,z);
    cout<<val1<<endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll count = 0;
    ll value = 0;
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    count += min(A, K);
    value += min(A, K);
    count += min(B, max(K - count, 0LL));
    value -= min(C, max(K - count, 0LL));
    cout << value << endl;
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int n, t; cin >> n >> t;
	vector<pair<int, int>> a(n);
	for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
	sort(a.begin(), a.end());
	vector<int> dp(10000, 0);
	auto chmax = [](int &a, int b) {
		a = max(a, b);
	};
	for (int i = 0; i < n; i++) {
		for (int j = t - 1; j >= 0; j--) {
			chmax(dp[j + a[i].first], dp[j] + a[i].second);
		}
	}
	int ans = 0;
	for (int i = 0; i < 10000; i++) chmax(ans, dp[i]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int n, m;
int mod = 1000000007;
vector<long long> fac, inv, finv;

void combinit()
{
    fac.resize(n + m + 1);
    inv.resize(n + m + 1);
    finv.resize(n + m + 1);

    fac[0] = fac[1] = 1;
    inv[1] = 1;
    finv[0] = finv[1] = 1;
    for (int i = 2; i < n + m + 1; 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;
    }
    
}

long long combination(int n, int k){
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main(int argc, char const *argv[])
{
    long long X, Y;
    cin >> X >> Y;
    int ans;
    if ((X + Y) % 3 == 0)
    {
        m = (2 * Y - X) / 3;
        n = Y - 2 * m;
        if (n < 0 || m < 0)
        {
            ans = 0;
            cout << ans << endl;
            return 0;
        }
        combinit();
        ans = (int)combination(n + m, n);
    }else
    {
        ans = 0;
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int h, w, n; cin>>h>>w>>n;
    int sy, sx; cin>>sy>>sx;
    sy--, sx--;
    string s, t; cin>>s>>t;

    bool valid = true;
    int cy = sy, cx = sx;

    // go up
    for(int i=0; i<n; i++){
        if(s[i] == 'U') cy--;
        if(cy < 0){
            valid = false;
            break;
        }
        if(t[i] == 'D'){
            cy++;
            chmin(cy, h - 1);
        }
    }

    // go down
    cy = sy, cx = sx;
    for(int i=0; i<n; i++){
        if(s[i] == 'D') cy++;
        if(h <= cy){
            valid = false;
            break;
        }
        if(t[i] == 'U'){
            cy--;
            chmax(cy, 0);
        }
    }

    // go right
    cy = sy, cx = sx;
    for(int i=0; i<n; i++){
        if(s[i] == 'R') cx++;
        if(w <= cx){
            valid = false;
            break;
        }
        if(t[i] == 'L'){
            cx--;
            chmax(cx, 0);
        }
    }

    // go left
    cy = sy, cx = sx;
    for(int i=0; i<n; i++){
        if(s[i] == 'L') cx--;
        if(cx < 0){
            valid = false;
            break;
        }
        if(t[i] == 'R'){
            cx++;
            chmin(cx, w - 1);
        }
    }

    if(valid) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 776
#include<stdio.h>
int main(void){
	int n,i,sum=0;
	int v[20],c[20];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&v[i]);
	}
	for(i=0;i<n;i++){
		scanf("%d",&c[i]);
	}
	for(i=0;i<n;i++){
		if(c[i]<v[i]){
			sum+=v[i]-c[i];
		}
	}
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 1728
from collections import deque

n,m = map(int,input().split())

adjacent_list = [[] for i in range(n+1)]

for i in range(m):
    a,b = map(int,input().split())
    adjacent_list[a].append(b)
    adjacent_list[b].append(a)#どこの点がどことつながっているか
pre = [-1] * (n+1)
dist = [-1] * (n+1)
dist[1] = 0
que = deque([1])

while que:
    now = que.popleft()#1取り出す。queはから
    for i in adjacent_list[now]:
        if pre[i] == -1:#訪問していない
            que.append(i)
            dist[i] = dist[now] + 1
            pre[i] = now
print("Yes")
for i in range(2,n+1):
    print(pre[i])

Measured memory_bytes: 35120
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
using namespace std;

const int MXN = 110;
const int MXK = 100005;
int n, k;
int v[MXN], w[MXN];
// ll dp[MXN][MXK];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n >> k;
    for(int i = 1; i <= n; i++) {
        cin >> w[i] >> v[i];
    }
    // for(int i = n - 1; i >= 0; i--) {
    //     for(int j = k; j >= 0; j--) {
    //         dp[i][j] = dp[i + 1][j];
    //         if(j + w[i] <= k) {
    //             dp[i][j] = max(dp[i][j], dp[i + 1][j + w[i]] + v[i]);
    //         }
    //     }
    // }
    // cout << dp[0][0] << endl;
    vector<ll> dp(k + 1, 0);
    for(int i = 1; i <= n; i++) {
        vector<ll> dpt(k + 1, 0);
        for(int j = 0; j <= k; j++) {
            dpt[j] = dp[j];
            if(j - w[i] >= 0) {
                dpt[j] = max(dpt[j], dp[j - w[i]] + v[i]);
            }
        }
        dp = dpt;
    }
    cout << dp[k] << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  map<char, int> cnt;
  rep (i, 3) cin >> cnt['A'+i];
  vector<string> s(n);
  for (string &i : s) cin >> i;
  string ans;
  rep (i, n) {
    char t1 = s[i][0], t2 = s[i][1];
    if(cnt[t1] == 0 and cnt[t2] == 0) {
      return printf("No\n"), 0;
    }
    if(cnt[t1] < cnt[t2]) {
      swap(t1, t2);
    }
    char t3 = 'A';
    while(t3 == t1 or t3 == t2) t3++;
    if(cnt[t1] == 1 and cnt[t2] == 1 and cnt[t3] == 0) {
      if(i + 1 < n) {
        if(t1 == s[i+1][0] or t1 == s[i+1][1]) {
          swap(t1, t2);
        }
      }
    }
    ans += t2;
    cnt[t2]++;
    cnt[t1]--;
  }

  cout << "Yes" << endl;
  for (char i : ans) cout << i << endl;
}


Measured memory_bytes: 6700