akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

int main(void){
  int n;
  char s[10];
  int i;
  int a=0, b=0, c=0, d=0;
  scanf("%d",&n);
  for(i=1; i<n+1; i++){
    scanf("%s",s);
    if(strcmp(s, "AC")==0){
      a++;
    }else if(strcmp(s,"WA")==0){
      b++;
    }else if(strcmp(s,"TLE")==0){
      c++;
    }else if(strcmp(s,"RE")==0){
      d++;
    }
  }
  printf("AC x %d\n", a);
  printf("WA x %d\n", b);
  printf("TLE x %d\n", c);
  printf("RE x %d\n", d);
  
  return 0;
}

Measured memory_bytes: 1728
import itertools
H,W,K=map(int,input().split())
S=[list(input()) for _ in range(H)]
#print(S)
l=[]
id=[0]*H
tables=[[0 for _ in range(W)] for _ in range(H)]
gnum=0
ans=0
mi=float("inf")
impossibleflag=0
for k in range(pow(2,H-1)):
    for i in range(H):
        id[i]=gnum
        if (k>>i)&1:    #kが2^iを持つかどうか
            gnum=gnum+1 #持っていればそこが琴線でありそこで分ける
    gnum=gnum+1         #0~gnumのグループ番号があるので、グループ数はgnum+1
    #print(id)
    tables = [[0 for _ in range(W)] for _ in range(H)]
    for i in range(H):
        for j in range(W):
            tables[id[i]][j]=tables[id[i]][j]+int(S[i][j])
    ans=ans+gnum-1  #とりあえず素のgroup数-1こ線を引かないといけない
    #print(ans)
    #print(tables)
    groupedwchoko=[0 for _ in range(gnum)]  #横線で分割したグループを左から貪欲するのに使うやつ
    for i in range(W):
        for j in range(gnum):
            groupedwchoko[j]=groupedwchoko[j]+tables[j][i]  #各グループにて(0<=j<=gnum-1)、wchokoの数をtables[j][i]を足していく
            #print(tables[j][i])
            if groupedwchoko[j]>K:      #もし、どれか一つでも結果がKを越えれば
                ans=ans+1               #そこと一つ前部分の間で線を引くことに
                groupedwchoko = [0 for _ in range(gnum)]
                for l in range(gnum):
                    groupedwchoko[l]=tables[l][i]   #各グループにて(0<=l<=gnum-1)、wchokoの数はtables[l][i]で初期化される
                    if tables[l][i]>K:              #初期化時点でKを超えるのは
                        ans=float("inf")            #どう頑張ってもムリということである
                break
        #print(groupedwchoko)
    #print(ans)
    if mi>ans:
        mi=ans
    gnum=0
    ans=0

print(mi)

Measured memory_bytes: 67548
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <cfloat>
#define zero(x) (((x)>0?(x):-(x))<eps)

#define pause cout << " press ansy key to continue...",  cin >> chh
#define file_r(x) freopen(x,  "r",  stdin)
#define file_w(x) freopen(x,  "w",  stdout)
#define lowbit(x) ((x) & (-x))
#define repit(i, c) for (__typeof__((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repe(i, u) for (int i = head[u]; i != -1; i = nxt[i])
#define repd(i, n) for (int i = (n - 1); i >= 0; i--)
#define FOR(i, n, m) for (int i = (n); i <= (m); i++)
#define FORD(i, n, m) for (int i = (n); i >= (m); i--)
#define pb push_back
#define X first
#define Y second
#define ins insert
#define rb rbegin
#define be begin
#define er erase
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define SZ(c) (c).size()
#define ALL(c) (c).begin(), (c).end()
#define sqr(r) ((r) * (r))
#define dis(x1, y1, x2, y2) (((x1) - (x2)) * ((x1) - (x2)) + ((y1) - (y2)) * ((y1) - (y2)))
#define FASTIO ios::sync_with_stdio(false);cin.tie(0)

#define sc(x) cout << #x" = " << x << endl
#define sc2(x, y) cout << #x" = " << x << " " << #y" = " << y << endl
#define sc3(x, y, z) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << endl
#define sc4(x, y, z, w) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << " " << #w" = " << w << endl

#define in(n) scanf("%d", &n)
#define in2(n, m) scanf("%d %d", &n, &m)
#define in3(x, y, z) scanf("%d %d %d", &x, &y, &z)

using namespace std;
int chh;

typedef vector<int> vi;
typedef set<int> si;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<int, pii> pi3;
typedef vector< pair<int, int> > vpii;
typedef long long LL;

const int N = 100005;

int n, e;
int head[N], pnt[N * 2], nxt[N * 2];

void init() {
    e = 0;
    memset(head, -1, sizeof(head));
}

void add_edge(int u, int v) {
    pnt[e] = v, nxt[e] = head[u], head[u] = e++;
}

int wv[N];
int dp[N];

bool dfs(int u, int fa) {
    int v, cnt = 0, flag;
    int sum = 0, maxi = 0, r;
    int x, y;
    repe (i, u) {
        v = pnt[i];
        if (v == fa) continue;
        flag = dfs(v, u);
        if (!flag) return 0;
        cnt++;
        sum += dp[v];
        maxi = max(maxi, dp[v]);
    }
    if (cnt == 0) {
        dp[u] = wv[u];
        return 1;
    }
    x = sum - wv[u];
    y = wv[u] - x;
    if (maxi * 2 <= sum) r = sum / 2;
    else r = sum - maxi;
   // sc3(u, x, y);
    if (x < 0 || x > r) return 0;
    dp[u] = y;
    //sc2(u, dp[u]);
    if (u == 1) {
        if (cnt == 1) return dp[u] == wv[u];
        return dp[u] == 0;
    };
    return 1;
}

int main() {
    int u, v;
    while (~in(n)) {
        FOR (i, 1, n) in(wv[i]);
        init();
        rep (i, n - 1) {
            in2(u, v);
            add_edge(u, v);
            add_edge(v, u);
        }
        puts(dfs(1, -1) ? "YES" : "NO");
    }
    return 0;
}


Measured memory_bytes: 9600
program bbb
implicit none

integer(8) :: a, b, k

read*, a, b, k

a = a - k

	if (a>=0) then
	print*, a, b
	return
    else
	b = b + a
		if (b>=0) then
        print*, 0, b
        return
        else
        print*, 0, 0
        return
        end if
    end if

end program

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

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

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

int main(){
    int n;
    cin >> n;
    int count;
    int nums[n + 1];
    for(int i = 0; i <= n; i++)
        nums[i] = 0;
    for(int i = 0; i < n-1; i++){
        cin >> count;
        nums[count] ++;
    }
    
    
    
    for(int i = 1; i <= n; i++)
        cout << nums[i] << "\n";

    
}

Measured memory_bytes: 4368
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 101010101000;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using pii = pair<int,int>;

int main(){
  int n; cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  //しゃくとり法
  ll right=0;
  ll sum=0;
  ll ans=0;
  rep(left,n){
    while(right<n&&(sum^a[right])==(sum+a[right])){
      sum+=a[right];
      right++;
    }
    //cout<<right-left<<endl;
    ans+=right-left;
    if(left==right)right++;
    else sum-=a[left];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4832
fun main(array: Array<String>) {
    val (a, b) = readLine()!!.split(" ").map { it.toInt() }
    var cnt = 0
    for(i in a..b) {
        if((i.toString()[0] == i.toString()[4]) && (i.toString()[1] == i.toString()[3])) cnt++
    }
    print(cnt)
}

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

using namespace std;

int main() {
    char a[1];
    cin >> a;

    if(strcmp(a, "A") == 0) {
      cout << "T";
    }else if(strcmp(a, "T") == 0) {
      cout << "A";
    }else if(strcmp(a, "C") == 0) {
      cout << "G";
    }else if(strcmp(a, "G") == 0) {
      cout << "C";
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795
typedef long long ll;
#define MOD 998244353
ll gcd(ll a,ll b){if (b == 0)return a;return gcd(b, a % b);} 
#define cases int t;cin>>t;while(t--) 
ll power(ll x,ll y,ll p){ll res=1;x=x%p;if(x==0)return 0;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res%MOD;}  

int main(){
    double r;
    cin>>r;
    double c = r*(double)3.1415926535897932384626433832795*2;
    cout<<r*2*PI<<endl;
}


Measured memory_bytes: 3784
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest._300Problems_remain_
{
    class Tenka12017_C
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            long N = ReadInt();
            for(long h = 1; h <= 3500; h++)
            {
                for(long n = 1; n <= 3500; n++)
                {
                    long Nhn = N * h * n;
                    long div = 4 * h * n - N * n - N * h;
                    if (div > 0 && Nhn % div == 0)
                    {
                        long w = Nhn / div;
                        Console.WriteLine(h + " " + n + " " + w);
                        return;
                    }
                }
            }
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
using System;
using System.IO;

namespace Contest
{

    class Program
    {
        private Scanner sc;

        public void Solve()
        {
            sc = new Scanner();
            int W = sc.NextInt();
            int H = sc.NextInt();
            int X = sc.NextInt();
            int Y = sc.NextInt();
            double ans = (double)W * H / 2;
            if (X * 2 == W && Y * 2 == H)
            {
                Console.WriteLine($"{ans} {1}");
            }
            else
            {
                Console.WriteLine($"{ans} {0}");
            }
        }

        static void Main() => new Program().Solve();
    }
}



class Scanner
{
    public Scanner()
    {
        _stream = new StreamReader(Console.OpenStandardInput());
        _pos = 0;
        _line = new string[0];
        _separator = ' ';
    }
    private readonly char _separator;
    private readonly StreamReader _stream;
    private int _pos;
    private string[] _line;
    #region get a element
    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = _stream.ReadLine().Split(_separator);
            _pos = 0;
        }
        return _line[_pos++];
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    #endregion
    #region convert array
    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }
    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }
    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }
    #endregion
    #region get array
    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = _stream.ReadLine().Split(_separator);
        _pos = _line.Length;
        return _line;
    }
    public int[] IntArray()
    {
        return ToIntArray(Array());
    }
    public long[] LongArray()
    {
        return ToLongArray(Array());
    }
    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }
    #endregion
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double  
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout<<'\n';
#define MOD 1000000007
#define sz(x) ((ll)x.size())
ll powm(ll a,ll n,ll x=MOD){a%=x;ll r=1;while(n>0){if(n&1)r=(r*a)%x;a=(a*a)%x;n>>=1;}return r;}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  ll _=1; //cin>>_;
  while(_--)
  {
    ll n; cin>>n;
    ll x=ceil(n/1000.0);
    cout<<x*1000-n;LOL
  }
  return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();
		sb.append(br.readLine());
		int count = Integer.parseInt(br.readLine());

		for (int i = 0; i < count; i++) {
			String[] command = br.readLine().split(" ");
			if (command[0].equals("replace")) {
				sb.replace(Integer.parseInt(command[1]), (Integer.parseInt(command[2]) + 1), command[3]);
			} else if (command[0].equals("reverse")) {
				int index01 = Integer.parseInt(command[1]);
				int index02 = Integer.parseInt(command[2]);
				char moji;
				char[] mojiList = sb.toString().toCharArray();
				while (index01 < index02) {
					moji = mojiList[index01];
					mojiList[index01] = mojiList[index02];
					mojiList[index02] = moji;
					index01++;
					index02--;
				}
				for (int l = 0; l < mojiList.length; l++) {
					sb.append(mojiList[l]);
				}
				sb.delete(0,mojiList.length );
			} else if(command[0].equals("print")){
				System.out.println(sb.substring(Integer.parseInt(command[1]),(Integer.parseInt(command[2]) + 1)));
			}
		}
	}
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef string ss;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll n,ans = 0;
    cin >> n;
    vll l(n);
    rep(i,n)cin >> l[i];
    sort(all(l));
    /*rep(i,n)cout << l[i] << " ";
    cout << endl;*/

    rep(i,n-2){
        REP(j,i+1,n-1){
            auto tmp = lower_bound(all(l), l[i]+l[j]);
            ll m = tmp - l.begin();
            m -= j+1;
            if(m > 0)ans += m;
            //cout << m << " ";
        }
    }
    //cout << endl;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll N; cin >> N;
  if(N % 1000 != 0){
    cout << (N/1000 + 1) * 1000 - N;
  }
  else{
    cout << "0";
  }
}

Measured memory_bytes: 3628
use proconio::{fastout, input, marker::Chars, marker::Usize1};
use std::collections::VecDeque;

#[fastout]
fn main() {
    input! {
        h: usize,
        w: usize,
        ch: Usize1,
        cw: Usize1,
        dh: Usize1,
        dw: Usize1,
        mut s: [Chars; h]
    }

    let mut q = VecDeque::new();
    q.push_back((ch,cw));

    let mut costs = vec![vec![-1; w]; h];
    costs[ch][cw] = 0;
    
    while !q.is_empty() {
        if let Some((y, x)) = q.pop_front() {
            s[y][x] = '#';
            for dx in -1..=1 {
                for dy in -1..=1 {
                    if i64::abs(dx) == i64::abs(dy) {
                        continue;
                    }
                    let nx = x as i64 + dx;
                    let ny = y as i64 + dy;
                    if nx < 0 || nx >= w as i64 || ny < 0 || ny >= h as i64 {
                        continue;
                    }
                    let nx = nx as usize;
                    let ny = ny as usize;
                    if s[ny][nx] != '#' && (costs[ny][nx] == -1 || costs[ny][nx] > costs[y][x]) {
                        costs[ny][nx] = costs[y][x];
                        q.push_front((ny, nx));
                    }
                }
            }
            for dx in -2..=2 {
                for dy in -2..=2 {
                    let nx = x as i64 + dx;
                    let ny = y as i64 + dy;
                    if nx < 0 || nx >= w as i64 || ny < 0 || ny >= h as i64 {
                        continue;
                    }
                    let nx = nx as usize;
                    let ny = ny as usize;
                    if s[ny][nx] != '#' && (costs[ny][nx] == -1 || costs[ny][nx] > costs[y][x] + 1) {
                        costs[ny][nx] = costs[y][x] + 1;
                        q.push_back((ny, nx));
                    }
                }
            }
        }
    }
    println!("{}", costs[dh][dw]);

}


Measured memory_bytes: 11268
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, x;
    cin >> n >> x;
    vector<int> l(n);
    rep(i, n) {
      cin >> l[i];
    }
    int count = 0;
    int d = 0;
    int i = 0;
    while (d <= x) {
      d += l[i];
      count++;
      i++;
      if (i > n) {
        count = n + 1;
        break;
      }
    }

    cout << count << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2010,inf=0x3f3f3f3f;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,f[N],s[N],ans;
char ch[N];
vector<int> e[N];
void work(int x,int fa){
	s[x]=ch[x]-'0';f[x]=0;
	for (auto y : e[x])
	if (y!=fa){
		work(y,x);
		s[x]+=s[y];
		f[x]+=f[y]+s[y];
	}
}
int calc(int x,int fa){
	int hs=0;
	for (auto y : e[x])
	if ((y!=fa)&&(f[hs]+s[hs]<f[y]+s[y])) hs=y;
	if (!hs) return 0;
	int res=f[x]-f[hs]-s[hs],cur=calc(hs,x)+s[hs];
	return (res>=cur)  ? (f[x]&1) : (cur-res); 
}
int main(){
	n=read();
	scanf(" %s",ch+1);
	for (int i=1;i<n;i++){
		int u=read(),v=read();
		e[u].push_back(v);
		e[v].push_back(u);
	}
	ans=inf;
	for (int i=1;i<=n;i++){
		work(i,0);
		if (calc(i,0)==0) ans=min(ans,f[i]/2);
	}
	printf("%d\n",(ans==inf) ? -1 : ans);
	return 0;
}

Measured memory_bytes: 512
N = int(input())
H = [0]*N
H = input().split()
H = [int(h) for h in H]
for i in range(0, N-1):
    for j in range(i+1, N):
        if H[i] > H[j]:
            H[j] = 0
H = [h!=0 for h in H]
print(sum(H))

Measured memory_bytes: 3064
import sys
def input(): return sys.stdin.readline().strip()

def main():
    N, M = map(int, input().split())
    drink = []
    for _ in range(N):
        a, b = map(int, input().split())
        drink.append((a, b))
    drink.sort(reverse=True)
    #print(drink)

    num = 0
    val = 0
    while num < M:
        a, b = drink.pop()
        if num + b <= M:
            num += b
            val += a * b
        else:
            val += a * (M - num)
            num = M
    print(val)


if __name__ == "__main__":
    main()


Measured memory_bytes: 48604
from collections import defaultdict
def main():
	S = input()
	K = int(input())
	sub = defaultdict(set)
	for i in range(len(S)):
		sub[S[i]].add(S[i:len(S)+1])

	alphabet = [chr(ord('a') + i) for i in range(26)]
	ans = set()
	for c in alphabet:
		if c in sub:
			this_list = list(sub[c])
			this_list.sort()
			for e in this_list:
				for i in range(1, len(e)+1):
					ans.add(e[:i])
					if len(ans) == K:
						print(e[:i])
						return


if __name__ == '__main__':
    main()

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

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

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

  int n, a, b; cin >> n >> a >> b;

  cout << min(a * n, b) << endl;
  
  return (0);
}

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

res = 0
if a[0] > x:
    res += a[0] - x
    a[0] = x
for i in range(n-1):
    if a[i] + a[i+1] > x:
        val = a[i] + a[i+1] - x
        res += val
        a[i+1] -= val

print(res)


Measured memory_bytes: 14252
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from math import gcd
S, W = read_ints()
print('unsafe' if S <= W else 'safe')


Measured memory_bytes: 65420
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

struct state {
	int p, c;
	state(int p, int c) : p(p), c(c) {};
	bool operator<(const state &o)const {
		return o.c<c;
	}
};

int main() {
	int n, k;
	while(cin >> n >> k, n) {
		vvi dist(n, vi(n, INF));
		int m;
		int a, b, c, d, e;
		priority_queue<state> Q;
		vi cost(n, INF);
		REP(_, k) {
			cin >> m;
			switch(m) {
			case 0:
				REP(i, n) 
					cost[i] = INF;
				while(!Q.empty()) {
					Q.pop();
				}
				cin >> a >> b;
				Q.push(state(a-1, 0));
				cost[a-1] = 0;
				while(!Q.empty()) {
					state st = Q.top();
					Q.pop();

					if(st.p == b-1) {
						cout << st.c << endl;
						goto next;
					}

					REP(i, n) {
						if(st.p != i) {
							int nc = st.c + dist[st.p][i];
							if(nc < cost[i]) {
								cost[i] = nc;
								Q.push(state(i, nc));
							}
						}
					}
				}
				cout << -1 << endl;
				break;
			case 1:
				cin >> c >> d >> e;
				dist[c-1][d-1] = min(dist[c-1][d-1], e);
				dist[d-1][c-1] = min(dist[d-1][c-1], e);
				break;
			}
			next:;
		}
	}

	return 0;
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }

int main(){
    INT(n);
    stack<int> s;
    vector<int> cat(101,0);
    int x;
    rep(i,n){
        in(x);
        if(x>0){
            if(cat[x]>=1){
                out(i+1);
                return 0;
            }
            s.push(x);
            cat[x]++;
        }else{
            x=-x;
            if(!s.empty()&&x==s.top()){
                s.pop();
                cat[x]--;
            }else{
                out(i+1);
                return 0;
            }
        }
    }
    out("OK");
}



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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

template <ll mod> class modint
{
private:
    ll x;

public:
    modint(ll x = 0) : x(x >= 0 ? x % mod : (x % mod) + mod) {}
    modint &operator+=(const modint rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    modint &operator-=(const modint rhs) {
        if ((x += mod - rhs.x) >= mod) x -= mod;
        return *this;
    }
    modint &operator*=(const modint rhs) {
        (x *= rhs.x) %= mod;
        return *this;
    }
    modint &operator/=(const modint rhs) {
        *this *= rhs.inv();
        return *this;
    }
    modint operator+(const modint rhs) const { return modint(*this) += rhs; }
    modint operator-(const modint rhs) const { return modint(*this) -= rhs; }
    modint operator*(const modint rhs) const { return modint(*this) *= rhs; }
    modint operator/(const modint rhs) const { return modint(*this) /= rhs; }

    modint operator-() const { return modint(-x); }

    modint pow(ll n) const {
        modint e = *this, ret = modint(1);
        while (n) {
            if (n & 1) ret *= e;
            e *= e, n >>= 1;
        }
        return ret;
    }

    modint inv() const { return pow(mod - 2); }

    friend ostream &operator<<(ostream &os, const modint &m) {
        os << m.x;
        return os;
    }

    friend istream &operator>>(istream &is, modint &m) {
        ll in;
        is >> in;
        m = modint(in);
        return is;
    }
};
using mint = modint<1000000007>;

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

    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    
    vector<int> cnt(n + 1, 0);
    cnt[0] = 3;
    mint ans = 1;
    for (int i = 0; i < n; i++) {
        if (cnt[a[i]] == 0) {
            cout << 0 << endl;
            return 0;
        }
        ans *= cnt[a[i]];
        cnt[a[i]]--, cnt[a[i] + 1]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <climits>
#include <cmath>
#include <cstring>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <utility>
#include <sstream>
#include <algorithm>
#include <stack>
#include <set>
#include <list>
#include <map>
#include <queue>
#include <vector>
#include <stdint.h> //uint32_t

typedef long long ll;
typedef double lf;

#define ull unsigned long long

#define FileIn(file) freopen("input.txt", "r", stdin)
#define FileOut(file) freopen("output.txt", "w", stdout)
#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0)

#define For(i, a, b) for (__typeof (a) i=a; i<=b; i++)
#define Rof(i, b, a) for (__typeof (a) i=b; i>=a; i--)
#define Rep(i, n) for (__typeof (n) i=0; i<n; i++)
#define Forit(i, s) for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
#define all(ar) ar.begin(), ar.end()
#define fill(ar, val) memset(ar, val, sizeof(ar))
#define clr(a) memset(a, 0, sizeof a)
#define sfll(a) scanf("%lld", &a)
#define pfll(a) printf("%lld", a)
#define sflf(a) scanf("%lf", &a)
#define pflf(a) printf("%lf", a)
#define sff(a) scanf("%f", &a)
#define pff(a) printf("%f", a)
#define sf(a) scanf("%d", &a)
#define pf(a) printf("%d", a)
#define nl cout << '\n';
#define SP cout << ' ';
#define gc getchar
#define chk cout << "##########\n"
#define debug1(x) cout << #x << ": " << x << endl
#define debug2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl
#define debug3(x, y, z) cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z << endl

#define PB push_back
#define max(a, b) (a < b ? b : a)
#define min(a, b) (a > b ? b : a)
#define sq(a) a * a
#define INF 0x7fffffff
#define MOD 1000000007
#define PI acos(-1.0)
#define MAX 100000000

using namespace std;

/********************* Code starts here ************************/

int main() {
    __FastIO;
    int n{};
    cin >> n;
    string a;
    cin >> a;
    ll ans{};
    ans = count(a.begin(), a.end(), 'R') * count(a.begin(), a.end(), 'G') * count(a.begin(), a.end(), 'B');

    for(int i = 0; i < n - 2; i++){
        for(int j = i + 1; j < n - 1; j++){
            int k = 2 * j - i;
            if(k >= n) continue;
            else if(a[i] != a[j] && a[k] != a[i] && a[j] != a[k]) ans--;
        }
    }
    cout <<  ans;
}


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

int a[101];

int main()
{
	int n,x;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		a[x]=1;
	}
	int s=0;
	for(int i=1;i<=100;i++)
	{
		if(a[i]==1)s++;
	}
	cout<<s<<endl;
	return 0;
	
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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);}

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a<b+c)cout<<b+c-a;
    else cout<<0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define mx 10001
#define ll long long int
int main(){
    ll a[1001],n,i,j,mx,s;
    for(i=0;i<5;i++)
        cin>> a[i];
    for(i=0;i<5;i++)
    {
        if(a[i]==0)
        {
            cout<< i+1 << endl;
            break;
        }
    }
return 0;
}


Measured memory_bytes: 3612
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int[][] map = new int[12][2];
			for (int i = 0; i < 12; i++) {
				map[i][0] = scanner.nextInt();
				map[i][1] = scanner.nextInt();
			}
			int sum = 0;
			int index = -1;
			for(int i = 0;i<12;i++){
				sum+= map[i][0]-map[i][1];
				if(sum>=n){
					index = i+1;
					break;
				}
			}
			System.out.println(index==-1?"NA":index);
		}
	}
}

Measured memory_bytes: 34588
#include <stdio.h>

int main(void)
{
	int a, b;

	scanf("%d%d", &a, &b);
	
	if(a>b)
		printf("a > b\n");
	else if(a<b)
		printf("a < b\n");
	else
		printf("a == b\n");
	
	return 0;
}

Measured memory_bytes: 580
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000;

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right){
    // printf("merge(n=%d ,left=%d ,mid=%d ,right=%d )\n\n",n,left,mid,right);
    int n1 = mid - left;
    int n2 = right - mid;
    for(int i=0; i < n1; i++) L[i] = A[left+i];
    for(int i=0; i < n2; i++) R[i] = A[mid+i];
    L[n1] = R[n2] = SENTINEL;
    int i=0 , j=0;
    for(int k=left ; k<right;k++){
        cnt++;
        if(L[i] <= R[j]){
            A[k] = L[i++];
        }else{
            A[k] = R[j++];
        }
    }
}

void mergeSort(int A[], int n, int left, int right){
    // printf("mergeSort(n=%d ,left=%d ,right=%d )\n",n,left,right);
    if(left+1 < right){
        int mid = (left + right) /2;
        mergeSort(A,n,left,mid);
        mergeSort(A,n,mid,right);
        merge(A,n,left,mid,right);
    }
}

int main(){
    int A[MAX],n,i;
    cnt = 0;

    cin >> n;
    for(i=0; i<n;i++) cin >> A[i];

    mergeSort(A,n,0,n);

    for(i=0;i<n;i++){
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;

    cout << cnt << endl;

    return 0;
}


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

const int MAX_N = 105;
int v0[MAX_N], v1[MAX_N];
int N;

int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf("%d %d", v0 + i, v1 + i);
  }
  for (int i = 0; i < N; ++i) {
    int c = 0;
    for (int j = i; j < i + 3 && j < N; ++j) {
      if (v0[j] == v1[j]) c++;
    }
    if (c == 3) {
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
}


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

int main(){
	long long m,n,k;
	cin>>n;
	long long a[61],b[61];
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));
	for(int y=0;y<n;y++){
		cin>>k;
		for(int j=0;j<61;j++){
			if(k&(1LL<<j))a[j]++;
			else b[j]++;
		}
	}
	long long ans=0,modn=1e9+7;
	for(int y=0;y<61;y++){
		ans+=(a[y]*b[y]%modn)*((1LL<<y)%modn)%modn;
		// cout<<ans<<'\n';
	}
	cout<<ans%modn<<'\n';
	return 0;
}

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

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

    string s;
    cin >> s;

    int n = s.size();
    vector<int> NearestLeft(n, n - 1);
    int bef = n - 1;
    for(int i = n - 1; i >= 0; i--){
        if(s[i] == 'L'){
            NearestLeft[i] = i;
            bef = i;
        }else{
            NearestLeft[i] = bef;
        }
    }

    vector<int> NearestRight(n, 0);
    bef = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'R'){
            NearestRight[i] = i;
            bef = i;
        }else{
            NearestRight[i] = bef;
        }
    }

    vector<int> Ans(n);
    for(int i = 0; i < n; i++){
        int idx;
        if(s[i] == 'R'){
            idx = NearestLeft[i] - (NearestLeft[i] - i) % 2;
        }else{
            idx = NearestRight[i] + ((i - NearestRight[i]) % 2 != 0);
        }
        Ans[idx]++;
    }

    for(int i = 0; i < n; i++){
        cout << Ans[i] << ' ';
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1872
<?php
$N = fgets(STDIN);
$TA = fgets(STDIN);
$T = (float)explode(" ",$TA)[0];
$A = (float)explode(" ",$TA)[1];
$H_array = explode(" ",fgets(STDIN));
$empty_array = [];
foreach($H_array as $H){
    array_push($empty_array,
        abs(
            ($A - ($T - (float)$H * 0.006))
        )
    );
}
echo array_keys($empty_array,min($empty_array))[0]+1;

Measured memory_bytes: 4728
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

bool check(vector<ll> as, vector<ll> bs) {
    int n = as.size();
    sort(as.begin(), as.end());
    sort(bs.begin(), bs.end());
    rep(i, n) {
        if (as[i] > bs[i]) return false;
    }
    return true;
}

void sort_tuple(vector<ll> &as, vector<ll> &bs) {
    int n = as.size();
    vector<P> ps(n);
    rep(i, n) ps[i].first = bs[i];
    rep(i, n) ps[i].second = as[i];

    sort(ps.begin(), ps.end());

    rep(i, n) as[i] = ps[i].second;
    rep(i, n) bs[i] = ps[i].first;
}

int main() {
    int n;
    cin >> n;
    vector<ll> as(n), bs(n);
    rep(i, n) cin >> as[i];
    rep(i, n)cin >> bs[i];

    if (!check(as, bs)) {
        cout << "No" << endl;
        ret();
    }

    sort_tuple(as, bs);

    multimap<ll, int> index;
    rep(i, n) index.emplace(as[i], i);

    multiset<ll> wait;
    for (ll l : as) wait.insert(l);

    int count = 0;

    rep(i, n) {
        ll o = as[i];

        if (as[i] <= bs[i]) {
            wait.erase(wait.find(o));
            index.erase(index.find(o));
            continue;
        }


        auto it = wait.upper_bound(bs[i]);
        it--;
        ll sp = *it;
        ll spi = index.find(sp)->second;

        swap(as[i], as[spi]);
        index.erase(index.find(sp));
        index.find(o)->second = spi;

        assert(as[i] <= bs[i]);

        wait.erase(wait.find(sp));
        count++;

    }

    cout << (n - 2 >= count ? "Yes" : "No") << endl;

}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INF = 2147483647;
const long long LINF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

struct mint {
    long long x;
    mint(long long x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
    	return *this;
    }
    mint& operator*=(const mint a) {
    	(x *= a.x) %= MOD;
    	return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
    	if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
    	return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

int main(void){
    ll N,K; cin >> N >> K;
    vector<mint> ans(K+1,0);
    vector<mint> f(K+1,0); REP(i,K) f[i+1] = mint(i+1).pow(N);
    RREP(i,K){
        mint tmp = f[K/(i+1)];
        mint rmv(0);
        for(int k=2; (i+1)*k<=K; k++){
            rmv += ans[k*(i+1)];
        }
        ans[i+1] = tmp - rmv;
    }
    mint ans_(0); REP(i,K) ans_ += ans[i+1]*(i+1);
    cout << ans_.x << endl;
    return 0;
}

Measured memory_bytes: 4780
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	if (k % 2 == 0)
	{
		println(a - b);
	}
	else
	{
		println(b - a);
	}
}


Measured memory_bytes: 256
// abc149_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    string S, T;
    cin >> S >> T;

    string ans = T + S;
    print(ans);

    return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))

now=1
to=0
t=k
l=[0]*n
l[0]=1
cnt=2

while t>0:
    to=a[now-1]
    t-=1
    if l[to-1]!=0:
        now=to
        break
    else:
        l[to-1]=cnt
        cnt+=1
    now=to

if t==0:
    print(now)
else:
    loop=max(l)-l[to-1]+1 #loopの長さ
    start=l[to-1]-1 #start回目で開始地点
    ans=l.index((k-start)%loop+start+1)+1
    print(ans)

Measured memory_bytes: 92424
#include <iostream>
using namespace std;
int main(void){
    int n;
    long long m=0, a=0, j=0, x, y, z, d;
    string s;
    cin >> s;
    n = s.length();
    for(int i=0;i<n;i++){
        if(s[i]=='A'){
            a++;
        }else if(i+1<n&&s[i]=='B'&&s[i+1]=='C'){
            m += a;
            i++;
        }else{
            a=0;
        }
    }
    cout << m << endl;
}


Measured memory_bytes: 640