akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;

typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<" "<<y<<endl
#define pl(x)                   out<<x
#define p2l(x,y)                out<<x<<" "<<y
#define range(v)                v.begin(),v.end()
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

void ssolve(std::istream& in, std::ostream& out){
    int n;
    s(n);
    vi h(n);
    f(i, 0, n){
        s(h[i]);
    }
    vi dp(n, 1e9+5);
    dp[0] = 0;
    f(i, 0, n){
        for(int j = i + 1; j < i + 3 && j < n; j++){
            dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
        }
    }
    p(dp[n - 1]);
    return;
}

class AFrog1 {
public:
void solve(std::istream& in, std::ostream& out) {
    ios_base::sync_with_stdio(false);
    in.tie(0);out.tie(0);
    int t;
    int READ = 0;
    if(READ) s(t);
    else t = 1;
    while(t--){
        ssolve(in, out);
    }
}
};

integer main() {
    AFrog1 solver;
    std::istream& in(std::cin);
     std::ostream& out(std::cout);
     solver.solve(in, out);
}

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

int main() {
    int n, m, q;
    std::vector<std::vector<int>> vec;

    std::cin >> n >> m >> q;
    vec.resize(n);

    for(int i = 0; i < m; ++i) {
        int l, r;

        std::cin >> l >> r;

        --l, --r;

        vec[l].push_back(r);
    }

    for(int i = 0; i < n; ++i) {
        std::sort(vec[i].begin(), vec[i].end());
    }

    for(int i = 0; i < q; ++i) {
        int p, q;

        std::cin >> p >> q;
        --p, --q;

        int cnt = 0;
        for(int j = p; j <= q; ++j) {
            //std::cout << j << std::endl;
            cnt += std::upper_bound(vec[j].begin(), vec[j].end(), q) - vec[j].begin();
        }

        std::cout << cnt << std::endl;
    }
}

Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<string,int> P;
const ll MOD=1e9+7;
ll kuri2(ll x,ll a)
{
	ll ret=1;
	ll tmp=x;
	while(a>0)
	{
		if(a&1LL)
		{
			ret*=tmp;
			ret%=MOD;
		}
		tmp=tmp*tmp;
		tmp%=MOD;
		a>>=1LL;
	}
	if(ret<0)
		ret+=MOD;
	return ret;
}
ll kai[200001];
ll gyaku[200001];
int main()
{
	int n,m;
	ll k;
	cin>>n>>m>>k;
	ll ans=0;
	kai[0]=1;
	gyaku[0]=kuri2(kai[0],MOD-2);
	for(int i=1;i<200001;i++)
	{
		kai[i]=(kai[i-1]*i+MOD)%MOD;
		gyaku[i]=kuri2(kai[i],MOD-2);
	}
	//cerr<<(kai[10]*gyaku[10])%MOD<<endl;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(i==0 && j==0)
				continue;
			ll d=i+j;
			ll cnt=(n-i)*(m-j);
			if(i>0 && j>0)
				cnt*=2;
			//cerr<<cnt<<" ";
			ll tmp=d;
			tmp*=kai[n*m-2];
			tmp%=MOD;
			tmp*=gyaku[k-2];
			tmp%=MOD;
			tmp*=gyaku[n*m-k];
			tmp%=MOD;
			tmp*=cnt;
			tmp%=MOD;
			ans+=tmp;
			ans%=MOD;
		}
		//cerr<<endl;
	}
	if(ans<0)
		ans+=MOD;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<vector<int>> A(n + 1, vector<int>(n - 1));
    for (int i = 1; i <= n; ++i) {
        for (int j = n - 1; j--; ) {
            cin >> A[i][j];
        }
    }
    int sz = n * (n - 1);
    set<int> sp;
    for (int i = 1; i <= n; ++i) {
        if (A[A[i].back()].back() == i)
            sp.insert(min(i, A[i].back()));
    }
    int ans = 0;
    while (sz > 0) {
        ++ans;
        sz -= sp.size() << 1;
        if (sp.empty()) {
            printf("-1\n");
            return 0;
        }
        vector<int> ch;
        for (int i : sp) {
            int j = A[i].back();
            A[j].pop_back();
            A[i].pop_back();
            ch.push_back(i);
            ch.push_back(j);
        }
        sp.clear();
        for (int i : ch) {
            if (A[i].empty()) continue;
            int j = A[i].back();
            if (!A[j].empty() && A[j].back() == i) {
                sp.insert(min(j, A[j].back()));
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 4224
def main():
    a, b, c, x, y = map(int, input().split())
    print(min([a*x+b*y, c*max(x, y)*2, c*x*2+max(0, (y-x)*b), c*y*2+max(0, (x-y)*a)]))

if __name__ == "__main__":
    main()

Measured memory_bytes: 38256
H = []
W = []
while True:
    input_item = list(map(int, input().split()))
    if input_item == [0, 0]:
        break
    H.append(input_item[0])
    W.append(input_item[1])

for i in range(len(H)):
    h = H[i]
    w = W[i]
    line_odd = "#."*(w//2) + "#"*(w%2)
    line_even = ".#"*(w//2) + "."*(w%2)
    for i in range(1, h+1):
        if i%2==1:
            print(line_odd)
        else:
            print(line_even)
    print()


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

using namespace std;
#define ll long long
const int maxn = 1e5 + 100;
ll s[maxn][8];
ll cum[maxn];
vector < pair < ll , ll > > arr;
ll dp[maxn][8];
ll n , p , k;

ll solve(int i , int d){
    if(d == p){
        ll nei = abs(i-d+1);
        ll d = n - (p+k);
        if(nei>d)
            return (-1e18);
        ll hm = abs(nei-d);
        cout << i << " " << d << " " << p << endl;
        return cum[n-1]-cum[i+hm-1];
    }
    if(i == n){
        return (-1e18);
    }
    ll &ret = dp[i][d];
    if(ret != -1)return ret;
    ret = max( s[arr[i].second][d] + solve(i+1,d+1) , solve(i+1,d) );
    return ret;
}

int main()
{
    ll n, m, k, a = 0, b = 0;
    string s;
    cin>>s;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'A') a = 1;
        if(s[i] == 'B') b = 1;
    }
    if(a && b) puts("Yes");
    else puts("No");
    return 0;
}


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

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

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

int main(){
	ll n,m;
	cin >>n >>m;
	
	if(n==1){
		cout <<m <<"\n"; return 0;
	}
	
	int mx = m/n;
	repr(i, mx, 2){
		ll w = m -(i * (n-1));
		if(w % i ==0){
			cout << i <<"\n";
			return 0;
		}
	}
	cout << 1 <<"\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
using namespace std;
using ll=long long;

int main(){
    string s;
    cin>>s;
    int cnt=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='x') cnt++;
    }
    cout<<(cnt>=8 ? "NO" :"YES")<<endl;
    
    return 0;
}

Measured memory_bytes: 764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String s = scan.next();
		scan.close();
		int cnt=1;
		for(int i=1;i<n;i++) {
			if(s.charAt(i)!=s.charAt(i-1))cnt++;
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 24620
#include <stdio.h>
#include <string.h>
int main()
{
    char a[11], b[11]="2019/04/30";
    scanf("%s", &a);
    if(strcmp(a, b) <= 0){
        printf("Heisei\n");
    }else{
        printf("TBD\n");
    }

    return 0;
}

Measured memory_bytes: 128
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    dp=[0]*100001
    dp[0]=1
    x=int(input())
    for i in range(100,100001):
        if sum(dp[max(i-105,0):i-99])>0:
            dp[i]=1
    print(dp[x])

main()

Measured memory_bytes: 3828
import java.io.IOException;
import java.io.InputStream;

public class Main {
    public static void main(String[] args)throws Exception {
        StringBuilder sb=new StringBuilder();
        FastReader in=new FastReader(System.in);
        int i,j;
        int n=in.nextInt();
        int m=in.nextInt();
        if(n>m)
            System.out.println("safe");
        else
            System.out.println("unsafe");
    }
}

class FastReader {

    byte[] buf = new byte[2048];
    int index, total;
    InputStream in;

    FastReader(InputStream is) {
        in = is;
    }

    int scan() throws IOException {
        if (index >= total) {
            index = 0;
            total = in.read(buf);
            if (total <= 0) {
                return -1;
            }
        }
        return buf[index++];
    }

    String next() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c > 32; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }

    int nextInt() throws IOException {
        int c, val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }

    long nextLong() throws IOException {
        int c;
        long val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }
}





Measured memory_bytes: 32200
import java.util.*;
public class Main {
	public static void main(final String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b= sc.nextInt();
        int c = sc.nextInt();

        if(a+b+c == 17){
            if(a == 5&& b == 5 || a==5 && c ==5 || b == 5 && c == 5){
                System.out.println("YES");
            }else{
                System.out.println("NO");
            }
        }else{
            System.out.println("NO");
        }
	}
}


Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
  std::vector<int> v;
  int c[3][3];
  for (int i=0; i<3; i++) {
    for (int j=0; j<3; j++) {
      cin >> c[i][j];
    }
  }
  int a[3],b[3];
  for (int a0=-100000; a0<c[0][0]; a0++) {
    for (int j = 0; j<3; j++) {
      b[j] = c[0][j] - a0;
    }
    if (c[1][0]-b[0] == c[1][1]-b[1] && c[1][1]-b[1] == c[1][2]-b[2] && c[2][0]-b[0] == c[2][1]-b[1] && c[2][1]-b[1] == c[2][2]-b[2]){
      cout << "Yes" << "\n";
      return 0;
    }
  }
  cout << "No" << "\n";
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
X = list(map(int, input().split()))
X_sorted = sorted(X)
L = X_sorted[N//2-1]
R = X_sorted[N//2]


for x in X:
    print(L if x >= R else R)


Measured memory_bytes: 26756
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

//        long start1 = System.currentTimeMillis();
//        long end1 = System.currentTimeMillis();
//        System.out.println("time1: " + (end1 - start1));

        Scanner scanner = new Scanner(System.in);

        String[] inputs = scanner.nextLine().split(" ");

        int n = Integer.parseInt(inputs[0]);
        int m = Integer.parseInt(inputs[1]);

        int result = n * (n - 1) / 2 + m * (m - 1) / 2;

        System.out.println(result);
    }
}

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

#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using pint = pair<int, int>;
using pstring = pair<int, string>;

int main() {
    ll ans=0;
    ll L, R, d;
    cin >> L >> R >> d;
    for(int i = L; i <= R; i++) {
        if(i % d == 0) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3668
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.split_whitespace().map(|x| x.parse::<u64>().unwrap());
    let n = it.next().unwrap();
    let r = it.next().unwrap();

    if n >= 10 {
        println!("{}", r);
    } else {
        println!("{}", r + 100 * (10 - n));
    }
}


Measured memory_bytes: 4352
import java.util.*;
class Main {
	public static void main(String[] abcdefg) {
		Scanner sc=new Scanner(System.in);
		List<String>list=new ArrayList<>();
		int n=sc.nextInt();
		for(int i=0;i<n;i++)
			list.add(sc.next());
		
			int ac=0,wa=0,tle=0,re=0;
		for(int i=0;i<n;i++){
			if(list.get(i).equals("AC")){
				ac++;
			}
			else if(list.get(i).equals("WA")){
				wa++;
			}
			else if(list.get(i).equals("TLE")){
				tle++;
			}
			else{
				re++;
			}
		}	
		System.out.print("AC x "+ac+"\n");
		System.out.print("WA x "+wa+"\n");
		System.out.print("TLE x "+tle+"\n");
		System.out.print("RE x "+re+"\n");
		sc.close();
		   
	}
}



Measured memory_bytes: 63800
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N; cin >> N;
    vl as(N, 0); REP(i, N) cin >> as[i];
    map<ll, ll> m; ll sum = 0; m[0]++;
    REP(i, N){
        sum += as[i]; m[sum]++;
    }
    
    ll ans = 0;
    FORMAP(it, m){
        ll n = it->ss;
        ans += n * (n-1) / 2;
    }
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 14336
n, y = gets.strip.split(" ").map(&:to_i)

(0..n).each do |a|
  (0..n-a).each do |b|
      if a*10000 + b*5000 + (n-a-b)*1000 == y
        puts "#{a} #{b} #{n-a-b}"
        exit
      end
  end
end

puts "-1 -1 -1"

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

#define lf long double

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>>N;
    vector<lf> x(N),y(N);
    rep(i,N) cin>>x[i]>>y[i];
    vi perm(N);
    rep(i,N) perm[i]=i;
    lf ans=0;
    int step=0;
    do{
        lf sum=0.0;
        rep(i,N-1){
            int a = perm[i+1];
            int b = perm[i];
            lf dx = x[b]-x[a];
            lf dy = y[b]-y[a];
            sum+=sqrt(dx*dx+dy*dy);
        }
        ans+=(sum-ans)/(step+1);
        step++;
    }while(next_permutation(all(perm)));
    cout<<setp(15);
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = A.copy()
B.sort()
a = B[N//2-1]
b = B[N//2]

if a == b:
    for i in range(N):
        print(a)
else:
    for i in range(N):
        if A[i] <= a:
            print(b)
        else:
            print(a)

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

int main() {
  string s; cin >> s;
  int ans = 0;
  int sn = s.size(), i = 0;
  while(i < sn) {
    if (s[i] == 'R') {
      int cnt = 0;
      while(s[i] == 'R' && i < sn) {
        i++;
        cnt++;
      }
      ans = max(ans, cnt);
    }
    i++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3616
import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class Main {

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

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new
		// File("D:\\UserArea\\J0124567\\Downloads\\ALDS1_6_A-in9.txt"));

		int n = scan.nextInt();
		int[] a = new int[n];

		for (int i = 0; i < n; i++)
			a[i] = scan.nextInt();

		int v = Q2sort(a, 0, n - 1);

		StringBuilder s = new StringBuilder(String.valueOf(a[0]));
		for (int i = 1; i < a.length; i++)
			if (i == v)
				s.append(" [" + a[i] + "]");
			else
				s.append(" " + a[i]);
		System.out.println(s);

		scan.close();
		System.exit(0);
	}

	private static int Q2sort(int[] a, int st, int ed) {
		int x = a[ed];
		int i = st - 1;
		for (int j = st; j < ed; j++)
			if (a[j] <= x) {
				i++;
				int tmp = a[j];
				a[j] = a[i];
				a[i] = tmp;
			}
		int tmp = a[i + 1];
		a[i + 1] = a[ed];
		a[ed] = tmp;
		return i + 1;
	}

	private static void Qsort(int[] a, int st, int ed) {
		if (st >= ed)
			return;
		int x = a[ed];
		int l = st, r = ed - 1;
		while (true) {
			for (; l < ed && a[l] <= x; l++)
				;
			for (; r >= st && a[r] > x; r--)
				;
			if (l < r) {
				int tmp = a[l];
				a[l] = a[r];
				a[r] = tmp;
			} else
				break;
		}
		int tmp = a[l];
		a[l] = a[ed];
		a[ed] = tmp;
		Qsort(a, st, l - 1);
		Qsort(a, l + 1, ed);
	}

	private static void Csort(int[] a, int[] b, int k) {
		int[] c = new int[k + 1];
		for (int i = 0; i < a.length; i++)
			c[a[i]]++;
		for (int i = 1; i < c.length; i++)
			c[i] += c[i - 1];

		for (int i = a.length - 1; i >= 0; i--) {
			c[a[i]]--;
			b[c[a[i]]] = a[i];
		}
	}
}

Measured memory_bytes: 68292
N, = map(int, input().split())
As, Bs = [], []
for _ in range(N):
    A, B = map(int, input().split())
    Bs.append([B, A])
Bs.sort()
t = -1
r = "Yes"
for b, a in Bs:
    t += a
    if b > t:
        continue
    r = "No"
    break
print(r)


Measured memory_bytes: 76376
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String a = s.nextLine();
		String b = s.nextLine();
		String c = s.nextLine();
		String ans = "";

		String aa = "A";
		String bb = "B";
		String cc = "C";

		int a1 = a.length();
		int b1 = b.length();
		int c1 = c.length();
		int i = 0;
		int j = 0;
		int k = 0;
		String senntou = "a";

		List<String> lista = new ArrayList<String>();
		List<String> listb = new ArrayList<String>();
		List<String> listc = new ArrayList<String>();

		for (i = 0; i < a1; i++) {
			lista.add(a.charAt(i) + "");
		}

		for (j = 0; j < b1; j++) {
			listb.add(b.charAt(j) + "");
		}

		for (k = 0; k < c1; k++) {
			listc.add(c.charAt(k) + "");
		}

		i = 0;
		for (i = 0;; i++) {
			

			if (senntou.equals("a")) {

				if (lista.size() == 0) {

					ans = aa;
					break;

				} else if (lista.get(0).equals("a")) {

					senntou = lista.get(0);

					lista.remove(0);

				} else if (lista.get(0).equals("b")) {

					senntou = lista.get(0);
					lista.remove(0);

				} else if (lista.get(0).equals("c")) {

					senntou = lista.get(0);
					lista.remove(0);

				}

			} else if (senntou.equals("b")) {
				if (listb.size() == 0) {
					ans = bb;
					break;
				} else if (listb.get(0).equals("a")) {

					senntou = listb.get(0);
					listb.remove(0);

				} else if (listb.get(0).equals("b")) {

					senntou = listb.get(0);
					listb.remove(0);

				} else if (listb.get(0).equals("c")) {

					senntou = listb.get(0);
					listb.remove(0);

				}

			} else if (senntou.equals("c")) {
				if (listc.size() == 0) {
					ans = cc;
					break;

				} else if (listc.get(0).equals("a")) {

					senntou = listc.get(0);
					listc.remove(0);

				} else if (listc.get(0).equals("b")) {

					senntou = listc.get(0);
					listc.remove(0);

				} else if (listc.get(0).equals("c")) {

					senntou = listc.get(0);
					listc.remove(0);

				}
			}
		}

		System.out.println(ans);

	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
using namespace std;
static const int MAX_len = 3000;

int main(void){
    // 入力
    string s,t;
    cin >> s >> t;

    // dp[i+1][j+1]=sのi番目とtのj番目を使ったときのLCS
    int dp[MAX_len+1][MAX_len+1];
    int s_len = s.length();
    int t_len = t.length();
    for(int i=0; i<=s_len; i++) dp[i][0]=0;
    for(int j=0; j<=t_len; j++) dp[0][j]=0;

    for(int i=0; i<s_len; i++){
        for(int j=0; j<t_len; j++){
            if(s[i]==t[j]){
                dp[i+1][j+1] = dp[i][j] + 1;
            }
            else{
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
            }
        }
    }

    string ans;
    if(dp[s_len][t_len]==0) ans = " ";

    int i=s_len, j=t_len;
    while(i&&j){
        if(dp[i-1][j]==dp[i][j]) i--;
        else if(dp[i][j-1]==dp[i][j]) j--;
        else{
            ans = s[i-1] + ans;
            i--;
            j--;
        }
    }

    // 出力
    cout << ans;

    return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int ans = 0;
  if (s[0]=='1') ans++;
  if (s[1]=='1') ans++;
  if (s[2]=='1') ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import copy
import math
import itertools
import numpy as np
l = [int(c) for c in input().split()]
N = l[0]
M = l[1]
KA = [list(map(int,input().split())) for c in range(N)]

F = [0]*M

for i in range(N):
    for j in range(1,KA[i][0]+1):
        F[KA[i][j]-1]+=1
print(F.count(N))

Measured memory_bytes: 27136
//Author rahuliitkgp
/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define ff              first
#define ss              second
#define SZ(x)           ((int)(x).size())
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//#endif
}

int main(){
    cpp();
    ll n;
    cin>>n;
    vector<ll> v(n+1);
    for(ll i=1; i<=n; i++){
        cin>>v[i];
    }
    unordered_map<ll, ll> mapp;
    for(ll i=1; i<=n; i++){
        mapp[i+v[i]]++;
    }
    ll ans = 0;
    for(ll i=n; i>=1; i--){
        ans+=mapp[i-v[i]];
    }
    cout<<ans<<endl;
    return 0;
}




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

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Trim();
            if(s.Contains("AB") | s.Contains("BA")){
                Console.WriteLine("Yes");
            }else{
                Console.WriteLine("No");
            }
        }
    }
}


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

int main()
{
    int a,b,c,flag = 1;
    cin >> a >> b >> c;

    for(int i = 1; i < b; i++)
        if(a * i % b == c) flag = 0;

    cout << (flag == 0 ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 256
/*
    Author:    DreamCat4er
    Created:   29.08.2020 15:54:00
*/
#include <bits/stdc++.h>
using namespace std;

void solve() {
    string s, t;
    cin >> s >> t;
    int ans = (int)(t.size());
    for (int i = 0; i + (int)(t.size()) <= (int)(s.size()); ++i) {
        int cur = 0;

        for (int j = 0; j < (int)(t.size()); ++j)
            cur += (t[j] != s[i + j]);

        ans = min(ans, cur);
    }

    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
                
    #ifdef _LOCAL
        int t;
        cin >> t;
        for (int _t = 0; _t < t; ++_t) {
            cout << "Case " << _t << " :\n";
            solve();
            cout << "\n";
        }
    #else
        solve();
    #endif // _LOCAL

    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#define W 0
#define G 1
#define B 2
#define inf 5000
#define MAX 100
#define NIL -1
using namespace std;

int n;
int A[MAX][MAX];

int Prim(){
    int color[MAX],d[MAX],p[MAX];
    int min,u,sum = 0;
    for(int i = 0; i < n; i++){
        color[i] = W;
        d[i] = inf;
        p[i] = NIL;
    }
    
    d[0] = 0;
    
    while(1){
        u = -1;
        min = inf;
        for(int i = 0; i < n; i++){
            if(d[i] < min && color[i] != B){
                u = i;
                min = d[i];
            }
        }
        
        if(u == -1) break;
            
        color[u] = B;
            
        for(int i = 0; i < n; i++){
            if(color[i] != B && A[u][i] != NIL){
                if(A[u][i] < d[i]){
                    d[i] = A[u][i];
                    color[i] = G;
                    p[i] = u;
                }
            }
        }
    }
    
    for(int i = 0; i < n; i++) {
        
        if(p[i] != -1) sum += A[i][p[i]];
        
    }
    
    return sum;
     
}

int main(){
    int x;
    scanf("%d",&n);
    for(int i = 0; i < n; i ++){
        for(int j = 0; j < n; j++){
            scanf("%d",&x);
            if( x == -1) A[i][j] = NIL;
            else A[i][j] = x; 
        }
    }
    
    cout << Prim() << endl;
    return 0;
}


Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
const int N = 200001;

int s[N], f[N];
void init(int n) {
    fill_n(f + 1, n, 0);
    fill_n(s + 1, n, 1);
}

int find(int x) { return f[x] ? f[x] = find(f[x]) : x; }
void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (s[x] < s[y]) swap(x, y);
    f[y] = x; s[x] += s[y];
}

int main(void) {
    int n, m; scanf("%d %d", &n, &m);
    init(n);
    for (int i = 1; i <= m; ++i) {
        int x, y; scanf("%d %d", &x, &y);
        unite(x, y);
    }
    int ans = 1;
    for (int i = 1; i <= n; ++i)
        ans = max(ans, s[i]);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 5388
#include<bits/stdc++.h>
 
using namespace std;
 
using   ll=long long;
using   ld=long double;
 
#define fast           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl           "\n"
#define int            long long 
#define pb             push_back
#define mp             make_pair
#define vll            vector<ll>
#define ff              first
#define ss              second
#define pll            pair<ll,ll>
#define ALL(v)         v.begin(),v.end()
#define ALLR(v)        v.rbegin(),v.rend()
#define pii            3.14159265358979323

void bfs(vector<vector<char>> & a,ll n,ll m,vector<vector<ll>> & cn)
{
    map<pll,ll> vis;
    
    cn[n][m]=0;
    
    queue<pll> qq;
    
    qq.push({n,m});
    
    vis[{n,m}]=1;
    
    while(!qq.empty())
    {
        pll g=qq.front();
        
        qq.pop();
        
        if(a[g.ff-1][g.ss]=='.' && vis[{g.ff-1,g.ss}]==0)
        {
            cn[g.ff-1][g.ss]=cn[g.ff][g.ss]+1;
            
            vis[{g.ff-1,g.ss}]=1;
            
            qq.push({g.ff-1,g.ss});
        }
        
        if(a[g.ff+1][g.ss]=='.' && vis[{g.ff+1,g.ss}]==0)
        {
            cn[g.ff+1][g.ss]=cn[g.ff][g.ss]+1;
            
            vis[{g.ff+1,g.ss}]=1;
            
            qq.push({g.ff+1,g.ss});
        }
        if(a[g.ff][g.ss-1]=='.' && vis[{g.ff,g.ss-1}]==0)
        {
            cn[g.ff][g.ss-1]=cn[g.ff][g.ss]+1;
            
            vis[{g.ff,g.ss-1}]=1;
            
            qq.push({g.ff,g.ss-1});
        }
        if(a[g.ff][g.ss+1]=='.' && vis[{g.ff,g.ss+1}]==0)
        {
            cn[g.ff][g.ss+1]=cn[g.ff][g.ss]+1;
            
            vis[{g.ff,g.ss+1}]=1;
            
            qq.push({g.ff,g.ss+1});
        }
    }
}
 
void solve()
{
    ll n,m,ans=0;
    
    cin>>n>>m;
    
    vector<vector<char>> a(n+2,vector<char>(m+2));
    
    for(int i=0;i<=n+1;i++)    a[i][0]='#';
    for(int j=0;j<=m+1;j++)    a[0][j]='#';
    
    for(int i=0;i<=n+1;i++)    a[i][m+1]='#';
    for(int j=0;j<=m+1;j++)    a[n+1][j]='#';
    
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin>>a[i][j];
        }
    }
    
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(a[i][j]=='.')
            {
                vector<vector<ll>> cn(n+2,vector<ll>(m+2,n*m));
                
                bfs(a,i,j,cn);
                
                for(int r=1;r<=n;r++)
                {
                    for(int l=1;l<=m;l++)
                    {
                        if(cn[r][l]!=n*m)      ans=max(ans,cn[r][l]);
                    }
                }
                
            }
        }
    }
    
    
    cout<<ans;
}
 
 
signed main()
{
 
    fast;
 
    ll t;
    
    t=1;
    
    //cin>>t;
    
    while(t--)
    {
        solve();
    }
 
    return 0;
}

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

int main(){
    int n, y;
    std::cin >> n >> y;

    std::vector<int> sum;
    std::vector<std::string> pattern;
    std::ostringstream ss1, ss2, ss3;
    std::string str;
    for(int i = 0; i <= n; ++i){
        for(int j = i; j <= n; ++j){
            ss1.str("");
            ss2.str("");
            ss3.str("");

            sum.push_back(10000*i + 5000*(j - i) + 1000*(n - j));

            ss1 << i;
            ss2 << j - i;
            ss3 << n - j;

            str = ss1.str() + " " + ss2.str() + " " + ss3.str();

            pattern.push_back(str);
        }
    }

    std::vector<int>::iterator itr = std::find(sum.begin(), sum.end(), y);
    if(sum.end() == itr){
        std::cout << "-1 -1 -1" << std::endl;
    }else{
        int dist;
        dist = std::distance(sum.begin(), itr);
        std::cout << pattern.at(dist) << std::endl;
    }
}


Measured memory_bytes: 65700
N = int(input())
W = [input() for _ in range(N)]

if len(list(set(W))) == N:
    first = W[0]
    for i in W[1:]:
        if first[-1] != i[0]:
            print("No")
            exit()
        first = i
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
numberOfCat,unidentifiedNumber,totalCatNumber=input().split(" ")
numberOfCat = int(numberOfCat)                            #int変換
unidentifiedNumber = int(unidentifiedNumber)                          #int変換
totalCatNumber = int(totalCatNumber)

if numberOfCat > totalCatNumber or (numberOfCat + unidentifiedNumber) < totalCatNumber:
    print("NO")
else:
    print("YES")

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

int main() {
  string w;
  cin >> w;

  for (int i = 0; i < w.length(); i++) {
    if(count(w.begin(), w.end(), w[i]) % 2 != 0){
      cout << "No" << endl;
      exit(0);
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

ll binpow(ll a, ll b) {
    if (b == 0)
    {
        return 1;
    }
    ll res = binpow(a, b / 2);
    res*=res;
    if (b % 2)
    {
        return res * a;
    }
    return res;
}

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

string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    cout<<max(0,(h2*60+m2)-(h1*60+m1)-k);
    return 0;
}

Measured memory_bytes: 3636
#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)
#define uniq(x) (x).erase(unique(all(x)),(x).end())
#define bitcnt(x) __builtin_popcount(x)

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> P;
typedef pair<P, int> PP;
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 = 128;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

int path[MAX][MAX];
vector <PP> p;

void solve(void){
    int N, M;
    cin >> N >> M;
    rep(N, i) rep(N, j) path[i][j] = INF;
    rep(M, i) {
        int a, b, c;
        scanf("%d %d %d\n", &a, &b, &c);
        a--; b--;
        path[a][b] = path[b][a] = c;
        p.pb(PP(P(a, b), c));
    }
    rep(N, k) rep(N, i) rep(N, j) {
        if (i == j) path[i][j] = 0;
        else path[i][j] = min(path[i][j], path[i][k] + path[k][j]);
    }

    int cnt = 0;
    for (auto pi : p) {
        int a = pi.first.first, b = pi.first.second, c = pi.second;
        if (path[a][b] != c) cnt++;
    }
    cout << cnt << endl;
}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i, n, x, sum;

  while(1){
    scanf("%d", &n);
    if(n == 0) break;

    for(i=0, sum=0; i<n/4; i++){
      scanf("%d", &x);
      sum += x;
    }

    printf("%d\n", sum);
  }

  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<iterator>
#include<set>
#include<queue>

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

using namespace std;



int main(){
	int n,m; cin >> n >> m;
	vector<int> howmany(100000+1);
	vector<int> modMany(m);
	rep(i,n){
		int temp; cin >> temp;
		howmany[temp] += 1;
		modMany[temp % m] += 1;
	}
	vector<int> modEqual(m);
	rep(i, 100000+1){
		if(i % m != 0)
			modEqual[i % m] += howmany[i] / 2;
	}
	int dame = 0;
	rep(i, m/2 + 1){
		if(i == 0)
			dame += modMany[0] % 2;
		else if(i == m/2 && m % 2 == 0){
			dame += modMany[m/2] % 2;
		}
		else{
			int counterpart = m - i;
			int i1 = modMany[i] - min(modMany[i], modMany[counterpart]);
			int i2 = modMany[counterpart] - min(modMany[i], modMany[counterpart]);
			if(i1 % 2 == 0)
				dame += max(0, i1 - 2*modEqual[i]);
			else
				dame += max(1, i1 - 2*modEqual[i]);
			if(i2 % 2 == 0)
				dame += max(0, i2 - 2*modEqual[counterpart]);
			else
				dame += max(1, i2 - 2*modEqual[counterpart]);

		}
	}
	int res = (n - dame) / 2;
	cout << res << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<algorithm>
#include<functional>
typedef long long ll;

using namespace std;


int main() {
	int n;
	cin >> n;
	int a[200000];
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	if (n >= 3) {
		for (int i = n-1 ;i >=0;i -= 2) {
			cout << a[i]<<' ' ;
		}
		if (n % 2 == 1) {
			for (int i = 1;i < n - 2;i += 2) {
				
			
				cout << a[i] << ' ';
			}
		}
		else {
			for (int i = 0;i < n - 2;i += 2) {
			
				cout <<a[i]<< ' ';
			}
		}
		
			cout << a[n - 2];
		}

	

   if(n==2){
	cout << a[1] << ' ' << a[0];
}
   if(n==1) { cout << a[0]; }






   }

Measured memory_bytes: 2944
/*
    CP Submission
*/

#include<bits/stdc++.h>

using namespace std;

/* Shortcuts */
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define val(x) cout << #x << ": " << (x) << endl;
#define log(x) cout << (x) << endl;
#define sz(x) (int)(x.size())

/* typedefs */
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <string,string> mss;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;

    int mini = pow(2,30);
    int maxi = 0;
    int x;
    for(int i = 0; i < n; i++){
        cin >> x;
        maxi = max(maxi, x);
        mini = min(mini, x);
    }

    cout << abs(maxi - mini) << endl;


    return 0;
}


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

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

CA = [0] * (N + 1)
CB = [0] * (N + 1)

for a in A:
  CA[a] += 1
for b in B:
  CB[b] += 1
X = 0
x = 0
y = 0
ans = [[0, 0] for i in range(N)]

for i in range(1, N + 1):
  if CA[i] + CB[i] > N:
    print('No')
    exit()
  if X + CA[i] + CB[i] < N:
    for j in range(X, X + CA[i]):
      ans[j][0] = i
    for j in range(X + CA[i], X + CA[i] + CB[i]):
      ans[j][1] = i
    X += CA[i] + CB[i]
    x += CA[i]
    y += CB[i]
    CA[i] = 0
    CB[i] = 0
  else:
    k = min(N, N + x - CB[i], X + CA[i])
    for j in range(X, k):
      ans[j][0] = i
    for j in range(k, N):
      ans[j][1] = i
    CA[i] -= k - X
    CB[i] -= N - k
    break
x = 1
y = 1
for j in range(N):
  while x < N + 1 and CA[x] == 0:
    x += 1
  if ans[j][0] == 0:
    ans[j][0] = x
    CA[x] -= 1
for j in range(N):
  while y < N + 1 and CB[y] == 0:
    y += 1
  if ans[j][1] == 0:
    ans[j][1] = y
    CB[y] -= 1
ans.sort()
print('Yes')
print(*(ans[i][1] for i in range(N)))
  

Measured memory_bytes: 140952
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
#define EQ(a,b) (abs((a)-(b)) < EPS)
using namespace std;
typedef double D;
typedef complex<D> P;
typedef pair<int,int> pii;
typedef pair<D, pii> data;
typedef vector<int> vi;
const D EPS = 1e-8;

int n;
string name[110];
D T,r,x[110],y[110],t[110][1100];
D vx[110][1100], vy[110][1100];

vector<D> cal(int a, int b){
  vector<D> res;
  P pa = P(x[a],y[a]), pb = P(x[b],y[b]);
  if( abs(pa-pb)<r+EPS )res.push_back(0);

  int ta=1, tb=1;
  D cur = 0, nxt = min(t[a][ta],t[b][tb]);
  while(!EQ(cur,T)){
    D tx = pa.real() - pb.real(), ty = pa.imag() - pb.imag();
    D tvx = vx[a][ta] - vx[b][tb], tvy = vy[a][ta] - vy[b][tb];
    D A = tvx*tvx + tvy*tvy, B = 2*tvx*tx + 2*tvy*ty, C = tx*tx + ty*ty - r*r;
    D d = B*B - 4*A*C;
    vector<D> sol;

    if(EQ(A,0)){
      if(!EQ(B,0))sol.push_back(-C/B);
    }else if(EQ(d,0)){
      sol.push_back(-B/2/A);
    }else if(d>EPS){
      sol.push_back( (-B - sqrt(d))/2/A );
      sol.push_back( (-B + sqrt(d))/2/A );
    }

    rep(i,sol.size()){
      if(sol[i]+EPS < 0 || nxt-cur+EPS < sol[i])continue;
      res.push_back(cur + sol[i]);
    }

    D dif = nxt - cur;
    pa += P(vx[a][ta]*dif, vy[a][ta]*dif);
    pb += P(vx[b][tb]*dif, vy[b][tb]*dif);

    cur = nxt;
    if(EQ(t[a][ta],cur))ta++;
    if(EQ(t[b][tb],cur))tb++;
    nxt = min(t[a][ta],t[b][tb]);
  }
  return res;
}

bool prop[110];
vector<vi> g;
void dfs(int v){
  prop[v] = true;
  for(int u : g[v]){
    if(!prop[u])dfs(u);
  }
}

int main(){
  cin.tie(0); ios::sync_with_stdio(0);
  while(cin >> n >> T >> r){
    if(n==0)break;
   
    rep(i,n){
      cin >> name[i];
      cin >> t[i][0] >> x[i] >> y[i];
      for(int j=0;;j++){
	cin >> t[i][j+1] >> vx[i][j+1] >> vy[i][j+1];
	if(EQ(t[i][j+1], T))break;
      }
    }

    vector<data> event;
    rep(i,n)rep(j,i){
      vector<D> sub_event = cal(i,j);
      for(D d : sub_event){
	event.push_back(data(d, pii(i,j)));
      }
    }
    sort(all(event));
    
    memset(prop,0,sizeof(prop));
    prop[0] = true;
    g = vector<vi>(n,vi());

    rep(i,event.size()){
      if(event[i].first>T+EPS)break;
      int a = event[i].second.first, b = event[i].second.second;
      bool f = true;
      rep(j,g[a].size()){
	if(g[a][j] == b){ f = false; break; }
      }

      if(f){
	g[a].push_back(b); g[b].push_back(a);
	if(prop[a] |= prop[b])dfs(a);
      }else{
	rep(j,g[a].size()){
	  if(g[a][j] == b)g[a].erase(g[a].begin()+j);
	}
	rep(j,g[b].size()){
	  if(g[b][j] == a)g[b].erase(g[b].begin()+j);
	}
      }	
    }
    
    vector<string> ans;
    rep(i,n){
      if(prop[i])ans.push_back(name[i]);
    }
    sort(all(ans));
    for(string s : ans)cout << s << endl;
  }
}

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

int main(){
    string s;
    while(cin >> s){
    	string ans = "";
    	for(int i = 0; i < s.size(); i++){
    		if(s[i] != '@')ans += s[i];
    		else{
    			for(int j = 0; j < s[i + 1] - '0'; j++){
    				ans += s[i + 2];
    			}
    			i += 2;
    		}
    	}
    	cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <ctype.h>
#include <string>

using namespace std;

int main() {
    string S;
    cin >> S;

    int prev = -1;

    for (int i = 0; i < S.length(); i++) {
        int num = S[i] - '0';
        if (prev == num) {
            cout << "Bad" << endl;
            return 0;
        }
        prev = num;
    }

    cout << "Good" << endl;

    return 0;
}


Measured memory_bytes: 256
'use strict'

function main(s) {

  s = s.split('\n')[0].split(' ').map(x => Number(x));
  const n = s[0];
  const y = s[1];
  const result = [];

  for (var i = 0; i <= n; i++) {
    for (var j = 0; j <= (n - i); j++) {
      const k = (n - i - j);
      if (10000 * i + 5000 * j + 1000 * k === y && i + j + k === n) {
        result.push([i, j, k]);
      }
    }
  }

  const ans = (result.length >= 1) ? result[0].join(' ') : '-1 -1 -1';
  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
/* When Talent doesn't work, Hard work beats Talent*/

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include"bits/stdc++.h"

using namespace std;

#define Fast_D cout<<fixed<<setprecision(13);
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define scanstr(s) cin>>ws; getline(cin,s);

const double PI = 3.141592653589793;

void solve()
{
	int n;
	cin >> n;
	int x = (n+10)/11;
	int tot = 2*x;
	int cur = x *11 +1 ;
	if(cur-n >=11) tot--;
	else if (cur-n >=6) tot--;
	cout << tot ;
}

int32_t main()
{
	FastIO;
	Fast_D;
	solve();
	return 0;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll N;
ll A[100005];
string solve()
{
    sort(A, A + N);

    ll num = 1;
    FOR(i, N, 1)
    {
        if (A[i] != A[i - 1])
            num++;
    }
    if (num > 2)
        return "No";

    if (num == 1)
    {
        if (N == A[0] + 1 || 2 * A[0] <= N)
            return "Yes";
        return "No";
    }

    if (A[0] + 1 != A[N - 1])
        return "No";

    ll n = 0;
    REP(i, N)
    {
        if (A[0] == A[i])
            n++;
    }
    if (A[0] >= n && 2 * (A[N - 1] - n) <= (N - n))
        return "Yes";
    return "No";
}

int main()
{
    cin >> N;
    REP(i, N)
    {
        cin >> A[i];
    }

    cout << solve() << endl;

    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[])
{
    int N, D, X;
    cin >> N >> D >> X;
    vector<int> a;
    int tmp;
    int sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        sum += (D - 1) / tmp + 1;
    }

    cout << sum + X << endl;
    
    return 0;
}

Measured memory_bytes: 256