akhauriyash/Code-Regression huggingface dataset:
import math
N = int(input())

min = math.floor(N / 1.08)
max = math.ceil(N/ 1.08)
flag = False
for i in range(min,max+1):
    ans = math.floor(i*1.08)
    if N == ans:
        X = i
        flag = True
        break
if(flag):
    print(X)
else:
    print(':(')

Measured memory_bytes: 9000
s = list(input())
for i in range(len(s)//2):
    if s[i] != s[len(s)//2-1-i]:
        print("No")
        exit()
for i in range(len(s)//2):
    if s[-1-i] != s[len(s)//2+1+i]:
        print("No")
        exit()
if s != s[::-1]:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll a,b,sum,z;
    while(cin>>a>>b)
    {
        sum=a+b;
        z=floor(log10(sum))+1;
        cout<<(ll)z<<endl;
    }
    return 0;
}

Measured memory_bytes: 1200
function main(input){
  input = input.split('\n');
  
  var N = Number(input[0]);
  var d = input[1].split(' ').map(parseFloat);
  
  var result = 0;
  for(var i = 0;i < N;i++){
    for(var j = 1;j + i < N;j++){
      result += d[i] * d[j + i];
    }
  }
  
  console.log(result);
}
main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var C = new int[N - 1];
            var S = new int[N - 1];
            var F = new int[N - 1];
            for (var i = 0; i < N - 1; i++)
            {
                var CSF = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
                C[i] = CSF[0];
                S[i] = CSF[1];
                F[i] = CSF[2];
            }

            for (var i = 0; i < N; i++)
            {
                var answer = 0;
                for (var j = i; j < N - 1; j++)
                {
                    var nc = C[j];
                    var ns = S[j];
                    var nf = F[j];
                    if (answer <= ns) answer = ns;
                    else if (answer % nf != 0) answer += nf - answer % nf;
                    answer += nc;
                }
                Console.WriteLine(answer);
            }
        }
    }
}


Measured memory_bytes: 28488
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll k,a,b;cin>>k>>a>>b;
  if(k<=a){
    cout<<1<<endl;
    return 0;
  }
  if(a<=b){
    cout<<-1<<endl;
    return 0;
  }
  ll ans=(k-a-1)/(a-b);
  ll now=ans*(a-b);
  ans*=2;
  for(;;){
    if(now+a>=k){
      cout<<ans+1<<endl;
      return 0;
    }
    ans+=2;
    now+=a-b;
  }
}


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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
 
    # divisors.sort()
    return divisors
  
lis = sorted(make_divisors(X))

for i in range(10**9):
  for j in lis:
    if i**5-(i-j)**5==X:
      print(i, i-j)
      exit()

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

int main(){
  int N,T[110],M,sum=0,qu=0;
  cin >> N;
  for(int i=1; i<=N; i++){
    cin >> T[i];
    sum += T[i];
  }cin >> M;
  int P[M+10],X[M+10];
  for(int j=1; j<=M; j++){
      cin >> P[j] >> X[j];
      if(T[P[j]] >= X[j]){
        qu = sum-(T[P[j]]-X[j]);
      }else{
        qu = sum+(X[j]-T[P[j]]);
      }cout << qu << endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include "bits/stdc++.h"
	
#define int long long
#define double long double 
#define PI 3.141592653589793
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
// Use for file I/O;
#define FIN string _fname = "paintbarn"; \
			string _is = _fname + ".in", _os = _fname + ".out"; \
			freopen(_is.c_str(), "r", stdin); \
			freopen(_os.c_str(), "w", stdout);

using namespace std;
	
int gcd(int a, int b) {
    while (b > 0) {
        a %= b;
        swap(a, b);
    }
    return a;
}

const int INF = 4e18 + 10;
const int INF2 = 2e18 + 10;
const int INF3 = 2e10;
const int MAXN = 100000;
const int LOGN = 19;
const int MOD = 1e9 + 7;
const int EPS = 1e-9;
const int MULT = 2e5;
const int MCNST = MOD * MOD * 8;

int32_t main() {
	FAST;

	int n, m, k;
	cin >> n >> m >> k;

	vector<int> a(n), b(m);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int j = 0; j < m; j++) {
		cin >> b[j];
	}

	vector<int> pa(n + 1);
	for (int i = 0; i < n; i++) {
		pa[i + 1] = pa[i] + a[i];
	}

	vector<int> pb(m + 1);
	for (int i = 0; i < m; i++) {
		pb[i + 1] = pb[i] + b[i];
	}

	int ans = 0;
	for (int i = 0; i <= n; i++) {
		// cout << pa[i]  << ' ' << k - pa[i] << ' ' << (upper_bound(pb.begin(), pb.end(), k - pa[i]) - pb.begin()) << endl;
		if (pa[i] > k) break;
		ans = max(ans, i + (upper_bound(pb.begin(), pb.end(), k - pa[i]) - pb.begin()) - 1);
	}
	cout << ans;
}	

Measured memory_bytes: 9524
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    cout << n / 3 << endl;

    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class ATenki {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        string S, T;
        in>>S>>T;
        int ans = 0;
        REP(i, 3){
            if(S[i]==T[i]) ++ans;
        }
        out<<ans<<'\n';
    }
};


int main() {
	ATenki solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#define maxn 100505
#define ll long long
#define mod 1000000007
using namespace std;
int n,m,k,t;
int a[maxn],b[maxn];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        if(i&1)b[1]+=a[i];
        else b[1]-=a[i];
    }
    for(int i=2;i<=n;i++)
        b[i]=2*a[i-1]-b[i-1];
    for(int i=1;i<n;i++)
        printf("%d ",b[i]);
    printf("%d\n",b[n]);
}


Measured memory_bytes: 2048
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
#from scipy.misc import comb

N,M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

L = []
for i in range(M):
    l = list(map(int, input().split()))
    L.append(l)
L = sorted(L, key=lambda x:-x[1])

ans = 0
index = 0
for i in range(N):
    if index >= M:
        ans += A[i]
    else:
        if A[i] >= L[index][1]:
            ans += A[i]
        else:
            ans += L[index][1]
            L[index][0] -= 1
            if L[index][0] == 0:
                index += 1

print(ans)

Measured memory_bytes: 45824
x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
apples = p[:x] + q[:y] + r
apples.sort(reverse=True)
print(sum(apples[:x+y]))

Measured memory_bytes: 106628
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

lint dfs(lint n){
    if(n == 1) return 1;
    return 1LL + 2LL * dfs(n/2);
}

int main(){
    lint h;
    scanf("%lld", &h);
    printf("%lld\n", dfs(h));
}

Measured memory_bytes: 256
object Main extends App {
  val n = scala.io.StdIn.readInt()
  var sArray = Vector.empty[String]
  (1 to n).foreach { _ =>
    val readS = scala.io.StdIn.readLine()
    sArray :+= readS.sorted
  }
  val result = sArray.groupBy(s => s).map(s => s._2.size.toLong).filter(_ >= 2L).map(s => (s * (s - 1L)) / 2L ).sum
  println(result)
}

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

int main()
{
    int a,b;
    int max;
    int s1,s2,s3;
    scanf("%d %d",&a,&b);

        s1 = a+b;
        s2 = a-b;
        s3 = a*b;
        max=s1;
        if(s2 > max)max=s2;
        if(s3 > max)max=s3;

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


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

#define TASK_NUM (3)
#define MIN_TASK (1)
#define MAX_TASK (100)

typedef unsigned char       u1;
typedef unsigned short      u2;
typedef unsigned long int   u4;
typedef char                s1;
typedef short               s2;
typedef long int            s4;

typedef struct {
    u4 no;
    s4 task_size;
} TASK;

static TASK tasks[TASK_NUM];

int main (void) {
    u4 i, j;
    s4 cost = 0;
    s4 tmp = 0;

    // 入力
    for (i = 0; i < TASK_NUM; ++i) {
        tasks[i].no = i;
        scanf("%ld", &tasks[i].task_size);
    }

    // 処理
    for (i = 0; i < TASK_NUM-1; ++i) {
         for (j = i + 1; j < TASK_NUM; ++j) {
             if (tasks[i].task_size >  tasks[j].task_size) {
                tmp = tasks[i].task_size;
                tasks[i].task_size = tasks[j].task_size;
                tasks[j].task_size = tmp;
             }
         }
    }
    for (i = 0; i < TASK_NUM; ++i) {
        cost += abs(tasks[1].task_size - tasks[i].task_size);
    }

    // 出力
    printf("%ld\n", cost);

    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, T;
int A[100000];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> T;
  rep(i, N) cin >> A[i];
  int m = A[0], mx = 0, c = 0;
  for (int i=1; i<N; i++) {
    if (A[i] - m > mx) {
      mx = A[i] - m;
      c = 1;
    }
    else if (A[i] - m == mx) c++;

    m = min(m, A[i]);
  }
  cout << c << "\n";
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	int a[3];
	cinf(a,3);
	sort(a,a+3);
	if(a[0]+a[1]==a[2])
		cout << "Yes" << endl;
	else
		cout << "No" << endl; 
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N;
    cin >> N;
    map<ll, ll> cnt;
    rep(i, 0, N){
        ll a; cin >> a;
        rep(i, -1, 2){
            cnt[a+i]++;
        }
    }
    ll ans = 0;
    for(auto c : cnt) ans = max(ans, c.second);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
#define VEC vector
#define V VEC<ll>
signed main(){
  ll N,Q,ans;cin>>N>>Q;
  if(N>39)ans=1;
  else if(N==1)ans=Q;
  else{
    ans=1+pow((double)Q,1.00000/(double)N);
    while(1){
      ll i,S=1;REP(i,N)S*=ans;
      if(Q%S==0)break;ans--;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int N;
int A[105];

int main(){

	scanf("%d",&N);

	for(int i = 0; i < N; i++){

		scanf("%d",&A[i]);
	}

	int ans = 0;
	for(int i = 0; i < N-1; i++){
		for(int k = i+1; k < N; k++){

			ans += A[i]*A[k];
		}
	}

	printf("%d\n",ans);

	return 0;
}


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

int main(){
    long long n , ans = 0;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    long long sum[n];
    memset(sum , 0 , sizeof(sum));
    sum[n - 1] = 0;
    for(int j=n-2;j>=0;j--){
        sum[j] = sum[j+1] + a[j+1];
    }
    for(int i = 0; i < n; i++){
        ans = (ans%mod + ((a[i]%mod) * (sum[i]%mod)))%mod;
    }
    cout<<ans<<endl;
}

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

# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

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

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############



S = S()

S1 = list(map(int,S[::2]))
S2 = list(map(int,S[1::2]))
ans = sum(S1)+len(S2)-sum(S2)
P(min(len(S)-ans,ans))
  

Measured memory_bytes: 43372
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
  
vector<int> to[N]; 
int col[N]={0}; 
void dfs(int no,int p){
	col[no]=1;
	for(auto &s:to[no]){
		if(s==p||col[s]==1){
			continue;
		}else{
			dfs(s,no);
		}
	}
}
int main(){
	int n,m;
	cin>>n>>m;
	REP(i,m){
		int x,y,w;
		cin>>x>>y>>w;
		x--;y--;
		to[x].push_back(y);
		to[y].push_back(x);
		
	}
	int ans=0;
	REP(i,n){
		if(col[i]==1) continue;
		dfs(i,-1);
		ans++;
	}
	OUT(ans);
	return 0;
}

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

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

    vector<int> d(n);
    for (int i = 0; i < n; i++)
    {
        cin >> d[i];
    }
    
    sort(d.begin(),d.end());

    int ans = 1;
    for (int i = 1; i < n; i++)
    {
        if(d[i - 1] != d[i])ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int x, y; cin >> x >> y;
	bool ok = false;
	for (int i = 0; i <= x; i++)
	{
		if(i * 2 + (x - i) * 4 == y) ok = true;
	}
	if(ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3640
n = int(input())
s = input()
t = input()

if s == t:
	print(n)
	exit()

maxl = 0
for i in range(n):
	sub_s = s[n-i-1:]
	sub_t = t[:i+1]
	if sub_s == sub_t:
		maxl = max(maxl, i + 1)

print(2 * n - maxl)


Measured memory_bytes: 38256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
p = -2
ans = 0
for i in a:
  i -= 1
  ans += b[i]
  if i-p == 1:
    ans += c[p]
  p = i
print(ans)
    


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s[0] - '0' == 7 || s[1] - '0' == 7 || s[2] - '0' == 7) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

ll MAX_V = 2e5 + 5;
vector<vector<ll>> G(MAX_V);//隣接リスト(添え字は始点、値は終点)

//引数は各頂点(0-indexed)の入次数
vector<ll>tsort(vector<ll>v){
  ll n=v.size();
  vector<ll>ret(n);
  stack<ll>st;
  for(ll i=0;i<n;i++)if(v[i]==0)st.push(i);
  for(ll i=0;i<n;i++){
    if(st.empty())return vector<ll>();//閉路がある
    ll x=st.top();
    st.pop();
    ret[i]=x;
    for(ll j=0;j<G[x].size();j++){
      v[G[x][j]]--;
      if(v[G[x][j]]==0)st.push(G[x][j]);
    }
  }
  return ret;
}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n,m;cin>>n>>m;
  vector<ll>num(n);
  for(ll i=0;i<m;i++){
    ll p,q;
    cin>>p>>q;
    G[p-1].push_back(q-1);
    num[q-1]++;
  }
  auto v=tsort(num);
  vector<ll>idx(n);
  rep(i,0,n)idx[v[i]]=i;
  vector<ll>dp(n);
  rep(i,0,n-1){
    rep(j,0,G[v[i]].size()){
      chmax(dp[idx[G[v[i]][j]]],dp[i]+1);
    }
  }
  cout<<*max_element(ALL(dp))<<endl;
  return 0;
}

Measured memory_bytes: 11248
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
constexpr int INF = 0x3f3f3f3f; constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;
#define db(x) { cerr << #x << " = " << x << endl; }
template<class RIt> void dbarr(RIt frs, RIt lst){ cerr << "arr: "; for(int i = 0; i < (int)(lst-frs); i++) cerr << frs[i] << " \n"[i==(int)(lst-frs)-1]; }
#define all(x) begin(x), end(x)
#define pb push_back
#define eb emplace_back
#define mpr make_pair
#define fs first
#define sn second

int main() {
	cin.tie(0)->sync_with_stdio(0);
    int x,a,b; cin >> x >> a >> b;
    if(abs(a-x) < abs(b-x)) cout << "A\n";
    else cout << "B\n";
}



Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include <cstddef>
using namespace std;

int main()
{
    int N;
    long long f = 0; 
    cin >> N;
    for(int i = 0; i < N-1; i++)
    {
        f += i + 1;
    }
    cout << f << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007


lli D[40][40];
lli c[510][510];

signed main(){

	lli N,C;
	cin>>N>>C;
	REP(i,0,C)REP(j,0,C)cin>>D[i][j];
	REP(i,0,N)REP(j,0,N){
		cin>>c[i][j];
		c[i][j]--;
	}

	lli sum[3][40];
	REP(i,0,3)REP(j,0,40)sum[i][j]=0;

	lli ans=INF;

	for(lli y=0;y<N;y++){
		for(lli x=0;x<N;x++){
			lli nowColor = c[y][x];
			for(lli color=0;color<C;color++){
				sum[(x+y)%3][color] += D[nowColor][color];
			}
		}
	}

	REP(i,0,C)REP(j,0,C)REP(k,0,C){
		if(i==j || j==k || k== i)continue;
		ans = min(ans,sum[0][i]+sum[1][j]+sum[2][k]);
	}

	cout<<ans<<endl;


	return 0;
}

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

#define MAX_N 200000
int N;
int A;

int main()
{
  int max1 = -1;
  int max2 =-2;
  int idx1 = 0;
  int idx2 =  0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A;
    if (A > max1) {
      max2 = max1;
      idx2 = idx1;
      max1 = A;
      idx1 = i;
    } else if (A > max2) {
      max2 = A;
      idx2 = i;
    }
  }

  for (int i = 0; i < N; i++) {
    if (i == idx1) {
      cout << max2 << endl;
    } else {
      cout << max1 << endl;
    }
  }
  return 0;
}

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

#define V (10*10*10*10*10*10*10*10*10+7)

typedef long long ll;

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

    ll ans = 1;
    for (int i = 1; i <= N; i++) {
        ans *= i;
        ans = ans % V;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
using namespace std;
const int inf = 1e9;
int x[2000], y[2000], z[2000];
bool used[2000];
int n,k,s;

void dfs(int node, int prev, vector<vector<int> > &adj, vector<int> &ret){
    if(used[node]) return;
    used[node] = true;
    for(size_t i=0; i<adj[node].size(); i++){
        int next = adj[node][i];
        if(next != prev){
            int dx = s -abs(x[node]-x[next]);
            int dy = s -abs(y[node]-y[next]);
            int dz = s -abs(z[node]-z[next]);
            ret.push_back(2*(dx*dy +dy*dz +dz*dx));
            dfs(next, node, adj, ret);
        }
    }
}

int solve(int k, vector<vector<int> > &adj){
    memset(used, 0, sizeof(used));
    int res = inf;
    for(int d=0; d<2; d++){
        for(int i=0; i<n; i++){
            if(used[i]) continue;
            if(d==0 && (int)adj[i].size()>=2) continue;
            vector<int> ret;
            int pre = (d==0)? -1: adj[i][0];
            dfs(i, pre, adj, ret);
            int m = ret.size();
            if((d==0 && m+1<k) || (d==1 && m<k)) continue;
            int rep = (d==1 && m==k)? k: k-1;
            for(int j=0; (d==0)? j<m-k+2: j<m; j++){
                int sur = k*6*s*s;
                for(int r=0; r<rep; r++){
                    sur -= ret[(j+r)%m];
                }
                res = min(res, sur);
            }
        }
    }
    return (res==inf)? -1 : res;
}

int main(){
    while(1){
        cin >> n >> k >> s;
        if(n==0) break;
        
        for(int i=0; i<n; i++){
            cin >> x[i] >> y[i] >> z[i];
        }
        vector<vector<int> > adj(n);
        for(int i=0; i<n; i++){
            for(int j=i+1; j<n; j++){
                if(abs(x[i]-x[j])<s && abs(y[i]-y[j])<s && abs(z[i]-z[j])<s){
                    adj[i].push_back(j);
                    adj[j].push_back(i);
                }
            }
        }
        cout << solve(k, adj) << endl;
    }
    return 0;
}



Measured memory_bytes: 3224
import numpy as np

N = int(input())
h = np.array([int(i) for i in input().split()])
flag = [0] * N

thrs = 0

if N == 1:
  print(h[0])
  exit()

i = 0
ans = 0
l, r = (0, 0)
while sum(flag) != N:
  j = 0
  while j < l:
    if h[j] == 0:
      flag[j] = 1
    j += 1
  
  if h[l] == 0:
    l += 1
    flag[l] = 1
  
  i = 0
  i += l
  r = i
  while h[i] > thrs:
    r += 1
    i += 1
    if i == N:
      break
  
  if l == r:
    continue
  ans += min(h[l:r])
  h[l:r] = h[l:r] - min(h[l:r])
print(ans)
  

Measured memory_bytes: 12444
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());


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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (i >= k) {
            cout << (a[i] > a[i - k] ? "Yes\n" : "No\n");
        }
    }

    return 0;
}


Measured memory_bytes: 4820
#include<bits/stdc++.h>
#define int long long

using namespace std;

int dp[3001][3001] = {};

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    
    string a, b;
    cin >> a >> b;
    for (int i = 1; i <= a.size(); i++)
        for (int j = 1; j <= b.size(); j++)
            if (a[i - 1] == b[j - 1])
                dp[i][j] = dp[i - 1][j - 1] + 1;
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
    
    int i = a.size(), j = b.size();
    stack<char> ans;
    while (i > 0 && j > 0)
    {
        if (dp[i][j] > dp[i - 1][j] && dp[i][j] > dp[i][j - 1])
            ans.push(a[i - 1]), i--, j--;
        else if (dp[i][j] == dp[i][j - 1] && j > 1)
            j--;
        else
            i--;
    }
    while (!ans.empty())
        cout << ans.top(), ans.pop();
    cout << '\n';
    
    return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        mp[a]++;
    }
    for (int i = 0; i < m; i++) {
        int b;
        cin >> b;
        mp[b]++;
    }

    vector<int> and_nums;
    vector<int> or_nums;
    int n_and = 0, n_or = 0;
    for (auto it = mp.begin(); it != mp.end(); it++) {
        pair<int, int> item = *it;
        if (item.second) {
            or_nums.push_back(item.first);
            n_or++;
        }
        if (item.second == 2) {
            and_nums.push_back(item.first);
            n_and++;
        }
    }

    cout << n_and << " " << n_or << endl;
    for (int i = 0; i < and_nums.size(); i++)
        cout << and_nums[i] << endl;
    for (int i = 0; i < or_nums.size(); i++)
        cout << or_nums[i] << endl;
    return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n;

string f(string s,bool flag){
	string res="";
	rep(i,s.length()){
		if(isdigit(s[i])){
			char c=s[i];
			if(flag)c++;
			else c--;
			if(c>'9')c='0';
			if(c<'0')c='9';
			res+=c;
		}else res+=s[i];
	}
	return res;
}

int main(){
	cin.sync_with_stdio(false);
	cin>>n;
	rep(h,n){
		string s,op;
		cin>>op>>s;
		reverse(all(op));
		int l=s.length();
		string res;
		rep(i,op.length()){
			if(op[i]=='C'){
				s=s.substr(1,l-1)+s[0];
			}else if(op[i]=='J'){
				s=s[l-1]+s.substr(0,l-1);
			}else if(op[i]=='E'){
				if(l%2==1)s=s.substr(l/2+1,l/2)+s[l/2]+s.substr(0,l/2);
				else s=s.substr(l/2,l/2)+s.substr(0,l/2);
			}else if(op[i]=='A'){
				reverse(all(s));
			}else if(op[i]=='P'){
				s=f(s,false);
			}else if(op[i]=='M'){
				s=f(s,true);
			}
		}
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 3192
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

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

	string s;
	cin >> s;

	if(s[0]=='1')s[0]='9';
  else s[0]='1';
  if(s[1]=='1')s[1]='9';
  else s[1]='1';
  if(s[2]=='1')s[2]='9';
  else s[2]='1';

	cout << s << "\n";
}


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

#define int long long

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

  int ans = 1000000000;
  for ( int i = 1; i < n; i++ ) {
    int a = i, b = n-i;
    int ans2 = 0;
    while ( a ) {
      ans2 += a%10;
      a /= 10;
    }
    while ( b ) {
      ans2 += b%10;
      b /= 10;
    }
    ans = min(ans, ans2);
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

template<class T>
struct BIT{
    int N;
    vector<T> bit;

    BIT(){};
    BIT(int n = 0) : N(n), bit(n + 1, 0) {}

    T sum(int i){
        T s = 0;
        while(i > 0){
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }

    void add(int i, int x){
        while(i <= N){
            bit[i] += x;
            i += i & -i; 
        }
    }
};

int cnt[26];
int cnt2[26];
int sec[200010];
ll ans;
string S;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> S;
    for(int i = 0; i < S.length(); i++){
        cnt[S[i] - 'a']++;
    }

    int odd = 0;
    for(int i = 0; i < 26; i++){
        odd += cnt[i] % 2;
    }
    if(odd > 1){
        cout << -1 << endl;
        return 0;
    }
    ll pre[3] = {};
    string l = "", r = "";
    for(int i = 0; i < S.length(); i++){
        int idx = S[i] - 'a';
        cnt2[idx]++;
        if(cnt2[idx] * 2 - 1 == cnt[idx]) sec[i] = 1;
        else if(cnt2[idx] * 2 <= cnt[idx]) sec[i] = 0, l += S[i];
        else sec[i] = 2, r += S[i];
        for(int j = 2; j > sec[i]; j--) ans += pre[j];
        pre[sec[i]]++;
    }
    reverse(r.begin(), r.end());
    vector<int> id[26];
    for(int i = 0; i < l.length(); i++) id[l[i] - 'a'].emplace_back(i + 1);
    
    BIT<ll> bit(l.length());
    int to[26] = {};
    for(int i = 0; i < r.length(); i++){
        int al = r[i] - 'a';
        int p = id[al][to[al]];
        ans += bit.sum(r.length()) - bit.sum(p);
        bit.add(p, 1);
        to[al]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3092
import kotlin.math.max

fun main(args: Array<String>) {
    val (n, k) = readIntList()
    val p = readIntList().map { it - 1 }
    val c = readLongList()

    var ans = Long.MIN_VALUE
    for (i in 0 until n) {
        val score = mutableListOf<Long>()
        var tmp = 0L
        var next = p[i]
        do {
            tmp += c[next]
            score.add(tmp)
            next = p[next]
        } while (next != i)
        tmp += c[next]
        score.add(tmp)

        var tmpAns = if (score.last() > 0) score.last() * (k / score.size - 1) else 0
        next = i
        repeat(k % score.size + score.size) {
            next = p[next]
            tmpAns += c[next]
            ans = max(ans, tmpAns)
        }
    }

    println(ans)
}

// read
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 59372
a,b=(map(int,input().split()))
if a>0 and b>0:
    print('Positive')
elif a<=0 and b>=0:
    print('Zero')
elif a<0 and b<0:
    x=b-a+1
    if x%2==0:
        print('Positive')
    else:
        print('Negative')

Measured memory_bytes: 9064
#include <iostream>
#include <sstream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;


int main(void)
{
	int N, M; cin >> N >> M;
	int ans = N * (N - 1) / 2 + M * (M - 1) / 2;
	cout << ans << endl;

	return 0;
}


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

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

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  lint A[N];
  REP(i,N)cin>>A[i];
  int j=0;
  sort(A,A+N);
  while(j<N-1){
    // REP(i,N)cerr<<A[i]<<" ";
    // cerr<<endl;
    FOR(i,j+1,N)A[i]%=A[j];
    sort(A,A+N);
    while(A[j]==0)j++;
  }
  cout<<A[N-1]<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;
int main(void)
{
	int H, W, N;
	cin >> H >> W >> N;
	cout << (N+max(H, W)-1)/max(H, W) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define debug1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define debug2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define debug3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"
// #define M 421412341324321
#define MOD 998244353

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	string s;
	cin>>s;
	
	string pre="", curr="";
	int c=0;
	rep(i,s.length())
	{
		curr+=s[i];
		if (curr!=pre)
		{
			c++;
			pre=curr;
			curr="";
		}
	}
	cout<<c;
	
}


Measured memory_bytes: 720
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    string n;
    cin >> n;
    if (n[0] == '7' || n[1] == '7' || n[2] == '7') {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <list>
#include <iomanip>
#include <queue>
#include <cmath>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
typedef pair<ll, ll> p;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const long long mod = 1e9 + 7;
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);

int main() {
	string S, tmp;
	cin >> S;

	reverse(S.begin(), S.end());
	ll N = S.size(), i = 0;

	while (i != N) {
		if (S[i] == 'e'){
			if (S.substr(i, 5) != "esare") {
				cout << "NO";
				return 0;
			}
			else {
				i += 5;
				continue;
			}
		}
		else if (S[i] == 'm') {
			if (S.substr(i, 5) != "maerd") {
				cout << "NO";
				return 0;
			}
			else {
				i += 5;
				continue;
			}
		}
		else if (S[i] == 'r' && S[i + 1] == 'e') {
			if (S.substr(i, 6) == "resare") {
				i += 6;
				continue;
			}
			else if(S.substr(i, 7) == "remaerd"){
				i += 7;
				continue;
			}
			else {
				cout << "NO";
				return 0;
			}
		}
		else {
			cout << "NO";
			return 0;
		}
	}

	cout << "YES";

	return 0;
}


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

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

static const int N = 100;
static const int INFTY = (1 << 21);

int d[N] = {0};

void bfs(int M[N][N], int n, int s) {
    queue<int> q;
    q.push(s);
    for (int i = 0; i < n; ++i) d[i] = INFTY;
    d[s] = 0;
    int u;
    while (!q.empty()) {
        u = q.front();
        q.pop();
        for (int v = 0; v < n; ++v) {
            if (M[u][v] == 0) continue;
            if (d[v] != INFTY) continue;
            d[v] = d[u] + 1;
            q.push(v);
        }
    }

    for (int i = 0; i < n; ++i) {
        cout << i + 1 << " " << ((d[i] == INFTY) ? (-1) : d[i]) << endl;
    }
}

int main() {

    int n;
    cin >> n;

    int M[N][N] = {0};
    int u, k, v;
    for (int i = 0; i < n; ++i) {
        cin >> u >> k;
        --u;
        for (int j = 0; j < k; ++j) {
            cin >> v;
            --v;
            M[u][v] = 1;
        }
    }

    bfs(M, n, 0);

    return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    //int t;cin>>t;while(t--)
    {
        ll i,j,k,l,m,n,a,b,c,d,cnt=0,sum=0;
        int arr[5];
        for(i=0;i<5;i++)
        {
            cin>>arr[i];
            if(arr[i]==0)
            {
                m=i;
            }
        }

cout<<m+1<<endl;
    }


}


Measured memory_bytes: 3624
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int main(){
  char S[1000005];
  int Q;
  int rev=0;
  int top=250001;
  int back=250002;

  scanf("%s",&S[250002]);
  back += strlen(&S[250002]);
  scanf("%d",&Q);
  for(int i = 1 ; i <= Q ; i++){
    int T;
    scanf("%d",&T);
    if(T == 1){
      rev++;
    }else if(T == 2){

      int F;
      char c[4];
      scanf("%d",&F);

      if(F == 1){
        if(rev % 2 == 0){
          scanf("%s",&c);
          S[top] = c[0];
          top--;
        }else if(rev % 2 == 1){
          scanf("%s",&c);
          S[back] = c[0];
          back++;
        }
      }else if(F == 2){
        if(rev % 2 == 0){
          scanf("%s",&c);
          S[back] = c[0];
          back++;
        }else if(rev % 2 == 1){
          scanf("%s",&c);
          S[top] = c[0];
          top--;
        }
      }
    }

  }
  if(rev % 2 == 0){
    for(int i = top+1 ; i <= back-1 ; i++){
      printf("%c",S[i]);
    }
  }else if(rev % 2 == 1){
    for(int i = back-1 ; i >= top+1 ; i--){
      printf("%c",S[i]);
    }
  }
}

Measured memory_bytes: 768
#include <stdio.h>

int main(void)
{
	double max, min, h;
	
	max = 0.0;
	min = 5000.0;
	while (scanf("%lf", &h) != EOF){
		if (h > max){
			max = h;
		}
		if (h < min){
			min = h;
		}
	}
	printf("%f\n", max - min);
	
	return (0);
}

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

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

  if (A + B < C + D ) {
    cout << "Right" << endl;
  }
  else if (A + B == C + D ) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Left" << endl;
  }
}


Measured memory_bytes: 3572
import sys
sys.setrecursionlimit(10000000)
import math
import bisect
from collections import deque
def input():
    return sys.stdin.readline()[:-1]
    
n,m = map(int,input().split())
s = input()
lis = []
now = len(s)-1
ju = 0
ju2 = 0
while now>0:
    ju = 0
    if ju2==1:
        break
    for i in range(m,0,-1):
        if now-i<0:
            continue
        if now-i ==0:
            lis.append(i)
            ju = 1
            now = 0
            break
        if s[now-i]=="0":
            now = now-i
            lis.append(i)
            ju = 1
            break
        if i==1 and ju==0:
            ju2 = 1
            break
if ju2==0:
    lis.reverse()
    print(*lis)
else:
    print(-1)


Measured memory_bytes: 83908
import sys
n,m=map(int,input().split())
bridge=[[i for i in map(int,l.split())] for l in sys.stdin]
bridge.reverse()
all=(n*(n-1))//2
ans=[all]
root=[i for i in range(n+1)]
rank=[0]*(n+1)
size=[1]*(n+1)
def find(x):
  if root[x]==x:
    return x
  else:
    root[x]=find(root[x])
    return root[x]
def check(x,y):
  return find(x)==find(y)
def union(x,y):
  x=find(x)
  y=find(y)
  if rank[x]<rank[y]:
    root[x]=y
    size[y]+=size[x]
  else:
    root[y]=x
    size[x]+=size[y]
  if rank[x]==rank[y]:
    rank[x]+=1
for i in bridge:
  if check(i[0],i[1]):
    ans.append(ans[-1])
  else:
    ans.append(ans[-1]-size[find(i[0])]*size[find(i[1])])
    union(i[0],i[1])
ans.pop()
for i in range(m):
  print(ans.pop())

Measured memory_bytes: 29900