akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
namespace io{
    #define ll long long
    #define inf 0x3f3f3f3f
    #define il inline 
    #define in1(a) read(a)
    #define in2(a,b) in1(a),in1(b)
    #define in3(a,b,c) in2(a,b),in1(c)
    #define in4(a,b,c,d) in2(a,b),in2(c,d)
    il void readl(ll &x){
        x=0;ll f=1;char c=getchar();
        while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
        x*=f;
    }
    il void read(int &x){
        x=0;int f=1;char c=getchar();
        while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
        x*=f;
    }
}
using namespace io;
#define N 100005
int en,front[N],in[N],fa[N];
struct edge{
	int v,next;
}e[N];
il void addedge(int u,int v){
	en++;
	e[en].v=v;
	e[en].next=front[u];
	front[u]=en;
}
queue <int> q;
int main(){
	int i,n,m,u,v,cnt=0;
	in2(n,m);
	for(i=1;i<=n+m-1;i++){
		in2(u,v);
		addedge(u,v);
		in[v]++;
	}
	for(i=1;i<=n;i++) if(!in[i]) q.push(i);
	while(!q.empty()){
		int u=q.front();
		q.pop();
		for(i=front[u];i;i=e[i].next){
			int v=e[i].v;
			in[v]--;
			if(!in[v]) fa[v]=u,q.push(v);
		}
	}
	for(i=1;i<=n;i++) printf("%d ",fa[i]);
	return 0;
}

Measured memory_bytes: 2816
// my の定義式を修正
// df=0
// int を li に
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define dist(a,b) max((a)-(b),(b)-(a));
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
typedef long int li;

int main(){
  int n,_; cin >>n >>_;
  vector<li> a;

  rep(_,n+1){
    int p; cin >>p;
    a.push_back(p);
  }
  if(df){
    for(const auto &x: a) cout << x << " ";
    cout << "\n";
  } 

  li mx,my,x;
  mx=my=x=dist(a[n],a[n-1]);
  for(int i=n-1; i>=0; i--){
    li d=dist(a[n],a[i]);
    x=max(my,d);
    mx=min(mx,x);
    my=max(my,min(mx,d));
    if(df)printf("x:%ld mx:%ld my:%ld \n",x,mx,my);
  }
  printf("%ld\n",x);
}

Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
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;}

int N,A;
inline void solve(){
  IN2(N,A);
  OUT(N*N-A);
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int F = 0;
  string color,result;
  for(int i = 0; i < N; i++){
   cin >> color;
   if (color == "Y"){
     F = 1;
   }
  }
  if(F == 0){
    result = "Three";
  }else{
    result = "Four";
  }
  cout << result << endl;
}

Measured memory_bytes: 256
def modinv(a,m):
    return pow(a,m-2,m)

n,k = map(int,input().split())
P = 10**9+7

ans = 1
nCl = 1
n1Cl = 1
for l in range(1,min(k+1,n)):
    nCl = nCl*(n+1-l)*modinv(l,P)%P
    n1Cl = n1Cl*(n-l)*modinv(l,P)%P
    ans = (ans+nCl*n1Cl)%P

print(ans)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = 0;
		int[] aArray = new int[9];
		for (int i = 0; i < 9; i++) {
			aArray[i] = sc.nextInt();
		}
		int n = sc.nextInt();
		int[] bArray = new int[n];
		for (int j = 0; j < n; j++) {
			bArray[j] = sc.nextInt();
		}
		
		for (int a = 0; a < aArray.length; a++) {
			for (int b = 0; b < bArray.length; b++) {
				if (aArray[a] == bArray[b]) {
					aArray[a] = 0;
				}
			}
		}
		
		for (int k = 0; k < 3; k++) {
			if (aArray[k] == aArray[k + 3] && aArray[k] == aArray[k + 6]) {
				count++;
			} 
		}
		
		for (int m = 0; m < 9; m += 3) {
			if (aArray[m] == aArray[m + 1] && aArray[m] == aArray[m + 2]) {
				count++;
			}
		}
		
		if (aArray[0] == aArray[4] && aArray[0] == aArray[8]) {
			count++;
		} else if(aArray[2] == aArray[4] && aArray[2] == aArray[6]) {
			count++;
		}
		
		System.out.println(count >= 1 ? "Yes" : "No");
	}
}	

Measured memory_bytes: 22868
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline LL read(){
    LL x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-10;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 1e5+10;
const int MAXM = (int) 1e5+10;
const int sigma_size = (int) 26;

///--------------------START-------------------------
int n;
int a[MAXN],b[MAXN],c[MAXN];
int C[MAXN*3];
LL M;

void update(int x){
    while(x<MAXN*3){
        C[x]++;
        x+=lowbit(x);
    }
}

int query(int x){
    int ret=0;
    while(x){
        ret+=C[x];
        x-=lowbit(x);
    }
    return ret;
}

bool is_judge(int x){
    for(int i=1;i<=n;i++) b[i]=a[i]>=x ? 1 : -1;
    b[0]=n+10;
    for(int i=1;i<=n;i++) b[i]+=b[i-1];
    LL cnt=0;
    memset(C,0,sizeof(C));
    update(n+1);
    for(int i=1;i<=n;i++){
        cnt+=(LL)query(b[i]);
        update(b[i]);
    }
    return cnt>=(M+1)/2;
}

void work(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=n;i++) c[i]=a[i];
    sort(c+1,c+1+n);
    M=(LL)n*(LL)(n+1)/2;
    int ans=a[1];
    int L=1,R=n;
    while(L<=R){
        int mid=(L+R)/2;
        if(is_judge(c[mid])){
            ans=c[mid];
            L=mid+1;
        }
        else R=mid-1;
    }
    printf("%d\n",ans);
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}






Measured memory_bytes: 2560
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include<algorithm>
#include<iomanip>
#include<math.h>
#include <stdlib.h>
#include <string.h>
using namespace std;


int koyaku(int a, int b, int c) {
	int k,x,y,tmp1 = 0;
	if (a == 1 || b == 1 || c == 1) {
		k = 1;
		return k;
	}
	//１つ目の公約数
	if (a == b) {
		x = a;
	}
	if (a != b) {
		while (1) {

			if (a > b) {
				tmp1 = a % b;
				if (tmp1 == 0) {
					x =  b;
					break;
				}
				else {
					a = a % b;
				}
			}
			if (a < b) {
				tmp1 = b % a;
				if (tmp1 == 0) {
					x =  a;
					break;
				}
				else {
					b = b % a;
				}
			}
		}
	}

		//２つ目の公約数

		if (x == c) {
			k = x;
		}
		if (x != c) {
			while (1) {

				if (x > c) {
					tmp1 = x % c;
					if (tmp1 == 0) {
						k =  c;
						break;
					}
					else {
						x = x % c;
					}
				}
				if (x < c) {
					tmp1 = c % x;
					if (tmp1 == 0) {
						k =  x;
						break;
					}
					else {
						c = c % x;
					}
				}
			}
		}
	return k;
}

int main()
{
	int a, b, c;
	int K, l = 0;

	cin >> K;


	for (a = 1; a <= K; a++) {

		for (b = 1; b <= K; b++) {

			for (c = 1; c <= K; c++) {

				l = l + koyaku(a, b, c);
			}
		}


	}

	cout << l;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

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

    int N, M;
    while (cin >> N >> M, N) {
        VV pc(N, V(1501, 0));
        int r;
        cin >> r;
        rep(_, r) {
            int t, n, m, s;
            cin >> t >> n >> m >> s;
            n--;
            if (s == 1) {
                pc[n][t] += m;
            } else {
                pc[n][t] -= m;
            }
        }
        rep(i, N) {
            rep(j, 1500) {
                pc[i][j + 1] += pc[i][j];
            }
        }

        int q;
        cin >> q;
        rep(_, q) {
            int ts, te, m;
            cin >> ts >> te >> m;
            int ans = 0;
            rep2(t, ts, te) {
                rep(n, N) {
                    if (pc[n][t] == m) {
                        ans++;
                        break;
                    }
                }
            }
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 14384
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    ll n,m; cin>>n>>m;
    priority_queue<int, vector<int>, greater<int>> q;
    rep(i,n){
        ll a; cin>>a;
        q.push(a);
    }
    vector<vector<ll>>cng(m,vector<ll>(2));
    rep(i,m){
        ll b,c; cin>>b>>c;
        cng[i][0]=c;
        cng[i][1]=b;
    }
    sort(cng.begin(),cng.end());
    reverse(cng.begin(),cng.end());
    rep(i,m){
        ll cnt=0;
        while(q.top()<cng[i][0]){
            q.pop();
            q.push(cng[i][0]);
            cnt++;
            if(cnt==cng[i][1])break;
        }
    }
    ll ans=0;
    rep(i,n){
        ans+=q.top();
        q.pop();
    }
    cout<<ans<<endl;

}





Measured memory_bytes: 6136
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    
    ArrayList<String> sa = new ArrayList<>();
    for(String s: scanner.next().split("")) {
      sa.add(s);
    }
    ArrayList<String> sb = new ArrayList<>();
    for(String s: scanner.next().split("")) {
      sb.add(s);
    }
    ArrayList<String> sc = new ArrayList<>();
    for(String s: scanner.next().split("")) {
      sc.add(s);
    }
    
    // 手番プレイヤーをAに決める
    // 繰り返し
    //  手番プレイヤーの配列0番目を見て、"a"なら次の人はAのように次の人を決める
    //  手番プレイヤーの配列0番目を捨てる
    //  手番プレイヤーの配列が長さ0なら手番プレイヤーの勝利で終わり
    String player = "a";
    while(true) {
      if(player.equals("a")) {
        if(sa.size() == 0) {
          System.out.println("A");
          break;
        }
        player = sa.get(0);
        sa.remove(0);
      } else if(player.equals("b")) {
        if(sb.size() == 0) {
          System.out.println("B");
          break;
        }
        player = sb.get(0);
        sb.remove(0);
      } else {
        if(sc.size() == 0) {
          System.out.println("C");
          break;
        }
        player = sc.get(0);
        sc.remove(0);
      }
    }
  }
}

Measured memory_bytes: 35612
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n,c;
	int ans=INF;
	int cnt=0;
	cin >>n>>c;
	VVi d(c,Vi(c));
	rep(i,c)rep(j,c){
		cin>>d[i][j];
	}
	VVi g(n,Vi(n));
	vector<int>sum(3,0);
	vector<map<int,int>>dis(3);
	//clog<<"?"<<endl;
	rep(i,n)rep(j,n){
		cin>>g[i][j];
		g[i][j]--;
		dis[(i+j)%3][g[i][j]]+=0;
		sum[(i+j)%3]++;
		dis[(i + j) % 3][g[i][j]]++;
	}
	//clog<<"!";
	rep(A,c){
		rep(B,c){
			rep(C,c){
				cnt=0;
				if(A==B or B==C or C==A){
					continue;
				}
				repi(itr,dis[0]){
					cnt+=(itr->S)*d[itr->F][A];
				}
				repi(itr, dis[1])
				{
					cnt += (itr->S) * d[itr->F][B];
				}
				repi(itr, dis[2])
				{
					cnt += (itr->S) * d[itr->F][C];
				}
				chmin(ans,cnt);
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4624
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    private static Scanner sc = new Scanner(System.in);

    private static long modulus = (long) (1e9 + 7);

    private static ArrayList<Integer> arrayList;

    public static void main(String[] args) {
        int N = readInt();

        arrayList = new ArrayList<>(N);

        for(int i=0; i<N; i++){
            arrayList.add(readInt()-(i+1));
        }

        Collections.sort((arrayList));

        int target_index = (N-1)/2;
        int target_num = arrayList.get(target_index);

        long ans = 0;
        for(int num: arrayList){
            ans += Math.abs(num - target_num);
        }
        System.out.println(ans);

    }



    private static int readInt(){
        return Integer.parseInt(sc.next());
    }

    private static long readLong(){
        return Long.parseLong(sc.next());
    }

}

Measured memory_bytes: 66984
K = int(input())
i = 1
Num = 7


if K%2 == 0 or K%5 == 0:
    print (-1)
else:
    while True:
        
        Num = Num % K
        if Num == 0:
            print(i)
            break
    
        while Num < K:
            Num = Num*10 + 7
            i += 1
        


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

int main(){
	double xp1,yp1,xp2,yp2,x0,y0,x,y,a;
	int i,q;
	
	cin>>xp1>>yp1>>xp2>>yp2;
	cin>>q;
	
	if(xp1==xp2){
		for(i=0;i<q;i++){
			cin>>x0>>y0;
			cout<<fixed<<setprecision(10)<<2*xp1-x0;
			cout<<" "<<fixed<<setprecision(10)<<y0<<endl;
		}
	}else{
		a=(yp2-yp1)/(xp2-xp1);
		for(i=0;i<q;i++){
			cin>>x0>>y0;
			x=a*((y0-yp1)-a*(x0-xp1))/(1+a*a)+x0;
        	y=(a*(a*y0+x0-xp1)+yp1)/(1+a*a);
			cout<<fixed<<setprecision(10)<<2*x-x0;
			cout<<" "<<fixed<<setprecision(10)<<2*y-y0<<endl;
		}
	}
}


Measured memory_bytes: 3288
#include <cstdio>

using namespace std;

int main()
{
  int n;
  scanf("%d", &n);
  int a[n];

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

  for(int i=(n-1); i>=0; i--)
  {
    if(i == 0){
      printf("%d\n", a[i]);
      break;
    }
    printf("%d ", a[i]);
  }
  return 0;
}


Measured memory_bytes: 2720
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String x = br.readLine();
		String[] cut = x.split(" ");

		int a = Integer.parseInt(cut[0]);
		int b = Integer.parseInt(cut[1]);

		System.out.println(((a + b) + 1) / 2);

	}
}

Measured memory_bytes: 21076
n = gets.to_i
cards = []
n.times do
  a, b = gets.chomp.split
  cards << [a, b.to_i]
end

class Array
  def partition(p, r)
    x = self[r][1]
    i = p - 1
    p.upto(r - 1) do |j|
      if self[j][1] <= x
        i += 1
        self[i], self[j] = self[j], self[i]
      end
    end
    self[i + 1], self[r] = self[r], self[i + 1]
    i + 1
  end
  
  def quick_sort(p, r)
    return if p >= r
    q = partition(p, r)
    quick_sort(p, q - 1)
    quick_sort(q + 1, r)
  end
  
  def merge_sort
    merge = ->(a, b) {
      result = []
      while a.size > 0 and b.size > 0
        result.push((a[0][1] <= b[0][1]) ? a.shift : b.shift)
      end
      result + a + b
    }
    
    l = length
    return self if l <= 1
    q = l / 2
    merge.(self[0...q].merge_sort, self[q..-1].merge_sort)
  end
end

another_cards = cards.merge_sort
cards.quick_sort(0, n - 1)
puts (cards == another_cards) ? "Stable" : "Not stable"
puts cards.map {|x| x.join(" ")}



Measured memory_bytes: 40596
num = int(input())
num_list = list(map(int,input().split()))

sign = 0

for i in range(0,num):
  if num_list[i]%2 == 0:
    if not (num_list[i]%3 == 0 or num_list[i]%5 == 0):
      sign = 1

if sign == 0:
  ans = "APPROVED"
elif sign == 1:
  ans = "DENIED"
  
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    //cout<<a<<b;

     if(a>=b)
     {
         cout<<10<<endl;
     }
     else
     {
         cout<<0<<endl;
     }
    return 0;
}


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

int main(void)
{
  int N, K;
  cin >> N >> K;
  int x[N];
  rep(i,N) cin >> x[i];
  int sum = 0;
  rep(i,N) sum += (x[i] < K-x[i]) ? x[i] : K-x[i];
  cout << sum * 2 << endl;
}

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

using namespace std;

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

	int result = 0;
	for (int i = 1; i < n; i++) {
		string s1 = s.substr(0, i), s2 = s.substr(i);
		
		set<char> set, set2;
		for (auto&& e : s1) {
			set.insert(e);
		}
		
		int count = 0;
		for (auto&& e : s2) {
			if (set.find(e) != set.cend()) {
				if (set2.find(e) != set2.cend()) {
					continue;
				}
				
				set2.insert(e);
				++count;
			}
		}
		
		if (result < count) {
			result = count;
		}
	}
	
	cout << result << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	static final int INF = Integer.MAX_VALUE/2;
	static final int mod = (int)1e9+7;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		int a[] = new int[n];
		for(int i=0;i<n;i++)a[i] = sc.nextInt();
		sc.close();

		int ans = (n-1 + (k-2))/(k-1);
		System.out.println(ans);
	}
	
}

Measured memory_bytes: 50244
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ld PI = 2 * acos(0.0);
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
const ll mod=1e9+7;
int MOD(int a)
{
    if(a<0)
        a+=mod;
    if(a>=mod)
        a%=mod;
    return a;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int n;cin>>n;
    int ans=8;
    for(int i=600;i<=2000;i+=200)
    {
        if(n<i)
        {
            break;
        }
        ans--;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main()
{
    bool num[1000000]={false};
    for(int i=2;i<1000;i++){
        if(!num[i]){
            for(int j=i*i;j<1000000;j+=i){
                num[j]=true;
            }
        }
    }
    int n;
    while(cin>>n){
        int ans=0;
        for(int i=2;i<=n;i++){
            if(!num[i])
                ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
int main(){

   long long int a,b,c,d=0,e,f,g,i,j,k,t=0,u=0,w,nt;
   double res;
   string x,y;
   char ch,ch1;
   vector<int> v;
   map<int,char> mp;
   map<int,char> mp2;
   vector<string> v1;
   set<int> s;
  cin>>a>>b;
  while(b--){
     cin>>c;
     t+=c;
  }
  if(a-t<0){
     cout<<-1<<endl;
  }
  else cout<<a-t<<endl;




 return 0;
}


Measured memory_bytes: 3604
a,b,x=map(int,input().split())
import math

ans=math.degrees(math.atan(2*(a**2*b-x)/(a**3)))
if ans>=math.degrees(math.atan(b/a)):
	ans=90-math.degrees(math.atan(2*x/(a*(b**2))))
print(ans)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
                    
                    
int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    while(A > 0 || C > 0){
        C -= B;
        if(C <= 0){
            break;
        }
       
        A -= D;
    }

    if(A <= 0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;
            
}

Measured memory_bytes: 3616
#include <stdio.h>

int	main(void)
{
  	int	a;
  	char	s[11];
  	
  	scanf("%d\n", &a);
  	scanf("%s\n", s);
  
  	if(a >= 3200)
      	printf("%s", s);
  	else
      	printf("red");
  
  	return (0);
}

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int sum = a[0];
    repk(i, 1, n) sum ^= a[i];
    rep(i, n) {
        int b = sum ^ a[i];
        cout << b << endl;
    }
}

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

#define INF 100000000
#define ABS(a) (a<0?-(a):a)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define REP(i,a) for(int i=0;i<a;i++) 

using namespace std;

int getLeng(int a[2], int b[2]){
  return ABS(a[0]-b[0])+ABS(a[1]-b[1]);
}

int main(){
  int N,M;
  cin >> N >> M;
  int point[M][2], st[N][2];
  for(int i = 0; i < N; i++){
    cin >> st[i][0] >> st[i][1];
  }
  for(int i = 0; i < M; i++){
    cin >> point[i][0] >> point[i][1];
  }

  for(int i = 0; i < N ; i++){
    int nearest = 2000000000;
    int num = 0;
    for(int j = 0; j < M; j++){
      int length = getLeng(st[i] ,point[j]);
      if(nearest > length){
        nearest = length;
        num = j + 1;
      }
    }
    cout << num << endl;
  }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include <cstdlib>
#include <climits>
#include <iomanip>
#include<iostream>
#include <sstream>  // for string streams
#include <string>  // for string
#include <stack> 
#include <cmath>
  #pragma comment(linker, "/STACK:2000000")
#pragma comment(linker, "/HEAP:2000000")
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 1000000007
  void printprecise(double l,int precision) 
  {
    std::cout << std::fixed;
    std::cout << std::setprecision(precision);
    std::cout << l;
}


int32_t main()
{
       



     int n;
     cin >> n;
     vector<pair<int,int> > v;

     rep(i,1,n)
     {
      int x;
      cin >> x;
      v.PB(MP(x,i));
     }

     sort(all(v));

     for(auto i:v)
     {
      cout << i.s << " ";
     }
    return 0;
}

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

int main(){
    int N,K,h,count = 0;
    cin >> N >> K;

    for(int i = 0;i < N;i++){
        cin >> h;
        if(h >= K){
            count += 1;
        }
    }

    cout << count << endl;
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int a , b;

int main()
{
    _FastIO;
    cin >> a >> b;
    if(b >= a){
        cout << "unsafe" << endl;
    }
    else
        cout << "safe" << endl;
    return 0;
}


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

int main(void)
{
	double a;
	double h;
	double s;
	
	while (scanf("%lf\n%lf", &a, &h), a != 0 ||  h != 0){
		s = 4 * h * h + a * a;
		s = sqrt(s);
		s = a * s + a * a;
		
		printf("%lf\n", s);
	}
	return (0);
}

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

int main() {

#ifdef LOCAL_DEFINE
	freopen("input.txt", "rt", stdin);
#endif

	int n;
	cin >> n;

	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < 15; j++) {
			if (i * 4 + j * 7 == n) {
				cout << "Yes\n";
				return 0;
			}
		}
	}

	cout << "No\n";

#ifdef LOCAL_DEFINE
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif

	return 0;
}

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

using namespace std;

int main(void)
{
	int a,b,mx;

	cin>>a>>b;

	if((a*b>a+b)&&(a*b>a-b)) mx=a*b;
	else if(a+b<a-b) mx=a-b; 
	else mx=a+b;

	cout<<mx<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define max(X, Y) ((X) > (Y) ? (X) : (Y))

void unite(int t[], int x, int y);
int root(int t[], int x);
int size(int t[], int x);

int row[2005][2005];
int col[2005][2005];
char mp[2005][2005];
int h, w;
int ans = 0;

int main()
{
    for (int i = 0; i < 2005; i++) {
        for (int j = 0; j < 2005; j++) {
            row[i][j] = col[i][j] = -1;
        }
    }
    
    scanf("%d %d", &h, &w);
    for (int i = 0; i < h; i++) {
        scanf("%s", mp[i]);
    }

    // row
    for (int i = 0; i < h; i++) {
        for (int j = 1; j < w; j++) {
            if (mp[i][j] == '.' && mp[i][j - 1] == '.') {
                unite(row[i], j, j - 1);
            }
        }
    }

    // col
    for (int j = 0; j < w; j++) {
        for (int i = 1; i < h; i++) {
            if (mp[i][j] == '.' && mp[i - 1][j] == '.') {
                unite(col[j], i, i - 1);
            }
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            ans = max(ans, size(col[j], i) + size(row[i], j) - 1);
        }
    }
    printf("%d\n", ans);

    return 0;
}

void unite(int t[], int x, int y)
{
    x = root(t, x);
    y = root(t, y);

    if (x == y) {
        return;
    }

    t[x] += t[y];
    t[y] = x;

    return;
}
    
int root(int t[], int x)
{
    if (t[x] < 0) {
        return x;
    }
    return t[x] = root(t, t[x]);
}

int size(int t[], int x)
{
    x = root(t, x);
    return -t[x];
}


Measured memory_bytes: 35584
#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);
    
    string s;
    cin >> s;
    int cnt = 0;
    for( int i = 0; i < 6; ++i ) if( s[i] == '1' ) ++cnt;;
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ff first
#define ss second
#define ll long long
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int pi = 3.1415926536;
const int MOD = 1000000007;
const int MAX = 510000;

void Main() {
  int n,m;
  cin>>n>>m;
  cout<<(n-1)*(m-1)<<endl;
}

int main() {
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  std::cout << std::fixed << std::setprecision(15);  // 小数を10進数表示
  Main();
}

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

int main()
{
	ll n;
	cin>>n;
	int count = 0;
	bool flag = false;
	for(int i=0; i<n; i++)
	{
		int a,b;
		cin>>a>>b;
		if(count >0 && a != b) count = 0;
		if(a == b) count++;
		if(count >=3) flag = true;
	}
	if(flag) cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 3616
from sys import stdin
import bisect
from itertools import accumulate
import numpy as np

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()

mi = 10**10

li = [0]*n
lin = [0]*n

for i in range(len(s)):
    if s[i] == "W":
        li[i] = 1
    if s[n-i-1] == "E":
        lin[i] = 1

li = np.asarray(list(accumulate(li)))
lin = np.asarray(list(accumulate(lin)))[::-1]
lis = li+lin

lis.sort()

print(lis[0]-1)

Measured memory_bytes: 31592
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cctype>
#include <queue>
#include <map>
#include <set> 
#include <bitset>
#include <cmath>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)

int main () {
    
    int n; cin >> n;
    int a = 0, b = n;

    while (n > 0) {
        int c = n % 10;
        a += c;
        n -= c;
        n = n/10;
    }

    if(b % a == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    } 
    
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   1e9 + 7 ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
void solve(){
   ll k ;
   cin >> k ;
   // 7*(1,11,111,1111................)
   ll start = 7%k;
   for( int i = 0 ; i < 1000000 ; i++){
        if(start==0){
            cout << i+1 ;
            return ;
        }
        start = ((start*10)%k + 7%k)%k ;
   }
   cout << -1 ;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1 ;
  //  cin >> t ;
    while(t--){
        solve( );
    }
}


Measured memory_bytes: 3644
#[allow(unused_imports)]
use std::cmp::*;

#[allow(unused_imports)]
use std::collections::*;

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(non_snake_case)]
fn main() {
    let S: String = read();
    let mut b: bool = false;
    let mut cnt_f = 0i32;
    let mut cnt_t = 0i32;
    for c in S.chars() {
        if c as i32 - 48 != b as i32 {
            cnt_f += 1;
        } else {
            cnt_t += 1;
        }
        b = !b;
    }
    println!("{}", min(cnt_f, cnt_t));
}


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

using namespace std;
#define ll long long

vector<ll> arr(102);
vector<vector<ll> >dp(102,vector<ll>(100002));

const int mod=1e9+7;

int main(){
	ll n,k;
	scanf("%lld%lld",&n,&k);
	
	for(int i=0;i<n;i++)scanf("%lld",&arr[i]);
	vector<ll> pre(k+1);
	for(int i=arr[0];i>=0;i--)dp[0][i]=1;
	
	
	for(int i=1;i<n;i++){
		pre[0]=dp[i-1][0];
		for(int j=1;j<=k;j++){
			pre[j]=(dp[i-1][j]+pre[j-1])%mod;
		}
		for(int j=0;j<=k;j++){
			ll ways=(pre[j]-(j-arr[i]-1>=0?pre[j-arr[i]-1]:0)+mod)%mod;
			dp[i][j]=ways;
		}
	}
	
	printf("%lld",dp[n-1][k]);
}


Measured memory_bytes: 81024
n = int(input())
t = 0
x = 0
y = 0
for i in range(n):
    ti,xi,yi = map(int,input().split())
    move = abs(xi-x) + abs(yi-y)
    time = ti - t
    if (time < move) or (time-move)%2==1:
        print('No')
        exit()
    t,x,y = ti,xi,yi
print('Yes')

Measured memory_bytes: 3064
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
namespace IO
{
	char buf[1 << 20 | 1] , *f1 = buf , *f2 = buf , pbuf[1 << 24 | 1] , *f3 = pbuf , sta[100];
	#define gc() ((f1 == f2) && (f2 = (f1 = buf) + fread(buf,1,sizeof buf,stdin),f1 == f2) ? EOF : *f1 ++)
	#define gt() getchar()
	inline ll read()
	{
		ll x = 0 , f = 1; char ch = gt();
		while(ch < '0' || ch > '9')	{if(ch == '-')	f = -1; ch = gt();}
		while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = gt();}
		return x * f;
	}
	template <class T> inline void write(T x)
	{
		if(!x) return (void)(*f3 ++ = 48 , *f3 ++ = ' ');
		if(x < 0) *f3 ++ = '-' , x = ~x + 1;
		char *top = sta;
		while(x) *top ++ = x % 10 + 48 , x /= 10;
		while(top != sta) *f3 ++ = *-- top;
		*f3 ++ = ' ';
	}
	inline void put(std::string s)
	{
		int len = s.length();
		for(int i = 0;i < len;i ++) *f3 ++ = s[i];
		*f3 ++ = ' ';
	}
	inline void endline() { *f3 ++ = '\n';}
	#define flush() fwrite(pbuf,1,f3 - pbuf,stdout)
	template <class T> inline T abs(T a) { return a < 0 ? -a : a;}
	template <class T> inline T max(T a,T b) { return a > b ? a : b;}
	template <class T> inline T min(T a,T b) { return a < b ? a : b;}
	template <class T> inline void swap(T &a,T &b) { T t = a; a = b; b = t;}
}
using namespace IO;
const int N = 1e5 + 5;
int n , cnt;
int size[N] , u[N] , v[N];
ll dis;
ll D[N];
struct node
{
	ll d; int id;
	node(ll d = 0,int id = 0) : d(d) , id(id) {}
	friend bool operator < (const node &a,const node &b) { return a.d < b.d;}
} e[N];
int main()
{
	n = read();
	for(int i = 1;i <= n;i ++) e[i] = node(read(),i) , size[i] = 1;
	std::sort(e + 1,e + 1 + n);
	for(int i = n;i > 1;i --)
	{
		ll dfa = e[i].d + 2 * size[i] - n;
		int j = std::lower_bound(e + 1,e + 1 + n,node(dfa)) - e;
		if(e[j].d != dfa) return puts("-1") , 0;
		u[++ cnt] = e[i].id; v[cnt] = e[j].id;
		size[j] += size[i];
		dis += size[i];
	}
	if(dis != e[1].d) return puts("-1") , 0;
	else for(int i = 1;i <= cnt;i ++) printf("%d %d\n",u[i],v[i]);
	return 0;
}

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

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L

#define long long long int

using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> b(n + 1, -1);
    b[0] = MAX_INT;
    int res = 0;
    for (int i = 0; i < n; i++) {
        int l = 0;
        int r = n;
        while (r > l + 1) {
            int m = (l + r) / 2;
            if (b[m] >= a[i]) {
                l = m;
            } else {
                r = m;
            }
        }
        b[l + 1] = a[i];
        res = max(res, l + 1);
    }
    cout << res << "\n";    

    return 0;
}

Measured memory_bytes: 1024
n, m = map(int, input().split())

if n == 1 and m == 1:
    print(1)
elif n <= 2 and m <= 2:
    print(0)
elif (n >= 3 and m == 1) or (n == 1 and m >= 3):
    print(max(n, m) - 2)
elif (n >= 3 and m == 2) or (n == 2 and m >= 3):
    print(0)
elif n >= 3 and m >= 3:
    print((n - 2) * (m - 2))

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const ll MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;




int main(void){

    int n;
    cin>>n;
    vll a(n),b(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    ll asum=0,bsum=0;
    rep(i,n)asum+=a[i];
    rep(i,n)bsum+=b[i];
    ll diff=bsum-asum;
    if(diff<0){
        fin("No");
        return 0;
    }

    ll diff2=0;
    rep(i,n)diff2+=max(0LL,a[i]-b[i]);
    
    ll diff3=0;
    rep(i,n)diff3+=max((ll)ceil(((double)b[i]-a[i])/2),0LL);
    
    if(diff2<=diff&&diff3<=diff)fin("Yes");
    else fin("No");
    
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<string, string> S;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int a[200100], b[200100];

vector<int> G[200100];

pair<int, int> dfs(int v, int prev) {
    pair<int, int> res = make_pair(v, 0);
    for (int u : G[v]) {
        if (u == prev)
            continue;
        const pair<int, int> p = dfs(u, v);
        if (res.second < p.second+1) {
            res = make_pair(p.first, p.second+1);
        }
    }
    return res;
}

int calc_tree_diameter() {
    const pair<int, int> p0 = dfs(0, -1);
    const pair<int, int> p1 = dfs(p0.first, -1);
    return p1.second;
}

string solve() {
    for (int i = 0; i < n-1; i++) {
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    int d = calc_tree_diameter();
    return (d % 3 == 1 ? "Second"  : "First");
}

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

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 25216
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  ll ans=0;
  for(auto c:s){
    if(c == '*')break;
    else if(c == '(')ans++;
    else ans--;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3228
def main():
    n, x = map(int, input().split())
    a = list(map(int, input().split()))
    b = [[None for _ in [0]*n] for _ in [0]*n]

    for i in range(n):
        m = a[i]
        for j in range(n):
            k = i-j
            if k < 0:
                k += n
            m = min(m, a[k])
            b[j][i] = m

    m = 10**15
    for i, j in enumerate(b):
        m = min(m, sum(j)+x*i)
    print(m)


main()

Measured memory_bytes: 37492
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
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;}

int X,Y,Z,T;
inline void solve(){
  IN3(X,Y,Z);
  T=X/(Y+Z);
  OUT(T+(X-T*(Y+Z)>=Z?0:-1));
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

ll a,b;
ll ans;

int main(){
  cin >> a >> b;
  ans=1;
  while(ans<=(int)10e5){
        if(floor(ans*0.08)==a && floor(ans*0.1)==b){cout << ans;return 0;}
        ++ans;
  }
  cout << -1;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}
struct union_find {
	int par[200010], size_[200010];
	union_find(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
signed main() {	
	int n, k, l;
	cin >> n >> k >> l;
	union_find road(n), rail(n);
	rep(i, k) {
		int a, b;
		cin >> a >> b;
		road.unite(a - 1, b - 1);
	}
	rep(i, l) {
		int a, b;
		cin >> a >> b;
		rail.unite(a - 1, b - 1);
	}
	map<P, int>mp;
	rep(i, n) {
		mp[{road.find(i), rail.find(i)}]++;
	}
	rep(i, n) {
		cout << mp[{road.find(i), rail.find(i)}] << ' ';
	}
	ggr
}


Measured memory_bytes: 18176