akhauriyash/Code-Regression huggingface dataset:
def makedivisor(N):  # 約数列挙
    p, upper, lower = 1, [], []
    while p * p <= N:
        if N % p == 0:
            lower.append(p)
            if p * p != N:
                upper.append(N // p)
        p += 1
    return lower + upper[::-1]


def totient(N):  # オイラーのトーシェント関数
    p, phi = 2, N
    while p * p <= N:
        if N % p == 0:
            phi = phi // p * (p - 1)
        while N % p == 0:
            N //= p
        p += 1
    if N > 1:
        phi = phi // N * (N - 1)
    return phi


k = int(input()) * 9

# 解説AC オイラーの定理 O(n**0.5)?
if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()
if k % 7 == 0:
    k //= 7

cnt = totient(k)
num = makedivisor(cnt)
for i in num:
    if pow(10, i, k) == 1:
        print(i)
        break


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

int main(){
    string s;
    cin >> s;
    if(s.at(0) == s.at(2) && s.at(1) == s.at(0)){
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

}

Measured memory_bytes: 256
// IlyM

#include <bits/stdc++.h>

#define pb push_back
#define sp " "
#define fi first
#define se second
#define mp make_pair
#define sz(a) ((int)a.size())
#define tra(a,b) for (auto a:b) 
#define fo(a,b,c) for (unsigned long long a=b;a<=c;a++) 
#define ms(a,b) memset(a,b,sizeof(a)) 
#define all(a) a.begin(),a.end()
#define rev(a) reverse(a.begin(),a.end())

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef pair<int,ii> iii;

const int N=2e6+5,mod=998244353;
int n,k,a[N];
ll s;
vi res;
int main()
{
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	cin>>n>>k;
	fo(i,0,k-1) cin>>a[i];
	fo(i,1,k-1) res.pb(abs(a[i]-a[i-1]));
	res.pb(n-a[k-1]+a[0]);
	sort(all(res));
	reverse(all(res));
	fo(i,0,sz(res)) s+=res[i];
	s-=res[0];
	cout<<s;
	return 0;
}


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

int main() {
string S, T;
int A, B;
string U;

  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
//  cout << A << B << endl;
  if(U == S){
    A = A -1;
  }else{
    B = B -1;
  }
cout << A <<' '<< B << endl;
}

Measured memory_bytes: 256
#include<iostream>

int main(){
	int N;
	std::cin >> N;
	bool exist = false;
	for (int i = 0; i < N; i++){
		char ch;
		std::cin >> ch;
		switch (ch){
		case 'Y':
			exist = true;
			break;

		}
	}

	if (exist){
		std::cout << "Four" << std::endl;
	}
	else{
		std::cout << "Three" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#define MOD 1000000007
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
signed main(){
    int n,m;
    cin>>n>>m;
    P p[114514];
    for(int i=0;i<m;i++){
        cin>>p[i].second>>p[i].first;
    }
    sort(p,p+m);
    for(int i=0;i<m;i++){
        swap(p[i].first,p[i].second);
    }
    int ans=0,k=0;
    for(int i=0;i<m;i++){
        if(p[i].first<k)continue;
        else {
            ans++;
            k=p[i].second;
        }
    }
    cout<<ans<<endl;
    return 0;
}




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

int main() {
  int x,y,z;
  cin>>x>>y>>z;
  cout << z << ' ' << x << ' ' <<y;
}



Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int a[7]={2,4,8,16,32,64,105},n;
	scanf("%d",&n);
	if(n==1)printf("1");
	for(int i=0;i<6;i++)
	{
		if(n>=a[i]&&n<a[i+1])printf("%d",a[i]);
	}
	return 0;
}

Measured memory_bytes: 128
n,m=gets.split.map(&:to_i)
puts "Yes"
l=[]
n.times do
  l << []
end
m.times do
  a,b=gets.split.map(&:to_i)
  l[a-1] << b-1
  l[b-1] << a-1
end
s=[0]
a=[nil]*(n-1)
ac=0
while ac<n-1
  z=[]
  s.each do |ss|
    l[ss].each do |lss|
      l[lss].delete(ss)
      if a[lss-1]==nil
        a[lss-1]=ss+1
        ac+=1
        z << lss
      end
    end
  end
  s=z.dup
end
puts a

Measured memory_bytes: 33180
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

class D {
    public static void main(String... args) {
        final Scanner sc = new Scanner(System.in);
        try (final PrintWriter pw = new PrintWriter(System.out, false)) {
            final int N = sc.nextInt();
            final char[] cs = new char[N];
            Arrays.fill(cs, 'a');
            do {
                pw.println(new String(cs));
            } while (next(cs));
        }
    }

    static boolean next(char[] cs) {
        char[] max = new char[cs.length];
        max[0] = (char) ('a' - 1);
        for (int i = 1; i < cs.length; i++)
            max[i] = (char) Math.max(max[i - 1], cs[i - 1]);
        for (int i = cs.length - 1; i > 0; i--)
            if (cs[i] <= max[i]) {
                cs[i]++;
                for (int j = i + 1; j < cs.length; j++)
                    cs[j] = 'a';
                return true;
            }
        return false;
    }
}
public class Main {
    public static void main(String... args) {
        D.main();
    }
}


Measured memory_bytes: 34228
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		 try {
		 BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		
		 String ln;
		ln = buf.readLine();
		
//       String[] strAry = ln.split(" ");
//       int x = Integer.parseInt(strAry[0]);
//       int y = Integer.parseInt(strAry[1]);
		
       int z = Integer.parseInt(ln);
       int min = z/60;
       int hour = min/60;
       min = min - hour*60;
       int sec = z - hour*3600 - min*60;
       
       System.out.println(hour + ":" + min + ":" +  sec);
			} catch (IOException e) {
				// TODO ????????????????????? catch ????????????
				e.printStackTrace();
			}
    }
}

Measured memory_bytes: 24336
#include<bits/stdc++.h>
using namespace std;
#define MAX 100001
#define MOD 1000000007
#define ll long long
#define ld long double
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
int main() {
	fast;
	int t = 1;
	// cin >> t;
    while(t--) {
		ll n;
		cin >> n;
		vector<ll> v(n);
		for(ll i=0;i<n;i++) {
			cin >> v[i];
		}
		ll curr = v[0], ans = 0;
		for(ll i=1;i<n;i++) {
			if(v[i] <= curr) ans += curr - v[i];
			else curr = v[i];
		}
		cout << ans << endl;
    }
}


Measured memory_bytes: 4760
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = 100000000000;
const long long int Mod = 1000000007;
using ll = long long int; //long long int は64bit
using vi = vector<int>; using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(long long int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
typedef pair<ll,ll> Pair;
bool p_compare(const Pair& firstP, const Pair& secondP){ 
    return firstP.second < secondP.second; 
}//sort(all(v),p_compare)で昇順ソート
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////
//Snipet -> Caps Lock

ll hh,ww;
ll h,w;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>hh>>ww;
    cin>>h>>w;
    cout<<hh*ww-h*ww-w*hh+h*w<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,A,B,C,D = map(int,readline().split())
S = '.' + read().rstrip().decode('utf-8')

if A > B:
    A,B = B,A
    C,D = D,C

from_A = [False] * (N+10) # 負のインデックス対策
from_A[A] = True
for i,x in enumerate(S):
    if x == '#':
        continue
    if from_A[i-1] or from_A[i-2]:
        from_A[i] = True
from_A = from_A[:N+1]

from_B = [False] * (N+10) # 負のインデックス対策
from_B[B] = True
for i,x in enumerate(S):
    if x == '#':
        continue
    if from_B[i-1] or from_B[i-2]:
        from_B[i] = True
from_B = from_B[:N+1]

from_A[C+1:] = [False] * (N - C)
from_B[D+1:] = [False] * (N - B)

if not (from_A[C] and from_B[D]):
    print('No')
    exit()

if C < D:
    print('Yes')
    exit()

# 追い越しが必要

can_swap = False
for i in range(0,N-1):
    j,k = i+1,i+2
    if from_A[i] and from_A[k] and from_B[j]:
        can_swap = True
        break

answer = 'Yes' if can_swap else 'No'
print(answer)

Measured memory_bytes: 10644
#include<bits/stdc++.h>
using namespace std;
const int N=300005;
int m,a[N],b[N],ans[N];
void update(int v,int p){
	if(v>a[p]){
		b[p]=a[p];
		a[p]=v;
	}
	else if(v>b[p])b[p]=v;
}
int main(){
	scanf("%d",&m);
	int n=1<<m;
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(int i=0;i<m;i++)
		for(int j=0;j<n;j++){
			int x=(1<<i);
			if(!(j&x)){
				update(a[j],j|x);
				update(b[j],j|x);
			}
		}
	for(int i=0;i<n;i++){
		ans[i]=a[i]+b[i];
		if(i!=0){
			ans[i]=max(ans[i],ans[i-1]);
			printf("%d\n",ans[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 6844
import math
a = list(map(int,input().split()))
#N a[0]
#D a[1]
d = 0
for i in range(a[0]):
    b = list(map(int,input().split()))
    c = math.sqrt(b[0]*b[0]+b[1]*b[1])
    if a[1] >= c: d=d+1
print(d)

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

using namespace std;

#define int long long
struct str{
	int day,money;
}st[120000];
priority_queue<int> q;
bool cmp(str a,str b){
	return a.day<b.day;
}
signed main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>st[i].day>>st[i].money;
	int ans=0;
	int now=1;
	sort(st+1,st+1+n,cmp);
	for(int i=1;i<=m;i++){
		while(st[now].day<=i&&now<=n){
			q.push(st[now++].money);
		}
		if(!q.empty()){
			ans+=q.top();
			q.pop();
		}
	}
	cout<<ans;
	return 0;
} 

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

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

    while (k--) {
        if (a >= b) {
            b *= 2;
        } else if (b >= c) {
            c *= 2;
        }
    }

    if (a < b && b < c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define x first
#define y second
#define pii pair<int , int>
#define mp make_pair
#define pb push_back
#define sz(a) (int)(a.size())
const int INF = 1000 * 1000 * 1000 + 7;
const ll LINF = INF * (ll)INF;
int main()
{
	string s , t , u;
	int a , b;
	cin >> s >> t >> a >> b >> u;
	cout << (a - (s == u)) << " " << (b - (t == u)) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#ifdef MPS
#define D(x...) printf(x)
#else
#define D(x...)
#endif
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;
 
void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}
 
const int maxn = 300050;
 
int n, a[maxn];
 
void local()
{
	fp("1.in","r",stdin);
	fp("1.out","w",stdout);
}
bool jud(int l, int r)
{
	int mx = -inf, mn = inf;
	fo(i,l,r) gmax(mx, a[i]), gmin(mn, a[i]);
	if(mx != r || mn != l) return 0;
	int tmpx = 0, tmpy = 0;
	for(int j = l; j <= r; j += 2) 
		if(a[j] > tmpx) tmpx = a[j];
		else if(a[j] > tmpy) tmpy = a[j];
		else return 0;
	return 1;
}
int main()
{
	// local();
	sf("%d",&n);
	fo(i,1,n) sf("%d",&a[i]);
	fo(i,1,n) if((a[i]%2) != (i%2)) return 0 * pf("No\n");
	fo(i,1,n)
	{
		int j = i;
		if(a[i] != i)
		{
			while(j+2<=n&&a[j+1]==j+1&&a[j+2]!=j+2) j += 2;
			if(!jud(i,j)) return 0 * pf("No\n");
		}
		i = j;
	}
	pf("Yes\n");
	return 0;
}

Measured memory_bytes: 1536
#include<stdio.h>
#define MAXN 200001
int main(void)
{
	int s=0,N,i,j,a[MAXN];
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%d",&a[i]);
	}
	i=0;
	for(j=1;i<N;j++)
	{
		for(;i<N;i++)
		{
			if(a[i]==j)
			{
				i++;
				break;
			}
			s++;
		}
	}
	if(s==N)
	s=-1;
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
typedef long long ll;

map<int, int> mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string str;
	int alp[26] = {};
	while (getline(cin, str)) {
		for (int i = 0; i < str.size(); i++) {
			if (str[i] >= 'a' && str[i] <= 'z') alp[str[i] - 'a']++;
			else if (str[i] >= 'A' && str[i] <= 'Z') alp[str[i] - 'A']++;
		}
	}
	for (int i = 0; i < 26; i++) {
		printf("%c : %d\n", i + 'a', alp[i]);
	}
	return 0;
}


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

int main(){
    int m,n;
    while(cin>>m>>n,m){
        vector<int> goodyear(7368792,0);
        int cnt=0;
        int res=-1;
        for(int i=m;;i++){
            if(goodyear[i]==0){
                if(cnt==n){
                    res=i;
                    break;
                }
                else{
                    cnt++;
                    for(int j=i;j<7368792;j+=i){
                        goodyear[j]=1;
                    }
                }

            }

        }
        cout<<res<<endl;

    }


}

Measured memory_bytes: 31872
#include <iostream>
using namespace std;
int main(void){
    // Your code here
    string a;
    cin>>a;
    int n;
    n=0;
    if(a[0]=='1'){
        n++;
    }
    if(a[1]=='1'){
        n++;
    }
    if(a[2]=='1'){
        n++;
    }
    cout<<n<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main() {
	std::string s; std::cin >> s;
	int count{ 0 };
	int ans{ 0 };
	for (auto i{ 0 }; i < s.size(); ++i) {
		if (s[i] == 'T' || s[i] == 'A' || s[i] == 'C' || s[i] == 'G') {
			++count;
			if (ans < count) ans = count;
		}
		else {
			if (ans < count) ans = count;
			count = 0;
		}
	}
	std::cout << ans << std::endl;

	return 0;
}


Measured memory_bytes: 3604
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

def gcd_l(A):
    if len(A) == 1:
        return A[0]
    x = gcd(A[0], A[1])
    if len(A) == 2:
        return x
    for i in range(2, len(A)):
        x = gcd(x, A[i])
    return x

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

def lcm_l(A):
    if len(A) == 1:
        return A[0]
    x = lcm(A[0], A[1])
    if len(A) == 2:
        return x
    for i in range(2, len(A)):
        x = lcm(x, A[i])
    return x


N = int(input())
T = [int(input()) for _ in range(N)]
T = list(set(T))
T.sort()
N = len(T)
L = []
'''
for i in range(N):
    flag = 1
    for j in range(N-1, i, -1):
        if T[j] % T[i] == 0:
            flag = 0
            break
    if flag:
        L.append(T[i])

GCD = gcd_l(L)
ans = 1
for i in range(len(L)):
    ans *= L[i] // GCD
ans *= GCD
if len(L) == 1:
    ans = L[0]
'''
ans = lcm_l(T)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define f first
#define s second

int h, w;
string g[1005];
int dp[1005][1005];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("input.in", "r", stdin);
        //freopen("output.out", "w", stdout);
	cin >> h >> w;
	for(int i = 0; i < h; i++){
		cin >> g[i];
	}
	ll MOD = 1e9 + 7;
	dp[0][0] = 1;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(i > 0 && g[i - 1][j] == '.') dp[i][j] = (dp[i - 1][j] + dp[i][j]) % MOD;
			if(j > 0 && g[i][j - 1] == '.') dp[i][j] = (dp[i][j - 1] + dp[i][j]) % MOD;
			if(g[i][j] == '#') dp[i][j] = 0;
		}
	}
	cout << dp[h - 1][w - 1] << endl;	
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/



Measured memory_bytes: 5248
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

void main() {
    int n, m, k;
    scan(n, m, k);
    auto a = readln.split.to!(long[]);
    auto b = readln.split.to!(long[]);
    auto as = new long[](n + 1);
    auto bs = new long[](m + 1);
    foreach (i; 1 .. n + 1) {
        as[i] = as[i - 1] + a[i - 1];
    }
    foreach (i; 1 .. m + 1) {
        bs[i] = bs[i - 1] + b[i - 1];
    }
    debug {
        writeln(as);
        writeln(bs);
    }
    int ans;
    foreach (i; 0 .. n + 1) {
        auto d = k - as[i];
        if (d < 0)
            break;

        auto j = bs.assumeSorted.lowerBound(d + 1).length.to!int - 1;
        debug {
            writefln("%s, %s, %s", d, i, j);
        }
        chmax(ans, i + j);
    }
    writeln(ans);
}

void scan(T...)(ref T args) {
    auto line = readln.split; // @suppress(dscanner.suspicious.unmodified)
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 22144
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <set>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

int main() {
    ios::sync_with_stdio(0);
    int n, q;
    cin >> n >> q;
    //cout << n << " " << q << endl;
    using P = pair<int, ll>;
    set<P> s;
    s.insert(P(-1, TEN(15)));
    s.insert(P(n-1, 0));

    for (int i = 0; i < q; i++) {
        int a; ll b;
        cin >> a >> b; a--;
        while (b) {
            auto it = s.lower_bound(P(a, -1));
            auto pr = *it; it--;
            auto pl = *it;
            int d = a-pl.first;
            if (a == pr.first) s.erase(pr);
            if (pl.second-pr.second <= b/d) {
                s.erase(pl);
                s.insert(P(a, pl.second));
                b -= d*(pl.second-pr.second);
            } else {                
                s.insert(P(a, pr.second + b/d));
                if (b%d) {
                    s.insert(P(pl.first + b%d, pr.second + b/d + 1));
                }
                if (pr.second + (b+d-1)/d == pl.second) {
                    s.erase(pl);
                }
                b = 0;
            }
        }
    }

    ll res[n];
    int b = -1;
    for (auto p: s) {
        for (int i = b+1; i <= p.first; i++) {
            res[i] = p.second;
        }
        b = p.first;
    }

    for (int i = 0; i < n; i++) {
        assert(res[i] <= 2*TEN(13));
        cout << res[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 8576
// https://atcoder.jp/contests/abc172/tasks/abc172_c

use proconio::input;

fn main() {
    input! {
        n: usize, m: usize, k: u32,
        a_s: [u32; n],
        b_s: [u32; m],
    }
    let mut max = 0;
    let mut sum: u32 = 0;
    for a in &a_s {
        if sum + a <= k {
            max += 1;
            sum += a;
        } else {
            break;
        }
    }
    let mut a_cnt = max;
    let mut b_cnt = 0;
    'outer: for b in b_s {
        if k < sum + b {
            loop {
                if a_cnt == 0 {
                    break 'outer;
                }
                a_cnt -= 1;
                sum -= &a_s[a_cnt as usize];
                if sum + b <= k {
                    break;
                }
            }
        }
        b_cnt += 1;
        sum += b;
        if max < a_cnt + b_cnt {
            max = a_cnt + b_cnt;
        }
    }
    println!("{}", max);
}


Measured memory_bytes: 7736
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <queue>
#include <stack>
#include <climits>
using namespace std;

typedef long long ll;
#define pb push_back

#define rep(i, n) for (int i=0;i<(n);++i)
#define rep2(i, s, n) for (int i=s;i<(n);++i)
#define rev(i, n) for (int i=(n);i>0;--i)
#define INF (1e9+1e9)

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

    int m = 0, ans;
    rep(i,N) {
        int a,b; cin>>a>>b;
        if (m < a) {
            m = a;
            ans = a + b; 
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

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

  string result = "Yes";
  map<string, int> word;
  string last = "aaa";
  rep(i, N) { 
    string w; cin >> w; 
    word[w]++;
    if (i==0 || last[last.length()-1] == w[0]) { last = w; continue; }
    else { result = "No"; break; }
  }
  for (auto x: word) if (x.second>=2) result = "No";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;
using P = pair<int, int>;

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

    vector<vector<int>> G(n+1);
    for(int i = 0; i < m; i++){
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }

    vector<int> ans(n+1, 0);
    queue<P> Q;
    for(int i = 0; i < G[1].size(); i++){
        Q.push(make_pair(1, G[1][i]));
        ans[G[1][i]] = 1;
    }

    while(Q.size()){
        P cur = Q.front();
        Q.pop();

        if(ans[cur.second] == 0) ans[cur.second] = cur.first;
        for(int i = 0; i < G[cur.second].size(); i++){
            if(ans[G[cur.second][i]] != 0) continue;
            Q.push(make_pair(cur.second, G[cur.second][i]));
            ans[G[cur.second][i]] = cur.second;
        }
    }

    bool isok = true;
    for(int i = 2; i <= n; i++){
        if(ans[i] == 0) isok = false;
    }

    if(isok){
        cout << "Yes" << endl;
        for(int i = 2; i <= n; i++) cout << ans[i] << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 12172
#include <stdio.h>
#include <string.h>

/*
MAX_DATASETは入力されるデータセットの最大個数
MAX_SHUFFLEはシャッフルする最大回数
CARD_MAXLENGTHは入力される最大の文字数
*/
#define MAX_DATASET 10
#define MAX_SHUFFLE 100
#define CARD_MAXLENGTH 200

int main(void)
{
	//data_countは入力されたデータセットを、first_pointは文字列の先頭位置を格納
	int i, j, data_count, first_point;
	//shuffle_pointはカードをシャッフルする位置を、shuffle_countはシャッフルする回数を格納
	int shuffle_point[MAX_DATASET][MAX_SHUFFLE], shuffle_count[MAX_DATASET];
	char work[CARD_MAXLENGTH];
	//cardはシャッフルする文字列を格納(連結用に2倍の領域を確保)
	char card[MAX_DATASET][2 * CARD_MAXLENGTH];

	data_count = 0;
	while(scanf("%s", card[data_count])){
		//データが '-' なら入力終了
		if(card[data_count][0] == '-'){
			break;
		}
		else{
			//シャッフルする回数を入力
			scanf("%d", &shuffle_count[data_count]);
			//シャッフルする位置を入力
			for(i = 0; i < shuffle_count[data_count]; i++){
				scanf("%d", &shuffle_point[data_count][i]);
			}
			data_count++;
		}
	}

	//入力されたデータセットの回数分繰り返す
	for(i = 0; i < data_count; i++){
		first_point = 0;
		for(j = 0; j < shuffle_count[i]; j++){
			//先頭位置からカードを取り出す位置までworkにコピー
			strncpy(work, &(card[i][first_point]), shuffle_point[i][j]);
			//文字列の最後に '\0' を挿入
			work[shuffle_point[i][j]] = '\0';
			//取り出したカードをシャッフルもとに連結
			strcat(card[i], work);
			//先頭位置をずらす
			first_point += shuffle_point[i][j];
		}
		//結果の出力
		printf("%s\n", &card[i][first_point]);
	}

	return 0;
}


Measured memory_bytes: 2056
# -*- coding: utf-8 -*-
N, K, Q = map(int, input().split())
A_list = [K - Q] * N

for i in range(Q):
    A_list[int(input()) - 1] += 1

for i in range(N):
    if A_list[i] > 0:
        print("Yes")
    else:
        print("No")

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

int main()
{
    int n,i;
    cin>>n;
    int l,m=0;
    for(i=1;i<=n;i++)
    {
        int r=i,c=0;
        while(r>0)
        {
            l=r%10;
            c++;
            r/=10;
        }
        
        if(c%2!=0)
            m++;
    }
    cout<<m<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; i++)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;

int main(void)
{
        int n;
        int f[110][10];
        int p[110][11];
        int c[110]={0};
        int m = INT_MIN;
        int rieki = 0;

        cin >> n;
        REP(i,n)REP(j,10)cin >> f[i][j];
        REP(i,n)REP(j,11)cin >> p[i][j];

        for(int i = 1; i < (1<<10); i++){
                rieki = 0;
                REP(j,n){
                        REP(k,10){
                                if(i&(1<<k) && f[j][k]) c[j]++;
                        }
                        rieki+=p[j][c[j]];
                        c[j]=0;
                }
                m = max(m,rieki);
        }

        cout << m << endl;

        return 0;
}

Measured memory_bytes: 256
N, K, C = map(int, input().split())
S = input()
count = 0
day = 0
pre_list = []
while count < K:
    if S[day] == "o":
        pre_list.append(day + 1)
        day += C
        count += 1
    day += 1

count = 0
day = N-1
post_list = []
while count < K:
    if S[day] == "o":
        post_list.append(day+1)
        day -= C
        count += 1
    day -= 1
post_list.reverse()

ans = []
for i in range(K):
    if pre_list[i] == post_list[i]:
        ans.append(pre_list[i])

for a in ans:
    print(a)


Measured memory_bytes: 113604
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }




void solve(void)
{
  int N,X;
  cin>>N>>X;
  if(X == 1 || X ==2*N-1)
  {
    cout<<"No"<<endl;
    return;
  }
  vector<int> vec(2*N-1,0);
  for (int i = 0; i < 2*N-1; i++)
  {
    vec[i] = i+1;
  }
  if(N == 2)
  {
    cout<<"Yes"<<endl;
    for (int i = 0; i < 2*N-1; i++)
    {
      cout<<i+1<<endl;
    }
    
    return;
  }
  int M = 2*N -1;
  vector<int> ANS(M,0);
  if(X != 2)
  {
  set<int> SET;
  SET.insert(X);
  SET.insert(X+1);
  SET.insert(X-2);
  SET.insert(X-1);
  ANS[M/2] = X;
  ANS[M/2+1] = X + 1;
  ANS[M/2+2] = X - 2;
  ANS[M/2-1] = X -1;
  int n = 1;
  for (int i = 0; i < M; i++)
  {
    while(SET.find(n) != SET.end())
    n++;
    if(ANS[i] > 0)continue;
    ANS[i] = n;
    n++;

  }
  

  }
  else
  {
  set<int> SET;
  SET.insert(X);
  SET.insert(X+1);
  SET.insert(X+2);
  SET.insert(X-1);
  ANS[M/2] = X;
  ANS[M/2+1] = X - 1;
  ANS[M/2+2] = X + 2;
  ANS[M/2-1] = X +1;
  int n = 1;
  for (int i = 0; i < M; i++)
  {
    while(SET.find(n) != SET.end())
    n++;
    if(ANS[i] > 0)continue;
    ANS[i] = n;
    n++;

  }
  }
  cout<<"Yes"<<endl;
  for (int i = 0; i < M; i++)
  {
    cout<<ANS[i]<<endl;
  }
  
  
  



  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 4608
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;


void array_show(int *a,int n){
	for(int i=0;i<n;i++)printf("%d%c",a[i],(i!=n-1?' ':'\n'));
}
void array_show(LL *a,int n){
	for(int i=0;i<n;i++)printf("%lld%c",a[i],(i!=n-1?' ':'\n'));
}

LL dp[100005];

int main(){
	int n,m;
	int i,j,k;
	LL a,b,c;
	cin>>n>>m;
	dp[0]=1;
	for(i=0;i<n;i++){
		cin>>a;
		for(j=m-a+1,b=0;j<=m;j++)b+=dp[j];
		for(j=m;j>=0;j--){
			if(a<=j)b+=dp[j-a];
			b-=dp[j];
			dp[j]+=b;
			if(dp[j]>=MAX)dp[j]%=MAX;
		}
	}
	cout<<dp[m]<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<math.h>

using namespace std;

int main(void){

    int n, d, count = 0;
    double tmp = 0.0;

    cin >> n >> d;

    int pos[n][d];

    for(int i = 0;i < n;i++){
        for(int j = 0;j < d;j++){
            cin >> pos[i][j];
        }
    }

    for(int i = 0;i < n;i++){
        for(int j = i+1;j < n;j++){
            for(int k = 0;k < d;k++){
                tmp += pow(pos[i][k]-pos[j][k], 2);
            }
            tmp = sqrt(tmp);

            if(tmp == tmp - (tmp - (int)tmp)) count++;
            tmp = 0;
        }
    }

    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>

typedef long long unsigned int ullint;

int main(void){

  ullint a, b, n;
  std::cin >> a >> b >> n;

  if(n>=b-1){
    n = b-1;
  }
  std::cout << ((a*n)/b) << std::endl;
 
  return 0;
}


Measured memory_bytes: 3592
n, x = map(int, input().split())
s = list(map(int, input().split()))

s.sort()
cnt = 0

for i in range(n):
    if x >= s[i]: 
        x -= s[i]
        cnt += 1
    else:
        x = 0
        break

if x > 0:
    cnt -= 1

print(cnt)


Measured memory_bytes: 3060
#include <stdio.h>
int s[1<<15];
int main(void)
{
    int i, j, k, n;
    for(i=1;i*i<(1<<15);++i) s[i*i]=i;
    while (scanf("%d", &n), n) {
        int res=!!s[n];

        for(i=1;i*i<n;++i) res+=!!(s[n-i*i]>=i);

        for(i=1;i*i<n-1;++i)
        for(j=i;i*i+j*j<n;++j) res+=(s[n-i*i-j*j]>=j);

        for(i=1;i*i<n-2;++i)
        for(j=i;i*i+j*j<n-1;++j)
        for(k=j;i*i+j*j+k*k<n;++k) res+=!!(s[n-i*i-j*j-k*k]>=k);

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

Measured memory_bytes: 728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

	ll n;
	cin >> n;
	vll a(n), cnt(n, 0);
	for (ll i = 0; i < n - 1; i++) {
		cin >> a[i];
		cnt[a[i] - 1]++;
	}
	for (ll i = 0; i < n; i++) cout << cnt[i] << endl;
}


Measured memory_bytes: 6428
#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<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	VI a(3);
	cin >>a[0] >>a[1] >>a[2];
	
	int ans = 0;
	int mx = *max_element(all(a));
	rep(i, 3) if(a[i] !=mx && mx- a[i] > 1){
		int z= (mx - a[i]) /2;
		a[i] += 2*z;
		ans +=z;
	}
	int df = 0;
	rep(i, 3) df += mx - a[i];
	if(df == 1) ans +=2;
	if(df == 2) ans +=1;
	cout << ans <<"\n"; 
	return 0;


}


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

signed main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int temp1=a/b;
    if(temp1!=0)
    {
        int fac=log2(temp1)+1;
       // cout<<fac<<endl;
        b=b*pow(2LL,fac);
        k-=fac;
    }
    int temp2=b/c;
    if(temp2!=0)
    {
        int fac=log2(temp2)+1;
       // cout<<fac<<endl;
        k-=fac;
    }
    if(k<0)
    {
        cout<<"No"<<endl;
    }
    else cout<<"Yes"<<endl;
}


Measured memory_bytes: 3752
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.ST                 as ST
import qualified Data.Array.Unboxed            as AU
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Foldable                 as DF
import           Data.Int
import qualified Data.IntMap                   as IM
import           Data.List
import qualified Data.Map                      as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                      as S
import qualified Data.Sequence                 as SQ
import           Data.Time
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
readInts n = replicateM n readInt
readString = map BS.unpack . BS.words <$> BS.getLine
readStrings n = replicateM n <$> readString
toPair [x, y] = (x, y)

main = do
  [n] <- readInt
  a   <- readInt
  mapM_ print $ solve a

f a = (sum a', M.fromList a'')
 where
  a' = map (\x -> g $ length x) $ group $ sort a
  a'' :: [(Int, Int)]
  a'' = map (\x -> (head x, length x)) $ group $ sort a

g :: Int -> Int
g x | x < 2     = 0
    | otherwise = x * (x - 1) `div` 2

solve :: [Int] -> [Int]
solve a = map (\x -> m - g (a' M.! x) + g (a' M.! x - 1)) a
  where (m, a') = f a



Measured memory_bytes: 68220
S = input()

SO = S[::2]  #奇数番目
SE = S[1::2] #偶数番目

SOC0 = SO.count("0")
SOC1 = SO.count("1")
SEC0 = SE.count("0")
SEC1 = SE.count("1")

#print(SOC0, SOC1, SEC0, SEC1)
print(min(SOC0+SEC1, SOC1+SEC0))


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

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

int main()
{
    int A, B, K, cnt = 0;

    cin >> A >> B >> K;
    for(int i = 100; i >= 1; i--) {
        if(A % i == 0 && B % i == 0) {
            cnt++;
            if(cnt == K) {
                cout << i << endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
inline int read()
{
	int x = 0 , f = 1; char ch = getchar();
	while(ch < '0' || ch > '9')	{if(ch == '-')	f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
const int N = 20;
ll a[N];
ll dfs(int l,int r,int xl,int xr)
{
	if(r - l <= 1) return 0;
	ll ans = 8e18;
	for(int i = l + 1;i < r;i ++) ans = min(ans,dfs(l,i,xl,xl + xr) + dfs(i,r,xl + xr,xr) + a[i] * (xl + xr));
	return ans;
}
int main()
{
	int n = read();
	for(int i = 1;i <= n;i ++) a[i] = read();
	printf("%lld\n",a[1] + a[n] + dfs(1,n,1,1));
}

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

using i64 = long long;

int main() {
  int n;
  std::cin >> n;
  int m = n / 2;
  int t = n - m * 2 + 2;
  std::vector<i64> a(n);
  for (auto &e : a) std::cin >> e;
  std::vector<i64> dp_(t + 1, 0);
  const auto dp = dp_.begin() + 1;
  dp[-1] = -10000000000000000;
  for (int i = 0; i < m; i += 1) {
    for (int j = 0; j < t; j += 1) {
      dp[j] = std::max(dp[j] + a[2 * i + j], dp[j - 1]);
    }
  }
  std::cout << dp[t - 1] << "\n";
}
  

Measured memory_bytes: 4848
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

int n;
int a;
deque<int> d;

int main() {
	scanf("%d ",&n);
	FORI(0, n) {
		scanf("%d ", &a);
		if (i % 2)
			d.push_back(a);
		else
			d.push_front(a);
	}
	if (n % 2) {
		for (int i = 0; i < n; i++, d.pop_front()) {
			int x = d.front();
			printf("%d%c", x, (i == n - 1) ? '\n' : ' ');
		}
	}
	else{
		for (int i = 0; i<n; i++, d.pop_back()) {
			int x = d.back();
			printf("%d%c", x, (i == n - 1) ? '\n' : ' ');
		}
	}
	return 0;
}


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

long long L[87];

void makeArray(){
  L[0] = 2;
  L[1] = 1;
  for(int i = 2; i < 87; i++){
    L[i] = L[i-1] + L[i-2];
  }
}

int main(){
  int n;
  cin >> n;
  makeArray();
  cout << L[n] << endl;
}


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

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

    vector<pair<int, int>> claim(m);
    for (auto i = 0; i < m; i++) {
        cin >> claim[i].second >> claim[i].first;
    }
    sort(claim.begin(), claim.end());

    int ans = 1, last = claim[0].first;
    for (auto i = 1; i < m; i++) {
        if(last > claim[i].second) continue;
        ans++;
        last = claim[i].first;
    }

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

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <set>

using namespace std;

int main() {

    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int total_cost = A * X + B * Y;
    //cout << total_cost << endl;
    int big = max(X, Y);
    int small = min(X, Y);

    int tc1;
    if (big == X) {
        tc1 = big * C * 2;
    } else {
        tc1 = big * C * 2;
    }
    //cout << tc1 << endl;
    total_cost = min(tc1, total_cost);

    int tc2;
    if (small == X) {
        tc2 = small * C * 2 + (big - small) * B;
    } else {
        tc2 = small * C * 2 + (big - small) * A;
    }
    //cout << tc2 << endl;
    total_cost = min(tc2, total_cost);

    cout << total_cost << endl;
	
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <functional>

using namespace std;

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		priority_queue< int, vector<int>, greater<int> > pq;
		int a;
		for (int i = 0; i < n; i++) {
			cin >> a;
			pq.push(a);
		}
		long long int counter = 0;
		long long int counter2 = 0;
		for (int i = 0; i < n-1; i++) {
			counter2 += pq.top();
			pq.pop();
			counter += counter2;
		}
		cout << counter << endl;
	}
	return 0;
}

Measured memory_bytes: 1320
N = int(input())
A = [list(map(int,input().split())) for _ in range(N)]
cnt = 0
for i in range(N-1):
    for j in range(i+1,N):
        amin = 10**10
        for k in range(N):
            if k!=i and k!=j:
                amin = min(amin,A[i][k]+A[k][j])
        if A[i][j]>amin:
            cnt = -1
            break
        elif A[i][j]<amin:
            cnt += A[i][j]
    if cnt==-1:break
print(cnt)

Measured memory_bytes: 44252
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <utility>
 
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

int main(void) {
    string now = "2019/04/30";
    string s;
    cin >> s;
    if (s <= now) {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }
    return 0;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define nl ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()

using namespace std;

int main() {
    nl // Chordyceps - Bittersweet Memories

    int a; cin >> a;
    cout << a+pow(a,2)+pow(a,3);

    return 0;
}

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

using namespace std;

struct Node
{
    int l,r;
} node[200050];
bool cmp(Node a, Node b)
{
    return a.r<b.r;
}
int main()
{
    int n,m;
    cin>>n>>m;

    for(int i=0; i<m; i++)
    {
        int a,b;
        cin>>a>>b;
        if(a>b)
            swap(a,b);

        node[i].l = a;
        node[i].r = b;
    }
    sort(node,node+m,cmp);

    vector<int>v;
    v.push_back(node[0].r);

    for(int i=1; i<m; i++)
    {
        int flag = 1;
        for(int j=0; j<v.size(); j++)
        {
            int rr = v[j];
            if(node[i].l<rr)
            {
                flag = 0;
                break;
            }

        }
        if(flag == 1)
        {
            v.push_back(node[i].r);
        }

    }
    cout<<v.size()<<endl;

    return 0;
}


Measured memory_bytes: 1024
x, y = gets.to_s.split.map { |s| s.to_i }
MOD = 1_000_000_007

def mod_pow(a, e, p)
  r = 1
  while e > 0
    r = r * a % p if (e & 1) == 1
    a = a * a % p
    e >>= 1
  end
  r
end

len = [y, 2*y-x].max
fact = [1, 1]
invt = [1, 1]
finv = [1, 1]
2.upto(len) do |i|
  fact[i] = i * fact[i-1] % MOD
  invt[i] = MOD - invt[MOD % i] * (MOD / i) % MOD
  finv[i] = finv[i-1] * invt[i] % MOD
end

cnt = 0

(0..2*y-x).each do |b|
  a = y-b*2
  next unless a >= 0 && a*2+b == x && a+b*2 == y
  
  cnt += fact[a+b] * finv[a] % MOD * finv[b] % MOD
end

p cnt % MOD


Measured memory_bytes: 44052
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

template <class T>
std::vector<T> enum_div(T n) {
    std::vector<T> ret;
    for (T i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

bool isPrime(ll num) {
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    for (ll i = 3; i * i <= num; i += 2) {
        if (num % i == 0) { return false; }
    }

    return true;
};

template <typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
bool is_integer(T x) {
    return std::floor(x) == x;
}

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

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

    int N;
    cin >> N;
    cout << (N - 1) / 2 << endl;

    return 0;
}


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

int main()
{
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      if (i < B)
      {
        cout << (j < A ? 1 : 0);
      }
      else
      {
        cout << (j < A ? 0 : 1);
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 3604