akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
string alp="abcdefghijklmnopqrstuvwxyz";

ll INF=1000000000;

int main(){
    ll N,M;
    cin >> N >> M;
    vector<ll> cost(M);
    vector<ll> S(M,0);
    rep(i,M){
        int a,b;
        cin >> a >> b;
        cost[i]=a;
        rep(j,b){
            int c;
            cin >> c;
            c--;
            S[i]|=(1<<c);
        }
    }
    vector<ll> dp(1<<N,INF);
    dp[(1<<N)-1]=0;
    for (int bit=(1<<N)-2;bit>=0;bit--){
        rep(j,M){
            rep(k,N){
                if (!(bit&(1<<k))&&S[j]&(1<<k)){
                    dp[bit]=min(dp[bit],dp[bit|S[j]]+cost[j]);
                }
            }
        }
    }
    if (dp[0]==INF){
      dp[0]=-1;
    }
    cout << dp[0] << endl;
}

Measured memory_bytes: 384
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;

int main() {
	int N;
	cin >> N;
	vl A(N+1);
	REP(i, N) {
		cin >> A[i+1];
	}
	vl S(N+1, 0);
	FOR(i, 1, N) {
		S[i] = S[i - 1] + A[i];
	}
	map<ll, ll> count;
	FOR(i, 0, N) {
		count[S[i]]++;
	}

	ll ans = 0;
	for (auto it = count.begin(); it != count.end(); ++it) {
		ll p = it->second;
		ans += p*(p-1) / 2;
	}

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

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

 
int main(){
  string s;
  cin >> s;
  int n = s.length();
  int ans = 10000;
  for(int i=0; i<n-2; i++){
    int tmp = s[i]-'0';
    for(int j=1; j<=2; j++){
      tmp *= 10;
      tmp += s[i+j]-'0';
    }
    ans = min(ans, abs(753-tmp));
  }
  cout << ans << endl;
  return 0;
}


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

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

  if (s.at(2) == s.at(3) && s.at(4) == s.at(5)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3608
// #includes {{{
	#include<stdio.h>
	#include<stdlib.h>
	#include<string.h>
	#include<math.h>
	#include<assert.h>
	#include<stdarg.h>
	#include<time.h>
	#include<limits.h>
	#include<ctype.h>
	#include<string>
	#include<map>
	#include<set>
	#include<queue>
	#include<algorithm>
	#include<vector>
	#include<iostream>
	#include<sstream>
	using namespace std;
	// }}}
	// #defines {{{
	#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
	#define SZ(x) ((int)(x).size())
	#define ALL(x) (x).begin(),(x).end()
	#define REP(i,n) for(int i=0;i<(n);i++)
	#define REP1(i,a,b) for(int i=(a);i<=(b);i++)
	#define PER(i,n) for(int i=(n)-1;i>=0;i--)
	#define PER1(i,a,b) for(int i=(a);i>=(b);i--)
	#define RI(x) scanf("%d",&x)
	#define DRI(x) int x;RI(x)
	#define RII(x,y) scanf("%d%d",&x,&y)
	#define DRII(x,y) int x,y;RII(x,y)
	#define RIII(x,y,z) scanf("%d%d%d",&x,&y,&z)
	#define DRIII(x,y,z) int x,y,z;RIII(x,y,z)
	#define RS(x) scanf("%s",x)
	#define PI(x) printf("%d\n",x)
	#define PIS(x) printf("%d ",x)
	#define CASET int ___T,cas=1;scanf("%d",&___T);while(___T--)
	#define CASEN0(n) int cas=1;while(scanf("%d",&n)!=EOF&&n)
	#define CASEN(n) int cas=1;while(scanf("%d",&n)!=EOF)
	#define MP make_pair
	#define PB push_back

	#define MS0(x) memset(x,0,sizeof(x))
	#define MS1(x) memset(x,-1,sizeof(x))

	#define F first
	#define S second
	typedef pair<int,int> PII;
	typedef long long LL;
	typedef unsigned long long ULL;
	// }}}
LL a,b,c,d,n;
main(){
	cin>>a>>b>>c>>d>>n;
	a*=4;
	b*=2;
	a=min(a,min(b,c));
	if (a*2<d){
		cout<<n*a<<endl;
	}
	else{
		cout<<d*(n/2)+(n%2)*a<<endl;
	}

}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>

using ll = long long;
int M = 100100100;
using namespace std;
int main()
{

	int n;
	cin >> n;
	vector<double> v(n);
	for (int i = 0;i < n;i++)
		cin >> v[i];
	sort(v.begin(), v.end());
	double ans = (v[0] + v[1]) / 2;
	v[0] = ans;
	v[1] = M;
	
	sort(v.begin(), v.end());
	if (n == 2) {
		cout << ans;
		return 0;
	}

	for (int i = 2;i < n;i++) {
		ans = (v[1] + v[0]) / 2;
		v[0] = ans;
		v[1] = M;
		sort(v.begin(), v.end());

	}
	cout << ans;
	
	
}


Measured memory_bytes: 3800
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    string s;
    cin >> s;
    s[5] = ' ';
    s[13] = ' ';

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <queue>
     
using namespace std;
typedef long long ll;
typedef pair<long long, long long> pll;


struct pair_hash
{
	size_t operator()(const std::pair<ll, ll> &v) const 
    {
      
        return std::hash<ll>()(v.first) ^ std::hash<ll>()(v.second);
    }
};

struct state
{
    ll a,b,c;

    state(ll a, ll b, ll c) : a(a), b(b), c(c)
    {

    }

  bool operator==(const state &other) const
  { return (a == other.a
            && b == other.b
            && c == other.c);
  }
};

struct KeyHasher
{
    size_t operator()(const state& k) const
  {
    //using std::size_t;
    //using std::hash;
    //using std::string;

    return ((hash<ll>()(k.a)
               ^ (hash<ll>()(k.b) << 1)) >> 1)
               ^ (hash<ll>()(k.c) << 1);
  }
};  

void solve()
{
	ll a,b,c,k;

	cin >> a >> b >> c >> k;

	ll res = 0;

	if (k > 0)
	{
		res += min(k, a);
		k -= min(k, a);
	}

	if (k > 0)
	{
		// res += min(k, a);
		k -= min(k, b);
	}

	if (k > 0)
	{
		res -= min(k, c);
		k -= min(k, c);
	}


	cout << res << endl;

}


int main()
{
	solve();

	return 0;
}




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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007

//cout << (c)?"Yay!":":(" << endl;

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> v;
    rep(i, h)
    {
        string str;
        cin >> str;
        v.push_back(str);
    }

    int ans = 0;

    rep(i, (int)pow(2, h))
    {
        rep(j, (int)pow(2, w))
        {
            int count = 0;
            int tate[h] = {0};
            int yoko[w] = {0};
            rep(q, h)
            {
                if ((i & (1 << q)) != 0)
                    tate[q] = 1;
               // cout << (i & (1 << q)) << endl;
            }
            rep(q, w)
            {
                if ((j & (1 << q)) != 0)
                    yoko[q] = 1;
            }
            // rep(q, h)
            // {
            //     cout << tate[q];
            // }
            // rep(q, w)
            // {
            //     cout << yoko[q];
            // }
            rep(k, h)
            {
                rep(l, w)
                {
                    if (tate[k] == 1)
                        continue;
                    if (yoko[l] == 1)
                        continue;
                    if (v[k][l] == '#')
                        count++;
                }
            }
         //   cout << count << endl;
            if (count == k)
            {
                ans++;
                //cout << i + 1 << j + 1 << endl;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4096
fun main(args: Array<String>) {
    val n = readInteger()
    val stArray = Array(n) {
        val (s, t) = readStringList()
        Pair(s, t.toInt())
    }
    val x = readLine()!!

    val time = stArray.sumBy { it.second }
    val index = stArray.indexOfFirst { it.first == x }
    val aa = stArray.dropLast(stArray.size - index - 1).sumBy { it.second }
    println(time - aa)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 37856
n = int(input())
h = list(map(int,input().split()))
dp = [0 for i in range(n)]
for i in range(1,n):
    if i == 1:
        dp[i] = abs(h[1]-h[0])
    else:
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])

Measured memory_bytes: 13928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);	
	int x,y,z;
  	cin >> x >> y >> z;
  	cout << z << " "<<x <<" "<<y<<endl;
  	return 0;
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

N = int(input())
A = [None] + list(map(int, input().split()))
answer = []
B = [0] * (N + 1)

for n in range(1, N + 1)[::-1]:
    x = sum(B[2*n::n])
    if x % 2 == A[n]:
        continue
    B[n] += 1
    answer.append(str(n))

print(len(answer))
print(' '.join(answer))


Measured memory_bytes: 17800
#include<bits/stdc++.h>
#define REP(i,x,y) for(ll i=x; i<=y; i++)
#define BIT(t) ((long long 1) << t)
#define PER(i,y,x) for(ll i=y; i>=x; i--)
#define vll vector<ll>
#define vvll vector<vector<ll>>
using namespace std;
typedef long long ll;

ll const kmax = 50;

ll f(ll n,ll a,ll k){
	ll t = 1;
	while(1){
		bool flag = 1;
		ll cur = 1;
		REP(i,1,k){
			cur *= t+1;
			if(cur >= n){
				flag = 0;
				break;
			}
		}
		if(flag){
			t++;
		}else break;
	}
	ll ttl = pow(t,k);
	ll u = 0;
	while(ttl < n){
		ttl = ttl / t * (t + 1);
		u++;
	}
	ll ans = (k-1) * a + (k-u) * t + u * (t + 1);
	return ans;
}

int main(){
	ll n,a;
	cin >> n >> a;
	ll ans = n;
	REP(k,2,kmax){
		ans = min(ans, f(n,a,k));
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 100005;
typedef long long i64;

class Edge {
public:
  int nxt, to;
} e[MAX_N << 1];

int head[MAX_N], cnt;
void addedge(int u, int v) {
  e[++cnt] = (Edge){head[u], v}, head[u] = cnt;
  e[++cnt] = (Edge){head[v], u}, head[v] = cnt;
}

int N, M, dep[MAX_N], fa[MAX_N], sum[MAX_N];
int c1, c2;
bool flag;

void dfs(int u, int v) {
  dep[u] = dep[v] + 1, fa[u] = v;
  if (dep[u] & 1) {
    sum[u] = 1;
  } else {
    sum[u] = -1;
  }

  for (int i = head[u]; i; i = e[i].nxt)
    if (!dep[e[i].to]) {
      dfs(e[i].to, u);
      sum[u] += sum[e[i].to];
    } else if (e[i].to != v && dep[e[i].to] < dep[u]) {
      if (!(dep[u] - dep[e[i].to] & 1)) flag = 1;
      c1 = u, c2 = e[i].to;
    }
}

int main() {
  scanf("%d%d", &N, &M);
  for (int i = 1, u, v; i <= M; ++i) {
    scanf("%d%d", &u, &v);
    addedge(u, v);
  }

  dfs(1, 0);

  if (M == N - 1) {
    if (sum[1] != 0) {
      puts("-1");
      return 0;
    }
    
    i64 res = 0;
    for (int i = 2; i <= N; ++i)
      res += abs(sum[i]);
    printf("%lld\n", res);
  } else if (flag) {
    if (sum[1] & 1) {
      puts("-1");
      return 0;
    }

    int add = -sum[1] / 2;
    while (c1) sum[c1] += add, c1 = fa[c1];
    while (c2) sum[c2] += add, c2 = fa[c2];
    
    i64 res = abs(add);
    for (int i = 2; i <= N; ++i)
      res += abs(sum[i]);
    printf("%lld\n", res);
  } else {
    if (sum[1] != 0) {
      puts("-1");
      return 0;
    }

    static int A[MAX_N];
    static bool vis[MAX_N];
    
    int tot = 1;

    while (c1 != c2) vis[c1] = 1, A[++tot] = sum[c1], c1 = fa[c1];
    
    sort(A + 1, A + tot + 1);
    i64 res = 0;
    for (int i = 2; i <= N; ++i)
      if (!vis[i]) res += abs(sum[i]);
    
    for (int i = 1; i <= tot / 2; ++i)
      res += A[tot - i + 1] - A[i];
    printf("%lld\n", res);
  }
  
  return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int a,b,c,k;
	int ans=0;
	cin >>a>>b>>c>>k;
	ans+=min(a,k);
	k-=min(k,a);
	k-=min(k,b);
	if(k>0){
		ans-=k;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <array>
#include <vector>
#include <map>
#include <utility>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <string>
#include <limits.h>
#include <algorithm>

#define MAXN 100001

using namespace std;

int main(){
    long long  x;
    cin >> x;
    
    cout <<( (x / 11) * 2 + (x%11 == 0 ? 0 :(x % 11 > 6) ? 2:1) ) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
/*int p = 998244353;*/
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define sq(a) (a)*(a)
#define rev(s) reverse(s.begin(),s.end())
#define end_pr(s) cout << s <<endl;return 0
#define itn int
int RE() {
	vel v(3, 2);
	return v.at(4);
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; }
	return ans % p;
}
int inv(int a) {
	return ru(a,p - 2);
}
vel dis(int mid1, vvel &way) {
	int n = way.size();
	vel dist(n, -1); dist[mid1] = 0;
	queue<int> q;
	q.push(mid1);
	while (!q.empty()) {
		int st = q.front(); q.pop();
		rep(i, way[st].size()) {
			int to = way[st][i];
			if (dist[to] == -1) {
				dist[to] = dist[st] + 1;
				q.push(to);
			}
		}
	}
	return dist;
}
pin most_far(int now, int n, vvel &way) {
	vel dist1 = dis(now, way);
	pin ans = mkp(-1, 0);
	rep(i, n) {
		if (dist1[i] > ans.first) { ans = mkp(dist1[i], i); }
	}
	return ans;
}

template<typename T>
V<T> uni(V<T> &v) {
	if (v.size() == 0) { return v; }
	sor(v);
	V<T> ans(1, v[0]);
	for (int i = 1; i < v.size(); i++) {
		if (v[i] != v[i - 1]) { ans.push_back(v[i]); }
	}
	v = ans;
	return v;
}
int s_gcd(int a, int b) {
	if (b == 0) { return a; }
	return s_gcd(b, a%b);
}
int gcd(int a, int b) {
	if (a < b) { swap(a, b); }
	return s_gcd(a, b);
}
vel par;
vel dp;
vvel chi;
int top(int i) {
	if (par[i] < 0) { return i; }
	int ans = top(par[i]);
	par[i] = ans;
	return ans;
}
void merge(int x, int y) {
	par[y] += par[x];
	par[x] = y;
	chi[y].push_back(x);
}
void solve(int now_pot) {
	for (auto x : chi[now_pot]) {
		dp[x] += dp[now_pot];
		solve(x);
	}
}
signed main() {
	int n; cin >> n;
	V<qin> edge(n - 1);
	rep(i, n - 1) {
		int a, b, c; cin >> a >> b >> c;
		a--; b--;
		edge[i] = mkp(c, mkp(a, b));
	}
	par = vel(n, -1);
	dp = vel(n, 0);
	chi = vvel(n);
	vel ans(n,0);
	sor(edge); rev(edge);
	rep(i, n - 1) {
		int c = edge[i].first;
		pin ed = edge[i].second;
		int x = ed.first;
		int y = ed.second;
		x = top(x); y = top(y);
		if ((par[x] > par[y]) xor (chi[x].size()>chi[y].size())) { swap(x, y); }
		int szx = par[x] * -1;
		int szy = par[y] * -1;//par[x]=yにあとでする
		ans[y] += szx * c;
		for (auto st : chi[y]) {
			dp[st] += szx * c;
		}
		dp[x] += szy * c;
		merge(x, y);
	}
	solve(top(0));
	int ret = 0;
	rep(i, n) {
		cout << ans[i] + dp[i] << endl;
	}
}

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

#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> using V = vector<T>;
using P = pair<int, int>;

/*
 */

signed main(){
  int n, p;
  cin >> n >> p;

  V<P> v;
  rep(i, 2, p/i+1){
    int c = 0;
    while(p%i == 0) {
      c++;
      p /= i;
    }
    if(c) v.emplace_back(i, c);
  }
  if(p != 1){
    v.emplace_back(p, 1);
  }

  int ans = 1;
  for(auto i : v){
    if(i.second/n > 0) ans *= pow(i.first, (i.second/n));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
AB = sorted([[int(_) for _ in input().split()] for _ in range(N)],
            key=lambda x: x[1],
            reverse=True)
CD = sorted([[int(_) for _ in input().split()] for _ in range(N)])
 
for i in range(N):
    for j in range(len(AB)):
        if AB[j][0] < CD[i][0] and AB[j][1] < CD[i][1]:
            del AB[j]
            break
print(N - len(AB))

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

int n;
int a[100000];

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

    sort(a,a+n);

    for(int i=0;i<n;i++){
        if(a[i]!=i+(i+n-1)%2){
            cout<<0;
            return 0;
        }
    }
    
    n/=2;
    long long ans=1;
    for(int i=0;i<n;i++){
        ans=(ans*2)%1000000007;
    }
    cout<<ans;
}

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

int main(){
    string s,t;
    cin >> s >> t;
    int x=0;
    int min = 100000000;
    for(int i=0;i<s.size()-t.size()+1;i++){
        x = 0;
        for(int j=i;j<t.size()+i;j++){
            //cout << "i " << i << " j " << j-i<<endl;
            if(s[j] != t[j-i]){
                
                x++;
            }
        }
        if(x < min){
            min = x;
        }
    }
    
    cout << min << endl;
    
}


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

using namespace std;

using ll = long long;
vector<ll> A;
vector<ll> P;

ll dfs(int n, ll x) {
  if (n == 0) return x;
  ll res = 0;
  if (x == 0) return res;
  x--;
  if (x <= A[n-1]) return res + dfs(n-1, x);
  res += P[n-1] + 1; x -= A[n-1] + 1;
  if (x <= A[n-1]) return res + dfs(n-1, x);
  return P[n];
}

int main() {
  int N;
  ll X;
  cin >> N >> X;
  A.resize(N+1, 1);
  P.resize(N+1, 1);
  for (int i = 1; i < N+1; i++) {
    A[i] = A[i-1] * 2 + 3;
    P[i] = P[i-1] * 2 + 1;
  }
  cout << dfs(N, X) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

int arr[1000001];
int main()
{
    fast
    int n,z;
    cin>>n;
    int g;
    bool b=1;
    for(int i=0; i<n; i++)
    {
        cin>>z;
        if(i==0)
            g=z;
        else
            g=__gcd(z,g);
        if(b)
        {
            int s=sqrt(z);
            for(int j=2; j<=s; j++)
            {
                if(z%j==0)
                {
                    if(arr[j]!=0)
                        b=0;
                    arr[j]++;
                    while(z%j==0)
                        z/=j;
                }
            }
            if(z!=1)
            {
                if(arr[z]!=0)
                    b=0;
                arr[z]++;
            }
        }
    }
    if(b)
        cout<<"pairwise coprime";
    else if(g==1)
        cout<<"setwise coprime";
    else
        cout<<"not coprime";







    return 0;
}


Measured memory_bytes: 7428
#include <vector>
#include <iostream>
#include <string>

using namespace std;

int main()
{
  string S;
  int N, K;
  cin >> N >> K >> S;
  
  char k;
  k = S[K - 1];
  if(k == 'A')S[K - 1] = 'a';
  if(k == 'B')S[K - 1] = 'b';
  if(k == 'C')S[K - 1] = 'c';
  
  cout << S << endl;
  
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

N, Ma, Mb = map(int, input().split())
ABC = [list(map(int, input().split())) for _ in range(N)]

sumA = sum([ABC[i][0] for i in range(N)])
sumB = sum([ABC[i][1] for i in range(N)])

INF = 10 ** 15
dp = [[INF for j in range(sumB + 1)] for i in range(sumA + 1)]
dp[0][0] = 0

for a, b, c in ABC:
  for i in range(sumA, -1, -1):
    for j in range(sumB, -1, -1):
      if dp[i][j] != INF:
        dp[i + a][j + b] = min(dp[i + a][j + b], dp[i][j] + c)

answer = INF
for i in range(1, sumA + 1):
  for j in range(1, sumB + 1):
    if dp[i][j] != INF and i / j == Ma / Mb:
      answer = min(answer, dp[i][j])
      
print(answer if answer != INF else -1)

Measured memory_bytes: 43356
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<int> X, Y, A, B, C;
  invec<ll> p(A), q(B), r(C);

  bst::sort(p);
  bst::sort(q);
  bst::sort(r);
  
  vector<ll> qs = q, ps = p, rs = r;
  
  for (int i = A -2; i >= 0; i--)
    ps[i] += ps[i+1];
   for (int i = B -2; i >= 0; i--)
    qs[i] += qs[i+1];
   for (int i = C -2; i >= 0; i--)
    rs[i] += rs[i+1];


 
  ll re = ps[A-X] + qs[B-Y];
  vector<ll> pp;
  copy(p.end() - X, p.end(), back_inserter(pp));
  copy(q.end() - Y, q.end(), back_inserter(pp));
  bst::sort(pp);
  
  REP(i, min((int)C, X + Y)) {
    ll tmp = re - pp[i] + r.back();
    if (re < tmp) {
      re = tmp;
      r.pop_back();
    }
    else break;
  }

  return re;
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 7156
N = int(input())

h = []

for _ in range(N):
    h.append(tuple(map(int, input().split())))

dp = [[0 for j in range(3)] for i in range(N)]
dp[0][0] = h[0][0]
dp[0][1] = h[0][1]
dp[0][2] = h[0][2]

for i in range(N-1):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i+1][j] = max(dp[i+1][j], dp[i][k]+h[i+1][j])

print(max(dp[N-1][x] for x in range(3)))


Measured memory_bytes: 41760
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define rep(i,k,n) for(int (i)=(k);(i)<(n);(i)++)
#define max(a,b) (a)>(b)?(a):(b)
#define min(a,b) (a)<(b)?(a):(b)
#define abs(a,b) (a)< 0 ?(a):-(a)
#define llong long long

int next(int*,int,int);

int main(){
	llong A,B,N; scanf("%lld %lld %lld",&A,&B,&N);
	llong ans;
	if( N >= B ) ans = (A*(B-1))/B;
	else ans = (A*N)/B;
	printf("%lld",ans);
	return 0;
}


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

int main() {
  int a,b;
  cin >>a >>b;
  int total =0;
  total = a +b;
  if(total <= a-b){
    total =a-b;
  }
  if(total <= a*b){
    total = a*b;
  }
  cout <<total <<endl;
  
  
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static int[][] map;
    static int[][] label;


    static ArrayList<String> list;

    static int M;
    static int N;
    static int T;
    static int P;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        long H = scanner.nextLong();

        long max = 0;
        long[] map = new long[N];

        for (int i = 0; i < N; i++) {
            long a = scanner.nextLong();
            long b = scanner.nextLong();

            max = Math.max(max, a);

            map[i] = b;
        }

        long to = 0;
        int ans = 0;

        Arrays.sort(map);
        long nokori = H;
        for (int i = 0; i < N; i++) {
            if(max > map[N - i - 1])break;
            nokori -= map[N - i - 1];
            ans++;
            if(nokori <= 0)break;
        }

        if(nokori <= 0)nokori = 0;
        System.out.println(ans + ((nokori + max - 1) / max));


    }



}


Measured memory_bytes: 80800
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
int main(){
    char s[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string hoge;
    cin>>hoge;
    rep(i,hoge.size()){if(hoge[i]<68)cout<<s[hoge[i]-65+23];else cout<<s[hoge[i]-68];}cout<<endl;
}

Measured memory_bytes: 3176
A = list(map(int, input().split()))
B = [a%2 for a in A]
if len(set(B))==1:
    ans = (max(A)*3-sum(A))//2
elif B.count(0)==1:
    ind = B.index(0)
    if A[ind] == max(A):
        ans = (max(A)*3-2-sum(A))//2+1
    else:
        ans = (max(A)*3-sum(A)+1)//2+1
else:
    ind = B.index(1)
    if A[ind] == max(A):
        ans = (max(A)*3-2-sum(A))//2+1
    else:
        ans = (max(A)*3-sum(A)+1)//2+1
print(ans)


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

int main() {
	int v[4] = {0, 3, 5, 7};
	string s;
	cin >> s;
	int len = s.size();
	int dp[len+1][2][2][2][2];
	fill((int *)dp, (int *)dp + sizeof(dp)/sizeof(int), 0);
	dp[0][0][0][0][0] = 1;
	for (int i = 0; i < len; i++) {
		const int D = s[i] - '0';
		for (int smaller = 0; smaller <= 1; ++smaller) {
			for (int f3 = 0; f3 <= 1; f3++) {
				for (int f5 = 0; f5 <= 1; f5++) {
					for (int f7 = 0; f7 <= 1; f7++) {
						int x_max = smaller ? 9 : D;
						for (int x : v) {
							if ((f3||f5||f7) && x == 0) continue; 
							if (x > x_max) continue;
							dp[i+1][smaller || x<D][f3||x==3][f5||x==5][f7||x==7] += dp[i][smaller][f3][f5][f7];
						}
					}
				}
			}
		}
	}
	int ans = dp[len][0][1][1][1] + dp[len][1][1][1][1];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define inf 100000000000000000
#define ll long long 
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define test ll t ; cin>>t; while(t--)
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	
	ll n , m ;
	cin>>n>>m;
	map<ll,ll> mp;
	bool flag=0;
	for(ll i=0 ,a , b ; i<m ;i++){
		cin>>a>>b ;
		if(mp.count(a)>0 && mp[a]!=b){
			flag=1;
		}
		else{
			mp[a]=b;
		}
	}
	if(flag)cout<<-1;
	else{
		for(ll i=1 ;i<=n ;i++){
			if(mp.count(i)>0){
				if(i==1 && mp[i]==0 && n!=1){
					cout<<-1<<endl;
					return 0;
				}
				cout<<mp[i];
			}
			else{
				if(i==1 && n!=1)cout<<1;
				else cout<<0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline().rstrip('\n')


def calc(N, M, H, C):
    f = [1 for _ in range(N)]
    for a, b in C:
        if H[a] == H[b]:
            f[a] = f[b] = 0
        elif H[a] > H[b]:
            f[b] = 0
        else:
            f[a] = 0
    return sum(f)
    

(N, M) = tuple([int(s) for s in input().split()])
H = [int(s) for s in input().split()]
C = [tuple([int(s) - 1 for s in input().split()]) for _ in range(M)]
print(calc(N, M, H, C))

Measured memory_bytes: 95600
/*input
cabacc
abc
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
//#define int long long

signed main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s,t; cin>>s>>t;
	int ans = t.size();
	for(int i=0; i<s.size(); ++i){
		int cnt=0;
		if(i+t.size() > s.size()) continue;
		for(int j=0; j<t.size(); ++j){
			if(s[i+j]!=t[j]) cnt++;
		}
		// cout<<i<<" "<<cnt<<endl;
		ans = min(ans, cnt);
	}
	cout<<ans;
	return 0;	
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <set>
#include <queue>
typedef long long ll;
using namespace std;
const int mod=1e9+7;
const ll inf=(1e14);
void solve(){
    int n,s=0;
    cin>>n;
    int a[n];
    for(int &i:a) cin>>i;
    for(int i:a) s=s^i;
    for(int i:a) cout<<(s^i)<<' ';
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    int t=1;
    //cin>>t;
    //while(t--) cout<<solve()<<'\n';
    while(t--) solve(),cout<<'\n';
    return 0;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
void solve()
{
    ll a, b, k;
    cin>>a>>b>>k;
    if(a>=k)
    	cout<<a-k<<' '<<b<<endl;
    else 
    	cout<<0<<' '<<max((ll)0, (b-(k-a)))<<endl;
}
int main()
{
	#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3752
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

A, B, C = [int(x) for x in stdin.readline().rstrip().split()]

tmp = A -B
C -= tmp

if C < 0:
    print(0)
else:
    print(C)

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

int main()
{
  int a[3]; cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  cout << (a[0] == 5 && a[1] == 5 && a[2] == 7 ? "YES" : "NO");
  return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

const int MAX_N = 110000;

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    ll res = 0;

    for (int bit = 0; bit < (1 << (n - 1)); bit++) {
        ll tmp = 0;
        for (int i = 0; i < n - 1; i++) {
            tmp *= 10;
            tmp += s[i] - '0';
            if (bit & (1 << i))
                res += tmp, tmp = 0;
        }
        tmp *= 10;
        tmp += s.back() - '0';
        res += tmp;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3584
#include<stdio.h>

int main(){
    int i,j,n,M[100][100],a,b,c;
    scanf("%d",&n);
    for(i = 0;i < n;i++){
        for(j = 0;j < n;j++){
            M[i][j] = 0;
        }
    }
    for(i = 0;i < n;i++){
        scanf("%d%d",&a,&b);
        a--;
        for(j = 0;j < b;j++){
            scanf("%d",&c);
            c--;
            M[a][c] = 1;
        }
    }
    for(i = 0;i < n;i++){
        for(j = 0;j < n;j++){
            if(j >= 1) printf(" ");
            printf("%d",M[i][j]);
        }
        printf("\n");
    }
}


Measured memory_bytes: 2052
N = int(input())
h = {}
for i in range(N):
    restaurant, score = list(input().split())
    item = h.get(restaurant, [])
    item.append([int(score), i+1])
    h[restaurant] = sorted(item,key=lambda x: -x[0])

for key in sorted(h.keys()):
    for item in h[key]:
        print(item[1])

Measured memory_bytes: 3060
import numpy as np

length = int(input())
As = list(map(int, input().split()))

As.sort()

# indexを数値と紐づけるために+1増やした数にする
check = np.zeros(10**6+1)

answer = 0

# 与えられた数列の小さいものから順にループ
for i in range(length):
    if check[As[i]] == 0:
        # 与えられた数値の倍数すべてに1を立てる
        # checkは0始まりのため、0と倍数要素に1が立つ
        check[::As[i]] = 1
        
        # checkリストが0の状態で数列の最後であればanswerへの加算は確定
        # また、同じ数字が複数ある場合はカウントさせない
        if  i == (length - 1) or  As[i] != As[i + 1]:
                answer = answer + 1

print(answer)

Measured memory_bytes: 51620
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

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

    vector<int> balls(n);
    rep(i, n) cin >> balls[i];

    int sum = 0;
    rep(i, n) sum += min(balls[i], abs(k - balls[i]));

    cout << sum * 2 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int n,i,j;
  int num[1000000]={0};

  for(i=3;i<1000000;i+=2){
    if(num[i]==1)
      continue;
    for(j=3*i;j<1000000;j+=i*2)
      num[j]=1;
  }

  for(;scanf("%d",&n)!=EOF;){
    int count=1;
    for(i=3;i<=n;i+=2){
      if(num[i]==1)
        continue;
      count+=1;
    }
    if(n<2)
      count=0;
    printf("%d\n",count);
  }

  return 0;
}

Measured memory_bytes: 4508
h,w,k1=map(int,input().split())
s=[[1 if i=='#' else 0 for i in input()] for _ in range(h)]
from collections import deque
yoko=deque([])
for i in range(h):
    x=sum(s[i])
    if x>0:
        yoko.append([i, x])
k=0
lasty=0
while yoko:
    y=yoko.popleft()
    y0=y[0]
    if not yoko:
        y0=h-1
    lim=k+y[1]
    k+=1
    tmp=s[lasty:y0+1]+[]
    tmp = [list(x) for x in zip(*tmp)]
    for i in range(w):
        x=sum(tmp[i])
        if x>0:
            for j in range(y0+1-lasty):
                s[lasty+j][i]=k
            k+=1
            k=min(lim,k)
        else:
            for j in range(y0+1-lasty):
                s[lasty+j][i]=k
            k=min(lim,k)
    lasty=y0+1



for i in range(h):
    print(' '.join(map(str, s[i])))

Measured memory_bytes: 49116
import sys
import decimal # 10進法に変換，正確な計算

def input():
    return sys.stdin.readline().strip()

def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    count = 0
    for i in h:
        if i >= k:
            count += 1
    print(count)

    
    
main()

Measured memory_bytes: 13948
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int s = 0;
  vi t(101);
  int a;
  while (cin >> a) t[a]++, cmax(s, t[a]);
  rep(i, 101) if (t[i] == s) cout << i << endl;
}

Measured memory_bytes: 3048
#include <stdio.h>

int main(void)
{
  int i,n,a,b;

  while (1) {
    scanf("%d %d",&a,&b);
    if (a == 0 && b == 0){
      break ;
    }
    for (i=0; i<a; i++){
      for (n=0; n<b ;n++){  
	  if (0 == n || 0 == i || n+1 == b || i+1 == a)
	    printf("#");
	  else
	    printf(".");
      }
        printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
use std::io::{self, Write};

fn main() {
    let stdin = io::stdin();
    let mut stdout = io::stdout();
    let mut input = String::new();
    stdin.read_line(&mut input).expect("failed to read line");
    let s = input.trim().to_owned();
    input.clear();
    stdin.read_line(&mut input).expect("failed to read line");
    let mut t = input.trim().to_owned();
    t.pop();
    if t == s {
        println!("Yes");
    } else {
        println!("No");
    }
    stdout.flush().unwrap();
}


Measured memory_bytes: 2056
# include <bits/stdc++.h>
typedef long long lint;
using namespace std;

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }


int main() {
  lint x,y,ans; cin >> x >> y;

  if(abs(x) == abs(y)) {
    ans = 1;
  } else if(abs(x) < abs(y)) {
    ans = abs(y)-abs(x);
    if(x < 0) { ans++; }
    if(y < 0) { ans++; }
  } else if(abs(x) > abs(y)) {
    ans = abs(x)- abs(y);
    if(x > 0) { ans++; }
    if(y > 0) { ans++; }
  }

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

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

/* macros */
#define int long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vt vector
#define pb push_back
#define fi first
#define se second
#define pi pair<int,int>
#define tc int t;cin>>t;while (t--){solve();}
#define notc solve();
#define newline cout << "\n";
#define mod 1000000007
#define ret return 0;
#define sz(x) (int)x.size();
#define rep(i,a,b) for(int i=a;i<b;i++)
#define srt(x) sort(x.begin(), x.end())

void solve(){
    int N,W;
    cin>>N>>W;
    vi w(N+1),p(N+1);
    for (int i=1;i<=N;i++){
        cin>>w[i];
        cin>>p[i];
    }
    
    int dp[N+1][W+1];
    for (int i=0;i<=W;i++) dp[0][i] = 0;
    for (int i=0;i<=N;i++) dp[i][0] = 0;
    
    for (int i=1;i<=N;i++){
        for (int j=1;j<=W;j++){
            if (w[i] > j) {
                dp[i][j] = dp[i-1][j];
            }else{
                dp[i][j] = max( dp[i-1][j] , dp[i-1][j-w[i]]+p[i]);
            }
        }
    }
    cout << dp[N][W] << "\n";
}

int32_t main(){
    fastio
    notc
    ret
}


Measured memory_bytes: 82528
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int a,b;
	cin>>a>>b;

	cout << a + 1 - b << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;







// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail

public class Main{
    public static void main(String args[] ) throws Exception {
        
        //Scanner
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] A = new int[n];
        for(int i=0;i<n;i++) {
            A[i] = scanner.nextInt();
        }
        int[] sorted = new int[n];
        for(int i=0;i<n;i++) {
            sorted[i] = i+1;
        }
        for(int i=0;i<n;i++) {
            if(A[i]!=i+1) {
                int a = A[A[i]-1];
                A[A[i]-1] = A[i];
                A[i] = a;
                break;
            }
        }
        
        
        
        int flag=0;
        for(int i=0;i<n;i++) {
            
            if(A[i]!=sorted[i]) {
                flag=1;
                break;
            }
        }
        if(flag==0) {
            System.out.println("YES");
        }
        else {
            System.out.println("NO");
        }
    }
    
    
    
}


Measured memory_bytes: 22484
#include<stdio.h>
int main()
{
  int a;
  // 整数の入力
  scanf("%d", &a);
  a = a%10;
  // 出力
  if(a == 2 || a == 4 || a == 5 || a == 7 || a == 9){
    printf("hon");
  }else if(a == 0 || a == 1 || a == 6 || a == 8){
    printf("pon");
  }else{
    printf("bon");
  }
  return 0;
}


Measured memory_bytes: 1732
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();

        if (A >= 13) {
            System.out.println(B);
        } else if (A >= 6 && A <= 12) {
            System.out.println(B / 2);
        } else if (A <= 5 && A >= 0) {
            System.out.println(0);
        }
    }
}

Measured memory_bytes: 21332