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

struct UnionFind{
    vector<int> data;

    UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);//親は負でサイズを保存
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  bool same(int x, int y){
      return find(x) == find(y);
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

/* 
using pint = pair<int,int>;
using Edge = pair<long long, pint>;
*/
struct Edge{long long u,v,cost;};
//using Edges = vector<Edge>;

bool comp(const Edge &a, const Edge &b){
    return a.cost < b.cost;
}
Edge es[100010];

int kruskal(int E, int V){
    //es.resize(E);
    sort(es,es+E,comp);
    UnionFind uf(V);
    int res = 0;
    for(auto e : es){
        long long cost = e.cost;
        int u = e.u,v = e.v;
        if(!uf.same(u,v)){
            uf.unite(u,v);
            res += cost;
        }
    }
    return res;
}

int main(){

    int V,E;cin >> V >> E;
    //Edges es(E);
    for(int i = 0; i < E ; i++){
        int u,v,c;
        cin >> u >> v >> c;
        es[i].cost = c;es[i].u = u,es[i].v = v;
    }
    int res = kruskal(E,V);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 5480
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 998244353;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

const int mod = 998244353;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
 
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint operator()(int n, int k, int a){
      if (k < 0 || k > n) return 0;
      return fact[n]*ifact[n-k];
  }
} comb(200010);


int main(){
    ll N,M,K;
    cin >> N >> M >> K;
    if(M == 1){
        if(K == N-1){
            cout << 1 << endl;
            return 0;
        }else{
            cout << 0 << endl;
            return 0;
        }
    }
    mint t=M;
    rep(i,N-1){
        t *= (M-1);
    }
    mint ans = 0;
    rep(k,K+1){
        ans += comb(N-1,k)*t;
        t /= (M-1);
    }
    cout << ans << endl;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

llong nCr(int n, int r){
	llong ret = 1;
	for(int i = 0; i < r; i++)
		(ret *= n-i) /= i+1;

	return ret;
}

int main(){
	llong N, A, B;
	vector<llong> v;
	map<llong,int> m;

	cin >> N >> A >> B;
	v.resize(N);
	for(int i = 0; i < N; i++){
		cin >> v[i];
		m[v[i]]++;
	}
	sort(BE(v), greater<llong>());

	ldbl ans1 = 0.0;
	llong ans2 = 0;
	llong sum = 0;
	map<llong,int> use;
	for(int i = 0; i < B; i++){
		sum += v[i];
		use[v[i]]++;
		if(i == A-1)
			ans1 = sum*1.0/(i+1.0);
		if(i >= A-1){
			if(i > A-1 && v[i] != v[0])
				break;
			ldbl res = sum*1.0/(i+1.0);
			llong many = 1;
			for(auto it = use.begin(); it != use.end(); it++){
				many *= nCr(m[it->first], it->second);
			}

			ans2 += many;
		}
	}


	cout << fixed << setprecision(20) << ans1 << endl;
	cout << ans2 << endl;

	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE MultiWayIf #-}

import Data.List

main :: IO ()
main = do
  _n <- readLn :: IO Int
  as <- (map read . words) <$> getLine :: IO [Int]
  let d = filter (\(_e, l) -> l > 1) $ map (\e -> (head e, length e)) $ group $ sortBy (flip compare) as
  print $ if
            | null d -> 0 :: Int
            | length d >= 1 && snd(head d) >= 4 -> fst(head d) * fst(head d)
            | length d >= 2 -> fst(head d) * fst(d!!1)


Measured memory_bytes: 38524
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ll = int64_t;
#define MAX_N 1010
#define MAX_M 100010
const long long mod = pow(10, 9) + 7;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define veche vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define ent cout<<endl
#define printvec(vec) for(int aqw=0;aqw<vec.size();aqw++){cout<<vec[aqw]<<" ";}ent;
#define rep1(n) for(ll i = 0; i < (n); ++i)
#define rep2(i, n) for(ll i = 0; i < (n); ++i)
#define rep3(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep4(i, a, b, c) for(ll i = (a); i < (b); i += (c))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define INF 1e+9
#define print(x) cout<<x<<endl;
using P = pair<int, int>;
#define PLL pair<ll, ll>;
#define MAX_V 10010
#define PI 3.141592653589793
#define vecP vector<P>
//cout << setprecision(15) << std::fixed;

int main() {
	double a, b;
	cin >> a >> b;
	for (int i = 1;i <=1000;i++) {
		
		if (int(i*0.08)==a&& int(i*0.1)==b) {
			print(i);
			exit(0);
		}
	}
	print(-1);
}



Measured memory_bytes: 256
N = int(input())
P = [0] + list(map(int, input().split()))
X = list(map(int, input().split()))

V = [[0, {0: True}, 0, 0] for i in range(N)]  # 子の数，可能な子孫の重み，白黒の総和，裏の値
for i in range(1, N):
    V[P[i]-1][0] += 1

from collections import deque
Open = deque()
for i, v in enumerate(V):
    if v[0]==0:
        Open.append(i)
#print(Open)
while len(Open)!=0:
    iv = Open.popleft()
    v = V[iv]
    if len(v[1]) == 0:
        print("IMPOSSIBLE")
        exit()
    v[3] = v[2] - max(v[1].keys())

    u = P[iv]-1
    if u==-1:
        print("POSSIBLE")
        #print(V)
        exit()
    V[u][0] -= 1
    if V[u][0] == 0:
        Open.append(u)
    V[u][2] += X[iv] + v[3]
    newdic = {}
    for key, val in V[u][1].items():
        if key+X[iv] <= X[u]:
            newdic[key+X[iv]] = True
        if key+v[3] <= X[u]:
            newdic[key+v[3]] = True
    V[u][1] = newdic

raise ValueError


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

int main() {
    int a, b;
    string op;

    while (true) {
        cin >> a >> op >> b;

        if (op == "+") {
            cout << a + b << endl;
        } else if (op == "-") {
            cout << a - b << endl;
        } else if (op == "*") {
            cout << a * b << endl;
        } else if (op == "/") {
            cout << a / b << endl;
        } else {
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
using	namespace	std;
#define ll long long
#define	llu	unsigned	long	long
#define	ld	double
#define	llu	unsigned	long	long
#define	rep(i,x,y)		for(ll	i=x;i<y;++i)
#define	For(i,x,y)		for(ll	i=x;i<=y;++i)
#define	FOr(i,x,y)		for(ll	i=ll(x);i>=ll(y);--i)
#define	pi	acos(-1)	
#define	mk	make_pair
#define	pa	pair<ll,ll>
#define	lf	else	if
#define	IL	inline
#define	max(x,y)				((x)<(y)?(y):(x))
#define	min(x,y)				((x)<(y)?(x):(y))
#define	sqr(x)						((x)*(x))
#define	Mul(x,y)				((x)=1LL*(x)*(y)%mod)
#define	Add(x,y)				((x)=((x)+(y))%mod)
#define	Max(x,y)				((x)=((x)<(y)?(y):(x)))
#define	Min(x,y)				((x)=((x)>(y)?(y):(x)))
#define	E(x)					return	writeln(x),0
#define	LL						(long	long)
#define	p(x)					prllf("~%lld~\n",LL(x))
#define	pp(x,y)					prllf("~~%lld	%lld~~\n",LL(x),LL(y))
#define	ppp(x,y,z)				prllf("~~~%lld	%lld	%lld~~~\n",LL(x),LL(y),LL(z))
#define	pppp(a,b,c,d)			prllf("~~~%lld	%lld	%lld	%lld\n",LL(a),LL(b),LL(c),LL(d))
#define	f_in(x)					freopen(x".in","r",stdin)
#define	f_out(x)				freopen(x".out","w",stdout)
#define	open(x)					f_in(x),f_out(x)
#define	fi	first
#define	se	second
#define	GuYue		puts("\nGuYueNa________________________________________________________________________________")
typedef	complex<double>	E;
namespace	SHENZHEBEI{
#ifdef	LOCAL
				struct	_{_(){freopen("cf.in","r",stdin);}}_;
#endif	
#define	NEG	1
				inline	char	gc(){	return	getchar();	}
#if	NEG
				inline	ll	read(){				ll	x=0,fa=1;	char	ch=gc();			for	(;!isdigit(ch);ch=gc())	if	(ch=='-')	fa=-1;		for	(;isdigit(ch);ch=gc())		x=x*10-48+ch;			return	x*fa;	}
				inline	void	write(ll	x){				if	(x<0)	putchar('-'),x=-x;		if	(x>=10)			write(x/10);				putchar(x%10+'0');		}
#else
				inline	ll	read(){				ll	x=0;	char	ch=gc();			for	(;!isdigit(ch);ch=gc());				for	(;isdigit(ch);ch=gc())		x=x*10-48+ch;			return	x;			}
				inline	void	write(ll	x){				if	(x>=10)			write(x/10);				putchar(x%10+'0');		}
#endif
	void	writeln(ll	x){write(x);puts("");}
}using	namespace	SHENZHEBEI;
const ll N=205,mod=998244353;
ll n,x[N],y[N],bin[N],ans,cnt;
int main(){
	n=read();	bin[0]=1;For(i,1,n)bin[i]=bin[i-1]*2%mod;
	For(i,1,n)x[i]=read(),y[i]=read();
	ll ans=(bin[n]-n-1)%mod;
	For(i,1,n)For(j,i+1,n){
		ll sum=0;
		For(k,j+1,n)sum+=((x[i]-x[k])*(y[j]-y[k])==(x[j]-x[k])*(y[i]-y[k]));
		Add(ans,-bin[sum]);
	}writeln((ans+mod)%mod);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b = 0, D, h, n, w, ans = 0, count = 0;
  string t;

  cin >> D;
  vlli c(26), r(26), f(26, 0);
  // vvli s(D, vlli(26));
  set<lli> g;

  rep(i, 0, 26)
  {
    cin >> c[i];
  }
  rep(i, 0, D)
  {
    b++;
    w = 0;
    ans = 0;
    count = 0;
    vector<pair<lli, lli>> pr;
    repe(j, 1, 26)
    {
      cin >> a;
      if (g.count(j))
      {
        w = f[j - 1];
        count = c[j - 1] * (b - w);
      }
      else
      {
        count = c[j - 1] * (b - 0);
      }
      a -= count;
      pr.eb(make_pair(-a, j));
    }
    SORT(pr);
    ans = pr[0].first;
    for (auto x : pr)
    {
      if (x.first == ans)
      {
        cout << x.second << endl;
        g.insert(x.second);
        f[x.second - 1] = b;
        break;
      }
    }
  }
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll n, m, d;
    cin >> n >> m >> d;

    double ans;
    if (d == 0) ans = (double)(m - 1) / n;
    else ans = (double)(m - 1) * (double)(2 * (n - d)) / (n * n);

    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main(){
    char s[20];
    scanf("%s",s);
    for(int i = 0; s[i] != '\0'; i++){
        if(s[i] == ','){
            printf(" ");
        }else{
            printf("%c",s[i]);
        }
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 888
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
N,M = map(int,input().split())
Map = [[] for _ in range(N)]
for _ in range(M):
    a,b = map(int,input().split())
    Map[a-1].append(b-1)
    Map[b-1].append(a-1)
sign = [0]*N
depth = [-1]*N
depth[0] = 0
q = deque([0])
while len(q) != 0:
    cur = q.popleft()
    for chi in Map[cur]:
        if depth[chi] != -1:
            continue
        depth[chi] = depth[cur]+1
        sign[chi] = cur
        q.append(chi)
print("Yes")
for i in range(1,N):
    print(sign[i]+1)

Measured memory_bytes: 52512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x=0;
  cin>>x;
  int coin500,coin5,amari=0;
  
  coin500=x/500;
  amari=x%500;
  coin5=amari/5;
  
  cout<<coin500*1000+coin5*5;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool is_prime(int n)
{
	if(n < 2)
		return false;
	if(n == 2)
		return true;
	for(int i=2; i*i<=n; i++)
		if(n % i == 0)
			return false;
	return true;
}
int main() 
{
	int n;
	scanf("%d", &n);
	for(int i=n; i<=1145141919810; i++)
		if(is_prime(i))
		{
			printf("%d", i);
			exit(0);
		}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main(){
   long long int a,b,n;
  cin>>a>>b>>n;
  long long int ans;
  long long int x;
  if(n<b){
     x=n;
  }
   else if(n%b==0)
    x=n-1;
  else if(n>b)
    x=b-1;
  
  long long int d=x*a;
  ans=(d/b)-a*(x/b);
  cout<<ans<<"\n";
}

Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

constexpr ll INF = 1e16;
constexpr ll INM = 114514;
constexpr ll MOD = 1e9 + 7;
constexpr ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll n, k, q;
	cin >> n >> k >> q;
	vector<ll> a(n, k - q);
	for (int i = 0; i < q; i++) {
		int x;
		cin >> x;
		a[--x]++;
	}
	for (int i = 0; i < n; i++) {
		dump(a[i] > 0 ? "Yes" : "No");
	}
	return 0;
}


Measured memory_bytes: 1408
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline
a = [0]*4
for i in range(3):
    n,m = map(int,input().split())
    n-=1;m-=1
    a[n] += 1
    a[m] += 1
a.sort()
if a == [1,1,2,2]:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
object Main extends App{
val Array(n,m,x) = scala.io.StdIn.readLine.split("\\s").map(_.toInt)

val a_list = scala.io.StdIn.readLine.split("\\s").map(_.toInt)

val hoge = a_list.partition(i => i>=x)

println(Seq(hoge._1.length,hoge._2.length).min)
}

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

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

void solve(void){
	string s;
	int K, l;
	cin >> s >> K;
	l = s.length();
	rep(l, i) {
		if (s[i] == 'a') continue;
		int cnt = 'z' - s[i] + 1;
		if(cnt > K) {
			continue;
		}
		s[i] = 'a';
		K -= cnt;
	}
	s[l-1] = (char)((s[l-1] - 'a' + K)%26 + 'a');
	cout << s << endl;
}

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


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
using P = pair<int, int>;
constexpr int INF = 1 << 30;

struct Graph {
    Graph(const int n)
    {
        edge.resize(n);
    }
    void addEdge(const int from, const int to)
    {
        edge[from].push_back(to);
    }
    vector<vector<int>> edge;
};

int main()
{
    int N, M, K;
    cin >> N >> M >> K;
    vector<int> dark_ind(N, -1);
    vector<int> D(M);
    for (int i = 0; i < M; i++) {
        cin >> D[i];
        D[i]--;
        dark_ind[D[i]] = i;
    }
    const int maximum = 1 << M;
    Graph g(N);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < K; j++) {
            int to;
            cin >> to;
            to--;
            g.addEdge(i, to);
        }
    }

    queue<P> q;
    q.push(make_pair(maximum - 1, 0));
    vector<int> distance(maximum, INF);
    vector<bool> used(maximum, false);
    used[maximum - 1] = true;
    distance[maximum - 1] = 0;
    while (not q.empty()) {
        const P& p = q.front();
        const int state = p.first;
        const int dist = p.second;
        q.pop();
        for (int i = 0; i < K; i++) {
            vector<bool> newdark(M, false);
            for (int j = 0; j < M; j++) {
                if (state & (1 << j)) {
                    const int to = g.edge[D[j]][i];
                    if (dark_ind[to] != -1) {
                        newdark[dark_ind[to]] = true;
                    }
                }
            }
            int newstate = 0;
            for (int j = 0; j < M; j++) {
                if (newdark[j]) {
                    newstate += (1 << j);
                }
            }
            if (not used[newstate]) {
                used[newstate] = true;
                distance[newstate] = dist + 1;
                q.push(make_pair(newstate, dist + 1));
            }
        }
    }
    cout << distance[0] << endl;

    return 0;
}

Measured memory_bytes: 3504
#include<bits/stdc++.h>
using namespace std;
long long aa;bool bb;char ch;
long long scan()
{
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	ch=='-'?(bb=1,aa=0):(bb=0,aa=ch-48);
	while(ch=getchar(),(ch>='0'&&ch<='9'))
		aa=aa*10+ch-48;
	return (bb?(-aa):(aa));
}
char mp[110][110];
int S=202,T=203;
int H,W;
int vis[300],q[300],d[300],head,tail;
int last[300],cur[300],tot=1;
struct E
{
	int next,to,flow;
} e[30000];
void add(int u,int v,int f)
{
	e[++tot].next=last[u];
	last[u]=tot;
	//cout<<u<<" "<<last[u]<<endl;
	e[tot].to=v;
	e[tot].flow=f;
}
int ans=0;
int inf=2000000000;
bool BFS()
{
	memset(vis,0,sizeof(vis));
	q[1]=S;
	d[S]=0;
	vis[S]=1;
	head=0;
	tail=1;
	while(head<tail)
	{
		for(int i=last[q[++head]];i;i=e[i].next)
		{
			if(!vis[e[i].to]&&e[i].flow>0)
			{
				vis[e[i].to]=1;
				d[e[i].to]=d[q[head]]+1;
				q[++tail]=e[i].to;
			}
		}
		//cout<<q[head]<<endl;
	}
	return vis[T];
}
int Min(int u,int v){return u<v?u:v;}
int DFS(int u,int a)
{
	if(u==T||a==0)
		return a;
	int f,flow=0;
	if(cur[u]==0)
		cur[u]=last[u];
	for(int& i=cur[u];i;i=e[i].next)
	{
		if(d[u]+1==d[e[i].to]&&(f=DFS(e[i].to,Min(a,e[i].flow)))>0)
		{
			e[i].flow-=f;
			e[i^1].flow+=f;
			flow+=f;
			a-=f;
			if(a==0)
				break;
		}
	}
	return flow;
}

int main()
{
	scanf("%d%d",&H,&W);
	for(int i=1;i<=H;++i)
		scanf("%s",mp[i]+1);
	
	for(int i=1;i<=H;++i)
		for(int j=1;j<=W;++j)
		{
			if(mp[i][j]=='S')
			{
				add(S,i,inf);
				add(i,S,0);
				add(S,H+j,inf);
				add(H+j,S,0);
			}
			else if(mp[i][j]=='T')
			{
				add(i,T,inf);
				add(T,i,0);
				add(H+j,T,inf);
				add(T,H+j,0);
			}
			else if(mp[i][j]=='o')
			{
				add(i,H+j,1);
				add(H+j,i,1);
			}
		}
	while(BFS())
	{
		memset(cur,0,sizeof(cur));
		ans+=DFS(S,inf);
		//cout<<ans<<endl;
	}
	if(ans>=inf)
		puts("-1");
	else
		cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,W;
 
  cin >> N >> W;
 
  vector<int> w(N), v(N);
  vector<vector<long long> > dp(N+1,vector<long long>(W+1,0));
 
  for(int i=0;i<N;i++) {
    cin >> w[i];
    cin >> v[i];
  }
 
 
 
  for(int i=0;i<N;i++) {
    for(int j=0;j<=W;j++) {
      if(j-w[i]>=0) {
        dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+v[i]);
      }
      else {
        dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
      }
    }
  }
 
  // for(int i=0;i<=N;i++) {
  //   for(int j=0;j<=W;j++) {
  //     cout << dp[i][j] << " ";
  //   }
  //   cout << endl;
  // }
 
  cout << dp[N][W] << endl;
 
  return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        rep(i, 0, 1000) {
                rep(j, 0, 1000) {
                        if (i*4 + j*7 == N) {
                                cout << "Yes" << endl;
                                return 0;
                        }
                }
        }
        cout << "No" << endl;
}

Measured memory_bytes: 3600
package main

import "fmt"

func cube(a int) int {
	return a * a * a
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	sum := cube(n / k)
	if k%2 == 0 {
		sum += cube(n/(k/2) - n/k)
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
int main() {
	int n, count = 0;
	cin >> n;
	for (int i = 1; i <= n; i++)count += i;
	cout << count << endl;
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
// luogu-judger-enable-o2
#include<bits/stdc++.h>
#define ll long long
#define uint unsigned
#define ull unsigned ll
#define db double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define vi vector<int>
#define vpi vector<pii >
#define IT iterator
 
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define y1 wzpakking
#define fi first
#define se second
#define BG begin
#define ED end
 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define sqr(x) (1ll*x*x)
 
#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
#define inf (1<<30)
#define INF (1ll<<58)
using namespace std;
int n,f[2][3],g[2][3];
ll x[100005],y[100005];
bool calc(ll pos){
	bool ans=0;
	For(i,1,n){
		ll v=pos-y[i];
		if (v>=0&&(x[i]&v)==v) ans^=1;
	}
	return ans;
}
bool solve(ll S,int rem){
	bool ans=0;
	For(i,1,n) if (y[i]<S){
		ll lim=S-y[i];
		For(v,0,2) f[0][v]=(v==0),f[1][v]=0;
		Rep(j,60,0){
			For(v,0,2) g[0][v]=g[1][v]=0;
			For(fl,0,1){
				int mx=(x[i]>>j)&1;
				if (!fl&&!((lim>>j)&1)) mx=0;
				For(v,0,2) if (f[fl][v])
					For(vnow,0,mx){
						int to=(v+vnow*((j&1)+1))%3;
						g[fl|(((lim>>j)&1)^vnow)][to]^=1;
					}
			}
			For(v,0,2){
				f[0][v]=g[0][v];
				f[1][v]=g[1][v];
			}
		}
		ans^=f[1][(rem-y[i]%3+3)%3];
	}
	return ans;
}
int main(){
	scanf("%d",&n);
	For(i,1,n){
		scanf("%lld%lld",&x[i],&y[i]);
		x[i]+=INF; y[i]+=INF;
	}
	int spe=0;
	for (;!solve(1ll<<60,spe);++spe);
	ll pos=0;
	Rep(i,59,0)
		if (solve(pos,spe)==solve(pos+(1ll<<i),spe))
			pos+=1ll<<i;
	ll l=pos,r=pos;
	Rep(i,59,0){
		if (calc(l-(1ll<<i))) l-=1ll<<i;
		if (calc(r+(1ll<<i))) r+=1ll<<i;
	}
	printf("%lld %lld\n",r-l-INF,l-INF);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int n;
  cin>>n;
  int x[n];
  P memo[n];
  for(int i=0;i<n;i++){
    cin>>x[i];
    memo[i]=make_pair(x[i],i);
  }
  sort(memo,memo+n);
  int shita=memo[n/2-1].first,ue=memo[n/2].first;
  for(int i=0;i<n;i++){
    if(x[i]<=shita) cout<<ue;
    else cout<<shita;
    cout<<endl;
  }
  return 0;
}


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

using namespace std;

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

    constexpr auto kRatingLength = 400;
    constexpr auto kColors = 3200 / kRatingLength;

    vector<bool> present(kColors, false);
    auto distinct = 0;
    auto free_choice = 0;

    for (auto i = 0; i < n; i += 1) {
        int rating;
        cin >> rating;

        auto color = rating / 400;
        if (color >= kColors) {
            free_choice += 1;
        } else if (!present[color]) {
            present[color] = true;
            distinct += 1;
        }
    }

    cout << max(1, distinct) << " " << distinct + free_choice << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //library
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //for-loop (from 0)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++) //for-loop (from 1)
#define all(x) (x).begin(),(x).end() //start-to-end iteration, mainly in upper_bound, lower_bound
#define SZ(x) ((int)(x).size()) //unsigned to signed

using namespace std;
using ll = long long; //long long
ll M = 1000000000 + 7;
const ll INF = 1LL << 60;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } //compare a,b and replace by greater
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } //compare a,b and replace by smaller
ll qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; } //power
ll qp(int a, ll b, ll Mod) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%Mod; a = 1ll * a*a%Mod; } while (b >>= 1); return ans; } //power(mod)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } //gcd
int dx[4] = { 1,0,-1,0 }; //path
int dy[4] = { 0,1,0,-1 }; //path
ll RS(ll N, ll P) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2); return sq*sq; } else { return N*RS(N, P - 1); } } //power(repeat-square,fast)
ll nPr(ll n, ll r) { ll ans = 1; rep(i, r) { ans = ans * (n - i); } return ans; } //permutation
ll nCr(ll n, ll r) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1); bunshi = bunshi * (n - i); } return bunshi / bunbo; } //combination
ll RS(ll N, ll P, ll Mod) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2, Mod); return sq*sq%Mod; } else { return N*RS(N, P - 1, Mod) % Mod; } } //power(mod)(repeat-square,fast)
ll nPr(ll n, ll r, ll Mod) { ll ans = 1; rep(i, r) { ans = ans * (n - i) % Mod; } return ans; } //permutation
ll nCr(ll n, ll r, ll Mod) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1) % Mod; bunshi = bunshi * (n - i) % Mod; } return bunshi * RS(bunbo, Mod - 2, Mod) % Mod; } //combination


int main(void) {
  ll N; cin >> N;
  ll abc[101000][3], dp[101000][3];
  rep(i,N) cin >> abc[i][0] >> abc[i][1] >> abc[i][2];
  dp[1][0] = abc[0][0]; dp[1][1] = abc[0][1]; dp[1][2] = abc[0][2];
  for (int i=2; i<=N; i++){
    rep(j,3){
      dp[i][j]=-INF;
      rep(k,3){
        if (j != k)
          chmax(dp[i][j],dp[i-1][k]+abc[i-1][j]);
      }
    }
  }
  
  ll res=0;
  rep(j,3) chmax(res,dp[N][j]);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 4992
#include<iostream>
using namespace std;
int main(){
  int n,a=0,f=0;
  string s[101];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s[i];
    if(s[i]=="A")a++;
    else a--;
    if (a<0)f=1;
  }
  if(f==0&&a==0)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 3144
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    string s;
    cin>>s;
    int a=0,b=0;
    int ar[n+1];
    fill(ar, 0);
    for(int i=0;i<n;i++)
    {
        if(s[i]=='R')
        {
            a++;
            ar[i+1]=1;
        }
        else
        b++;
    }
    for(int i=1;i<=n;i++)
    ar[i]+=ar[i-1];
    int ans=INF;
    for(int i=0;i<=n;i++)
    {
        int cur=abs(a-i);
        cur+=(ar[n]-ar[i]-a+i);
        //cout<<i<<" "<<cur<<"\n";
        ans=min(ans, cur);
    }
    cout<<ans;
}

Measured memory_bytes: 5316
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)

using namespace std;

int main(){
	while(1){
		int n,m,s1[105],s2[105],sum1=0,sum2=0;
		cin>>n>>m;
		if(n==0&&m==0) break;
		for(int i=0; i<n; i++){
			cin>>s1[i];
			sum1+=s1[i];
		}
		for(int i=0; i<m; i++){
			cin>>s2[i];
			sum2+=s2[i];
		}

		bool flag = false;
		int tt1,tt2, t1, t2, inf = 999999;
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				t1 = sum1; t2 = sum2;
				t1 = t1 - s1[i] + s2[j];
				t2 = t2 + s1[i] - s2[j];
				if(t1 == t2){
					if(s1[i] + s2[j] < inf){
						inf = s1[i] + s2[j];
						tt1 = s1[i];
						tt2 = s2[j];
					}
					flag = true;
				}
			}
		}
		if(flag){
			cout<<tt1<<" "<<tt2<<endl;
		}else{
			cout<<-1<<endl;
		}
	}
	

	return 0;
}

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

int main(void){
  int n; cin >> n;
  double x[n],y[n];
  rep(i,n){
    cin >> x[i] >> y[i];
  }
  int kaijo = 1;
  for(int i = 1; i < n; i++){
    kaijo *= i;
  }
  double sum = 0;
  for(int i = 0; i < n-1; i++){
    for(int j = i+1; j < n; j++){
      double nijo = (x[i] - x[j])*(x[i] - x[j]) + (y[i]-y[j])*(y[i]-y[j]);
      sum += pow(nijo,0.5);
    }
  }
  cout << fixed << setprecision(20);
  cout << sum*kaijo/(n*kaijo)*2 << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int N;

vector<i64> h;
i64 A,B;

bool f(i64 k){
  i64 d = B * k;
  i64 ans = 0;
  rep(i,0,N - 1){
    i64 re = max(0LL,h[i] - d);
    ans += re / A + min(re % A, 1LL);
  }

  return ans <= k;
}

int main(){
  cin >> N >> A >> B;
  A -= B;
  h.resize(N);
  rep(i,0,N - 1) cin >> h[i];

  i64 ok = 1e9;
  i64 ng = -1;
  while(ok - ng > 1){
    i64 mid = (ok + ng) / 2;
    if(f(mid)){
      ok = mid;
    }
    else{
      ng = mid;
    }
  }
  cout << ok << endl;
}


Measured memory_bytes: 1024
n,a,b,c,d = map(int,input().split())

xpen=0
xmoney=0
ypen=0
ymoney=0

while(xpen<n):
    xpen=xpen+a
    xmoney=xmoney+b
while(ypen<n):
    ypen=ypen+c
    ymoney=ymoney+d

if(xmoney>ymoney):
    print(ymoney)
else:
    print(xmoney)



Measured memory_bytes: 5596
#include <iostream>

const int N = 100;

int main() {
  int n = 0;
  int a[N] = {0};

  std::cin >> n;

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

  int count = 0;

  
  for (int i = 0; i < n; i++) {
    int min = i;
    
    for (int j = i + 1; j < n; j++) {
      if (a[j] < a[min]) {
	min= j;
      }
    }
    
    if (a[min] < a[i]) {
      int tmp = a[min];
      a[min] = a[i];
      a[i] = tmp;

      count++;
    }
  }

  for (int i = 0; i < n; i++) {
    std::cout << a[i];

    if (i < (n - 1)) {
      std::cout << " ";
    } else {
      std::cout << std::endl;
    }
  }

  std::cout << count << std::endl;
  
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <ctype.h>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
// #include <pair> 
       
using namespace std;
       
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
 
// #define MAX 100010
 
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
 
// long long binpow(long long a,long long b)
// {
//     if (b == 1) return a;
//     long long res = binpow(a, b/2)%MOD;
//     if (b % 2) return (res*((res*a)%MOD))%MOD;
//     else return (res * res)%MOD;
// }
 
// long long int fact(long long int a)
// {
//     if(a==0||a==1)
//         return 1;
//     long long int ans = 1;
//     for(int i=a;i>=1;i--)
//         ans = (ans * i);
//     return ans;
// }
 
// long long int ivmod(long long int a)
// {
//     return binpow(a,MOD-2);
// }
 
// long long int ncr(long long int a,long long int b)
// {
//     long long int pans=1;
//     for(int i =a;i>max(b,a-b);i--)
//         pans=pans*i;
//     long long int div = fact(min(b,a-b));
//     // cout<<ans<<"            "<<div<<endl;
//     pans = pans/div;
//     return pans;
// }

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    // #endif   
    string a,b,c,d;
    cin>>a>>b;
    c = a;
    d =b;
    if(d.length()>c.length())
    {
        cout<<"LESS"<<endl;
        return 0;
    }
    else if(c.length()>d.length())
    {
        cout<<"GREATER"<<endl;
        return 0;
    }
    for(int i=0;i<min(d.length(),c.length());i++)
    {
        if(c[i]>d[i])
        {
            cout<<"GREATER"<<endl;
            return 0;
        }
        else if(c[i]<d[i])
        {
            cout<<"LESS"<<endl;
            return 0;
        }
    }
    cout<<"EQUAL"<<endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    from collections import Counter

    c = Counter(A)

    a = 0
    b = 0

    for k,v in sorted(c.items(), reverse=True):
        if(v >= 4):
            if(a == 0 and b == 0):
                a = k
                b = k
                break
            else:
                b = k
                break
        if(2 <= v < 4):
            if(a != 0):
                b = k
                break
            else:
                a = k

    print(a*b)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 29076
#include <stdio.h>

int main(){

  int n,x,i,j,k,count,tmp;

  while(scanf("%d %d",&n,&x),n+x!=0){
    count=tmp=0;
    for(i=1;i<n-1;i++){
      for(j=i+1;j<n;j++){
        for(k=j+1;k<=n;k++){
          if(i+j+k==x) count++;
        }
      }
    }
    printf("%d\n",count);
  }
  return 0;
}


Measured memory_bytes: 600
import scala.collection.mutable.HashMap
import scala.collection.mutable.ArrayBuffer

object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val d  = inputs(0).toInt // 365
  val ci = inputs(1).split(" ").map(_.toInt)
  val sdi = HashMap.empty[Long, Seq[Long]]
  // 日付ごとに、満足度の配列を持つ
  inputs.splitAt(2)._2.zipWithIndex.foreach { case (line, index) =>
    sdi.update(index, line.split(" ").map(_.toLong))
  }

  solve(d, ci, sdi)

  // 1. 単純にでかい数を持っているものを抽出
  // 2. 減少分と上昇分を考慮して最大になる物を選ぶ
  def solve(d: Int, ci: Array[Int], sdi: HashMap[Long, Seq[Long]]): Unit = {
    val last = ArrayBuffer.fill(26)(0)
    var score = 0L
    val range = Range(0, 26, 1)

    (0 until d).foreach { day =>
      val todayValues = sdi(day)
      val todayScores = range.map { i =>
        last(i) + todayValues(i)
      }
      val max = todayScores.max
      // println(s"max value = $max")
      // TODO: 同じ数値のものが複数ある可能性を考慮
      val maxIndexes = range.map { i =>
        if (max == todayScores(i)) {
          i
        } else {
          -1
        }
      }.filter(v => v != -1)

      val minCiOfTopValue      = maxIndexes.map(v => ci(v)).min
      val minCiOfTopValueIndex = range.filter(i => maxIndexes.exists(_ == i) && ci(i) == minCiOfTopValue).min

      // println(s"selected: $i")
      println(minCiOfTopValueIndex + 1)

      range.foreach { i =>
        last.update(i, last(i) + ci(i))
      }
      last.update(minCiOfTopValueIndex, 0)

      // println(s"score: $score")
    }

  }

}

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

int main()
{
    string s;
    cin >> s;

    if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3]){
        puts("Bad");
    }else {
        puts ("Good");
    }
    return 0;
}

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

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;

typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<" "<<y<<endl
#define pl(x)                   out<<x
#define p2l(x,y)                out<<x<<" "<<y
#define range(v)                v.begin(),v.end()
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

const int INF = 1e18L + 5;

void ssolve(std::istream& in, std::ostream& out){
    int N, W;
    s2(N, W);

    vi ws(N), vls(N);
    int total_value = 0;
    f(i, 0, N){
        s2(ws[i], vls[i]);
        total_value += vls[i];
    }

    vi dp(total_value + 1, INF);
    vi newdp(total_value + 1, INF);
    dp[0] = 0;
    newdp = dp;
    f(i, 0, N){
        for(int j = 0; j <= total_value - vls[i]; j++){
            newdp[j + vls[i]] = min(dp[j + vls[i]], dp[j] + ws[i]);
        }
        dp = newdp;
    }

    int ans = INF;
    for(int i = total_value; i >= 0; i--){
        if(dp[i] <= W){
            ans = i;
            break;
        }
    }
    p(ans);
    return;
}

class EKnapsack2 {
public:
void solve(std::istream& in, std::ostream& out) {
    ios_base::sync_with_stdio(false);
    in.tie(0);out.tie(0);
    int t;
    int READ = 0;
    if(READ) s(t);
    else t = 1;
    while(t--){
        ssolve(in, out);
    }
}
};

integer main() {
    EKnapsack2 solver;
    std::istream& in(std::cin);
     std::ostream& out(std::cout);
     solver.solve(in, out);
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll P[200005];

int main() {
    ll N;
    cin >> N;
    ll min = INF;
    ll ans = 0;
    REP(i, N) {
        cin >> P[i];
        min = std::min(min, P[i]);
        if (P[i] <= min)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

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

"""
参考：https://img.atcoder.jp/agc023/editorial.pdf
"""

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, initial=1)
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def nCr(n, r):
    # 10C7 = 10C3
    r = min(r, n-r)
    return factorial(n) // (factorial(r) * factorial(n-r))

N = INT()
aN = LIST()

sm = [0] * (N+1)
for i in range(N):
    sm[i+1] = sm[i] + aN[i]

c = Counter(sm)
ans = 0
for k, v in c.items():
    if v >= 2:
        ans += nCr(v, 2)
print(ans)


Measured memory_bytes: 118288