akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb(a) push_back(a)
#define pi pair<int,int>
#define f first
#define s second
#define endl "\n"
void solve()
{
  int x,y;
  cin>>x>>y;
  if(y&1)
  {
      cout<<"No\n";
      return;
  }
  int a=2*x-y/2;
  int b=y/2-x;
  if((a>=0)&&(b>=0))
  cout<<"Yes\n";
  else
  cout<<"No\n";
}
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
       solve();
    return 0;
} 

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pb push_back
const double PI = acos(-1.0);
using namespace std;

int main()
{
    faster

    int n,k;
    cin>>n>>k;

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

    int dp[n],mn;

    dp[0]=0;

    for(int i=1; i<n; i++)
    {
        for(int j=i-1; j>=0 && j>=i-k; j--)
        {
            if(j==i-1)
                mn=abs(a[i]-a[j])+dp[j];
            else
                mn=min(mn,abs(a[i]-a[j])+dp[j]);
        }

        dp[i]=mn;
    }

    /*for(int i=0; i<n; i++)
    {
        cout<<dp[i]<<endl;
    }*/

    cout<<dp[n-1]<<endl;




    return 0;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//String s = sc.next();
		//String t = sc.next();
		//String g = sc.next();
		long n = sc.nextLong();
		long m = sc.nextLong();
		long k = sc.nextLong();
		//long l = sc.nextLong();
		long count=0;
		long[] array=new long[3];
		array[0] = n;
		array[1] = m;
		array[2] = k;

		/*for(int i=0;i<=3;i++) {
			if(s.substring(i,i+1).equals("+")) {
				count++;
			}else {
				count--;
			}
		}*/
		Arrays.sort(array);
		/*if((n*m)%2==0) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}*/
		System.out.println(array[2]*10+array[1]+array[0]);
		//System.out.println(Math.abs(array[2]-array[1])+Math.abs(array[1]-array[0]));
	}
}




Measured memory_bytes: 21204
#include <iomanip>
#include <iostream>
using namespace std;
int main(void) {
  for(; true;) {
    int m, f, r;
    cin >> m >> f >> r;
    if(m == -1 && f == -1 && r == -1)
      break;
    if(m == -1 || f == -1)
      cout << "F" << endl;
    else if(m + f >= 80)
      cout << "A" << endl;
    else if(m + f >= 65)
      cout << "B" << endl;
    else if(m + f >= 50 || (m + r >= 30 && r >= 50))
      cout << "C" << endl;
    else if(m + f >= 30)
      cout << "D" << endl;
    else
      cout << "F" << endl;
  }

  return 0;
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long u[3333][3333];
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    s = '&' +s;
    u[1][1] = 1;
    for(int i = 2; i <= n; i++){
        for(int j = 1; j <= i; j++){
            if(s[i - 1] == '<')
                u[i][j] = (u[i][j - 1] + u[i - 1][j - 1]) % mod;
            else
                u[i][j] = (u[i][j - 1] + u[i - 1][i - 1] - u[i - 1][j -1] + mod) % mod;
        }
    }
    cout << u[n][n] << endl;
}


Measured memory_bytes: 78592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (ll (i) = (s); (i) < (e); ++(i))
#define per(i, s, e) for (ll (i) = (s); (i) >= (e); --(i))
#define all(x) x.begin(),x.end()
 
int main(void) {
    int n; cin >> n;
    vector<int> x(n), y(n), index(n);
    rep(i, 0, n) {
        cin >> x[i] >> y[i];
        index[i] = i;
    }
    double ans = 0; int cnt = 0;
    do{
        cnt++;
        rep(i, 0, n-1) {
            int xd = (x[index[i]]-x[index[i+1]]);
            int yd = (y[index[i]]-y[index[i+1]]);
            ans += sqrt(xd*xd+yd*yd);
        }
    } while(next_permutation(all(index)));
    printf("%.10lf\n", ans/cnt);
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;

int main() {
  string s;
  cin >> s;
  int ans = 0;
  int l   = 0;
  int r   = s.length() - 1;
  while (l < r) {
	  if (s[l] != s[r]) {
		  ans++;
		}
	  l++;
	  r--;
	}
  cout << ans << endl;
  return 0;
}


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

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

    if ((e - a) > k) {
        cout << ":(" << endl;
    } else {
        cout << "Yay!" << endl;
    }
    
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    
    vector<char> c;
    for(int i=0;i<s.at(0).size();i++){
        c.push_back(s.at(0).at(i));
    }
    
    for(int i=0;i<n;i++){
        if(c.size()==0){
            break;
        }
        string t=s.at(i);
        for(int j=0;j<c.size();j++){
            bool judge=true;
            for(int k=0;k<t.size();k++){
                if(c.at(j)==t.at(k)){
                    judge=false;
                    t.erase(t.begin()+k);
                    break;
                }
            }
            if(judge){
                c.erase(c.begin()+j);
                j--;
            }
        }
    }
    
    if(c.size()!=0){
        sort(c.begin(),c.end());
        for(int i=0;i<c.size();i++){
            cout << c.at(i);
        }
        cout << endl;
        return 0;
    }
    cout << endl;
    return 0;
}




Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import heapq

N,M,S = list(map(int, input().rstrip().split()))
UVAB_list = [list(map(int, input().rstrip().split())) for i in range(M)]
CD_list = [list(map(int, input().rstrip().split())) for i in range(N)]
#-----

max_money = 2500
S = min(max_money, S)

# graph[current city][i] = [ (next city, coin, time) ]
graph = [None] + [ [] for _ in range(N) ]

# change[current city][i] = [ (coin, time) ]
change = [None] + [ () for _ in range(N) ]

# dp[city][money] = total time
dp = [None] + [ [float("inf")]*(max_money + 1) for _ in range(N) ]
dp[1][S] = 0


for u,v,a,b in UVAB_list:
    graph[u].append( (v,a,b) )
    graph[v].append( (u,a,b) )

for i,(c,d) in enumerate(CD_list):
    change[i+1] = (c,d)

# heap[i] = (current time, current city, current money)
heap = [ (0, 1, S) ]


while heap:
    cur_time, cur_city, cur_mone = heapq.heappop(heap)
    
    # change money at current city ---
    changed_money = cur_mone + change[cur_city][0]
    changed_time = cur_time + change[cur_city][1]
    
    if (changed_money <= max_money) and (changed_time < dp[cur_city][changed_money] ):
        dp[cur_city][changed_money] = changed_time
        heapq.heappush(heap, ( changed_time, cur_city, changed_money) )
    
    # move to next city ---
    for next_city, cost_coin, cost_time in graph[cur_city]:
        next_time = cur_time + cost_time
        next_money = min( max_money , cur_mone - cost_coin )
        
        if (cur_mone >= cost_coin) and ( next_time < dp[next_city][next_money] ):
            dp[next_city][next_money] = next_time
            heapq.heappush(heap, ( next_time, next_city, next_money) )


for row in dp[2:]:
    print( min(row) )


Measured memory_bytes: 24048
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  ld n,k;
  cin>>n>>k;
  ld a=0.5;
  ld ans=0;
  Rep(i,1,n+1){
    ll now=i;
    ld na=1.0;
    while(now<k){
      na*=a;
      now*=2;
    }
    ans+=na;
  }
  ans/=n;
  cout<<fixed<<setprecision(10);
  cout<<ans<<endl;
}



Measured memory_bytes: 256
/*input

*/


// assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll          long long int
#define pb          push_back
#define pii         pair<ll ,ll >
#define vpii        vector< pii >
#define vi          vector<ll >
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define debug(x)     cout << #x << " " << x << endl;
#define debug_p(x)   cout << #x << " " << x.F << " " << x.S << endl;
#define debug_v(x)   {cout << #x << " "; for (auto ioi : x) cout << ioi << " "; cout << endl;}
#define debug_vp(x)  {cout << #x << " "; for (auto ioi : x) cout << '[' << ioi.F << " " << ioi.S << ']'; cout << endl;}
#define debug_v_v(x) {cout << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cout << ioi2 << " "; cout << '\n';} cout << "*/" << #x << endl;}

int solve()
{
	ll n;cin>>n;
	
	vi a(n);
	rep(i,0,n) cin>>a[i];

	vi b(n);
	rep(i,0,n) cin>>b[i];

	reverse(b.begin(), b.end());
	ll L = n+1,R = -1;
	rep(i,0,n)
	{
		if(a[i]==b[i])
		{
			L = min(L,i);
			R = max(R,i);
		} 
	}

	rep(j,0,n)
	{
		if(L<=R && a[j]!=a[L] && b[j]!=a[L])
		{
			swap(b[j],b[L++]);
		}
	}

	if(L<=R)
	{
		cout<<"No\n";
	}
	else
	{
		cout<<"Yes\n";
		rep(i,0,n) cout<<b[i]<<" ";
	}

	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	//cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 6364
#include <iostream>
using namespace std;
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; }
const long long INF = 1LL<<60;

const int MAX_N = 110;
const int MAX_V = 100100;

/*
LCS:最長共通部分列問題
sの部分列とtの部分列で最長なものの長さ
dp[i+1][j+1]=sのi文字までとtのj文字まででのLCSの長さ
*/

/*
長さを求めるのと、文字列を復元する２つのパートに別れる
*/

int dp[3010][3010]={0};

int main()
{
  string s,t;cin>>s>>t;
  
  //長さを求める
  for (int i = 0; i < s.size(); ++i) {
        for (int j = 0; j < t.size(); ++j) {
            if (s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j] + 1);
            chmax(dp[i+1][j+1], dp[i+1][j]);
            chmax(dp[i+1][j+1], dp[i][j+1]);
        }
   }
  
  // 復元
    string res = "";
    int i = (int)s.size(), j = (int)t.size();
    while (i > 0 && j > 0)
    {
        // (i-1, j) -> (i, j) と更新されていた場合
        if (dp[i][j] == dp[i-1][j]) {
            --i; // DP の遷移を遡る
        }

        // (i, j-1) -> (i, j) と更新されていた場合
        else if (dp[i][j] == dp[i][j-1]) {
            --j; // DP の遷移を遡る
        }

        // (i-1, j-1) -> (i, j) と更新されていた場合
        else {
            res = s[i-1] + res; // このとき s[i-1] == t[j-1] なので、t[j-1] + res でも OK
            --i, --j; // DP の遷移を遡る
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 35584
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<62;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
string s;

int main(){
	cin>>s;
	n=s.size();
	vi a;
	string t;
	int I=-1;
	for(int i=0;i<n;i++){
		if(s[i]!='x'){
			t+=s[i];
			a.push_back(i-I-1);
			I=i;
		}
	}
	a.push_back(n-I-1);
	string t_=t;
	reverse(t_.begin(),t_.end());
	if(t_!=t){
		cout<<-1<<endl;
		return 0;
	}
	int res=0,S=a.size();
	for(int i=0;i<S/2;i++) res+=max(a[i],a[S-i-1])-min(a[i],a[S-i-1]);
	cout<<res<<endl;
}

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

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, int num=0){
  if(num == 0) num = (int)v.size();
  if(is_reverse) for(int i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<" ";}
  else for(int i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<" ";}
  cout << endl;
}

template <typename T>
void print_pairvec(const vector<T> &v, int num=0){
  if(num == 0) num = (int)v.size();
  cout << endl;
  for(int i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

using LP = pair<ll, ll>;  
int main(){
  ll N, K;
  cin >> N >> K;

  vector<ll> P(N), C(N);
  vector<ll> to(N);
  for(int i=0; i<N; i++){
    cin >> P[i];
    P[i]--;
    to[i] = P[i];
  }
  for(int i=0; i<N; i++) cin >> C[i];

  vector<vector<ll>> mazes(N);
  vector<LP> loops(N);// loops[i]: iから始めたときloopのはじまりとloop長さ
  vector<ll> get_score(N);
  for(int i=0; i<N; i++){
    vector<ll> node(N, 0);
    ll now = i;
    node[now] = 1;
    ll cnt = 0;
    while(true){
      now = to[now];
      if(node[now] == 1) break;
      node[now] = 1;
      cnt++;
    }
    ll init_loop = 0;
    ll j = i;
    ll flag = 0;
    while(true){
      if(j == now) flag++;
      if(flag == 0) init_loop++;
      j = to[j];
      if(flag == 1) get_score[i] += C[j];
      if(flag == 2) break;
    }

    loops[i] = LP(init_loop, (cnt - init_loop + 1));
  }
  

  ll const INF = 9*1e18 + 1;
  ll ans = -INF;
  for(int i=0; i<N; i++){
      ll score = 0;
      ll max_score = -INF;
      ll now = i;
      ll _K = K;
      for(int j=0; j<loops[i].first; i++){
        now = to[now];
        score += C[now];
        max_score = max(max_score, score);
        _K--;
        if(_K == 0) break;
      }

      if(get_score[i] <= 0){
        for(int j=0; j<loops[i].second; j++){
          if(_K == 0) break;
          _K--;
          now = to[now];
          score += C[now];
          max_score = max(max_score, score);
        }
        ans = max(ans, max_score);
        continue;
      }

      // ll num = _K / loops[i].second;
      ll num = _K / loops[i].second  -1;// 最後に1周期分以上残すために-1しとく
      if(num < 0) num = 0;
      score += num * get_score[i];
      _K -= num * loops[i].second;
      for(int j=0; j<_K; j++){
        now = to[now];
        score += C[now];
        max_score = max(max_score, score);
      }
      ans = max(ans, max_score);
  }
  // cout << " loops: "; print_pairvec(loops);
  // cout << " get_score: "; print_vec(get_score);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 4020
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin>>N;
  vector<int> dp(N+3,1000000000);
  int h[N+1];
  for(int i=1;i<=N;i++){
    cin>>h[i];
  }
  dp[1]=0;
  for(int i=1;i<=N+3;i++){
    if(dp[i+1]>dp[i]+abs(h[i+1]-h[i])){
      dp[i+1]=dp[i]+abs(h[i+1]-h[i]);
    }
    if(dp[i+2]>dp[i]+abs(h[i+2]-h[i])){
      dp[i+2]=dp[i]+abs(h[i+2]-h[i]);
    }
  }
  cout<<dp[N]<<endl;
  return 0;
}

Measured memory_bytes: 4044
#coding:utf-8
#1_8_B
class Node:
    def __init__(self, key):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None

class Tree:
    def __init__(self):
        self.root = None

    def insert(self, node):
        y = None # set parent
        x = self.root
        while x is not None:
            y = x
            if node.key < x.key:
                x = x.left
            else:
                x = x.right
    
        if y is None:
            self.root = node
        elif node.key < y.key:
            y.left = node
        else:
            y.right = node

    def find(self, node, key):
        if node is None:
            return 'no'

        if key == node.key:
            return 'yes'
        elif key < node.key:
            return self.find(node.left, key)
        else:
            return self.find(node.right, key)

def inorder(node):
    if node is None:
        return
    inorder(node.left)
    print(" {}".format(node.key), end = "")
    inorder(node.right)

def preorder(node):
    if node is None:
        return
    print(" {}".format(node.key), end = "")
    preorder(node.left)
    preorder(node.right)

m = int(input())
t = Tree()
for i in range(m):
    cmd = input().split()
    if cmd[0] == 'insert':
        t.insert(Node(int(cmd[1])))
    elif cmd[0] == 'find':
        print(t.find(t.root, int(cmd[1])))
    else:
        inorder(t.root)
        print()
        preorder(t.root)
        print()

Measured memory_bytes: 124608
#include <iostream>
#include <algorithm>
#include <set>

using namespace std;

int main() {
    int p, q;
    cin >> p >> q;
    q /= __gcd(p, q);
    set<int> s;
    for (int i = 2; i * i <= q; i++) {
        if (q % i == 0) {
            s.insert(i);
            while (q % i == 0)q /= i;
        }
    }
    if (q > 1)s.insert(q);
    long long ret = 1;
    for (auto x : s) ret *= x;
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 3108
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1];}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const objvs =(a)=>{const b=[];for(const v in a){b.push(a[v])}return b};
const main=()=>{
  let [a,b]=[ts().split(''),ts().split('')]
  a.sort()
  b = b.sort().reverse()
  to(a<b?'Yes':'No')
}
main()


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

typedef long long ll;

typedef pair<int, ll> p;

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

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

    vector<vector<p> > x(N);

    for(int i = 0; i < M; i++) {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        a--;
        b--;
        x[a].push_back(make_pair(b, c));
    }

    vector<vector<bool> > b(N, vector<bool>(N));

    stack<p> s;

    for(int i = 0; i < N; i++) {

        for(int j = 0; j < x[i].size(); j++) {
            s.push(make_pair(x[i][j].first, x[i][j].second));
        }

        while(!s.empty()) {
            int pos = s.top().first;
            ll l = s.top().second;
            s.pop();

            if(pos == i) {
                if(l > 0) b[i][i] = true;
                continue;
            }

            if(b[i][pos]) continue;
            b[i][pos] = true;

            for(int j = 0; j < x[pos].size(); j++) {
                s.push(make_pair(x[pos][j].first, l + x[pos][j].second));
            }
        }
    }

    for(int i = 0; i < N; i++) {
        if(b[0][i] && b[i][i] && b[i][N - 1]) {
            cout << "inf" << endl;
            return 0;
        }
    }

    vector<ll> c(N, -pow(10, 18));

    queue<int> q;

    int count = 0;

    q.push(0);

    c[0] = 0;

    while(!q.empty()) {
        count++;
        if(count > 2000100) {
            break;
        }

        int pos = q.front();
        q.pop();

        ll l = c[pos];

        for(int i = 0; i < x[pos].size(); i++) {
            if(l + x[pos][i].second > c[x[pos][i].first]) {
                c[x[pos][i].first] = l + x[pos][i].second;
                q.push(x[pos][i].first);
            }
        }
    }

    cout << c[N - 1] << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
const int MOD = 1000000007;
using namespace std;

int main() {
	int K, S;
	cin >> K >> S;
	int x = 0, y = 0, z = 0;
	ll ans = 0;
	for (x = 0; x <= K; x++) {
		for (y = 0; y <= K; y++) {
			z = S - x - y;
			if (z >= 0 && z <= K) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int n,i,num[100001],temp,max;
  scanf("%d",&n);
int a[n];
  
    for(i=0;i<100001;++i)
  {num[i]=0;
  }
  
  for(i=0;i<n;++i)
  {
  scanf("%d",&a[i]);
  num[a[i]]++;
  }
  max=0;
  
  for(i=0;i<99999;i++)
  {
  temp=num[i]+num[i+1]+num[i+2];
  if(temp>max) max=temp;
  }

  printf("%d",max);
  
return 0;
}

Measured memory_bytes: 2512
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#include <cstdint>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

class Combination{
private:
    long long m_mod;
    long long *fac;
    long long *finv;
    long long max_n;
    long long power(long long a, long long b);
    long long ext_gcd(long long a, long long b, long long &x, long long &y);
public:
    Combination(long n, long mod);//max_n, mod
    ~Combination();
    long long comb(long n, long r);
    void fac_vis();
    void finv_vis();
};
long long Combination::power(long long a, long long b){
    if(b == 0){
        return 1ll;
    }else if(b % 2){
        return power(a, b-1) * a % m_mod;
    }else{
        return power(a, b/2) * power(a, b/2) % m_mod;
    }
}
long long ext_gcd(long long a, long long b, long long &x, long long &y){//ax + by = gcd(a, b), returns gcd. |x| + |y| is minimum and x <= y.
    if(b == 0){
        x = 1;
        y = 0;
        return a;
    }
    long d = ext_gcd(b, a % b, y, x);
    y -= a/b * x;
    return d;
}
long long mod(long long a, long long m){
    return (a % m + m) % m;
}
long long modinv(long long a, long long m){
    long long x, y;
    ext_gcd(a, m, x, y);
    return mod(x, m);
}
Combination::Combination(long n, long mod){
    max_n = n;
    m_mod = mod;
    fac = new long long[n+1];
    finv = new long long[n+1];
    fac[0] = finv[0] = 1;
    if(max_n > 0){
        fac[1] = finv[1] = 1;
    }
    for(long long i = 2; i <= max_n; i++){
        fac[i] = fac[i-1] * i % m_mod;
    }
    finv[n] = modinv(fac[n], m_mod);
    for(long long i = max_n-1; i >= 0; i--){
        finv[i] = finv[i+1] * (i+1) % m_mod;
    }
}
Combination::~Combination(){
    delete[] fac;
    delete[] finv;
}
long long Combination::comb(long n, long r){
    if(n < r || n < 0 || r < 0){
        return 0;
    }
    return fac[n] * finv[r] % m_mod * finv[n-r] % m_mod;
}
void Combination::fac_vis(){
    for(int i = 0; i <= max_n; i++){
        printf("%lld ", fac[i]);
    }
    printf("\n");
}
void Combination::finv_vis(){
    for(int i = 0; i <= max_n; i++){
        printf("%lld ", finv[i]);
    }
    printf("\n");
}

const long MOD = 1000000007;

long h, w, a, b;
int main(){
    scanf("%ld%ld%ld%ld", &h, &w, &a, &b);
    Combination c(h + w, MOD);
    long ans = 0;
    for(long i = 0; i < h - a; i++){
        long x = c.comb(b+i-1, i);
        long y = c.comb(w - b + h - i - 2, h - i - 1);
        //printf("%ld : %ld, %ld\n", i, x, y);
        ans += x * y % MOD;
        ans %= MOD;
    }
    printf("%ld\n", ans);
}


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

int main() {
	int N;
	
	cin >> N;
	
	int h[N];
	
	for(int i=0; i<N; i++){
		cin >> h[i];
	}
	
	int cnt=1;
	for(int i=1;i<N;i++){
		int f =1;
		for(int j= i-1; j > -1; j--){
			if(h[i] < h[j]){
				f = 0;
				break;
			}
		}
		if(f==1) cnt++;
	}
	
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
//#include <string.h>
#include <string>
#include <vector>
using namespace std;

#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;

int main()
{
	int k;
	string str;
	string dots = "...";
	
	cin >> k;
	cin >> str;

	if (str.length() > k)
		cout << str.substr(0, k) << dots << "\n";
	else
		cout << str << "\n";

	return 0;
}

Measured memory_bytes: 3580
def fairfield(y, m, d):
	if m < 3:
		y -= 1
		m += 12;
	return 365 * y + int(y / 4) - int(y / 100) + int(y / 400) + int(306 * (m + 1) / 10) + d - 428
while True:
	dset =  map(int, raw_input().split())
	if -1 in dset:
		break
	y1, m1, d1 = dset[0:3]
	y2, m2, d2 = dset[3:6]
	print fairfield(y2, m2, d2) - fairfield(y1, m1, d1)

Measured memory_bytes: 4232
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 2000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;

using namespace std;

int main(void){
  int N,K,ans=0;
  int cL=0,cR=0;
  string S;
  cin >> N >> K >> S;
  int L=S.length();
  rep(i,L-1) if(S[i]==S[i+1]) ans++;
  int count=0;
  rep(i,L-1) if(S[i]!=S[i+1]) count++;
  cout << ans+min(count,2*K) << endl;
}
  

Measured memory_bytes: 512
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
const double PI = 3.14159265358979323846;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	int X;
	cin >> X;
	if (30 <= X) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3588
#include <iostream>

using namespace std;
int main(void){
    string s;
    long long k;
    cin >> s;
    cin >> k;
    
    long t = 0;
    char c = '1';
    for(long i = 0;i < s.size();i++){
          if(s[i] == '1'){
                t++;
          }else{
                c = s[i];
                break;
          }
    }
    if(t >= k){
          cout << '1' << endl;
    }else{
          cout << c << endl;
    }
}


Measured memory_bytes: 3604
/**
 * File    : D.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-9-8 21:12:40
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int H, W;
int a[510][510];

typedef tuple<int, int, int, int> X;
vector<X> V;

void flush()
{
  int N = (int)V.size();
  cout << N << endl;
  for (auto i = 0; i < N; i++)
  {
    X x = V[i];
    cout << get<0>(x) + 1 << " " << get<1>(x) + 1 << " " << get<2>(x) + 1 << " " << get<3>(x) + 1 << endl;
  }
}

void make_swap(int x, int y, int z, int w)
{
  a[x][y]--;
  a[z][w]++;
  V.push_back(X(x, y, z, w));
}

int main()
{
  cin >> H >> W;
  for (auto i = 0; i < H; i++)
  {
    for (auto j = 0; j < W; j++)
    {
      int x;
      cin >> a[i][j];
    }
  }
  for (auto i = 0; i < H - 1; i++)
  {
    for (auto j = 0; j < W; j++)
    {
      if (a[i][j] % 2 == 1)
      {
        make_swap(i, j, i + 1, j);
      }
    }
  }
  for (auto j = 0; j < W - 1; j++)
  {
    if (a[H - 1][j] % 2 == 1)
    {
      make_swap(H - 1, j, H - 1, j + 1);
    }
  }
  flush();
}

Measured memory_bytes: 5232
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main() {
    long long n, a, b;
    cin >> n >> a >> b;

    long long ans;
    ans = (n / (a + b)) * a;
    long long rem = n % (a + b);
    ans += min(a, rem);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	int n,k,ans=0;
	string s,t;
	cin>>s>>t;
	n=s.size();
	rep(i,n){
	    if(s[i]!=t[i]){
	        rep(j,n)if(j!=i){
	            if(t[j]==s[i]){
	                if(j<i){
	                    cout<<"No";return 0;
	                }
	                else t[j]=t[i];
	            }
	            else if(t[j]==t[i]){
	                if(j<i){
	                    cout<<"No";return 0;
	                }
	                else t[j]=s[i];
	            }
	        }
	        t[i]=s[i];
	    }
	}
	if(s==t)cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 776
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc142/tasks/abc142_c>
 問題文============================================================
 =================================================================
 解説=============================================================

 出席番号iの生徒はAi番目に出席した生徒となるので、
 入力の値とindexで探索すればいい
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    map<int,int> mp;
    for(int i = 1; i <= N;i++){
        int A; cin >> A;
        mp[A] = i;
    }
    for(auto p:mp) res.push_back(p.second);
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<vector<ll>>() << endl;
    return 0;
}


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

vector<int> v;

void shuffle(int p,int c) {
  vector<int> t;
  for(int i=0; i<c; i++)
    t.push_back(v[p-1+i]);
  for(int i=0; i<p-1; i++)
    t.push_back(v[i]);
  for(int i=p-1+c; i<v.size(); i++)
    t.push_back(v[i]);
  v = t;
}

int main() {
  while(1) {
    int n,r;
    cin>>n>>r;
    v.clear();
    if(!n&&!r) break;

    for(int i=0; i<n; i++)
      v.push_back(n-i);

    int p,c;
    while(r--) {
      cin>>p>>c;
      shuffle(p,c);
    }
    cout<<v[0]<<endl;
  }
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int a, b, d;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> a >> b >> d;
    int ans = b / d;
    ans -= (a - 1) / d;
    cout << ans << E;
    //system("pause");
    return 0;
}

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

int main () {
  int n, m;
  cin >> n >> m;
  vector<pair<ll,ll>> ab(n);
  rep(i,n) {
    ll a, b;
    cin >> a >> b;
    ab[i] = pair<ll,ll>(a,b);
  }

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

  ll ans = 0;
  rep(i,n) {
    if(m - ab[i].second <= 0) {
      ans += ab[i].first * m;
      break;
    }
    ans += ab[i].second * ab[i].first;
    m -= ab[i].second;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順

using namespace std;
using ll = long long int;

int main(){
    int S,W;cin>>S>>W;
    if(S<=W) cout << "unsafe" << endl;
    else cout << "safe" << endl;
}

Measured memory_bytes: 3624
using System;

namespace _2441
{
	class Program
	{
		static long index;

		static long Calc(long key)//Finish letter count(1-indexed)
		{
			//only_num
			long ret = 0;
			for (int i = 0; i < key.ToString().Length; i++)
			{
				ret += key - ((long)Math.Pow(10, i) - 1);
			}
			//fizzbuzz
			ret += (key / 3 + key / 5) * 4;
			//-fizzbuzz_num
			for (int i = 0; i < key.ToString().Length; i++)
			{
				long a = (long)Math.Pow(10, i) - 1;
				ret -= (key / 3 + key / 5 - key / 15) - (a / 3 + a / 5 - a / 15);
			}
			return ret;
		}

		static bool IsOK(long key)
		{
			long a = Calc(key);
			if (a <= index) return true;
			else return false;
		}

		static long Binary_search()
		{
			long ok = 0;
			long ng = 1000000000000000000;

			while (Math.Abs(ok - ng) > 1)
			{
				long mid = ng + (ok - ng) / 2;

				if (IsOK(mid)) ok = mid;
				else ng = mid;
			}

			return ok;
		}
		static void Main(string[] args)
		{
			index = long.Parse(Console.ReadLine());
			long x = Binary_search();//文字数でおさまる最大の数字
			long l = Calc(x - 1) + 1;//xが始まるカウント
			long remain = index - l;
			string ret = "";
			for (long i = -remain; i < 20; x++)
			{
				if (x % 15 == 0)
				{ ret += "FizzBuzz"; i += 8; }
				else if (x % 3 == 0)
				{ ret += "Fizz"; i += 4; }
				else if (x % 5 == 0)
				{ ret += "Buzz"; i += 4; }
				else
				{ ret += x.ToString(); i += x.ToString().Length; }
			}
			Console.WriteLine(ret.Substring((int)remain, 20));
		}
	}
}


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

using namespace std;

typedef long long ll;
ll n,a,b,c,d;
int main() {
  cin >> n >> a >> b >> c >> d;

  bool is = false;

  for(ll k = 0; k < n; k++) {
    if(((k * c - (n - 1 - k) * d) <= (b - a)) && ((b - a) <= (k * d - (n - 1 - k) * c)))
	is = true;

  }

  if(is) cout << "YES" << endl;
  else cout << "NO" <<endl;
}
      
  


Measured memory_bytes: 256
#include <stdio.h>
int main (void){
  int a,b;
  scanf("%d %d",&a,&b);
  if (a == 1){
    if (b == 1)
      printf("Draw\n");
    else
      printf("Alice\n");
  }
  else if (b == 1)
    printf("Bob\n");
  else if (a == b)
    printf("Draw\n");
  else if (a > b)
    printf("Alice\n");
  else
    printf("Bob\n");
  return (0);
}


Measured memory_bytes: 128
use std::collections::HashMap;

pub fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

pub struct UnionFind {
    pub par: Vec<usize>,
    pub rank: Vec<usize>,
}

impl UnionFind {
    pub fn new(n: usize) -> UnionFind {
        let par = (0..n).collect::<Vec<usize>>();
        let rank = vec![0; n];
        UnionFind { par: par, rank: rank }
    }

    pub fn root(&mut self, x: usize) -> usize {
        let cand = self.par[x];
        if cand == x {
            return x;
        } else {
            let ret = self.root(cand);
            self.par[x] = ret;
            return ret;
        }
    }

    pub fn same(&mut self, x: usize, y: usize) -> bool {
        self.root(x) == self.root(y)
    }

    pub fn unite(&mut self, x: usize, y: usize) {
        let root_x = self.root(x);
        let root_y = self.root(y);
        if root_x == root_y { return; }

        if self.rank[root_x] < self.rank[root_y] {
            self.par[root_x] = self.par[root_y];
        } else {
            self.par[root_y] = self.par[root_x];
            if self.rank[root_y] == self.rank[root_x] {
                self.rank[root_x] += 1;
            }
        }
    }
}

fn main() {
    let nkl = readn::<usize>(" ");
    let n = nkl[0];
    let k = nkl[1];
    let l = nkl[2];

    let mut uf1 = UnionFind::new(n);
    let mut uf2 = UnionFind::new(n);
    let mut dict = HashMap::new();
    
    for _ in 0..k {
        let pq = readn::<usize>(" ");
        uf1.unite(pq[0]-1, pq[1]-1);
    }
    let root1 = (0..n).map(|i| uf1.root(i)).collect::<Vec<usize>>();

    for _ in 0..l {
        let pq = readn::<usize>(" ");
        uf2.unite(pq[0]-1, pq[1]-1);
    }
    let root2 = (0..n).map(|i| uf2.root(i)).collect::<Vec<usize>>();

    for i in 0..n {
        let t = (root1[i], root2[i]);
        let count = dict.entry(t).or_insert(0);
        *count += 1;
    }

    let mut ans = String::new();
    for i in 0..n {
        let add = dict[&(root1[i], root2[i])].to_string();
        ans += &add;
        ans += " ";
    }
    println!("{}", ans);
}

Measured memory_bytes: 31008
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

x,a,b = inputIL()

if abs(x-a)>abs(x-b):
  print("B")
else:
  print("A")

Measured memory_bytes: 63980
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    intl cnt = 0;
    rep(i,n){
        intl a,b;
        cin >> a >> b;
        cnt += b - a + 1;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def select_a(a, b):
    nums[a] += 1
    nums[b] -= 1
    choices.append(a)

n, a, b, c = map(int, input().split())
nums = [a, b, c]
queries = []
for i in range(n):
    s = input()
    if 'AB' in s:
        queries.append((0, 1))
    elif 'AC' in s:
        queries.append((0, 2))
    else:
        queries.append((1, 2))

choices = []
for i in range(n):
    p, q = queries[i]
    if nums[p] > nums[q]:
        select_a(q, p)
        if min(nums) < 0:
            break
    elif nums[p] < nums[q]:
        select_a(p, q)
        if min(nums) < 0:
            break
    else:
        if i == n-1:
            select_a(p, q)
            if min(nums) < 0:
                break
        else:
            v, w = queries[i+1]
            if p in {v, w}:
                select_a(p, q)
                if min(nums) < 0:
                    break
            else:
                select_a(q, p)
                if min(nums) < 0:
                    break

if min(nums) < 0:
    print('No')
else:
    print('Yes')
    for choice in choices:
        print('ABC'[choice])


Measured memory_bytes: 75892
import java.util.*;


public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			char [] c = sc.next().toCharArray();
			boolean flg = false;
			for(int i = 0; i < c.length-1;i++){
				if(c[i] == 'A' && c[i+1] == 'C'){
					flg = true;
					break;
				}
			}

			System.out.println(flg ? "Yes" : "No");
		}
	}



	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

}


Measured memory_bytes: 23764
#include<iostream>
using namespace std;
int main(){
    string a;   bool v[2]={0};
    cin>>a;
    for(int i=0;i<a.length();i++)
    {
        if(a[i]=='C') v[0]=1;
        if(a[i]=='F'&&v[0])  v[1]=1;
    }
    if(v[1]) cout<<"Yes";
    else cout<<"No"; 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    ll n,y,i,j;
    cin>>n>>y;
    int f=0;
    for (i=0;i<=n;i++)
    {
        for (j=0;j<=n;j++)
        {
            if ((n-i-j)>=0 && (i*10000+j*5000+(n-i-j)*1000)==y)
            {
                f=1;
                cout<<i<<" "<<j<<" "<<n-i-j<<endl;
                break;
            }
        }
        if (f)
            break;
    }
    if (!f)
        cout<<"-1 -1 -1\n";
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 2e5+5;

const ll MOD = 1000000007LL;

void solve() {

}

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

    string s;
    cin >> s;

    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
        cout << "Bad";
    } else {
        cout << "Good";
    }







    return 0;
}


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

int main() {
  long long int n, sum = 0; cin >> n;
  long long int a[n*3];
  for (long long int i = 0; i < n*3; i++) cin >> a[i];
  sort(a, a+3*n);
  for (long long int i = n; i < n*3; i+=2) 
    sum += a[i];
  cout << sum << endl;
  return 0;
}
    


Measured memory_bytes: 2560