akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<cassert>
#include<iostream>
#include<algorithm>

using namespace std;

#define Whats(x) cout<<#x<<" is "<<(x)<<endl
#define Divhim() cout<<">>>>>>>>>>>>>>>"<<endl
#define Divher() cout<<"<<<<<<<<<<<<<<<"<<endl
#define Oops() cout<<"!!!!!!!!!!!!!!!"<<endl

template<typename T> bool GetMin(T &a,T b)
{
	return ((a<=b)?false:(a=b,true));
}

template<typename T> bool GetMax(T &a,T b)
{
	return ((a>=b)?false:(a=b,true));
}

/*
	 -<Unlimited Blade Works>-
 */

#define LL long long

const int N=3333;
const int MOD=1e9+7;

int U(int x,int y)
{
	return ((x+=y)>=MOD)?(x-MOD):x;
}

int Qpow(int x,int y=MOD-2)
{
	int res=1;
	for(;y;y>>=1,x=(LL)x*x%MOD)if(y&1)
		res=(LL)res*x%MOD;
	return res;
}

int n,q,dp[N][N],a[N],ny2;

void Doit(int x,int y)
{
	//int a=U(dp[x][y],dp[y][x]);
	//dp[x][y]=(LL)ny2*a; dp[y][x]=(LL)ny2*a;
}

int main()
{
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;++i)
		scanf("%d",a+i);
	for(int i=1;i<=n;++i)for(int j=1;j<=n;++j)if(i!=j)
		dp[i][j]=(a[i]>a[j]);
	ny2=Qpow(2);
	for(int i=1,x,y;i<=q;++i)
	{
		scanf("%d%d",&x,&y);
		for(int i=1;i<=n;++i)if(i!=x&&i!=y)
		{
			dp[x][i]=dp[y][i]=(LL)ny2*U(dp[x][i],dp[y][i])%MOD;
			dp[i][x]=dp[i][y]=(LL)ny2*U(dp[i][x],dp[i][y])%MOD;
		}
		dp[x][y]=dp[y][x]=(LL)ny2*U(dp[x][y],dp[y][x])%MOD;
	}
	int ans=0;
	for(int i=1;i<=n;++i)for(int j=1;j<=n;++j)if(i<j)
		ans=U(ans,dp[i][j]);
	ans=(LL)ans*Qpow(2,q)%MOD;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 41216
'use strict';

function Main(INPUT) {
    const S = INPUT.split("");
    let n = 0;
    for (let i = 0; i < S.length; i++) {
        n += S[i] == "+" ? 1 : 0;
        n -= S[i] == "-" ? 1 : 0;
    }
    console.log(n);
}

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


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	string s, t;
	cin >> s;
	cin >> t;
	int n = s.l_ength();
	bool yn = 0;
	for( int i=0; i < n; ++i ){
		for( int j=0; j < n; ++j ){
			if( s.at(j) != t.at((i+j)%n) ){
				break;
			}
			if( j == n-1 ){
				yn = 1;
			}
		}
	}
	cout << (( yn ) ? "Yes" : "No") << endl;
	return 0;
}

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

using namespace std;

const double EPS = 1e-8;

int dcmp(double d) {
    if (fabs(d) < EPS) {
        return 0;
    }
    else {
        return d < 0? -1 : 1;
    }
}

struct Vector {
    double x, y;
    Vector(double x = 0, double  y = 0):x(x), y(y) {
    }
};

typedef Vector Point;

Vector operator-(const Vector& a, const Vector& b) {
    return Vector(a.x - b.x, a.y - b.y);
}

double cross(const Vector& a, const Vector& b) {
    return a.x * b.y - a.y * b.x;
}

double dot(const Vector& a, const Vector& b) {
    return a.x * b.x + a.y * b.y;
}

double ccw(const Point& a, const Point& b, const Point& c) {
    return cross(b - a, c - a);
}

//TZ
void polygonContain(int n, vector<Point>& g, Vector& p){
    int count = 0; //0: on segment
    bool onseg = false;
    for (int i = 0; i < n; i++) {
        Vector u = g[i] - p;
        Vector v = g[(i + 1) % n] - p;
        //on segment
        if (dcmp(cross(u, v)) == 0 && dcmp(dot(u, v)) <= 0) {
            onseg = true;
            break;
        }
        if (u.y > v.y) {
            swap(u, v);
        }
        if (dcmp(v.y) >= 0 && dcmp(u.y) < 0 && dcmp(cross(u, v)) > 0) {
            count++;
        }
    }
    //0: on seg, 1: outside, 2: contain
    if (onseg) {
        cout << 1 << endl;
    }
    else if (count % 2 == 0) {
        cout << 0 << endl;
    }
    else {
        cout << 2 << endl;
    }
}

//Winding number: Aoaoc training
void polygonContain1(int n, vector<Point>& g, Vector& p){
    int wn = 0; //0: on segment
    bool onseg = false;
    for (int i = 0; i < n; i++) {
        Vector u = g[i] - p;
        Vector v = g[(i + 1) % n] - p;
        //on segment
        if (dcmp(cross(u, v)) == 0 && dcmp(dot(u, v)) <= 0) {
            onseg = true;
            break;
        }
        
        if (dcmp(v.y) >= 0 && dcmp(u.y) < 0 && dcmp(cross(u, v)) > 0) {
            wn++;
        }
        else if (dcmp(u.y) >= 0 && dcmp(v.y) < 0 && dcmp(cross(u, v) < 0)) {
            wn--;
        }
    }
    //0: on seg, 1: outside, 2: contain
    if (onseg) {
        cout << 1 << endl;
    }
    else if (wn == 0) {
        cout << 0 << endl;
    }
    else {
        cout << 2 << endl;
    }
}

int main() {
    int n; 
    cin >> n;
    vector<Point> g(n);
    for (int i = 0; i < n; i++) {
        cin >> g[i].x >> g[i].y;
    }
    
    int q;
    cin >> q;
    
    for (int i = 0; i < q; i++) {
        Vector p;
        cin >> p.x >> p.y;
        polygonContain1(n, g, p);
    }
   
    return 0;
}

Measured memory_bytes: 3220
#include<bits/stdc++.h>
#include<iostream>
#include<string.h>
using namespace std;
int main(){
    int k,i,l;
    string s;
    cin>>k;
    cin>>s;
    l=s.length();
    if(l<=k){
        for(i=0;i<l;i++)
        cout<<s[i];
    }
    else{
         for(i=0;i<k;i++)
        cout<<s[i];
        cout<<"...";
    }
}


Measured memory_bytes: 3620
import java.util.*;

public class Main {
  public static void main(String[] srgs) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    long[] time = new long[n];
    long ans = 1;
    long temp = 1;
    for(int i = 0; i < n; i++) time[i] = Long.parseLong(sc.next());
    for(int i = 0; i < n; i++) {
      ans = (ans > time[i])? ans / gcd(ans, time[i]) * time[i]: time[i] / gcd(time[i], ans) * ans;
    }
    System.out.println(ans);
  }

  public static long gcd(long a, long b) {
    if(b == 0) return a;
    return gcd(b, a % b);
  }
}


Measured memory_bytes: 21844
n = gets.chomp.to_i
alist = gets.chomp.split(" ").map { |i| i.to_i }
alist.each do |a|
  if a % 2 == 0 and not(a % 3 == 0 or a % 5 == 0)
    puts "DENIED"
    exit
  end
end
puts "APPROVED"

Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>
#include <limits>

using namespace std;

struct Rectangle {
  int H;
  int W;
};

int main()
{
  vector<Rectangle> data_set;

  while (true) {
    int H, W;
    cin >> H >> W;

    if (H == 0 && W == 0) {
      break;
    }

    data_set.push_back({H, W});
  }

  for (auto &&i : data_set) {
    for (int h = 0; h < i.H; h++) {
      for (int w = 0; w < i.W; w++) {
        if (1 <= h && h < i.H - 1 && 1 <= w && w < i.W - 1) {
          cout << ".";
        }
        else {
          cout << "#";
        }
      }
      cout << endl;
    }
    cout << endl;
  }

  return 0;
}



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

int main(){
    ll N;
    vector<ll> a, b;

    cin >> N;
    a.resize(N); for(ll i = 0; i < N; i++) cin >> a[i];
    b.resize(N); for(ll i = 0; i < N; i++) cin >> b[i];

    ll ans = 0;

    for(ll k = 0; k < 30; k++){
        ll T = 1 << k;
        vector<ll> amods(a.size()), bmods(b.size());
        transform(a.begin(), a.end(), amods.begin(), [&](ll it){
            return it % (2 * T);
        });
        transform(b.begin(), b.end(), bmods.begin(), [&](ll it){
            return it % (2 * T);
        });
        sort(bmods.begin(), bmods.end());

        ll count = 0;
        for(const auto amod : amods){
            ll countT_2T  = distance(bmods.begin(), lower_bound(bmods.begin(), bmods.end(), 2 * T - amod)) -
                            distance(bmods.begin(), lower_bound(bmods.begin(), bmods.end(),     T - amod));
            ll count3T_4T = distance(bmods.begin(), lower_bound(bmods.begin(), bmods.end(), 4 * T - amod)) -
                            distance(bmods.begin(), lower_bound(bmods.begin(), bmods.end(), 3 * T - amod));

            count += countT_2T + count3T_4T;
        }

        ans += (count % 2) << k;
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
    int a,b, res;
    string op;
    cin >> a >> op >> b;
    if (op == "+") {
        res = a + b;
    } else if (op == "-") {
        res = a - b;
    }

    cout << res;
    return 0;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);

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

  vector<int> b(n, 0);

  for (int i = n-1; i >= 0; i--) {
    // sum := iを除くiの倍数のボールの数の和
    int sum = 0;
    for (int j = i; j < n; j += (i+1)) {
      sum += b[j];
    }
    b[i] = ( (sum&1) == a[i] ? 0 : 1 );
  }

  int m = count(b.begin(), b.end(), 1);
  cout << m << endl;

  if (m == 0) { return 0; }

  for (int i = 0; i < n; i++) {
    if (b[i]) {
      cout << i+1;
      m--;
    }
    cout << (m == 0 ? "\n" : " ");
    if (m == 0) { break; }
  }

  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ std::cin >> head; _cin(std::forward<Tail>(tail)...); }
void _cout(){ std::cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ std::cout << head; _cout(std::forward<Tail>(tail)...); }
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__);
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

using namespace std;
using ll = long long;

int main(void){
    Cin(int, n, m);
    Cinm(int, 2*m, ans);
    For(i, n) Cout(ans[i+1]);
}

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

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

using namespace std;

string f(char c, int n)
{
  string ret;
  n-='0';
  rep(i, n)
    ret += c;
  return ret;
}
int main()
{
  char a, b;
  cin >> a >> b;
  string ans;
  if(a < b || a == b)
    ans = f(a, b);
  if(a > b)
    ans = f(b, a);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F(i,n) for (int i=1; i<=(int)n; i++)
#define FF(i,n) for (int i=0; i<(int)n; i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pi pair < int , int >
#define re(x) (int)x.size()
#define y1 u228
using namespace std;
typedef long long ll;
const int N = 3020;
const int big = 2e9;
const int md = 1e9 + 7;
int n;
ll f[N][N][2],a[N];
bool mrk[N][N][2];
ll go(int l,int r,int x){
    if (l>r) return 0;
    if (mrk[l][r][x]) return f[l][r][x];
    ll tex=0ll; mrk[l][r][x]=1;
    if (x==0) tex=max(a[l]+go(l+1,r,x^1),a[r]+go(l,r-1,x^1));
        else tex=min(-a[l]+go(l+1,r,x^1),-a[r]+go(l,r-1,x^1));
    f[l][r][x]=tex;
    return tex;
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    //freopen("input.txt","r",stdin);
    cin>>n;
    F(i,n) cin>>a[i];
    cout<<go(1,n,0)<<endl;
    return 0;
}







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

int main(){
	string A,B;
	cin >> A >> B;
	if(A == B){
	cout << "EQUAL" << endl;
	return 0;
	}
	if(A.size()>B.size()){
		cout << "GREATER" << endl;
		return 0;
		}
	if(B.size()>A.size()){
		 cout << "LESS" << endl;
		return 0;
		}

	else if(A.size() == B.size()){
		int ketaA = A.at(0) - '0';
		int ketaB = B.at(0) - '0';
 		if(ketaA > ketaB)cout << "GREATER" << endl;
		else if(ketaB > ketaA)cout << "LESS" << endl;
		}
	return 0;
}


Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#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>
#include <regex>

//#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;

#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
using namespace std;
using Bint = mp::cpp_int;
//using Real = mp::number<mp::cpp_dec_float<1024>>;

int main() {
  int n;
  cin >> n;
  vector<Bint> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());
  Bint res = 1;
  rep(i,n) {
    res *= a[i];
    if(res > 1000000000000000000) {cout << -1 << endl; return 0;}
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 6500
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        long n = Long.parseLong(sc.next());
        int sqrt = (int) Math.sqrt(n);

        for (int i = sqrt; i >= 1 ; i--) {
            if (n % i == 0) {
                System.out.println(i + n / i - 2);
                break;
            }
        }
    }
}


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

#define loop(s, e, i) for (int i = s; i < e; ++i)
#define print(s) cout << s << endl;
#define DIV 1000000007
#define ll = long long
using namespace std;

/*
浮動小数点の入力
cout << fixed << setprecision(9) << endl;
*/

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;

  int both = min(X, Y);
  int both_cost = min(A+B, 2*C);

  int left_X = X - both;
  int left_Y = Y - both;

  int x_cost = min(A, 2*C);
  int y_cost = min(B, 2*C);

  int total_cost = both * both_cost + left_X * x_cost + left_Y * y_cost;
  print(total_cost);
}


Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int line[4];
	for (int i = 0; i < 4; ++i) {
		cin >> line[i];
	}
	for (int i = 1; i < 4; ++i) {
		swap(line[0], line[i]);
		if (line[0] == line[1] && line[2] == line[3]) {
			cout << "yes" << endl;
			return 0;
		}
	}
	cout << "no" << endl;
	return 0;
}

Measured memory_bytes: 3088
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;


void main() {
    writeln(readln.chomp.to!int < 1200 ? "ABC" : "ARC");
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define M 100007
using namespace std;
char s[M];
int num[M],L[M],R[M];
int main() {
	scanf("%s",s+1);
	int l=strlen(s+1);
//	int p=l;
	for(int i=1; i<=l; i++) {
		if(s[i]=='R')R[i]=i;
		else R[i]=R[i-1];
	}
	for(int i=l; i>=1; i--) {
		if(s[i]=='L')L[i]=i;
		else L[i]=L[i+1];
	}
	for(int i=1; i<=l; i++) {
		if(s[i]=='R') {
			int p=L[i]-i;
			if(p&1)num[L[i]-1]++;
			else num[L[i]]++;
		} else {
			int p=i-R[i];
			if(p&1)num[R[i]+1]++;
			else num[R[i]]++;
		}
	}
//	while(p) {
//		int l1=0,l2=0;
//		while(s[p]=='L')p--,l1++;
//		while(s[p]=='R')p--,l2++;
//		int w=l1+l2;
//		if(w%2==0)num[p+l2]=num[p+l2+1]=w/2;
//		else {
//			int mo=max(l1,l2);
//			if(mo==1)num[p+l2]=l2,num[p+l2+1]=l1;
//			else num[p+l2]=l1,num[p+l2+1]=l2;
//		}
//	}
	for(int i=1; i<=l; i++)
		cout<<num[i]<<" ";
	puts("");
	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

int main(){
	string S;
	cin >> S;
	bool ans = true;

	for (int i = 1; i <= S.length(); i++){
		if (i % 2 == 1){
			if (S[i - 1] == 'L'){
				ans = false;
				break;
			}
		}
		if (i % 2 == 0){
			if (S[i - 1] == 'R'){
				ans = false;
				break;
			}
		}
	}
	if (ans){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
open System

let isPalindromic (str:string) =
    let rStr = 
        str.ToCharArray()
        |> Array.rev
        |> String    
    str = rStr
               
let A,B = 
    let t = Console.ReadLine().Split()
            |> Array.map(int)
    t.[0],t.[1]

[A..B]
|> List.map (fun x -> x.ToString())
|> List.where(fun x -> isPalindromic x)
|> List.length
|> printfn "%i"


Measured memory_bytes: 28492
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        if(n%2 == 1) {
            System.out.println(0);    
        }else {
            long ans = n/10;
            for(int i = 1; i<=36; i++) {
                long power = (long)Math.pow(5,i);
                if(power> (long)Math.pow(10,18)) break;
                ans += n/(10L*power);
            }
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>

using namespace std;

class UnionFind{
private:
    vector<int> Parent;
public:
    UnionFind(int N){
        vector<int> Parent(N,-1);
    }

    int root(int A){
        if(Parent[A]<0) return A;
        return Parent[A]=root(Parent[A]);
    }

    int size(int A){
        return -Parent[root(A)];
    }

    bool connect(int A,int B){
        A=root(A);
        B=root(B);
        if(A==B) return false;
        if(size(A)<size(B)) swap(A,B);
        Parent[A]-=Parent[B];
        Parent[B]=A;
    }
};

int main(){
    int A,B;
    cin >> A >> B;
    if(A<=5) cout << "0" << endl;
    else if(A<=12) cout << B/2 << endl;
    else cout << B<< endl;
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    ll N,K;
    cin >> N >> K;
    ll ans = 0;
    while( N >= pow(K,ans) ) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 384
r,c=map(int,input().split())
table=list()
for i in range(r):
    table.append(list(map(int,input().split())))
for i in range(r):
    for j in range(c):
        print(table[i][j],"",end="")
    print(sum(table[i]),sep="")
bottom=list()
for i in range(c):
    tmp=0
    for j in range(r):
        tmp+=table[j][i]
    bottom.append(tmp)
for i in bottom:
    print(i,"",end="")
print(sum(bottom))

Measured memory_bytes: 6740
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstdio>

using namespace std;

double distance(int N, const vector<double> &x, const vector<double> &y, const vector<int> &idx)
{
	double ans = 0;
	for (int i = 0; i + 1 < N; ++i) {
		double dx = x[idx[i]] - x[idx[i + 1]];
		double dy = y[idx[i]] - y[idx[i + 1]];
		ans += sqrt(dx * dx + dy * dy);
	}
	return ans;
}

int main()
{
	int N;
	cin >> N;
	vector<double> x(N), y(N);
	
	for (int i = 0; i < N; ++i) {
		cin >> x[i] >> y[i];
	}

	vector<int> idx(N);
	iota(idx.begin(), idx.end(), 0);

	double ans = 0;
	int M = 0;

	do {
		ans += distance(N, x, y, idx);
		++M;
	} while (next_permutation(idx.begin(), idx.end()));

	ans /= M;
	printf("%.10f\n", ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  while(cin>>n,n){
    vs s(n);
    rep(i,n)cin>>s[i];

    rep(i,n)
      for(j = s[i].size()-1; j > 0; j--)
        if(s[i][j] != '.' && s[i][j-1] == '.'){
          s[i][j-1] = '+';
          break;
        }

    rep(i,n)rep(j,s[i].size())
      if(s[i][j] == '+'){
        int k = i+1;
        bool c = false;
        while(k < n && j < s[k].size()){
          if(s[k][j] == '+'){
            c = true;
            break;
          }
          if(s[k][j] != '.')break;
          k++;
        }
        if(c){
          for(k--; k > i; k--)s[k][j] = '|';
        }
      }

      rep(i,n)rep(j,s[i].size())
        if(s[i][j] == '.') s[i][j] = ' ';

      rep(i,n)cout << s[i] << endl;

  }
}



Measured memory_bytes: 3668
if __name__ == '__main__':
  s = input()
  s1 = s[0:2]
  s2 = s[2:]
  if int(s1) == 0 or int(s1) > 12:
    if int(s2) == 0 or int(s2) > 12:
      print("NA")
    else:
      print("YYMM")
  else:
    if int(s2) == 0 or int(s2) > 12:
      print("MMYY")
    else:
      print("AMBIGUOUS")

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 1145141919
#define ll long long
//#define scanf scanf_s


int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a < b&&b < c) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1156
N = int(input())
li = []
cities = []
for i in range(N) :
    inp = input().split()
    l = [inp[0], int(inp[1]), int(i+1)]
    li.append(l)
    if (l[0] not in cities) :
        cities.append(l[0])

li.sort(key=lambda x : x[0])
cities.sort()

ans = []
for c in cities :
    # hoge = list(filter(lambda x : x[0] == c, li)).sort(key=lambda x : x[1], reverse=True)
    ans += sorted(list(filter(lambda x : x[0] == c, li)),key=lambda x: x[1], reverse=True)
    # ans.extend()

for a in ans :
    print(a[2])



Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};

const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};


ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

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

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

/*
//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}
*/


int main(){
  ll A, B;
  cin >> A >> B;
  ll need = 0;
  ll now = 1;
  while(now < B){
    need++;
    now += A - 1;
  }
  cout << need << endl;

}


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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(int i=0; i<(n); i++)
#define REPj(n) for(int j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/* 
	add utility Algorithm
*/



int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin >> N;

    REPinit(i, 0, 26) {
        REPinit(j, 0, 26) {
            if ((i * 4 + j * 7) == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define UNIQUE(v) do{ (v).erase( unique(begin(v), end(v)), end(v) ); } while(0)

namespace std {
	template<class S, class T> pair<S, T> operator + (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first + b.first, a.second + b.second);}
	template<class S, class T> pair<S, T> operator - (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first - b.first, a.second - b.second);}
	template<class S, class T> pair<S, T>& operator += (pair<S, T> &a, const pair<S, T> &other) {return a = a + other;}
	template<class S, class T> pair<S, T>& operator -= (pair<S, T> &a, const pair<S, T> &other) {return a = a - other;}
	template<class S, class T> ostream& operator << (ostream& ost, pair<S, T> p) {ost << "(" << p.first << ", " << p.second << ")";return ost;}
	template<class T> ostream& print_iterable_container(ostream& ost, T& container) {
		for (auto&& iter = begin(container); iter != end(container); ++iter) ost << (iter == begin(container) ? " [ " : ", ") << (*iter);
		return ost << " ]";
	}
#	define APPLY_PRINT_ITERABLE_CONTAINER(container_type)\
	template<class T> ostream& operator << (ostream& ost, container_type<T>& container) {\
		return print_iterable_container(ost, container);\
	}
	APPLY_PRINT_ITERABLE_CONTAINER(vector);
	APPLY_PRINT_ITERABLE_CONTAINER(list);
	APPLY_PRINT_ITERABLE_CONTAINER(deque);
}

template<class T> inline bool CHMAX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool CHMIN(T &l,const T &r){return l>r?l=r,1:0;}

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

using ld = long double;

template<class T> using VV = vector<vector<T> >;
template<class T> using maxPQ = priority_queue<T>;
template<class T> using minPQ = priority_queue<T, vector<T>, greater<T> >;
template<class T, class U> using uomap = unordered_map<T, U>;
template<class T> using uoset = unordered_set<T>;

const ll INF = 1001001001;
const ll INFll = (ll)INF * INF;
const ll MOD = 1000000007;
const ll MOD_FFT = 998244353;
const ld EPS = 1e-15;

//function<void(int,int)> tensi_no_3p=[&](int v,int d){
//};

int main() {
	ios_base::sync_with_stdio(false);
	ll N; cin >> N;
	ll ans = 0;
	repr(k, 1, 1000010) {
		if (N % k != 0) continue;
		ll m = N / k - 1;
		if (k < m) ans += m;
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    if(a > b) cout << "a > b" << endl;
    else if (a < b) cout << "a < b" << endl;
    else cout << "a == b" << endl;
    return 0;
}


Measured memory_bytes: 3096
#include <stdio.h>

int main(){
  int n,u,k,i,j,v[1000],x[1000][1000];

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    scanf("%d%d",&u,&k);
    for(j = 0; j < k; j++){
      scanf("%d",&v[i]);
      x[u-1][v[i]-1] = 1;
	 }
  }

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      if(j == 0){
	if(x[i][j] == 1) printf("1");
	else printf("0");
      }
      else{
	if(x[i][j] == 1) printf(" 1");
	else printf(" 0");
      }
    }
    printf("\n");
  }

  return 0;
}
	

Measured memory_bytes: 976
s = input()
q = int(input())
a = 0
c = ""
d = ""
for i in range(q):
    b = list(input().split())
    if b[0] == "1":
        if a == 0:
            a = 1
        else:
            a = 0
    else:
        if (a, b[1]) == (0, "1") or (a, b[1]) == (1, "2"):
            c = b[2]+c
        else:
            d += b[2]
s = c+s+d
if a == 0:
    print(s)
else:
    print(s[::-1])

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

using namespace std;

typedef long long ll;

ll pow(ll x, int n) {
    ll ret = 1;
    while (n > 0) {
        if (n & 1) ret *= x;
        x *= x;
        n >>= 1;
    }

    return ret;
}

int main() {
    int n, p, cnt;
    cin >> n >> p;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        if (x % 2) ++cnt;
    }

    if (cnt > 0) {
        cout << pow(2, n - 1) << endl;
    } else if (p == 0) {
        cout << pow(2, n) << endl;
    } else {
        cout << 0 << endl;
    }
}

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

int main() {
	int m, f, r;
	for (;;) {
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1) break;
		if (m == -1 || f == -1) {
			cout << "F" << endl;
			continue;
		}
		if (m + f >= 80) cout << "A" << endl;
		else if (m + f >= 65) cout << "B" << endl;
		else if (m + f >= 50) cout << "C" << endl;
		else if (m + f >= 30) {
			if (r >= 50) cout << "C" << endl;
			else cout << "D" << endl;
		}
		else cout << "F" << endl;
	}
}


Measured memory_bytes: 3072
// #pragma GCC optimize("no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma vector temporal
// #pragma simd
// #pragma GCC diagnostic ignored "-W"

#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<sstream>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<vector>
#include<utility>
#include<functional>
#include<complex>
#include<climits>

// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define ll long long
#define ld long double
#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vint vector<int>
#define SS stringstream
#define PQ priority_queue
#define MS(x,v) memset((x),(v),sizeof(x))
#define RZUNI(x) sort(x.begin(),x.end()), x.resize(unique(x.begin(),x.end())-x.begin())
#define FLH fflush(stdout)
#define CPPinput ios_base::sync_with_stdio(0); cin.tie(0)
#define FIN(fname) freopen(fname,"r",stdin)
#define FOUT(fname) freopen(fname,"w",stdout)

#define tm Ovuvuevuevue
#define y1 Enyetuenwuevue
#define left Ugbemugbem
#define ws Osas
#define dec tetteterette
#define exp expexpexpexp
#define expl explexplexpl

#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl

#ifdef WEAK
#include"/home/edison/Coding/cpp/template/debug.cpp"
#define DEB(...) printf(__VA_ARGS__),fflush(stdout)
#define WHR() printf("%s: Line %d",__PRETTY_FUNCTION__,__LINE__),fflush(stdout)
#define LOG(...) printf("%s: Line %d ",__PRETTY_FUNCTION__,__LINE__),printf(__VA_ARGS__),fflush(stdout)
#define DEBUG 1
#define exit(x) cout<<"exit code "<<x<<endl, exit(0)
#else
#define PDE(...) ;
#define DEB(...) ;
#define WHR() ;
#define LOG(...) ;
#define DEBUG 0
#endif

#define lowbit(x) ((x)&(-(x)))

#if __cplusplus >= 201103L
#include<unordered_map>
#include<unordered_set>
#include<tuple>
#endif

void JIZZ(string output=""){cout<<output; exit(0);}

const ld PI=3.14159265358979323846264338327950288;
const ld eps=1e-13;
const ll mod=1e9+7;

pair<int,int> seg[100005];;

int main(){
    CPPinput;
    int n,m; cin>>n>>m;
    for(int i=0;i<m;++i)cin>>seg[i].first>>seg[i].second,--seg[i].second;
    sort(seg,seg+m,[](const pii &a,const pii &b){ return a.first==b.first?a.second>b.second:a.first<b.first; });
    int la=-1;
    int ans=0;
    for(int i=0;i<m;++i){
        PDE(la,ans,i,seg[i]);
        la=min(la,seg[i].second);
        if(seg[i].first>la)la=seg[i].second,++ans;
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 1024
N, M = map(int, input().split())
stair = [0]*(N+1)
for i in range(M):
    num = int(input())
    stair[num] = -1

stair[0] = 1
if stair[1] == -1:
    stair[1] = 0
else:
    stair[1] = 1

for j in range(2, N + 1):
    if stair[j] == -1:
        stair[j] = 0
    else:
        stair[j] = stair[j-1]+stair[j-2]

ans = stair[N] % 1000000007
print("{}".format(ans))


Measured memory_bytes: 460020
#include <cstdio>
#include<iostream>

using namespace std;

int n,s;
int use[11]={0};
int dp[11][(0*1+1*2+3*2+4*3+5*4+6*5+7*6+8*7+9*8+10*9)*2]={0};
inline void combination(register int d,register int sum){
	dp[d][sum]++;
	if(d==11) return;
	for(int i=0;i<10;i++){
		if(use[i]==0){
			use[i]=1;
			combination(d+1,sum+(i*d));
			use[i]=0;
		}
	}
	return;
}

int main(){
	std::ios_base::sync_with_stdio(false);
	combination(1,0);
	while(cin>>n>>s){
		if((0*1+1*2+3*2+4*3+5*4+6*5+7*6+8*7+9*8+10*9)*2>s) cout<<dp[n+1][s]<<endl;
		else cout<<"0"<<endl;
	}

	return 0;
}

Measured memory_bytes: 1224
S = input()
ans = 0
mods = [0] * 2019
mods[0] = 1
curr = 0
x = 1
for d in S:
    curr = curr * 10 + int(d)
    ans += mods[curr * x % 2019]
    mods[curr * x % 2019] += 1
    x = x * 202 % 2019
    curr %= 2019
print(ans)


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

#define N ((int)1e5 + 1)
#define forn(i,x,y) for(int i = int(x); i<int(y); i++)
#define debug(x) cerr << #x << " == " << (x) << '\n';
#define all(V) V.begin(), V.end()

template<typename T> ostream &operator<<(ostream &out, const pair<T, T> &P){ out << P.first << ' ' << P.second; return out; }
template<typename T> ostream &operator<<(ostream &out, const vector<T> &V){ for(int i = 0; i<V.size(); ++i) out << V[i] << ' '; return out; }
template<typename T> istream &operator>>(istream &in, vector<T> &V){ for(T &i : V) in >> i; return in; }
template<typename T> istream &operator>>(istream &in, pair<T,T> &P){ in >> P.first >> P.second; return in; }

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

    int n; cin >> n;
    vector<int> a(n); cin >> a;

    int seek = 1;
    for(int i : a) {
        if(i == seek) seek++;
    }

    cout << (seek == 1 ? -1 : n - seek + 1) << '\n';

    return 0;
}

/* don't forget to check:
   int overflow
   min/max cases (n = 1)
   printing index of sorted array
   limits for ans (start with inf)
 */


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1e9+5 // 1 billion, safer than 2B for Floyd Warshall’s
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pcont(x) for(auto i: x){cout << i << ", ";} cout << "\n";

int main(){
    IOS;
    int n, w;
    cin >> n >> w;
    vector<ll> val(n), wgt(n);
    for(int i = 0; i<n; i++){
        cin >> wgt[i];
        cin >> val[i];
    }
 
    vector<ll> dp(w+1, 0);

    for(ll item = 0ll; item<n; item++){
        // pcont(dp);
        for(ll weight_already = w-wgt[item]; weight_already>=0; weight_already--){
            dp[weight_already+wgt[item]] = max(dp[weight_already+wgt[item]], dp[weight_already] + val[item]);
        }
    }

    ll ans = 0;
    for(auto i:dp){
        ans = max(ans, i);
    }

    cout << ans << "\n";

    return 0;
}

/*
create dp with the weight as dimension
we need to maximum value for a particular weight
*/

Measured memory_bytes: 3972
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3512
#include <stdio.h>

int main(){
	
	int harga;
	scanf("%d", &harga);
	int money = 0;
	while(money < harga){
		money = money + 1000;
	}
	if(money == harga){
		printf("0");
	}
	else if (money >= harga){
		printf("%d", money - harga);
	}
	return 0;
}

Measured memory_bytes: 1736
N, K = map(int, input().split())
h = list(int(input()) for _ in range(N))
h.sort()

i = 0
ans = 10 ** 9
while i + K - 1 < N:
  n = abs(h[i+K-1] - h[i])
  if ans > n: ans = n
  i += 1
print(ans)

Measured memory_bytes: 7448
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

const int DEBUG = 0;

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef pair<int, int> PI;

const int N = 100100;
int n;
VI g[N];
int deg[N];
bool alive[N];

VI gdist(int v, const VI &vals) {
  VI ret(n, -1);
  queue<PI> que;
  que.push(PI(v, vals[v]));
  while (not que.empty()) {
    PI t = que.front(); que.pop();
    int w = t.first;
    int d = t.second;
    if (ret[w] >= 0) continue;
    ret[w] = d;
    REP(i, 0, g[w].size()) {
      int u = g[w][i];
      que.push(PI(u, d + vals[u]));
    }
  }
  return ret;
}

string c;

VI vert;

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  REP(i, 0, n - 1) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  cin >> c;
  {
    queue<int> que;
    REP(i, 0, n) {
      alive[i] = true;
      deg[i] = g[i].size();
      if (g[i].size() == 1) que.push(i);
    }
    while (not que.empty()) {
      int v = que.front(); que.pop();
      if (c[v] == 'B') {
	// delete
	int nxt = -1;
	REP(i, 0, g[v].size()) {
	  if (alive[g[v][i]]) {
	    nxt = g[v][i];
	    break;
	  }
	}
	alive[v] = false;
	deg[nxt]--;
	if (deg[nxt] == 1) que.push(nxt);
      }
    }
    // deletes all unnecessary edges
    REP(i, 0, n) {
      VI cp;
      REP(j, 0, g[i].size()) {
	int w = g[i][j];
	if (not alive[w]) continue;
	cp.push_back(w);
      }
      g[i] = cp;
    }
    REP(i, 0, n) if (alive[i]) vert.push_back(i);
  }
  if (DEBUG) {
    REP(i, 0, n) {
      if (alive[i]) {
	REP(j, 0, g[i].size()) {
	  int w = g[i][j];
	  cerr << " (" << i << "," << w << ")";
	}
	cerr << endl;
      }
    }
  }
  VI vals(n);
  for (int i: vert) {
    vals[i] = (c[i] == 'W') ^ (deg[i] % 2);
  }
  int idx = -1;
  for (int i: vert) {
    if (alive[i] && c[i] == 'W') idx = i;
  }
  if (idx < 0) {
    cout << 0 << endl;
    return 0;
  }
  if (vert.size() <= 1) {
    cout << vert.size() << endl;
    return 0;
  }
  assert (idx >= 0);
  PI ma1(-1, -1);
  VI d1 = gdist(idx, vals);
  REP(i, 0, n) {
    if (c[i] == 'W') {
      ma1 = max(ma1, PI(d1[i], i));
    }
  }
  PI ma2(-1, -1);
  VI d2 = gdist(ma1.second, vals);
  for (int i: vert) {
    if (c[i] == 'W') {
      ma2 = max(ma2, PI(d2[i], i));
    }
  }
  if (DEBUG) {
    cerr << "vals:";
    REP(i, 0, n) cerr << " " << vals[i];
    cerr << endl;
    cerr << "d2:";
    REP(i, 0, n) cerr << " " << d2[i];
    cerr << endl;
  }
  int diam = ma2.first;
  int base = 2 * (vert.size() - 1);
  for (int i: vert) {
    base += vals[i];
  }
  DEBUGP(base);
  DEBUGP(diam);
  cout << base - 2 * diam << endl;
}


Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(n);
  set<int> ans;
  for(int i=0;i<n;i++){
    ans.insert(i+1);
    cin >> a[i];
  }
  int temp,temp2;
  for (int i=0;i<m;i++){
    cin >> temp >> temp2;
    if(a[temp-1]<=a[temp2-1]){
      if(ans.find(temp)!=ans.end())
        ans.erase(temp);

    }
    if(a[temp-1]>=a[temp2-1]){
      if(ans.find(temp2)!=ans.end())
        ans.erase(temp2);
    }
  }
  cout << ans.size() << endl;
}

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

int main(){
    rep(i,5){
        int x;cin>>x;
        if(x!=i+1)cout<<i+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 3596
H,W=map(int,input().split())
N=int(input())
A=[int(x) for x in input().split()]

ans=[[0 for i in range(W)] for j in range(H)] 

cnt=0
for i in range(H):
  if i%2==0:
    for j in range(W):
      if A[cnt]!=0:
        ans[i][j]=(cnt+1)
        A[cnt]-=1
      if A[cnt]==0:
        cnt+=1
  else:
    for k in range(W-1,-1,-1):
      if A[cnt]!=0:
        ans[i][k]=(cnt+1)
        A[cnt]-=1
      if A[cnt]==0:
        cnt+=1
for i in range(H):
  for j in range(W):
    if j==(W-1):
      print(ans[i][j])
    else:
      print(ans[i][j],"",end="")


Measured memory_bytes: 4600
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define pb push_back
#define rng(a) a.begin(),a.end()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (i64)(x).size()
#define bit(n) (1LL<<(n))
#define fi first
#define se second
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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;}

bool check_p(string s){
  i64 n = sz(s);
  rep(i,n/2){
    if(s[i] != s[n-1-i]) return false;
  }
  return true;
}


void Main()
{
  string s;
  cin >> s;

  i64 n = sz(s);

  if(check_p(s) and check_p(s.substr(0,(n-1)/2)) and check_p(s.substr((n+1)/2,(n-1)/2)))
    cout << "Yes\n";
  else
    cout << "No\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vector<int> graph[n+1];
    int a, b;
    for(int i=0;i<m;++i) {
        cin >> a >> b;
        graph[b].emplace_back(a);
        graph[a].emplace_back(b);
    }

    vector<int> ans(n+1, -1);
    queue<int> que;
    que.push(1);
    ans[0] = 0;
    ans[1] = 0;
    while(!que.empty()) {
        int node = que.front(); que.pop();
        for(int nxt: graph[node]) {
            if(ans[nxt] != -1) continue;
            que.push(nxt);
            ans[nxt] = node;
        }
    }

    if(*min_element(ans.begin(), ans.end()) == -1) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
        for(int i=2;i<=n;++i) {
            cout << ans[i] << endl;
        }
    }
}

Measured memory_bytes: 10164