akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct ii
{
    int tg,type,vt;
};
bool cmp(const ii &aa,const ii &bb)
{
    return (aa.tg<bb.tg || aa.tg==bb.tg && aa.type<bb.type);
}
vector<ii> g;
multiset<int> se;
int a[200005];
int s,t,x,n,q,d;
int main()
{
    cin >> n >> q;
    for (int i = 1; i <= n; ++i)
    {
        cin >> s >> t >> x;

        g.push_back({s-x,1,x});
        g.push_back({t-x,2,x});
    }
    for (int i = 1; i <= q; ++i)
    {
        cin >> d;

        g.push_back({d,3,i});
    }

    sort(g.begin(),g.end(),cmp);

    for(int i=0 ; i<g.size();++i)
        {
            //cout<<i<<'\n';
            if (g[i].type==1)
                se.insert(g[i].vt);
            else if (g[i].type==2)
                    se.erase(se.find(g[i].vt));
            else if(se.empty())
                    a[g[i].vt]=-1;
                else
                    a[g[i].vt]=*se.begin();
        }
    for(int i=1 ; i<=q ; ++i)
            cout<<a[i]<<'\n';
    return 0;
}


Measured memory_bytes: 20456
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    int array[n];
    for(int i=0; i<n; i++){
        cin >> array[i];
    }
    for(int i=sizeof(array)/sizeof(int)-1; 0<=i; i--){
        cout << array[i];
        if(i!=0) cout << ' ';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3076
#include <iostream>
//#include <string>
//#include <vector>
//#include <cstdlib>
//#include <algorithm>
//include <cmath>
//#include <math.h>
using namespace std;
 
int main() {
    int K,S;
    cin >> K >> S;
    
    int ans; 
    int count=0;
    
    for(int X=0; X<=K; X++){
      for(int Y=0; Y<=K; Y++){
        //for(int Z=0; Z<=K; Z++){
             int z = S - X - Y;
              if(0 <= z && z <= K) count++;
        //}    
      }
    }
    
    cout << count << endl;
    
    return 0;
}

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

using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector< vector<int> > g(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	for (int i = 0; i < n; i++) {
		cout << g[i].size() << endl;
	}
	return 0;
}


Measured memory_bytes: 384
S=input()
L=[str(c) for c in S]
if L[0]==L[1]==L[2]==L[3]:
  print("No")
elif L[0] ==L[1]:
  if L[2]==L[3]:
    print("Yes")
  else:
    print("No")
elif L[0]==L[2]:
  if L[1]==L[3]:
    print("Yes")
  else:
    print("No")
elif L[0]==L[3]:
  if L[1]==L[2]:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.next();

            var s = n[n.Length - 1].ToString();
            var hon = new string[] { "2", "4", "5", "7", "9" };
            var pon = new string[] { "0", "1", "6", "8"};
            var bon = new string[] { "3"};
            if (hon.Contains(s))
            {
                Console.WriteLine("hon");
                return;
            }
            if (pon.Contains(s))
            {
                Console.WriteLine("pon");
                return;
            }
            if (bon.Contains(s))
            {
                Console.WriteLine("bon");
                return;
            }
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 26308
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
int a[1000000];
int main()
{
    int n,j,i;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);
    int ct=a[1];
    int cc=1;
    for(i=2;i<=n;i++)
    {
        if(a[i]<=ct)
        {
            ct=a[i];
            cc++;
        }
    }
    printf("%d\n",cc);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int main() {
  int w, h, n, s;
  // 長方形を作るx座標の左端、右端を表す（xp[0]: 右, xp[1]: 左）
  int xp[2];
  // 長方形を作るy座標の上端、下端を表す（yp[0]: 上, yp[1]: 下）
  int yp[2];
  cin >> w >> h >> n;

  xp[0] = w;
  xp[1] = 0;
  yp[0] = h;
  yp[1] = 0;

  for (int i = 0; i < n; i++) {
    int x, y, a;
    cin >> x >> y >> a;

    if (a == 1) {
      if (xp[1] < x) {
        xp[1] = x;
      }

    } else if (a == 2) {
      if (xp[0] > x) {
        xp[0] = x;
      }
    } else if (a == 3) {
      if (yp[1] < y) {
        yp[1] = y;
      }
    } else {
      if (yp[0] > y) {
        yp[0] = y;
      }
    }
  }

  if ((xp[0] - xp[1]) <= 0 || (yp[0] - yp[1] <= 0)) {
    cout << 0 << endl;
  } else {
    s = (xp[0] - xp[1]) * (yp[0] - yp[1]);
    cout << s << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<queue>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()
bool comparator(P a, P b) {
	return a.first / a.second < b.first / b.second;
}

int main() {
	int n;
	cin >> n;
	vector<ll> d(n);
	rep(i, n) {
		cin >> d[i];
	}
	sort(ALL(d));
	ll j = -1;
	ll ans = 0;
	while (upper_bound(ALL(d), j) < d.end()) {
		j = d[upper_bound(ALL(d), j)-d.begin()];
		ans++;

	}
	cout <<ans <<endl;
}


Measured memory_bytes: 3156
import heapq as hq

n,m =  map(int,input().split())
ai = list(map(lambda x : -1 *int(x),input().split()))
hq.heapify(ai) 

for _ in range(m):
    saidai = -hq.heappop(ai)
    saidai = -1*(saidai //2)
    
    hq.heappush(ai,saidai)

print(-1*sum(ai))

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

map_o = map(int, input().split())
Dn = list(map_o)

tairyoku = 0

j = 0
while j < N-1:
	base = Dn[j]

	k = j+1
	while k < N:
		tmp = base*Dn[k]
		tairyoku += tmp
		k += 1
	j += 1

print(tairyoku)


Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>

int main(){
	int n,i,j;
	double x[4],y[4],l[2],mag;

	scanf("%d",&n);

	for(i = 0;i < n;i++){
		for(j = 0;j < 4;j++){
			scanf("%lf %lf",&x[j],&y[j]);
		}
		l[0] = (y[0]-y[1])/(x[0]-x[1]);
		l[1] = (y[2]-y[3])/(x[2]-x[3]);

		printf("%s\n",(l[0] == l[1]) ? "YES" : "NO");
	}

	return 0;
}

Measured memory_bytes: 620
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<sstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int,int>PII;
typedef pair<ll,ll>PLL;
#define make_pair mkp;

const int maxn=1e9+7;

//注意这一题不要看数字挺大的挺吓人的，一定要注意，10^100次方是一个非常非常大的数，所以你在取k个数字和k+1个数字他们的和一定是不一样的，，，
//而且你在取k个不同的数字他们的和也是一定不一样的，所以我们只需要统计当取得k个数字我们可以取得的最小数字，以及取得的最大数字之间的差值加上1（加一因为区间边界的原因）就是我们需要求解的不同和的个数
//这一题其实与10^100没什么特别大的关系，这个数字只是为了告诉你，你加的和不可能回重复的。。。。

ll cal(int x){
	return (x+1LL)*x/2;
}

int main(){

	int n,k;
	cin>>n>>k;
	ll ans=0;
	for(int i=k;i<=n+1;i++){//i表示的是可以取得数的个数，可以取得的不同个数。。。。
		ans=(ans+cal(n)-cal(n-i)-cal(i-1)+1)%maxn;//当去i个数字的时候，可以取得的最小数字，以及可以取得的最大数字。。。
	}//注意最后还是剩一组0-n这个时候我们选择n+1个数就ok啦。。。因为k取数是只要不重复就OK啦。。。
	cout<<ans<<endl;
	return 0;
}

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

const int MAX = 510000;
 const int MOD = 1000000007;
 
 long long fac[MAX], finv[MAX], inv[MAX];
 
 // テーブルを作る前処理
 void COMinit() {
     fac[0] = fac[1] = 1;
     finv[0] = finv[1] = 1;
     inv[1] = 1;
     for (int i = 2; i < MAX; i++){
         fac[i] = fac[i - 1] * i % MOD;
         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
         finv[i] = finv[i - 1] * inv[i] % MOD;
     }
 }
 
 // 二項係数計算
 long long COM(int n, int k){
     if (n < k) return 0;
     if (n < 0 || k < 0) return 0;
     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
 }
 
  long long modpow(long long a, long long n) {
      long long res = 1;
      while (n > 0) {
          if (n & 1) res = res * a % MOD;
          a = a * a % MOD;
          n >>= 1;
      }
      return res;
  }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll d,n;
    std::cin >> d>>n;
    
    ll ans = n*pow(100,d);
    if(n==100){
        ans += pow(100,d);
    }
    std::cout << ans << std::endl;
}



Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

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

		int d = sc.nextInt();
		int[] ls = new int[d];
		for(int i=0;i<d;i++) {
			ls[i]=sc.nextInt();
		}
		int max=0;
		for(int i=0;i<d;i++) {
			max=Math.max(max, ls[i]);
		}
		int sum=0;
		for(int i=0;i<d;i++) {
			if(ls[i]==max) {
				max=-1;
				ls[i]/=2;
			}
			sum+=ls[i];
		}
		System.out.println(sum);
	}

}


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

int main(){
    int N; cin >> N;
    int B[N-1];
    rep(i, N-1) cin >> B[i];

    int ans = 0;
    rep(i, N){
        if(i == 0) ans += B[0];
        else if(i != N - 1){
            ans += min(B[i-1], B[i]);
        }else{
            ans += B[N-2];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int[] A = new int[N + 1];
            for (int i = 1; i <= N; i++) {
                A[i] = sc.nextInt();
            }

            long ans = 1;

            int[] C = new int[N + 1];
            C[0] = 3;

            for (int i = 1; i <= N; i++) {
                ans = ans * C[A[i]] % 1000000007;

                C[A[i]]--;
                C[A[i] + 1]++;
            }

            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 51364
n,m=map(int,input().split())
ans=[]
for i in range(m):
  ans.append([i+1,2*m-i])
if n%2==0:
  ans.reverse()
  flag=0
  for i in range(len(ans)):
    if ans[i][1]-ans[i][0]>=n//2:
      flag=1
    if flag==1:
      ans[i][1]+=1
  ans.reverse()
for i in range(len(ans)):
  print(ans[i][0],ans[i][1])

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

using ll = long long;
using namespace std;

constexpr static ll MOD = 1000000007ll;
constexpr static int INF = 1 << 28; // for x <= 10^9
constexpr static ll INFL = 1ll << 60; // for x <= 10^19
constexpr static double EPS = 1e-10;

int main() {
    int n;
    vector<int> ds;

    cin >> n;
    for (int i = 0; i < n; i++) {
        int d;
        cin >> d;
        ds.push_back(d);
    }

    sort(ds.begin(), ds.end());

    int first = ds[n / 2 - 1];
    int last = ds[n / 2];
    int ans = (first == last) ? 0 : last - first;
    cout << ans << endl;
}


Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <algorithm>
#include <climits>
#include <cmath>
using namespace std;


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

	k--;
	if(s[k]=='A'){
		s[k]='a';
	}else if(s[k]=='B'){
		s[k]='b';
	}else{
		s[k]='c';
	}

		cout << s <<endl;
}


Measured memory_bytes: 256
N = int(input())
tree = [None] * N
root = set(range(N))

def set_pd(i, parent, sibling, depth):
    if i == -1:
        return -1
    node = tree[i]
    l, r = node[0], node[1]
    
    node[2], node[3], node[5] = parent, sibling, depth
    node[4] = (l != -1) + (r != -1)
    height = node[6] = max(set_pd(l, i, r, depth + 1), set_pd(r, i, l, depth + 1)) + 1
    return height

while N:
    i, l, r = list(map(int, input().split()))
    tree[i] = [l,r] + [None] * 5 # parent, sibling, degree, depth, height
    root -= {l, r}
    N -= 1

set_pd(root.pop(), -1, -1, 0)

for i, node in enumerate(tree):
    l, r, p, s, deg, dep, h = node
    print('node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}'.format(
        i, p, s, deg, dep, h, 'root' if not dep else 'internal node' if deg else 'leaf'
    ))

Measured memory_bytes: 7788
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <sstream>
#include <complex>
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++)


const int m[] = {10, 50, 100, 500};

int main(){
    int N, coin[4],i;

    bool x = false;
    while( cin >> N, N ){
        scanf("%d %d %d %d", &coin[0], &coin[1], &coin[2], &coin[3]);

        if( x ) puts("");
        x = true;

        int sum = 0;
        rep(i,4) sum += m[i] * coin[i];

        sum -= N;
        if( sum < 0 ) { puts("error"); exit(1); }

        int tmp[4];
        for(i=3; i>=0; i--){
            tmp[i] = sum / m[i];
            sum -= (sum / m[i]) * m[i];
        }

        // debug
        //printf("%d %d %d %d\n", tmp[0], tmp[1], tmp[2], tmp[3]);

        rep(i,4){
            if( tmp[i] < coin[i] ){
                printf("%d %d\n", m[i], coin[i] - tmp[i]);
            }
        }
    }

    return 0;
}

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

int main()
{
    int n, limit;
    cin >> n >> limit;
    vector<ll> dp(limit+1);

    while (n--) {
        int w, p;
        cin >> w >> p;
        for (int x = limit; x >= w; x--) {
            dp[x] = max(dp[x], dp[x-w] + p);
        }
    }

    ll ans = 0;
    for (int i = 1; i <= limit; i++) ans = max(ans, dp[i]);
    cout << ans << "\n";
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

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

	deque<int> deq;
	deq.push_front(1);
	deque<int> v;
	
	while(n != 1){
		if(n % 2 == 0){
			v.push_front(1);
			n--;
		}
		else {
			v.push_front(0);
			n--;
			n /= 2;
		}
	}
	
	REP(i,v.size()){
		if(v[i]){
			deq.push_front(i+2);
		}
		else {
			deq.push_back(i+2);
		}
	}
	
	cout << 2*(v.size()+1) << endl;
	REP(i,v.size()+1)cout << i+1 << ' ';
	REP(i,v.size()+1){
		cout << deq[i];
		if(i != v.size()+1 - 1)cout << ' ';
	}
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 256
n,y=map(int,input().split())

moji="-1 -1 -1"
for i in range(n+1):
    y1=y-10000*i
    for j in range(n-i+1):
        y2=y1-5000*j-1000*(n-i-j)
        if y2==0:
            moji=str(i)+ " " + str(j) + " " + str(n-i-j)
            break
        else:
            continue
print(moji)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> x(n);
  for(int i=0;i<n;i++){
    cin>>x[i];
  }
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
        ans+=x[i]*x[j];
    }
  }
  cout<<ans<<endl;
}

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

A = [int(i) for i in input().split()]

cnt = 0
for i in range(N):
  if A[i]%2 == 0:
    if A[i]%3 == 0 or A[i]%5 == 0:
      cnt += 1
  else:
    cnt += 1

print('APPROVED' if cnt == N else 'DENIED') 

Measured memory_bytes: 3060
import java.util.*;

public class Main{

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int R = sc.nextInt();
        if(N >= 10){
          System.out.println(R);
        }else{
          System.out.println(R+(100*(10-N)));
        }
      
	}

}





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

int main(){

  int a,b,c=0;
  cin>>a>>b>>c;
	

  int amari=a%b;
  
  int n=1;
  while(1){

	int k=((a%b)*n)%b;
    
    if(k==c){cout<<"YES"<<endl; return 0;}

    if(k==amari &&n!=1){cout<<"NO"<<endl; return 0;}
    n++;
    if(n>b+1){cout<<"NO"<<endl;break;}
  }
  
  
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll mod = 1e9+7;
ll inf = 1e9;
//LLONG_MIN

//WA

int main(void){
	int dp[100010],N;
	cin>>N;
	reg(i,1,N)dp[i]=inf;
	dp[0]=0;
	int a=1;
	rep(i,N){
		reg(j,0,N){
			if(j+a>N)break;
			dp[j+a]=min(dp[j+a],dp[j]+1);
		}
		a*=6;
		if(a>N)break;
	}
	a=1;
	rep(i,N){
		reg(j,0,N){
			if(j+a>N)break;
			dp[j+a]=min(dp[j+a],dp[j]+1);
		}
		a*=9;
		if(a>N)break;
	}
	cout<<dp[N]<<endl;
	return 0;
}

Measured memory_bytes: 640
import java.math.BigInteger;
import java.util.Scanner;

class Main {

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

			int num = 0;
			while (sc.hasNextInt() && (num = sc.nextInt()) != 0) {
				BigInteger factorial = calc(num);

				char[] c = String.valueOf(factorial).toCharArray();
				int count = 0;
				for (int i = c.length - 1; i > 0; i--) {
					if ('0' != c[i]) {
						break;
					}
					count++;
				}

				System.out.println(count);
			}
		} finally {
			sc.close();
		}
	}

	public static BigInteger calc(int num) {
		BigInteger result = new BigInteger("1");
		BigInteger bigNum = new BigInteger(String.valueOf(num));
		for (int i = 0; i < num; i++) {
			result = result
					.multiply(bigNum.subtract(new BigInteger(String.valueOf(i))));
		}
		return result;
	}
}

Measured memory_bytes: 167528
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <functional>
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
int main() {
	ll n;
	cin >> n;
    if(n%2==0)
      cout << n << endl;
    else
      cout << n*2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
vector<int> e[100005];
int p,q,vis[100005];
void dfs(int u)
{
 vis[u]=1;
 for(int i=0,len=e[u].size(),v;i<len;i++)
  if(vis[v=e[u][i]]==-1)
  {
   if(p)q=v;
   else p=v;
  }
  else if(!vis[v])dfs(v);
}
int main()
{
 ios::sync_with_stdio(false);
 int n,m;
 cin>>n>>m;
 for(int i=1;i<=m;i++)
 {
  int u,v;
  cin>>u>>v;
  e[u].push_back(v);
  e[v].push_back(u);
 }
 int maxd=0,cnt=0;
 for(int i=1;i<=n;i++)
 {
  int t=e[i].size();
  if(t%2)
  {
   cout<<"No"<<endl;
   return 0;
  }
  if(t>maxd)
   maxd=t,cnt=1;
  else if(t==maxd)cnt++;
 }
 if(maxd>=6)
  cout<<"Yes"<<endl;
 else if(maxd==4)
 {
  if(cnt>=3)
   cout<<"Yes"<<endl;
  else if(cnt==1)
   cout<<"No"<<endl;
  else
  {
   for(int i=1;i<=n;i++)
    if(e[i].size()==4)vis[i]=-1;
   for(int i=1;i<=n;i++)
    if(!vis[i])
    {
     p=q=0;
     dfs(i);
     if(p==q)
     {
      cout<<"Yes"<<endl;
      return 0;
     }
    }
   cout<<"No"<<endl;
  }
 }
 else cout<<"No"<<endl;
 return 0;
}

Measured memory_bytes: 10528
h, n = map(int, input().split())
dp = [float('inf')]*(2*(10**4)+1)
dp[0] = 0
l = [list(map(int, input().split())) for _ in range(n)]

for i in range(n):
  for j in range(h):
    dp[j+l[i][0]] = min(dp[j+l[i][0]], dp[j]+l[i][1])
    
print(min(dp[h:]))

Measured memory_bytes: 50652
a = int(input())
b = int(input())

if a == 1 and b ==2:
  print(3)
if a == 2 and b ==1:
  print(3)
if a == 1 and b ==3:
  print(2)
if a == 3 and b ==1:
  print(2)
if a == 2 and b ==3:
  print(1)
if a == 3 and b ==2:
  print(1)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
//#include<string>

using namespace std;

int tree_depth(vector<int>& parent, int node) {
	int depth = 0;
	while (parent.at(node) != -1) {
		node = parent.at(node);
		depth++;
	}
	return depth;
}

int tree_height( vector<vector<int>>& children, int node) {
	int height1=0;
	int cnum = children.at(node).size();
	if (cnum == 0) return height1;
	else if (cnum == 2) {
		int height2;
		height1 = tree_height(children, children.at(node).at(0));
		height2 = tree_height(children, children.at(node).at(1));
		return (height1 > height2) ? height1+1 : height2+1;
	}
	else if (cnum == 1) {
		height1 = tree_height(children, children.at(node).at(0));
		return height1 + 1;
	}
	

}

int node_degree(vector<vector<int>>& children, int node) {
	return children.at(node).size();
}

int node_sibling(vector<int>& parent, vector<vector<int>>& children, int node) {

	int prnt = parent.at(node);
	if (prnt == -1) return -1;
	for (int child : children.at(prnt)) if (child != node) return child;
	return -1;
}

void disp_tree(vector<int> & parent, vector<vector<int>> & children) {
	for (int i = 0; i < parent.size(); i++) {
		cout << "node " << i << ": parent = " << parent.at(i) << ", sibling = " << node_sibling(parent, children, i);
		cout << ", degree = " << node_degree(children, i) << ", depth = " << tree_depth(parent, i) << ", height = " << tree_height( children, i);
		if (parent.at(i) == -1) {
			if (children.at(i).size() == 0) {
				cout << ", root" << endl;
				return;
			}
			cout << ", root" << endl;
		}
		else if (children.at(i).size() > 0) {
			cout << ", internal node" << endl;
		}
		else {
			cout << ", leaf" << endl;
		}
	}
}

int main(void) {

	int size, node, left, right;
	cin >> size;
	vector<int> parent(size, -1);

	vector<vector<int>> children(size);
	for (int i = 0; i < size; i++) {
		cin >> node >> left >> right;
		if (left > -1) {
			children.at(node).push_back(left);
			parent.at(left) = node;
		}
		if (right > -1) {
			children.at(node).push_back(right);
			parent.at(right) = node;
		}
	}

	disp_tree(parent, children);
	return 0;
}



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

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

    int n;
    cin >> n;

    int h[n];
    int max_h = 0;
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
        max_h = max(max_h, h[i]);
    }

    int total = 0;
    for (int i = 1; i <= max_h; ++i) {
        bool cont = false;
        for (int j = 0; j < n; ++j) {
            if (h[j] >= i) {
                total += !cont;
                cont = true;
            } else {
                cont = false;
            }
        }
    }

    cout << total << '\n';

    return 0;
}


Measured memory_bytes: 256
from collections import deque
s = deque(input())
num = int(input())
cnt = 0
for _ in range(num):
    t = input().split()
    if t[0] == "1":
        cnt += 1
    else:
        if (int(t[1])+cnt) % 2 == 1:
            s.appendleft(t[2])
        else:
            s.append(t[2])
if cnt % 2 == 1:
    s.reverse()
print("".join(s))


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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;

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

    // i番目以降の個数
    vector<int> r(n, 0), g(n, 0), b(n, 0);
    for (int i = n - 1; i >= 0; i--)
    {
        if (s[i] == 'R')
            r[i]++;
        if (s[i] == 'G')
            g[i]++;
        if (s[i] == 'B')
            b[i]++;

        if (i != 0)
        {
            r[i - 1] = r[i];
            g[i - 1] = g[i];
            b[i - 1] = b[i];
        }
    }

    i64 sum = 0;
    for (int i = 0; i < n - 2; i++)
    {
        char c1 = s[i];
        for (int j = i + 1; j < n - 1; j++)
        {
            if (s[j] == c1)
                continue;
            char c2 = s[j];
            int dist = j - i;
            if ((c1 != 'R') && (c2 != 'R'))
            {
                sum += r[j + 1];
                if ((j + dist < n) && (s[j + dist] == 'R'))
                    sum--;
            }
            if ((c1 != 'G') && (c2 != 'G'))
            {
                sum += g[j + 1];
                if ((j + dist < n) && (s[j + dist] == 'G'))
                    sum--;
            }
            if ((c1 != 'B') && (c2 != 'B'))
            {
                sum += b[j + 1];
                if ((j + dist < n) && (s[j + dist] == 'B'))
                    sum--;
            }
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;

ll n,m,x;
vector<ll> c,u;
vector<vector<ll>> a;

void dfs(ll *mn,ll nowd,ll cost,vector<ll> u){
    if(nowd==n){
        rep(i,m){
            if(u[i]<x) break;
            if(i==m-1) *mn=min(*mn,cost);
        }
    }else{
        dfs(mn,nowd+1,cost,u);
        rep(i,m) u[i]+=a[nowd][i];
        dfs(mn,nowd+1,cost+c[nowd],u);
    }
}

int main(){
    cin>>n>>m>>x;
    ll mn=1e9;
    c=vector<ll>(n);
    u=vector<ll>(m,0);
    a=vector<vector<ll>>(n,vector<ll>(m));
    rep(i,n){
        rep(j,m+1){
            if(j==0) cin>>c[i];
            else cin>>a[i][j-1]; 
        }
    }
    dfs(&mn,0,0,u);
    cout<<(mn==1e9?-1:mn)<<endl;
    return 0;
}

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

int main() {
  int a,b,c;
  cin >>a >>b >>c;
  if(a==b&&b==c){
    cout <<1 <<endl;
    return 0;
  }
  else if(a==b||a==c||b==c){
    cout <<2 <<endl;
    return 0;
  }
  else{
    cout <<3 <<endl;
  }
}

Measured memory_bytes: 256
#include <set>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <vector>
#include <tuple>
#include <string>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <limits>
#include <climits>
#include <numeric>
#include <functional>

#define lnd '\n'
// #define reverse(i, n) for(ll i = n-1; i >= 0; --i)
#define from(i, n) for (ll i = 0; i < n; ++i)
#define loop(i, n) for(ll i = 0; i < n; i++)
#define REPN(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(s) (s).begin(), (s).end()
#define rALL(s) (s).rbegin(), (s).rend()
#define sz(s) (int)(s).size()
#define mk make_pair
#define pb push_back
#define sqr(s) ((s) * (s))

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;

template <class T>
T GCD (T a, T b) {
  if(a == 0) return b;
  return GCD(b%a, a);
}

template <class T>
T LCM(T a, T b){
  return a*b/GCM(a,b);
}

template <class T>
T modpow(T x, T p){
    T res = 1;
    while(p > 0){
        if(p&1) res *= x;
        x *= x;
        p /= 2;
    }
    return res;
}

template <class T>
T modpow(T x, T p, ll mod){
    T res = 1;
    while(p > 0){
        if(p&1) res = (res*x)%mod;
        x = (x*x)%mod;
        p /= 2;
    }
    return res%mod;
}

template <class T>
void print(T a[], ll n){
    for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
    cout << endl;
}

template<class T>
void printc(T c){
    for(auto const& v: c) std::cout << v << ' ';
    cout << endl;
}

struct HASH{
  size_t operator()(const pair<long,long>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

bool pair_sort(const pair<int, int> &p1, const pair<int,int> &p2){
    if(p1.first != p2.first) return p1.first < p2.first;
    else return p1.second < p2.second;
}

const int INF = std::numeric_limits<int>::max();
const ll M_INF = std::numeric_limits<ll>::min();
const ll LL_INF = std::numeric_limits<ll>::max();

void solution();
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solution();
    return 0;
}

void solution(){
  ld n;
  cin >> n;
  ld d = n/3;
  cout.precision(12);
  cout << d*d*d << endl;
}     


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


N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
res = [0] * M
for i in range(N):
    for j in A[i][1:]:
        res[j - 1] += 1
print(res.count(N))

Measured memory_bytes: 3060
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = input()
for i in range(len(n)):
    count += int(n[i])
if count%9 == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9668
def main():
    import sys

    input = sys.stdin.readline

    inf = 10 ** 8 + 10

    h, n = map(int, input().split())
    *ab, = (list(map(int, input().split())) for _ in range(n))

    dp = [[inf] * (h + 1) for _ in range(n + 1)]
    dp[0][0] = 0
    # dp[使った魔法][与えたダメージ]=最小魔法消費

    for i, (a, b) in enumerate(ab):
        for hp in range(h + 1):
            if hp < a:
                dp[i + 1][hp] = min(dp[i][hp], dp[i + 1][0] + b)
            else:
                dp[i + 1][hp] = min(dp[i][hp], dp[i + 1][hp - a] + b)

    print(dp[n][h])


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 119152
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<complex>
#include<algorithm>
#include<vector>
#include<math.h>
#include<set>
#include<map>
#include<queue>

int main()
{
	int d, g, p[10], c[10], min{}, sum{}, sum_table[10]{};
	scanf("%d%d", &d, &g);
	g /= 100;
	for (int i = 0; i < d; i++)
	{
		scanf("%d%d", p + i, c + i);
		c[i] /= 100;
	}
	for (int i = 0; i < d; i++)
	{
		sum_table[i] = p[i] * (i + 1) + c[i];
	}
	for (int i = d - 1; i >= 0; i--)
	{
		sum += sum_table[i];
		min += p[i];
		if (sum >= g) break;
	}
	for (int i = 0; i < (1 << d); i++)
	{
		int count{};
		sum = 0;
		bool all_added[10]{};
		for (int j = 0; j < d; j++)
		{
			all_added[j] = i & (1 << j);
			if (all_added[j])
			{
				sum += sum_table[j];
				count += p[j];
			}
		}
		if (count >= min) continue;
		if (sum < g)
		{
			for (int j = d - 1; j >= 0; j--)
			{
				if (all_added[j]) continue;
				if (sum + (p[j] - 1) * (j + 1) < g)
				{
					count = min + 1;
				}
				else
				{
					count += (g - sum + j) / (j + 1);
				}
				break;
			}
		}
		if (count > min) continue;
		min = count;
	}
	printf("%d\n", min);

	return 0;
}

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

using namespace std;

typedef long long ll;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}


int g[2][105];
int dp[2][105];
int n;
int ans = 0;

int go(int x, int y) {
  if(x == 1 and y == n - 1) {
    return g[x][y];
  }
  if(dp[x][y] != -1) return dp[x][y];
  int cur = 0;
  if(x + 1 < 2) {
    cur = g[x][y] + go(x + 1, y);
  }
  if(y + 1 < n) {
    cur = max(cur, g[x][y] + go(x, y + 1));
  }
  return dp[x][y] = cur;
}

int main() {
  int n; cin >> n;
  map <char, ll> cnt;
  vector <string> s;
  for(int i = 0; i < n; i++) {
    string x; cin >> x;
    s.push_back(x);
    cnt[x[0]]++;
  }
  ll ways = 0;
  for(auto x : s) {
    bool pk = 0;
    vector <char> can;
    for(char p : {'M', 'A', 'R', 'C', 'H'}) {
      if(p == x[0]) {
        pk = 1;
        continue;
      }
      can.push_back(p);
    }
    if(!pk) continue;
    ll cur = 0;
    for(int j = 0; j < can.size(); j++) {
      for(int k = j + 1; k < can.size(); k++) {
        cur += cnt[can[j]] * cnt[can[k]];
      }
    }
    ways += cur;
  }
  print(ways / 3ll);
}

Measured memory_bytes: 6132
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <tuple>
#include <math.h>
#include <deque>
#include <stack>
#include <queue>

#define PI 3.14159265358979323846

using namespace std;

typedef long long ll;
typedef long double ld;


int solve() {
    string s;
    cin >> s;
    ll last = s.length() - 1;
    ll ans = 0;
    for(ll i = 0;i < s.length(); i++){
        if(last == i) break;
        ans = s[i] == s[last] ? ans : ans + 1;
        last--;
        if(last == i) break;
    }
    cout << ans << endl;
    return 0;
}


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


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int[] values = new int[num];
		for(int i = 0; i < num; i++)values[i] = sc.nextInt();
		Arrays.sort(values);
		double ans = (double)values[0];
		for(int value : values){
			ans = (value + ans) / 2;
		}

		System.out.println(ans);
	}
}




Measured memory_bytes: 21844
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int n;
    cin >> n;
    int m;
    cin >> m;
    ll sum = 0;
    unordered_map<int, int> mp;
    mp[0] = 1;
    rep(i, n) {
        int a;
        cin >> a;
        sum += a;
        sum %= m;
        mp[sum]++;
    }

    ll ans = 0;
    for(P x:mp) {
        ans += (ll)x.second * (x.second-1) / 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3596
import sys
sys.setrecursionlimit(10**6)

N=int(input())
Graph = [ [] for ii in range(N) ]

for ii in range(N-1):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    Graph[a].append([b, ii])

ans = [None]*(N-1)
def rec(cur, color):
    cnt = 1
    for (to, jj) in Graph[cur]:
        if cnt==color:
            cnt+=1
        ans[jj] = cnt
        rec(to, cnt)
        cnt += 1

rec(0, 0)
print(max(ans))
print(*ans, sep='\n')


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

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

  if(N<6){
    cout<<N<<endl;
    return 0;
  } 
  int ans=0;
  
  queue<int> q;
  int base[]={6,9};
  vector<int> a;
  int times[100010]={0};
  
  a.push_back(1);
  times[1]=1;
  for(int i=0;i<2;i++){
    int j=1;
    while(pow(base[i],j)<=N){
      
      a.push_back(pow(base[i],j));
      j++;
    }
  }
  q.push(0);
  //幅優先
  while(!q.empty()){
    int tmp=q.front();
    //cout<<"tmp:"<<tmp<<endl;
    q.pop();
    for(int i=0;i<a.size();i++){
      int tmp2=tmp+a[i];
      
      if(tmp2<=N) {
        if(times[tmp2]>0) continue;
        q.push(tmp2);
        //cout<<"tmp2:"<<tmp2<<endl;
        times[tmp2]=times[tmp]+1;
        if(tmp2==N){
          cout<<times[N]<<endl;
          return 0;
        }
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) v.erase(unique(ALL(v)), v.end())
#define bit(i) (1LL<<i)
#define sz(v) ((LLI)(v).size())

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int N;
  while(cin >> N){
    vector<LLI> s(N); cin >> s;

    LLI ans = 0;

    FORE(d,1,N-1){
      LLI sum = 0;
      FORE(k,0,N-1){
	if(((N-1)%d==0 and d*k>=N-1-d*k) or d*k>N-1 or N-1-d*k<0) break;
	LLI b = N-1-(k+1)*d;
	if(b<=0) continue;
	
	sum += s[d*k] + s[N-1-d*k];
	chmax(ans, sum);
      }
    }

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


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

int main(void){
char x[3];
char y[3];
cin >> x ;
cin >> y ;

if (x[0]==y[2] & x[1]==y[1] & x[2]==y[0]){
cout << "YES" << endl;
}else{
cout << "NO" << endl;
}

};

Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#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 printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll Q;
    cin >> Q;
    ll res = 0;
    priority_queue<ll, vector<ll>, less<ll> > pq_less;
    priority_queue<ll, vector<ll>, greater<ll> > pq_greater;
    ll sum_less = 0, sum_greater = 0;
    ll val = 0;
    while(Q--){
        ll q;
        cin >> q;
        if(q == 1){
            ll a,b;
            cin >> a >> b;
            res += b;
            if(pq_less.size() == 0){
                pq_less.push(a);
            }else{
                if(pq_greater.size() == 0){
                    val += abs(pq_less.top() - a);
                    if(pq_less.top() <= a){
                        pq_greater.push(a);
                    }else{
                        pq_greater.push(pq_less.top());
                        pq_less.pop();
                        pq_less.push(a);
                    }
                }else{
                    ll v1 = pq_less.top();
                    ll v2 = pq_greater.top();
                    ll sz = pq_less.size() + pq_greater.size();
                    if(sz % 2 == 0){
                        if(a < v1 || v2 < a) val += min(abs(v1 - a), abs(a - v2));
                        if(a <= v2){
                            pq_less.push(a);
                        }else{
                            pq_less.push(v2);
                            pq_greater.pop();
                            pq_greater.push(a);
                        }
                    }else{
                        val += abs(v1 - a);
                        if(a <= v1){
                            pq_greater.push(v1);
                            pq_less.pop();
                            pq_less.push(a);
                        }else{
                            pq_greater.push(a);
                        }
                    }


                }
            }

        }else{
            print(pq_less.top(), val+res);
        }
    }

}

Measured memory_bytes: 3828
while(<>){
	chomp;
	@h = split(/ /, $_) if($. == 2);
}

($cnt, $max, $pre) = (0, 0, 0);
foreach $one (@h){
	if($pre >= $one){
		$cnt++;
		$max = $cnt if($max < $cnt);
	}else{
		$cnt = 0;
	}
	$pre = $one;
}

print "$max\n";


Measured memory_bytes: 17228
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    Int n, k;
    cin >> n >> k;

    vector<bool> su(n, true);
    for (Int i = 0; i < k; i++) {
        Int d;
        cin >> d;
        for (Int j = 0; j < d; j++) {
            int in;
            cin >> in;
            in--;
            su[in] = false;
        }
    }

    Int ans = 0;
    for (Int i = 0; i < n; i++) {
        if (su[i]) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
def extgcd(a, b):
    r = [1, 0, a]
    w = [0, 1, b]
    while w[2] != 1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0], r[1]-q*w[1], r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0], w[1]]


def mod_inv(a, m):
    x = extgcd(a, m)[0]
    return (m+x % m) % m


def mod_e(n, p):
    res = 0
    while n >= p:
        res += n//p
        n = n//p
    return res


def mod_fact(n, p):
    if n == 0:
        return 1

    res = mod_fact(n//p, p)

    if n//p % 2 != 0:
        return res*(p-fact[n % p]) % p
    return res*fact[n % p] % p


# nCk mod p
def mod_comb(n, k, p):
    if n < 0 or k < 0 or n < k:
        return 0
    e1 = mod_e(n, p)
    e2 = mod_e(k, p)
    e3 = mod_e(n-k, p)
    #pで割り切れる場合
    if e1 > e2 + e3:
        return 0

    #pで割り切れない場合
    a1 = mod_fact(n, p)
    a2 = mod_fact(k, p)
    a3 = mod_fact(n-k, p)
    return a1 * mod_inv(a2*a3 % p, p) % p

X, Y = map(int, input().split())
x = (2 * Y - X) / 3
y = (2 * X - Y) / 3

# print(x, y)

if (2 * Y - X) % 3 != 0 or (2 * X - Y) % 3 != 0:
    print(0)
    exit()
else:
    x = int(x)
    y = int(y)

if x < 0 or y < 0:
    print(0)
    exit()
# print(x,y)
if x < y:
    x, y = y, x

#pは素数とする
p = 10**9+7

#fact[i] : i! modp (0<= i <p) O(p)
#上だとO(p)なのでnまでにして O(n)にする
fact = [1]
k = 1
for i in range(1, 10**6+100):
    k = k*i % p
    fact.append(k)

#10000C4000 mod 10**9+7
print(mod_comb(x + y, y, p))


Measured memory_bytes: 79476
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  int N; cin >> N;
  ll K; cin >> K;

  vector<ll> G(K+1, 0L);
  for (int i = K; i > 0; --i) {
    ll x = i;
    auto num = K / x;
    ll cnt = modpow<ll>(num, N, MOD);
    x += i;
    while (x <= K) {
      cnt -= G[x];
      while (cnt < 0) { cnt += MOD; }
      cnt %= MOD;
      x += i;
    }
    G[i] = cnt;
  }
  ll ans{};
  for (int i = 1; i <= K; ++i) {
    ans += (i * G[i]) % MOD;
    ans %= MOD;
  }
  cout << ans << CRLF;
  return;
}

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

  gErr = 0;

  solve();

  return gErr;
}


Measured memory_bytes: 3968