akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#define INF ((1<<30)-1+(1<<30))

using namespace std;
int mn[1000000];
int n,q;
int a,b,c;

void update(int i,int x){
	i += 131072;
	mn[i] = x;
	i /= 2;
	while(i>0){
		int l = mn[2*i];
		int r = mn[2*i+1];
		mn[i] = min(l,r);
		i /= 2;
	}
}

int find(int l,int r,int bottom = 0,int top = 131072,int node = 1){
	if(l <= bottom && top <= r) return mn[node];
	if(top <= l || r <= bottom) return INF;
	int mid = (bottom+top)/2;
	int lmn = find(l,r,bottom,mid,2*node);
	int rmn = find(l,r,mid,top,2*node+1);
	return min(lmn,rmn);
}

int main(){
	cin >> n >> q;
	for(int i=1;i<=2*131072;i++){
		mn[i] = INF;
	}
	for(int i=0;i<q;i++){
		cin >> a >> b >> c;
		if(a==0){
			update(b,c);
		}
		else if(a==1){
			cout << find(b,c+1) << endl;
		}
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d; cin>>a>>b>>c>>d;
    cout<<min(a,b)+min(c,d)<<endl;
    return 0;
}


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

using ll = long long;
const int MOD = 998244353;

ll powmod(ll a, int b) {
  a %= MOD;
  ll res = 1;
  while (b > 0) {
    if (b % 2 == 1) res = res * a % MOD;
    a = a * a % MOD;
    b /= 2;
  }
  return res;
}
ll f[200005];
void cominit() {
  f[0] = 1;
  for (int i = 0; i < 200000; i++) f[i + 1] = f[i] * (i + 1) % MOD;
}

ll nCr(int n, int r) {
  if (n < r) return 0;
  if (n < 0 or r < 0) return 0;
  return f[n] * powmod(f[r] * f[n - r], MOD - 2) % MOD;
}

int main() {
  ll n, m, k;
  cin >> n >> m >> k;
  cominit();
  ll ans = 0;
  for (int i = 0; i < k + 1; i++) {
    ll res = nCr(n - 1, i);
    res *= m * powmod(m - 1, n - i - 1) % MOD;
    res %= MOD;
    ans = (ans + res) % MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 5200
class BinaryTree:
    class Node:
        def __init__(self, num, left_child, right_child):
            self.id = num
            self.left_child = left_child
            self.right_child = right_child
            
    def __init__(self, n):
        self.nodes = [None] * n
        self.root_id = int(n * (n - 1) / 2)

    def add_node(self, i_s):
        num, left_child, right_child = map(int, i_s.split())
        self.nodes[num] = BinaryTree.Node(num, left_child, right_child)
        if left_child != -1:
            self.root_id -= left_child
        if right_child != -1:
            self.root_id -= right_child

    def preorder_walk(self):
        print('Preorder')
        def _pre_walk(node_id):
            if node_id != -1:
                print(' {0}'.format(node_id), end = '')
                _pre_walk(self.nodes[node_id].left_child)
                _pre_walk(self.nodes[node_id].right_child)
        _pre_walk(self.root_id)
        print('')

    def inorder_walk(self):
        print('Inorder')
        root_node = self.nodes[self.root_id]
        def _in_walk(node_id):
            if node_id != -1:
                _in_walk(self.nodes[node_id].left_child)
                print(' {0}'.format(node_id), end = '')
                _in_walk(self.nodes[node_id].right_child)
        _in_walk(self.root_id)
        print('')

    def postorder_walk(self):
        print('Postorder')
        root_node = self.nodes[self.root_id]
        def _post_walk(node_id):
            if node_id != -1:
                _post_walk(self.nodes[node_id].left_child)
                _post_walk(self.nodes[node_id].right_child)
                print(' {0}'.format(node_id), end = '')
        _post_walk(self.root_id)
        print('')


n = int(input())

BT = BinaryTree(n)

for i in range(n):
    BT.add_node(input())

BT.preorder_walk()
BT.inorder_walk()
BT.postorder_walk()

Measured memory_bytes: 7748
#include <bits/stdc++.h>
typedef long long LL;
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define RALL(X) (X).rbegin(), (X).rend()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define DRVI(N, X) VI X(N); for (int ___I=0; ___I<n; ___I++) scanf("%d", &(X[___I]))  
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second

using namespace std;

int main(){
    DRII(s,w);
    if (w>=s) printf("un");
    printf("safe\n");
}


Measured memory_bytes: 3828
#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);
ll gcd(ll a, ll b);

vector<ll> pn(1001, 0);

void PF(ll n);



int main() {
	ll n;
	cin >> n;
	
	rep(i, n + 1) {
		PF(i);
	}
	ll ans = 1;

	repl(i, 2, n + 1) {
		ans *= (pn[i] + 1);
		ans %= mod;
	}

	cout << ans;

	return 0;
}

void PF(ll n) {
	ll tmp = sqrt(n) + 1;
	repl(i, 2, tmp) {
		while (n % i == 0) {
			n /= i;
			pn[i]++;
		}
	}
	pn[n]++;
}


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: 3640
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
// #include "prettyprint.hpp"

bool comp(pair<int, int> a, pair<int, int> b) {
  return a.second < b.second;
}

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> A;

  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A.emplace_back((i + 1), a);
  }

  sort(A.begin(), A.end(), comp);

  for (int i = 0; i < N; i++) {
    cout << A[i].first << " ";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 1780
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))

void run (void) {
  i32 n, m;
  scanf ("%" SCNi32 "%" SCNi32, &n, &m);
  const i32 LIM = 200000;
  i32 *dp = ALLOC (2 * LIM + 2, i32);
  i64 sum = 0;
  for (i32 i = 0; i < n; ++i) {
    i32 a;
    scanf ("%" SCNi32, &a);
    sum += a;
    dp[a]++;
  }
  for (i32 i = LIM - 1; i >= 0; --i) {
    dp[i] += dp[i + 1];
  }
  i32 *cnt = ALLOC (200000 + 1, i32);
  for (i32 i = 0; i < m; ++i) {
    i32 b;
    scanf ("%" SCNi32, &b);
    cnt[b]++;
  }
  i64 ans = (i64) sum * m;
  for (i32 i = 1; i <= LIM; ++i) {
    if (cnt[i] == 0) continue;
    for (i32 j = 0; j <= 200000; j += i) {
      ans -= (i64) cnt[i] * (dp[j] - dp[j + i]) * j;
    }
  }
  printf ("%" PRIi64 "\n", ans);
}

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



Measured memory_bytes: 4152
#include <iostream>

const long long int MOD=1000000007;

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    
    int a[M];
    for(int i=0; i<M; i++) {
        cin >> a[i];
    }
    
    int dp[N+1], count=0;
    dp[0]=1;
    
    for(int i=1; i<N+1; i++) {
        dp[i] = 0;

        if(count<M) {
            if(i==a[count]) {
                count++;
            } else {
                if(i>1) {
                    dp[i] = dp[i-1] + dp[i-2];
                } else {
                    dp[i] = dp[i-1];
                }
            }
        } else {
            if(i>1) {
                dp[i] = dp[i-1] + dp[i-2];
            } else {
                dp[i] = dp[i-1];
            }
        }

        dp[i] %= MOD;

        // cout << i << " " << dp[i] << endl;
    }
    
    cout << dp[N] << endl;

    return 0;
    
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
using namespace std;
//const int N=1e5+5;
int a[25][25],v[25][25],dx[5]={1,-1,0,0},dy[5]={0,0,1,-1};
struct P{
	int x,y,dis;
};
int main(){
	ios::sync_with_stdio(false);
	int h,w,m=0;
	vector<P>b;
	P sta;
	sta.x=0;sta.y=0;
	cin>>h>>w;
	for(int i=1;i<=h;i++)
	{
	/* getchar();
	 for(int j=1;j<=w;j++)
	  { char s;
	     s=getchar();
	     if(s=='.'){
		 a[i][j]=1;*/
		 char s[25];
		 cin>>s;
		 for(int j=0;j<w;j++){
		 if(s[j]=='.'){
		 a[i][j+1]=1;sta.x=i;sta.y=j+1;sta.dis=0;b.push_back(sta);
       }  
    }
  }

	for(int i=0;i<b.size();i++){
		memset(v,0,sizeof(v));
	  v[b[i].x][b[i].y]=1;
	  queue<P>q;
	  q.push(b[i]);
	  while(!q.empty()){
	  	P now=q.front();
	  //	if(a[now.x][now.y]==0)continue;
	  q.pop();
	  	for(int i=0;i<4;i++){
	  		int nx=now.x+dx[i],ny=now.y+dy[i];
	  		if(nx>0&&nx<=h&&ny>0&&ny<=w&&!v[nx][ny]&&a[nx][ny]){
	  			//cout<<nx<<' '<<ny<<endl;
	  			v[nx][ny]=1;
	  			P cur;
	  			cur.x=nx;cur.y=ny;cur.dis=now.dis+1;
	  			m=max(m,cur.dis);
	  			q.push(cur);
			  }
		  }
	  }
}
	  cout<<m;
	  return 0;
}

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

typedef long long ll;
const ll mod = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

typedef pair<ll, ll> P;
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

ll mpow(ll a, ll b)
{
  if(b == 0) return 1; 
  return mpow(a*a%mod, b/2)*(b%2?a:1)%mod;
}

int main()
{
    ll n;
    cin >> n;
    vector <ll> a(n);
    ll p[1000010] = {0};
    for (ll i = 0; i < n; i++) cin >> a[i];
    for (ll i = 0; i < n; i++) {
        ll tmp = a[i];
        for (ll j = 2; j*j <= tmp; j++) {
            ll cnt = 0;
            while (tmp % j == 0) {
                cnt++;
                tmp /= j;
            }
            chmax(p[j], cnt);
        }
        if (tmp) chmax(p[tmp], 1LL);
    }

    ll tmp = 1;
    for (ll i = 0; i < 1000010; i++) {
        for (ll j = 0; j < p[i]; j++) {
            //cout << i << endl;
            (tmp *= i) %= mod;
        }
    }
    //cout << tmp << endl;

    ll ans = 0;
    for (ll i = 0; i < n; i++) {
        //(ans += tmp*mpow(a[i], mod-2)%mod) %= mod;
        (ans += tmp*mpow(a[i], mod-2)%mod) %= mod;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 8192
#include<stdio.h>
int main(void){
    int i,M,N,L,total,month,f=0;
    for(;;){
        total=0,month=0,f=0;
        scanf("%d",&L);
        if(L==0)
            break;
        for(i=1;i<=12;i++){
            scanf("%d%d",&M,&N);
            total=total+M-N;
            if(total>=L&&f==0){
                month=i;
                f++;
            }
        }
        if(total>=L)
            printf("%d\n",month);
        else
            printf("NA\n");
    }
    return 0;
}

Measured memory_bytes: 612
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

s = sum(b)

i = 0
while i < n - 1:
	if a[i] + 1 == a[i + 1]:
		s += c[a[i] - 1]
	i += 1

print(s)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl

const int max_E = 2000;
const int max_V = 1000;
struct edge{int from,end,cost;};
edge es[max_E];
int d[max_V];
int V,E;

void BellmanFord(int s){
    for(int i=0;i<V;i++)d[i]=INF;
    d[s]=0;
    for(int j=0;j<V;j++){
        bool update=false;
        for(int i=0;i<E;i++){
            edge k=es[i];
            if(d[k.from]!=INF && d[k.end]>d[k.from]+k.cost){
                d[k.end]=d[k.from]+k.cost;
                update=true;
            }
        }
        if(!update)break;
    }
    
}
bool negative[max_V]={};
bool NegativeLoopExist(void){
    memset(d,0,sizeof(d));
    for(int i=0;i<V;i++){
        for(int j=0;j<E;j++){
            edge f=es[j];
            if(d[f.end]>d[f.from]+f.cost){
                d[f.end]=d[f.from]+f.cost;
                if(i==V-1){
                    negative[f.end]=true;
                }
            }
        }
    }
    for(int i=0;i<V;i++){
        return true;
    }
    return false;
}
/*bool NegativeLoopExist(void){
    memset(d,0,sizeof(d));
    for(int i=0;i<V;i++){
        for(int j=0;j<E;j++){
            edge f=es[j];
            if(d[f.end]>d[f.from]+f.cost){
                d[f.end]=d[f.from]+f.cost;
                if(i==V-1)return true;
            }
        }
    }
    return false;
}*/

signed main(){
    int N,M;
    int a[2000],b[2000],c[2000];
    edge h;
    cin >> N >> M;
    V=N,E=M;
    REP(i,M){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;b[i]--;
    }
    REP(i,M){
        h.from=a[i];
        h.end=b[i];
        h.cost=-1*c[i];
        es[i]=h;
    }
    //REP(i,M){cout << es[i].from << " "<< es[i].end << " "<< es[i].cost << endl;}
    if(NegativeLoopExist() && negative[N-1]==true){
        cout << "inf" << endl;
        return 0;
    }
    BellmanFord(0);
    //REP(i,N){cout << d[i] << " ";}cout << endl;
    cout << -1*d[N-1] << endl;
    return 0;
}      


Measured memory_bytes: 384
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Set<String> s = new HashSet<>();

		for (int i = 0; i < n; i++) {
			s.add(sc.next());
		}

		System.out.println(s.size());

		sc.close();
	}

}


Measured memory_bytes: 78140
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int n;
	unordered_set<int> s;
	cin >> n;
	rep(i,n) {
		int a;
		cin >> a;
		s.insert(a);
	}

	cout << (s.size() == n ? "YES" : "NO") << endl;



	return 0;
}

Measured memory_bytes: 8520
<?php
// C
fscanf(STDIN, '%d', $K);
for ($i = 1; $i <= $K; $i++) {
    for ($j = $i; $j <= $K; $j++) {
        $gcd[$i][$j] = $gcd[$j][$i] = gcd($i, $j);
    }
}
$ans = 0;
for ($i = 1; $i <= $K; $i++) {
    for ($j = $i + 1; $j <= $K; $j++) {
        $gij = $gcd[$i][$j];
        $ans += $gij * 6;
        for ($k = $j + 1; $k <= $K; $k++) {
            $ans += $gcd[$gij][$k] * 6;
        }
    }
}
$ans += (1 + $K) * $K / 2;
echo $ans;

// 最大公約数（2つ）
function gcd($m, $n)
{
    if (!$n) return $m;
    return gcd($n, $m % $n);
}

// 最大公約数（3つ以上）
function gcdAll($arr)
{
    $gcd = array_pop($arr);
    foreach ($arr as $a) {
        $gcd = gcd($gcd, $a);
    }
    return $gcd;
}

Measured memory_bytes: 18680
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
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; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

	ll H, A;
	cin >> H >> A;

	ll ans = H / A;
	if (H % A != 0) ans++;

	cout << ans << endl;

	//system("pause");
}


Measured memory_bytes: 256
N, M, K=map(int, input().split())


class UnionFind():
  # 作りたい要素数nで初期化
  # 使用するインスタンス変数の初期化
  def __init__(self, n):
    self.n = n
    # root[x]<0ならそのノードが根かつその値が木の要素数
    # rootノードでその木の要素数を記録する
    self.root = [-1]*(n+1)
    # 木をくっつける時にアンバランスにならないように調整する
    self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
  def Find_Root(self, x):
    if(self.root[x] < 0):
      return x
    else:
    # ここで代入しておくことで、後の繰り返しを避ける
      self.root[x] = self.Find_Root(self.root[x])
      return self.root[x]

    # 木の併合、入力は併合したい各ノード
  def Unite(self, x, y):
    # 入力ノードのrootノードを見つける
    x = self.Find_Root(x)
    y = self.Find_Root(y)
    # すでに同じ木に属していた場合
    if (x == y):
      return 
      # 違う木に属していた場合rnkを見てくっつける方を決める
      #rnkが大きい方に結合
    elif (self.rnk[x] > self.rnk[y]):
      self.root[x] += self.root[y]
      self.root[y] = x

    else:
      self.root[y] += self.root[x]
      self.root[x] = y
      # rnkが同じ（深さに差がない場合）は1増やす
      if(self.rnk[x] == self.rnk[y]):
        self.rnk[y] += 1

  # xとyが同じグループに属するか判断
  def isSameGroup(self, x, y):
    return self.Find_Root(x) == self.Find_Root(y)

  # ノードxが属する木のサイズを返す
  def Count(self, x):
    return -self.root[self.Find_Root(x)]
  
F=[[] for i in range(N)]
B=[[] for i in range(N)]
union=UnionFind(N)
for i in range(M):
  a, b=map(int, input().split())
  union.Unite(a-1,b-1)
  F[a-1].append(b-1)
  F[b-1].append(a-1)
  
for i in range(K):
  c, d=map(int, input().split())
  B[c-1].append(d-1)
  B[d-1].append(c-1)
  
ans=[]
for i in range(N):
  x=union.Count(i)-1-len(F[i])
  for j in range(len(B[i])):
    if union.isSameGroup(i, B[i][j]):
      x-=1
  ans.append(str(x))
  
print(" ".join(ans))



Measured memory_bytes: 123936
# 参考URL https://note.nkmk.me/python-union-find/
class UnionFind():
    # 各要素の親要素の番号を格納するリスト
    # 要素が根（ルート）の場合は-(そのグループの要素数)を格納する
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    # 要素xが属するグループの根を返す
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    # 要素xが属するグループと要素yが属するグループとを併合する
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    # 要素xが属するグループのサイズ（要素数）を返す
    def size(self, x):
        return -self.parents[self.find(x)]

    # すべての根の要素をリストで返す
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

from sys import stdin
def input():
    return stdin.readline().strip()

n, m = map(int, input().split())

uf = UnionFind(n)

for _ in range(m):
    i, j = map(int, input().split())
    uf.union(i-1, j-1)

ans = 0
for i in uf.roots():
    j = uf.size(i)
    if ans < j:
        ans = j

print(ans)


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

int main(void){
	int m, f, r;
	
	while (true){
		cin >> m >> f >> r;

		if (m == -1 && f == -1 && r == -1)break;

		if (m == -1 || f == -1)cout << "F\n";
		else if (m + f >= 80) cout << "A\n";
		else if (m + f >= 65)cout << "B\n";
		else if (m + f >= 50)cout << "C\n";
		else if (m + f >= 30){
			if (r >= 50)cout << "C\n";
			else cout << "D\n";
		}
		else cout << "F\n";
	}

	return 0;
}

Measured memory_bytes: 1120
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long a = scan.nextLong();
        long b = scan.nextLong();
        int c = scan.nextInt();
        int d = scan.nextInt();
        long lcm = lcm(c, d);
        System.out.println(b - b / c - b / d + b / lcm - a + 1 + (a - 1) / c + (a - 1) / d - (a - 1) / lcm);
        scan.close();
    }
    static long gcd(long a, long b){
        return b > 0 ? gcd(b, a % b) : a;
    }
    static long lcm(long a, long b){
        return a * b / gcd(a, b);
    }
}


Measured memory_bytes: 23764
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <iostream>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define tii tuple<int,int,int>
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}
int main(){
    ll n=lin();
    ll ans=LONG_MAX/2;
    ll x=1;
    while(x*x<=n){
        if(n%x==0){
            ans=min(ans,x+n/x);
        }
        x++;
    }
    cout<<ans-2<<endl;
}


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

t = int(input())
for _ in range(t):
    n, a, b, c, d = map(int, input().split())
    memo = {0: 0, 1: d}

    def cost(N):
        if N in memo:
            return memo[N]
        ans = N * d
        ks = [2, 3, 5]
        abc = [a, b, c]
        for i in range(3):
            k = ks[i]
            coin = abc[i]
            div, mod = divmod(N, k)
            pay = mod * d + coin
            ans = min(ans, pay + cost(div))
            if mod == 0:
                continue
            pay = (k - mod) * d + coin
            ans = min(ans, pay + cost(div + 1))
        memo[N] = ans
        return ans

    print(cost(n))


Measured memory_bytes: 10860
#include <iostream>
#include <cstdio>
#define N 500005
using namespace std;

typedef long long ll;
ll s, ans[N];
string a;

ll f(ll p) {
	if (ans[p] != -1) return ans[p];
	ans[p] = 0;
	if (a[p] == '<') ans[p] = max(ans[p], f(p - 1) + 1);
	if (a[p + 1] == '>') ans[p] = max(ans[p], f(p + 1) + 1);
	return ans[p];
}

int main()
{
	ll i;
	cin >> a;
	a = ' ' + a;
	for (i = 0; i < a.size(); i++) ans[i] = -1;
	for (i = 0; i < a.size(); i++) s += f(i);
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 20376
#define _GLIBCXX_IOSTREAM
#include<bits/stdc++.h>
#define maxn 500100
using namespace std;
typedef pair<int,int> par;
struct point{
	int x1,y1,x2,y2;
	point(){}
	void scan(){
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
	}
}p[maxn];
int n,r,c,sta[maxn],tp;
vector<par> v;
int getid(int x,int y){
	if(x==0)return y;
	if(y==c)return x+c;
	if(x==r)return c-y+r+c;
	if(y==0)return r-x+c+c+r;
	return -1;
}
int main(){
	scanf("%d%d%d",&r,&c,&n);
	for(int i=1;i<=n;++i)p[i].scan();
	for(int i=1;i<=n;++i){
		if(!(p[i].x1==0||p[i].x1==r||p[i].y1==0||p[i].y1==c)||!(p[i].x2==0||p[i].x2==r||p[i].y2==0||p[i].y2==c))continue;
		int x=getid(p[i].x1,p[i].y1),y=getid(p[i].x2,p[i].y2);
		if(x>y)swap(x,y);
		v.push_back(par(x,i));
		v.push_back(par(y,-i));
//		printf("{%d,%d(%d,%d,%d,%d)}\n",getid(p[i].x1,p[i].y1),getid(p[i].x2,p[i].y2),p[i].x1,p[i].y1,p[i].x2,p[i].y2);
	}
	sort(v.begin(),v.end());
	for(auto p:v){
		if(p.second>0)sta[++tp]=p.second;
		else if(sta[tp]!=-p.second)return puts("NO"),0;
		else tp--;
	}
	puts("YES");
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

bool dump(lint A, lint B) {
    if (A % B == 0) {
        cout << 0 << endl;
        return true;
    }
    else if (A < B) {
        cout << min(A, B - A) << endl;
        return true;
    }
    return false;
}

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

    if (dump(A, B)) return 0;
    else {
        A %= B;
        dump(A, B);
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B,C;
    cin>>A>>B>>C;
    if((A+B==C)||(A+C==B)||(B+C==A)){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
X, N = map(int, input().split())
plis = list(map(int, input().split()))
lis = [i for i in range(102)]
for p in plis:
    lis.remove(p)
ans = float('inf')
for i in lis:
    if abs(i - X) < abs(ans-X):
        ans = i
print(ans)

Measured memory_bytes: 9096
n = int(input())
A = [int(x) for x in list(input().split())]
B = [[A[i], i + 1] for i in range(n)]
B.sort()
A = [j for i, j in B]
bit = [0] * (n + 2)
ans = 0
for i in range(n):
    ret = 0
    a = A[i]
    while 0 < a:
        ret += bit[a]
        a -= a & (-a)
    ans += i - ret
    a = A[i]
    while a <= n:
        bit[a] += 1
        a += a & (-a)
print(ans)



Measured memory_bytes: 38808
h, w = gets.split.map &:to_i
a = Array.new(h+2, Array.new(w+2, 0))
a[0] = "#"*(w+2)
a[-1] = "#"*(w+2)
for i in 1..h
  a[i] = "#"+gets.chomp+"#"
end

a.each do |r|
  puts r
end
  

Measured memory_bytes: 1788
#include <iostream>
#include <string>

using namespace std;

int main(){
    
    string p[3];
    cin>>p[0]>>p[1]>>p[2];
    
    char now = 0;
    char next;
    
    while(!p[now].empty()){
        next = p[now].front() - 'a';
        p[now].erase(p[now].begin());
        now=next;
    }
    
    cout<<char('A'+now);
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define log(x) cerr<<x<<endl
#define pb push_back
#define rep(i,n) for(int i = 0;i < n;++i)
using namespace std;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && b != c){
        cout << "Yes" << endl;
    }else if(a != b && b == c){
        cout << "Yes" << endl;
    }else if(a != c && c == b){
        cout << "Yes" << endl;
    }else if(b != c && c == a){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        List<Integer> input = Arrays.stream(sc.nextLine().split("")).map(e -> Integer.valueOf(e)).collect(Collectors.toList());

        int start0 = 0;
        int start0TargetNum = 0;
        int start1 = 0;
        int start1TargetNum = 1;

        for (int tar : input) {
            if (tar != start0TargetNum) start0++;
            if (tar != start1TargetNum) start1++;

            start0TargetNum = change(start0TargetNum);
            start1TargetNum = change(start1TargetNum);
        }

        if (start0 < start1) {
            System.out.println(start0);
        } else {
            System.out.println(start1);
        }
    }

    public static int change(int tar) {
        int res = 0;
        if (tar == 0) {
            res = 1;
        } else {
            res = 0;
        }
        return res;
    }
}


Measured memory_bytes: 37312
#include<bits/stdc++.h>
using namespace std;
char s[15];
int main()
{
    int n,l,r,mid;
    int M1,M2;
    cin>>n;
    cout<<"0"<<endl;
    cin>>s;
    if(s[0]=='V')
       return 0;
    if(s[0]=='M')  
	M1=1;
    else  
	M1=0;
    l=0,r=n;
    for(;l<r;)
    {
        mid=(r+l)/2;
        cout << mid << endl;
        cin>>s;
        if(s[0]=='V')
          return 0;
        if(s[0]=='M')  M2=1;
        else  M2=0;
        int t=(mid-l);
        if (t%2==0)
        {
            if(M1==M2) 
			l=mid;
            else 
			r=mid;
        }
        else
        {
            if(M1==M2) 
			r=mid;
            else 
			l=mid,M1=M2;
        }
    }
    cout<<flush;
    return 0;
}

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

using namespace std;
using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto&& x:a)cin >> x;
    bool x = false;
     if(is_sorted(a.begin(), a.end()))x = true;
    for(int i=0;i<n;i++)for(int j=i+1;j<n;j++){
        vector<int> b = a;
        swap(b[i], b[j]);
        if(is_sorted(b.begin(), b.end()))x = true;
    }
    cout << (x ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = "" + in.nextInt();

        int rs = 0;
        for (char c : s.toCharArray()) {
            if (c == '2') rs++;
        }

        System.out.println(rs);
    }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  ll ans=0;
  rep(i,n){
    if(i%2==0&&a[i]%2==1) ans++;
  }
  COUT(ans);
}


Measured memory_bytes: 3584
// Repeated Substitution with Sed
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			String[] alpha = new String[n];
			String[] beta = new String[n];
			for (int i = 0; i < n; i++) {
				alpha[i] = scanner.next();
				beta[i] = scanner.next();
			}
			String start = scanner.next();
			String goal = scanner.next();
			Queue<State> queue = new LinkedList<State>();
			queue.add(new State(0, start));
			int result = -1;
			while (!queue.isEmpty()) {
				State state = queue.poll();
				String str = state.str;
				if (str.equals(goal)) {
					result = state.num;
					break;
				}
				for (int i = 0; i < n; i++) {
					String t = str.replace(alpha[i], beta[i]);
					if (!str.equals(t) && t.length() <= goal.length()) {
						queue.add(new State(state.num + 1, t));
					}
				}
			}
			System.out.println(result);
		}
		scanner.close();
	}
}

class State {
	int num;
	String str;

	State(int n, String s) {
		num = n;
		str = s;
	}
}

Measured memory_bytes: 62328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
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; }

int main(){
    ll N, K;
    cin >> N >> K;
    ll cnt = 0;
    while(N > 0){
        N /= K;
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
// ini template jangan diedit
#include <bits/stdc++.h>
#include <math.h>
//macros goblok


#define forian(i,a,n) for(ll i=a;i<=n;i++)
#define pb push_back
#define popb pop_back
#define ll long long
#define Faqih using
#define itu namespace
#define Ganteng_Titik std; 
Faqih itu Ganteng_Titik
//int N; int a=0;
//int arr[110];

void test_case()
{
	const int NMAX =107;
	char str[NMAX];
	string kata;
	int k;
	cin >> k;
	cin >> kata;
//	cout << "panjang kata: " << kata.length() << "\n";
	if (kata.length() <= k ){
		cout << kata << "\n";
	}
	else {
		for (int i=0; i<k;i++){
			cout << kata[i];
		}
		cout << "...\n";
	}
//	for (int i=0;i<NMAX;i++){
//		cin >> str[i];
//	}
//	for (int j=0;j<k;j++){
//		cout << str[j];
//	}
	cout << "\n";
	
}
	
//int main() // Main Program for Code Jam/Kick Start
//{
//	ios::sync_with_stdio(0);
//	cin.tie(0);
//	int t;
//	cin >> t;
//	for (int i=1;i<=t;i++)
//	{
//	cout << "Case #" << i << ": ";
//	test_case();
//	}
//return 0;
//}

//int main() // Main Program for Codeforces
//{
//	ios::sync_with_stdio(0);
//	cin.tie(0);
////	int t;
////	cin >> t;
////	while (t--)
//	test_case();
//// Type Your Body of Code Here
//return 0;
//}


int main() // Main Program for At Coder
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	test_case();
return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

int main(int argc, char **argv) {
  int n, q, i, e, cnt, ret;
  int s[10000];

  ret = fscanf(stdin, "%d", &n);
  if (errno != 0) perror("fscanf");
  if (ret < 1) exit(1);

  for (i = 0; i < n; ++i) {
    ret = fscanf(stdin, "%d", &s[i]);
    if (errno != 0) perror("fscanf");
    if (ret < 1) break;
  }

  ret = fscanf(stdin, "%d", &q);
  if (errno != 0) perror("fscanf");
  if (ret < 1) exit(1);

  for (cnt = 0; q > 0; --q) {
    ret = fscanf(stdin, "%d", &e);
    if (errno != 0) perror("fscanf");
    if (ret < 1) break;

    for (i = 0; i < n; ++i) {
      if (s[i] == e) {
        ++cnt;
        break;
      }
    }
  }

  printf("%d\n", cnt);
  exit(0);
}


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

long long x[100001];

int main() {
	
    long long n, l, mx = 0;

    cin >> n;

for (int i = 0; i < n; i ++){
cin >> l;
l ++;
x[l] ++;
x[l+1] ++;
x[l-1] ++;
}

for (int i = 0; i < 100001; i ++){
mx = max(x[i],mx);
}
cout << mx;
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

using i64=long long;

i64 f(i64 b, i64 n) {
    i64 s=0;
    while (n) {
        s += n % b;
        n /= b;
    }
    return s;
}

int main() {
    i64 n, s;
    scanf("%lld %lld", &n, &s);

    if (n == s)
        return !printf("%lld\n", n+1);

    i64 ub=sqrt(n);
    for (i64 b=2; b<=ub; ++b)
        if (f(b, n) == s)
            return !printf("%lld\n", b);

    for (i64 p=ub+1; --p;) {
        i64 b=(n-s)/p+1;
        if (b < 2) continue;
        if (f(b, n) == s)
            return !printf("%lld\n", b);
    }

    return !printf("-1\n");
}


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

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

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

int main(){
    int N, M; cin >> N >> M;
    vector<int> a( N );
    REP( i, N ) cin >> a[i];

    sort( ALL( a ) );

    vector<P> cb;
    REP( i, M ){
        int b, c; cin >> b >> c;
        cb.emplace_back( c, b );
    }

    sort( ALL( cb ), greater<>() );

    int t = 0;
    ll ans = 0;
    REP( i, N ){
        if( a[i] < cb[t].first ){
            ans += cb[t].first;
            cb[t].second--;
            if( cb[t].second == 0 ) t++;
        }else{
            ans += a[i];
        }
    }

    cout << ans << endl;


}

/*

*/

Measured memory_bytes: 1912
IDENTIFICATION DIVISION.
 PROGRAM-ID. TEST132.
 
 ENVIRONMENT DIVISION.
 
 DATA DIVISION.
 WORKING-STORAGE SECTION.

 01 INP.
  03 N1 PIC 9(1).
  03 N2 PIC 9(1).
  03 N3 PIC 9(1).
  03 N4 PIC 9(1).

 PROCEDURE DIVISION.

  ACCEPT INP.

  EVALUATE TRUE
   WHEN (N1 = N2) AND (N3 = N4) AND (N1 NOT= N3)
   WHEN (N1 = N3) AND (N2 = N4) AND (N1 NOT= N2)
   WHEN (N1 = N4) AND (N2 = N3) AND (N1 NOT= N2)
    DISPLAY 'Yes'

   WHEN OTHER
    DISPLAY 'No'

  END-EVALUATE.

  STOP RUN. 

Measured memory_bytes: 632
fn main() {
    let mut buf = String::new();
    let handle = std::io::stdin();
    let n: usize = {
        handle.read_line(&mut buf).unwrap();
        let tmp = buf.trim().parse().unwrap();
        buf.clear();
        tmp
    };
    let mut alist: Vec<usize> = {
        handle.read_line(&mut buf).unwrap();
        let tmp = buf
            .trim()
            .split_whitespace()
            .map(|a| a.parse().unwrap())
            .collect();
        buf.clear();
        tmp
    };
    let mut blist: Vec<usize> = {
        handle.read_line(&mut buf).unwrap();
        let tmp = buf
            .trim()
            .split_whitespace()
            .map(|a| a.parse().unwrap())
            .collect();
        buf.clear();
        tmp
    };

    let mut lack_point = 0;
    // count lack point
    let mut lacklist = 0;
    let remainlist: Vec<(usize, usize)> = alist
        .into_iter()
        .zip(blist)
        .filter(|&(a, b)| {
            if b < a {
                true
            } else if a == b {
                false
            } else {
                lack_point += b - a;
                lacklist += 1;
                false
            }
        })
        .collect();

    let mut diff: Vec<usize> = remainlist.into_iter().map(|(a, b)| a - b).collect();
    diff.sort();
    if lacklist == 0 {
        println!("{}", 0);
    } else {
        let mut can = false;
        let mut over_point_index = 0;
        for (i, d) in diff.into_iter().rev().enumerate() {
            if lack_point <= d {
                over_point_index = i + 1;
                can = true;
                break;
            } else {
                lack_point -= d;
            }
        }
        if can {
            println!("{}", over_point_index + lacklist);
        } else {
            println!("{}", -1);
        }
    }
}


Measured memory_bytes: 10492
def main():
    N, M = (int(i) for i in input().split())
    AB = [[int(i) for i in input().split()] for j in range(M)]
    AB.sort(key=lambda p: p[1])
    ma = AB[0][1]
    ans = 1
    for a, b in AB[1:]:
        if a < ma:
            continue
        else:
            ma = b
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 65416
#include<stdio.h>
int main(){
int n,a[7],i,x;
while(scanf("%d",&n),n){
for(i=0;i<7;i++)
a[i]=0;
for(i=0;i<n;i++){
scanf("%d",&x);
if(x<10)
a[0]++;
else if(x<20)
a[1]++;
else if(x<30)
a[2]++;
else if(x<40)
a[3]++;
else if(x<50)
a[4]++;
else if(x<60)
a[5]++;
else a[6]++;
}
for(i=0;i<7;i++)
printf("%d\n",a[i]);
}
return 0;
}

Measured memory_bytes: 408
n, k = list(map(int, input().split()))
steps = list(map(int, input().split()))

dp = [0] * n
dp[0] = 0;

for i in range(1, n):
    step_to = steps[i]
    dp[i] = min(
        [
            dp_from + abs(step_to - step_from)
            for dp_from, step_from in zip(
                dp[max(0, i - k):i], steps[max(0, i - k):i])
        ]
    )

print(dp[n - 1])


Measured memory_bytes: 13980
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.trim().split('\n');

const getMax = (limit, numbers) => {
	return numbers.reduce((acc, next) => {
		if (next > acc) {
			if (next <= limit) {
				return next
			}
			return acc	
		}
		return acc
	}, 0);
}

const getHighestPriceSum = (budget, priceList) => {
	const sums= [];

	for (i=0; i<priceList.length; i++) {
		const leftAddend = priceList[i]

		for (j=0; j<priceList.length; j++) {
			if (i !== j) {
				const rightAddend = priceList[j]
				sums.push(leftAddend + rightAddend);
			}
		}
	}

	return getMax(budget, sums)
};

let ctr = 0;

const dataSets = [];

const objHolder = {};

while (line = lines.shift()) {
	if (ctr % 2 === 0) {
		const budget = line.split(' ').map(Number)[1];
		objHolder.budget = budget;
	} else {
		const priceList = line.split(' ').map(Number);
		objHolder.priceList = priceList;
		dataSets.push(Object.assign({}, objHolder))
	}
	ctr++
}

dataSets.forEach(obj => {
	const { budget, priceList } = obj;
	const highest = getHighestPriceSum(budget, priceList)
	if (highest === 0) {
		console.log('NONE')
	} else {
		console.log(highest)
	}
	
})




Measured memory_bytes: 94480
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const int INF = INT_MAX / 2;

int main(){
    string s; cin >> s;
    int N = s.size();
    int ans = INF;
    for (int i = 0; i < N-2; i++)
    {
        int k = stoi(s.substr(i, 3));
        ans = min(ans, abs(k-753));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
   
int i,d,b,s,t,y;
   while(scanf("%d", &d)!= EOF) {
   int sum=0;
   b=600/d;
           for(i=1;i<b;i++){
           y=i*d;
           t=y*y;
           s=d*t;
           sum+=s;
       }
       printf("%d\n",sum);
       if(d == 0) {
   break;
   }
       }
   return 0;
   }


Measured memory_bytes: 2060
var s,t:string;
var i,len:longint;
begin
  readln(s);readln(t);len:=length(s);
  i:=1;
  while s<>t do
  begin
    s:=s[len]+s;delete(s,len+1,1);i:=i+1;
    if i>len+2 then begin writeln('No');halt;end;
  end;
  writeln('Yes');
end.

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

bool	issmall(char c)
{
	return (c >= 'a' && c <= 'z');
}

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

	int n;
	cin >> n;
	vector<int> V(n);
	rep(i, n)
		cin >> V.at(i);
	int sum;
	sum = accumulate(V.begin(), V.end(), 0);
	int m;
	cin >> m;
	rep(i, m)
	{
		int p, x;
		cin >> p >> x;
		cout << sum - V.at(p - 1) + x << endl;
	}
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
  int i;
  char st,al[53] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
   
  do{
    scanf("%c", &st);
 
    for(i=0;i<52;i++)
      if(al[i] == st){
        st = al[ (i+26)%52 ];
        break;
      }
 
    printf("%c", st);
 
  }while(st != '\n');
 
  return 0;
}


Measured memory_bytes: 2100
import java.util.Scanner;

public class Main {

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

        long N = sc.nextLong();
        double upper = Math.sqrt(N);
        long min = N;
        for (int i = 1; i <= upper; i++) {
            if (N % i == 0) {
                long j = N / i;
                min = Math.min(min, i + j - 2);
            }
        }
        System.out.println(min);
    }

}

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

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

int n, hmax;
bool maps[5000][5];

int serch(int x, int l) {
	for (int i = hmax; i >= 0; i--) {
		REP(j, l) if (maps[i][x + j]) return i + 1;
	}
	return 0;
}

int check(int y, int l) {
	REP(i, l) {
		bool flag = true;
		REP(j, 5) if (!maps[y + i][j]) flag = false;
		if (flag) return y + i;
	}
	return -1;
}

void bset(int d, int p, int q) {
	int hl = d == 2 ? p : 1;
	int xl = d == 1 ? p : 1;
	int hpos = serch(q - 1, xl);
	
	if (d == 1) REP(i, p) maps[hpos][q + i - 1] = true;
	else REP(i, p) maps[hpos + i][q - 1] = true;
	hmax = max(hmax, hpos + hl);
	
	int tmp;
	while ((tmp = check(hpos, hl)) != -1) {
		REP(i, 5) maps[tmp][i] = false;
		FOR(i, tmp, hmax) {
			REP(j, 5) swap(maps[i][j], maps[i + 1][j]);
		}
		hmax--;
	}
}

int main() {
	while (cin >> n, n) {
		memset(maps, 0, sizeof(maps));
		hmax = 0;
		
		while (n--) {
			int d, p, q;
			scanf("%d %d %d", &d, &p, &q);
			bset(d, p, q);
		}
		cout << count(maps[0], maps[5000], true) << endl;
	}
	return 0;
}

Measured memory_bytes: 1276
import java.util.*;

/**
 * x==black, o==whiteとする xo -> ox oxoo -> ooxo oxox -> ooxx xxoo -> xoxo xxox ->
 * xoxx
 * 
 * @author glycine
 *
 */
public class Main {
	String S;
	List<Integer> origIndexes;
	long result;

	Main() {
		Scanner in = new Scanner(System.in);
		S = in.nextLine();
		in.close();
		this.origIndexes = new ArrayList<>();
	}

	void calc() {
		for (int i = 0; i < S.length(); ++i) {
			char c = S.charAt(i);
			if (c == 'W') {
				origIndexes.add(i);
			}
		}
		long result = 0;
		for (int i = 0; i < this.origIndexes.size(); ++i) {
			result += (long) (this.origIndexes.get(i) - i);
		}
		this.result = result;
	}

	public static void main(String[] args) {
		Main ins = new Main();
		ins.calc();
		System.out.println(ins.result);
	}
}

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

int main(){
    int N;
    cin>>N;
    int ans=0;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        while(a>0&&a%2==0){
            a/=2; ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n,r[200000],i,j,max1=-1000000000,min1;
  cin >> n;
  for(i=0;i<n;i++) cin >> r[i];
  min1=r[0];
  for(i=1;i<n;i++){
    max1=max(r[i]-min1,max1);
    min1=min(r[i],min1);
  }
  cout << max1 << endl;
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  double ans;
  
  if (n%2 == 0) {
    ans = (double)n/2/n;
    printf("%.10f",ans);
  }
  
  else{
    ans = (double)(n+1)/2/n;
    printf("%.10f", ans);
  }
      
}

Measured memory_bytes: 256