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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
#define VL vector<lol>
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result{0};
    lol n; cin >> n;
    
    //int minn = keta1*pow(10, dec-1);
    lol a[10][10] = {}; //a[i][j]
    FOR(i, 1, n)
    {
        string str = to_string(i);
        int dec = str.length();
        int keta1 = (char)str[0] - (char)'0';
        int keta2 = (char)str[dec-1] - (char)'0';
        if(keta2 != 0)
        {
            a[keta1][keta2]++;
        }
    }

    FOR(i, 1, 9)
    {
        FOR(j, 1, 9)
        {
            //cout << "i: " << i << " j:" << j << " a[i][j]:" << a[i][j] << endl;
            result += a[i][j]*a[j][i];
        }
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3756
// ?????¬???????????¬??????

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int H, W;
char board[110][110];
bool visited[110][110];

signed main() {
    while(cin >> H >> W, H || W) {
        rep(i,0,H) rep(j,0,W) cin >> board[i][j];
        memset(visited, false, sizeof(visited));

        int ans = 0;
        rep(i,0,H) rep(j,0,W) {
            if(visited[i][j]) continue;
            visited[i][j] = true;
            ans++;

            queue<pii> que;
            que.push(make_pair(i, j));

            while(!que.empty()) {
                pii t = que.front(); que.pop();
                int x = t.first, y = t.second;
                rep(k,0,4) {
                    int nx = x + dx[k], ny = y + dy[k];
                    if(nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
                    if(board[x][y] != board[nx][ny]) continue;
                    if(visited[nx][ny]) continue;

                    visited[nx][ny] = true;
                    que.push(make_pair(nx, ny));
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3036
#include <iostream>
#include <cmath>

using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if ((abs(b - a) <= d && abs(c - b) <= d) || abs(a - c) <= d) cout << "Yes";
  else cout << "No";
  cout << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin >> n;
  for(long long i=1;i<=3500;i++){
    for(long long j=1;j<=3500;j++){
      if(4*i*j-n*i-n*j>0){
        if((n*i*j)%(4*i*j-n*i-n*j)==0){
          cout << i << " " << j << " " << (n*i*j)/(4*i*j-n*i-n*j) <<endl;
          return 0;
        }
      }
    }
  }
}

Measured memory_bytes: 384
n, l = map(int,input().split())
A = []
for i in range(n):
    A.append(l+i)

ind = -1
minr = 10**10
for i in range(n):
    if abs(A[i])<minr:
        minr = abs(A[i])
        ind = i
print(sum(A)-A[ind])

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
//debug
#ifdef grief
#define debug(...) do{\
	fprintf(stderr , "%s - %d : (%s) = " , __PRETTY_FUNCTION__ , __LINE__ , #__VA_ARGS__ );\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){
	cerr<<x<<endl;
}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){
	cerr<<x<<" , ";
	_DO(tail...);
}
#else
#define debug(...)
#endif
//type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef priority_queue<pll,vector<pll>,greater<pll> > heap;
//macro
#define SZ(x) ((ll)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define F first
#define S second
#define mkp make_pair
#define pb push_back
#define IOS do{ios_base::sync_with_stdio(0); cin.tie(0);}while(0)
const ll INF=4e18;
const ll MAX=1e5+5;
const ll MOD=1e9+7;
//}}}
ll q,h,s,d,n;
int main(){
	//IOS;
	cin>>q>>h>>s>>d;
	cin>>n;
	cout<<min(min(n/2*2 *4*q,n/2*2 *2*h),min(n/2*2 *s,n/2 *d))+min(min(n%2 *4*q,n%2 *2*h),n%2 *s )<< '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n;
    while(cin >> n, n){
        vector<int> a(n, 0), sum(n + 1, 0);
        rep(i, 0, n){
            cin >> a[i];
        }
        rep(i, 1, n + 1){
            sum[i] += sum[i - 1] + a[i - 1];
        }
        int MAX = -1e10;
        rep(i, 0, n + 1){
            rep(j, i + 1, n + 1){
                MAX = max(MAX, sum[j] - sum[i]);
            }
        }
        cout << MAX << endl;
    }
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;}
using ll = long long;

int n,m,x,sum,ans=1e9;
string s,t;
int a[100][100],c[100];

int main() {
  cin >> n >> m >> x;
  rep(i,n){
    cin >> c[i];
    rep(j,m) cin >> a[i][j];
  }
  rep(b,1<<n){
    vector<int> r(m); sum=0;
    rep(i,n)if(b&1<<i){
      sum+=c[i];
      rep(j,m) r[j]+=a[i][j];
    }
    bool ok=true;
    rep(k,m)if(r[k]<x) ok=false;
    if(ok) chmin(ans,sum);
  }
  cout << (ans!=1e9 ? ans : -1) << endl;
}


Measured memory_bytes: 3640
n = int(input())
ls0 = [list(map(int, input().split())) for _ in range(n)]
ls1 = [list(map(int, input().split())) for _ in range(n)]
ls0.sort(key=lambda x: x[0], reverse=True)
count = 0
for x0, y0 in ls0:
    val = float('inf')
    index = -1
    for i, (x1, y1) in enumerate(ls1):
        if x0 <= x1:
            if y0 <= y1 < val:
                index = i
                val = y1
    if index >= 0:
        count += 1
        ls1.remove(ls1[index])
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <utility>

int main(int, char**) {
  int n;
  std::cin >> n;

  std::vector<int> hs(n);
  for(int i{}; i < n; ++i) {
    std::cin >> hs[i];
  }

  int ans{};
  int max{-1};
  for(int i{}; i < n; ++i) {
    if(hs[i] >= max) {
      max = hs[i];
      ++ans;
    }
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
a = [int(i) for i in input().split()]
ans = 0
left = 0
right = 0
rr = k*(k+1)//2
ll = k*(k-1)//2
mod = 10**9+7

for i in range(n):
    for j in range(0,i):
        if a[j] < a[i]:
            left += 1
    for _ in range(i+1,n):
        if a[_] < a[i]:
            right += 1
print(int((left * ll + right * rr)%mod))

Measured memory_bytes: 42220
#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1.0)
#define pb push_back
#define vi vector<int>
#define mapii map<int , int>
#define mapci map<char, int>
#define mapsi map<string,int>
#define FOR(i,n) for(int i = 0;i<n;i++)
#define CP(n) cout<<"Case "<<n<<": "
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
#define MAX 1000007
#define all(x)(x.begin(),x.end())
#define debug(x,c) cout<<x<<": "<<c<<" ";
#define fast_io ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
int main()
{
	ll n;
	cin>>n;
	stack<int>st;
	while(n)
	{
		int r = n%26;
		if(!r)r = 26;
		n-=r;
		r--;
		st.push(r);
		n/=26;
	}
	while(!st.empty())
	{
		int x = st.top();
		cout<<(char)(97+x);
		st.pop();
	}
	cout<<endl;
	//main();
	return 0;
}


Measured memory_bytes: 3560
import java.util.Scanner;

/**
 * C - Slimes
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        int n = sc.nextInt();      // スライムの数
        String s = sc.next();      // 文字列

        int result = 1;
        for( int i = 0; i < s.length(); i++ ) {
//            System.out.println("charat : " + s.charAt(i));
            if( i == 0 ) continue;
            if( s.charAt(i) != s.charAt(i - 1) ) {
                result++;
            }
        }

        System.out.println( result );

        sc.close();
    }
}

Measured memory_bytes: 24916
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  lint N;
  cin>>N;
  lint A[5];
  REP(i,5)cin>>A[i];
  sort(A,A+5);
  cout<<((N-1)/A[0])+5<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1000000007;

void solve() {
  string s;
  cin >> s;
  int n = s.length();
  ll ans = 0;

  rep(bit, (1 << n-1)) {
    ll temp = 0;
    ll prev = s[0] - '0';
    rep(i, n-1) {
      if (bit & (1 << i)) {
        temp += prev;
        prev = s[i+1] - '0';
      } else {
        prev = prev * 10 + (s[i+1] - '0');
      }
    }
    temp += prev;
    ans += temp;
  }
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n + 2, 0);
    for (int i = 0; i < n; i++) {
        cin >> a[i + 1];
    }
    int total = 0;
    for (int i = 1; i <= n + 1; i++) {
        total += abs(a[i] - a[i - 1]);
    }
    for (int i = 1; i <= n; i++) {
        int ans = total - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1664
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

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

    ll N, K;
    cin >> N >> K;

    vi A(N);
    REP(i, N) {
        cin >> A[i];
        --A[i];
    }

    vi v1(N + 1, 0), v2;

    int cur = 0;
    v1[0] = 1;

    while (true) {
        v2.pb(cur);
        cur = A[cur];
        if (v1[cur] > 0) break;
        v1[cur] = 1;
    }

    int c[2], id = 0;
    memset(c, 0, sizeof(c));
    REP(i, v2.size()) {
        if (v2[i] == cur) id = 1;

        c[id] += 1;
    }

    if (K <= v2.size() - 1) {
        print(v2[K] + 1);
    } else {
        K -= c[0];
        K %= c[1];

        print(v2[c[0] + K] + 1);
    }
}


Measured memory_bytes: 5848
program problemB
  implicit none


integer(8) :: n,K,l
character(len=128) :: S,rep

read(*,*) K
read(*,*) S

l=len_trim(S)

if (l<=K) then
  write(*,*) S
else
rep=S(1:K)
rep((K+1):(K+3))='...'
rep=trim(rep(1:(K+3)))
write(*,*) rep
end if
stop
end program


Measured memory_bytes: 2848
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int A, B;
	cin >> A >> B;
	if (A - 2 * B > 0)
	{
		cout << A - 2 * B << endl;
	}
	else
	{
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;

int main()
{
	string s,t;
	ll ans=0;
	cin>>s>>t;
	for(int i=0;i<3;i++)
	{
		if(s[i]==t[i])
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
    int N,Q;
    cin >> N >> Q;
    vector<stack<int>> S(N);
    for(int i = 0;i < Q;i++) {
        int A;
        cin >> A;
        if(A == 0) {
            int B,C;
            cin >> B >> C;
            S[B].push(C);
        }
        else if(A == 1) {
            int B;
            cin >> B;
            if(S[B].empty() == false) {
                cout << S[B].top() << endl;
            }
        }
        else {
            int B;
            cin >> B;
            if(S[B].empty() == false) {
                S[B].pop();
            } 
        }
    }
}


Measured memory_bytes: 5120
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }

int main(void){
	int q=nextint();
	while(q-->0){
		long a=nextint();
		long b=nextint();
		if(a>b){ int t=a; a=b; b=t; }
		long ans;
		if(a==b){
			ans=a*2-2;
		}else if(a+1==b){
			ans=a*2-2;
		}else{
			long c=sqrtl(a*b-1);
			if(c*(c+1)>=a*b){
				ans=c*2-2;
			}else{
				ans=c*2-1;
			}
		}
		printf("%ld\n", ans);
	}
}


Measured memory_bytes: 1992
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class D
{
	public static void Main()
	{
		string S = GetString();
		int N = S.Length;

		int[] ans = new int[N];
		int iFirst = 0;
		while(iFirst < N)
		{
			int iMid = iFirst;
			while(S[iMid + 1] == 'R')
				iMid++;

			int iLast = iMid + 1;
			while((iLast + 1 < N) && (S[iLast + 1] == 'L'))
				iLast++;

			for(int i = iFirst; i < iMid; i++)
				ans[iMid + ((iMid - i) % 2)]++;

			ans[iMid]++;
			ans[iMid + 1]++;

			for(int i = iMid + 2; i <= iLast; i++)
				ans[iMid + ((i - iMid) % 2)]++;

			iFirst = iLast + 1;
		}

		string[] str = ans.Select(x => x.ToString()).ToArray();
		Console.WriteLine(string.Join(" ", str));
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}





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

using namespace std;

int main(void)
{
	int a,b,c,x,y;

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

	cin >> a >> b >> c >> x >> y;

	int n = max(x,y);

	int res = a*x+b*y;

	for(int i=1;i<=n;i++)
	{
		int cal = c*(2*i);
		if(x-i>0)
		{
			cal += (x-i)*a;
		}
		if(y-i>0)
		{
			cal += (y-i)*b;
		}
		res = min(res,cal);
	}

	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 256
// ATCG文字列を発見したら以降の文字も調べてカウントする
// カウント数を記録し、最後にカウント数の最大値を出力する
#include<iostream>
#include<string>
using namespace std;
int main() {
  int count,ans=0;
  string s;
  cin >> s;
  for(int i=0;i<s.size();i++){
    if(s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G'){
      count = 0;
      for(int j=i;j<s.size();j++){
        if(s[j] == 'A' || s[j] == 'T' || s[j] == 'C' || s[j] == 'G') count++;
        else break;
      }
      if(count>=ans) ans = count;
    }
  }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var sc = bufio.NewScanner(os.Stdin)
var ReadString func() string
var ReadLine func() string
var ReadInt64 func() int64
var ReadInt func() int
var ReadIntSlice func(int) []int
var ReadInt64Slice func(int) []int64
var GetIntAbs func(int) int
var Atoi func(string) int
var FindMin func([] int) int
var FindMax func([] int) int
var StrReverse func(string) string

func init() {
	ReadString = newReadString()
	ReadLine = readLine
	ReadInt64 = readInt64
	ReadInt = readInt
	ReadIntSlice = readIntSlice
	FindMin = findMin
	FindMax = findMax
	StrReverse = strReverse
  GetIntAbs = getIntAbs
}

func main() {
	n := ReadInt()
  var ans int
  for i := 1; i <= n; i++ {
    s := len(strconv.Itoa(i))
    if s % 2 == 1 {
      ans++
    }
  }
  fmt.Println(ans)
}

func strReverse(s string) string {
	runes := []rune(s)
	l := len(runes)
	for i, j := 0, l-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}


func newReadString() func() string {
	sc.Buffer(make([]byte, 1024), 2048)
	sc.Split(bufio.ScanWords)
	return func() string {
		if !sc.Scan() {
			panic("scanできなかった")
		}
		return sc.Text()
	}
}

func readLine() string {
	if !sc.Scan() {
		panic("line をscanできなかった")
	}
	return sc.Text()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		fmt.Println("parseInt失敗")
		panic(err.Error())
	}
	return int64(i)
}

func readInt() int {
	i := ReadInt64()
	return int(i)
}

func readIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}

func readInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt64()
	}
	return arr
}

/*------ number util ------*/

func getIntAbs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func atoi(a string) int {
	i, err := strconv.Atoi(a)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func findMin(arr []int) int {
	if len(arr) == 0 {
		return 0
	}
	min := arr[0]
	for _, v := range arr {
		if v < min {
			min = v
		}
	}
	return min
}

func findMax(arr []int) int {
	if len(arr) == 0 {
		return 0
	}
	max := arr[0]
	for _, v := range arr {
		if v > max {
			max = v
		}
	}
	return max
}


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

i64 N,A,B,K;

i64 MOD = 998244353;

// Eucli
i64 inv_mod(i64 a, i64 m = MOD) {
  i64 b, x, u, q, abs_m, tmp;

  abs_m = (m < 0) ? -m : m;
  b = m;
  x = 1;
  u = 0;
  while (b > 0) {
    q = a / b;
    tmp = u;
    u = x - q * u;
    x = tmp;
    tmp = b;
    b = a - q * b;
    a = tmp;
  }

  return (x < 0) ? abs_m + x : x;
}

i64 fact[303030];

i64 nCr(int n, int r) {
  return (fact[n] * inv_mod(fact[r]) % MOD * inv_mod(fact[n - r]) % MOD) % MOD;
}

//重複組み合わせ
i64 nHr(int n, int r) { return (nCr(n + r - 1, r)) % MOD; }


int main(){
  cin >> N >> A >> B >> K;
  fact[0] = 1;
  rep(i,1,300030){
    fact[i] = (fact[i - 1] * i) % MOD;
  }

  i64 ans = 0;
  for(i64 x = 0;x <= N;x++){
    if(K - A * x < 0) continue;
    if((K - A * x) % B != 0) continue;
    i64 y = (K - A * x) / B;
    if(y > N) continue;
    ans = ((ans + (nCr(N,x) * nCr(N,y)) % MOD)) % MOD;
  }

  cout << ans << endl;
}

Measured memory_bytes: 2560
N, M, X = [int(x) for x in input().split()]


C = []
RIKAI = []
ans = 0

BOOK= []
for i in range(N):
    BOOK += [[int(x) for x in input().split()]]

ans = -1
MIN_PAY = 10**5 * 12 +1

for FLAG in range(2 ** N ):
    PAY = 0
    RIKAI = [0] * M
    for i in range(N):
        if FLAG >> i & 1:
            for j in range(M):
                RIKAI[j] = RIKAI[j] + BOOK[i][j+1]
            PAY += BOOK[i][0] 
    if min(RIKAI) >= X:
        MIN_PAY = min(PAY,MIN_PAY)
        

if MIN_PAY == 10 ** 5 * 12 +1:
    ans = -1
else:
    ans = MIN_PAY

print(ans)

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N;
    cin >> N;
    
    vector<int> v(N);
    int cnt[1000005] = {};
    for(int i = 0; i < N; ++i) {
        cin >> v[i];
    }
    sort(all(v));

    int t[1000005] = {};
    int res = 0;
    for(int i = 0; i < N; ++i) {
        if(i + 1 < N && v[i] == v[i + 1]) {
            t[v[i]]++;
            continue;
        }
        if(i - 1 >= 0 && v[i] == v[i - 1]) {
            t[v[i]]++;
            continue;
        }
        vector<LL> d = Div(v[i]);

        bool f = true;
        for(int j = 0; j < d.size(); ++j) {
            if(t[d[j]]) {
                f = false;
                break;
            }
        }
        if(f) ++res;
        t[v[i]]++;
    }
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 7956
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define FASTIO ios_base::sync_with_stdio(NULL); cin.tie(NULL);
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define MOD 1000000007

using namespace std;

void init(){
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin) ;
  freopen("output.txt", "w", stdout) ;
  #endif
}

// code from below
int dp[(int)1e5+1]; // dp[i] would store the max path length from node i of the tree
vector<int> adj[(int)1e5 + 1];
bool visited[(int)1e5+1];
void dfs(int i){
    dp[i]=0;
    visited[i]=true;
    for(int child :adj[i]){
        if(!visited[child])
            dfs(child);
        dp[i]=max(1+dp[child],dp[i]);
    }
}
void solve(){
	for(int i=0;i<=(int)1e5;i++)
        adj[i].clear();
    memset(visited,false,sizeof(visited));
    memset(dp,0,sizeof(dp));

    int n,m,a,b;
    cin>>n>>m;
    FOR(i,m){
        cin>>a>>b;
        adj[a].pb(b);
    }
    for(int i=1;i<=n;i++){
        if(!visited[i])
            dfs(i);
    }
    int Max=INT_MIN;
    for(int i=1;i<=n;i++){
        Max=max(Max,dp[i]);
    }
    cout<<Max<<"\n";
}

int main(){
    int t=1;
    // cin>>t;
    // cin.ignore(numeric_limits<streamsize>::max(),'\n'); 
    while(t--)
        solve();
}

Measured memory_bytes: 12216
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(123456789012345678)


unsigned GetDigit(unsigned num) {
    return std::to_string(num).length();
}


int main(void){
	int D; cin >> D;
  int time_Eve = 25 - D;
  cout << "Christmas ";
  rep(i, time_Eve) {
    cout << "Eve ";
  }
  cout << endl;
    
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
#define MOD 1000000007
using namespace std;

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

template<typename T, typename V> 
void __print(const pair<T, V> &x)
{
	cerr << '{'; __print(x.first);
	cerr << ','; __print(x.second);
	cerr << '}';
}

template<typename T>
void __print(const T &x)
{
	int f = 0;
	cerr << '{';
	for (auto &i : x)
		cerr << (f++ ? "," : ""), __print(i);
	cerr << "}";
}

void _print()
{
	cerr << "]\n";
}

template <typename T, typename... V>
void _print(T t, V... v)
{
	__print(t);
	if (sizeof...(v))
		cerr << ", "; _print(v...);
}

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

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


	string s;
	cin >> s;

	int count=0;
	for (int i=0;i<=2;i++)
	{
		if (s[i]=='A')
		{
			count++;
		}
	}

	if ((count==0)||(count==3))
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
int main(){
	int n,k,a;
	while(~scanf("%d%d",&n,&k)){
		a=1;
		for(int i=1;i<=n;i++){
			if(2*a<=a+k) a=2*a;
			else a=a+k;
		}
		printf("%d\n",a);
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    
    typedef double dd;
    typedef long long ll;

    #define ff first
    #define ss second
    #define mp make_pair
    #define eb emplace_back
    #define trav(i,a) for(auto i: a)
    #define all(v) (v.begin(),v.end())
    #define rall(v) (v.rbegin(),v.rend())
    #define tc(t) ll t; cin>>t; while(t--)
    #define prec(n) fixed<<setprecission(n)
    #define mst(arr,value) memset(arr,value,sizeof(arr)) /* -1 or 0 */
    
    const long long sz = (long long)1e4+5;
    const long long mx = (long long)2e5+5;
    const long long inf = (long long)1e18;
    const long long mod = (long long)1e9+7;
    
    #define f(i,n)     for(ll i=0;   i<n;  i++)
    #define fab(i,a,b) for(ll i=a;   i<b;  i++)
    #define fr(i,n)    for(ll i=n-1; i>=0; i--)
    #define fba(i,b,a) for(ll i=b-1; i>=a; i--)

    long long pw(long long x,unsigned long long y) 
    { 
        if (y==0) return 1; 
        else if (y%2==0)  return pw(x,y/2)*pw(x,y/2); 
        else return x*pw(x,y/2)*pw(x,y/2);
    }

    int main() 
    {
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        cout.tie(NULL);
        ll h,n,a,ans=0;
        cin>>h>>n;
        f(i,n){ cin>>a; ans+=a; }
        if(ans>=h) cout<<"Yes";
        else cout<<"No";
        return 0;
    }

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

int main(){
    int N, M;
    string s[110], t[110];
    cin >> N;
    for(int i = 0; i < N; ++i) cin >> s[i];
    cin >> M;
    for(int i = 0; i < M; ++i) cin >> t[i];
    
    map<string, int> mp;
    for(int i = 0; i < N; ++i) mp[s[i]] += 1;
    for(int i = 0; i < M; ++i) mp[t[i]] -= 1;
    
    int money = 0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr){
        if(itr->second > money) money = itr->second;
    }
    cout << money << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define ss(a) scanf("%s",a)
#define mem(a,b) memset(a,b,sizeof(a))
#define PII pair<int,int>
const double pi = acos(-1.0);
using namespace std;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
int pre[maxn], siz[maxn];
int find(int a){
	if(a==pre[a])return a;
	return pre[a] = find(pre[a]);
}
void merge(int a, int b){
	int x = find(a), y = find(b);
	if(x == y)return;
	if(siz[x] > siz[y]){
		siz[x] += siz[y] + 1;
		pre[y] = x;
	}
	else {
		siz[y] += siz[x] + 1;
		pre[x] = y;
	}
}
int main(){
	int n, m, x, y;
	sc2(n, m);
	for(int i = 1; i <= n; i ++){
		pre[i] = i;
		siz[i] = 0;
	}
	while(m--){
		sc2(x, y);
		merge(x, y);
	}
	// for(int i = 1; i <= n; i ++){
	// 	cout << "i: " << i << "\t";
	// 	cout << "siz: " << siz[i] << "\t";
	// 	cout << "pre: " << pre[i] << endl;
	// }
	int ans = -1;
	for(int i = 1; i <= n ; i ++){
		int t = find(i);
		if(t == i) ans = max(ans, siz[t] + 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5316
#include <stdio.h>
int main(void){
	int n,x,contagem=0,soma=0,i;
	scanf("%d %d", &n,&x);
	int pulos[n];
	for(i=0;i<n;i++)scanf("%d", &pulos[i]);
	i=0;
	while(soma<=x){
		contagem++;
		soma+=pulos[i];
		i++;
	}
	printf("%d\n", contagem);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

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

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;


void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}



int main() {
	int n, t;
	cin >> n >> t;
	vector<pair<ll, ll>> ab(n);
	rep(i,n){
		int a, b;
		cin >> a >> b;
		ab[i] = pair<ll, ll>(a, b);
	}
	sort(all(ab));
	vector<vector<long long int>> dp(n + 1, vector<long long int>(t, 0));
	rep(i,n){
		rep(j,t){
			if(j-ab[i].first >= 0)
				dp[i + 1][j] = max(dp[i][j], dp[i][j - ab[i].first] + ab[i].second);
			else
				dp[i + 1][j] = dp[i][j];
		}
	}
	ll m = 0;
	rep(i,n){
		m = max(m, dp[i][t - 1] + ab[i].second);
	}
	cout << m << endl;

	return 0;
}

Measured memory_bytes: 70784
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <stdlib.h>
#include <deque>
#include <cstdint>
using namespace std;

int main () {
  int n;
  cin >> n ;
  int c = 0;
  int a[n];
  int old[n] = {0};
  for (int i = 0; i < n; i++){
    int tmp;
    cin >> tmp;
    a[i] = tmp;
  }
  int i = 0;
  while (true) {
    old [i] ++;
    if (a[i]==2){
      cout << c+1;
      break;
    }else if (old[a[i]-1]!=0){
      cout << "-1";
      break;
    } else{
      i = a[i] - 1;
      c++;
    }
  }
  return 0;
}

Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))

if len(set(A)) == 1:
    if A[0] == N-1 or A[0] <= N // 2:
        print("Yes")
    else:
        print("No")
elif len(set(A)) == 2:
    M = max(A)
    m = min(A)
    if M-m != 1:
        print("No")
    else:
        if A.count(m) < M and 2*(M-A.count(m)) <= A.count(M):
            print("Yes")
        else:
            print("No")
else:
    print("No")


Measured memory_bytes: 14564
n, m = map(int, input().split())
h = list(map(int, input().split()))
d = [1] * n
for i in range(m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  if h[a] > h[b]:
    d[b] = 0
  elif h[b] > h[a]:
    d[a] = 0
  else:
    d[a] = 0
    d[b] = 0
print(sum(d))

Measured memory_bytes: 20004
#include<stdio.h>
int min(int a, int b)
{
	if (a < b)
		return a;
	else
		return b;
}
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	int i;
	int l, r;
	int ans[100005];
	for (i = 0; i < m + 2; i++)
		ans[i] = 0;
	int b, c, cc;
	for (i = 0; i < n; i++)
	{
		scanf("%d %d", &l, &r);
		b = r;
		cc = -1;
		for (;;)
		{
			c = l / b;
			if (c < 1)
				c = 1;
			if (c == cc)
				c++;
			if (c < 1)
				break;
			ans[min(r / c + 1, b + 1)]--;
			ans[(l + c - 1) / c]++;
			b = (l + c - 1) / c - 1;
			if (b < 1)
				break;
			cc = c;
		}
	}
	for (i = 1; i <= m; i++)
		ans[i] += ans[i - 1];
	for (i = 1; i <= m; i++)
		printf("%d\n", ans[i]);
	return 0;
}

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

int main(){
  int H, W;
  cin >> H >> W;
  
  vector<vector<char>> ftable(H, vector<char>(W));
  for(int i = 0; i < H; i++){
    for (int j = 0; j < W; j++ ){
      cin >> ftable.at(i).at(j);
    }
  }
  //storeに残すべき行を溜める
  vector<int> store_1(H);
  for(int i = 0; i < H; i++){
    store_1.at(i) = 0;
  }
  int cnt = 0;
  //横列の整理
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(ftable.at(i).at(j) == '#'){
        store_1.at(cnt) = i;
        cnt++;
        break;
      }
    }
  }
  //横列を削除した後の表
  vector<vector<char>> stable(cnt, vector<char>(W));
  for(int i = 0; i < cnt; i++){
    stable.at(i) = ftable.at(store_1.at(i));
  }
  
  //横列の時と同じくstoreに溜める
  vector<int> store_2(W);
  for(int i = 0; i < W; i++){
    store_2.at(i) = 0;
  }
  
  int num = 0;
  
  //縦列の整理
  for(int i = 0; i < W; i++){
    for(int j = 0; j < cnt; j++){
      if(stable.at(j).at(i) == '#'){
        store_2.at(num) = i;
        num++;
        break;
      }
    }
  }
  
  //縦列を削除した後の表
  vector<vector<char>> res(cnt, vector<char>(num));
  for(int i = 0; i < cnt; i++){
    for(int j = 0; j < num; j++){
      cout << stable.at(i).at(store_2.at(j));
    }
    cout << endl;
  }
}
    
    
      

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	
	int divisores(int i);
	
	int n;
	scanf("%d",&n);
	
	int y,d;
	
	
	for(int i = 1; i<=n; ++i){
		if(i%2 != 0){
			y = divisores(i);
			if( y == 8){
				d+=1;
			}
		}
	}	
	
	printf("%d\n",d);
	
	return 0;
}

int divisores(int i){
	
	int num = 0;
	
	for (int x = 1; x<=i; ++x){
		if(i%x == 0){
			num+=1;
		}
	}
	
	return num;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 100'000
i64 N, M, K;
vector<i64> F[MAX_N]; // 友人関係
vector<i64> B[MAX_N]; // ブロック関係
vector<set<i64> > C;  // 連結成分のリスト
map<i64, i64> m;  // <ノード, 友達候補の数>

bool visited[MAX_N];

void dfs(i64 orig) {
    set<i64> c;

    stack<i64> s;
    s.push(orig);
    visited[orig] = true;
    c.insert(orig);
    while(!s.empty()) {
        i64 u = s.top(); s.pop();

        for (auto it = F[u].begin(); it != F[u].end(); it++) {
            if (visited[*it]) continue;
            visited[*it] = true;
            c.insert(*it);
            s.push(*it);
        }
    }

    i64 n;
    for (auto it = c.begin(); it != c.end(); it++) {
        n = c.size() - F[*it].size() - 1;
        REP(i, B[*it].size()) {
            n -= c.count(B[*it][i]);
        }
        m[*it] = n;
    }
}

void solve() {
    REP(i, N) visited[i] = false;
    REP(i, N) m[i] = 0;

    REP(i, N) {
        if (visited[i]) continue;
        dfs(i);
    }

    REP(i, N) {
        cout << m[i] << " ";
    }
    cout << endl;
}

int main() {
    cin >> N >> M >> K;
    i64 u, v;
    REP(i, M) {
        cin >> u >> v;
        u--; v--;
        F[u].pb(v);
        F[v].pb(u);
    }
    REP(i, K) {
        cin >> u >> v;
        u--; v--;
        B[u].pb(v);
        B[v].pb(u);
    }

    solve();

    return 0;
}

Measured memory_bytes: 24820
use proconio::input;

use std::cmp::Reverse;

fn main() {
/*
    1 - 2 - 4 - 3
            |
            5
    Yes
    1
    4
    2
    4

    edges
    1: [2]
    2: [1, 4]
    3: [4]
    4: [2,3,5]
    5: [4]
*/
    input! {
        (n, m): (usize, usize),
        abs: [(usize, usize); m]
    };

    let mut edges = vec![vec![]; n+1];
    for (a,b) in abs {
        edges[a].push(b);
        edges[b].push(a);
    }

    let mut dp = vec![std::usize::MAX; n+1];
    let mut arrow = vec![0; n+1];

    let mut heap = std::collections::BinaryHeap::new();
    heap.push(Reverse((0, 1, 0)));

    while let Some(Reverse((cost, pos, pre))) = heap.pop() {
        if dp[pos] <= cost {
            continue;
        }

        dp[pos] = cost;
        arrow[pos] = pre;

        for &n in edges[pos].iter() {
            heap.push(Reverse((cost + 1, n, pos)));
        }
    }

    for i in 1..=n {
        if dp[i] == std::usize::MAX {
            println!("No");
            return;
        }
    }

    println!("Yes");
    for i in 2..=n {
        println!("{}", arrow[i]);
    }
}


Measured memory_bytes: 23496
#include<stdio.h>
int main(){
  while(1){
  int m, i, sum10, sum9=0;
  scanf("%d",&sum10);
  if(sum10==0){
    break;
  }
  for(i=0; i<9; i++){
  scanf("%d",&m);
  sum9 += m;
  }
  printf("%d\n",sum10-sum9);
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <stack>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    stack<char> st;

    char tmp;
    cin >> tmp;
    st.push(tmp);
    int result = 0;
    while(cin>>tmp){

        if(!st.empty()&&tmp!=st.top()){
            result+=2;
            st.pop();
            //cout << "pop!" << endl;
        }else{
            st.push(tmp);
            //cout << "push!" << endl;
        }
    }
    cout << result << endl;


    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			int x = sc.nextInt();
			for(int i = -150; i <= 150; i++){
				for(int j = -150; j <= 150; j++){
					int culc = (int) (Math.pow(i, 5) - Math.pow(j, 5));
					if(culc == x) {
						System.out.println(i + " " + j);
						return;
					}
				}
			}
		}
	}
}


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

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

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int h, w; cin>>h>>w;
    int n; cin>>n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin>>a[i];

    int cnt=0;
    int c[110][110];
    for(int i=0; i<w; i++){
        if(i % 2 == 0){
            for(int j=0; j<h; j++){
                c[j][i]=cnt+1;
                a[cnt]--;
                if(a[cnt] == 0) cnt++;
            }
        }
        else{
            for(int j=h-1; j>=0; j--){
                c[j][i]=cnt+1;
                a[cnt]--;
                if(a[cnt] == 0) cnt++;
            }
        }
    }

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cout << c[i][j] << " ";
        }
        cout << endl;
    }
}

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

int main(){
    int X,happiness=0,a,b;
    cin >> X;
    a = X / 500;//500円の数
    b = (X - 500 * a) / 5;//5円の数
    happiness = a * 1000 + b * 5;
    cout << happiness;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, intmax_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, intmax_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N, M; cin >> N >> M;

    vector<pair<size_t, intmax_t>> G[N];
    vector<int> imos(N + 1);
    for (size_t i = 0; i < M; ++i) {
        size_t l, r, c; cin >> l >> r >> c;
        l--, r--;
        imos[l]++, imos[r + 1]--;
        G[l].emplace_back(r, c);
    }

    for (size_t i = 1; i <= N; ++i) {
        imos[i] += imos[i - 1];
        if (imos[i] != 0) {
            G[i].emplace_back(i - 1, 0);
        }
    }

    vector<intmax_t> cost(N, LINF);
    cost[0] = 0;
    priority_queue<pair<intmax_t, size_t>, vector<pair<intmax_t, size_t>>, greater<>> que;
    que.emplace(0, 0);

    while (!que.empty()) {
        intmax_t nowCost = que.top().first;
        size_t nowNode = que.top().second;
        que.pop();

        if (cost[nowNode] < nowCost) continue;

        for (const auto &nextNode: G[nowNode]) {
            if (chmin(cost[nextNode.first], cost[nowNode] + nextNode.second)) {
                que.emplace(cost[nextNode.first], nextNode.first);
            }
        }
    }

    cout << (cost[N - 1] == LINF ? -1: cost[N - 1]) << "\n";

    return 0;
}


Measured memory_bytes: 9720
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int counter = 0;
  for (int i = 0; i < n; i++) {
    bool flag = true;
    for (int j = 0; j < i; j++) {
      if (a[j] > a[i]) {
        flag = false;
        break;
      }
    }
    if (flag) counter++;
  }
  cout << counter;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;
const int MAXN = 1e5 + 7;

inline int R()
{
	int rt = 0;
	bool isn = false;
	char ch = getchar();
	for ( ; ch < '0' || ch > '9'; ch = getchar() )
		isn = ch == '-' ? true : isn;
	for ( ; ch >= '0' && ch <= '9'; ch = getchar() )
		rt = rt * 10 + ch - '0';
	return isn ? -rt : rt;
}

struct Hotel
{
	int pos, id;
}a[MAXN];
int dp[19][MAXN], rp[MAXN];

bool Cmp ( Hotel t1, Hotel t2 )
{
	return t1.pos < t2.pos;
}

int main()
{
//	freopen ( "test.in", "r", stdin );
	int n = R(), lm = log2 ( n );
	for ( int i = 1; i <= n; ++i )
		a[i].pos = R(), a[i].id = i;
	sort ( a + 1, a + n + 1, Cmp );
	for ( int i = 1; i <= n; ++i )
		rp[a[i].id] = i;
	int l = R();
	for ( int i = 1; i <= n; ++i )
	{
		int nl = i, nr = n;
		while ( nl <= nr )
		{
			int mid = nl + nr >> 1;
			if ( a[mid].pos - a[i].pos <= l )
				dp[0][i] = mid, nl = mid + 1;
			else
				nr = mid - 1;
		}
	}
	for ( int i = 1; i <= lm; ++i )
		for ( int j = 1; j <= n; ++j )
			dp[i][j] = dp[i - 1][dp[i - 1][j]];
	for ( int q = R(); q; --q )
	{
		int l = rp[R()], r = rp[R()];
		if ( l > r )
			swap ( l, r );
		int ans = 0;
		for ( int i = log2 ( r - l ); i >= 0; --i )
			if ( a[dp[i][l]].pos < a[r].pos )
				ans += 1 << i, l = dp[i][l];
		printf ( "%d\n", ans + 1 );
	}
	return 0;
}

Measured memory_bytes: 9472