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

long long MOD = 1e9+7;
int MAX_INT = 1e9;

// 最大公約数
long long gcd(long long a, long long b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
// 最小公倍数
long long lcm(long long a, long long b) {
  return a / gcd(a, b) * b;
}

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int N;
  cin >> N;
  map<int, int> A;
  for(int i = 0; i < N; i++) {
    int input;
    cin >> input;

    A[input]++;
  }
  
  int cnt = 0;
  for(auto itr : A) {
    if(itr.second % 2 != 0) cnt++;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 8208
import java.util.Scanner;


public class Main{

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String[] line = s.nextLine().split(" ");
		int height = Integer.parseInt(line[0]);
		int width = Integer.parseInt(line[1]);
		int [][] input = new int[width+1][height+1];
		for(int i=1 ; i<=height ; i++) {
			String str = s.nextLine();
			for(int j=1 ; j<=width ; j++) {
				input[j][i] = Integer.parseInt(str.substring(j-1, j));
			}
		}
		System.out.println(solve(height, width, input));
	}

	public static int solve(int height, int width, int[][] input) {
		int[][] result = new int[width+1][height+1];
		for(int i=0 ; i<=width ; i++) {
			result[i][0] = Integer.MAX_VALUE;
		}
		for(int i=0 ; i<=height ; i++) {
			result[0][i] = Integer.MAX_VALUE;
		}
		result[0][1] = 0;
		result[1][0] = 0;

		for(int i=1 ; i<=width ; i++) {
			for(int j=1 ; j<=height ; j++) {
				if(result[i-1][j] >= result[i][j-1])
					result[i][j] = result[i][j-1] + input[i][j];
				else
					result[i][j] = result[i-1][j] + input[i][j];
			}
		}
		return result[width][height];
	}
}

Measured memory_bytes: 17524
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N, K;
    cin >> N >> K;
    cout << (K == 1 ? 0 : N - (K - 1) - 1) << endl;
}

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

using namespace std;

const int MOD=1e9+7;
vector<tuple<int,int,int>> E;
int color[1000];
map<long long,int> cnt;

long long fast_pow(long long a, long long b)
{
	long long ret=1;
	for(;b;b>>=1) {
		if(b&1) ret=(ret*a)%MOD;
		a=(a*a)%MOD;
	}
	return ret;
}

int find_(int a)
{
	return color[a]=color[a]==a ? a:find_(color[a]);
}

void union_(int a, int b)
{
	a=find_(a); b=find_(b);
	color[a]=color[b]=min(a,b);
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(NULL);
	int N, M, s=0, e=0, m=0;
	long long X;
	cin>>N>>M>>X;
	E.resize(M);
	for(int i=0;i<M;i++) {
		int u, v, w;
		cin>>u>>v>>w;
		E[i]=make_tuple(w,--u,--v);
	}
	sort(E.begin(),E.end());
	for(int j=0;j<M;j++) {
		int u, v, w;
		long long sum;
		for(int i=0;i<N;i++) color[i]=i;
		tie(w,u,v)=E[j];
		sum=w;
		union_(u,v);
		for(int i=0;i<M;i++) {
			tie(w,u,v)=E[i];
			if(find_(u)!=find_(v)) {
				union_(u,v);
				sum+=w;
			}
		}
		cnt[sum]++;
	}
	for(auto t: cnt) {
		if(t.first<X) s+=t.second;
		else if(t.first>X) e+=t.second;
		else m+=t.second;
	}
	if(m==0) cout<<"0\n";
	else {
		long long ans;
		if(s) ans=(2LL*((fast_pow(2,m)+MOD-1)*fast_pow(2,e))%MOD)%MOD;
		else ans=((fast_pow(2,m)+MOD-2)*fast_pow(2,e))%MOD;
		cout<<ans%MOD<<'\n';
	}
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

void receive(int *, int *, int *);
int calc(int, int *);

int main(){
  int N, K, dislike[10] = {0};
  receive(&N, &K, dislike);
  
  int ans = calc(N, dislike);

  printf("%d\n", ans);
  return 0;
}

void receive(int *N, int *K, int *dislike){
  scanf("%d %d", N, K);
  for(int i = 0; i < *K; i++){
    int d;
    scanf("%d", &d);
    dislike[d] = 1;
  }
}

int calc(int N, int *dislike){
  int i = N;
  for(; i <= 10*N; i++){
    int j = i;
    while(j > 0 && !dislike[j%10]) j /= 10;
    if(j == 0) break;
  }
  return i;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <set>
#include <cstdio>
#include <vector>
#include <iostream>
#include <utility>

#define fir first
#define sec second
#define pb push_back
#define get(n) scanf("%d",&n);
#define gets(s) string s;cin >> (s);
#define prfi(n) printf("%d", &n);
#define prfd(n) printf("%lf", &n);
#define All(s) (s).begin(), (s).end()
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define rep(i, j) for (int (i)=0;(i)<(j);(i)++)
#define repk(i, j, k) for(int (i)=(j);(i)<(k);(i)++)
#define repdown(i, j, k) for(int (i)=(j);(i)>=(j);(i)--)
#define dump(x)  std::cout << #x << " = " << (x) << std::endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using ll = long long;
using vi = std::vector<int> ;
using vvi = std::vector<vi> ;
using vd = std::vector<double> ;
using vvd = std::vector<vd> ;
using qi = std::queue<int> ;
using vpii = std::vector<std::pair<int, int> >;
using namespace std;

const int Mod = 1e9 + 7;
const int max_n = 3 * 1e5 + 1;
const int max_m = 83 * 1e5 + 1;
const ll INF = 10241024;
long double INFD = 100100100;

//_________template______________
inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

//_____________________array calc____________________________________//
/*
vvi mul(vvi &A, vvi &B){
  vvi C(A.size(), vi(B.size()))
  rep(i,A.size()){
    rep(j,B.size()){
      rep(k,B[0].size()){
        C[i][j] = (C[i][j] A[i][k] + B[k][j]) % Mod;
      }
    }
  }

  return C;
}

vvi pow(vvi A, ll n){
  vvi B(A.size(), vi(A.size()));
  rep(i=0;i<A.size();i++){
    B[i][i] = 1;
  }

  while (n >0){
    if (n & 1) B = mul(B, A);
    A = mul(A, A);
    n = n >> 1;
  }
  return B;
}
*/
//_____________________Bynary Indexed Tree __________________________//
/*
const max_st = (1 << 15) - 1;
int bit[max_st];
int sum (int i){
  int s = 0;
  while(i > 0){
    s += bit[i];
    i -= i & -i;
  }
  return s;
}

void add(int i, int x){
  while(i <= n){
    bit[i] += x;
    i += i & -i;
  }
}
*/
//_____________________　following sorce code_________________________//
string s;
void input(){
  IN(s);
}

void solve(){
  input();
  int n = s.size();
  vi ans(n);
  rep(i, 2){
    {
      int count = 0;
      rep(i,n){
        if(s[i]=='R')count++;
        else {
          ans[i] += count / 2;
          ans[i-1] += (count+1) / 2;
          count = 0;
        }
      }
    }
    reverse(ans.begin(),ans.end());
    reverse(s.begin(), s.end());
    rep(i,n){
      if(s[i]=='L')s.at(i) = 'R';
      else s[i] = 'L';
    }
  }

  rep(i,n){
    OUT(ans[i]);
  }
}

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




Measured memory_bytes: 1104
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <string>

using namespace std;
using ll = long long;
using ull = size_t;

double T, X;

void input() {
    cin >> T >> X;
}

void solve() {
    auto ans = T / X;
    cout << ans << endl;
}

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



Measured memory_bytes: 256
import sys,math,copy

def main():
    # import numpy as np
    input = sys.stdin.readline
    S = ''.join(reversed(input().strip()))

    # dp = np.zeros((13), dtype=int)
    # dp_ = np.zeros((13), dtype=int)
    dp = [0] * 13
    dp_ = [0] * 13
    mod13_list = [i % 13 for i in range(12 ** 2 + 1)]
    list10 = list(range(10))
    list13 = list(range(13))
    divisor = 10 ** 9 + 7
    dp_[0] = 1
    mul = 1
    for i in range(len(S)):
        s = S[i]
        if s == '?':
            for d in list10:
                m = mod13_list[(d * mul)]
                for pm in list13:
                    dp[mod13_list[(pm+m)]] += dp_[pm]

        else:
            si = int(s)
            m = mod13_list[(si * mul)]
            for pm in list13:
                dp[mod13_list[(pm+m)]] = dp_[pm]

        # dp_ = dp % divisor
        # dp = dp * 0 # np.zeros((13), dtype=int)
        for j in list13:
            dp_[j] = dp[j] % divisor
            dp[j] = 0
        mul = mod13_list[(mul * 10)]
    print(dp_[5])

if __name__ == '__main__':
    main()


Measured memory_bytes: 50652
N,A,B=map(int,input().split())
hs = [int(input()) for _ in range(N)]
l=0
r=max(hs)

def enough(x):
  res = 0
  for i in range(N):
    res += max(0,(hs[i]-B*x+A-B-1))//(A-B)
  return res <= x

while l+1 < r:
  m = (l+r)//2
  if enough(m):
    r = m
  else:
    l = m

print(r)

Measured memory_bytes: 13032
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
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; }

int main(){
	int a,b,c;cin>>a>>b>>c;
	int cnt = 0;
	int k;cin>>k;
	while(a >= b){
		b *= 2;
		cnt++;
	}
	while(b >= c){
		c *= 2;
		cnt ++;
	}
	if(cnt <= k){
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3640
#include <vector>
#include <iostream>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int V, E, Q, a, b; vector<int> G[100009], rG[100009], vs; bool used[100009]; int cmp[100009];
void add_edge(int from, int to) {
	G[from].push_back(to);
	rG[to].push_back(from);
}
void dfs(int v) {
	used[v] = true;
	for (int i = 0; i < G[v].size(); i++) {
		if (!used[G[v][i]]) dfs(G[v][i]);
	}
	vs.push_back(v);
}
void rdfs(int v, int k) {
	used[v] = true;
	cmp[v] = k;
	for (int i = 0; i < rG[v].size(); i++) {
		if (!used[rG[v][i]]) rdfs(rG[v][i], k);
	}
}
int scc() {
	fill(used, used + V, false);
	vs.clear();
	for (int v = 0; v < V; v++) {
		if (!used[v]) dfs(v);
	}
	fill(used, used + V, false);
	int k = 0;
	for (int i = vs.size() - 1; i >= 0; i--) {
		if (!used[vs[i]]) rdfs(vs[i], k++);
	}
	return k;
}
int main() {
	scanf("%d%d", &V, &E);
	for (int i = 0; i < E; i++) {
		scanf("%d%d", &a, &b);
		add_edge(a, b);
	}
	scc();
	scanf("%d", &Q);
	for (int i = 0; i < Q; i++) {
		scanf("%d%d", &a, &b);
		printf("%d\n", (cmp[a] == cmp[b]) ? 1 : 0);
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  map<int, ll> mp;
  vector<int> a(N);
  rep(i, N){
    cin >> a[i];
    mp[a[i]]++;
  }

  ll total = 0;
  for(auto itr : mp){
    total += itr.second * (itr.second - 1) / 2;
  }

  for(int i = 0; i < N; ++i){
    ll ans = total;
    ll count = mp[a[i]];
    ans -= count * (count - 1) / 2;
    count--;
    ans += count * (count - 1) / 2;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 10368
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.IO;
using System.Text;
using System.Diagnostics;

class Program
{
    static void Main()
    {
        long[] nm = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long n = nm[0];
        long m = nm[1];

        List<long> previousroute = new List<long>();
        List<long> nextroute = new List<long>();

        for (long i = 0; i < m; i++)
        {
            string[] s = Console.ReadLine().Split();
            long a = long.Parse(s[0]);
            long b = long.Parse(s[1]);
            
            if (a == 1)
            {
                previousroute.Add(b);
            }

            if (b == n)
            {
                nextroute.Add(a);
            }
        }

        long[] cross = nextroute.ToArray();
        Array.Sort(cross);

        foreach(long prev in previousroute)
        {
            if (Array.BinarySearch(cross, prev) >= 0)
            {
                Console.WriteLine("POSSIBLE");
                return;
            }
        }

        Console.WriteLine("IMPOSSIBLE");
    }
}

Measured memory_bytes: 21940
using System;
using System.Linq;
public class Program {
	public static void Main() {
		while(true) {
			string s = Console.ReadLine();
			if(s == null) break;
			int[] x = s.Split(',').Select(int.Parse).ToArray();
			Array.Sort(x);
			int[] c = new int[13];
			for(int i = 0; i < 5; i++) c[x[i] - 1]++;
			Array.Sort(c);
			Array.Reverse(c);
			if(c[0] == 4) Console.WriteLine("four card");
			else if(c[0] == 3 && c[1] == 2) Console.WriteLine("full house");
			else if(c[0] == 3) Console.WriteLine("three card");
			else if(c[0] == 2 && c[1] == 2) Console.WriteLine("two pair");
			else if(c[0] == 2) Console.WriteLine("one pair");
			else if((x[1] + 1 == x[2] && x[2] + 1 == x[3] && x[3] + 1 == x[4]) && (x[0] + 1 == x[1] || (x[0] == 1 && x[1] == 10))) Console.WriteLine("straight");
			else Console.WriteLine("null");
		}
	}
}

Measured memory_bytes: 9340
N=int(input())
cN=N

d=1
while N%2==0:
  N//=2
  d+=1

k=-1
for i in range(1,int(N**0.5)+1):
  if N%i==0:
    if abs(i*(2**d)-N//i)==1:
      k=max(i*(2**d),N//i)
      break
    elif abs((N//i)*(2**d)-i)==1:
      k=max((N//i)*(2**d),i)
      break

if k==-1:
  print("No")
else:
  print("Yes")
  print(k)
  S=[[] for _ in range(k)]
  n=0
  for j in range(k):
    for i in range(1,k-j):
      S[j].append(n+i)
      S[i+j].append(n+i)
    n+=i
  
  for i in range(k):
    print(k-1," ".join(map(str,S[i])))


Measured memory_bytes: 12320
h, w, k = map(int, input().split())
ans = 0
c = [input() for i in range(h)]
for i in range(1<<h):
    for j in range(1<<w):
        cnt = 0
        for l in range(h):
            for m in range(w):
                if c[l][m] == '#' and (i >> l) & 1 and (j >> m) & 1:
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)

Measured memory_bytes: 9064
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    unsigned long long limit = pow(10,18);
    //cout << limit << endl;
    cin >> n;
    vector <long long> a(n);
    long long ans = 1;
    for(long long i = 0; i < n; i++){
        cin >> a[i];
        if(a[i]==0){
            cout << 0 << endl;
            return 0;
        }
    }
    //sort(a.begin(),a.end());
    for(long long i = 0; i < n; i++){
        long long a_div = 0;
        long long a_mod = 0;
        a_div=a[i]/10;
        a_mod=a[i]%10;
        if(a_div>(limit/10)){
            ans = -1;
            break;
        }
        long long oldAns = ans;
        long long newAns1 = a_div*oldAns;
        long long newAns2 = a_mod*oldAns;
        if(newAns1>(limit/10)){
            ans = -1;
            break;
        }
        ans=newAns1*10+newAns2;
        if(ans>(limit)){
            ans = -1;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define ld long double
using namespace std;

ll mod = 1000000007;


void solve()
{
ll a,b,c,d;
cin>>a>>b>>c>>d;

ll x=a*c;
ll y=a*d;
ll z=c*b;
ll k=b*d;
cout<< max( max(x,y),max(z,k))<<endl;

}

int main()
{

#ifndef ONLINE_JUDGE

	freopen("inputs.txt", "r", stdin);

	freopen("outputs.txt", "w", stdout);
#endif
	fast;
	
		solve();

	return 0;
}

Measured memory_bytes: 3648
# ARC078C - Splitting Pile (ABC067C)
from itertools import accumulate


def main():
    n = int(input())
    lst = tuple(accumulate(map(int, input().rstrip().split())))
    total = lst[-1]
    ans = min(abs(total - i * 2) for i in lst[:-1])
    print(ans)


if __name__ == "__main__":
    main()


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

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

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

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

int main()
{
    ll M, D;
    cin >> M >> D;
    ll ans = 0;
    REP(i, M)
    {
        REP(j, D)
        {
            ll d0 = (j + 1) % 10;
            ll d1 = (j + 1) / 10;
            if (d0 < 2 || d1 < 2)
                continue;
            if (d0 * d1 == (i + 1))
                ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int ans = 0;

        for(int i=a;i<=b;i++){
            if(c%i==0){
                ans++;
            }            
        }
        System.out.println(ans);
        }finally{
            scanner.close();
        }



    }
    
}


Measured memory_bytes: 26296
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using vi32 = vector<i32>;
using vu32 = vector<u32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf64 = vector<f64>;
using vstr = vector<string>;
using vvi32 = vector<vi32>;
using vvu32 = vector<vu32>;
using vvi64 = vector<vi64>;
using vvu64 = vector<vu64>;
using vvf64 = vector<vf64>;

template<typename T, typename S> bool amax(T &x, S y) { if (x < y) { x = y; return 1; } return 0; }
template<typename T, typename S> bool amin(T &x, S y) { if (y < x) { x = y; return 1; } return 0; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  i32 N, K;
  cin >> N >> K;
  vi32 A(N);
  rep(i, N) cin >> A[i];
  vi32 b(N, false);
  sort(all(A), greater<i32>());
  for(int i = 0; i < N; i++) {
    i32 idx = i;
    i64 sum = 0;
    while (idx < N && sum < K) {
      sum += A[idx++];
    }
    if (sum < K) break;
    sum -= A[--idx];
    i32 ok = idx, ng = N;
    while (ng - ok > 1) {
      i32 md = (ok + ng) / 2;
      if (sum + A[md] >= K) {
        ok = md;
      } else {
        ng = md;
      }
    }
    for (int j = i; j < idx; j++) {
      b[j] = true;
    }
    for (int j = idx; j <= ok; j++) {
      b[j] = true;
    }
  }
  int ans = 0;
  rep(i, N) if (!b[i]) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <climits>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>


using namespace std;
using ll = long long;

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

int main() {
	vector<char> buff;
	string s;
	cin >> s;
	for (const char c : s) {
		if (c == 'B') {
			if (!buff.empty())buff.pop_back();
		}
		else buff.push_back(c);
	}
	for (const char c : buff)cout << c;
	cout << endl;
}

Measured memory_bytes: 3572
use std::cmp;

fn main() {
  let nw_lim = read::<usize>();
  let n_lim = nw_lim[0];
  let w_lim = nw_lim[1];
  let mut items: Vec<(usize, usize)> = Vec::new();
  for _ in 0..n_lim {
    let wv = read::<usize>();
    items.push((wv[0], wv[1]));
  }
  
  let mut dp: Vec<Vec<usize>> = Vec::new();
  dp.push(vec![0; n_lim]);
  for w_cur in 1..=w_lim {
    let mut row = vec![0];
    for i in 0..n_lim {
      let (w, v) = items[i];
      let mut max = 0;
      if w <= w_cur {
        max = dp[w_cur-w][i] + v;
      }
      max = cmp::max(max, row[i]);
      row.push(max);
    }
    dp.push(row);
  }
  let max = dp[w_lim][n_lim];
  
  println!("{}", max);
}

fn read<T: std::str::FromStr>() -> Vec<T> {
  gets().split_whitespace().filter_map(|s|s.parse().ok()).collect()
}

fn gets() -> String {
  let mut line = String::new();
  std::io::stdin().read_line(&mut line).ok();
  line.trim().to_string()
}


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

using namespace std;

#define inputInt(a) scanf("%d", &a)
#define inputStr(a) getline(cin, a)
#define inputLong(a) scanf("%I64d", &a)
#define clr(a) memset(a, 0, sizeof(a))
#define printn(a) cout<<a<<"\n"
#define print(a) cout<<a

int num[10];

int main()
{
	


	string n;
	cin>>n;

	if((n[0] == n[1] and n[1] == n[2]) or (n[1] == n[2] and n[2] == n[3]))
		cout<<"Yes"<<endl;
	else if(n[0] == n[1] and n[1] == n[2] and n[2] == n[3])
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;

	return 0;

}

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

int main(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    cout << (k%2 == 0 ? a-b : b-a)  << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

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

	if (A >= 13) {
		cout << B << endl;
	}
	else if (6 <= A && A <= 12) {
		cout << B / 2 << endl;
	}
	else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int h=sc.nextInt();
		int w=sc.nextInt();
		int[][] ary=new int[h+1][w+1];
		for(int i=0; i<h; i++) {
			for(int j=0; j<w; j++) {
				ary[i][j]=sc.nextInt();
				ary[i][w]+=ary[i][j];
				ary[h][j]+=ary[i][j];
				ary[h][w]+=ary[i][j];
			}
		}
		for(int i=0; i<=h; i++) {
			output(ary[i]);
		}
	}
	public static void output(int[] a) {
		for(int i=0; i<a.length-1; i++) {
			System.out.print(a[i]+" ");
		}
		if(a.length-1>=0) {
			System.out.println(a[a.length-1]);
		}
	}
}


Measured memory_bytes: 41704
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
constexpr int MOD = 1000000007;
constexpr int INF = 1e18;

using namespace std;

vector<int> dijkstra(int i,int n, vector<vector<pair<int, int>>> graph) {
  vector<int> d(n, INF);
  d[i] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
  q.push(make_pair(0, i));
  while (!q.empty()) {
    pair<int, int> p = q.top();
    q.pop();
    int v = p.second;
    if (d[v] < p.first) {
      continue;
    }
    for (auto x : graph[v]) {
      if (d[x.first] > d[v] + x.second) {
        d[x.first] = d[v] + x.second;
        q.push(pair<int, int>(d[x.first], x.first));
      }
    }
  }
  return d;
}

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

  vector<vector<pair<int, int>>> graph(N);
  vector<int> cnt(N);
  REP(i, N-1){
    int u, v, w;
    cin >> u >> v >> w;
    u--; v--;
    graph[u].push_back(make_pair(v, w));
    graph[v].push_back(make_pair(u, w));
  }


  vector<int> dist = dijkstra(0, N, graph);
  REP(i, N) cout << (dist[i]%2?1:0) << endl;

  return 0;
}

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

int a[100009],b[100009],c[100009],fa[100009],va[100009]={0},cva[100009]={0},cvb[100009]={0},xore=0;
bool is[100009]={0},vis=0;

int gf(int u){
	if(fa[u]==u){return u;}
	va[fa[u]]+=va[u];va[u]=0;
	return fa[u]=gf(fa[u]);
}

int main(){
	int n,res=0,tot,apos,bpos;
	scanf("%d",&n);
	for(int i=1;i<=n;i=-(~i)){scanf("%d",&a[i]);c[i]=a[i];xore^=a[i];}	
	sort(c+1,c+1+n);tot=unique(c+1,c+1+n)-c-1;
	for(int i=1;i<=tot;i=-(~i)){fa[i]=i;}fa[tot+1]=tot+1;
	for(int i=1;i<=n;i=-(~i)){
		scanf("%d",&b[i]);
		if(a[i]==b[i]){continue;}
		apos=lower_bound(c+1,c+1+tot,a[i])-c;
		bpos=lower_bound(c+1,c+1+tot,b[i])-c;
		if(c[bpos]!=b[i]){
			if(vis||b[i]!=xore){printf("-1\n");return 0;}
			else{vis=true;res--;bpos=tot+1;}//本质 xore 不参与离散化，也不参与并查集统计
		}
		cva[apos]++;cvb[bpos]++;
//		fprintf(stdout,"%d[%d:%d %d[%d:%d %d %d\n",a[i],c[apos],apos,b[i],c[bpos],bpos,tot,xore);
		if(gf(apos)!=gf(bpos)){va[fa[apos]]+=va[fa[bpos]];va[fa[bpos]]=0;fa[fa[bpos]]=fa[apos];}//注意顺序
		va[fa[bpos]]++;
	}
	for(int i=1;i<=tot;i=-(~i)){
		gf(i);
		if(c[i]==xore){vis=true;res--;cvb[i]--;}
		//不能直接用vis判断
		if(cva[i]<cvb[i]){printf("-1\n");return 0;}
	}
	for(int i=1;i<=tot;i=-(~i)){
		if(va[i]){res+=va[i]+1;}//fprintf(stdout,"%d:%d\n",c[i],va[i]+1);}
	}
	printf("%d\n",((res<0)?0:res));
	return 0;
}

Measured memory_bytes: 2944
#include<stdio.h>

int counter=0;

bool bubbleSort(int* A , int N){
    bool flag = true;
    while(flag){
        flag = false;
        for(int i=N-1; i>0; i--){
            if(A[i]<A[i-1]){
                int tmp = A[i];
                A[i] = A[i-1];
                A[i-1] = tmp;
                flag = true;
                counter++;
            }
        }
    }
}

int main(){

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

    int A[n];
    for(int i=0; i<n; i++){
        scanf("%d", &A[i]);
    }

    bubbleSort(A, n);
    for(int i=0; i<n; i++){
        if(i!=n-1) printf("%d ", A[i]);
        if(i==n-1) printf("%d\n", A[i]);
    }
    printf("%d\n", counter);

    return 0;
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

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

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n,k; cin>>n>>k;
  vi a(n);
  rep(i,n)cin>>a[i];
  int b=1e9;
  rep(i,k)chmin(b,a[i]);
  int i=0;
  int ans=0;
  while(i<n){
    while(a[i]==b)i++;
    if(i>=n)break;
    ans++;
    bool flg=false;
    for(int j=i;j<k;j++) if(a[j]==b)flg=true;
    if(flg)i+=k;
    else i+=k-1;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
def main():
    A, B, C, D, E, F = map(int, input().split())
    xl = []
    yl = []
    for i in range(31):
        for j in range(31):
            x = 100 * A * i + 100 * B * j
            if F >= x and x > 0 and x not in xl:
                xl.append(x)
    for i in range(F):
        for j in range(F):
            y = C * i + D * j
            if F >= y and y > 0 and y not in yl:
                yl.append(y)
    ax = 3001
    ay = 0
    for x in xl:
        for y in yl:
            if F >= x + y and E / (E + 100) >= y / (x + y) and y / (x + y) > ay / (ax + ay):
                ax = x
                ay = y
    if ax == 3001:
        print(100 * A, 0, end=' ')
    else:
        print(ax + ay, ay, end=' ')


main()


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

int main() {
	int N;
  	int C0, C1, C2, C3;
  
  	C0 = C1 = C2 = C3 = 0;
  	cin >> N;
  
  	vector<string> S(N);
	
  	for(int i = 0; i < N; i++){
      cin >> S.at(i);
    }
  
  	for(int j = 0; j < N; j++){
  		if(S.at(j)=="AC"){
          	C0 = C0 + 1;
        }
      	else if(S.at(j)=="WA"){
          	C1 = C1 + 1;
        }
      	else if(S.at(j)=="TLE"){
          	C2 = C2 + 1;
        }
      	else if(S.at(j)=="RE"){
          	C3 = C3 + 1;
        }
    }
  
	cout << "AC" << " " << "x" << " " << C0 << endl;
  	cout << "WA" << " " << "x" << " " << C1 << endl;
  	cout << "TLE" << " " << "x" << " " << C2 << endl;
  	cout << "RE" << " " << "x" << " " << C3 << endl;
}

Measured memory_bytes: 6368
#include <bits/stdc++.h>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main() {
char abc[3];
  cin >> abc;
  if(abc[0] != abc[1] && abc[1] != abc[2] && abc[2] != abc[0]) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
// AOJ 2642: Dinner
// 2017.11.9 bal4u@uu
// 2018.1.5

#include <stdio.h>
#include <stdlib.h>

long long a[500003];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	if (c == '-') {
		c = getchar_unlocked();
		do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
		while (c >= '0');
		return -n;
	}
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

#define THRESHOLD 10
#define STACKSIZE 64		// 2^432 for long long int

void quicksort(long long *a, int n)
{
	int i, j, l, r, p;
	int lsp[STACKSIZE], rsp[STACKSIZE];
	long long m, t;
	
	l = 0, r = n-1, p = 0;
	while (1) {
		if (r-l <= THRESHOLD) {
			if (!p--) break;
			l = lsp[p], r = rsp[p];
		}
		m = a[(l+r)>>1];
		i = l, j = r;
		while (1) {
			while (a[i] > m) i++;
			while (m > a[j]) j--;
			if (i >= j) break;
			t = a[i], a[i] = a[j], a[j] = t;
			i++, j--;
		}
		if (i-l > r-j) {
			if (i-l > THRESHOLD) {
				lsp[p] = l;
				rsp[p] = i-1;
				p++;
			}
			l = j+1;
		} else {
			if (r-j > THRESHOLD) {
				lsp[p] = j+1;
				rsp[p] = r;
				p++;
			}
			r = i-1;
		}
	}
	
	// insert sorting
	for (i = 1; i < n; i++) {
		m = a[i];
		for (j = i-1; j >= 0 && a[j] < m; j--) a[j+1] = a[j];
		a[j+1] = m;
	}
}


int main()
{
	int n, q, c, i;
	long long p, s, t, ans;

	n = in(), p = in(), q = in();
    for (s = 0, t = p*q, i = 0; i < n; i++, t -= p) {
		c = in(), a[i] = t - c, s += c;
    }

	quicksort(a, n);
    for (ans = s, t = 0, p <<= 1, i = 0; i < n; i++, t += p) {
		s += a[i] + t;
		if (s > ans) ans = s;
	}
    printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 5744
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  long long ans = 0;
  for(int i = 0; i < n; i++){
    long long l, r;
    cin >> l >> r;
    ans += r - l + 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
        int b,f,r,v,n,i,j;
        int a[4][3][10]={0};
        scanf("%d",&n);
        for(i=0;i<n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
                a[b-1][f-1][r-1]=a[b-1][f-1][r-1]+v;
	}
        for(i=0;i<4;i++){
		for(j=0;j<3;j++){
		       printf(" %d %d %d %d %d %d %d %d %d %d\n",a[i][j][0],a[i][j][1],a[i][j][2],a[i][j][3],a[i][j][4],a[i][j][5],a[i][j][6],a[i][j][7],a[i][j][8],a[i][j][9]);
                }
                if(i<3){printf("####################\n");}
	}
	
	return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,x,y,ans;
int main()
{
	scanf("%lld%lld%lld%lld%lld",&a,&b,&c,&x,&y);
	if(c*2<a+b){
		if(x<y){
			ans+=x*2*c;
			
			ans+=min((y-x)*b,(y-x)*2*c);
		}
		else{
			ans+=y*2*c;
			ans+=min((x-y)*a,(x-y)*2*c);
		}
	}else{
		ans=x*a+y*b;
		
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
 
int n,t,b;
int a[1010];          
 
int main() {
    cin >> n;
    cin >> t;
    cin >> b;
    for (int i = 1; i<=n; i++) cin >> a[i];
    
    int c = b;
    
    double min = 10000;
    int findID = -1;
    
    for(int i = 1; i<=n; i++){
		double tmp = t-a[i]*0.006;
		if(min > abs(c-tmp)){ min = abs(c-tmp);
			
		findID = i;}
		
	}
		cout<<findID<<endl;
 
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int n;
  cin >> n;
  
  vector<int>num(n);
  for(int i=0;i<n;i++){
    cin >> num[i];
  }
  
  bool ans = true;
  
  for(int i=0;i<n;i++){
    if(num[i] % 2 == 0){
      if(num[i] % 3 != 0 && num[i] % 5 != 0){
        ans = false;
      }
    }
  }

    if(ans)
      cout << "APPROVED" << endl;
    else
      cout << "DENIED" << endl;
    
    return 0;
  }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

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 = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    LL sum = 0;
    int cnt = 0;
    while( sum < n ) {
        ++cnt;
        sum += cnt;
    }
    
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 256
/*
T(i, j) 前 i 天以 j 活动结尾的最优值
T(0, a) = T(0, b) = T(0, c) = 0

T(i, j) = max{T(i-1, k!=j) + happiness of j at day i}

*/

package main

import "fmt"

const N = 100005
const INF = 1e9+7
var p [N][3]int
var T [N][3]int

func umax(current *int, val int) {
  if val > *current {
    *current = val
  }
}

func max(a ...int) int {
  v := a[0]
  for i := 1; i < len(a); i++ {
    umax(&v, a[i])
  }
  return v
}

func main() {
  var n int
  fmt.Scanf("%d", &n)
  for i := 1; i <= n; i++ {
    fmt.Scanf("%d %d %d", &p[i][0], &p[i][1], &p[i][2])
  }
  for i := 1; i <= n; i++ {
    for j := 0; j < 2; j++ {
      T[i][j] = 0
    }
  }
  for i := 1; i <= n; i++ {
    for j := 0; j < 3; j++ {
      v := &T[i][j]
      for k := 0; k < 3; k++ {
        if j == k { continue }
        umax(v, T[i-1][k] + p[i][j])
      }
    }
  }
  
  fmt.Println(max(T[n][0], T[n][1], T[n][2]))
}

Measured memory_bytes: 11020
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
using R = double;
using Data = pair < ll, vector <ll>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 60;
struct edge { ll from; ll to; ll cost; };
typedef tuple<ll, ll, ll>T;
typedef pair<ll, ll>pll;
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2

double dp[310][310][310];
int n;
double rec(int i,int j,int k) {
	if (dp[i][j][k] >= 0)return dp[i][j][k];
	if (i == 0 && j == 0 && k == 0)return 0.0;

	double res = 0.0;
	if (i > 0)res += rec(i-1,j,k)*i;
	if (j > 0)res += rec(i+1,j-1,k)*j;
	if (k > 0)res += rec(i, j + 1, k - 1)*k;
	res += n;
	res *= 1.0 / (i + j + k);
	return dp[i][j][k] = res;
}

int main() {
	cin >> n;
	int one = 0, two = 0, three = 0;
	rep(i, 0, n) {
		int a;
		cin >> a;
		if (a == 1)one++;
		else if (a == 2)two++;
		else three++;
	}
	memset(dp, -1, sizeof(dp));
	printf("%.20f\n", rec(one, two, three));
	
	return 0;
}


Measured memory_bytes: 233088
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll A[100010];
    cin >> N;
    rep(i,0,N) cin >> A[i];
    if(N == 1){
        print(1);
        return 0;
    }
    ll p = -1;
    ll ans = 1;
    rep(i,0,N-1){
        if(p == -1){
            if(A[i] == A[i+1]){
                p = 0;
            }else if(A[i] < A[i+1]){
                p = 1;
            }else{
                p = 2;
            }
        }else if(p == 0){
            if(A[i] < A[i+1]){
                p = 1;
            }else if(A[i] > A[i+1]){
                p = 2;
            }
        }else if(p == 1){
            if(A[i] > A[i+1]){
                p = -1;
                ans++;
            }
        }else{
            if(A[i] < A[i+1]){
                p = -1;
                ans++;
            }
        }
    }
    print(ans);
 }

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

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

  long long n, m;
  cin >> n >> m;
  vector<int> x(m), y(m);
  vector<vector<int> > graph(n);
  vector<int> iriji(n, 0);
  for(int i=0;i<m;i++){
    cin >> x[i] >> y[i];
    x[i]--; y[i]--;
    graph[x[i]].push_back(y[i]);
    iriji[y[i]]++;
  }
  queue<int> que;
  for(int i=0;i<n;i++){
    if(iriji[i] == 0){
      que.push(i);
    }
  }
  vector<int> dp(n, 0);
  while(!que.empty()){
    int now = que.front();
    que.pop();
    for(size_t i=0;i<graph[now].size();i++){
      int next = graph[now][i];
      iriji[next]--;
      dp[next] = max(dp[next], dp[now]+1);
      if(iriji[next] == 0){
        que.push(next);
      }
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    ans=max(ans, dp[i]);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std; //ごめんなさい
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

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

  int N,M,R;
  cin>>N>>M>>R;
  vector<int>r(R);
  for(int i=0;i<R;i++)cin>>r[i];
  vector<vector<int>>g(N,vector<int>(N,INT_MAX));
  for(int i=0;i<N;i++)g[i][i]=0;
  for(int i=0;i<M;i++){
    int A,B,C;
    cin>>A>>B>>C;
    A--,B--;
    g[A][B]=C;
    g[B][A]=C;
  }
  for(int k=0;k<N;k++){
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        if(g[i][k]==INT_MAX||g[k][j]==INT_MAX)continue;
        g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
      }
    }
  }
  sort(rng(r));
  int ans=INT_MAX;
  do{
    int res=0;
    for(int i=0;i<R-1;i++){
      res+=g[r[i]-1][r[i+1]-1];
    }
    ans=min(ans,res);
  }while(next_permutation(rng(r)));
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
n = gets.chomp.to_i
h = gets.chomp.split(" ").map(&:to_i)
i = 0
j = 1
if n == 1
    puts "Yes"
    exit
end

until j == n 
    if h[i] < h[j]
        h[j] = h[j] - 1
    end
    if h[i] > h[j]
        puts "No"
        exit
    end
    j += 1
    i += 1
end
puts "Yes"


Measured memory_bytes: 21880
from collections import deque

N = int(input())
E = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    E[a-1].append(b-1)
    E[b-1].append(a-1)
    
q = deque()
q.append(0)
parents = [-1]*N
parents[0] = -2
while q:
    t = q.popleft()
    for i in E[t]:
        if parents[i] == -1:
            parents[i] = t
            q.append(i)
    if parents[N-1] >= 0:
        break

q_snuke = deque()
q_snuke.append(N-1)
idx = N-1
used = [0]*N
used[0] = 1
cnt = 0
while parents[idx] >= 0:
    q_snuke.append(parents[idx])
    idx = parents[idx]
    used[idx] = 1

n = len(q_snuke)
for _ in range(n//2+(n%2)):
    q_snuke.pop()
    

while q_snuke:
    t = q_snuke.popleft()
    for i in E[t]:
        if used[i] == 0:
            used[i] = 1
            q_snuke.append(i)

s = sum(used) - (n//2+(n%2))
if s >= N-s or N == 2:
    print("Snuke")
else:
    print("Fennec")

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


int main()
{
    char s[3];
    int i, j;

    for(i=0;i<3;i++){
        cin >> s[i];
    }

    j = 0;
    for(i=0;i<3;i++){
        if(s[i] == 'A'){
            j++;
        }
    }

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

    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, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_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;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

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

    size_t N; cin >> N;

    vector<size_t> l(2 * N);
    for (size_t i = 0; i < 2 * N; ++i) {
        cin >> l[i];
    }

    sort(l.rbegin(), l.rend());

    size_t res = 0;
    for (size_t i = 0; i < 2 * N; i += 2) {
        res += min(l[i], l[i + 1]);
    }

    cout << res << "\n";

    return 0;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> cnt(n+1, 1);
    vector<bool> red(n+1, false);
    red[1] = true;
    set<int> s;
    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        cnt[x]--, cnt[y]++;
        if(red[x]){
            red[y] = true;
            if(cnt[x] == 0) red[x] = false;
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(red[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3668
#include<iostream>
#include<math.h>
using namespace std;

int main() {
    string a, b; cin >> a >> b;
    int c = stoi(a + b);
    for (int i = 1; i <= c / 2; i++) {
        if (pow(i, 2) == c) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
  
// #define int long long
#define pb push_back
#define print(Target) cout << Target << '\n'
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;

bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}

struct DIC{
  string s;
  int cnt;
};

bool cmp(DIC lhs, DIC rhs)
{
  if (lhs.cnt != rhs.cnt){
    return (lhs.cnt > rhs.cnt);
  }
  else {
    return (lhs.s < rhs.s);
  }
}

signed main()
{
  // ios::sync_with_stdio(false);
  int n;
  while (cin >> n, n){
    vector<DIC> dic;
    REP(i, n){
      string input;
      while (cin >> input){
        bool same = false;
        REP(j, dic.size()){
          if (input == dic[j].s){
            same = true;
            dic[j].cnt++;
            break;
          }
        }
        if (!same) {
          dic.pb((DIC){input, 1});
        }
        char c;
        if (scanf("%c", &c), c == '\n') break;
      }
    }
    string t;
    cin >> t;
    sort(dic.begin(), dic.end(), cmp);

    int w = 0;
    bool first = false;
    for (int i = 0; w < 5 && i < dic.size(); i++){
      if (t[0] == dic[i].s[0]){
        if (first){
          cout << " ";
        }
        cout << dic[i].s;
        w++;
        first = true;
      }
    }
    if (!w){
      cout << "NA";
    }
    print("");
  }

  return (0);
}

Measured memory_bytes: 1244
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <limits>

using namespace std;

int N;
vector<long long> v;
vector<vector<vector<long long>>> dp;
long long LIM = std::numeric_limits<long long>::min();

long long deque(long long i, long long j, long long c = 1)
{ 
  if (i+1 == j) return v[i] * c;
  
  int k = c < 0 ? 0 : 1;
  
  if (dp[i][j][k] != LIM)
  { 
    return dp[i][j][k];
  }
  
  long long a = v[i]*c + deque(i+1, j, c*-1);
  long long b = v[j-1]*c + deque(i, j-1, c*-1);
  
  dp[i][j][k] = c < 0 ? min(a, b) : max(a, b);
  return dp[i][j][k];
}

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

  std::cin >> N;
  v.resize(N);
  dp = vector<vector<vector<long long>>>(N+1, vector<vector<long long>>(N+1, vector<long long>(2, LIM)));

  for (int i = 0; i < N; ++i)
  { 
    long long val;
    cin >> val;
    v[i] = val;
  }

  std::cout << deque(0, N);

  return 0;
}


Measured memory_bytes: 493312
def popcount(x):
    x = x - ((x >> 1) & 0x55555555)
    x = (x & 0x33333333) + ((x >> 2) & 0x33333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    return x & 0x0000007f

cmb=[[0 for i in range(51)] for j in range(51)]
cmb[0][0]=1
for i in range(51):
    for j in range(51):
        if i!=50:
            cmb[i+1][j]+=cmb[i][j]
        if j!=50 and i!=50:
            cmb[i+1][j+1]+=cmb[i][j]


for i in range(1,51):
    for j in range(2,51):
        cmb[i][j]+=cmb[i][j-1]

import random
N,K,T,S=map(int,input().split())
a=list(map(int,input().split()))

must0=[i for i in range(18) if S>>i &1==0]
must1=[i for i in range(18) if T>>i &1==1]

A=[]
for val in a:
    check=True
    for j in must0:
        check=check&(val>>j &1==0)
    for j in must1:
        check=check&(val>>j &1==1)
    if check:
        A.append(val)

if not A:
    print(0)
    exit()

bit=[]
for i in range(18):
    if i not in must0 and i not in must1:
        bit.append(i)

for i in range(len(A)):
    temp=0
    for j in range(len(bit)):
        temp+=(A[i]>>bit[j] &1==1)*2**j
    A[i]=temp

ans=0
n=len(bit)
data=[0]*(2**n)
pc=[popcount(i) for i in range(2**n)]
for i in range(2**n):
    for a in A:
        data[a&i]+=1
    for a in A:
        if data[a&i]:
            ans+=cmb[data[a&i]][min(K,data[a&i])]*(-1)**pc[i]
            data[a&i]=0

print(ans)

Measured memory_bytes: 102912
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,a;
  cin>>N;
  a=0;
  vector<int> H(N);
  for(int i=0;i<N;i++){
    cin>>H.at(i);}
  
  for(int i=N-1;i>0;i--){int x=0;
   for(int j=0;j<i;j++){
     if(H.at(i)>=H.at(j)){x++;}
   }
    if(x==i){a++;}
  }
  cout<<a+1<<endl;
}

Measured memory_bytes: 256