akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n; cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    ll mx = 0;
    rep(i,n-1){
        REP(j,i+1,n){
            mx = max(mx, abs(a[i]-a[j]));
        }
    }
    cout << mx << endl;
}

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

#define rep(i,n) for(int i=1; i<=n; i++)
using namespace std;

unsigned eu_gcd(unsigned a, unsigned b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

int main() {

    long int K, g1, g2, sum=0;
    cin >> K;

    rep(a,K) {
        rep(b,K) {
            g1 = eu_gcd(a,b);
            rep(c,K) {
                g2 = eu_gcd(g1, c);
                sum += g2;
            }
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3624
s = list(input())

for i in range(len(s)):
    if i == 0:
        s.pop()
    elif len(s) % 2 == 0:
        if s[:len(s)//2] == s[len(s)//2:]:
            print(len(s))
            break
        else:
            s.pop()
    else:
        s.pop()

Measured memory_bytes: 9096
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static int calc_abs_diff (char *s) {
    char    num_str[4];
    int     num;

    /* prepare target number string */
    strncpy(num_str, s, 3);
    num_str[3] = '\0';

    num = strtol(num_str, NULL, 10);
    return abs(num - 753);
}

int main (void) {
    int     i;
    int     ans;
    int     min_diff = INT_MAX;
    int     s_len;
    char    s[11];
    scanf("%s", s);

    s_len = strlen(s);
    for ( i=0; i<s_len-2; i++ ) {
        ans = calc_abs_diff(&s[i]);
        if ( ans < min_diff )
            min_diff = ans;
        else
            ans = min_diff;
    }

    printf("%d\n", ans);
    return EXIT_SUCCESS;
}


Measured memory_bytes: 128
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

const int maxn = 410000;

int n,m,s[maxn];
int li[maxn],ri[maxn],cnt;
struct node{int x,i;}a[maxn<<1]; int tot;
inline bool cmp(const node x,const node y){return x.x<y.x;}

ll qs; int num;
ll re;

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&s[i]);
	for(int i=2;i<=n;i++)
	{
		if(s[i]>s[i-1])
		{
			li[++cnt]=s[i-1],ri[cnt]=s[i]; re+=s[i]-s[i-1];
			a[++tot]=(node){li[cnt]+1,cnt};
			a[++tot]=(node){ri[cnt]+1,cnt};
		}
		else
		{
			li[++cnt]=s[i-1],ri[cnt]=m; re+=m-s[i-1];
			a[++tot]=(node){li[cnt]+1,cnt};
			a[++tot]=(node){ri[cnt]+1,cnt};
			
			li[++cnt]=-(m-s[i-1]),ri[cnt]=s[i]; re+=s[i];
			a[++tot]=(node){li[cnt]+1,cnt};
			a[++tot]=(node){ri[cnt]+1,cnt};
		}
	}
	sort(a+1,a+tot+1,cmp);
	
	qs=0; num=0;
	int now=1;
	ll ans=LLONG_MAX;
	for(int i=1;i<=m;i++)
	{
		while(now<=tot&&a[now].x<=i)
		{
			int ii=a[now].i;
			int cc=(ri[ii]+1==a[now].x?1:0);
			if(!cc) num++,qs+=(ll)li[ii];
			else num--,qs-=(ll)li[ii];
			now++;
		}
		ans=min(ans,re-(ll)num*i+qs+(ll)num);
	}
	printf("%lld\n",ans);
	
	return 0;
}


Measured memory_bytes: 8448
#include <iostream>
#include <algorithm>
#define MAX 10
#define INF 9999999

using namespace std;

int v[MAX + 1];
int road[MAX + 1][MAX + 1];
bool visit[MAX + 1];
int n,mn,MN,Max;

int dij(int now){

  fill( v , v + MAX + 1 , INF );
  fill( visit , visit + MAX + 1 , false );
  v[now] = 0;
  
  while(1){
    
    MN = INF;
    for( int i = 0 ; i <= Max ; i++ ){
      if( !visit[i] && v[i] < MN ){
	MN = v[i];
	mn = i;
      }
    }
    if( MN == INF ) break;
    visit[mn] = true; 
    
    for( int i = 0 ; i <= Max ; i++ ){
      int t = road[mn][i] + v[mn];
      v[i] = min( v[i] , t );
    }
  }
  
  int total = 0;
  for(int i = 0 ; i <= Max ; i++) 
    total += v[i]; 
  
  return total;
}

int main(void){

  while( cin >> n , n ){

    for(int i = 0 ; i <= MAX ; i++)
      for(int j = 0 ; j <= MAX ; j++)
	road[i][j] = INF;

    int a,b,c; 
    Max = 0;
    for(int i = 0 ; i < n ; i++){
      cin >> a >> b >> c;
      road[a][b] = c;
      road[b][a] = c;
      Max = max( Max , max(a,b) );
    } 
    
    int ans = INF;
    int ansnum;
    for(int i = 0 ; i < Max ; i++){
      int ANS = dij(i);
      if( ans > ANS ){ 
	ans = ANS;
	ansnum = i;
      }
    }
    cout << ansnum << " " << ans << endl;
    }
  return 0;
}

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

#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;

priority_queue <ll> pq;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	ll z,x;
	cin>>z>>x;
	
	for(int q=1;q<=z;q++){
		ll a;
		cin>>a;
		pq.push(a);
	}
	
	while(x--){
		int temp=pq.top();
		pq.pop();
		temp/=2;
		pq.push(temp);
	}
	long long ans=0;
	while(!pq.empty()){
		ans+=pq.top();
		pq.pop();
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		
		if(n % 2 == 0) {
			for(int i = n - 1; i > 0; i -= 2) {
				System.out.print(a[i] + " ");
			}
			for(int i = 0; i < n; i += 2) {
				System.out.print(a[i] + " ");
			}
		} else {
			for(int i = n - 1; i >= 0; i -= 2) {
				System.out.print(a[i] + " ");
			}
			for(int i = 1; i < n; i += 2) {
				System.out.print(a[i] + " ");
			}
		}
	}
}


Measured memory_bytes: 95008
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N,c,q=0,z=1e9+7;
  cin >>N;
  vector<int> C(N,0);
  for(int i=0; i<N; i++){
    cin >>c;
    C[i]=c;
  }
  if(N==1){
    q=C[0]*2%z;
  }
  else{
    sort(C.begin(), C.end());
    for(int i=0; i<N; i++){
      q+=(N+1-i)*C[i];
      q%=z;
    }
    for(int i=0; i<2*N-2; i++){
      q*=2;
      q%=z;
    }
  }
  cout <<q <<endl;
}

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

using T = tuple<ll, ll, ll, ll>;

int main() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    ll a[x], b[y], c[z];
    for (int i = 0; i < x; i++) cin >> a[i];
    for (int i = 0; i < y; i++) cin >> b[i];
    for (int i = 0; i < z; i++) cin >> c[i];
    sort(a, a + x, greater<ll>());
    sort(b, b + y, greater<ll>());
    sort(c, c + z, greater<ll>());
    map<T, int> mp;
    priority_queue<T> que;
    que.push(T(a[0] + b[0] + c[0], 0, 0, 0));
    for (int i = 0; i < k; i++) {
        T t = que.top(); que.pop();
        cout << get<0>(t) << endl;
        ll j = get<1>(t), l = get<2>(t), r = get<3>(t);
        if (j + 1 < x && mp[T(a[j + 1] + b[l] + c[r], j + 1, l, r)] == 0) {
            que.push(T(a[j + 1] + b[l] + c[r], j + 1, l, r));
            mp[T(a[j + 1] + b[l] + c[r], j + 1, l, r)]++;
        }
        if (l + 1 < y && mp[T(a[j] + b[l + 1] + c[r], j, l + 1, r)] == 0) {
            que.push(T(a[j] + b[l + 1] + c[r], j, l + 1, r));
            mp[T(a[j] + b[l + 1] + c[r], j, l + 1, r)]++;
        }
        if (r + 1 < z && mp[T(a[j] + b[l] + c[r + 1], j, l, r + 1)] == 0) {
            que.push(T(a[j] + b[l] + c[r + 1], j, l, r + 1));
            mp[T(a[j] + b[l] + c[r + 1], j, l, r + 1)]++;
        }
    }
}

Measured memory_bytes: 4184
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  int i,count=1;
  for(i=0;i<n-1;i++)
  {
  	if(s[i]!=s[i+1])
  	count++;
  }
  cout<<count;
  return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>

int main()
{
	int h[100];
	int n;
	int max = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", h + i);
		if (max < h[i])
		{
			max = h[i];
		}
	}

	int ans = 0;
	for (int i = 1; i <= max; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			if (h[j] >= i)
			{
				while (j < n && h[j] >= i)
				{
					j++;
				}
				ans++;
			}
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define MAXN 100005
using namespace std;

int N, K, P[3], dp[2*MAXN][4];
vector<int> S;


int main () {
  scanf("%d%d",&N,&K);
  for (int i=0;i<3;++i) scanf("%d",&P[i]);
  for (int i=0;i<N;++i) {
    char c;
    scanf(" %c",&c);
    if (c == 'r') S.push_back(0);
    if (c == 's') S.push_back(1);
    if (c == 'p') S.push_back(2);
  }
  for (int i=N-1;i>=0;--i)
    for (int a=0;a<=3;++a) {
      dp[i][a] = dp[i+K][3];
      int m = (S[i] + 2) % 3;
      if (m != a)
        dp[i][a] = max(dp[i][a], P[m] + dp[i+K][m]);
      //printf("dp[%d][%d] = %d\n", i, a, dp[i][a]);
    }
  int ans = 0;
  for (int i=0;i<K;++i) ans += dp[i][3];
  printf("%d\n",ans);
}


Measured memory_bytes: 2296
n = list(map(int, input().split()))
if n[0] == 0:
    print(1)
elif n[1] == 0:
    print(2)
elif n[2] == 0:
    print(3)
elif n[3] == 0:
    print(4)
elif n[4] == 0:
    print(5)

Measured memory_bytes: 9060
#include <bits/stdc++.h>
#define PCI(X) __builtin_popcount((X))
#define PCL(X) __builtin_popcountll((X))
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (ll I = (A); I < (B); ++I)
#define REPC(I, A, B, C) for (ll I = (A); I < (B); I = I + (C))
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VB vector<bool>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second

#define VVI vector<vector<int> >
#define VVPII vector<vector<pair<int,int> > >

typedef long long ll;
using namespace std;

// link: 

void boost()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // cout << fixed << setprecision(10);
}


void solve()
{
    int n;
    cin >> n;
    cout << 1000*(n % 1000 != 0) - n % 1000;
}

int main()
{
    boost();
    int T;
    T = 1;
    
    while (T--) {
    	solve();
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    int a,b,m;
    cin >> a >> b >> m;
    vector<long> pa(a);
    vector<long> pb(b);
    rep(i,a) cin >> pa.at(i);
    rep(i,b) cin >> pb.at(i);
    long ans = 1e15;
    rep(i,m){
        long x,y,c;
        cin >> x >> y >> c;
        x--;y--;
        long tmp = pa.at(x) + pb.at(y) - c;
        ans = min(ans,tmp);
    }
    long ma = 1e6;
    long mb = 1e6;
    rep(i,a){
        ma = min(ma,pa.at(i));
    }
    rep(i,b){
        mb = min(mb,pb.at(i));
    }
    cout << min(ans,ma+mb) << endl;
}

Measured memory_bytes: 1792
class UnionFind:
    def __init__(self, size):
        self.parent = [-1 for i in range(size)]#非負なら親ノード，負ならグループの要素数

    def root(self, x): #root(x): xの根ノードを返す．
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.root(self.parent[x]) #xをxの根に直接つなぐ
            return self.parent[x]

    def merge(self, x, y): #merge(x,y): xのいるグループと$y$のいるグループをまとめる
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.parent[x] > self.parent[y]: #xの要素数がyの要素数より「小さい」とき入れ替える
            x,y=y,x
        self.parent[x] += self.parent[y] #xの要素数を更新
        self.parent[y] = x #yをxにつなぐ
        return True

    def issame(self, x, y): #same(x,y): xとyが同じグループにあるならTrue
        return self.root(x) == self.root(y)

    def size(self,x): #size(x): xのいるグループの要素数を返す
        return -self.parent[self.root(x)]

def solve():
    N, M = map(int, input().split())
    bridges = [[int(i) - 1 for i in input().split()] for i in range(M)]
    ans = [N * (N - 1) // 2]

    uf = UnionFind(N)
    for bridge in reversed(bridges):
        A, B = bridge
        if uf.issame(A, B):
            ans.append(ans[-1])
        else:
            ans.append(ans[-1] - uf.size(A) * uf.size(B))
            uf.merge(A, B)
    ans.pop(-1)
    return '\n'.join(map(str, reversed(ans)))

print(solve())


Measured memory_bytes: 34272
#include <stdio.h>

int main(void)
{
	char s[101];
	int n,t,t1[26],t2[26],m=0,i,j;
	scanf("%d%s",&n,s);
	for(i=0;i<n-1;i++){
		for(j=0;j<26;j++){
			t1[j]=0;
			t2[j]=0;
		}
		t=0;
		for(j=0;j<=i;j++)t1[s[j]-'a']++;
		for(j=i+1;j<n;j++)t2[s[j]-'a']++;
		for(j=0;j<26;j++)if(t1[j]&&t2[j])t++;
		if(t>m)m=t;
	}
	printf("%d",m);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
typedef long long ll;

int n;
ll ans;
ll d[301][301];
bool did[301][301];

bool warshallfloyd(){
    for(int k = 0; k < n; k++){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(k != i && k != j && d[i][j] == d[i][k] + d[j][k] && !did[i][j]){
                    ans -= d[i][j];
                    did[i][j] = true;
                }
                if(d[i][j] > d[i][k] + d[j][k]) return false;
            }
        }
    }
    return true;
}

int main()
{
    cin >> n;
    ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> d[i][j];
            ans += d[i][j];
            did[i][j] = false;
        }
    }
    if(!warshallfloyd()){
        cout << -1 << endl;
        return 0;
    }
    cout << ans / 2 << endl;
}

Measured memory_bytes: 1024
#pragma GCC optimize("O3")   //
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, b, a) for(int i = b - 1; i >= a; i--)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef unsigned long long ull;

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);

uniform_int_distribution<> DD(0, (1ll << 31));

ll random2(){
    return (ll(DD(eng))*(1ll << 31) + ll(DD(eng))) & ((1ll << 62ll)-1);
}

ll n,m,k,q,T;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const int MAXN = 5001;



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

    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);

    ll a,b,c,d,e;

    cin >> n;
    ll ans = 1;
    ld logs = 0;
    bool zero = 0;
    rep(c1,0,n){
        cin >> a;
        ans *= a;
        if(a == 0)zero = 1;
        if(a != 0)logs += log(a);
    }

    if(zero){
        cout << "0\n";
        return 0;
    }

    //cerr << logs << " " << log(2e18) << "\n";


    if(ans > 1000000000000000000 || logs > log(2e18)){
        cout << "-1\n";
    }
    else{
        cout << ans << "\n";
    }

    return 0;
}


Measured memory_bytes: 3864
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit; int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

typedef struct Card card;

void irekae(card a[], int i,int j){

  struct Card t;

  t=a[i];
  a[i]=a[j];
  a[j]=t;

}

void merge(struct Card A[], int n, int left, int mid, int right) {
  
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;

  for (i = 0; i < n1; i++ ) L[i] = A[left + i];
  for (i = 0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for ( k = left; k < right; k++ ) {
    if ( L[i].value <= R[j].value ) {
      A[k] = L[i++];
    }
    else {

      A[k] = R[j++];

    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right) {

  int mid;

  if ( left + 1 < right ) {
    mid = (left + right) / 2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }

}

int partition(struct Card A[], int n, int p, int r) {

  int i, j;
  struct Card t, x;
  x = A[r];
  i = p - 1;
  for (j = p; j <r; j++ ) {

    if ( A[j].value <= x.value ) {
      i++;
      irekae(A,i,j);
    }
    else continue;
  }

  irekae(A,i+1,r);
  
  return i + 1;
}

void quickSort(struct Card A[], int n, int p, int r) {
  int q;
  if (p < r ) {
    q = partition(A, n, p, r);
    quickSort(A, n, p, q - 1);
    quickSort(A, n, q + 1, r);
  }
  else return;
}

void print(int stable, int n,card B[]){

  int i;

  if ( stable == 1 ) printf("Stable\n");
  else printf("Not stable\n");
  for (i = 0; i <n; i++ ) {
    printf("%c %d\n", B[i].suit, B[i].value);
  }

}

int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;
  scanf("%d", &n);
  for (i = 0; i <n; i++ ) {
    scanf("%s %d", S, &v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }
  
  mergeSort(A, n, 0, n);

  quickSort(B, n, 0, n - 1);
  for (i = 0; i < n; i++ ) {
    if ( A[i].suit != B[i].suit ) stable = 0;
  }

  print(stable,n,B);
  
  return 0;

}



Measured memory_bytes: 4108
#include <iostream>
#include <string>
#include <set>
using namespace std;
typedef long long ll;

int main() {
    int n;
    int ai;
    cin >> n;
    set<ll> seen;
    for (int i=0; i<n; i++){
        cin >> ai;
        // cout << seen[ai-1];
        if (seen.find(ai) != seen.end()){
            cout << "NO" << endl;
            return 0;
        }
        seen.insert(ai);
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 12920
#include <cstdio>
#include <string>
#include <vector>
using namespace std;


int main()
{
  char s[110];
  long long K;
  scanf("%s%lld",s,&K);
  vector<int> v;
  vector<char> c;
  for(int i=0;s[i];i++){
    if(i==0||s[i-1]!=s[i]){
      v.push_back(1);
      c.push_back(s[i]);
    }
    else{
      v[v.size()-1]++;
    }
  }
  long long ans=0;
  if(v.size()==1){
    ans=K*v[0]/2;
  }
  else{
    int T=v.size();
    for(int t=1;t<T-1;t++){
      ans+=v[t]/2*K;
    }
    if(c[0]==c[T-1]){
      ans+=v[0]/2+(v[0]+v[T-1])/2*(K-1)+v[T-1]/2;
    }
    else{
      ans+=(v[0]/2+v[T-1]/2)*K;
    }
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
void Swap(int &a,int &b)
{
	int temp = a;
	a = b;
	b = temp;
}
int main(void)
{

    int N, a[100],d=0, i, j;
	cin >> N;
    for (i = 0; i < N; i++)
        cin >> a[i];
	for (i = 0 ; i<N-1 ; i++)
		for (j =N-1; j >i ; j --)
			if(a[j]< a[j-1])
			{
				Swap(a[j], a[j-1]);
				d++;
			}
	for (i = 0; i < N; i++)
	{
		if(i<N-1)
			cout << a[i] << " ";
		else
			cout<< a[i];
	}
	cout<<endl;
	cout<<d<<endl;
    return 0;
}

Measured memory_bytes: 3088
N,K = list(map(int,input().split()))
p = list(map(int,input().split()))

lst = [0]*(N+1)
for i in range(1,N+1):
    lst[i] = lst[i-1] + 0.5*(p[i-1]+1)
ans = 0
for i in range(K,N+1):
    ans = max(ans,lst[i]-lst[i-K])

print(ans)

Measured memory_bytes: 25060
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max()/2;
const int MOD = 1e9+7;

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

    int n;cin>>n;
    string s;cin>>s;
    vector<int> west(n,0),east(n,0);
    if(s[0]=='E') east[0]=1;
    else west[0]=1;
    for(int i=1;i<n;i++){
        if(s[i]=='E'){
            west[i]=west[i-1];
            east[i]=east[i-1]+1;
        }
        else{
            west[i]=west[i-1]+1;
            east[i]=east[i-1];
        }
    }
    int res=INF;
    res=min(res,east[n-1]-east[0]);
    for(int i=1;i<n;i++){
        int tmp=0;
        tmp+=west[i-1]+(east[n-1]-east[i]);
        res=min(res,tmp);
    }
    res=min(res,west[n-2]);
    cout<<res<<endl;
}

Measured memory_bytes: 2964
#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>;

int main() {
   int n, m;
   cin >> n >> m;
   vector<pair<ll, ll>> choku(n);
   rep(i, n){
      cin >> choku[i].first >> choku[i].second;
   }
   sort(choku.begin(), choku.end());
   /*rep(i, n){
      cout << choku[i].first << " " << choku[i].second << endl;
   }*/
   ll ans = 0;
   rep(i, n){
      if(choku[i].second < m){
         ans += choku[i].first * choku[i].second;
         m -= choku[i].second;
      }else{
         ans += choku[i].first * m;
         cout << ans << endl;
         return 0;
      }
   }
   return 0;
}

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

int main() {
    // 'W': 左，'E': 右
    int n; cin >> n;
    string s; cin >> s;

    vector<int> cl(n);
    int cntl = 0;
    for (int i=0; i<n; ++i) {
        if (s[i] == 'W') {
            ++cntl;
        }
        cl[i] = cntl;
    }

    vector<int> cr(n);
    int cntr = 0;
    for (int i=0; i<n; ++i) {
        if (s[n-1-i] == 'E') {
            ++cntr;
        }
        cr[n-1-i] = cntr;
    }

    vector<int> res(n);
    for (int i=0; i<n; ++i) {
        if (i == 0) res[0] = cr[1];
        else if (i == n-1) res[n-1] = cl[n-2];
        else res[i] = cl[i-1] + cr[i+1];
    }
    sort(res.begin(), res.end());
    cout << res[0] << endl;
}

Measured memory_bytes: 4228
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main(){
    
    int P,Q,R;
    int a,b,c,ans;

    cin >> P>>Q>>R;

    a=P+Q;
    b=Q+R;
    c=R+P;

    ans=min(a,b);
    ans=min(ans,c);

    cout << ans <<endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define debug(output) cout<<#output<<"= "<<output<<endl

using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}
long long myPow(int x,int n){
    lint res=1;
    lint cur=x;
    while(n>0){
        if(n&1){
            res*=cur;
        }
        n/=2;cur*=cur;
    }
    return res;
}
signed main(){
  lint n;cin>>n;
  map<lint,int> prime;
  lint bbuf=n*2;
  for(int i=2;i*i<=n*2;++i){
    while(bbuf%i==0){
      bbuf/=i;
      prime[i]+=1;
    }
  }
  if(bbuf>1)prime[bbuf]+=1;
  vector<pair<lint,int>> primes;
  for(auto& val:prime){
    primes.push_back({val.first,val.second});
  }
  lint num=primes.size();
  lint res=inf;
  for(lint bit=0;bit<(1<<num);++bit){
    lint a=1;lint b=1;
    lint buf=inf;
    lint x,y;
    for(int i=0;i<num;++i){
      if(bit&(1<<i)){
        a*=myPow(primes[i].first,primes[i].second);
      }
      else{
        b*=myPow(primes[i].first,primes[i].second);
      }
    }
    if(a==1){
      res=min(res,b-1);
      continue;
    }
    if(b==1){
      res=min(res,a-1);
      continue;
    }
    extGCD(a,b,x,y);
    if(x>0){
      while(x>b){
        x-=b;y+=a;
      }
      buf=min(buf,min(abs(a*x),abs(b*(-y))));
      x-=b;y+=a;
      buf=min(buf,min(abs(a*x),abs(b*y)));
    }
    else{
      while(x<-b){
        x+=b;y-=a;
      }
      buf=min(buf,min(abs(a*x),abs(b*(-y))));
      x+=b;y-=a;
      buf=min(buf,min(abs(a*x),abs(b*y)));
    }
    if(buf==0)continue;
    res=min(res,buf);
  }
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 3620
from math import sqrt
from math import log10
n=int(input())

i=1
ans=13
j=0

while i<=sqrt(n):
    if n%i==0:
        j=n//i
        ans=int(min(ans,max(log10(i)+1,log10(j)+1)))
    i+=1
if j==0:
    ans=int(max(log10(i)+1,log10(j)+1))
print(ans)
    



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	string S;
  	cin >> S;
  	string ans = "yes";
  	for(int i = 0; i < S.size(); i++){
    	for(int j = i + 1; j < S.size(); j++){
        	if(S[i] == S[j]){
            	ans = "no";
            }
        }
    }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		boolean[] list = new boolean[10];
		for(int i = 0; i < k; i++){
		    int d = sc.nextInt();
		    list[d] = true;
		}
		
		// 計算
		//String result = "NO";
		while(true){
		    String s = Integer.toString(n);
		    for(int i = 0; i < s.length(); i++){
		        int j = s.charAt(i)-'0';
		        if(list[j]) break;
		        if(i == s.length()-1){
		            System.out.println(n);
		            return;
		        }
		    }
		    n++;
		}
		
		// 出力
		//System.out.println(result);
	}
	
	public static class Scanner {
		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());}
	}
}



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

from collections import deque

q = deque()

h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())

ch -= 1
cw -= 1
dh -= 1
dw -= 1

# mylist = [[]]
ban_list = [[-1 for j in range(w)] for i in range(h)]
cost_list = [[-1 for j in range(w)] for i in range(h)]

# print(mylist)

for i in range(h):
  # 文字列の入力
  s = input()
  for j in range(len(s)):
    ban_list[i][j] = s[j]

ban_list[ch][cw] = 0
# cost_list[ch][cw] = 0

cost = 0
ph = ch
pw = cw

q.append([ph, pw])


# # 最後デバッグ
# for li in ban_list:
#   print(li)



loop = True
while loop:
  # print(len(q))
  ph, pw = q.popleft()
  cost = ban_list[ph][pw]

  # print(ph, pw)
  # print(cost)
  # 上
  if ph == 0:
    pass
  else:
    if ban_list[ph-1][pw] != "#" and ban_list[ph-1][pw] != cost:
      if ban_list[ph-1][pw] == "." or cost < ban_list[ph-1][pw]:
        ban_list[ph-1][pw] = cost
        # appendだとrandom_02.txtがWAになる
        q.appendleft([ph-1, pw])
    else:
      pass

  # 右
  if pw == w -1:
    pass
  else:
    if ban_list[ph][pw + 1] != "#" and ban_list[ph][pw + 1] != cost:
      if ban_list[ph][pw + 1] == "." or cost < ban_list[ph][pw + 1]:
        ban_list[ph][pw + 1] = cost
        q.appendleft([ph, pw+1])
    else:
      pass

  # 下
  if ph == h -1:
    pass
  else:
    if ban_list[ph+1][pw] != "#" and ban_list[ph+1][pw] != cost:
      if ban_list[ph+1][pw] == "." or cost < ban_list[ph+1][pw]:
        ban_list[ph+1][pw] = cost
        q.appendleft([ph+1, pw])
    else:
      pass

  # 左
  if pw == 0:
    pass
  else:
    if ban_list[ph][pw - 1] != "#" and ban_list[ph][pw - 1] != cost:
      if ban_list[ph][pw - 1] == "." or cost < ban_list[ph][pw - 1]:
        ban_list[ph][pw - 1] = cost
        q.appendleft([ph, pw-1])
    else:
      pass


  # ジャンプ--------------
  for i in range(-2, 3):
    if (ph + i < 0) or (h - 1 < ph + i):
      continue

    for j in range(-2, 3):
      if (pw + j < 0) or (w - 1 < pw + j) or (i==0 and j == 0) or (i==0 and j == -1) or (i==0 and j == 1) or (i==-1 and j == 0) or (i==1 and j == 0):
        continue
      if ban_list[ph + i][pw + j] == ".":
        # print(ph, pw)
        # print(i, j)
        # print(cost)
        ban_list[ph + i][pw + j] = cost + 1
        q.append([ph + i, pw + j])

  if len(q) == 0:
    loop = False


result = ban_list[dh][dw]
if result == ".":
  result = -1

# # 最後デバッグ
# for li in ban_list:
#   print(li)

print(result)


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

using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using f64 = double;
using f80 = long double;

#define FOR(v, a, b) for(i64 v = (a); v < (b); ++v)
#define FORE(v, a, b) for(i64 v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(i64 v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T> void pout(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void pout(const T &value, const Args&... args){std::cout << value << " ";pout(args...);}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;




int main(){
  int N;
  string S;

  while(cin >> N >> S){
    i64 ans = 0;

    vector<int> r(N+1), g(N+1), b(N+1);

    REP(i,N){
      if(S[i] == 'R') r[i+1] = 1;
      if(S[i] == 'G') g[i+1] = 1;
      if(S[i] == 'B') b[i+1] = 1;
    }

    REP(i,N){
      r[i+1] += r[i];
      g[i+1] += g[i];
      b[i+1] += b[i];
    }

    dump(r,g,b);
    

    

    REP(i,N){
      FOR(k,i+2,N){
        if(S[i] == S[k]) continue;

        if(S[i] != 'R' and S[k] != 'R'){
          if((i+k) % 2 == 0 and S[(i+k)/2] == 'R') ans -= 1;
          ans += r[k] - r[i+1];
        }

        if(S[i] != 'G' and S[k] != 'G'){
          if((i+k) % 2 == 0 and S[(i+k)/2] == 'G') ans -= 1;
          ans += g[k] - g[i+1];
        }

        if(S[i] != 'B' and S[k] != 'B'){
          if((i+k) % 2 == 0 and S[(i+k)/2] == 'B') ans -= 1;
          ans += b[k] - b[i+1];
        }
        
      }
    }
    


    pout(ans);
  }

  return 0;
}


Measured memory_bytes: 3692
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int N, X, Y;
	cin >> N >> X >> Y;
	vector<int> ans(N);
	for (int i = 1; i <= N - 1; i++) {
		vector<int> dist(N + 1);
		for (int j = i + 1; j <= N; j++) dist[j] = min(j - i, abs(X - i) + 1 + abs(Y - j));
		for (int j = i + 1; j <= N; j++) ans[dist[j]]++;
	}
	for (int i = 1; i <= N - 1; i++) cout << ans[i] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(hoge) hoge.begin(),hoge.end()
const long long INF = 1LL << 60;


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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {//降順second
	if (a.second != b.second) {
		return a.second > b.second;
	}
	else {
		return a.first > b.first;
	}
}

bool compare_by_a(pair<ll, ll> a, pair<ll, ll> b) {//降順first
	if (a.first != b.first) {
		return a.first > b.first;
	}
	else {
		return a.second > b.second;
	}
}

ll gcd(ll m, ll n){
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd


int main() {
	ll n;
	cin >> n;
	vector<ll> x(n);
	rep(i, n) {
		cin >> x[i];
	}
	sort(all(x));
	ll max = 0;
	ll num = 0;
	rep(i, n - 1) {
		if (x[i] < x[n - 1] - x[i]) {
			if (max < x[i]) {
				max = x[i];
				num = x[i];
			}
		}
		else {
			if (max < x[n - 1] - x[i]) {
				max = x[n - 1] - x[i];
				num = x[i];
			}
		}
	}
	cout << x[n - 1] << ' ' << num;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long int
#define mi map<int,int>
#define mcr map<char,int>
using namespace std;

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

    return 0;
}


Measured memory_bytes: 3632
package main

import (
	"fmt"
)

func main() {
	var s string
	var cnt int
	fmt.Scan(&s)
	
	for i := 0; i <len(s); i++ {
		for j := i+1; j < len(s); j++ {
			if s[i] == s[j] {
				cnt++
			}
		}
	}
	if cnt == 2 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

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

int main(){
    string s;
    cin >> s;
    int i;
    string res = "Yes";
    int len = s.length()/2;
    for(i = 0; i < len; i++){
        if(s[i] != s[s.length()-1-i]) res = "No";
    }
    
    for(i = 0; i < len/2; i++){
        if(s[i] != s[len-1-i]) res = "No";
    }
    
    for(i = 0; i < len/2; i++){
        if(s[i+len+1] != s[s.length()-1-i]) res = "No";
    }
    
    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int A,B;
    cin >> A >> B;
    if(B==1) cout << 0 << endl;
    else if(A>=B) cout << 1 << endl;
    else{
        int cnt = 1;
        B = B-A;
        while(B>0){
            cnt++;
            B -= (A-1);
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n;
  while(  cin >> n,n ){
  int b,t[10000] = {0};
    for(int i = 0 ; i < n ; i++ ){
      cin >> b;
      ++t[b];
    }
    for(int i = 0 ; i <= 9 ; i++ ){
	if(t[i] == 0)cout << '-';
      for(int j = 1 ; j <= t[i]; j++ ){
	cout << '*';
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 1196
while True:
    

    n,l,r = map(int,input().split())

    ans = 0

    if n == 0 and l == 0 and r == 0:
        break

    A = []

    for i in range(n):

        a = int(input())

        A.append(a)


    for x in range(r-l+1):

        x += l

        #print (x)

        for i in range(len(A)):

            
            flag = True

            if x % A[i] == 0:

                if i % 2 == 0:
                    ans += 1
                   # print (x,"は",A[i],i)


                #print (x,"はだめ",A[i],i)
                flag = False
                break

        if flag and len(A) % 2 == 0:

            #print (x , "x")

            ans += 1


    print (ans)


Measured memory_bytes: 5600
while True:
    try:
        x1,y1,x2,y2,x3,y3,x4,y4 = map(float,input().split())
    except EOFError:
        break

    if (x4 < x1 or x2 < x3) or (y4 < y1 or y2 < y3):
        print('NO')
    else:
        print('YES')

Measured memory_bytes: 7248
import sys

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
S = S()
ans = N
for i in range(N-1):
    if S[i] == S[i+1]:
        ans -= 1

print(ans)

Measured memory_bytes: 39280
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	ll n;cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	vector<ll> t;
	for(int i=0;i<n-1;i++){
		t.push_back(a[i]^a[i+1]);
	}
	ll ans=0;
	for(int i=0;i<t.size();i+=2){
		ans=ans^t[i];
	}
	for(int i=0;i<n;i++){
		ll r=ans^a[i];
		cout<<r<<" ";
	}
}


Measured memory_bytes: 6760
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
a = 0
while a <= A:
    b = 0
    while b <= B:
        c = 0
        while c <= C:
            if 500*a+100*b+50*c == X:
                count+=1
            else:
                pass
            c+=1
        b+=1
    a+=1
print(count)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W ,&H ,&x ,&y ,&r);
	if(((x+r)>W)||((x-r)<0)){
		printf("No\n");
	}
	else if(((y+r)>H)||((y-r)<0)){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
	return 0;
}


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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    H=LI()
    
    now=0
    
    for i in range(N):
        if H[i]!=now:
            H[i]-=1
        now=H[i]
    
    flag=1
    now=0
    for i in range(N):
        if H[i]<now:
            flag=0
            break
        now=H[i]
        
    if flag:
        print("Yes")
    else:
        print("No")
            

main()


Measured memory_bytes: 84604
#include <iostream>
#include <vector>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>
#include <climits>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <bitset>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (n); ++i)
#define InitRep(i, begin, n) for (int i = (begin); i < (n); ++i)
#define RepItr(it, begin, end) for (auto it = (begin); it != (end); ++it)
using int64 = long long;
using vint = vector<int>;
using vint64 = vector<int64>;
const static double PI = ::acos(-1);

constexpr int64 MOD = 1000000007;


int64 getGCD(int64 a, int64 b)
{
    if (a < b)
    {
        return getGCD(b, a);
    }

    if (b == 0)
    {
        return a;
    }

    return getGCD(b, a % b);
}

int main()
{
    int64 a, b;
    cin >> a >> b;

    int64 gcd = getGCD(a, b);
    cout << (a * b / gcd) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
const ll INF = 100000000000000000;

int main(){
    int h,w;
    cin>>h>>w;
    char s[h][w];
    rep(i,0,h-1){
        rep(j,0,w-1){
            cin>>s[i][j];
        }
    }
    rep(i,0,h-1){
        rep(j,0,w-1){
            if(s[i][j]=='#'){
                if(s[i-1][j]!='#'&&s[i+1][j]!='#'&&s[i][j-1]!='#'&&s[i][j+1]!='#'){
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

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

int main() {
  string s[12]={"C","C#","D","D#","E","F","F#","G","G#","A","A#","B"};
  string t[5]={"","7","M7","m","m7"};
  string r[11]={"","-9","9","+9","-11","11","+11","","-13","13","+13"};
  int d[5][4]={{0,4,7,-1},{0,4,7,10},{0,4,7,11},{0,3,7,-1},{0,3,7,10}};
  int T;
  cin >> T;
  while(T--) {
    int n;
    cin >> n;
    vector<int> a(12,0);
    for(int i=0; i<n; i++) {
      string e;
      cin >> e;
      for(int j=0; j<12; j++) {
        if(s[j]==e) {
          a[j]=1;
          break;
        }
      }
    }
    vector<string> ans;
    for(int i=0; i<12; i++) {
      for(int j=0; j<5; j++) {
        vector<int> b(12,0);
        for(int k=0; k<4; k++) {
          if(d[j][k]==-1) break;
          b[(i+d[j][k])%12]=1;
        }
        if(a==b) {
          ans.push_back(s[i]+t[j]);
          continue;
        }
        for(int k=1; k<11; k++) {
          if(k==7) continue;
          int x=b[(i+k)%12];
          b[(i+k)%12]=1;
          if(a==b) ans.push_back(s[i]+t[j]+"("+r[k]+")");
          b[(i+k)%12]=x;
        }
        b[(i+7)%12]=0;b[(i+6)%12]=1;
        if(a==b) ans.push_back(s[i]+t[j]+"(-5)");
        b[(i+6)%12]=0;b[(i+8)%12]=1;
        if(a==b) ans.push_back(s[i]+t[j]+"(+5)");
      }
    }
    if(ans.size()) {
      for(int i=0; i<ans.size(); i++) {
        if(i) cout << " ";
        cout << ans[i];
      }
      cout << endl;
    } else cout << "UNKNOWN" << endl;
  }
  return 0;
}

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

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

    if(a > b){
        d = a;
        a = b;
        b = d;
    }
    if(b > c){
        d = b;
        b = c;
        c = d;
    }
    if(a > b){
        d = a;
        a = b;
        b = d;
    }

    cout << a << " " << b << " " << c << endl;
    
return 0;
}

Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main(){
  string s;
  cin >> s;
  int c=0;int cn=0;bool flag=true;
  if(s[0]=='A'){
    for(int i=2;i<s.size()-1;i++){
      if(s[i]=='C'){
        c++; cn=i;
      }
    }
    if(c==1){
      for(int i=1;i<s.size();i++){
        if(i==cn) continue;
        if(isupper(s[i])) flag=false;
      }
      if(flag==true) cout << "AC"<<endl;
      else cout <<"WA"<<endl;
    }
    else cout <<"WA"<<endl;
  }
  else cout <<"WA"<<endl;
}


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

struct Read{ //読み込みたい
    char c[101];
    int figure[101];
};

// isStable
bool isStable(int n, int b[], char bc[], int s[], char sc[]){   //bはBubble,SはSelect
    for(int i = 0 ; i < n;i++){
        if(i == n && b[i] != s[i] || bc[i] != sc[i]) return false;
    }
    return true;
}



int main(void){
    // Your code here!
    Read Bcards,Scards;    //BcardsはBubbleSort, ＳcardsはSelectionSort
    int n;
    cin >> n;
    
    for(int i = 0; i < n; i++){   //読み込み
        cin >> Bcards.c[i];   //H,D,Cだけ
        cin >> Bcards.figure[i];  //数値だけ
        Scards = Bcards;     //copy
    }
    
    //for(int t = 0; t < n; t++){  //書ける   試運転
    //    cout << "cards.c[" << t << "]" << cards.c[t] << endl;
    //   cout << "cards.figure[" << t << "]" << cards.figure[t] << endl;
    //}
    
    int flag = 1,i=0;
    //BubbleSort
    while(flag != 0){   
        flag = 0;
        for(int j = n-1; j > i;j--){
            if(Bcards.figure[j] < Bcards.figure[j-1]){
                swap(Bcards.figure[j],Bcards.figure[j-1]);  //数値を入れ替える
                swap(Bcards.c[j],Bcards.c[j-1]);    //H,Cとかを入れ替える
                
                flag = 1;
            }
        }
        i++;
    }
    
    int minj,si;
    // SelectionSort
    for(si = 0; si<n-1; si++){  
        minj = si;
        for(int z = si; z < n; z++){
            if(Scards.figure[z] < Scards.figure[minj]) minj = z;
        }
        if(Scards.figure[si] != Scards.figure[minj]) swap(Scards.figure[si], Scards.figure[minj]);  //数値を入れ替える
        if(Scards.c[si] != Scards.c[minj]) swap(Scards.c[si], Scards.c[minj]);   //H,Cとかを入れ替える
    
    }
    
    
    
    
    for(int t = 0; t < n; t++){  //書ける   BubbleSort試運転
        if(t == n-1) cout << Bcards.c[t] << Bcards.figure[t] ;
        else cout << Bcards.c[t] << Bcards.figure[t] << " " ;
    }
    
    
    cout << endl << "Stable" << endl;
    
    for(int t = 0; t < n; t++){  //書ける   SelectionSort試運転
        if(t == n-1) cout << Scards.c[t] << Scards.figure[t] ;
        else cout << Scards.c[t] << Scards.figure[t] << " " ;
    }
    
    if( isStable(n, Bcards.figure, Bcards.c, Scards.figure, Scards.c)) cout << endl << "Stable" << endl;
    else cout << endl << "Not stable"<< endl;
    
    
}



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

int main()
{
    int x,a,b,c,ans=0;cin>>a>>b>>c;
    for (int i=1;i<=a;++i) {
        scanf("%d",&x);
        if (x<b||x>=c) ++ans;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

use std::iter::Iterator;


fn main() {
    input!{
        a:usize,
        b:usize,
        t:usize,
    }

   println!("{}",  (t/a)*b);
}


Measured memory_bytes: 4352