akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
 string s, t;
  cin >> s;
  cin >> t;
  
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());

  if(s < t) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

bool isprime(int x)
{
int kijun=0;
for(int i=2;i<x;i++)
{
if(x%i==0)  {kijun++;}
}
if(kijun==0){return true;}
else{return false;}
}


int main(){
int answer;
cin>>answer;
while(isprime(answer)==false){answer++;}
cout<<answer<<endl;

}

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

int main() {
    // 展望台、展望台の高さ、道で繋がっている展望台がセット
    // 全探索かソートか
    // 道を追加する時点で、高さに差があれば、一方は良い展望台であり、一方は良い展望台ではないことが確定する？
    // 道が追加されない展望台は良い展望台であるから、良い展望台ではない展望台（低い方の展望台）を、道の追加時点で答えの候補から削除できる
    // 具体例
        // 6 5
        // 8 6 9 1 2 1
        // 1 3 高さは1<3より、1を除外
        // 4 2 高さは4<2より、4を除外
        // 4 3 高さは4<3より、4を除外
        // 4 6 高さは4=6より、4も6も除外
        // 4 6 高さは4=6より、4も6も除外
        // 1,4,6の3つが除外されたので、残る3つが答え
    int n, m;
    cin >> n >> m;
    vector<int> obs(n); // 各展望台の高さを格納する配列
    for (int i = 0; i < n; i++) {
        cin >> obs.at(i);
    }
    set<int> badobs; // 良い展望台でない展望台を格納する集合
    for (int i = 0; i < m; i++) {
        int x, y; // 道で繋がれた展望台の番号
        cin >> x >> y;
        if (obs.at(x-1) < obs.at(y-1)) { // 道で繋がれた展望台の高さの低い方を良い展望台ではないとして排除
            badobs.insert(x);
        } else if (obs.at(x-1) > obs.at(y-1)) {
            badobs.insert(y);
        } else { // 二つの展望台の高さが同じ場合はどちらも良い展望台ではない
            badobs.insert(x);
            badobs.insert(y);
        }
    }
    cout << obs.size() - badobs.size() << endl; // 展望台の数から、良い展望台ではない展望台の数を引いた値が答え
    // m回ペアの入力を繰り返し
    // cin >> x >> y;
    // pair<int,int> p(x,y);
    // ペアの数字はそれぞれ展望台の番号を指す
    // よく考えたらペアじゃなくても良くてもそのまま入力した値を使えば良いな
    // 展望台の番号からそれぞれの高さにアクセスし比較する
    // if (obs.at(x-1) > obs.at(y-1))
    // 低い方の展望台の番号を、setに格納
    // badobs.insert(y);
    // else if (obs.at(x-1) < obs.at(y-1))
    // badobs.insert(x);
    // 同じなら、両方setに加える
    // else
    // badobs.insert(x); badobs.insert(y);
    // 最終的にsetの大きさ（良い展望台ではない展望台の数）を、展望台の数から引いたのが答えのはず
    // cout << obs.size() - badobs.size() << endl;
}

Measured memory_bytes: 6424
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "x", long, "y", long, "cost");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    auto s = sread();
    long cnt = INF;
    if (s.allEqual())
    {
        writeln(0);
        return;
    }

    foreach (c; "abcdefghijklmnopqrstuvwxyz")
    {
        cnt = min(s.needchange(c), cnt);
    }
    cnt.writeln();
}

long needchange(string str, char c)
{
    if (str.length == 1)
        return 1;

    auto newstr = new char[](str.length - 1);
    foreach (i; iota(str.length - 1))
    {
        newstr[i] = (str[i] == c || str[i + 1] == c) ? c : str[i];
    }
    if (newstr.allEqual())
        return 1;
    else
        return 1 + needchange(newstr.to!string, c);
}

bool allEqual(T)(T s)
{
    bool ret = true;
    foreach (i; iota(s.length - 1))
        ret &= s[i] == s[i + 1];
    return ret;
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 508
#include <stdio.h>

int main(){
    
    int S,h,m,s;
    scanf("%d", &S);
    
    h = S/3600;
    m = (S%3600)/60;
    s = (S%3600) - m*60;

    printf("%d:%d:%d\n",h,m,s);
}


Measured memory_bytes: 2732
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////


int main() {
	
	cout << fixed << setprecision(10);

	double n, m, d;
	cin >> n >> m >> d;

	double x;
	if (d == 0) { x = n; }
	else { x = 2.0 * (n - d); }

	double ans = x / n / n * (m - 1);

	cout << ans;


	system("PAUSE");
}


Measured memory_bytes: 504
h1,m1,h2,m2,k = map(int,input().split())

if h1 < h2:
    t = (h2-h1-1)*60 + (60-m1) + m2
elif h1 == h2:
    t = m2 - m1
else:
    t = (60-m1) + (24 - h1 + h2)*60 + m2

print(t-k)


Measured memory_bytes: 9164
from collections import Counter
n = int(input())

D = Counter(list(input()))
for i in range(n-1):
    d = Counter(list(input()))
    key = D.keys()
    for k in key:
        D[k] = min(D[k], d[k])

ans = []
key = D.keys()
for k in key:
    for i in range(D[k]):
        ans.append(k)
ans.sort()
print("".join(ans))

Measured memory_bytes: 9444
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define ls(x) (x<<1)
#define rs(x) (ls(x)|1)
#define eps 1e-11
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef double db;
const int mod = 1e9 + 7;
const int N = 2e5 + 5;
const int M = 1e3 + 5;
ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; }
ll lcm(ll a,ll b){ return a*b/gcd(a,b); }
inline ll qsm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;
x=x*x%mod; y>>=1;} return res; }
int n, m;
int cnt[N], sz[N], p[N], ans[N];
vector<int> g[N];
void dfs(int u, int fa){
    sz[u]=cnt[u]=1;
    for(auto v:g[u]){
        if(v==fa) continue;
        dfs(v,u);
        sz[u]+=sz[v];
        cnt[u]=1ll*cnt[u]*cnt[v]%mod*qsm(p[sz[v]],mod-2)%mod;
    }
    cnt[u]=1ll*cnt[u]*p[sz[u]-1]%mod;
}

void dfs2(int u, int fa,int d){
    ans[u]=1ll*cnt[u]*qsm(p[sz[u]-1],mod-2)%mod*p[n-1]%mod*qsm(p[n-sz[u]],mod-2)%mod*d%mod;
    for(auto v:g[u]){
        if(v==fa) continue;
        int tmp=1ll*ans[u]*qsm(p[n-1],mod-2)%mod*p[n-sz[v]-1]%mod*p[sz[v]]%mod*qsm(cnt[v],mod-2)%mod;
        dfs2(v,u,tmp);
    }
}

int main(){
    int x,y;
    scanf("%d",&n);
    p[0]=1;
    rep(i,1,n) p[i]=1ll*p[i-1]*i%mod;
    rep(i,1,n-1){
        scanf("%d%d",&x,&y);
        g[x].pb(y);
        g[y].pb(x);
    }
    dfs(1,0);
    //rep(i,1,n) printf("%d\n", cnt[i]);
    dfs2(1,0,1);
    rep(i,1,n) printf("%d\n", ans[i]);
    return 0;
}
/*
k
*/
//
//                            _ooOoo_
//                           o8888888o
//                           88" . "88
//                           (| -_- |)
//                           O\  =  /O
//                        ____/`---'\____
//                      .'  \|     |//  `.
//                     /  \|||  :  |||//  \
//                    /  _||||| -:- |||||-  \
//                    |   | \  -  /// |   |
//                    | \_|  ''\---/''  |   |
//                    \  .-\__  `-`  ___/-. /
//                  ___`. .'  /--.--\  `. . __
//               ."" '<  `.___\_<|>_/___.'  >'"".
//              | | :  `- \`.;`\ _ /`;.`/ - ` : | |
//              \  \ `-.   \_ __\ /__ _/   .-` /  /
//         ======`-.____`-.___\_____/___.-`____.-'======
//                            `=---='
//        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//                     佛祖保佑      永无BUG


Measured memory_bytes: 17012
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep2(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 100100100100;
const int MOD = 1000000007;


int main(){
  int N, M; cin >> N >> M;
  vector<int> wa(N, 0);
  vector<bool> ac(N, false);
  rep(i, M){
    int p; cin >> p;
    p--;
    string s; cin >> s;
    if(s == "AC") ac[p] = true;
    else if(!ac[p]) wa[p]++;
  }

  int pen, nac;
  pen = nac = 0;
  rep(i, N){
    if(ac[i]){
      nac++;
      pen += wa[i];
    }
  }
  cout << nac << " " << pen << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = ll(1e9 + 7);

ll dp[42][1 << 17];
int N;
int X[3];

vector<int> tovec(int bit) {
	vector<int> v;
	int a = 1;
	while(bit) {
		if(bit & 1) {
			v.push_back(a);
			a = 0;
		}
		a++;
		bit >>= 1;
	}
	return v;
}

int tobit(vector<int>& v) {
	int b = 0, sum = 0;
	for(int i = v.size() - 1; i >= 0; i--) {
		int a = v[i];
		sum += a;
		if(sum > 16) break;
		b <<= 1;
		b++;
		b <<= a - 1;
	}
	return b;
}

bool check(vector<int>& v) {
	int now = 2, rem = X[2];
	for(int i = v.size() - 1; i >= 0; i--) {
		int a = v[i];
		rem -= a;
		if(rem < 0) return false;
		if(rem == 0 && now == 0) return true;
		if(rem == 0) rem = X[--now];
	}
	return false;
}

ll f(int n, int bit) {
	if(n == N) return 1;
	if(dp[n][bit] != -1) return dp[n][bit];

	dp[n][bit] = 0;
	vector<int> v = tovec(bit);
	for(int i = 1; i <= 10; i++) {
		v.push_back(i);
		if(!check(v)) {
			int nb = tobit(v);
			dp[n][bit] += f(n + 1, nb);
			dp[n][bit] %= MOD;
		}
		v.pop_back();
	}
	return dp[n][bit];
}


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

	cin >> N;
	for(int i = 0; i < 3; i++) {
		cin >> X[i];
	}
	memset(dp, -1, sizeof dp);

	ll ans = 1;
	for(int i = 0; i < N; i++) {
		ans *= 10;
		ans %= MOD;
	}
	cout << (ans + MOD - f(0, 0)) % MOD << endl;
}

Measured memory_bytes: 43392
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 40000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

string S;
int X, Y;
vector <int> fx, fy;
bool flag[4096][MAX];


void solve(void){
    //input
    cin >> S >> X >> Y;
    int j = 0, tcnt = 0;
    rep(S.size(), i) {
        if (S[i] == 'F') tcnt++;
        else {
            if (j%2==0) fx.pb(tcnt);
            else fy.pb(tcnt);
            j++; tcnt = 0;
        }
    }
    if (j%2==0) fx.push_back(tcnt);
    else fy.push_back(tcnt);
    //init
    X -= fx[0];
    fx[0] = 0;

    //check
    memset(flag, false, sizeof(flag));
    flag[0][MAX/2] = true;
    rep(fx.size(), x) {
        rep(MAX, nx) {
            if (flag[x][nx]) {
                flag[x+1][nx-fx[x]] = flag[x+1][nx+fx[x]] = true;
            }
        }
    }
    bool can = flag[fx.size()][MAX/2+X];
    if (j > 0) {
        memset(flag, false, sizeof(flag));
        flag[0][MAX/2] = true;
        rep(fy.size(), y) {
            rep(MAX, ny) {
                if (flag[y][ny]) {
                    flag[y+1][ny-fy[y]] = flag[y+1][ny+fy[y]] = true;
                }
            }
        }
        can = can and flag[fy.size()][MAX/2+Y];
    }
    else can = can and Y == 0;
    cout << (can?"Yes":"No") << '\n';
}

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


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

int main(){
	int N, T;
	cin >> N >> T;
	
	int ans = 100005;
	for(int i=0; i<N; i++){
		int t, c;
		cin >> c >> t;
		if(t <= T){
			ans = min(ans, c);
		}
	}
	
	if(ans == 100005) cout << "TLE" << endl;
	else cout << ans << endl;
	
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trv(a) cerr<<#a<<":\n";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define mod 1000000007
#define inf 9999999999999999ll

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	bool p=true;
	for(ll i=0;i<n;i++)
	{
		ll x;
		cin>>x;
		if(x%2==0)
		{
			if(x%5==0 || x%3==0)
			{

			}
			else
				p=false;
		}
	}
	if(p)
		cout<<"APPROVED\n";
	else
		cout<<"DENIED\n";
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace A {
static class Extensions {
   public static int ToInt(this string str) =>
      int.Parse(str);

   public static int[] readIntArr() =>
      ReadLine().Split(' ').Select(int.Parse).ToArray();

   public static long[] readLongArr() =>
      ReadLine().Split(' ').Select(long.Parse).ToArray();
   
   public static void Fill<T>(this List<T> a, T b) {
      for (var i = 0; i < a.Capacity; i++) {
         a.Add(b);
      }
   } 

   public static void Fill<T>(this T[] a, T b) {
      for (var i = 0; i < a.Length; i++) {
         a[i] = b;
      }
   }
}

class Program {
    static string Smax(string a, string b) {
        if (a.Length > 0 && a[0] == '-') {
            return b;
        }
        else if (a.Length < b.Length) {
            return b;
        }
        else if (a.Length > b.Length) {
            return a;
        }
        else {
            for (var i = 0; i < a.Length; i++) {
                if (a[i] > b[i]) {
                    return a;
                }
                else if (a[i] < b[i]) {
                    return b;
                }
            }
            return a;
        }
    }

    public static void Main(string[] args) {
        var tmp = Extensions.readIntArr();
        var N = tmp[0]; // マッチの数
        var M = tmp[1];
 
        var arr = Extensions.readIntArr().OrderBy(e => -e).ToArray();

        var match = new int[9]{2,5,5,4,5,6,3,7,6};
        /*
          dp[i] ちょうどi本のマッチを使って作れる整数の桁数
        */
        var dp = new int[N + 1];
        dp.Fill(-1);
        dp[0] = 0;

        for (var i = 1; i <= N; i++) {
            foreach (var e in arr) {
                var reqm = match[e - 1];
                if (reqm > i) {
                    continue;
                }
                else if (dp[i - reqm] < 0) {
                    continue;
                }
                else {
                    dp[i] = Max(dp[i], dp[i - reqm] + 1);
                }
            }
        }

        var sb = new StringBuilder();
        var keta = dp.Last();

        var rest = N;
        for (var i = 0; i < keta; i++) {
            foreach(var e in arr) {
                var reqm = match[e - 1];
                if (rest - reqm >= 0 && dp[rest - reqm] == dp[rest] - 1) {
                    sb.Append(e.ToString());
                    rest -= reqm;
                    break;
                }
            }
        }

        WriteLine(sb.ToString());
   }
}

}


Measured memory_bytes: 13440
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__",", __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000123456789LL

void solve(int n, int m){
  int s,t;
  cin>>s>>t;
  s--;t--;
  vector<vector<pair<int,double>>> vec(n*n*31 + 2);
  // (f*n+v)*31 + V : ??´??????f??§v??????????????????V

  rep(i,m){
    int a,b,c; double d;
    cin>>a>>b>>d>>c;
    a--;b--;
    // a -> b
    rep(j,n)if(j!=b && j!=a){
      rep(k,31){
        int from = (j*n+a)*31+k;
        if(k-1>0 && k-1<=c) vec[from].pb(mp((a*n+b)*31+k-1, d/(k-1)));
        if(k>0 && k<=c) vec[from].pb(mp((a*n+b)*31+k, d/k));
        if(k+1>0 && k+1<=c) vec[from].pb(mp((a*n+b)*31+k+1, d/(k+1)));
      }
    }
    // b -> a
    rep(j,n)if(j!=b && j!=a){
      rep(k,31){
        int from = (j*n+b)*31+k;
        if(k-1>0 && k-1<=c) vec[from].pb(mp((b*n+a)*31+k-1, d/(k-1)));
        if(k>0 && k<=c) vec[from].pb(mp((b*n+a)*31+k, d/k));
        if(k+1>0 && k+1<=c) vec[from].pb(mp((b*n+a)*31+k+1, d/(k+1)));
      }
    }
  }

  int from = n*n*31, dest = from+1;

  rep(i,n) if(i!=s) vec[from].pb(mp((i*n+s)*31+0, 0));
  rep(i,n) if(i!=t) vec[(i*n+t)*31+1].pb(mp(dest, 0));

  // dijkstra
  vector<double> d(n*n*31+2, INF);
  d[from] = 0;
  typedef pair<double,int> P;
  priority_queue<P, vector<P>, greater<P>> pq;
  pq.push(mp(0,from));
  while(!pq.empty()){
    auto p = pq.top(); pq.pop();
    int v = p.second; double dis = p.first;
    if(d[v] < dis) continue;
    for(auto &to : vec[v]){
      double nd = dis + to.second;
      if(d[to.first] <= nd) continue;
      d[to.first] = nd;
      pq.push(mp(nd, to.first));
    }
  }
  if(d[dest] == INF) cout << "unreachable" << endl;
  else printf("%.6f\n", d[dest]);
}

int main(){
  int n,m;
  while(cin>>n>>m, n|m) solve(n,m);

  return 0;
}

Measured memory_bytes: 56392
#include <iostream>

//a>bのときの最大公約数(greatest common divisor)を計算する関数
long int get_gcd(long int a, long int b){
    long int r,gcd;
	r = a % b;
	if(r == 0)
		gcd = b;
	else 
		gcd = get_gcd(b,r);
    return gcd;
}
			

int main(){
	long int a, b,tmp,gcd;
	while(std::cin >> a >> b){
		if(b>a){
		tmp = a;
		a = b;
		b = tmp;
	}
		gcd = get_gcd(a,b);
		std::cout << gcd << " " << a*b/gcd << std::endl;
	}
	return 0;
}

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

int main(){
  int n, m;
  cin >> n >> m;
  P p[n];
  rep(i,n) cin >> p[i].first >> p[i].second;
  sort(p,p+n);
  int ans = 0;
  int pos = 0;
  priority_queue<int> que;
  for(int i = 1; i <= m; i++) {
    while(pos < n and p[pos].first <= i) {
      que.push(p[pos].second);
      pos++;
    }
    if(!que.empty()) {
      ans += que.top();
      que.pop();
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4644
#include<iostream>
using namespace std;
int main(){
	int n, k; cin >> n >> k;
	k++;
	int ans = 0;
	while (n > 0) {
		int m = (n + k - 1) / k;
		n -= m;
		ans++;
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
   string x,y;
   cin >> x >> y;
   if (x[0] == y[2] && x[1] == y[1]&&x[2]==y[0])
   {cout <<"YES" << endl;
  }else {
      cout << "NO" << endl;
  }
   
    
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
const int MaxN = 2e5;
long long a[MaxN + 5];
int N;
long long T, x;

int main()
{
	long long flag = 0;
	scanf("%d %lld", &N, &T);
	for(int i = 1; i <= N; i++)
	{
		scanf("%lld", &a[i]);
	}
	for(int i = 1; i <= N; i++)
	{
		if(a[i] <= T)
		{
			flag = a[i];
			x = a[i];
		}
		else if(a[i] - a[i - 1] > T) x = x + T;
		else x = x + a[i] - a[i - 1];
	}
	printf("%lld\n", x + T);
	return 0;
}

Measured memory_bytes: 1792
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0;i < n;i++)
#define INF 1 << 30

int MOD = 1000000007;



int main(){
    std::ios_base::sync_with_stdio(false);

    int n; cin >> n;
    std::vector<int> a(n); REP(i,n) cin >> a[i];
    std::vector<int> v(100001, 0);
    int ans = n;

    int one = 0, two = 0;


    REP(i,n) v[a[i]]++;
    REP(i,100001){
        if(v[i] >= 3){
            if(v[i]%2==0){
                ans-=v[i]-2;
                v[i] = 2;
            } else {
                ans-=v[i]-1;
                v[i] = 1;
            }
        }
    }
    REP(i,100001){
        if(v[i] == 1) one++;
        else if(v[i] == 2) two++;
    }

    ans -= 2*(two/2);
    two%2==0 ? two=0 : two=1;

    if(two==1) ans-=2;

    cout << ans << endl;





    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define N 10000

void mpAdd(int *,int *,int *);
void mpNum2Str(char *,int *);
void mpStr2Num(int *,char *);

int main(void){
  int ans[1000],a[1000],b[1000],i,j,n;
  char ach[1000],bch[1000],str[1000];

  scanf("%d",&n);
  
  rep(j,n){
    scanf("%s",ach);
    scanf("%s",bch);    
    mpStr2Num(a,ach);
    mpStr2Num(b,bch);
    mpAdd(ans,a,b);
    mpNum2Str(str,ans);
    
    if(strlen(str)>80)printf("overflow\n");
    else printf("%s\n",str);
  }
  return 0;
}

void mpAdd(int *ret, int *a, int *b){
    int  i;
    int  lr, la, lb;
    int  *rr;
    int  x;

    la = *a;
    lb = *b;
    lr = (la >= lb) ? la : lb;

    rr = ret;
    x = 0;
    for (i = 1; i <= lr; i++) {
        if (i <= la) x += *++a;
        if (i <= lb) x += *++b;
        if (x < N) {
            *++rr = x;
            x = 0;
        } else {
            *++rr = x - N;
            x = 1;
        }
    }
    *++rr = x;
    *ret = lr + x;
}

void mpNum2Str(char *str, int *num){
    int  i, j;
    char *ss;
    int  x;

    if (*num == 0) {
        *str++ = '0';
        *str = '\0';
        return;
    }

    ss = str - 1;
    for (i = *num; i > 0; i--) {
        x = *++num;
        for (j = 1; j < N; j *= 10) {
            *++ss = x % 10 + '0';
            x /= 10;
        }
    }
    while (*ss == '0') ss--;

    *(ss + 1) = '\0';    
    while (str < ss) {
        x = *str;
        *str++ = *ss;
        *ss-- = x;
    }
}

void mpStr2Num(int *num, char *str){
    char *ss;
    int  *nn;
    int  k;
    int  x;

    while (*str == ' ' || *str == '\t') str++;
    while (*str == '0') str++;
    ss = str;
    while (*ss >= '0' && *ss <= '9') ss++;

    if (ss == str) {
        *num = 0;
        return;
    }

    x = 0;
    k = 1;
    nn = num;
    do {
        x += (*--ss - '0') * k;
        k *= 10;
        if (k == N || ss == str) {
            *++nn = x;
            x = 0;
            k = 1;
        }
    } while (ss != str);

    *num = nn - num;
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <complex>

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> p(n), q(n);
	for (int i = 0; i < n; i++) cin >> p[i];
	for (int i = 0; i < n; i++) cin >> q[i];
	vector<int> v(n);
	for (int i = 0; i < n; i++) v[i] = i + 1;
	int now = 0;
	int flag = -1;
	int answer = 0;
	if (p == q) {
		cout << 0;
		return 0;
	}
	do {
		now += 1;
		if (v == p || v == q) {
			answer += flag * now;
			flag *= -1;
		}
	} while (next_permutation(v.begin(), v.end()));
	cout << answer;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
using namespace std;
using ll = long long;
using pil = pair<int, ll>;


const ll INF = (ll)1e18;
const int N = 200200;
int n, m;
vector<pil> Graph[N]; // <p1, p2> のp1は関係を持つ頂点,p2は辺の重み
bool used[N];
ll min1, min2;
ll val[N];  // 二部グラフの頂点の重み. 二次元配列にしないように工夫している


void dfs(int v){
  used[v] = 1;
  for(pil e : Graph[v]){
    int u = e.first; // 相手の頂点
    ll w = e.second - val[v]; // 相手の頂点の重み
    if(used[u]){
      if (w != val[u]){
        min2 = -INF;
        return ;
      }
      continue;
    }
    val[u] = w;
    // 二部グラフのどちらの側かを判定する
    if(u < n){
      min1 = min(min1, w);
    }else{
      min2 = min(min2, w);
    }

    dfs(u);
  }
  return ;
}
int main(){
  int k;
  cin >> n >> m;
  cin >> k;
  while(k--){
    int v, u;
    ll x;
    cin >> v >> u >> x;
    // 0インデックスにする
    v--;
    u--;
    // 1次元配列で表現するための工夫
    u += n;
    Graph[v].push_back(make_pair(u, x));
    Graph[u].push_back(make_pair(v, x));
  }

  for(int i = 0; i < n; ++i){
    if (used[i]) continue;
    min1 = 0;
    min2 = INF;
    val[i] = 0;
    dfs(i);
    if(min1 + min2 < 0){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 15104
n = int(input())
answer = 0
for i in range(1, n+1, 2):
    num_of_divisor = 0
    for j in range(1, i+1):
        if i % j == 0:
            num_of_divisor += 1
    if num_of_divisor == 8:
        answer += 1
print(answer)

Measured memory_bytes: 3060
N = int(input())
xu = [[] for i in range(N)]
otoshidama = 0
for i in range(N):
    xu[i] = list(input().split())
for i in xu:
    if i[1] == 'JPY':
        otoshidama += int(i[0])
    else:
        otoshidama += float(i[0])*380000
print(otoshidama)

Measured memory_bytes: 3060
#include<iostream>
#include<map>
#include<algorithm>
#include<functional>
#include<bitset>
#include<vector>
#include<set>
using  namespace std;
#define ll long long
#define pb push_back
#define sc second
#define fr first
#define mp make_pair
const int  MOD = 1e9 + 7, OO = 1e9;
const int  N = 2e5 + 10;
int a[30][30], calc[30];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll  l, r;
	cin >> l >> r;
	if ((l - 1) / 2019 != r / 2019) {
		cout << 0 << endl; return 0;
	}
	l %= 2019;
	r %= 2019;
	if (l > r) swap(l, r);
	
	int ans = 2018;
	for (int i = l; i <= r; ++i) {
		for (int j = i + 1; j <= r;++j) {
			ans = min(ans, (i*j) % 2019);
		}
	}
	cout << ans%2019 << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>

using namespace std;

void get(vector <int> &A, int &max_1, int &max_2)
{
    for(int i = 0; i < A.size(); i++)
    {
        if(A[i] >= A[max_1])
        {
            max_2 = max_1;
            max_1 = i;
        }
        else if(A[i] > A[max_2])
        {
            max_2 = i;
        }
    }
}

int main()
{
    int no_of_elements;
    scanf("%d", &no_of_elements);

    const int MAX_N = 1e5 + 5;
    vector <int> odd_frequency(MAX_N, 0);
    vector <int> even_frequency(MAX_N, 0);

    for(int i = 1; i <= no_of_elements; i++)
    {
        int element;
        scanf("%d", &element);

        if(i%2 == 0)
        {
            even_frequency[element]++;
        }
        else if(i%2 == 1)
        {
            odd_frequency[element]++;
        }
    }

    int most_frequent_even_element = 0, second_most_frequent_even_element = 0;
    get(even_frequency, most_frequent_even_element, second_most_frequent_even_element);

    int most_frequent_odd_element = 0, second_most_frequent_odd_element = 0;
    get(odd_frequency, most_frequent_odd_element, second_most_frequent_odd_element);

    int changes;
    int even_changes = 0, odd_changes = 0;
    if(most_frequent_even_element != most_frequent_odd_element)
    {
        even_changes = no_of_elements/2 - even_frequency[most_frequent_even_element];
        odd_changes = no_of_elements/2 - odd_frequency[most_frequent_odd_element];
        changes = even_changes + odd_changes;
    }
    else if(most_frequent_even_element == most_frequent_odd_element)
    {

            even_changes = no_of_elements/2 - even_frequency[most_frequent_even_element];
            odd_changes = no_of_elements/2 - odd_frequency[second_most_frequent_odd_element];
            int option_1 = even_changes + odd_changes;


            even_changes = no_of_elements/2 - even_frequency[second_most_frequent_even_element];
            odd_changes = no_of_elements/2 - odd_frequency[most_frequent_odd_element];
            int option_2 = even_changes + odd_changes;

        changes = min(option_1, option_2);
    }

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


Measured memory_bytes: 1024
import java.util.Scanner;

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

        int a = scan.nextInt();

        int b = scan.nextInt();
        
        if(a<b){
            System.out.println("a < b");
        }
        if(a>b){
            System.out.println("a > b");
        }
        if(a==b){
             System.out.println("a == b");
        }
    } 
}


Measured memory_bytes: 26204
# coding: utf-8
# Your code here!

n = int(input())
M = []
for i in range(n):
    adj = list(map(int,input().split()))
    if adj[1] == 0:
        M += [[]]
    else:
        M += [adj[2:]]
time = 1
ans = [[j+1,0,0] for j in range(n)] # id d f

while True:
    for i in range(n):
        if ans[i][1] == 0:
            stack = [i]
            ans[i][1] = time
            time += 1
            break
        elif i == n-1:
            for k in range(n):
                print(*ans[k])
            exit()
    while stack != []:
        u = stack[-1]
        if M[u] != []:
            for i in range(len(M[u])):
                v = M[u][0]
                M[u].remove(v)
                if ans[v-1][1] == 0:
                    ans[v-1][1] = time
                    stack.append(v-1)
                    time += 1
                    break
        else:
            stack.pop()
            ans[u][2] = time
            time += 1
     
        
    



Measured memory_bytes: 5652
import collections

N=int(input())
A=list(map(int,input().split()))
B=collections.Counter(A)
C=sum([x*(x-1)//2 for x in B.values()])

for i in A:
  temp=B[i]
  print(C-(temp*(temp-1)//2-(temp-1)*(temp-2)//2))

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

int main() {
	int n, t[100], v[100];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	int a[102], b[102], m[102];
	a[0] = b[n] = 0;
	for (int i = 0; i < n; i++) {
		if (t[i] < v[i] - a[i]) {
			a[i + 1] = a[i] + t[i];
		} else {
			a[i + 1] = v[i];
		}
	}
	for (int i = n - 1; i >= 0; i--) {
		if (t[i] < v[i] - b[i + 1]) {
			b[i] = b[i + 1] + t[i];
		} else {
			b[i] = v[i];
		}
	}
	for (int i = 0; i < n + 1; i++) {
		m[i] = min(a[i], b[i]);
	}
	double s = 0;
	for (int i = 0; i < n; i++) {
		int l = v[i] - m[i];
		int r = v[i] - m[i + 1];
		double ss = t[i] * v[i] - l * l / 2.0 - r * r / 2.0;
		if (l + r > t[i]) {
			int d = l + r - t[i];
			ss += d * d / 4.0;
		}
		s += ss;
	}
	cout << fixed << setprecision(4) << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

  int a,b;
  scanf("%d",&a);
  scanf("%d",&b);

  if (b>0){
    if (a>0){
      printf("Positive\n");
    }else {
      printf("Zero\n");
    }
  }else if(b<0){
    if ((b-a)%2==0){
      printf("Negative\n");
    }else{
      printf("Positive\n");

    }
   }else{
      printf("Zero\n");
   }


  return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

void leave(string message) {
    cout << message << endl;
    exit(0);
}

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

    for(lint i=0; i<=n; i++) {
        if(lint(i * 1.08) == n)  leave(to_string(i));
    }
    cout << ":(" << endl;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        int M = int.Parse(str[1]);
        long[] A = new long[N];
        long[] B = new long[N];
        for(int i=0;i<N;i++){
            str = Console.ReadLine().Split(' ');
            A[i] = int.Parse(str[0]);
            B[i] = int.Parse(str[1]);
        }
        long[] C = new long[M];
        long[] D = new long[M];
        for(int i=0;i<M;i++){
            str = Console.ReadLine().Split(' ');
            C[i] = int.Parse(str[0]);
            D[i] = int.Parse(str[1]);
        }
        for(int i=0;i<N;i++){
            long min = 100000000000000;
            int m = -1;
            for(int j=0;j<M;j++){
                if(min > Math.Max(A[i]-C[j],C[j]-A[i])+Math.Max(B[i]-D[j],D[j]-B[i])){
                    min = Math.Max(A[i]-C[j],C[j]-A[i])+Math.Max(B[i]-D[j],D[j]-B[i]);
                    m = j;
                }
            }
            sb.Append((m+1)+"\n");
        }
    }
}

Measured memory_bytes: 13268
// 有點不耐煩會破壞偉大的計劃

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e14 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug() {
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

long long num(char c) {
    return ll(c - '0');
}

int main() {
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    string s; cin >> s;
    long long n = s.size(), ans = INF;

    for(long long i = 0; i + 2 < n; i++) {
        long long x = num(s[i]) * 100 + num(s[i + 1]) * 10 + num(s[i + 2]);
        long long y = 753;
        ans = min(ans, abs(x - y));
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 3656
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();




            Console.WriteLine(line.IndexOf('7') >= 0 ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 25836
#include <bits/stdc++.h>
using namespace std;
#define dump(a) cout << (a) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
// Int MOD = 998244353;

int main() {
    ios::sync_with_stdio(false);
    Int n, m;
    cin >> n >> m;
    vector<Int> x(m);
    for (Int i = 0; i < m; i++) cin >> x[i];
    if (n >= m) {
        dump(0);
        return 0;
    }
    else {
        sort(x.begin(), x.end());
        vector<Int> dif(m - 1);
        for (Int i = 0; i < m - 1; i++) dif[i] = x[i + 1] - x[i];
        sort(dif.begin(), dif.end(), greater<Int>());
        Int res = 0;
        for (Int i = n - 1; i < m - 1; i++) res += dif[i];
        dump(res);
        return 0;
    }
    return 0;  
} 

Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]
A = sorted(A, reverse=True)
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
mod = 7 + 10 ** 9
lcm = lcm(*A)
ans = 0
for i in A:
    ans += lcm // i
print(ans % mod) 


Measured memory_bytes: 5868
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <iomanip>
using namespace std;

int n, a, b;;
;;
bool func(int i){;;
int sum = 0;;
    while(i){;;;
        sum += i%10;
        i = i/10;
    };;;
    if((a<=sum&&sum<=b)) {;return (true);}
    else {;return (false);};
};;;

int main(){
  ;;
    cin >> n >> a >> b;
    ;
    int ans = 0;;
    if(1<n){;
        for(int i = 1; i <= n; ++i){;;;
        if(func(i)) {;ans += i;};
    }
    ;}
    else {;
        for(int i = 1; i >= n; --i){;;;
        if(func(i)) {;ans += i;};
    }
    ;};;;;
    cout << (ans) << endl;;
    return (0);
    ;
    ;
}

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

int main(){
	int w,h;cin >> w >> h;
	
	int i0=1,i1=1;
	
	int ans = 0;
	
	int n;cin >> n;
	for(int i=0;i<n;i++){
		int p;
		cin >> p;
		if(p){
			i1++;
		} else {
			i0++;
		}
		if(i1 <= w-1 && i0 <= w-1 && i0 == i1){
			ans++;
		}
		if(i1 >= w-1 && i0 >= w+1 && i1 <= w+h-4 && i0 <= w+h-2 && i0-2 == i1){
			ans++;
		}
		if(i1 >= w+h-4 && i0 >= w+h && i0-4 == i1){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3116
<?php

fscanf(STDIN, "%d", $n);

$p = explode(" ", trim(fgets(STDIN)));

$copy = $p;

sort($copy);
$k = 0;
for($i=0; $i<$n; $i++){
    if($p[$i] != $copy[$i]){
        $k++;
    }
    if($k > 2){
        echo "NO";
        exit;
    }
}

echo "YES";

Measured memory_bytes: 4728
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        var NK = ReadLine().Split().Select(long.Parse).ToArray();
        long N = NK[0], K = NK[1];
        WriteLine(Min(N%K,Abs((N%K)-K)));
    }
}


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

using ll = long long;
using pp = pair<ll,ll>;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end() //昇順
#define enb(a) a.rbegin(),a.rend() //降順
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)

int main(){
	string s;
	cin >> s;
	int a,b,c,d;
	a = s[0] - '0';
	b = s[1] - '0';
	c = s[2] - '0';
	d = s[3] - '0';
	char op[2] = {'+','-'};
	int ok = 0;
	for(int i = 0; i < 2; i++){
		for(int j = 0; j < 2; j++){
			for(int l = 0; l < 2; l++){
				int ans = a;
				if(!i)ans += b;
				else ans -= b;

				if(!j)ans += c;
				else ans -= c;

				if(!l)ans += d;
				else ans -= d;

				if(ans == 7){
					cout << a << op[i] << b << op[j] << c << op[l] << d << "=7" << endl;
					ok = 1;
				}

				if(ok)break;
			}
			if(ok)break;
		}
		if(ok)break;
	}
	return 0;
}



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

C_list = []
S_list = []
F_list = []

for _ in range(N-1):
    c, s, f = map(int, input().split())
    C_list.append(c)
    S_list.append(s)
    F_list.append(f)

def next_station(t, c, s, f):
    if t >= s:
        if t % f == 0:
            return t + c
        else:
            return f*(t // f + 1) + c
    else:
        return s + c
    
for i in range(N):
    t = 0
    for j in range(i, N-1):
        t = next_station(t, C_list[j], S_list[j], F_list[j])
    print(t)

Measured memory_bytes: 3444
s = input()
n = len(s)
k = int(input())
p = []
append = p.append
for i in range(1,min(n+1,k+1)):
    for j in range(n):
        append(s[j:j+i])

p.sort()
ans = 0
q = ""
for i in p:
    if i>q:
        ans += 1
        q = i
    if ans == k:
        print(q)
        exit()

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


ll solve(){
    ll H = 0, W = 0, A = 0, result = 0;
       cin >> H >> W;
       if(H == 1 or W == 1)return 1;
       A = H * W;
       result = (A/2) + (A%2);
        return result;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll result;
    result = solve();
    cout << result;
}


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

class Program {
    static void Main(string[] args) {
        int[] inp = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int N = inp[0];
        int X = inp[1];
        var dList = new List<int>();

        for (int i = 0; i < N; i++) {
            dList.Add(int.Parse(ReadLine()));
            X -= dList[i];
        }

            WriteLine((N + (X / dList.Min())).ToString());
    }
}



Measured memory_bytes: 13396
import numpy as np

N, K = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(N)]
MOD = 10 ** 9 + 7

A = np.array(a, dtype = 'O')
A = A.T

ans = np.eye(N, dtype = 'O')
while K:
  if K & 1:
    ans = np.dot(ans, A)
    ans %= MOD
  A = np.dot(A, A)
  A %= MOD
  K >>= 1

print(np.sum(abs(ans)) % MOD)

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

ll po (ll a, ll p) { return !p?1:po(a*a%MOD,p/2)*(p&1?a:1)%MOD; } //Source: bqi343

ll modInv(ll a, ll mod) {
    a = a % mod;
    if (a <= 1) return a;
    ll i = modInv(mod % a, a);
    ll result = -1 * ((mod/a) * i + ((mod%a) * i)/a) % mod;
    if (result < 0) result += mod;
    return result;
}

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

    int N; cin >> N;
    int M; cin >> M;

    ll answer = 1;
    FOR(i, 2, 35000) {
        int count = 0;
        while (M % i == 0) {
            count++;
            M = M / i;
        }
        ll temp = 1;
        int cur = N + count - 1;
        int choose = count;
        F0R(i, choose) {
            answer = answer * (cur - i);
            answer = answer % MOD;
            temp = temp * (i + 1);
            temp = temp % MOD;
        }
        answer = answer * modInv(temp, MOD);
        answer = answer % MOD;
    }

    if (M > 1) {
        answer = answer * N;
        answer = answer % MOD;
    }

    cout << answer << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define LAST 4280
int main(){
    int w;
    while(cin >> w){
        if (w==-1)
            break;
        if(w<=10)
            cout << LAST-1150 << endl;
        if(10 <w && w<=20)
            cout << LAST-(1150+(w-10)*125) << endl;
        if(20<w && w<=30)
            cout << LAST-(2400+(w-20)*140) << endl;
        if(30<w)
            cout << LAST-(3800+(w-30)*160) << endl;
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int gcd(int a, int b)
{
  while(b>0)
  {
    int t = b;
    b = a%b;
    a = t;
  }
  return a;
}

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

int main(){
  int n,m;
  string s,t;

  cin >> n >> m >> s >> t;

  long int l = lcm(n,m);

  long int ln = l/n;
  long int lm = l/m;

  if(n<m)
  {
    for (int i = 0; i < n; ++i) {
      if(long(i*m)%n==0)
      {
        int j = long(i*m)/n;
        if(s[i]!=t[j])
        {
          cout << -1 <<endl;
          return 0;
        }
      }
    }
  }
  else
  {
    for (int i = 0; i < m; ++i) {
      if(long(i*n)%m==0)
      {
        int j = long(i*n)/m;
        if(t[i]!=s[j])
        {
          cout << -1 <<endl;
          return 0;
        }
      }
    }
  }

//vector<char> x(l,0);
//  for (int i = 0; i < n; ++i) {
//    long int idx = i*(l/n)+1;
//    x[idx] = s[i];
//  }
//  for (int i = 0; i < m; ++i) {
//    long int idx = i*(l/m)+1;
//    char c = x[idx];
//    if(c!=0 && c!=t[i])
//    {
//      cout << -1 << endl;
//      return 0;
//    }
//  }

  cout << l << endl;

  return 0;
}

Measured memory_bytes: 888
#include <cstdio>
#include <algorithm>
#include <string>
#include <map>
using namespace std;

int main(){
    map<string, int> m;
    int id;
    char buffer[3];
    string str;
    m.insert({"A", 0}); m.insert({"AB", 0}); m.insert({"B", 0}); m.insert({"O", 0});
    while(scanf("%d,%s", &id, buffer) != EOF) {
        str = buffer;
        m[str]++;
    }
    printf("%d\n%d\n%d\n%d\n", m["A"], m["B"], m["AB"], m["O"]);

    return 0;
}





Measured memory_bytes: 2808
#include <bits/stdc++.h>
#include<vector>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define MAX 400000
#define BEGIN 1
#define DEFAULT_VALUE 0
#define MOD 2019
char s[MAX];
long long RR[MAX];
int main()
{

    int n,i,j;
    char c;
    int rem[MOD]={1};
    for(i=0;;i++)
    {
        scanf("%c",&c);
        if(!(c>='0'&&c<='9')) break;
        s[i]=c;
    }
    n=i;
    //printf("n=%d\n",n);
    RR[n-1]=1;
    for(i=n-2;i>=0;i--)
    {
        RR[i]=(RR[i+1]*10)%MOD;
    }
    long long int current=0;
    int cur;
    for(i=n-1;i>=0;i--)
    {
        current=(current+(RR[i]*(s[i]-'0'))%MOD)%MOD;
        cur=(int) current;
        rem[cur]++;
        //printf("cur=%d,%d\n",cur,rem[cur]);
    }
    long long int ans=0,temp=0;
    for(i=0;i<MOD;i++)
    {
        temp=rem[i];
        temp=temp*(temp-1)/2;
        ans=ans+temp;
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 5528