akhauriyash/Code-Regression huggingface dataset:
//file_name:ABC43_D.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    string s;
    cin >> s;
    rep(i,s.size()-1){
        if(s[i]==s[i+1]){
            cout << i+1 << ' ' << i+2 << endl;
            return 0;
        }
    }
    rep(i,s.size()-2){
       if(s[i]==s[i+2]){
            cout << i+1 << ' ' << i+3 << endl;
            return 0;
        } 
    }



    cout << "-1 -1" << endl;
    return 0;
}



Measured memory_bytes: 512
package main

import "fmt"

func judge(k int64, n int, a int, b int, h []int) bool {
	var sum int64 = 0
	for i := 0; i < n; i++ {
		var t int64 = int64(h[i]) - k*int64(b)
		if t > 0 {
			sum += (t + int64(a-b-1)) / int64(a-b)
			if sum > k {
				return false
			}
		}
	}
	return true
}

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)

	h := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&h[i])
	}

	var low, high int64 = 0, 1000000009

	for low < high {
		mid := (low + high) / 2
		if judge(mid, n, a, b, h) {
			high = mid
		} else {
			low = mid + 1
		}
	}

	fmt.Println(low)
}

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


signed main(){
    int n, t, a, x;
    scanf("%d%d%d", &n,&t,&a);
    double mn = 100000, tmp;
    int pos;
    for(int i = 1; i <= n; i++){
        scanf("%d", &x);
        tmp = 1.0*t- x*0.006;
        if(abs(tmp-a)<mn){
            mn=abs(tmp-a);
            pos=i;
        }
    }
    printf("%d\n", pos);
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace atcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var buffer = Console.ReadLine().Split();
            var num = new List<long>();
            foreach (var v in buffer)
                num.Add(long.Parse(v));

            var max = long.MinValue;
            for (int i = 0; i < 2; i++)
                for (int j = 2; j < 4; j++)
                    if (max < num[i] * num[j]) max = num[i] * num[j];

            Console.WriteLine(max);
        }
    }
}


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

int main() {
  int H,W;
  cin >> H >> W;
  vector<string> maze(H);
  rep(i,H){
    cin >> maze.at(i);
  }
  //BFS
  vector<vector<int>> dist(H,vector<int>(W,-1));
  dist.at(0).at(0) = 0;
  queue<pair<int,int>> que;
  pair<int,int> start = make_pair(0,0);
  que.push(start);
  while(!que.empty()){
    pair<int,int> p = que.front();
    que.pop();
    int pf = p.first;
    int ps = p.second;
    if(pf>0){
      if(maze.at(pf-1).at(ps) == '.' && dist.at(pf-1).at(ps) == -1){
        pair<int,int> pa = make_pair(pf-1,ps);
        que.push(pa);
        dist.at(pf-1).at(ps) = dist.at(pf).at(ps)+1;
      }
    }
    if(ps>0){
      if(maze.at(pf).at(ps-1) == '.' && dist.at(pf).at(ps-1) == -1){
        pair<int,int> pb = make_pair(pf,ps-1);
        que.push(pb);
        dist.at(pf).at(ps-1) = dist.at(pf).at(ps)+1;
      }
    }
    if(pf<H-1){
      if(maze.at(pf+1).at(ps) == '.' && dist.at(pf+1).at(ps) == -1){
        pair<int,int> pc = make_pair(pf+1,ps);
        que.push(pc);
        dist.at(pf+1).at(ps) = dist.at(pf).at(ps)+1;
      }
    }
    if(ps<W-1){
      if(maze.at(pf).at(ps+1) == '.' && dist.at(pf).at(ps+1) == -1){
        pair<int,int> pd = make_pair(pf,ps+1);
        que.push(pd);
        dist.at(pf).at(ps+1) = dist.at(pf).at(ps)+1;
      }
    }
  }
  int ans = H*W - dist.at(H-1).at(W-1);
  rep(i,H){
    rep(j,W){
      if(maze.at(i).at(j) == '#'){
        ans--;
      }
    }
  }
  if(dist.at(H-1).at(W-1) == -1){
    cout << -1 << endl;
  }
  else{
    cout << ans-1 << endl;
  }
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn long long

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


int main()
{
  int w, h, n;
  cin >> w >> h >> n;
  vector<p> v(n,{0,0});
  vector<int> a(n, 0);
  int beginX = 0;
  int beginY = 0;

  for(int i = 0; i < n; i++)
  {
    cin >> v[i].first >> v[i].second >> a[i];
    switch (a[i]) {
      case 1:
        if(v[i].first >= w)
        {
          cout << 0 << endl;
          return 0;
        }
        else beginX = max(beginX, v[i].first);
        break;
      case 2:
        if (v[i].first <= beginX)
        {
          cout << 0 << endl;
          return 0;
        }
        else w = min(w, v[i].first);
        break;
      case 3:
        if(v[i].second >= h)
        {
          cout << 0 << endl;
          return 0;
        }
        else beginY = max(beginY,v[i].second);
        break;
      case 4:
        if (v[i].second <= beginY)
        {
          cout << 0 << endl;
          return 0;
        }
        else h = min(h, v[i].second);
        break;
    }
    // cout << "========-yyj" << endl;
    // cout << beginX << endl;
    // cout << w << endl;
    // cout << beginY << endl;
    // cout << h << endl;
  }
  cout << abs(beginX - w) * abs(beginY - h) << endl;
}

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

#define REP(i,n) for (int (i) = 0;(i) < (n);++(i))
#define FORN(i,a,b) for (int i = (a);i <=(b); ++i)
#define FORD(i,a,b) for (int i = (a); i >= (b); --i)
#define SORT(list) sort(ALL((list)));
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define IOS  cin.tie(0),cout.tie(0); ios::sync_with_stdio(false);
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;

const ll mod=1000000007;
// int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head


int main()   {  
	IOS
   	int n;                                                             
	cin >> n;	
	string s1, s2;
	cin >> s1 >> s2;
	string ans = "";
	REP(i, SZ(s1)) {
		ans += s1[i];
		ans += s2[i];
	} 

	cout << ans << '\n';
}  
  

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

#define precise(n,k) fixed<<setprecision(k)<<n

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
 
int main() {
    
    string s;
    
    cin >> s;
    
    int n = s.size();
    
    int x = 0;
    
    for(int i = 0; i < n; ++i) {
        if(s[i] == '-') {
            x--;
        } else if(s[i] == '+'){
            x++;
        }
    }
    
    cout << x << endl;
   
    
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<62;
const int IINF = 1000000000;
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; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;

int main(){

    string S, T; cin >> S >> T;
    int sn = S.size();
    int tn = T.size();

    int match = 0;

    rep(i,sn){
        if (i + tn > sn) continue;
        int tmp = 0;
        rep(j,tn){
            if (S[i+j] == T[j]){
                tmp++;
            }
        }

        match = max(match, tmp);
    }

    int ans = tn - match;
    cout << ans << endl;

}


Measured memory_bytes: 3632
import java.util.*;
public class Main{
  public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  int ramen = 700;
  String s = sc.next();
    for (int i = 0; i < s.length(); i++){
    if(s.charAt(i)=='o'){
      ramen += 100;
    }
    }
  System.out.println(ramen);
  }
}


Measured memory_bytes: 23764
def print_list(r):
    for i in range(len(r)):
        if i != len(r)-1:
            print (r[i], end=' ')
        else:
            print(r[i])

n=int(input())
r=list(map(int,input().split()))
flag = 1
change_num = 0
while flag:
    flag = 0
    for j in range(n-1, 0, -1):
        if r[j] < r[j-1]:
            v = r[j]
            r[j] = r[j-1]
            r[j-1] = v
            flag = 1
            change_num += 1
print_list(r)
print(change_num)


Measured memory_bytes: 5608
#include<stdio.h> 
int main(void) {
    int i;
	int n;
	int array1[100];
	int array2[100];
   	scanf("%d", &n);
	
	for(i = 0; i < n; i++) {
		scanf("%d", &array1[n-i-1]); 
	}

	for(i = 0; i < n; i++) {
		printf("%d", array1[i]);
		if(i < n-1) {
			printf(" ");
		} else {
			printf("\n");
		}
	}	

	return 0;
}

Measured memory_bytes: 600
y,m,d=list(map(int,input().split("/")))
if y>2019:
  print("TBD")
elif y<2019:
  print("Heisei")
elif m>4:
  print("TBD")
elif m<4:
  print("Heisei")
elif d>30:
  print("TBD")
else:
  print("Heisei")

Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#define ll long long
#define rep(i, a, b) for(int i = a; i <= (int)b; i++)
void read(int &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
void read(ll &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
using namespace std;
const int maxn = 100010;
int n, Size[maxn], weight[maxn];
ll d[maxn], dis[maxn];
vector < pair <int, int > > ans;
vector <int> edge[maxn];
void dfs(int u, int fa) {
    Size[u] = 1;
    for(int i = 0; i < edge[u].size(); i++) if(edge[u][i] != fa) {
        int v = edge[u][i];
        dfs(v, u);
        dis[u] += dis[v] + Size[v];
        Size[u] += Size[v];
    }
}
int main()
{
    read(n);
    map <ll, int> mp;
    rep(i, 1, n) read(d[i]), mp[d[i]] = i, weight[i] = 1;
    rep(times, 1, n - 1) {
        map <ll, int> :: iterator it = --mp.end();
        int i = it -> second;
        ll want = d[i] + 2 * weight[i] - n;
        if(mp.find(want) == mp.end() || mp[want] == i) {
            puts("-1");
            return 0;
        }
        int j = mp[want];
        weight[j] += weight[i];
        ans.push_back(make_pair(i, j));
        edge[i].push_back(j), edge[j].push_back(i);
        mp.erase(--mp.end());
    }
    dfs(1, 0);
    if(dis[1] != d[1]) {
        puts("-1");
        return 0;
    }
    rep(i, 0, n - 2) printf("%d %d\n", ans[i].first, ans[i].second);
    return 0;
}

Measured memory_bytes: 20984
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

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

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int k;
    ll a[112345];

    cin >> k;

    REP(i, k)
    cin >> a[i];

    if (a[k - 1] != 2)
    {
        cout << -1 << endl;
        return 0;
    }

    ll l = 0;
    ll r = 2 + 1e9 * k;

    ll mi, ma;

    bool check = false;

    while (r - l > 0)
    {
        ll mid = (l + r) / 2;

        ll num = mid;

        REP(i, k)
        {
            num = num - num % a[i];
        }

        if (num == 2)
        {
            r = mid;
            check = true;
        }
        else if (num > 2)
        {
            r = mid - 1;
        }
        else
        {
            l = mid + 1;
        }
    }

    if (!check)
    {
        cout << -1 << endl;
        return 0;
    }

    mi = l;

    l = 0;
    r = 2 + 1e9 * k;

    while (r - l > 0)
    {
        ll mid = (l + r + 1) / 2;

        ll num = mid;

        REP(i, k)
        {
            num -= num % a[i];
        }

        if (num == 2)
        {
            l = mid;
        }
        else if (num > 2)
        {
            r = mid - 1;
        }
        else
        {
            l = mid + 1;
        }
    }

    ma = l;

    if (ma < mi)
        cout << -1 << endl;
    else
        cout << mi << " " << ma << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

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

    int a[3][3],b[3][3];

    memset(b,0,sizeof(b));

    rep(i,3)rep(j,3)cin >> a[i][j];

    int N;
    cin >> N;

    rep(_,N){
        int c;
        cin >> c;

        rep(i,3)rep(j,3){
            if(a[i][j] == c){
                b[i][j] = 1;
            }
        }
    }

    rep(i,3){
        int tmp = 1;
        rep(j,3){
            tmp *= b[i][j];
        }

        if(tmp){
            cout << "Yes" << endl;
            return 0;
        }
    }

    rep(i,3){
        int tmp = 1;
        rep(j,3){
            tmp *= b[j][i];
        }

        if(tmp){
            cout << "Yes" << endl;
            return 0;
        }
    }

    if(b[0][0] && b[1][1] && b[2][2]){
        cout << "Yes" << endl;
            return 0;
    }

    if(b[2][0] && b[1][1] && b[0][2]){
        cout << "Yes" << endl;
            return 0;
    }

    cout << "No" << endl;

}

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

int main() {
	int N;
	string S;

	cin >> N;
	
	cin >> S;
	
	int cow = 0;

	/*
	N - 3�ɂ��闝�R�Ƃ��āAString��i����i+2�܂ł����āA���O����n�܂�̂ŁA
	�Ō�͓񌅁A�ꌅ�ɂȂ�̂Œ��ׂ�K�v���Ȃ��̂� i <= N-3 �ɂ��Ă���B
	i <= N-3�ɂ��Ȃ������ꍇ�ARunTime Error(���s���G���[)�ɂȂ�\��������B
	�܂��AN < N-3 �ɂ����ꍇ�A�Ⴆ�� N ���P�O���Ƃ��āA�񌅂ɂȂ�����O�̂V�񒲂ׂ����̂ɁA
	i < N-3 �Ƃ����ꍇ�Ai < 7 �܂�A(i��7����(7���܂܂Ȃ�)�̊�)�ƂȂ�̂�7��ڂ����s����Ȃ��Ȃ�A
	Wrong answer�ƂȂ�ꍇ������B
	*/
	for (int i = 0; i <= N-3; i++) {
		if (S.at(i) == 'A' && S.at(i + 1) == 'B' && S.at(i + 2) == 'C') {
			cow++;
		}
	}

	cout << cow << endl;
	
	return 0;

}

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

const int INF = 1012345678;

int digit_sum(int x)
{
	int sum = 0;
	while(x > 0)
	{
		sum += x % 10;
		x /= 10;
	}

	return sum;
}

int main()
{
	int n = 0;
	cin >> n;
	vector<int> list(n);
	for (int i = 0; i < n; i++)
	{
		cin >> list[i];
	}
	sort(list.begin(), list.end(), greater<int>());
	int odd = 0;
	int even = 0;
	for (int i = 0; i < n; i++)
	{
		if (i == 0 || i % 2 == 0)
		{
			even += list[i];
		}
		else
		{
			odd += list[i];
		}
	}
	cout << even - odd << "\n";
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return a
}

func dfs(a int, ch []int, t [][]int) {
	for _, e := range t[a] {
		if ch[e] == 0 {
			ch[e] = 1
			dfs(e, ch, t)
		}
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	n := scanInt()
	m := scanInt()
	t := make([][]int, n)
	for i := 0; i < m; i++ {
		x := scanInt() - 1
		y := scanInt() - 1
		_ = scanInt()
		t[x], t[y] = append(t[x], y), append(t[y], x)
	}
	ch := make([]int, n)
	ans := 0
	for i := 0; i < n; i++ {
		if ch[i] == 0 {
			ans++
			ch[i] = 1
			dfs(i, ch, t)
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 34376
/*adarsh*/
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define int long long int
#define vec vector<int>
#define all(xx) xx.begin(),xx.end()
#define IO ios::sync_with_stdio(0);cin.tie(0); cout.tie(0) ; 
#define adsw  int Test ;cin >> Test; while(Test--)
using namespace std;

int32_t main(){ IO 
   
   int x ;
   cin >> x;
   
   if(x>=30)
   {
       cout<<"Yes";
   }
   else
   {
       cout<<"No";
   }
   cout<<endl;


    return 0;
} 


Measured memory_bytes: 3648
n = gets.to_i
a = gets.split.map(&:to_i)

vs = Array.new(0)
vs.push(a[0])
id = 0

mode = 0 # search: 0..down, 1..up
for i in 1..(n-1)
  if mode == 0
    if vs[id] > a[i]
      vs[id] = a[i]
    elsif vs[id] < a[i]
      vs.push(a[i])
      id += 1
      mode = 1
    end
  elsif mode == 1
    if vs[id] < a[i]
      vs[id] = a[i]
    elsif vs[id] > a[i]
      vs.push(a[i])
      id += 1
      mode = 0
    end
  end
end

id -= 1 if id % 2 == 0
mon = 1000
cnt = 0
for i in 0..id
  if i % 2 == 0
    cnt = mon / vs[i]
    mon -= vs[i]*cnt   
  else
    mon += cnt*vs[i]
    cnt = 0
  end
end
puts mon

Measured memory_bytes: 14348
<?php

$counts = [];
fscanf(STDIN, "%d %d %d %d", $counts[0], $counts[1], $counts[2], $k);

$cakes = [];
for ($i = 0; $i < 3; $i++) {
    $input = trim(fgets(STDIN));
    $cakes[$i] = explode(' ', $input);
    rsort($cakes[$i]);
}

$calc = function($p) use ($cakes) {
    $sum = 0;
    for ($i = 0; $i < 3; $i++) {
        $j = $p[$i];
        $n = $cakes[$i][$j];
        $sum += $n;
    }
    return $sum;
};
$kcalc = function($p) {
    return implode("_", $p);
};

$cp = [0,0,0];
$key = $kcalc($cp);
$used = [$key => true];
echo $calc($cp).PHP_EOL;

$add_current = function(&$current, $new) use($calc, $kcalc, $used, $counts) {
    for ($j = 0; $j < 3; $j++) {
        $tmp = $new;
        $tmp[$j]++;
        if ($tmp[$j] >= $counts[$j]) {
            continue;
        }
        $key = $kcalc($tmp);
        if (array_key_exists($key, $current) || array_key_exists($key, $used)) {
            continue;
        }
        $current[$key] = $calc($tmp);
    }
};

$current = [];
$add_current($current, $cp);

for ($i = 1; $i < $k; $i++) {
    $key = array_search(max($current), $current);
    echo $current[$key].PHP_EOL;
    $add_current($current, explode('_', $key));
    $used[$key] = true;
    unset($current[$key]);
}

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

int main() {
    int h,w;
    while(true){
        cin >> h >> w;
        if (w==0 && h ==0) {
            break;
        }
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(i==0 || j==0 || i ==h-1 || j == w-1){
                    cout << '#';
                }else{
                    cout << '.';
                }
                
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3040
n = int(input())
a = list(map(int, input().split()))
mn = min(a)
mx = max(a)
bb = mx if abs(mx) >= abs(mn) else mn
base = a.index(bb)
print(n + n - 1)
[print(base+1, i+1) for i in range(n)]
if abs(mx) >= abs(mn):
    [print(i, i+1) for i in range(1,n)]
else:
    [print(i+1, i) for i in range(1,n)[::-1]]


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

int main() {
	long long x; cin >> x;

	long long num11 = x / 11;
	int m = x % 11;
	long long minAction = 2 * num11;
	if (m > 0) minAction++;
	if (m > 6) minAction++;

	cout << minAction << endl;

	return 0;
}

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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    vector<int> v;
    for(int i=0;i<n;++i){
        int a;
        cin >> a;
        v.push_back(a);
    }

    vector<int> dp(n+1, -1);
    dp[1] = v[0];
    for(int i=1;i<n;++i){
        int valid = n, invalid = 0;
        while(abs(valid-invalid) > 1){
            int mid = (valid + invalid) / 2;
            if(v[i] > dp[mid])valid = mid;
            else invalid = mid;
        }
        dp[valid] = v[i];
    }

    int ans = 0;
    for(int i=1;i<=n;++i){
        if(dp[i] != -1)ans = i;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1144
#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>;

int main(){
  int N ;
  cin >> N;
  vector<int>A(N);
  vector<int>B(N-1);
  
  rep(i,N-1)cin >> B[i];
  
  ll ans = 0;
  
  rep(i,N-1){
    if(i == 0){
      A[i] = B[i];
      A[i+1] = B[i]; //最初の2個は決まっている
    }
    else{
      A[i+1] = B[i];
      A[i] = min(A[i],B[i]);
    }
    ans += A[i];
  }
  ans += A[N-1];
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define scantype int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())
#define debug(x) cerr << #x " = " << (x) << '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
 
lli MOD  = 1000000007;
lli inf = 1e15;
 
void scan(scantype &x);

lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli string_to_number(string s){lli x=0; stringstream convert(s); convert>>x; return x;}
lli add(lli a,lli b){lli x = (a+b)%MOD; return x; }
lli mul(lli a,lli b){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b){lli x = (a-b+MOD)%MOD; return x; }
lli div(lli a,lli b){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}

bool isprime(long long int n)
{
    if(n ==1 )
        return false;
    if(n == 2)
        return true;
    for(long long int i =2;i<=n/i;i++)
    {
        if(n%i == 0)
            return false;
    }
    return true;
}
int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);   
    int t;
    t = 1;
    while(t--)
    {
        int n;
        cin>>n;
        int a[n];
        for(int i = 0;i<n;i++ )
            cin>>a[i];

        int c[8];
        int co = 0;
        for(int i = 0;i<8;i++)
            c[i] = 0;
        for(int i = 0;i<n;i++)
        {
            if(a[i]<400)
                c[0]++;
            else if (a[i] < 800)
                c[1]++;
            else if (a[i] < 1200)
                c[2]++;
            else if (a[i] < 1600)
                c[3]++;
            else if (a[i] < 2000)
                c[4]++;
            else if (a[i] < 2400)
                c[5]++;
            else if (a[i] < 2800)
                c[6]++;
            else if (a[i] < 3200)
                c[7]++;
            else 
                co++;
        }
        int mi = n+1;
        int mx = 0;
        for(int i = 0;i<=7;i++)
        {
          //  cout<<c[i]<<endl;
            if(c[i]>0)
                mx++;
        }

        cout<<max(1,mx)<<" "<<(mx+co);
   }    


    
    return 0;    
}
 

void scan(scantype &x)
{
    register int c = getchar(); //for negative/positive
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar());
    if(c=='-') {neg=1;c=getchar();}
    for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}


Measured memory_bytes: 256
from heapq import heappush, heappop
INF = 10 ** 9


def dijkstra(s, n): 
    dist = [INF] * n
    hq = [(0, s)] 
    dist[s] = 0
    seen = [False] * n 
    while hq:
        v = heappop(hq)[1] 
        seen[v] = True
        for to, cost in adj[v]: 
            if seen[to] == False and dist[v] + cost < dist[to]:
                dist[to] = dist[v] + cost
                heappush(hq, (dist[to], to))
    return dist


v, e, r = map(int, input().split())

adj = [[] for _ in range(v)]
for i in range(e):
    s, t, d = map(int, input().split())
    adj[s].append((t, d))

# print(adj)
d = dijkstra(r, v)
for i in d:
    if i != 1000000000: print(i)
    else: print("INF")



Measured memory_bytes: 90040
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	a, b := getInt(), getInt()

	ans := lcm(a, b)
	fmt.Fprintln(wr, ans)
}

func gcd(a, b int) int {
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

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

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
map<lli,lli>mp;
map<string,lli>mps;
map<char,lli>mpc;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> A >> B >> N;
  lli ng=-1,ok=N+1;
  while(ok-ng>1){
    lli mid=(ok+ng)/2;
    lli ns=(A*mid/B)-A*(mid/B);
    if(ns>=sum){
      sum=ns;
      ng=mid;
    }
    else ok=mid;
  }
  Out(sum);
}

Measured memory_bytes: 3568
def sum_from_to(a,b)
    (a+b)*(b-a+1)/2
end

def main
    n,k = gets.chomp.split(" ").map(&:to_i)
    # n,k = 3,2
    ans = 0
    (k..(n+1)).each do |i|
        ans += sum_from_to(n-i+1, n) - sum_from_to(0, i-1) + 1
    end
    puts ans % (10**9+7)
end

main


Measured memory_bytes: 14380
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> LIST(m);

    for (int i = 0; i < n; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int a;
            cin >> a;
            LIST[a - 1]++;
        }
    }

    int count = 0;
    for (int i = 0; i < m; i++) {
        if (LIST[i] == n) {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
# define ll long long
# define mo 1000000009
using namespace std;
int main()
{
	int n,count=0;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<n-1;i++)
	{
		if(max(a[i],a[i-1])==a[i]&&max(a[i],a[i+1])==a[i]);
		else if(max(a[i],a[i-1])!=a[i]&&max(a[i],a[i+1])!=a[i]);
		else
		count++;
	}
	cout<<count;
	
}


Measured memory_bytes: 256
q,h,s,d = map(int, input().split())
n = int(input())

q_2l = q*8
h_2l = h*4
s_2l = s*2
ans = (n - n%2) //2 * min(q_2l, h_2l, s_2l, d) 
ans += (n % 2) * min(q_2l, h_2l, s_2l) // 2 # 奇数リットルの場合
print(ans)


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

using namespace std;

int64_t l, r, ans = 2019;

int main()
{
    cin >> l >> r;
    if (l+2019<=r) r = l + 2019;
    for (int64_t i=l; i<=r; i++)
    {
        for (int64_t j=i+1; j<=r; j++)
        {
            ans = min(ans, (i*j)%2019);
            if (ans==0) break;
        }
        if (ans==0) break;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		
		int[] map = new int[N];
		int min = Integer.MAX_VALUE;
		int minIndex = N;
		for (int i = 0; i < N; i++) {
			int Ai = sc.nextInt();
			min = Math.min(Ai, min);
			if (min == Ai)
				minIndex = i;
		}
		
		int right = (N - 1) - minIndex;
		int left = (N - 1) - right;
		
		int div = K - 1;
		
		int ans = (left / div) + (right / div);
		int amari = (left % div) + (right % div);
		ans += amari / div;
		ans += amari % div > 0 ? 1 : 0;
		
		System.out.println(ans);
	}
	
}

Measured memory_bytes: 50220
#include<iostream>
using namespace std;
bool isprime(long long n) {
    if (n == 1) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;
    for (long long i = 3; i * i <= n; ++i) {
        if (n % i == 0) return false;
    }
    return true;
}
int func(long long n) {
    int cnt = 0;
    while (n) {
        n /= 10;
        cnt++;
    }
    return cnt;
}
long long sqrt(long long n) {
    long long i;
    for (i = 1; i * i <= n; ++i) {
        
    }
    return i;
}
int main() {
    long long n; cin >> n;
    if (isprime(n)) { //(prime, 1) only
        cout << func(n) << endl;
        return 0;
    }
    for (long long i = sqrt(n); ; i--) { //出来るだけ2数に差がない方から
        if (n % i == 0) {
            cout << func(n / i) << endl;
            return 0;
        }
    }
}




Measured memory_bytes: 256
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	abc = set(LI())
	print(len(abc))




if __name__ == '__main__':
    main()

Measured memory_bytes: 14220
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanInt64() int64 {
	sc.Scan()
	i, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return i
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func scanInts64(n int) []int64 {
	res := make([]int64, n)
	for i := range res {
		res[i] = scanInt64()
	}
	return res
}

func scanText() string {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Scan()
	return sc.Text()
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n, m := scanInt(), scanInt()
	days := 0
	for i := 0; i < m;i++ {
		days += scanInt()
	}
	if days > n {
		fmt.Println(-1)
		return
	}
	fmt.Println(n-days)
}



Measured memory_bytes: 1808
h,w = map(int,input().split())
a = [list(map(str,input())) for _ in range(h)]
#dp[i][j]は上からi番目,左からj番目 dp[i+1][j+1] = dp[i][j+1]+dp[i+1][j]
mod = 10**9+7
dp = [[0]*w for i in range(h)]
for k in range(h):
  if a[k][0] == ".":
    dp[k][0] = 1
  else:
    break
for l in range(w):
  if a[0][l] == ".":
    dp[0][l] = 1
  else:
    break
for i in range(h-1):
  for j in range(w-1):
    dp[i+1][j+1] = (dp[i][j+1]+dp[i+1][j]) % mod
    if a[i+1][j+1] == "#":
      dp[i+1][j+1] = 0
print(dp[-1][-1]%mod)
#print(dp)

Measured memory_bytes: 89436
#include <stdio.h>

int main(void) {
  int a,b;
  char op;
  while(1){
    scanf("%d %c %d",&a,&op,&b);
    if(op=='?'){
    break;
    }
    else if(op=='+'){
    printf("%d\n",a+b);
    }
    else if(op=='-'){
    printf("%d\n",a-b);
    }
    else if(op=='*'){
      printf("%d\n",a*b);
    }
    else if(op=='/'){
      printf("%d\n",a/b);
    }
  }
  return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll mod=86400,wd=10801;
  ll N;
  cin>>N;
  vector<int> cnt(mod,0);
  ll idx=0;
  for(int i=0;i<N;i++){
    ll a,b;
    cin>>a>>b;
    (idx+=a)%=mod;
    cnt[idx]++;
    (idx+=b)%=mod;
  }
  vector<int> sum(2*mod,0);
  for(int i=0;i<2*mod;i++){sum[i]=cnt[i%mod];}
  for(int i=1;i<2*mod;i++){sum[i]+=sum[i-1];}
  int ans=sum[wd-1];
  for(int i=wd;i<2*mod;i++){ans=max(ans,sum[i]-sum[i-wd]);}
  cout<<ans<<endl;
  

  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h> 
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define vbi vector<bool> 
#define mod 1000000007
#define INF 1000000000
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define sd second
#define ft first
#define ms(x,v) memset(x,v,sizeof x)
#define endl '\n'
#define cnl cout<<endl;
#define frr(i,b) for(ll i=0; i<b;i++)
#define fb(i,b) for(ll i=b-1; i>=0; i--)
#define pi  3.141592653589793238
ll i,j,k;
void solve()
{
  ll n; cin>>n;
  ll x;
  ll min=1e13;
  for(i=1;i<=sqrt(n);i++){
       if(n%i==0){
        x=n/i;
        ll y=x+i;
        if(y<min) min=y;
       }
  }
  cout<<(min-2)<<endl;
}
signed main(){
   
    solve();

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
#define PI 3.14159265358979
using P = pair<ll , ll>;
//using map = map<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main(){
    ll x, n;
    cin >> x >> n;
    vl p(n);
    rep(i,n) cin >> p.at(i);
    vl p_not_count(200, 1);
    rep(i,n) p_not_count.at(p.at(i)-1)--;

    ll ans = 1000;
    ll dist = 1000;

    rep(i,200){
        if(p_not_count.at(i) > 0){
            if(dist > abs(x-(i+1)) ){
                dist = abs(x-(i+1));
                ans = i+1;
            }
        }
    }
    if(dist >= abs(x)) ans = 0;

    cout << ans << endl;


    return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;

const int N = 125252;
const int B = 252;
const int C = (N+B-1)/B;
const ll INF = 1ll<<60;

ll a[N];
ll b[C];
void update(int i, ll v){
	a[i] = v;
	int id = i/B;
	b[id] = INF;
	REP(j,B){
		b[id] = min(b[id], a[id*B+j]);
	}
}
ll qmin(int l, int r){
	ll ret = INF;
	if(r-l<=B){
		REP(i,r-l)ret = min(ret,a[l+i]);
		return ret;
	}
	while(l%B>0)ret = min(ret, a[l++]);
	while(r-l>=B){
		ret = min(ret, b[l/B]);
		l += B;
	}
	while(l<r)ret = min(ret, a[l++]);
	return ret;
}

int main(){
	int n,q;
	scanf("%d%d",&n,&q);
	REP(i,n)a[i] = 2147483647ll;
	REP(i,C)b[i] = 2147483647ll;
	while(q--){
		int t,x,y;
		scanf("%d%d%d",&t,&x,&y);
		if(t==0){
			update(x,y);
		}else{
			printf("%lld\n",qmin(x,y+1));
		}
	}
	return 0;
}


Measured memory_bytes: 3980
def main():
    N, M = (int(i) for i in input().split())
    ab = [tuple(int(i) for i in input().split()) for _ in range(M)]
    ab.sort(key=lambda p: p[1])

    pre_b = 1
    ans = 0
    for a, b in ab:
        if pre_b <= a:
            ans += 1
            pre_b = b
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62040
import heapq

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

A = list(map(int,input().split()))

q = []

for a in A:
    heapq.heappush(q, -a)

for i in range(m):
    a = heapq.heappop(q)
    a = -(-a // 2)
    heapq.heappush(q, a)

print(-sum(q))

Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
typedef int64_t i64;

int main()
{
  int a,b;
  cin >> a >> b;

  if(a <= 5){
      cout << 0 << endl;
  }else if( a <= 12){
      cout << b / 2 << endl;
  }else{
      cout << b << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll a, b, k;
  cin >> a >> b >> k;
  ll t = __gcd(a, b);

  set<ll> s;
  for (ll i = 1; i*i <= t; i++) {
    if (t%i == 0) {
      s.insert(i);
      if (t/i != i) s.insert(t/i);
    }
  }

  ll cnt = s.size();
  for (auto&& i : s) {
    if (cnt == k) {
      cout << i << endl;
      return 0;
    }
    cnt--;
  }
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <map>

std::vector<size_t> read_vector(size_t len) {
    std::vector<size_t> result;
    size_t temp = 0;
    for (size_t i = 0; i < len; ++i) {
        std::cin >> temp;
        result.push_back(temp);
    }
    return result;
}

size_t flowers(std::vector<size_t> & heights, std::vector<size_t> & values) {
    std::map<size_t, size_t> best_seqs;

    for (size_t curr_flower = 0; curr_flower < heights.size(); ++curr_flower) {
        size_t current_height = heights[curr_flower];

        auto lb = best_seqs.lower_bound(current_height);
        
        size_t curr_val;
        if (lb != best_seqs.begin() && best_seqs.size() > 0) {
            --lb;
            curr_val = values[curr_flower] + (*lb).second;
        } else {
            curr_val = values[curr_flower];
        }

//        std::cout << current_height << " h " << (*lb).first << " " << curr_val << std::endl;

        best_seqs[current_height] = curr_val;

        auto ub = best_seqs.upper_bound(current_height);
        std::vector<size_t> keys_to_remove;
        while (ub != best_seqs.end()) { 
            if ((*ub).second <= curr_val) {
                keys_to_remove.push_back((*ub).first);
            } else {
                break;
            }
            ++ub;
        }

        for (size_t k : keys_to_remove) {
            best_seqs.erase(k);
        }
    }

    auto e = best_seqs.end();
    --e;

    return (*e).second;
}

int main(int argc, char** argv) {
    size_t flowers_number = 0;
    std::cin >> flowers_number;    
    std::vector<size_t> heights = read_vector(flowers_number);
    std::vector<size_t> values = read_vector(flowers_number);

    std::cout << flowers(heights, values);
    return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<ll,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


ll ff(int h, int w,int k,int sy, int sx, int ey,int ex, vector<string> s){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	//int h, w, k, sx, sy, ex, ey;
	//cin >>h >>w >>k >>sy >>sx >>ey >>ex;
	//vector<string> s(h);
	//rep(i, h) cin >>s[i];
	const int dr[]={0,1,0,-1,0};
	const int INF= 1<<28;
	vector<VI> dd(h, VI(w, INF));
	queue< pair<int, int> > que;
	que.emplace(sy-1, sx-1); dd[sy-1][sx-1]=0;
	while(!que.empty()){
		int cy,cx; tie(cy,cx) = que.front();
		que.pop();
		rep(i,4) rep2(j, 1, k+1){
			int ny=cy+dr[i]*j, nx=cx+dr[i+1]*j;
			if(ny<0 || ny>=h || nx<0 || nx>=w) break;
			if(s[ny][nx] !='.' || dd[ny][nx] <= dd[cy][cx]) break;
			if(dd[ny][nx] == INF && s[ny][nx] =='.'){
				que.emplace(ny, nx);
				dd[ny][nx] = dd[cy][cx] + 1;
			}
		}
	}
	int ans = dd[ey-1][ex-1];
	dbg((ans <INF? ans : -1), "p2");
	return ans;
}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	typedef tuple<ll, int, int, int> TS;
	int h, w, k, sx, sy, ex, ey;
	cin >>h >>w >>k >>sy >>sx >>ey >>ex;
	vector<string> s(h);
	rep(i, h) cin >>s[i];
	const int dy[]={0,1,0,-1}, dx[]={1,0,-1,0};
	const ll INF= 1LL<<55;
	vector<vector<vector<pii>>> 
		dd(h,vector<vector<pii>>(w ,vector<pii>(4, pii(INF, k*4))));
	priority_queue< TS, vector<TS>, greater<TS> > que;
	
	rep(i, 4){
		que.emplace( 0, sy-1, sx-1, i);
		dd[sy-1][sx-1][i] = pii(0, 0);
	}
	while(!que.empty()){
		auto [cst, cy, cx, cd] = que.top();
		que.pop();
		const auto crp = dd[cy][cx][cd];
		if(cst != crp.first * 4*k + crp.second )continue;
		rep(i,4) {
			int ny=cy+dy[i], nx=cx+dx[i];
			if(ny<0 || ny>=h || nx<0 || nx>=w || s[ny][nx] !='.') continue;
			int sp = 1, sd = 0;
			if(i==cd ){ sd = crp.second +1; sp = sd/k; sd%=k;}
			if(i!=cd){
				if(crp.second >0 ){ sd = 1; sp = 1;}
				else { sd = 1; sp = 0;}
			}
			if(dd[ny][nx][i] >  pii(crp.first + sp, sd)){
				dd[ny][nx][i] = pii(crp.first + sp, sd);
				que.emplace( (crp.first + sp) * 4*k + sd, ny, nx, i );
				//dbg( ny, nx, i ,"/", cy,cx,cd,"/",crp.first + sp, sd );
			}
		}
	}
	ll ans = INF;
	rep(i, 4){
		auto [s,s2] = dd[ey-1][ex-1][i];
		ans = min<ll>(ans, s + (s2>0));
	}
	cout <<(ans <INF? ans : -1) <<"\n";
	//ff(h, w, k, sy, sx, ey, ex, s);
	return 0;
}

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

int main(){
    string s, t;
    cin >> s;
    getchar();
    cin >> t;

    int c = 0;

    for(int i = 0; i < s.size(); i++){
        if(s[i] != t[i]) c++;
    }

    cout << c << endl;

}

Measured memory_bytes: 3856
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.util.*
import kotlin.collections.HashSet
import kotlin.math.*
fun main(){
    var fs = CodeForces.FastReader()
    var n = fs.nextInt()
    var a = IntArray(4){0}
    for (i in 0 until n) {
        var s = fs.next()
        if(s=="AC") a[0]++
        else if(s=="WA")a[1]++
        else if(s=="TLE")a[2]++
        else if(s=="RE")a[3]++
    }
    println("AC x ${a[0]}\nWA x ${a[1]}\n" +
            "TLE x ${a[2]}\n" +
            "RE x ${a[3]}")
}

class CodeForces {
    internal class FastReader {
        private var br: BufferedReader = BufferedReader(InputStreamReader(System.`in`))
        private var st: StringTokenizer? = null

        operator fun next(): String {
            while (st == null || !st!!.hasMoreElements()) {
                try {
                    st = StringTokenizer(br.readLine())
                } catch (e: IOException) {
                    e.printStackTrace()
                }

            }
            return st!!.nextToken()
        }

        fun nextInt(): Int {
            return Integer.parseInt(next())
        }

        fun nextLong(): Long {
            return java.lang.Long.parseLong(next())
        }

        fun nextDouble(): Double {
            return java.lang.Double.parseDouble(next())
        }

        fun nextLine(): String {
            var str = ""
            try {
                str = br.readLine()
            } catch (e: IOException) {
                e.printStackTrace()
            }
            return str
        }

        fun readIntArray(n: Int): IntArray {
            val a = IntArray(n)
            for (i in 0 until n) a[i] = nextInt()
            return a
        }

        fun readLongArray(n: Int): LongArray {
            val a = LongArray(n)
            for (i in 0 until n) a[i] = nextLong()
            return a
        }

        fun readDoubleArray(n: Int): DoubleArray {
            val a = DoubleArray(n)
            for (i in 0 until n) a[i] = nextDouble()
            return a
        }
    }
}


Measured memory_bytes: 47228
S = [i for i in input()]
N = len(S) + 1
A = [0]*N

for i in range(len(S)):
    if S[i]=='<':
        A[i+1]=A[i]+1
        
for i in range(len(S)-1, -1, -1):
    if S[i]=='>':
        A[i]=max(A[i], A[i+1]+1)

print(sum(A))

Measured memory_bytes: 27452