akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include<bitset>

using namespace std;
#define loop(i,n) for(int i = 0; i < (n); ++i)
#define loops(i,f,n) for(int i = (f); i < (n); ++i)
#define INF 9999999
#define lint long long int
#define VEC vector<int>
#define VEC2 vector<vector<int>>

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >>n ;
	if(n<1200)cout<<"ABC"<<endl;
	else if (n<2800)cout << "ARC" << endl;
	else cout << "AGC" << endl;
}

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

int main(void)
{
    long long N, A, B, C;
    vector<vector<long long>> ABC(6, vector<long long>(3));
    cin >> N >> A >> B >> C;
    ABC[0][0] = A;
    ABC[0][1] = B;
    ABC[0][2] = C;
    ABC[1][0] = A;
    ABC[1][1] = C;
    ABC[1][2] = B;
    ABC[2][0] = B;
    ABC[2][1] = A;
    ABC[2][2] = C;
    ABC[3][0] = B;
    ABC[3][1] = C;
    ABC[3][2] = A;
    ABC[4][0] = C;
    ABC[4][1] = A;
    ABC[4][2] = B;
    ABC[5][0] = C;
    ABC[5][1] = B;
    ABC[5][2] = A;    
    vector<long long> L(N);
    for(long long i = 0; i < N; i++)
    {
        cin >> L[i];
    }
    long long tmptmpans = 10000;
    for (long long a = 0; a < 6; a++)
    {
        vector<long long> l(N);
        long long ans = 0;
        for(long long i = 0; i < N; i++)
        {
            l[i] = L[i];
        }
        for (long long i = 0; i < 3; i++)
        {
            long long tmpans = 10000;
            vector<long long> tmpcount(l.size());
            for (long long j = 1; j < pow(2,l.size()); j++)
            {
                vector<long long> count(l.size());
                for (long long k = 0; k < l.size(); k++)
                {
                    count[k] = 0;
                }
                long long X = j;
                long long num = 0;
                while(X > 0)
                {
                    if (X & 1)
                    {
                        count[num] = 1;
                    }
                    num++;
                    X >>= 1;
                }
                long long answer = 0;
                long long sum = 0;
                long long countb = 0;
                for (long long k = 0; k < l.size(); k++)
                {
                    
                    if (count[k] == 1)
                    {
                        sum++;
                        countb += l[k];
                    }
                }
                answer += 10 * (sum-1) + abs(ABC[a][i] - countb);
                if (answer < tmpans)
                {
                    tmpans = answer;
                    for (long long k = 0; k < l.size(); k++)
                    {
                        tmpcount[k] = count[k];
                    }
                }
            }
            ans += tmpans;
            for(long long i = 0; i < l.size(); i++)
            {
                if (tmpcount[i] == 1)
                {
                    l[i] = 10000;
                }
            }
        }
        if (tmptmpans > ans)
        {
            tmptmpans = ans;
        }
    }   
    cout << tmptmpans << endl;
}

Measured memory_bytes: 4112
import sys
N=input()
A=[];B=[]
P=[]
for i in range(N):
    a,b=map(int,raw_input().split())
    A.append(a);B.append(b)
    P.append((b,a))
P.sort()

t=0
for b,a in P:
    t+=a
    if t>b:
        print("No")
        sys.exit(0)
print("Yes")        

Measured memory_bytes: 36484
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			cout << v[i][j] << "   ";
		}
		cout << endl;
	}
}




int main(){//
	ll N, W;
	cin >> N >> W;
	vector<ll> w(N+1, 0), v(N+1, 0);
	for(int i=1; i<=N; i++) cin >> w[i] >> v[i];


	const int INF = 1e9 + 5;
	const int MAX_v = 100000+5;
	//dp[m][v]: m個目まで考えた時，価値がvとなる最小重さ
	vector<vector<ll>> dp(N+3, vector<ll>(MAX_v, INF));
	dp[0][0] = 0;
	for(int m=0; m<=N; m++){
		for(int j=0; j<MAX_v; j++){
			dp[m+1][j] = min(dp[m+1][j], dp[m][j]+0);//m番目を入れない
			if(j+v[m+1] < MAX_v) dp[m+1][j+v[m+1]] = min(dp[m+1][j+v[m+1]], dp[m][j] + w[m+1]);
		}
	}

	//print_vec2(dp);
	ll ans = 0;
	for(ll i=0; i<MAX_v; i++){
		if(dp[N][i] <= W) ans = max(ans, i);

	}
	cout << ans << endl;

}


Measured memory_bytes: 84820
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	LL a,b;
	cin>>a>>b;
	LL ans=0LL;
	int aa=a%4,bb=b%4;
	if(b-a<=8){
		LL ii;
		for(ii=a;ii<=b;ii++){
			ans^=(ii&1);
		}
	}else{
		FOR(i,aa,4){
			ans^=(i&1);
		}
		FOR(i,0,bb+1){
			ans^=(i&1);
		}
	}
	FOR(i,1,60){
		LL tmp=1LL<<(i+1);
		LL aaa=a%tmp,bbb=b%tmp;
		if(aaa<tmp/2)aaa=tmp/2;

		ans^=(1LL<<i)*((tmp-aaa)&1);
		if(bbb>=tmp/2){
			ans^=(1LL<<i)*((bbb-tmp/2-1)&1);
		}
	}
	cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define REP(i,last) for (int i=0;i<last;i++)
#define MAX(x,y) (x > y ? x : y)
#define MIN(x,y) (x < y ? x : y)
#define prints(str) cout << str << " ";
#define printn(str) cout << str << endl;

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

const int MAX_N = 1e5;

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

  int a[3*N];
  REP(i,3*N){
    cin >> a[i];
  }
  
  sort(a, a+3*N);
  reverse(a, a+3*N);

  ll ans = 0;
  REP(i,N){
    ans += a[i*2 + 1];
  }

  printn(ans);
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fto(i, s, e) for (int i = (s); i <= (e); ++i)
#define fto1(i, s, e) for (int i = (s); i < (e); ++i)
#define fdto(i, s, e) for (int i = (s); i >= (e); --i)
#define fit(it, a) for (auto it = (a).begin(); it != (a).end(); ++it)
#define fat(i, a) for (auto i : (a))

#define ll long long
#define ii pair<int, int>
#define pll pair<ll, ll>
template<class T, class Cmp = less<T>> using oss = tree<T, null_type, Cmp, rb_tree_tag, tree_order_statistics_node_update>;

#define bc __builtin_popcountll
#define y1 ansdj
#define endl '\n'
#define ff first
#define ss second
#define sz(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define bug(...) _bug(cout, __VA_ARGS__)
#define bugn(...) _bugn(#__VA_ARGS__, __VA_ARGS__)
#define buga(a, s, e) cout << '{'; fto (i, s, e) cout << a[i] << " }"[i == e]; cout << endl

template<class T1, class T2> ostream& operator<<(ostream &os, pair<T1, T2> const &v) {
    return os << '(' << v.ff << ", " << v.ss << ')';
}

template<typename T>
void _bug(ostream &os, T const &var) { os << var << endl; }

template<typename T, typename... Args>
void _bug(ostream &os, T const &var, Args const &... args) {
    os << var << ' ';
    _bug(os, args...);
}

template<typename... Args>
void _bugn(string const &s, Args const &... args) {
    auto split = [](string const &s, string const &delim) {
        int next, pos = 0;
        vector<string> res;
        while (1) {
            next = s.find(delim, pos);
            if (next == string::npos) break;
            res.push_back(s.substr(pos, next-pos));
            pos = next+sz(delim);
        }
        res.push_back(s.substr(pos));
        return res;
    };

    ostringstream os; _bug(os, args...);
    string tmp = os.str(); tmp.pop_back(); 
    vector<string> v1 = split(s, ", "), v2 = split(tmp, " ");
    fto1 (i, 0, sz(v1)) cout << '[' << v1[i] << ": " << v2[i] << "]" << " \n"[i == sz(v1)-1];
}

double const pi = acos(-1);
#define oo 1000000007
#define OO 1000000000000000003LL
int const maxn = 1e5+3;

ll calc(int n) {
    if (n == 1) return 1;
    static vector<int> div; div.clear();
    for (int i = 2; (ll)i * i <= n; ++i) {
        if (n%i == 0) {
            div.push_back(0);
            while (n%i == 0) {
                n /= i;
                ++div.back();
            }
        }
    }
    if (n > 1) div.push_back(1);
    int res = 1;
    fat (d, div) res *= d+1;
    return res;
}

#define multi_test 0
void _main() {
    int n; cin >> n;
    ll ans = 0;
    fto1 (i, 1, n) ans += calc(i);
    bug(ans);
}

int main() {
    #ifdef KITTENS
        freopen("main.inp", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int t = 1;
    if (multi_test) cin >> t;
    while (t--) {
        _main();
    }

    #ifdef KITTENS
        cerr << 0.001*clock() << endl;
    #endif
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
#include <string>
#include <stack>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;

typedef long long llong;

int main() {
	int N, L[11], max_index = 0;
	cin >> N;

	for (int i = 0; i < N; ++i) {
		cin >> L[i];
		if(L[max_index] < L[i]){
			max_index = i;
		}
	}

	int smaller_sum = 0;

	for (int k = 0; k < N; ++k) {
		if(k != max_index){
			smaller_sum+= L[k];
		}
	}

	if(smaller_sum > L[max_index]) {
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int asc(const void *a, const void *b)
{
    return *(long int *)a - *(long int *)b;
}
int dis(const void *a, const void *b)
{
    return *(long int *)b - *(long int *)a;
}
int main()
{
    int k, a, b;
    scanf("%d %d %d", &k, &a, &b);
    if (a % k == 0 || b % k == 0 || b / k > a / k)
    {
        printf("OK");
    }
    else
    {
        printf("NG");
    }

    return 0;
}

Measured memory_bytes: 1732
use std::cmp::max;
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let aa = (0..n).map(|_| read::<usize>()).collect::<Vec<_>>();

    let mut left = vec![0; n];
    let mut right = vec![0; n];

    left[0] = aa[0];
    right[n - 1] = aa[n - 1];

    for i in 1..n {
        left[i] = gcd(left[i - 1], aa[i]);
        right[n - 1 - i] = gcd(right[n - i], aa[n - 1 - i]);
    }

    // compare case i == 0 and case i == n - 1
    let mut ans = max(right[1], left[n - 2]);
    for i in 1..n - 1 {
        let now = gcd(left[i - 1], right[i + 1]);
        ans = max(ans, now)
    }

    println!("{}", ans);

    fn gcd(a: usize, b: usize) -> usize {
        if b == 0 {
            a
        } else {
            gcd(b, a % b)
        }
    }
}


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

#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define x first
#define y second
#define sz(x) (x).size()
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal

#define ll long long
#define ld long double

const ld EPS = 10e-9;
const int INF = 1e9 + 5;
const long long INFLL = (ll)INF * (ll)INF;
const ll MOD = 1e9 + 7;
const ld PI = 3.14159265358979323846;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "[";
    for (int i = 0; i < (int)v.size(); ++i) {
        os << v[i];
        if (i != (int)v.size() - 1)
            os << ", ";
    }
    os << "]\n";
    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const set<T>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it;
        if (it != *v.rbegin())
            os << ", ";
    }
    os << "}\n";
    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const unordered_set<T>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it;
        if (it != *v.rbegin())
            os << ", ";
    }
    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const map<T, S>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it.first << " : "
           << it.second;

        if( it != *v.rbegin())
            os  << ", ";
    }

    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const unordered_map<T, S>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it.first << " : "
           << it.second;

        if( it != *v.rbegin())
            os  << ", ";
    }

    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const pair<T, S>& v)
{
    os << "(";
    os << v.first << ", "
       << v.second << ")";
    os << "\n";
    return os;
}

#define DEBUG

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define debug(...)
#endif


// __gcd(x, y)

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;

    int N, K;
    cin >> N >> K;

    vector<vector<int>> snukes(N, vector<int>());
    for(int i = 0; i < K; i++)
    {
        int di;
        cin >> di;

        for(int j = 0; j < di; j++)
        {
            int snuke;
            cin >> snuke;
            snukes[snuke-1].push_back(i);
        }
    }

    int num = 0;
    for(auto& s : snukes)
        if(s.size() == 0)
            num++;

    cout << num << endl;
    return 0;
}




Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for (string &i : s) cin >> i;
  sort(s.begin(), s.end());
  int ans = 1;
  for (int i = 0; i < n-1; i++) if (s[i] != s[i+1]) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9524
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define ld double
#define pb push_back
#define EPS 1e-9
#define all(a) a.begin(),a.end()
#define sz(a) int((a).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
using namespace std;
typedef pair<int, int> II;
typedef pair<II, int> III;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    //freopen("inp.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n, m;
    cin >> n >> m;
    cout << (n-1) * (m-1);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

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

    cout << ceil((double)N/(2*D+1)) << endl;
}

Measured memory_bytes: 3744
a,b,c,x,y = map(int,input().split())
if a+b > c*2:
  if x >= y:
    print(min(c*2*y+a*(x-y),c*2*x))
  else:
    print(min(c*2*x+b*(y-x),c*2*y))
else:
  print(a*x+b*y)

Measured memory_bytes: 3060
def main():

    A, B, C = map(int, input().split())
    d = dict()
    for i in [A, B, C]:
        d[i] = d.get(i, 0) + 1
    if d[5] == 2 and d[7] == 1:
        return "YES"
    return "NO" 

if __name__ == '__main__':
    print(main())

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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;

void solve(){
	ll n;
	cin>>n;
	bool ok = true;
	string prev;
	unordered_map<string,bool> ma;
	for(int i=0;i<n;i++){
		string s;cin>>s;
		if(i==0) ma[s]=true;
		else if(prev[prev.length()-1]!=s[0] || ma[s]) ok = false;
		prev=s;ma[s]=true;
	}
	puts(ok?"Yes":"No");
}

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

	//ll t;cin>>t;while(t--)
	solve();

}


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

void call(int n){
	for(int i=1; i<= n; i++){
		int x = i;
		if( x%3 == 0 ){
			cout << " " << i;
			continue;
		}
		do{
			if( x%10== 3 ){
				cout << " " << i;
				break;
			}
			x /= 10;
		} while(x);
	}
}

int main(){
	int n;
	cin >> n;
	call(n);
	cout << endl;
	return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define mod2 1000000006
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pi 3.141592653589793
#define FF first
#define SS second
using namespace std ;
 
const lli dx4[] = {-1, 0, 1, 0};
const lli dy4[] = {0, 1, 0, -1};
const lli dx8[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const lli dy8[] = {0, 1, 0, -1, -1, 1, -1, 1};
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count()); // can give negative values too

#define N 100001

void solve()
{
    lli n;
    cin>>n;

    lli cnt=0;

    loopl(i,0,n)
    {
        lli x;
        cin>>x;

        if(i%2 == 0 && x%2 == 1)
            cnt++;
    }

    cout<<cnt;
    
}   

int main()
{
////////////////////////////////////////////   
    fastio;
////////////////////////////////////////////
    
    lli t;
    t=1;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3600
import itertools


def is_compatible_internal(hyp, statement):
    honests = {key for key in statement if statement[key] == 1}
    unkinds = {key for key in statement if statement[key] == 0}

    return len(honests - hyp) == 0 and len(unkinds - hyp) == len(unkinds)


def is_compatible(hyp, statements):
    for i in hyp:
        if not is_compatible_internal(hyp, statements[i]):
            return False
    return True


def main():
    n = int(input())

    all_statements = [{}]
    for _ in range(n):
        ai = int(input())
        statements = {}
        for _ in range(ai):
            x, y = input().split()
            statements[int(x)] = int(y)
        all_statements.append(statements)

    for e in all_cases(n):
        if is_compatible(e, all_statements):
            print(len(e))
            return

    print(0)


def all_cases(n):
    for r in range(n, 0, -1):
        for ensemble in itertools.combinations(range(1, n + 1), r):
            yield set(ensemble)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        mut s: chars,
    }
    let ans = if n % 2 != 0 {
        "No"
    } else {
        let s2 = s.split_off(n / 2);
        if s == s2 {
            "Yes"
        } else {
            "No"
        }
    };
    println!("{}", ans);
}


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

using namespace std;

int main()
{ int n,l;
 scanf("%d%d",&n,&l);
  char s[n][l+1];
  int i,j;
  char temp[l+1];
  for(i=0;i<n;++i)
      scanf("%s",&s[i]);
  
  for(i=0;i<n;++i)
  {
    for(j=i+1;j<n;++j)
    { 
        if(strcmp(s[i],s[j])>0)
        {
          strcpy(temp,s[i]);
          strcpy(s[i],s[j]);
          strcpy(s[j],temp);
        }
    }
  }
 for(i=0;i<n;++i)
    printf("%s",s[i]);
}
    

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <queue>
#include <set>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
using P = pair<double,int>;


int main(){
  int a,b; cin >> a >> b;
  cout << a*b << endl;
  return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
 
#define int long long
#define left left1
#define right right1
 
using namespace std;

int n, m, k;
vector <int> g[100001];
vector <int> b[100001];
int u[100001];
int kol[100001];
int sz;

void dfs (int v) {
    u[v] = sz;
    kol[sz] ++;
    for (auto to : g[v]) {
        if (!u[to]) {
            dfs (to);
        }
    }
}

 main () {
    //freopen ("deleg.in", "r", stdin);
    //freopen ("deleg.out", "w", stdout);
	ios_base::sync_with_stdio (0);
	cin.tie (0), cout.tie (0);
    cin >> n >> m >> k;
    for (int i = 1;i <= m;i ++) {
        int x, y;
        cin >> x >> y;
        g[x].push_back (y);
        g[y].push_back (x);
    }
    for (int i = 1;i <= k;i ++) {
        int x, y;
        cin >> x >> y;
        b[x].push_back (y);
        b[y].push_back (x);
    }
    for (int i = 1;i <= n;i ++) {
        if (!u[i]) {
            sz ++;
            dfs (i);
        }
    }
    for (int i = 1;i <= n;i ++) {
        int id = u[i];
        int qwe = g[i].size ();
        int ans = kol[id] - 1 - qwe;
        for (auto  to : b[i]) {
            if (id == u[to]) ans --; 
        }
        cout << ans << ' ';
    }
	return 0;   
}

Measured memory_bytes: 14080
#include <stdio.h>
#define N 100

void dijkstra(void);

int n,a[N][N];

int main(){
  int i,j,x,y,z,w;

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

  for(i = 0;i < n;i++){
    scanf("%d %d",&x,&y);
    for(j = 0;j < y;j++){
      scanf("%d %d",&z,&w);
      a[x][z] = w;
    }
  }

  dijkstra();
  
  return 0;
}

void dijkstra(void){
  int i,u,v,d[N],sum = 0,mincost,color[N];
  
  for(u = 0;u < n;u++){
    d[u] = 10000000;
    color[u] = 0; //0=white
  }

  d[0] = 0;
  color[0] = 1; //1=gray

  while(1){
    mincost = 10000000;
    u = -1;
    for(i = 0;i < n;i++){
      if(color[i] != 2 && d[i] < mincost){ //2=black
	mincost = d[i];
	u = i;
      }
    }
    if(u == -1) break;

    color[u] = 2;

    for(v = 0;v < n;v++){
      if(color[v] != 2 && a[u][v] != 10000000){
	if(d[v] > d[u] + a[u][v]){
	  d[v] = d[u] + a[u][v];
	  color[v] = 1;
	}
      }
    }
  }

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



Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  while(true){
    cin >>H >>W;
    if(H==0 && W==0) break;
    for(int i=0; i<W; i++) cout <<"#";
    cout << endl;
    for(int j=0; j<(H-2); j++){
      cout << "#";
      for(int i=0; i<(W-2); i++) cout <<".";
      cout << "#" << endl;}
    for(int i=0; i<W; i++) cout <<"#";
    cout << "\n" << endl;}
  return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9+7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}

vector<ll> FactorialInv, Factorial;

void init_combination(ll MAX){
    Factorial.resize(MAX + 1);
    FactorialInv.resize(MAX + 1);
    Factorial[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % mod;
    }
    FactorialInv[MAX] = power(Factorial[MAX], mod - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
    }
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    if(b < 0) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}

//modの値の確認をすること
int main(){
    ll n,ans = 0;
    map<ll,ll> m;
    cin >> n;
    vector<ll> a(n);
    rep0(i, n){
        cin >> a[i];
        ++m[a[i] + i];
    }
    rep0(i, n)ans += m[i - a[i]];
    pf(ans);
    return 0;
}


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

int main() {
    int n, count, s;
    count = 0;
    s = 1;
    cin >> n;
    vector<int> vec(n);

    for(int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }

    for(int j = 0; j < n; j++) {
        s = vec.at(s-1);
        count++;

        if(s==2) {
            cout << count << endl;
            break;
        }

        if(j==n-1) {
            cout << -1 << endl;
            break;
        }
    }
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 1000000007;

struct FiniteField {
 private:
  int64 x;
  static inline int64 Normalize(int64 x) {
    if (0 <= x && x < P) return x; x %= P; if (x < 0) x += P; return x;
  }
 public:
  FiniteField(int64 x) : x(Normalize(x)) {}
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

ostream& operator<<(ostream& s, const FiniteField& v) { s << v.Value(); return s; }

tuple<vector<FiniteField>, vector<FiniteField>> MakeFactorialTables(int n) {
  vector<FiniteField> factorials(n + 1);
  vector<FiniteField> inverse_factorials(n + 1);
  factorials[0] = 1;
  for (int i = 1; i <= n; i++) {
    factorials[i] = factorials[i - 1] * i;
  }
  inverse_factorials[n] = FiniteField(1) / factorials[n];
  for (int i = n; i >= 1; i--) {
    inverse_factorials[i - 1] = inverse_factorials[i] * i;
  }
  return make_tuple(factorials, inverse_factorials);
}

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

  int b, w;
  cin >> b >> w;

  FiniteField half = FiniteField(1) / 2;

  vector<FiniteField> fs, i_fs;
  tie(fs, i_fs) = MakeFactorialTables(b + w + 1);
  auto c_fn = [&](int a, int b) -> FiniteField {
    if (a < 0) return 0;
    if (b < 0 || b > a) return 0;
    return fs[a] * i_fs[b] * i_fs[a - b];
  };

  FiniteField x = 0;
  FiniteField y = 0;
  FiniteField unit = 1;
  for (int k = 0; k < b + w; k++) {
    x += unit * c_fn(k - 1, w - 1);
    y += unit * c_fn(k - 1, b - 1);
    FiniteField r = x + (FiniteField(1) - x - y) * half;
    cout << r << "\n";

    unit *= half;
  }
}

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

#define p100 (a == 1 && b == 0 && c == 0)
#define p010 (a == 0 && b == 1 && c == 0)
#define p110 (a == 1 && b == 1 && c == 0)
#define p001 (a == 0 && b == 0 && c == 1)
#define p000 (a == 0 && b == 0 && c == 0)

int main() {
	int a, b, c; cin >> a >> b >> c;
	if (p110 || p001) cout << "Open" << endl;
	if (p100 || p010 || p000) cout << "Close" << endl;
	return 0;
}


Measured memory_bytes: 3092
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	long long sum,syo,n,k,a,b,c;
	scanf("%lld %lld",&n,&k);
	if(k%2==0)	{
		a=n/k;
		sum=a*a*a;
		c=n%k;
		if(c>=k/2)	{
			b=a+1;
		}
		else {
			b=a;
		}
		sum+=b*b*b;
	}
	else {
		a=n/k;
		sum=a*a*a;
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(){
    string s,t;
    cin>>s>>t;
    string ans = "No";
    ll n = s.size();
    string a,b;
    for(ll i=0;i<n;++i){
        a = s[n-1];
        s = s.substr(0, n-1);
        s = a+s;
        if(s == t){
            ans = "Yes";
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
main(){int n,i,j;double x[4],y[4];std::cin>>n;for(i=0;i<n;i++){for(j=0;j<4;j++)std::cin>>x[j]>>y[j];if(((y[0]-y[1])/(x[0]-x[1]))==((y[2]-y[3])/(x[2]-x[3])))std::cout<<"YES\n";else std::cout<<"NO\n";}}

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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

const ll mod = 1e9 + 7;

int main() {
  ll h, w, k;
  cin >> h >> w >> k;
  if (k >= 4) {
    puts("0");
    return 0;
  }

  vvll omp(w, vll(h));
  rep(i, h) {
    string s;
    cin >> s;
    rep(j, w) omp[j][h - 1 - i] = (s[j] - '0');
  }

  vvll mp;

  auto fall = [&](ll j) {
    vll& tgt = mp[j];
    vll nv;
    rep(i, h) if (tgt[i] != -1) nv.push_back(tgt[i]);
    ll times = h - (ll)nv.size();
    rep(i, times) nv.push_back(-1);
    mp[j] = nv;
    assert(nv.size() == (size_t)h);
  };

  // auto printmp = [&](string s) {
  //   cout << s << endl;
  //   rep(i, h) {
  //     rep(j, w) printf("%3lld ", mp[j][h - 1 - i]);
  //     cout << endl;
  //   } // i
  // };

  ll ans = 0;
  rep(i, h) rep(j, w) {
    mp = omp;
    mp[j][i] = -1;
    //printmp("start bef");
    fall(j);
    //printmp("start aft");
    ll score = 0;
    for (ll loop = 0;; loop++) {
      bool erflag = false;
      rep(ii, h) rep(jj, w) {
        if (mp[jj][ii] == -1) continue;
        ll cnt = 1;
        for (ll jdx = jj + 1; jdx <= w; jdx++) {
          if (jdx < w && mp[jdx][ii] == mp[jj][ii])
            cnt++;
          else {
            if (cnt >= k) {
              erflag = true;
              ll add = (1LL << loop)*mp[jj][ii];
              rep(era, cnt) {
                score += add;
                mp[jj + era][ii] = -1;
              }  // era
            }
            break;
          }
        }  // jdx
      }    // jj, ii
      if (!erflag) break;

      //printmp("before fall");
      rep(jdx, w) fall(jdx);
      //printmp("after fall");
      //cout << score << endl;
    }  // loop
    chmax(ans, score);
  }  // j, i

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#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 sumW[4100][4100];
int sumB[4100][4100];

int Wsum(int i, int j, int k, int l)
{
    int res = sumW[i][j];

    if (k > 0)
        res -= sumW[k - 1][j];

    if (l > 0)
        res -= sumW[i][l - 1];

    if (k > 0 && l > 0)
        res += sumW[k - 1][l - 1];

    return res;
}

int Bsum(int i, int j, int k, int l)
{
    int res = sumB[i][j];

    if (k > 0)
        res -= sumB[k - 1][j];

    if (l > 0)
        res -= sumB[i][l - 1];

    if (k > 0 && l > 0)
        res += sumB[k - 1][l - 1];

    return res;
}

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

    int n, k, x[112345], y[112345];
    char c[112345];

    cin >> n >> k;
    REP(i, n)
    cin >> x[i] >> y[i] >> c[i];

    int res = 0;

    memset(sumW, 0, sizeof(sumW));
    memset(sumB, 0, sizeof(sumB));

    REP(i, n)
    {
        if (c[i] == 'W')
        {
            sumW[x[i] % (k * 2)][y[i] % (k * 2)]++;
            sumW[x[i] % (k * 2)][y[i] % (k * 2) + k * 2]++;
            sumW[x[i] % (k * 2) + k * 2][y[i] % (k * 2)]++;
            sumW[x[i] % (k * 2) + k * 2][y[i] % (k * 2) + k * 2]++;
        }
        if (c[i] == 'B')
        {
            sumB[x[i] % (k * 2)][y[i] % (k * 2)]++;
            sumB[x[i] % (k * 2)][y[i] % (k * 2) + k * 2]++;
            sumB[x[i] % (k * 2) + k * 2][y[i] % (k * 2)]++;
            sumB[x[i] % (k * 2) + k * 2][y[i] % (k * 2) + k * 2]++;
        }
    }

    REP(i, k * 4)
    {
        for (int j = 1; j < k * 4; j++)
        {
            sumW[i][j] += sumW[i][j - 1];
            sumB[i][j] += sumB[i][j - 1];
        }
    }

    for (int i = 1; i < k * 4; i++)
    {
        REP(j, k * 4)
        {
            sumW[i][j] += sumW[i - 1][j];
            sumB[i][j] += sumB[i - 1][j];
        }
    }

    for (int i = 0; i < k * 2; i++)
    {
        for (int j = 0; j < k * 2; j++)
        {
            int r = 0;

            r += Wsum(i + k - 1, j + k - 1, i, j);
            r += Wsum(i + k * 2 - 1, j + k * 2 - 1, i + k, j + k);
            r += Bsum(i + k * 2 - 1, j + k - 1, i + k, j);
            r += Bsum(i + k - 1, j + k * 2 - 1, i, j + k);

            res = max(res, r);
        }
    }

    cout << res << endl;

    /*
    REP(i, k * 4)
    {
        REP(j, k * 4)
        cout << sumW[i][j] << " ";

        cout << endl;
    }
    cout << endl;
    REP(i, k * 4)
    {
        REP(j, k * 4)
        cout << sumB[i][j] << " ";

        cout << endl;
    }
    */

    return 0;
}

Measured memory_bytes: 132480
#include<stdio.h>
int main(void){
	int num[4],i,work,k;
	scanf("%d %d %d",&num[0],&num[1],&num[2]);
	num[3]=10001;
	for(k=0;k<3;k++){
		for(i=0;i<3;i++){
			if(num[i]>num[i+1]){
				work=num[i];
				num[i]=num[i+1];
				num[i+1]=work;
			}
		}
	}
	printf("%d ",num[0]);
	printf("%d ",num[1]);
	printf("%d\n",num[2]);
	
	return 0;
}


Measured memory_bytes: 1808
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (;;) {
            int[] l = new int[5];
            boolean[] t = new boolean[3];
            l[0] = sc.nextInt()-1;
            if (l[0] == -1) {
                break;
            }
            t[l[0]] = true;
            for (int i = 1; i < 5; i++) {
                l[i] = sc.nextInt()-1;
                t[l[i]] = true;
            }
            for (int i = 0; i < 5; i++) {
                if (t[0] ^ t[1] ^ t[2]) {
                    System.out.println(3);
                } else {
                    for(int j=0;j<3;j++) {
                        if(l[i]!=j&&t[l[i]]==t[j]) {
                           System.out.println((l[i]-j+3)%3==2?1:2);
                           break;
                        }
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 28852
N = input()
Hlist = list(map(int, input().split()))

maxnum = 0
num = 0
now = Hlist[0]
Hlist.remove(Hlist[0])

for i in Hlist:
		if now >= i:
				num += 1
		else:
				maxnum = max(num, maxnum)
				num = 0
		now = i

maxnum = max(num, maxnum)

print(maxnum)


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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);i++)
#define FOR2(i,a,b) for (int i=(a);i<(b);i++)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define ROF2(i,x,y) for(int i = (y) ; i >= (x) ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
#define FAST ios_base::sync_with_stdio(false); cin.tie(0)

template<class T,class U>
ostream &operator<<(ostream &os,const pair<T,U> &x) {
    return os<<"("<<x.first<<","<<x.second<<")";
}

template<class T>
ostream &operator<<(ostream &os,const vector<T> &x) {
    os << '[';
    if ( !x.empty() ) {
        std::copy (x.begin(), x.end(), std::ostream_iterator<T>(os, ","));
        os << "\b";
    }
    os << "]";
    return os;
}
template<class T>
ostream &operator<<(ostream &os,const vector<vector<T> > &x) {
    os << '[';
    if ( !x.empty() ) {
        os << x[0];
        for (int i=1;i<x.size();i++) os << endl << " " << x[i];
    } else os << "[]";
    os << "]";
    return os;
}

int main() {
    FAST;
    //freopen ("in.txt", "r", stdin);
    int n,m;cin>>n>>m;

    vii p(m);
    FOR(i,m){
        int a,b;cin>>a>>b;
        if (a>b) swap(a,b);
        p[i]=MP(a,b);
    }
    sort(p.begin(),p.end());
    int fin=p[0].second;
    int cnt=0;
    FOR2(i,1,m){
        if (fin<=p[i].first){
            cnt++;
            fin=p[i].second;
        }else {
            fin = min(fin, p[i].second);
        }
    }
    cout << cnt+1;
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

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

const ll mod = 1e9 + 7;

ll modpow(ll a, ll b){
    if(b == 0)return 1;
    if(b%2 == 0){
        ll k = modpow(a,b/2);
        return k*k%mod;
    }else{
        return modpow(a,b-1)*a%mod;
    }
}

ll gcd(ll a,ll b){
    ll p = max(a,b);
    ll q = min(a,b);
    while(p%q != 0){
        ll s = p%q;
        p = max(s,q);
        q = min(s,q);
    }
    return q;
}



int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    string n;
    cin >> n;
    ll num = 0;
    rep(i,n.size()){
        int k = n[i] - '0';
        num = num + k;
        num %= 9; 
    }

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


    return 0;


}


Measured memory_bytes: 3768
#include<stdio.h>
#include<string.h>
int n,m;
int i,j;
char st[1000000];
char ans[10000000];
int now;
int counter;

char tochar(int a){
	switch(a){
	case 0:
		return '0';
	case 1:
		return '1';
	case 2:
		return '2';
	case 3:
		return '3';
	case 4:
		return '4';
	case 5:
		return '5';
	case 6:
		return '6';
	case 7:
		return '7';
	case 8:
		return '8';
	case 9:
		return '9';
	}
}

void change(){
	counter=1;
	now=0;
	char string[100]="";
	int cou=0;
	for(int k=0;k<strlen(st)-1;k++){
		cou=0;
		char a=st[k];
		char b=st[k+1];
		if(a==b)counter++;
		else{
			cou=0;
			string[0]='\0';
			while(counter>=1){
				string[cou++]=tochar(counter%10);
				counter=(int)(counter/10);
			}
			string[cou]='\0';
			for(int l=cou-1;l>=0;l--)ans[now++]=string[l];
			ans[now++]=(char)(st[k]);
			counter=1;	
		}
	}
	cou=0;
	string[0]='\0';
	while(counter>=1)
	{
		string[cou++]=tochar(counter%10);
		counter=(int)(counter/10);
	}
	string[cou]='\0';
	for(int l=cou-1;l>=0;l--){
		ans[now++]=string[l];
	}
	ans[now++]=(char)(st[strlen(st)-1]);
	ans[now]='\0';
}

int main(){
	while(1){
		scanf("%d",&n);
		if(n==0)return 0;
		scanf("%s",st);
		for(i=0;i<n;i++){
			change();
			for(j=0;j<now;j++)st[j]=ans[j];
			st[now]='\0';
		}
		for(i=0;i<now;i++)printf("%c",ans[i]);
		printf("\n");
		ans[0]='\0';
	}
	printf("%s",ans);
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define f first
#define s second
#define pii pair<int,int>
using namespace std;
typedef queue<pii> qpii;
 
int xo[4] = {1, -1, 0, 0};
int yo[4] = {0, 0, 1, -1};
int n, m;
 
bool good(int x, int y) {
	return x >= 1 && x <= n && y >= 1 && y <= m;
}
 
void test_case() {
	int k, a, b, c, d; cin >> n >> m >> k >> a >> b >> c >> d;
	
	vector<string> grid(n+1);
	vector<vector<int> > odl(n+1, vector<int>(m+1, 1e9));
	vector<vector<bool> > odw(n+1, vector<bool>(m+1));
	for (int i = 1; i <= n; i ++) cin >> grid[i];
	qpii Q;
	Q.push({a, b});
	odl[a][b] = 0;
	odw[a][b] = true;
	
	while (!Q.empty()) {
		pii cur = Q.front(); Q.pop();
		for (int i = 0; i < 4; i ++) {
			for (int j = 1; j <= k; j ++) {
				int X = cur.f + xo[i] * j;
				int Y = cur.s + yo[i] * j;
				if (good(X, Y)) {
					if (grid[X][Y-1] == '@' || odl[X][Y] < odl[cur.f][cur.s] + 1) break;
					if (!odw[X][Y]) {
						odl[X][Y] = odl[cur.f][cur.s] + 1;
						odw[X][Y] = true;
						Q.push({X, Y});
					}
				}
			}
		}
	}
	cout << (odl[c][d] == 1e9 ? -1 : odl[c][d]) << '\n';
}
 
int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	test_case();
	return 0;
}


Measured memory_bytes: 15060
#include<bits/stdc++.h>
#define F first
#define S second
#define LL long long
using namespace std;
typedef pair<int,int>P;
typedef vector<int>V;
typedef priority_queue<int,V,greater<int>>PQ;
int main(void){
	int n,m;
	int nn;
	int x;
	P pp[100001];
	int i;
	LL sum;
	PQ que;
	cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>x;
		que.push(x);
	}
	for(i=0;i<m;i++){
		cin>>pp[i].F>>pp[i].S;
		swap(pp[i].F,pp[i].S);
	}
	sort(pp,pp+m,greater<P>());
	for(i=0;i<m;i++)	swap(pp[i].F,pp[i].S);
	for(i=0;i<m;i++){
		nn=0;
		while(1){
			x=que.top();
			//cout<<"X="<<x<<endl;
			if(nn==pp[i].F)	break;
			if(pp[i].S<=x)	break;
			else{
				que.pop();
				que.push(pp[i].S);
			}
			nn++;
		}
	}
	sum=0;
	for(i=0;i<n;i++){
		x=que.top();
		//cout<<x<<endl;
		sum+=(LL)x;
		que.pop();
	}
	cout<<sum<<endl;
	return 0;
}
			
	
		
	

Measured memory_bytes: 1660