akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,ma,sum,mai;
  int a[10][10000];
  while(scanf("%d %d",&h,&w),h!=0&&w!=0){
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	scanf("%d",&a[i][j]);
      }
    }    
    ma = 0;
    for(int i=0;i<(1<<h);i++){
      sum = 0;
      for(int j=0;j<w;j++){
	mai = 0;
	for(int k=0;k<h;k++){
	  if( (i&(1<<k)) == 0) mai += !(a[k][j] == 1);
	  else mai += (a[k][j] == 1);
	}
	sum += max(mai,h-mai);
      }
      ma = max(ma,sum);
    }
    printf("%d\n",ma);
  }
  return (0);
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forN(i, n) for(int i = 0; i <n ; ++i)
#define endl "\n"
#define noob (main)
typedef long long ll;
using namespace  std;
typedef vector<int> vi;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const int N = 2e5 +5 ;
vi primes(1,2);
void sieve(){
    vi m(N+1,0);
    for(int i = 4; i<N; i+=2)m[i]=1;
    for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
    for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}
bool isPrime(ll x){
    if(x==1)return 0;
    for(auto i:primes){
        if(i*i>x)return 1;
        if(x%i==0)return 0;
    }
    return 1;
}

int noob(){
    fastIO;
    int n;
    cin>>n;
    ll ans = 0;
    for(int i = 1 ; i<n ; i++){
        ans+=n/i;
        if(n%i==0){
            ans--;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3656
#include<cstdio>
using namespace std;
int x,mx=1;
int main()
{
	scanf("%d",&x);
	for(int i=2,tmp;i*i<=x;i++)
	{
		for(int tmp=i*i;tmp<=x;tmp*=i)
		{
			if(tmp>mx)mx=tmp;
		}
	}
	printf("%d",mx);
}

Measured memory_bytes: 128
l1=[]
for i in range(3):
  a, b, c=map(int, input().split())
  l1.append(a)
  l1.append(b)
  l1.append(c)
n=int(input())

for i in range(n):
  d=int(input())
  for j in range(9):
    if l1[j]==d:
      l1[j]=0
if l1[0]+l1[1]+l1[2]==0 or l1[3]+l1[4]+l1[5]==0 or l1[6]+l1[7]+l1[8]==0 or l1[0]+l1[4]+l1[8]==0 or l1[2]+l1[4]+l1[6]==0 or l1[0]+l1[3]+l1[6]==0 or l1[1]+l1[4]+l1[7]==0 or l1[2]+l1[5]+l1[8]==0:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 62132
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<string> v;
int main()
{
    int n,l;
    cin >> n >> l;
    for(int i = 0;i < n;i++)
    {
        string str;
        cin >> str;
        v.push_back(str);
    }
    sort(v.begin(),v.end());
    for(int i = 0;i < v.size();i++)
    {
        cout << v[i];
    }
    cout << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using ll = long long int;

int main(){
    int N, D;
    cin >> N >> D;
    ll h = 2*D + 1;
    if(N%h == 0){
        cout << N/h;
    }
    else{
        cout << N/h + 1;
    }
}

Measured memory_bytes: 256
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
bool check(string s)
{
	string temp=s;
	reverse(all(s));
	return s==temp;
}
int main()
{
	fast();
	string s;
	cin>>s;
	bool flag=true;
	if(!check(s))
		flag=false;
	ll n=s.length();
	string temp=s.substr(0,(n-1)/2);
	//prn(temp);
	if(!check(temp))
		flag=false;
	temp=s.substr((n+3)/2-1,n-(n+3)/2+1);
//	prn(temp);
	if(!check(temp))
		flag=false;
	if(flag)
		cout<<"Yes";
	else
		cout<<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long
#define ld long double

#define mod 1000000007
#define EULER 2.7182818284
#define INF 1000000000

#define pb push_back
#define ins insert
#define IT iterator
#define PQ priority_queue

#define fi first
#define se second
#define maxe max_element
#define mine min_element
#define er erase
#define lb lower_bound
#define ub upper_bound

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


#define mem(v,i) memset(v,i,sizeof(v)) // v is array. To set all elements to 0 or -1 only. mem(arr,0);


#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORd(i,a,b) for(int i=(a);i>=(b);i--)
#define FORl(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORN(i,n) for(int i=(0);i<(n);i++)
#define FORR(i,n) for(int i=(n);i>=0;i--)
#define bs bitset
#define bpc(a) __builtin_popcount(a)

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

ll mypow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}
//..............................!!!!!!Get ready to fight!!!!!!............................

vector<ll>vec[200005];

int main()
{
    fast
    
    ll n,i,sum=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        if(i%3==0||i%5==0)
        continue;
        else
        sum+=i;
    }
    cout<<sum<<"\n";
    
    
    
    return 0;
}

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

struct P{
  double x,y;
};

void dfs(P p1,P p2,int d){
  double px=(p2.x-p1.x)/3,py=(p2.y-p1.y)/3;
  P s,u,t,u2;
  if(d==n){
    printf("%.5f %.5f\n",p1.x,p1.y);
    return;
  }
  s.x=p1.x+px,s.y=p1.y+py;
  t.x=p1.x+2*px,t.y=p1.y+2*py;
  u2=t;
  u2.x-=s.x,u2.y-=s.y;
  u.x=u2.x/2-u2.y*sqrt(3)/2;
  u.y=u2.x*sqrt(3)/2+u2.y/2;
  u.x+=s.x,u.y+=s.y;
  dfs(p1,s,d+1);
  dfs(s,u,d+1);
  dfs(u,t,d+1);
  dfs(t,p2,d+1);
}

int main(){
  P a,b;
  a.x=0,a.y=0;
  b.x=100,b.y=0;
  cin>>n;
  dfs(a,b,0);
  printf("%.5f %.5f\n",b.x,b.y);
  return 0;
}

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

int main() {
  char c;
  cin >> c;
  if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o'){
      cout << "vowel" << endl;
  }else {
    cout << "consonant" << endl;
}
  return 0;
}


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

x = L

xs1 = []
xs2 = []
xs3 = []

for i in range(19):
    c = 18 - i
    xs1.append((i + 1, i + 2, 0))

#print("x=", x)

b = 0

for i in range(20):
    n = 19 - i
    r = 2 ** n
    if x >= r:
        m = n
        x -= r
        b += r
        #print(n, r, x, b)
        break

#print("m=", m)
#print("i=", i)

for i in range(i + 1, 20):
    n = 19 - i
    r = 2 ** n
    if x >= r:
        xs3.append((n + 1, 20, b))
        x -= r
        b += r
        #print(n, r, x, b)

for i in range(m):
    xs2.append((i + 1, i + 2, 2**i))

xs = xs1 + xs2 + xs3

print(20, len(xs))

for x in xs:
    print(*x)


Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <vector>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iterator>

using namespace std;

int main(){
  long n,m;
  scanf("%ld",&n);
  scanf("%ld",&m);
  vector<unsigned long> a(n);
  vector<unsigned long> loga(n);

  for(int i=0;i<n;i++){
    scanf("%lu", &a[i]);
    loga[i] = floor(log2(a[i]));
  }

  sort(a.begin(),a.end(),greater<unsigned long>());
  sort(loga.begin(),loga.end(),greater<unsigned long>());

  do{
    unsigned long tmp = loga[0];
    int i=0;
    do{
      if(!(m>0)) break;
      m--;
      a[i] = a[i]/2;
      loga[i] = loga[i] - 1;
    }while(tmp==loga[++i]);
    sort(a.begin(),a.end(),greater<unsigned long>());
    sort(loga.begin(),loga.end(),greater<unsigned long>());
  }while(m>0);

  unsigned long sum = 0;
  for(int i=0;i<n;i++){
    sum += a[i];
  }

  std::cout << sum << std::endl;

  return 0;
}

Measured memory_bytes: 1792
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2300

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>
#include<iomanip>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

struct Lab
{
	double L;
	double A;
	double B;
	Lab(double l, double a, double b):L(l),A(a),B(b){}
};

template <class BidirectionalIterator>
bool next_combination (
		BidirectionalIterator first1 ,
		BidirectionalIterator last1 ,
		BidirectionalIterator first2 ,
		BidirectionalIterator last2 )
{
	if (( first1 == last1 ) || ( first2 == last2 )) {
		return false;
	}
	BidirectionalIterator m1 = last1 ;
	BidirectionalIterator m2 = last2 ; --m2;
	while (--m1 != first1 && !(* m1 < *m2 )){
	}
	bool result = (m1 == first1 ) && !(* first1 < *m2 );
	if (! result ) {
		while ( first2 != m2 && !(* m1 < * first2 )) {
			++ first2;
		}
		first1 = m1;
		std :: iter_swap(first1 , first2 );
		++ first1;
		++ first2;
	}
	if (( first1 != last1 ) && ( first2 != last2 )) {
		m1 = last1 ; m2 = first2;
		while (( m1 != first1 ) && (m2 != last2 )) {
			std :: iter_swap (--m1 , m2 );
			++ m2;
		}
		std :: reverse(first1 , m1);
		std :: reverse(first1 , last1);
		std :: reverse(m2, last2);
		std :: reverse(first2, last2);
	}
	return ! result;
}

template <class BidirectionalIterator>
bool next_combination (
		BidirectionalIterator first ,
		BidirectionalIterator middle ,
		BidirectionalIterator last )
{
	return next_combination (first , middle , middle , last );
}

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

	int N,M;
	cin >> N >> M;
	vector<Lab> labs;
	rep(nth,N)
	{
		double l,a,b;
		cin >> l >> a >> b;
		labs.push_back( Lab(l,a,b) );
	}

	vector<int> num;
	rep(i,N){
		num.push_back(i);
	}


	double ans=0.0;	
	do {
		
		double tmp=0.0;
		
		rep(i,M)
		{
			REP(j,i,M)
			{
				if(i != j)
				{
					double li = labs[num[i]].L - labs[num[j]].L;
					double ai = labs[num[i]].A - labs[num[j]].A;
					double bi = labs[num[i]].B - labs[num[j]].B;
					tmp	+= li*li + ai*ai + bi*bi;
				}
			}
		}
		ans = max(tmp,ans);
	
	} while ( next_combination (num.begin(), num.begin()+M, num.end()) );
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1312
#include <stdio.h>

int main() {
    int x, y, n;
    scanf("%d%d%d", &x,&y,&n);
    int count1 = 0;
    int count2 = 0;
    int temp1 = 0;
    int temp2 = 0;
    for (int i=1; i<=x; i++){
        count1++;
        temp1 += y;
        if (temp1 >= n){
            break;
        }
    }
    for (int i=1; i<=y; i++){
        count2++;
        temp2 += x;
        if (temp2 >= n){
            break;
        }
    }
    if (count1 <= count2){
        printf("%d\n", count1);
    }
    else{
        printf("%d\n", count2);
    }
    return 0;
}

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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    int a,b;
    cin>>a>>b;
    
    int ans=max(0LL,a-2LL*b);
    cout<<ans;

    return 0;
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int m = ri();
	std::set<int> bad;
	for (int i = 0; i < m; i++) bad.insert(ri());
	int dp[n + 1];
	for (int i = 0; i <= n; i++)dp[i] = 0;
	dp[0] = 1;
	for (int i = 0; i < n; i++) {
		if (!bad.count(i + 1)) {
			dp[i + 1] += dp[i];
			if (dp[i + 1] >= 1000000007)
				dp[i + 1] -= 1000000007;
		}
		if (!bad.count(i + 2) && i + 2 <= n) {
			dp[i + 2] += dp[i];
			if (dp[i + 2] >= 1000000007)
				dp[i + 2] -= 1000000007;
		}
	}
	std::cout << dp[n] << std::endl;
	return 0;
}


Measured memory_bytes: 5376
/*
[arc077] D - 11
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_N = 1e5;
const int MOD = 1e9 + 7;

class gf {
public:
    int n;
    static int mod_inv(int a, int m) {
        int u = 0, v = 1, mod = m;
        while (a != 0) {
            ll t = m / a;
            m -= t * a;
            u -= t * v;
            swap(a, m);
            swap(u, v);
        }
        return (u + mod) % mod;
    }
    gf() : n(0) {}
    gf(int n) : n(n < 0 ? (n % MOD) + MOD : n % MOD) {}
    gf operator+(gf x) { return gf((n + x.n) % MOD); }
    gf operator-(gf x) { return gf((n - x.n + MOD) % MOD); }
    gf operator*(gf x) { return gf((1LL * n * x.n) % MOD); }
    gf operator/(gf x) { return *this * x.inv(); }
    gf& operator+=(gf x) { return *this = (*this + x); }
    gf& operator-=(gf x) { return *this = (*this - x); }
    gf& operator*=(gf x) { return *this = (*this * x); }
    gf& operator/=(gf x) { return *this = (*this / x); }
    gf inv() { return gf(mod_inv(n, MOD)); }
};

int N;
int a[MAX_N + 1];
int idx[MAX_N + 1];

void solve() {
    fill(idx, idx + N + 1, -1);
    int d;
    for (int i = 0; i < N + 1; i++) {
        if (idx[a[i]] >= 0) {
            d = i - idx[a[i]];
            break;
        }
        idx[a[i]] = i;
    }

    gf t = N + 1;
    gf r = 1;
    for (int k = 1; k <= N + 1; k++) {
        cout << (t - r).n << endl;
        t = t * (N - k + 1) / (k + 1);
        r = r * (N - d - k + 1) / k;
    }
}

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

    solve();

    return 0;
}


Measured memory_bytes: 2048
// Aizu Vol-5 0512: Caesar Cipher
// 2017.8.30 bal4u@uu

#include <stdio.h>
char *gets();

char t[128];
char s[1003], *p;

int main()
{
	int i;

	for (i = 'A'; i <= 'Z'; i++) t[i+3] = i;
	for (i = 'A'; i <= 'C'; i++) t[i] = i-'A'+'X';
	gets(p = s); while (*p) putchar(t[*p++]);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
    
    int n, a, b; cin >> n >> a >> b;
    cout << min(a * n, b) << endl;   
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
//#define ARRAY(type,n) (type *)malloc(sizeof(type)*n)
template<typename T>
T* ARRAY(int n){
	(T*)malloc(sizeof(T)*n);
}
template<typename T>
T** ARRAY2(int m,int n){
	T** type = (T**)malloc(sizeof(T*)*m);
	for(int i=0;i<m;i++){
		type[i]=(T*)malloc(sizeof(T)*n);
	}
	return type;
}

int par[200000];
void init(int n){
	rep(i,n){
		par[i]=i;
	}
}

int root(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x] = root(par[x]);
	}
}

void unite(int x,int y){
	x=root(x);
	y=root(y);
	if(x==y)return;
	par[x]=y;
}

int par2[200000];
void init2(int n){
	rep(i,n){
		par2[i]=i;
	}
}

int root2(int x){
	if(par2[x]==x){
		return x;
	}else{
		return par2[x] = root2(par2[x]);
	}
}

void unite2(int x,int y){
	x=root2(x);
	y=root2(y);
	if(x==y)return;
	par2[x]=y;
}

struct ans{
	int r1;
	int r2;
	int memo;
	int num;
	
};

bool operator< (const ans& left,const ans& right){
        return left.r1 == right.r1 ? left.r2 < right.r2 : left.r1 < right.r1;
    }

class MY_LESS_DEFINITION{
public:
    bool operator() (const ans& left, const ans& right) const {
        return left.num<right.num;
    }
};

int main(void){
	int n;
	cin>>n;
	ll a[n],b[n];
	ll aa,bb;
	aa=0;
	bb=0;
	rep(i,n){
		cin>>a[i];
		aa+=a[i];
	}
	rep(i,n){
		cin>>b[i];
		bb+=b[i];
	}
	aa=0;
	bb=0;
	rep(i,n){
		if(a[i]>b[i]){
			bb+=a[i]-b[i];
		}else if(a[i]<b[i]){
			aa += (b[i]-a[i])/2;
		}
	}
	cout<<(aa>=bb?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;
const int LEN = 1e2 + 10;
int arr[LEN];

int main() {
    int n, cnt = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n - i; j++) {
            if (arr[j] > arr[j + 1]) {
                cnt += 1;
                swap(arr[j], arr[j + 1]);
            }
        }
    }
    for (int i = 1; i < n; i++) {
        cout << arr[i] << " ";
    }
    cout << arr[n] << endl << cnt << endl;
    return 0;
}


Measured memory_bytes: 3096
let () =
  let counter = ref 0 in
  let rec msort (array : int array) left right =
    let merge (array : int array) left mid right =
      let init n p = Array.init (n+1) (fun i -> if i=n then max_int else array.(p+i)) in
      let xs = init (mid-left) left in
      let ys = init (right-mid) mid in
      let rec loop i j k =
        if k < right then
          (incr counter;
           if xs.(i) <= ys.(j) then (array.(k) <- xs.(i); loop (i+1) j (k+1))
           else (array.(k) <- ys.(j); loop i (j+1) (k+1)) )
      in loop 0 0 left in
    if left+1 < right then
      let mid = (left+right)/2 in
      msort array left mid;
      msort array mid right;
      merge array left mid right in
  let n = read_int () in
  let (l : int array) = Array.init n (fun _ -> Scanf.scanf "%d " (fun x -> x)) in
  msort l 0 n;
  Array.iteri (fun i v -> Printf.printf (if i = n-1 then "%d\n" else "%d ") v) l;
  Printf.printf "%d\n" !counter

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

def main():
    N,M = map(int, input().split())

    A = []
    for _ in range(N):
        a,b = list(map(int, input().split()))
        A.append((a,b))

    A.sort()
    ans = 0
    for a,b in A:
        if M == 0:
            break
        n = M if M <= b else b
        M -= n
        ans += n * a
    print(ans)

if __name__ == '__main__':
    main()


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

int main() {
  int l, r, d;
  cin >> l >> r >> d;
  int ans = 0;
  for (int i = l; i <= r; i++) {
    if (i % d == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static class Move {
		int fx, fy, gx, gy;
		
		public Move(int fx, int fy, int gx, int gy) {
			this.fx = fx;
			this.fy = fy;
			this.gx = gx;
			this.gy = gy;
		}
		
		public String toString() {
			return this.fy + " " + this.fx + " " + this.gy + " " + this.gx;
		}
	}
	
	public static int[][] move_dirs = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
	public static boolean in_range(int x, int y, int W, int H) {
		return 0 <= x && x < W && 0 <= y && y < H;
	}
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			if(N == 1) {
				System.out.println("Hello World");
			}else {
				final int A = sc.nextInt();
				final int B = sc.nextInt();
				
				System.out.println(A + B);
			}
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

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

using namespace std;

#define ll long long int
typedef pair<ll,ll>PII;
ll a[100005],b[100005];
vector<PII> v;
int main() {
      ll  n,k;
      cin>>n>>k;
      v.clear();
      for (ll i = 0; i < n; i++) {
            cin>>a[i]>>b[i];
            v.push_back({a[i],b[i]});
      }
      sort(v.begin(),v.end());
      ll cnt = 0;
      for (int i = 0; i < v.size(); i++) {
            ll p1 = v[i].first;
            ll p2 = v[i].second;
            if ( cnt + p2 >= k) {
                  cout<<p1<<endl;
                  return 0;
            }
            cnt += p2;
      }

      return 0;
}

Measured memory_bytes: 3444
import java.io.*;
import java.util.*;

public class Main {
    public static PrintWriter out;
    public static FastScanner in;

    private void solve(){
        int n = in.nextInt();
        int m = in.nextInt();

        out.print((n+m)%24);
    }

    private void runIO() {
        in = new FastScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        solve();
        out.close();
    }
    private static class FastScanner {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;

        private FastScanner() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            if (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

        private int nextInt() {
            return Integer.parseInt(next());
        }

        private long nextLong() {
            return Long.parseLong(next());
        }

        private String nextLine() {
            String ret = "";
            try {
                ret = bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return ret;
        }
    }

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


Measured memory_bytes: 22356
import sys

N = int(input())
A = list(map(int, input().split()))
result = A[0]

if 0 in A:
    print(0)
    sys.exit()

for i in range(1,N):
    result = result*A[i]
    if result > 10**18:
        print(-1)
        sys.exit()

print(result)


Measured memory_bytes: 21656
n = int(input())
dic = {}
for i in range(n):
    s = "".join(sorted(input()))
    if s not in dic:
        dic[s] = [0, 0]
    else:
        dic[s][1] += 1 
        dic[s][0] += dic[s][1]
ans = 0
for i in dic.values():
    ans += i[0]
print(ans)

Measured memory_bytes: 68312
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()
#define pb push_back

#define error(x) cout << #x << " = " << x << endl

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

const int N = 2e5 + 20, mod = 1e9 + 7;
int n, x, y, ans = 1, fac[N], inv[N];
pii p[N];

bool vis[N];

vector <int> g[N];
int best[N], id1, id2;

inline int pw (int a, int b)
{
	int res = 1;
	while (b)
	{
		if (b & 1) res = 1ll * res * a % mod;
		a = 1ll * a * a % mod;
		b >>= 1;
	}
	return res;
}

inline void add_edge (int u, int v)
{
	g[u].pb(v);
	g[v].pb(u);
}

inline bool ok (int i, int j)
{
	if (p[i].S == p[j].S)
		return p[i].F + p[j].F <= x;
	else
		return p[i].F + p[j].F <= y;
}

int num[N];
int sz;
vector <int> vec;

void dfs (int v) 
{
	vis[v] = 1;
	sz++;
	vec.pb(p[v].S);

	for (int u : g[v])
		if (!vis[u]) dfs(u);
}

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

	fac[0] = 1;
	for (int i = 1; i < N; i++) 
	{
		fac[i] = 1ll * fac[i - 1] * i % mod;
		inv[i] = pw(i, mod - 2);
	}

	cin >> n;
	cin >> x >> y;

	for (int i = 0; i < n; i++) cin >> p[i].S >> p[i].F;

	sort(p, p + n);

	for (int i = 1; i < n; i++)
		if (p[i].S != p[i - 1].S)
		{
			id2 = i;
			break;
		}

	memset(best, -1, sizeof best);
	for (int i = 0; i < n; i++)
		if (best[p[i].S] == -1) best[p[i].S] = i;	

	for (int i = 0; i < n; i++)
	{
		if (ok(i, id1)) add_edge(id1, i);
		if (ok(i, id2)) add_edge(id2, i);
		if (ok(i, best[p[i].S])) add_edge(best[p[i].S], i);
	}

	for (int i = 0; i < n; i++)
	{
		if (vis[i]) continue;

		vec.clear();
		sz = 0;
		dfs(i);

		for (int x : vec)
		{
			num[x]++;
			ans = 1ll * ans * inv[num[x]] % mod;
		}

		for (int x : vec) num[x]--;

		ans = 1ll * ans * fac[sz] % mod;
	}

	cout << ans << '\n';
}


Measured memory_bytes: 18280
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int n; cin >> n;
	string s; cin >> s;
	REP(i, n-2){
		if(s.substr(i, 3) == "ABC")ans ++;
	}
	cout << ans << endl;
}

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

int main() {
  int a, b, c,d,e,k;
  cin >> a >> b >> c >> d >>e>>k;
  
  if(b-a<=k&&c-a<=k&&d-a<=k&&e-a<=k&&c-b<=k&&d-b<=k&&e-b<=k&&d-c<=k&&e-c<=k&&e-d<=k){
  	cout << "Yay!" << endl;
  }  
  else{
  	cout << ":(" << endl;
  }


}


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

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i,n)  for(ll i=0; i<n; i++)
#define loop1(i,n)  for(ll i=1; i<=n; i++)

#define all(a)      (a).begin(),(a).end()
#define exist(s,e)  (s.find(e)!=s.end())
#define dbg(x)  cout << #x << " = " << x << endl
#define pt(x) cout<<x<<"\n"
#define pts(x) cout<<x<<" "

#define mp make_pair
#define pb push_back
#define F first
#define S second


#define inf (int)1e9
#define infll 1e18
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007


#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test   int t; cin>>t; while(t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll,ll> mll;
typedef set<ll> sl;


int dirx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int diry[] = { -1, 0, 1, -1, 1, -1, 0, 1 };



//===========================DEBUG======================//
#define XOX 1
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

//================================================================//



//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt=2e5+5;


int main(){
    #ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
    fast

    ll n,ele, cnt=0; cin>>n;
    loop(i,n){
    	cin>>ele;
    	if(i%2==0 && ele%2)cnt++;
    }
    pt(cnt);
}


/*


*/





Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
const int INF = numeric_limits<int>::max();

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

    if (s == "ABC") cout << "ARC" << endl;
    if (s == "ARC") cout << "ABC" << endl;

    return 0;
    
}

Measured memory_bytes: 3624
n, m = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))

sw = [i + 1 for i in range(n)]

t_on = []
for i in range(2 ** n):
    on = []
    for j in range(n):
        if (i>>j) & 1:
            on.append(sw[j])

    t_on.append(on)

ans = 0
for i in range(len(t_on)):
    for j in range(m):
        c = set(t_on[i]) & set(ks[j][1:])
        # print(ks[j][1:], t_on[i], c, len(c), p[j])
        if len(c) % 2 != p[j]: break
    else:
        ans += 1

print(ans)
        



Measured memory_bytes: 3064
#include<stdio.h>
int a[10010];

int main(){
	int n;
	scanf("%d",&n);
	int m=0,mi=1;
	for(int i=2;i<=n;i++){
		printf("? 1 %d\n",i);
		fflush(0);
		int t;
		scanf("%d",&t);
		if(t>m){
			m=t;
			mi=i;
		}
	}
	
	for(int i=1;i<=n;i++){
		printf("? %d %d\n",mi,i);
		fflush(0);
		int t;
		scanf("%d",&t);
		a[t]=i;
	}
	
	printf("!");
	for(int i=0;i<n;i++)printf(" %d",a[i]);
	puts("");
}


Measured memory_bytes: 3668
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).unwrap();
    word.trim().to_owned()
}

fn main() {
	let b = get_input().chars().nth(0).unwrap();
    let ans = match b {
    	'T' => 'A',
    	'A' => 'T',
    	'G' => 'C',
    	_ => 'G',
	};
	println!("{}", ans);
 }

Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

int main() {
  uint32_t D = 0, T = 0, S = 0;
  std::cin >> D >> T >> S;

  std::cout << (T*S >= D ? "Yes" : "No") << std::endl;

  return 0;
}

Measured memory_bytes: 3628
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }

}

use std::cmp::{max, min};

fn main() {
    let n: String = read();

    if n == "Sunny" {
        println!("{}", "Cloudy");
    }

    if n == "Cloudy" {
        println!("{}", "Rainy");
    }

    if n == "Rainy" {
        println!("{}", "Sunny");
    }

}


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

int main(){

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

    if(k!=1){
        cout << n-k << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define int long long  
signed main(){
    int N,P;
    int A;
    bool od=0;
    cin >> N >> P;
    REP(i,N){cin >> A;if(A%2==1){od=1;}}
    if(od==1){
        cout << (int)pow(2,(int)N-1) << endl;
    }else{
        cout << (int)pow(2,(int)N)*(1-P) << endl;
    }
	return 0;
}


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

/**
 * 弧度法表記を度数法表記に変換する
 * @param r 角度[rad]
 * @return  角度[deg]
 */
long double to_deg(long double r) {
    return r * 180.0 / (atanl(1.0) * 4.0);
}

int main() {
    long double a, b, x;
    cin >> a >> b >> x;
    
    long double ans = 0;
    if (x >= a * a * b / 2.0)
    {
        ans = to_deg(atanl(2.0 * b / a - 2.0 * x / (a * a * a)));
    } else
    {
        ans = to_deg(atanl(a * b * b / 2.0 / x));
    }
    
    cout << fixed << setprecision(10) << ans << endl;
    

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
    
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    #endif
    string s;
    cin >> s;
    if (s.find('7') != string::npos) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 3652
import java.util.*;
import java.io.*;
import java.math.*;


import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;


public class Main{ 


    static long mod=1000000007;
    //  static int dx[]={1,-1,0,0};
    //  static int dy[]={0,0,1,-1};
    // static int dx[]={1,-1,0,0,1,1,-1,-1};
    // static int dy[]={0,0,1,-1,1,-1,1,-1}; 

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

    
    Reader sc = new Reader(System.in);
    PrintWriter out=new PrintWriter(System.out);

//  int n=sc.nextInt();  
  // int n=sc.nextInt(), k=sc.nextInt();  
  // int s=sc.nextInt(), t=sc.nextInt(); 
    int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
    String ans = "NO";
    for( int i=0; i<1000; i++ ){
        if( (b*i + c) % a == 0) {ans = "YES"; break;}
    }


    out.println(ans);
    out.flush();
}

static void db(Object... os){

    System.err.println(Arrays.deepToString(os));

}

static boolean validpos(int x,int y,int r, int c){
    
    return x<r && 0<=x && y<c && 0<=y;
    
}
 
static boolean bit(long x,int k){
    // weather k-th bit (from right) be one or zero
    return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
}

}







class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
    ll n,temp;
    cin>>n;
    if(n%2==0)
        temp=(n/2)*(n+1);
    else
        temp =( (n+1) / 2) * (n);
    cout<<temp-n<<endl;
    return 0;
    }


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
ll dp[1100][1100];
const ll mod = 1000000007; 
string field[1100];
int main()
{
    int h,w;
    cin >> h >> w;
    rep(i,h)cin >> field[i];
  
    rep(i,h)rep(j,w){
        if(i == 0 && j == 0){
            dp[i+1][j+1] = 1;
            continue;
        }

        if(field[i][j] == '#')continue;
        
        dp[i+1][j+1] = (dp[i][j+1]+dp[i+1][j])%mod;
        

    }
    cout << dp[h][w] << endl;

    

    return 0;
}

Measured memory_bytes: 9856
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;
#define rep(i,n) for(UL i=0; i<(n); i++)

int N,K;
int A[200001];

int main() {
 cin>>N>>K;
 rep(i,N) cin>>A[i];
 for(int i=K; i<N; i++){
  if(A[i]>A[i-K]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
 }
}



Measured memory_bytes: 4408
import java.util.Scanner;

public class Main{
    public static void main(String[]argc){
        Scanner sc = new Scanner(System.in);
        String word = sc.next();
        int count=0;
        while(true){
            String text = sc.next();
            if(text.equals("END_OF_TEXT")){
                break;
            }else if(text.equalsIgnoreCase(word)){
                count++;
            }
        }
        System.out.println(count);
    }
}



Measured memory_bytes: 26108
t_h, t_a, a_h, a_a = [int(i) for i in input().split()]

turn = True
while True:
    if turn:
        a_h -= t_a
    else:
        t_h -= a_a

    turn = not turn

    if a_h <= 0:
        print('Yes')
        break
    if t_h <= 0:
        print('No')
        break



Measured memory_bytes: 9180
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int d = scanner.nextInt();
        if ( Math.abs(a - c) <= d || (Math.abs(a - b) <= d && Math.abs(b - c) <= d)) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function permutation(a,n)
	ans = Array{Int,1}[copy(a)]
	c = ones(Int,n)
	i = 1
	while i<=n
		if c[i]<i
			if i%2==1
				tmp = a[1]
				a[1] = a[i]
				a[i] = tmp
			else
				tmp = a[c[i]]
				a[c[i]] = a[i]
				a[i] = tmp
			end
			c[i] += 1
			i = 1
			push!(ans,copy(a))
		else
			c[i] = 1
			i += 1
		end
	end
	ans
end

function main()
    n,m,rn = readline() |> split |> parseMap
    r = readline() |> split |> parseMap
    d = 10^18*ones(Int,n,n)
    for i in 1:n
        d[i,i] = 0
    end
    for i in 1:m
        a,b,c = readline() |> split |> parseMap
        d[a,b] = c
        d[b,a] = c
    end
    for i in 1:n
        for j in 1:n
            for k in 1:n
                d[i,j] = min(d[i,j],d[i,k]+d[k,j])
            end
        end
    end
    for i in 1:n
        for j in 1:n
            for k in 1:n
                d[i,j] = min(d[i,j],d[i,k]+d[k,j])
            end
        end
    end

    prm = permutation(r,rn)
    minim = 10^18
    for i in 1:length(prm)
        x = 0
        for j in 2:rn
            x += d[prm[i][j-1],prm[i][j]]
        end
        minim = min(minim,x)
    end
    println(minim)
end
main()

Measured memory_bytes: 133252
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e3+10;
const int mod=1e9+7;
char s[maxn];
int n,m,f[maxn][maxn],R[maxn],sum[maxn][2];
void check(int &a,int b) 
{
	a=a+b>=mod?a+b-mod:a+b;
}
int main() 
{
	cin>>n>>m;
	cin>>s+1;
	n=strlen(s+1);
	for(int i=1;i<=n;i++) 
	{
		R[i]=i;
		sum[i][0]=sum[i-1][0];
		sum[i][1]=sum[i-1][1];
		sum[i][s[i]-'0']++;
	}
	for(int i=1;i<=m;i++) 
	{
		int l,r;
		cin>>l>>r;
		R[l]=max(R[l],r);
	}
	for(int i=2;i<=n;i++) 
	{
		R[i]=max(R[i],R[i-1]);
	}
	f[0][0]=1;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<=i;j++) 
		{
			if(!f[i][j]) continue;
			if(j<sum[R[i+1]][0]) 
			{
				check(f[i+1][j+1],f[i][j]);
			}
			if(i-j<sum[R[i+1]][1]) 
			{
				check(f[i+1][j],f[i][j]);
			}
		}
	}
	cout<<f[n][sum[n][0]];
}

Measured memory_bytes: 33920
#include<stdio.h>
#define N 100
int main(){
	int n,i,j,min,hoge,a[N],cnt = 0;;
	scanf("%d",&n);
	for(i = 0; i < n; i++) scanf("%d",&a[i]);
	for(i = 0; i < n; i++){
		min = i;
		for(j = i; j < n; j++){
			if(a[j] < a[min]) min = j;
		}
		
			hoge = a[i];
			a[i] = a[min];
			a[min] = hoge;
			if(hoge != a[i]) cnt++;
		
	}
	for( i = 0; i < n; i++) {
		printf("%d",a[i]);
		if(i == (n-1) ) break;
		printf(" ");
	}
	printf("\n%d\n",cnt);
	return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[214514][3];
int main() {
	string s;
	cin>>s;
	dp[0][1]=1;
	dp[1][1]=2;
	dp[1][2]=1;
	if(s[0]==s[1])dp[1][1]=1;
	for(int i=2;i<s.size();i++){
		dp[i][1]=dp[i-1][2]+1;
		if(s[i]!=s[i-1])dp[i][1]=max(dp[i][1],dp[i-1][1]+1);

		dp[i][2]=dp[i-2][1]+1;
		if(i>2&&s.substr(i-1,2)!=s.substr(i-3,2))dp[i][2]=max(dp[i][2],dp[i-2][2]+1);
	}
	cout<<max(dp[s.size()-1][1],dp[s.size()-1][2]);
	return 0;
}


Measured memory_bytes: 5252
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    s,t=STRM()
    print(t+s)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3060
# 二項係数を"やるだけ"にしてくれるライブラリ
MAX = 3000
MOD = 1000000007
factrial = [0]*MAX
inverse = [0]*MAX
factrial_inverse = [0]*MAX


# テーブルを作る前処理
def COMinit():
    global factrial, inverse, factrial_inverse
    factrial[0] = 1
    factrial[1] = 1
    inverse[1] = 1
    factrial_inverse[0] = 1
    factrial_inverse[1] = 1
    for i in range(2, MAX):
        factrial[i] = factrial[i-1] * i % MOD
        inverse[i] = MOD - inverse[MOD % i] * (MOD//i) % MOD
        factrial_inverse[i] = factrial_inverse[i-1] * inverse[i] % MOD


# 二項係数計算
def COM(n, k):
    global factrial, inverse, factrial_inverse
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return factrial[n] * (factrial_inverse[k] * factrial_inverse[n-k] % MOD) % MOD


# 前処理完了
COMinit()

N, K = map(int, input().split())  # 合計N個のボール, K個の青いボール, N-K個の赤いボール

for i in range(1, K+1):
    print(COM(N-K+1, i) * COM(K-1, i-1) % MOD)


Measured memory_bytes: 3696
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
#include <set>

struct Edge {
	int a, b, id;
	int other_side(int vertex) const {
		return a == vertex ? b : a;
	}
};
bool dfs(int current, int to, const std::vector<std::vector<Edge>>& nodes, std::vector<int>& bit_pattern, int s_id, std::vector<bool> &is_searching) {
	if (current == to) return true;
	if (is_searching[current]) return false;
	is_searching[current] = true;
	for (const auto e : nodes[current]) {
		if (dfs(e.other_side(current), to, nodes, bit_pattern, s_id, is_searching)) {
			bit_pattern[e.id] |= 1 << s_id;
			return true;
		}
	}
	return false;
}
int main(void) {
	int n; std::cin >> n;
	std::vector<Edge> edges(n - 1);
	std::vector<std::vector<Edge>> nodes(n);
	for (auto i = 0; i < edges.size(); ++i) {
		auto& e = edges[i];
		e.id = i;
		std::cin >> e.a >> e.b;
		--e.a; --e.b;
		nodes[e.a].push_back(e);
		nodes[e.b].push_back(e);
	}
	int m; std::cin >> m;
	std::vector<int> bit_pattern(n - 1, 0);
	std::vector<bool> is_searching(n, false);
	for (auto i = 0; i < m; ++i) {
		std::fill(is_searching.begin(), is_searching.end(), false);
		int u, v;
		std::cin >> u >> v; --u; --v;
		dfs(u, v, nodes, bit_pattern, i, is_searching);
	}
	std::vector<long long int> pattern(1 << m, 0); pattern[0] = 1;
	for (const auto b : bit_pattern) {
		for (int i = pattern.size() - 1; i >= 0; --i) {
			pattern[i | b] += pattern[i];
		}
	}
	std::cout << pattern.back() << std::endl;
}


Measured memory_bytes: 9080
#include <iostream>
#include <vector>
#include <math.h>
#include <string.h>
#include <stdio.h>
#include <algorithm>

using namespace std;
using ll = long long;

int main(){
    int n;
    cin>>n;
    int a1 = 0,  a2 = 0;
    ll cnt = 0;
    for(int i = 0; i<n;i++){
        cin>>a2;
        if(a2<a1){
            cnt += a1-a2;
        }else{
            a1 = a2;
        }
    }
    cout<<cnt<<endl;
    return 0;
}  


Measured memory_bytes: 3600
#include "bits/stdc++.h"
using namespace std;
#ifdef ONLINE_JUDGE
#define trace(...)
#endif

using LL = long long;
using PII = pair<int, int>;

queue<int> Q[1000];
int lst[1000];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n - 1; j++) {
			int x; cin >> x;
			Q[i].push(x - 1);
		}
	}

	queue<PII> play;
	for (int i = 0; i < n; i++) {
		int j = Q[i].front();
		if (Q[j].front() == i && j > i) play.emplace(i, j);
	}

	int tot = (n * (n - 1)) / 2;
	int ans = 0;
	while (tot--) {
		if (play.empty()) break;
		int u, v; tie(u, v) = play.front(); play.pop();
		lst[u] = lst[v] = max(lst[u], lst[v]) + 1;
		ans = max(ans, lst[u]);
		
		for (int w: {u, v}) {
			Q[w].pop();
			if (!Q[w].empty()) {
				int ww = Q[w].front();
				if (Q[ww].front() == w) {
					play.emplace(w, ww);
				}
			}
		}
	}

	if (tot > 0) ans = -1;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4736