akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
ll N,M,X;
vector<ll> C;
vector<vector<ll>>A;
int main(){
  cin >> N >> M >> X;
  C.resize(N);
  A.resize(N,vector<ll>(M));
  for (int i = 0; i < N; i++) {
    cin >> C[i];
    for (int l = 0; l < M; l++) {
      cin >> A[i][l];
    }
  }
  ll ans = LLONG_MAX;
  for (int bit = 0; bit < (1 << N); bit++) {
    bool can = true;
    ll cost = 0;
      vector<ll> rikai(M,0);
    for (int i = 0; i < N; i++) {
      if(bit & (1 << i)){
        cost += C[i];
        for (int a = 0; a < M; a++) {
          rikai[a] += A[i][a];
        }
      }
    }
    for (int l = 0; l < M; l++) {
      if(!(rikai[l] >= X))can = false;
    }
    if(can){
      ans = min(cost,ans);
    }
  }
  cout << (ans == LLONG_MAX ? -1 : ans) << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define lli long long int
#define pii pair<int,int>
#define vii vector<pii>
#define pb push_back
#define eb emplace_back
#define em emplace
#define all(v)  v.begin(),v.end()
#define mod 1000000007
#define vi vector<int>
#define vl vector<lli>
#define vll vector<pair<lli,lli>>
#define pll pair<lli,lli>
#define vvi vector<vector<int>>
#define vvl vector<vector<lli>>
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define tk(args...) take(args);
#define posLSB(X) __builtin_ctz(X)
#define num1bit(X) __builtin_popcount(X)
#define numlead0(X) __builtin_clz(X)
#define umreserve(X) X.reserve(32768); X.max_load_factor(0.25);
void err(istream_iterator<string> it) {} template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cout << *it << " = " << a << "\n"; err(++it, args...);}
void take() {} template<typename T, typename... Args> void take( T & a, Args & ... args ) { cin>>a; take(args...); }
template<class T>
void printvec(vector<T> &a){
	for(T &x:a){
		cout<<x<<" ";
	}
	cout<<endl;
}
template<class T>
void printarr(T a[],lli n){
	for(lli i=0;i<n;i++){
		cout<<a[i]<<" ";
	}
	cout<<endl;
}
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};

#define endl "\n"

lli add(lli a, lli b) {
	a += b;
	if (a >= mod) a -= mod;
	return a;
}

lli mul(lli a, lli b) {
	return a * 1ll * b % mod;
}

inline bool setmin(lli &x, lli y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(lli &x, lli y) { return (y > x) ? x = y, 1 : 0; }

lli power_mod(lli a,lli x){if(x==0) return 1;lli y=power_mod(a,x/2);lli ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
lli inv(lli a){return power_mod(a,mod-2);}
lli power(lli a, lli x){ if(x==0) return 1; lli y= power(a,x/2); lli ans=(y*y); if(x%2) ans*=a; return ans;}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	lli n,W;
	cin>>n>>W;
	vector<lli> w(n),v(n);
	for(lli i=0;i<n;i++)cin>>w[i]>>v[i];
	vector<lli> dp(W+1);
	for(lli i=0;i<n;i++){
		vector<lli> newdp(W+1);
		for(lli j=0;j<=W;j++){
			if(j-w[i]>=0)
				newdp[j]=max(dp[j-w[i]]+v[i],dp[j]);
			else{
				newdp[j]=dp[j];
			}
		}

		dp=newdp;
	}
	lli ans=0;
	for(lli i=0;i<=W;i++)ans=max(ans,dp[i]);
	cout<<ans<<endl;
}


Measured memory_bytes: 1804
n = int(input())
h = list(map(int, input().split()))

f = True
maxh = None
for i in range(n - 1, 0, -1):
    if i == n - 1:
        continue
    if h[i] - h[i + 1] == 1:
        h[i] -= 1
    elif h[i] - h[i + 1] > 1:
        print("No")
        exit(0)
print("Yes")


Measured memory_bytes: 14252
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,a,n) for(i=a; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define foreach(it,x) for(typeof(x.begin()) it=x.begin(); it!=x.end(); it++)


// YET_SYSTEM_TEST

typedef long long ll;

const int dx[] = {0,1,0,-1};
const int dy[] = {-1,0,1,0};
int w,h, tatu_x[20], tatu_y[20], kazu_x[20], kazu_y[20];
int field[12][12], cx[36], cy[36], csize;
map<pair<int,int>, int> idx;
set<pair<ll,ll> > visited[20][4][2];


bool inside(int x, int y){
    return !(x < 0 || x >= w || y >= h || y < 0 );
}

bool backtrack(int cnt, ll tS, ll kS, int init_dir, int f){
    int i,j,k;

    if( visited[cnt][init_dir][f].count(make_pair(tS,kS)) ) return false;
    if( csize/2 == cnt ) return true;

    rep(i,cnt){ // ツ達ツ姪ァツづ個チツδコツつゥツづァツ新ツつオツつ「ツ偲シツ陛督づ個チツδコツづーツ選ツ妥ー
        rep(k,4){
            int tx = tatu_x[i] + dx[k];
            int ty = tatu_y[i] + dy[k];
            if( !inside(tx,ty) || field[ty][tx] == 0 ) continue;

            // ツ妥篠可楪つキツづゥツ和ツ姪ァツづ個チツδコ
            int ttx = kazu_x[i] + dx[(k + init_dir + (f?2:0)) % 4];
            int tty = kazu_y[i] + dy[(k + init_dir) % 4];
            if( (tx == ttx && ty == tty) || !inside(ttx,tty) || field[tty][ttx] == 0 ) continue;

            field[ty][tx] = 0;
            tatu_x[cnt] = tx, tatu_y[cnt] = ty;

            field[tty][ttx] = 0;
            kazu_x[cnt] = ttx, kazu_y[cnt] = tty;

            if( backtrack(cnt+1, tS|(1LL<<idx[make_pair(tx,ty)]), kS|(1LL<<idx[make_pair(ttx,tty)]), init_dir, f) ) return true;
            field[tty][ttx] = 1;
            field[ty][tx] = 1;
        }
    }
    visited[cnt][init_dir][f].insert(make_pair(tS,kS));
    return false;
}

bool solve(){
    int i,j,k;

    if( csize % 2 ) return false;

    // ツ達ツ姪ァ
    tatu_x[0] = cx[0], tatu_y[0] = cy[0];
    field[cy[0]][cx[0]] = 0;

    REP(j,1,csize){ // ツ和ツ姪ァ
        kazu_x[0] = cx[j], kazu_y[0] = cy[j];
        field[cy[j]][cx[j]] = 0;

        rep(k,4){
            if( backtrack(1, 1LL, 1LL<<j, k, 0) ) return true;
            if( backtrack(1, 1LL, 1LL<<j, k, 1) ) return true;
        }
        field[cy[j]][cx[j]] = 1;
    }
    field[cy[0]][cx[0]] = 1;

    return false;
}

int main(){
    int i,j,k,u;

    while( cin >> w >> h, w|h ){
        // init
        idx.clear();
        rep(i,20) rep(j,4) rep(k,2) visited[i][j][k].clear();
        csize = 0;

        // input
        rep(i,h) rep(j,w){
            cin >> field[i][j];
            if( field[i][j] == 1 ){
                cx[csize] = j, cy[csize] = i;
                idx[make_pair(j,i)] = csize;
                csize++;
            }
        }
        puts( solve() ? "YES" : "NO" );
    }

    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
#define lint long long
auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;};
auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;};
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail){
  std::cerr << " " << head;
  debug_impl(tail...);
}
#ifndef STOPIT
#define debug(...)\
  std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
  debug_impl(__VA_ARGS__);\
  std::cerr << std::noboolalpha;
#else
#define debug 0;
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector< int > a(n);
  std::cin >> a;
  for (auto & x : a) x--;
  std::vector< int > b(n, -1);
  rep(i, 0, n) {
    b.at(a.at(i)) = i;
  }
  for (auto & x : b) x++;
  rep(i, 0, n)
    { std::cout << (i > 0 ? " " : "") << b.at(i); }
  std::cout << std::endl;
  return 0;
}


Measured memory_bytes: 1664
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
//        int t = in.nextInt();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) throws IOException {
            int n = in.nextInt();
            while (n > 0) {
                int rem = n % 10;
                n /= 10;
                if (rem == 7){
                    out.println("Yes");
                    return;
                }
            }
            out.println("No");
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public char nextChar() {
            return next().charAt(0);
        }

        public String nextLine() throws IOException {
            return reader.readLine().trim();
        }
    }
}


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

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

void gen(vector<ll> &tb, int digit, int starting, int mxDigit)
{
    if (digit > mxDigit)
        return;

    int mx = tb.size();
    for (int i = starting; i < mx; i++) {
        ll d = tb[i] % 10;
        if (d > 0)
            tb.push_back(tb[i] * 10 + d - 1);
        tb.push_back(tb[i] * 10 + d);
        if (d < 9)
            tb.push_back(tb[i] * 10 + d + 1);
    }

    gen(tb, digit + 1, mx, mxDigit);
}

int main()
{
    vector<ll> tb;
    for (int i = 1; i <= 9; i++)
        tb.push_back(i);
    gen(tb, 2, 0, 10);

    //    printf("%d\n", tb.size());
    sort(tb.begin(), tb.end());

    // for (int i = 0; i < tb.size(); i++)
    //  printf("%d\n", tb[i]);

    int k;
    scanf("%d", &k);

    printf("%lld\n", tb[k - 1]);

    return 0;
}


Measured memory_bytes: 2420
#include<stdio.h>
#include<string.h>
int main()
{
    char N[10];
    scanf("%s",N);
    for(int i=0;i<strlen(N);i++)
    {
        if(N[i]=='7')
        {printf("Yes\n");
          goto l;
        }
    }
    printf("No\n");
    l:return 0;
}


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

using namespace std;


int64_t gcd(int64_t one, int64_t other) {
    int64_t tmp;
    while (one != 0) {
        tmp = one;
        one = other % one;
        other = tmp;
    }
    return other;
}

int main(int argc, char *argv[]) {
    int N, X;
    cin >> N >> X;

    vector<int64_t> arr;
    int64_t cur;
    for (int64_t i = 0; i < N; i++) {
        cin >> cur;
        arr.push_back(abs(cur - X));
    }

    int ans = arr[0];
    for (int j = 0; j < N; j++) {
        int one = arr[j];
        ans = gcd(one, ans);
    }
    cout << ans << endl;
    return 0;
}


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

int n;
const int maxn=105;
int x[maxn];
int main(){
	cin >> n;
	for (int i=1;i<=n;i++){
		cin >> x[i];
	}		
	int mini = 1e9;
	int s=0;
	for (int j=1;j<=100;j++){
		s=0;
		for (int k=1;k<=n;k++){
			s += (x[k]-j)*(x[k]-j);	
		}
		mini = min(mini,s);
	}
	cout << mini;
	return 0;
}

Measured memory_bytes: 256
<?php
$n = (int)trim(fgets(STDIN));

for ($i=1; $i <= 9; $i++) { 
	for ($j=$i; $j <= 9; $j++) { 
		if ($n === $i * $j) {
			echo 'Yes';
			exit();
		}
	}
}
echo 'No';

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

int main() {
int a,b,m,k=1;
  cin >> a >> b >> m;
  for (int i=min(a,b); i!=0; i--){
  if(a%i==0&&b%i==0){
  if(k==m){
  cout << i << endl;
    return 0;
  }
    k+=1;
  }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i= a ; i < b ; ++i)
#define rep(i,n) fo(i,0,n)
#define pln(n) printf("%lld\n",n)
#define sll(n) scanf("%lld",&n)
#define ss(n) scanf("%s",n)
#define vi vector < int >
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define dbg3(x,y,z) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) <<" , "<< #z <<": "<<(z)<<endl; }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<int>
#define tr(c, it) \
for(decltype(c.begin()) it = c.begin(); it!= c.end(); it++)
#define pis pair<int,string>
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c),x) != c.end())
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    vi h(n);
    for(int i = 0; i < n; i++){
		cin >> h[i];
	}
	int dp[n];
	dp[n-1] = 0;
	for(int i = n-2; i >= 0; i--){
		int mn = INT_MAX;
	    for(int j = 1; j <= k; j++){
	    	if(i + j < n){
	    		mn = min(mn, dp[i + j] + abs(h[i+j] - h[i]));
	    	}
	    	else break;
	    }
	    dp[i] = mn;
	}
	cout << dp[0] << endl;
	return 0;
}

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

int main() {
    int a, b, m;
    cin >> a >> b >> m;
    vector<int> pa(a), pb(b);
    
    rep(i, a) cin >> pa.at(i);

    rep(i, b) cin >> pb.at(i);

    vector<vector<int>> discount(m, vector<int>(3));
    rep(i, m) {
        rep(j, 3) {
            cin >> discount.at(i).at(j);
        }
    }

    vector<int> price(m);
    rep(i, m) {
        price.at(i) = pa.at(discount.at(i).at(0) - 1)
        + pb.at(discount.at(i).at(1) - 1)
        - discount.at(i).at(2);
    }
    sort(price.begin(), price.end());
    sort(pa.begin(), pa.end());
    sort(pb.begin(), pb.end());

    int ans = 100100100;
    ans = min(ans, price.at(0));
    ans = min(ans, pa.at(0) + pb.at(0));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6912
N = int(input())
a = list(map(int, input().split()))

cnt = {}

for item in a:
    if item not in cnt:
        cnt[item] = 0
    cnt[item] += 1

A = list(set(a))

candidate = []

for item in A:
    if cnt[item] == 1:
        candidate.append(item)

judge = [True] *(10**6 + 1)

for item in A:
    for i in range(2, ((10**6)//item) + 1):
        judge[item*i] = False

ans = 0

for item in candidate:
    if judge[item]:
        ans += 1

print(ans)

Measured memory_bytes: 44616
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	int[] l = new int[n];
      	int[] tri = new int[3];
      	int count = 0;
      
      	for(int i = 0; i < n; i++){
        	l[i] = sc.nextInt();
        }
      	
      	for(int i = 0; i < n-2; i++){
        	for(int j = i+1; j < n-1; j++){
            	for(int k = j+1; k < n; k++){
                  	if(l[i]!=l[k] && l[i]!=l[j] && l[j]!=l[k]){
                      tri[0]=l[i];
                      tri[1]=l[j];
                      tri[2]=l[k];
                      Arrays.sort(tri);
                      if(tri[2] < tri[1]+tri[0]){
                      	count++;
                      }
                    }
                }
            }
        }
      	System.out.print(count);
    }
}

Measured memory_bytes: 36500
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

vector<int> E[101];
int d[101];
void dfs1(int a, int b) {
	if (d[a] == 0) {
		d[a] = b;
		for (int i : E[a]) dfs1(i, b + 1);
	}
}

int wakare[101];
void dfs2(int a, int b) {
	if (d[a] == 0) {
		d[a] = b;
		int kari = E[a].size();
		kari--;
		wakare[b] = max(wakare[b], kari);
		for (int i : E[a]) dfs2(i, b + 1);
	}
}


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


	int N;
	cin >> N;
	rep(i, N - 1) {
		int a, b;
		cin >> a >> b;
		E[a].pb(b);
		E[b].pb(a);
	}

	dfs1(1, 1);
	int saidai = 0;
	int doko, doko2;
	rep1(i, N) {
		if (saidai < d[i]) {
			saidai = d[i];
			doko = i;
		}
	}
	rep1(i, N) d[i] = 0;
	dfs1(doko, 1);
	saidai = 0;
	rep1(i, N) {
		if (saidai < d[i]) {
			saidai = d[i];
			doko2 = i;
		}
	}
	int d1[101], d2[101];
	rep1(i, N) d1[i] = d[i];
	rep1(i, N) d[i] = 0;
	dfs1(doko2, 1);
	rep1(i, N) d2[i] = d[i];

	cosp((saidai + 1) / 2);
	ll saishou = 1e18;

	if (saidai & 1) {
		int nekko;
		rep1(i, N) if (d1[i] == (saidai + 1) / 2 && d2[i] == (saidai + 1) / 2) {
			rep1(j, N) d[j] = 0;
			dfs2(i, 1);
			wakare[1]++;
			nekko = i;
			break;
		}
		ll kotae = 1;
		rep1(i, N) {
			if (wakare[i]) kotae *= wakare[i];
		}
		saishou = kotae;

		for (int i : E[nekko]) {
			rep1(j, N) d[j] = 0;
			rep1(j, N) wakare[j] = 0;
			d[i] = 1;
			dfs2(nekko, 1);
			d[i] = 0;
			dfs2(i, 1);
			ll kotae = 2;
			rep1(j, N) {
				if (wakare[j]) kotae *= wakare[j];
			}
			saishou = min(saishou, kotae);
		}
	}
	else {
		int a, b;
		rep1(i, N) {
			if (d1[i] == saidai / 2 && d2[i] == saidai / 2 + 1) {
				a = i;
			}
			else if (d2[i] == saidai / 2 && d1[i] == saidai / 2 + 1) {
				b = i;
			}
		}
		rep1(i, N) d[i] = 0;
		d[a] = 1;
		dfs2(b, 1);
		d[a] = 0;
		dfs2(a, 1);
		ll kotae = 2;
		rep1(i, N) {
			if (wakare[i]) kotae *= wakare[i];
		}
		saishou = kotae;
	}

	co(saishou);

	Would you please return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
vector<int> a;
int n;
 
signed main() {
    cin >> n;
  	int suma = 0;
  	int ans = 0;
    for(int i = 0;i < n;i++){
        int j;cin >> j;
        if(j == 0){
          ans += suma/2;
          suma = 0;
          continue;
        }
        suma += j;
    }
   	ans += suma/2;
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int dis[11],up,down,sum;
    char s;
    while(cin>>dis[1]>>s){
        sum=dis[1];
        for(int i=2;i<=10;i++){
                cin>>dis[i]>>s;
                sum+=dis[i];
        }
        cin>>up>>s>>down;
        double sec,spead=up+down;
        sec=(sum/spead)*up;
       // cout<<sec<<endl;
        for(int i=1;i<11;i++){
            sec-=dis[i];
            if(sec<=0){
                cout<<i<<endl;
                break;
            }
        }
    }
}

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

typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;

vector<int> AdjList[1000005];

int a[100005];
int b[100005];
int ans[100005];

bool visited[100005];

int main(){
    int N;
    scanf("%d", &N);

    set<iii> s;
    for(int i = 1; i < N; i ++){
        scanf("%d%d", &a[i], &b[i]);
        AdjList[a[i]].push_back(b[i]);
        AdjList[b[i]].push_back(a[i]);
        s.insert(iii(a[i], b[i], i));
        s.insert(iii(b[i], a[i], i));
    }

    int K = 0;
    for(int i = 1; i <= N; i ++){
        K = max(K, (int)AdjList[i].size());
    }

    memset(visited, 0, sizeof(visited));

    queue<ii> q;
    q.push(ii(1, 0));
    visited[1] = true;
    while(!q.empty()){
        ii temp = q.front(); q.pop();
        int u = temp.first;
        int x = temp.second;
        int i = 1;
        if(x == 1){i ++;}
        for(int v: AdjList[u]){
            if(!visited[v]){
                auto it = s.lower_bound(iii(u, v, -1));
                int indx = get<2>(*it);
                ans[indx] = i;
                visited[v] = true;
                q.push(ii(v, i));

                i ++;
                if(i == x){i ++;} // to avoid duplicate edges with the same colour
            }
        }
    }

    printf("%d\n", K);
    for(int i = 1; i < N; i ++){
        printf("%d\n", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 40960
import java.util.*;

public class Main {

    public static void main(String[] args) {
//        long startTime = System.currentTimeMillis();
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        int[] L = new int[M];
        int[] R = new int[M];
        for (int i = 0; i < M; i++) {
            L[i] = scanner.nextInt();
            R[i] = scanner.nextInt();
        }
        scanner.close();

        // index start
        int idxStart = 1;

        // index end
        int idxEnd = N;

        for (int i = 0; i < M; i++) {
            int l = L[i];
            int r = R[i];
            if (idxStart < l) {
                idxStart = l;
            }
            if (idxEnd > r) {
                idxEnd = r;
            }
        }

        // result count
        int result = idxEnd - idxStart;
        if (result == 0) {
            result = 1;
        } else if (result < 0) {
            result = 0;
        } else {
            result = result + 1;
        }

        System.out.println(result);

//        System.out.println(System.currentTimeMillis() - startTime);
    }


}


Measured memory_bytes: 80272
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e9 + 10;



int main()
{
    fastInp;

    ll m, d;
    cin >> m >> d;
    ll m1, d1;
    cin >> m1 >> d1;
    
    if (m1 != m) {
        cout << "1";
    } else {
        cout << "0";
    }

    return 0;
}

Measured memory_bytes: 3644
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
a=int(input())
b=0
for i in range(1,a+1,2):
    if len(make_divisors(i))==8:
        b+=1
print(b)

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

#define ff first
#define ss second
#define pb push_back

const int MAXN = 2e5 + 100, maxval = 2010, mod = 1e9 + 7;

int n;
int a[MAXN], b[MAXN];
int dp[maxval << 1][maxval << 1];
long long fact[MAXN], invfact[MAXN];
long long ans;

long long pw(long long a, long long b) {
    if (!b)
        return 1;

    long long res = pw(a, b / 2);

    res = res * res % mod;

    if (b & 1)
        res = res * a % mod;
    return res;
}

inline void sum(int &a, int b) {
    a += b;
    if (a >= mod)
        a -= mod;
    else if (a < 0)
        a += mod;
}

long long comb(int n, int r) {
    return fact[n] * (invfact[r] * invfact[n - r] % mod) % mod;
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    fact[0] = 1;
    invfact[0] = pw(fact[0], mod - 2);

    for (int i = 1; i < MAXN; i++) {
        fact[i] = fact[i - 1] * i % mod;
        invfact[i] = pw(fact[i], mod - 2);
    }

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        dp[maxval - a[i]][maxval - b[i]]++;
    }

    for (int i = 0; i < maxval * 2 - 2; i++)
        for (int j = 0; j < maxval * 2 - 2; j++) {
            sum(dp[i + 1][j], dp[i][j]);
            sum(dp[i][j + 1], dp[i][j]);
        }

    for (int i = 0; i < n; i++)
        ans = (ans + dp[maxval + a[i]][maxval + b[i]]) % mod;

    for (int i = 0; i < n; i++)
        ans = (ans - comb(2 * a[i] + 2 * b[i], 2 * a[i]) + mod) % mod;

    cout << ans * invfact[2] % mod << '\n';
    return 0;
}


Measured memory_bytes: 68096
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
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 double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
 
	int N;
	cin >> N;
	int num = 26;
	string S{};
	while(N>0){
		int a = N % num;
		if(a == 0){
			--N;
			a=26;
		}
		S = (char)('a'+a-1) + S;
		N /= num;
	}
	cout << S << endl;
}

Measured memory_bytes: 3660
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    ll gcd = __gcd(A[0], A[1]);
    for (ll i = 2; i < N; i++) {
        gcd = __gcd(gcd, A[i]);
    }

    cout << gcd << endl;

    return 0;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

ll gcd(ll a,ll b)
{
    if(a % b == 0){
        return b;
    }else{
        return gcd(b,a%b);
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,x;
    cin >> n >> x;
    cout << 3*(n-gcd(n,x)) << endl;
    return 0;
}


Measured memory_bytes: 256
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

int n,x,y;

int32_t main(){_
    //freopen("input","r",stdin);
	cin >> n;
	auto p = [](int x,int pow)
	{
		int ans = 1;
		while(pow--) ans *= x;
		return ans;
	};
	for(int i = 1;i <= n;i++)
	{
		cin >> x;
		y += !(x & 1);
	}
	rc(p(3,n) - p(2,y));
}


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

int main (){
	int a,b;
	scanf("%d%d",&a,&b);
	if(a*b%2==1)
	printf("Odd\n");
	if(a*b%2==0)
	printf("Even\n");
	return 0;
}

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

using namespace std;

#define ll long long int

vector<int> temp;

int main(){
  int X;
  cin >> X;
  for(int x=X;x<10E5;x++){
    int n;
    for(n=2;n<x/2+1;n++){
      if(x%n==0) break;
    }
    if(n==x/2+1){
      cout << x << endl;
      break;
    }
  }

  return 0;
}

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

int main(){
    int N;
    cin >> N;
    int arr[3], dp[3];
    memset(dp, 0, sizeof(dp));
    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++)
            cin >> arr[j];
        int a,b,c;
        a = arr[0] + max(dp[1], dp[2]);
        b = arr[1] + max(dp[0], dp[2]);
        c = arr[2] + max(dp[0], dp[1]);
        dp[0] = a;
        dp[1] = b;
        dp[2] = c;
    }
    cout << max(dp[0], max(dp[1], dp[2])) << "\n";


    return 0;
}

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

int main() {
    int x, y;
    
    int tmp;
    while(true) {
        cin >> x >> y;
        
        if (x == 0 && y == 0) {
            break;
        }
        
        if (x > y) {
            tmp = x;
            x = y;
            y = tmp;
        }
        cout << x << " " << y << endl;
    }
    return 0;
}


Measured memory_bytes: 3048
n,k,*x=gets(p).split.map(&:to_i)
puts (n-k+1).times.map{|i|
  l,r=x[i],x[i+k-1]
  if l>=0&&r>=0
    [l,r].max
  elsif l<=0&&r<=0
    [-l,-r].max
  else
    l.abs+r.abs+[l.abs,r.abs].min
  end
}.min

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

int main() {
    string word, largestWord, mostFrequentWord;
    int maxLength = 0, mode = 0;    
    map<string, int> words;

    while (cin >> word) {
        if (words.count(word)) {
            words[word]++;
            if (words[word] > mode) { 
                mode = words[word];
            }
        }
        else {
            words[word] = 1;            
        }

        if (word.size() > maxLength) {
            maxLength = word.size();
            largestWord = word;
        }
    }
    
    for (map<string, int>::iterator it = words.begin(); it != words.end(); ++it) {
        if (it->second == mode) {
            mostFrequentWord = it->first;
        }
    }

    cout << mostFrequentWord << " " << largestWord << endl;
    return 0;
}

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


void solve(){
    int n;
    cin >> n;
    vector<int> p;
    rep(i,n){
        int tmp;
        cin >> tmp;
        p.emplace_back(tmp);
    }
    sort(p.begin(),p.end());
    int sum = 0;
    rep(i,n){
        sum += p[i];
    }
    sum -= (p[n-1]/2);
    cout << sum << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n,h;cin>>n>>h;
  int a[100000];
  int b[100000];
  vector<int> use_b;
  REP(i,n){
    cin>>a[i]>>b[i];
  }
  sort(a,a+n);
  reverse(a,a+n);
  REP(i,n){
    if(b[i]>=a[0])use_b.push_back(b[i]);
  }
  sort(use_b.begin(), use_b.end());
  reverse(use_b.begin(), use_b.end());
  REP(i, (int)use_b.size()){
    if(i+1<(int)use_b.size())use_b[i+1]+=use_b[i];
  }
  REP(i,(int)use_b.size()){
    if(use_b[i]>=h){
      P(i+1);
      return 0;
    }
  }
  int count = (int)use_b.size();
  count+=(h-use_b[use_b.size()-1]+a[0] - 1)/a[0];
  P(count);
  return 0;
}


Measured memory_bytes: 1660
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
an = list(map(int, input().split()))
bn = list(map(int, input().split()))
cn = list(map(int, input().split()))

sum_bn = sum(bn)
sum_cn = 0

for i in range(N-1):
    if an[i] + 1 == an[i+1]:
        sum_cn += cn[an[i]-1]

print(sum_bn + sum_cn)


Measured memory_bytes: 38444
program main
    implicit none
    integer N, counter, bool, i, j
    integer, dimension(210) :: A = 0
    counter = 0
    bool = 0
    read *, N
    read *, A(1:N)

    do j = 1,40
        bool = 0
        do i = 1,N
            if(mod(A(i), 2) /= 0)bool = 1
        end do

        if(bool == 0) then
            counter = counter + 1
            do i = 1,N
                A(i) = A(i) / 2
            end do
        else
            exit
        end if
    end do
    
    print *, counter

end program main


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n, x, y, sum=0;
    cin>>n;
    // vector<ll> a(n);
    // for(int i = 0; i < n; i++)
    // {
        // cin>>a[i];
        // sum+=y;
    // }
    // sort(a.rbegin(), a.rend());
    // for(int i = x; i < n; i++)
    // {
        // sum+=a[i];
    // }
    // cout<<sum<<endl;
    // if(n>sum) cout<<"No"<<endl;
    // else cout<<"Yes"<<endl;
    // int ans = ceil(1.0*n/(1.0*x));
    // cout<<ans<<endl;
    x = ll(log2(n));
    sum=pow(2, x+1);
    sum--;
    cout<<sum<<endl;
}

Measured memory_bytes: 1020
#include"bits/stdc++.h"
using namespace std;
using ll = long long;

int main() {
    ll N;
    cin >> N;
    vector<ll> a(N), pos(N + 2, -1);
    for (ll i = 0; i < N; i++) {
        cin >> a[i];
        pos[a[i]] = i;
    }

    ll ans = 0;

    set<ll> st;
    st.insert(-1);
    st.insert(N);
    for (ll i = 1; i <= N; i++) {
        auto itr = st.lower_bound(pos[i]);
        ll r_value = *itr;
        itr--;
        ll l_value = *itr;

        ans += i * (pos[i] - l_value) * (r_value - pos[i]);

        st.insert(pos[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 12800
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;

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

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> input = Arrays.asList(br.readLine().split(" "));
            int ballCount = Integer.parseInt(input.get(0));
            int colorCount = Integer.parseInt(input.get(1));

            int ans = colorCount;
            ballCount -= 1;
            for (int i = 0; i < ballCount; i++) {
                ans *= (colorCount - 1);
            }

            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);  
        }
    }
}

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

using namespace std;


void solve() {
    int n; cin >> n;
    n%=10;
    if (n==3) {
        cout << "bon";
    } else if (n==0||n==1||n==6||n==8) {
        cout << "pon";
    } else {
        cout << "hon";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


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

int main(){
    int H,W,h,w;
    cin >>H >>W >>h >>w;
    int all=H*W;
    //W*h 消える行の個数
    //H*w 消える列の行
    cout <<all-h*W-(H-h)*w <<endl;

    return 0;
}

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

int main(void){
    long n;
    cin >> n;
    long nums[5];
    long ans = 0;
    for(int i = 0;i < 5;i++){
        cin >> nums[i];
        ans = max(ans,(n + nums[i] - 1) / nums[i]);
    }
    
    cout << ans + 4<< endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

int ans = 0;

void dfs(string str, int n){
    if(str.size()==10 || stoi(str)>n){
        return;
    }
    if((int)str.find('3')!=-1 && (int)str.find('5')!=-1 && (int)str.find('7')!=-1){
        ans++;
    }
    dfs(str + '3', n);
    dfs(str + '5', n);
    dfs(str + '7', n);
    return;
}

int main(){
    int n;
    cin >> n;
    dfs("3", n);
    dfs("5", n);
    dfs("7", n);
    cout << ans << endl;
    return 0;

}


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

int main()
{
    map<int,int> mp;
    int n;cin>>n;
    int a[100005];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        mp[a[i]]++;
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        int now = mp[a[i]];
        if(!now)continue;
        if(a[i]>now)
        {
            ans+=now;
            mp[a[i]]=0;
        }
        if(a[i]==now)continue;
        if(a[i]<now)
        {
            ans+=now-a[i];
            mp[a[i]]-=(now-a[i]);
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 5120
#include <stdio.h>

int main(void)
{
	int a1,a2,a3,s=0;

	scanf("%d%d%d",&a1,&a2,&a3);
	s = a1+a2+a3;
	if(s>=22) printf("bust\n");
	else if(s<=21) printf("win\n");
	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repbtw(i, a, b) for (int i = a; i <= (int)(b); i++)
#define all(v) v.begin(), v.end()
#define pr(x) cout << x << endl


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

    if(a >= k) pr(k);
    else if(a + b >= k) pr(a);
    else pr(a - (k-(a+b)));

    return 0;
}



Measured memory_bytes: 3636
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
#include<map>
#include<set>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

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

  if(A>=B) cout<<"delicious"<<endl;
  else if(X+A>=B) cout<<"safe"<<endl;
  else cout<<"dangerous"<<endl;
}


Measured memory_bytes: 256
open System

let n, m, x =
    let l = Console.ReadLine().Split(' ') |> Array.map int
    l.[0], l.[1], l.[2]

let lines =
    [ for i in 0 .. n - 1 do
        yield Console.ReadLine().Split(' ') |> Array.map int ]

let a = Array2D.init n m (fun i j -> lines.[i].[j + 1])
let c = Array.init n (fun i -> lines.[i].[0])

let ans =
    let mutable ans = Int32.MaxValue

    let rec dfs is k =
        if k = n then
            let ok =
                [ for j in 0 .. m - 1 do
                    let mutable sum = 0
                    for i in is do
                        sum <- sum + a.[i, j]
                    yield sum ]
                |> List.forall (fun sum -> sum >= x)

            if ok then
                let cost =
                    let mutable sum = 0
                    for i in is do
                        sum <- sum + c.[i]
                    sum
                ans <- min ans cost
        else
            dfs is (k + 1)
            dfs (k :: is) (k + 1)

    dfs [] 0
    if ans = Int32.MaxValue then ans <- -1
    ans

ans |> Console.WriteLine


Measured memory_bytes: 35624
#pragma comment(linker, "/STACK:500000000")
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <time.h>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

#define y0 y0ChloeGraceMoretz
#define y1 y1ChloeGraceMoretz
typedef long long ll;
typedef unsigned long long ull;
int nextInt() { int n; scanf("%d", &n); return n; }
ll nextLong() { ll n; scanf("%lld", &n); return n; }
const double PI = acos(-1.0);
const double EPS = 1e-9;
const int INF = (int)2e9;
const int MOD = (int)1e9 + 7;

char s[(int)1e5 + 9];

int main() {
	//freopen("in.txt", "rt", stdin);
	//freopen("out.txt", "wt", stdout);
	int k;
	scanf("%s %d", s, &k);
	int n = strlen(s);
	for (int i = 0; i < n; ++i) {
		if (s[i] != 'a') {
			int needed = (int) ('z' - s[i]) + 1;
			if (needed <= k) {
				s[i] = 'a';
				k -= needed;
			}
		}
	}
	if (k > 0) {
		k %= 26;
		s[n - 1] = (char) ('a' + (((int) (s[n - 1] - 'a') + k) % 26));
	}
	printf("%s\n", s);
	return 0;
}

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

using namespace std;
using ll =long long;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
#define leftunique(a) {sort((a).begin(),(a).end());(a).erase(unique((a).begin(),(a).end()),(a).end());}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
static const ll INF = 1LL << 60;
//Write From this Line

int main()
{
	string s;
	cin >> s;
	if(s[2] == s[3]){
		if(s[4] ==s[5]){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int> w(n), s(n), v(n);
  for(int i = 0; i < n; i++) cin >> w[i] >> s[i] >> v[i];
  vector<int> od(n);
  iota(od.begin(), od.end(), 0);
  sort(od.begin(), od.end(), [&](int a, int b){
    if(s[a] + w[a] == s[b] + w[b]) return v[a] > v[b];
    return s[a] + w[a] < s[b] + w[b];
  });
  const int l = 2 * 10100;
  vector<long long> f(l + 1, 0);
  for(int i = 0; i < n; i++){
    int id = od[i];
    for(int j = s[id]; j >= 0; j--){
      f[j + w[id]] = max(f[j + w[id]], f[j] + v[id]);
    }
  }
  long long ans = 0;
  for(int i = 0; i <= l; i++) ans = max(ans, f[i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
import java.util.*;
class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long P = sc.nextLong();
        long num = 1;
        long max = 1;
        long pmax = P;
	if(N==1) {
            System.out.println(P);
            return;
        }
        for(long i = 1; num<=P;i++) {
            if(P%num == 0) {
                max = i;
            }
            num = (long)Math.pow(i+1,N);
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 23764
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			final int N = s.nextInt();
			final int[] P = IntStream.generate(s::nextInt).limit(N).toArray();

			int ret = 0;
			for (int i = 1; i < N - 1; i++) {
				if (P[i - 1] < P[i] && P[i] < P[i + 1]) {
					ret++;
				}
				if (P[i - 1] > P[i] && P[i] > P[i + 1]) {
					ret++;
				}
			}
			System.out.println(ret);
		}
	}
}


Measured memory_bytes: 26960
#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);

    double t,x;
    cin >> t >> x;

    cout << fixed << setprecision(10) << t/x  << endl;
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <locale>
#include<set>



using namespace std;

#define MAX 200000
int main() {

long long n,m,i,j,k,fow,pt=0,ans=0,temp;
long long syurui=0;
cin>>n;
long long a[2][101];
for(j=0;j<2;j++) {
    for (i = 0; i < n; i++) {
        cin >> a[j][i];
    }
}
for(i=0;i<n;i++){
    temp=0;
    for(j=0;j<n;j++){
        if(j<=i){
            temp+=a[0][j];
        }
        if(i<=j){
            temp+=a[1][j];
        }
    }
    ans=max(temp,ans);
}

cout << ans << endl;

 return 0;

}


Measured memory_bytes: 256
n = int(input())
job = [[0, 0] for _ in range(n)]
for i in range(n):
    a, b = map(int, input().split())
    job[i][0] = b
    job[i][1] = a
job.sort()

ans = "Yes"
t = 0
for i in range(n):
    t += job[i][1]
    if t > job[i][0]:
        ans = "No"

print(ans)


Measured memory_bytes: 35616
W, H, N = map(int, input().split())
XYA = [list(map(int, input().split())) for _ in range(N)]

x1, x2, y1, y2 = 0, W, 0, H

for xya in XYA:
    a = xya[2]
    if a == 1:
        x1 = max(x1, xya[0])
    if a == 2:
        x2 = min(x2, xya[0])
    if a == 3:
        y1 = max(y1, xya[1])
    if a == 4:
        y2 = min(y2, xya[1])

w = max(0, x2-x1)
h = max(0, y2-y1)

print(w*h)


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

int main(){
  
  int N;
  cin >> N;
  
  int T, A;
  cin >> T >> A;
  
  vector<int> H(N);
  for(int i = 0; i < N; i++){
    cin >> H.at(i);
  }
  
  
  double mint = 1000;
  int find = 1;
  for(int i = 0; i < N; i++){
  if(mint > abs(T - 0.006 * H.at(i) - A)){
    mint = abs(T - 0.006 * H.at(i) - A);
    find = i + 1;
  }
  }
  
  cout << find << endl;
}
  
    

Measured memory_bytes: 256
#abc150 c
import itertools 
n = int(input())
lnp = tuple(map(int, input().split()))
lnq = tuple(map(int, input().split()))
ln = list(itertools.permutations(list(range(1,n+1))))
np, nq = (0,0)
for i in range(len(ln)) :
    if lnp == ln[i]:
        np = i
        
        break
for i in range(len(ln)) :
    if lnq == ln[i]:
        nq = i
        
        break
        
print(abs(np - nq))

Measured memory_bytes: 8052