akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll mod=1e9+7;

int main() {
  ll n=50;
  ll k;
  cin >> k;
  vector<ll> a(n);
  for(ll i=0;i<n;i++) {
    a[i]=i+k/n;
  }
  k%=n;
  for(ll i=0;i<k;i++) {
    a[i]+=n-(k-1);
  }
  for(ll i=k;i<n;i++) {
    a[i]-=k;
  }
  cout << n << endl;
  for(ll i=0;i<n;i++) {
    if(i!=0) cout << " ";
    cout << a[i];
  }
}

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
	string  s; cin >> s;
	s[3] = '8';
	
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <cstring>
#include <bits/stdc++.h>
#include <iostream>
#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based
#define enterarray(a,n) for(int i=0;i<(int)(n);++i)cin>>a[i];
#define ins insert
const int MOD =998244353;
const int MX = int(2e6+9);
using namespace std;
ll f[200004];
ll even(ll num){
    if(num%2==0)return 1;
    else return 0;
}
void printvector(vector<ll> v){
    ll i;
    for0(i,v.size())cout<<v[i]<<" ";
}
void solve(){
    ll n,m,i,j,k;
    ll a[200005],b[200005];
    ll ans=0,res=0;
    bool flag=true;
    string s1,s2;
    set<ll> s;
   // cin>>n;
    vector<ll> v;
   // for0(i,n)cin>>v[i];
    cin>>s1;
    for0(i,s1.length()){
        ll y;
        y=s1[i]-48;
        ans+=y;
    }
    if(ans%9)cout<<"No";
    else cout<<"Yes";

}
 
int main()
{
    FAST;
   int t;
    t=1;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
}

    

Measured memory_bytes: 3772
import sys

INPUT = lambda: sys.stdin.readline().rstrip()

sys.setrecursionlimit(10 ** 9)


def main():
    S = INPUT()

    cnt = 0
    for i in range(len(S)//2):
        if S[i] != S[-1-i]: cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()


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

class Stack{
private:
  int sp;
  int S[100];
public:
  Stack(){ sp = 0; }
  bool isFull() const{ return (sp==100);}
  bool isEmpty() const{ return (sp==0);}
  void push(int d);
  int top();
  void pop();
};

void Stack::push(int d){
  if(isFull())
   return;
  S[sp++] = d;
}

int Stack::top(){
  if(isEmpty())
   return -1;
  return S[sp-1];
}

void Stack::pop(){
  if(isEmpty())
   return;
  sp--;
}

int main(){
  Stack s;

  string expr;
  getline(cin, expr);

  istringstream is(expr);

  while(!is.eof()){
    string op;
    is >> op;

    int tmp1, tmp2;

    switch(op[0]){
    case '+':
             tmp1 = s.top(); s.pop();
             tmp2 = s.top(); s.pop();
             s.push(tmp2+tmp1);
             break;
    case '-':
             tmp1 = s.top(); s.pop();
             tmp2 = s.top(); s.pop();
             s.push(tmp2-tmp1);
             break;
    case '*':
             tmp1 = s.top(); s.pop();
             tmp2 = s.top(); s.pop();
             s.push(tmp2*tmp1);
             break;
     default:
             istringstream is2(op);
             is2 >> tmp1;
             s.push(tmp1);
             break;
     }
  }
  cout << s.top() << endl;
  return 0;
}



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

typedef map<string,priority_queue<int,vector<int>,greater<int> > >Book;

int main(){
  int value;
  string str;
  Book book;
  int flag;
  while(cin>>str>>value){
    book[str].push(value);
  }
  for(Book::iterator it=book.begin();it!=book.end();++it){
    cout<<it->first<<endl;
    flag=0;
    while(!(it->second.empty())){
      if(flag)cout<<" ";
      flag=1;
      cout<<it->second.top();
      it->second.pop();
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1244
import scala.io.StdIn._
import java.util.Scanner

object Main {
  def main(args: Array[String]) = {
    val s = new Scanner(System.in)
    val a = s.nextLong
    val b = s.nextLong
    val c = s.nextLong
    if (c - a - b > 0 && 4 * a * b < (c - a - b) * (c - a - b)) {
      println("Yes")
    } else {
      println("No")
    }
  }
}

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

#define rep(i,n)  for(int i = 0; i < (int)(n); i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

class CumulativeSum {
  private:
    int H_, W_;
    std::vector<std::vector<long long>> s;

  public:
    explicit CumulativeSum (int H, int W) : H_(H), W_(W) {
      s.resize(H+1); for(int i=0; i<=H; i++) s[i].resize(W+1);
      s[0][0] = 0;
      for(int i=0; i<=H_; i++) s[i][0] = 0;
      for(int i=0; i<=W_; i++) s[0][i] = 0;
    }

    void set(int i, int j, long long a) {
      s[i+1][j+1] = a;
      return;
    }

    void add(int i, int j, long long a) {
      s[i+1][j+1] += a;
      return;
    }

    void build() {
      for(int i=0; i<=H_; i++) for(int j=1; j<=W_; j++) s[i][j] += s[i][j-1];
      for(int i=1; i<=H_; i++) for(int j=0; j<=W_; j++) s[i][j] += s[i-1][j];
    }

    void build ( const std::vector<std::vector<long long>> &a ) {
      for(int i=1; i<=H_; i++) for(int j=1; j<=W_; j++) s[i][j] = a[i-1][j-1];
      for(int i=0; i<=H_; i++) for(int j=1; j<=W_; j++) s[i][j] += s[i][j-1];
      for(int i=1; i<=H_; i++) for(int j=0; j<=W_; j++) s[i][j] += s[i-1][j];
    }

    // h : [i,j],  w : [k,m]
    long long Get(int i, int j, int k, int m) {
      return s[j+1][m+1] - s[i][m+1] + s[i][k] - s[j+1][k];
    }
};



int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll N; std::cin >> N;
  std::vector<ll> A(N);
  rep(i,N) {
    double a; std::cin >> a;
    A[i] = std::round(a * 1e10);
  }

  std::vector<ll> two(N), five(N);
  rep(i,N) {
    ll cnt = 0;
    auto tmp = A[i];
    while( tmp % 2 == 0 ) {
      tmp /= 2;
      cnt++;
    }
    two[i] = cnt;

    cnt = 0;
    tmp = A[i];
    while( tmp % 5 == 0 ) {
      tmp /= 5;
      cnt++;
    }
    five[i] = cnt;
  }

  CumulativeSum S(62,62);
  rep(i,N) S.add(two[i], five[i], 1);
  S.build();

  ll ans = 0;
  rep(i,N) {
    ll t = two[i];
    ll f = five[i];
    ans += S.Get( std::max<int>(0,20-t), 61, std::max<int>(0,20-f), 61 );
  }
  rep(i,N) if ( two[i] >= 10 && five[i] >= 10 ) ans--;
  ans /= 2;
  std::cout << ans << std::endl;
  return 0;
}



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

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

    ll n;
    cin >> n;
    ll x[n],y[n];
    for(ll i=0;i<n;i++) {
      cin >> x[i] >> y[i];
    }

    ll res = 0, smallest, cur;
        for (int p : {1, -1}) {
            for (int q : {1, -1}) {
                smallest = p * x[0] + q * y[0];
                for (ll i = 1; i < n; ++i) {
                    cur = p * x[i] + q * y[i];
                    res = max(res, cur - smallest);
                    smallest = min(smallest, cur);
                    // cout << cur << " " << smallest << " " << res << endl;
                }
            }
        }

    cout << res ;
    return 0;
}

Measured memory_bytes: 6756
import sys
sys.setrecursionlimit(10000000)

x,n = map(int,input().split())

p = list(map(int,input().split()))


if n == 0:print(x);exit()

l=[0] * 102

for i in p:
    l[i] =1

diff=1000
ans=0
for i in range(0,102):
    if l[i] == 0 and diff > abs(x-i):
        diff= abs(x-i)
        ans=i

print(ans)


Measured memory_bytes: 9112
K, A, B = list(map(int, input().split()))
if (B - A) <= 2:
    print(K+1)
else:
    if (K - 1) < A:
        print(K+1)
    else:
        count = max(0, ((K - (A - 1)) // 2))
        print(A + count * (B - A) + (K - (A - 1)) % 2)


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
#include<vector>
#include<iomanip>
using namespace std;
typedef long long ll;
ll inf = 100000000;
ll v[205];
ll x[20000005];
ll a[10000005];
ll dp[10005][10005];
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };
typedef pair<ll, ll> P;
double q[200005];
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}
int main() {
	ll n;
	cin >> n;
	ll ans;
	cin >> ans;
	for (int i = 0; i < n; i++) {
		ll a;
		cin >> a;
		ans  = gcd(ans,a);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  char tenki[6];
  scanf("%s",tenki);
  
 if(tenki[0] == 'S')  printf("Cloudy");
 if(tenki[0] == 'C')  printf("Rainy");
 if(tenki[0] == 'R')  printf("Sunny");
}

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

using namespace std;

int main()
{
  int i;
  cin >> i;

  int a;
  auto v = vector<int>{};
  while (cin >> a)
  {
    v.push_back(a);
  }

  std::reverse(v.begin(), v.end());

  for (auto i = 0; i < v.size(); i++)
  {
    cout << v[i];
    if (i != v.size() - 1)
    {
      cout << " ";
    }
  }

  cout << std::endl;
  return 0;
}



Measured memory_bytes: 3144
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>

/* template start */

using i64 = std::int_fast64_t;
using u64 = std::uint_fast64_t;

#define rep(i, a, b) for (i64 i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...)                                                    \
  std::cerr << "LINE: " << __LINE__ << "  [" << #__VA_ARGS__ << "]:", \
      debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << std::endl; }

template <typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
  std::cerr << " " << h;
  if (sizeof...(t) > 0) std::cout << " :";
  debug_out(t...);
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b) {
  return a > b && (a = b, true);
}

template <typename Num>
constexpr Num mypow(Num a, u64 b, Num id = 1) {
  if (b == 0) return id;
  Num x = id;
  while (b > 0) {
    if (b & 1) x *= a;
    a *= a;
    b >>= 1;
  }
  return x;
}

/* template end */

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

  long double n,m,d;
  std::cin>>n>>m>>d;

  long double ans=(n-d)*(m-1)/n/n;

  std::cout<<std::setprecision(15);

  if(d!=0)std::cout<<ans*2<<"\n";
  else std::cout<<ans<<"\n";

  return 0;
}

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

int dp[1000+1][1000+1];

int main() {
    int n; cin >> n;
    while(n--) {
        string s, t; cin >> s >> t;
        int N = s.length();
        int M = t.length();
        dp[0][0] = 0;
        for(int i = 0; i < N; i++) {
            for(int j = 0; j < M; j++) {
                if(s[i] == t[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
                else dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
            }
        }
        cout << dp[N][M] << endl;
    }
}

Measured memory_bytes: 5116
using System;

namespace A
{
    class Program
    {
        static int[] fib = new int[45];

        static int func(int n)
        {
            if (fib[n] == 0) fib[n] = func(n - 1) + func(n - 2);
            return fib[n];
        }

        static void Main(string[] args)
        {
            fib[0] = 1;
            fib[1] = 1;
            Console.WriteLine(func(int.Parse(Console.ReadLine())));
        }
    }
}

Measured memory_bytes: 9120
def examD(inf):
    N, Ma, Mb = LI()
    abc = [0,0,0]*N
    maxA = 0; maxB = 0
    for i in range(N):
        abc[i] = LI()
        if maxA<abc[i][0]:
            maxA=abc[i][0]
        if maxB<abc[i][1]:
            maxB=abc[i][1]
    dp = [[[inf]*(maxB*(N+1)+1) for _ in range(maxA*(N+1)+1)]for _ in range(N+1)]
    dp[0][0][0] = 0
    for i in range(N):
        for j in range(maxA*N+1):
            for k in range(maxB*N+1):
                dp[i+1][j][k] = min(dp[i][j][k],dp[i+1][j][k])
                dp[i+1][j+abc[i][0]][k+abc[i][1]] = min(dp[i][j+abc[i][0]][k+abc[i][1]],dp[i][j][k]+abc[i][2])
#    print(dp)
    ans = inf
    for j in range(1,maxA * N+1):
        for k in range(1,maxB * N+1):
            if j%Ma==0 and k%Mb==0:
                if j//Ma==k//Mb:
                    ans = min(ans,dp[N][j][k])
    if ans==inf:
        ans = -1
    print(ans)


import sys
import copy
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD(inf)


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

#define f first 
#define s second 
#define pb push_back               
#define mp make_pair 

using namespace std;                    

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

const int N = (int)1e5 + 123, mod = (int)1e9 + 7;

ll get(ll x, ll y)
{
	if(y % x == 0)
		return (y / x * 2 - 1) * x;
	return get(y % x , x) + y / x * 2 * x;
}
int main(){    
	ll n, x;
	cin >> n >> x;
	cout << get(n - x, x) + n; 
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main (void){
    int h1,m1,h2,m2,k;
    int ans;
    scanf("%d %d %d %d %d",&h1,&m1,&h2,&m2,&k);
    ans = (h2-h1)*60 + (m2-m1) -k;
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 1732
#include<stdio.h>

void insertionSort ( int *A , int N) {
	for( int i = 1; i < N; i++) {
		int v = A[i];
		int j = i -1;
		while ( j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--; 
		}
		A[j + 1] = v;
		for( int i = 0; i < N; i++) {
	        printf("%d", A[i]);
	        if ( i != N -1 ) printf(" ");
	    }
	    printf("\n");
	}
}

int main() {
	int N, A[100+10];
	scanf("%d", &N);
	for( int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	for( int i = 0; i < N; i++) {
		printf("%d", A[i]);
		if ( i != N -1 ) printf(" ");
	}
	printf("\n");
	insertionSort( A, N );
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

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


Measured memory_bytes: 3644
n, y = map(int, input().split())
A = [10000, 5000, 1000]

ans = [-1, -1, -1]
for i in range(n + 1):
    for j in range(n - i + 1):
        if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
            ans = [i, j, n - i - j]
            break
            
print(' '.join(map(str, ans)))

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

int main(){
    string s; cin >> s;
    int len = s.length();
    for(int i = 0; i < len-8; i++){
        cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#define MAX 2000
int A[MAX], M[MAX];
int a,b,i,j,k,f=0;

int solve(int p, int t){
	if (p>=a){
		return 0;
	}

	if (t - A[p] == 0 || solve(p + 1, t - A[p]) || solve(p + 1, t) ){
		return 1;
	}
	return 0;
}


int main(){
	

	scanf("%d",&a);
	for (i = 0; i < a;i++){
		scanf("%d",&A[i]);
	}
	scanf("%d",&b);

	for (i = 0; i < b;i++){
		scanf("%d",&M[i]);
	}

	for (i = 0; i < b; i++){
		if (solve(0, M[i])){
			printf("yes\n");
		}else{
			printf("no\n");
		}
	}

	return 0;

}

Measured memory_bytes: 588
N, K = map(int, input().split())
V = [int(i) for i in input().split()]
ans = 0
for pick in range(min(N+1,K+1)):
  for right in range(pick+1):
    left = pick - right
    picklist = V[:right] + V[N-left:]
    picklist = sorted(picklist)
    ans1 = sum(picklist)
    rem = min(K-pick, len(picklist))
    for i in range(rem):
      if picklist[i] < 0:
        ans1 -= picklist[i]
      else:
        break
    ans = max(ans, ans1)
print(ans)

Measured memory_bytes: 3064
#![allow(clippy::needless_range_loop)]
#![allow(unused_macros)]
#![allow(dead_code)]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

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

fn main() {
    input! {
        n: usize,
        a: usize,
        b: usize,
        x: [usize; n],
    }
    let diff = x.iter().zip(x[1..].iter()).map(|(x, y)| y - x);
    let ans: usize = diff.map(|x| std::cmp::min(x * a, b)).sum();
    println!("{}", ans);
}


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

int main(){
  int n; cin >>n;
  map<int, int> mp;
  vector<int> a(n);
  rep(i,n) {
    cin >>a[i];
    mp[a[i]]++;
  }
  int cnt = 0;
  for(int x : a){
    if(mp[x]>x){
      cnt += mp[x]-x;
      mp[x] = x;
    }
    if(mp[x]<x){
      cnt += mp[x];
      mp[x] = x;
    }
  }
  cout << cnt << endl;
  return 0;
}

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

int main(){
    int x, a, b;
    cin >> x >> a >> b;
    string ans;
    int disa = abs(x-a);
    int disb = abs(x-b);
    if(disa < disb) ans = "A";
    else ans = "B";
    cout << ans << endl;
}

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

using namespace std;


int main()
{
   
   int n,m,sum=0,cnt=0;
   scanf("%d%d",&n,&m);
   int a[n],i;
   float ans;
   for(i=0;i<n;++i)
      { scanf("%d",&a[i]);
         sum+=a[i];
      }
       
       sort(a,a+n);
       ans=(float)sum/(4*m);
      
    for(i=n-1;i>=n-m;--i)
     {
         if(ans<=a[i])
            cnt++;
            
         else
           break;
             
     }
     if(cnt==m)
        printf("Yes");
        
     else
       printf("No");
}

Measured memory_bytes: 256
N = int(input())
S =[""]*N
R =[0]*N
for i in range(N):
    S[i], R[i] = input().split()
Ri = [0]*N
for i in range(N):
    Ri[i] = -1*int(R[i])
SR = [0]*N
for i in range(N):
    SR[i]=[S[i],Ri[i],i+1]
SR.sort()
for i in range(N):
    print(SR[i][2])

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main(){
    int n,m;
    int s[5];
    int c[5];
    scanf("%d %d",&n,&m);
    for(int i = 0;i < m;i++){
        scanf("%d %d",&s[i],&c[i]);
    }

    for(int i = 0;i < 1000;i++){
        int a[3];
        int nx = i/10;
        int keta = 1;
        a[0] = i%10;
        int k = 0;
        while(nx > 0){
            keta++;
            k++;
            a[k] = nx%10;
            nx /= 10;
        }
        if(keta != n) continue;
        int flag = 0;
        for(int j = 0;j < m;j++){
            if(c[j] != a[keta - s[j]]) flag = 1;
        }
        if(flag == 0){
            printf("%d",i);
            return 0;
        }
    }
    printf("-1");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<ll, ll> P;
typedef pair<double, P> T;

#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


int main(){
    ll h, n;    cin >> h >> n;
    vector<ll> a(n), b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }

    vector<ll> dp(h+1, INT32_MAX);
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < h; j++){
            int target = min(j + a[i], h);
            dp[target] = min(dp[target], dp[j] + b[i]);
        }
    }

    cout << dp[h] << endl;


    return 0;
}


Measured memory_bytes: 384
a,b,c,x,y=map(int,input().split())
price=0
if a+b>=c*2:
    min_point=min(x,y)
    price +=min_point*c*2
    x -=min_point
    y -=min_point
    if x>y:
        if a>=c*2:price +=c*2*x
        else:price +=a*x
    elif y>x:
        if b>=c*2:price +=c*2*y
        else:price +=b*y
    print(price)
else:
    print(a*x+b*y)

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		char[] c = s.toCharArray();

		if (c[0] == c[1] || c[1] == c[2] || c[2] == c[3]) {
			System.out.println("Bad");
		} else {
			System.out.println("Good");
		}
		sc.close();
	}
}

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


int main() {
	int n, m; std::cin >> n >> m;
	std::vector<int> wa(n, 0);
	std::vector<bool> is_ac(n, false);
	for (auto i = 0; i < m; ++i) {
		int p; std::string state; std::cin >> p >> state; --p;
		if (!is_ac[p]) {
			if (state == "AC") {
				is_ac[p] = true;
			}
			else {
				++wa[p];
			}
		}
	}
	int count = 0;
	int wa_sum = 0;
	for (auto i = 0; i < n; ++i) if (is_ac[i]) {
		++count;
		wa_sum += wa[i];
	}
	std::cout << count << " " << wa_sum << std::endl;
}

Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <string>
#include <stdio.h>
using namespace std;

const int N = 2e5 + 10;
int black_num[N], white_num[N];

int main() {
    int n;
    string s;
    cin >> n >> s;
    for (int i = n; i >= 1; i--) {
        white_num[i] = white_num[i + 1] + (s[i - 1] == '.');
    }
    for (int i = 1; i <= n; i++) {
        black_num[i] = black_num[i - 1] + (s[i - 1] == '#');
    }

    int res = white_num[1];
    for (int i = 1; i <= n; i++) {
        res = min(res, white_num[i + 1] + black_num[i]);
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 2172
macro_rules! get {
    (Vec<t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

use std::cmp;

fn main() {
    let N = get!(i64);
    let S = get!(String);

    let mut ans = 0;
    let mut x = 0;
    for c in S.chars() {
        x += if c == 'I' {
            1
        } else {
            -1
        };
        ans = cmp::max(ans, x);
    }

    println!("{}", ans);
}

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

int main(){
      int N,M,L,R;
      int hozon1 = 0,hozon2 = 1000000;
      cin >> N >> M;
      for(int i=0;i < M;i++){
            cin >> L >> R;
            hozon1=max(L,hozon1);
            hozon2=min(R,hozon2);
      }
      if(hozon2 >= hozon1){
      cout << hozon2 - hozon1 + 1<< endl;
      }else{
            cout << 0 <<endl;
      }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
#include<cmath>
#include<string>
#include<iomanip>
#include <numeric>
#include <limits>
using namespace std;

int main()
{
int n; cin>>n;
if(n==1) cout<<0;
else cout<<1;
return 0;
}


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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout<<setprecision(12);
    //I don't care about anybody, and fuck ratings! I'll go to google!
    int n; cin>>n;
    if(n&1^1) return cout<<"0.5\n", 0;
    double x = (n+1)/2.0;
    x /= n;
    cout<<x<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;

int main() {
    int n;
    int d[50];
    cin >> n;
    rep(i, n) cin >> d[i];
    int charge = 0;
    rep(i, n - 1){
        for (int j = i + 1; j < n; ++j) {
            charge += d[i] * d[j];
        }    
    }
    cout << charge << endl;
    return 0;
}

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

int main() {
  int n,m;
  cin>>n>>m;

  vector<vector<int>> start(n,vector<int>(2));
  for(int i=0;i<n;i++){
    cin>>start.at(i).at(0)>>start.at(i).at(1);
  }
  vector<vector<int>> goal(m,vector<int>(2));
  for(int i=0;i<m;i++){
    cin>>goal.at(i).at(0)>>goal.at(i).at(1);
  }

  for(int i=0;i<n;i++){
    int mindis=1e+9;
    int next=-1;
    for(int j=0;j<m;j++){
      int dis=abs(start.at(i).at(0)-goal.at(j).at(0))+abs(start.at(i).at(1)-goal.at(j).at(1));
      if(dis<mindis){
        mindis=dis;
        next=j+1;
      }
    }
    cout<<next<<endl;
  }
}

Measured memory_bytes: 3608
n, a, b = map(int, input().split())
ans = 0
for i in range(1, n+1):
    t4 = i %10
    t3 = (i %100 -t4) //10
    t2 = (i %1000 -t4 -t3*10) //100
    t1 = (i %10000 -t4 -t3*10 -t2*100) //1000
    t0 = (i %100000 -t4 -t3*10 -t2*100 -t1*1000) //10000
    c = t0 + t1 + t2 + t3 + t4
    if a <= c <= b: ans += i

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main(){ 
  int a,b,c;cin>>a>>b>>c;
  cout<<min(b/a,c);
  }


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

S = [i for i in input()]
count = 0

if S.pop(0) == 'A':
    count += 1

if S[1:-1].count('C') == 1:
    count += 1
    S.remove('C')

    if ''.join(S).islower():
        count += 1

print('AC' if count == 3 else 'WA')


Measured memory_bytes: 2940
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
 
public class Main implements Runnable {
	
    public static void main(String[] args) {
    	new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }
    
    public void run() {
        FastScanner sc = new FastScanner();
        
        int n = sc.nextInt();
        int k = sc.nextInt();

    	System.out.println(partition(n,k));

    }
    
	//分割数をdpで求める
	//nをk個の非負整数の和で表す（⇔k個以下の自然数の和で表す）場合の数
	static int partition(int n, int k){
		int mod = 1000000007;
		if(k>n){k=n;} //無駄な計算を省ける。テーブルごと使う場合は注意。
		int[][] dp = new int[n+1][k+1];
		dp[0][0] = 1;
		for(int i=0;i<=n;i++){
			dp[i][1] = 1; 
		}
		for(int i=2;i<=k;i++){
			dp[0][i] = 1;
			dp[1][i] = 1; 
		}
		
		for(int i=1;i<=n;i++){
			for(int j=2;j<=k;j++){
				if(i-j>=0){
					dp[i][j] = dp[i][j-1] + dp[i-j][j]; //0を最低1つ含む + 丁度k個の自然数の和
					dp[i][j] %= mod;
				}
				else{
					dp[i][j] = dp[i][j-1];
				}
			}
		}
		
		return dp[n][k];
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}
	public int[] nextIntArray(int n){
		int[] a = new int[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public Integer[] nextIntegerArray(int n){
		Integer[] a = new Integer[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 28732
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

int main(int argc, char *argv[])
{

  int N, a;
  cin >> N;

  cin >> a;
  int minv = a , maxv = a;

  for (int i = 1; i < N; i++) {
    cin >> a;

    minv = min(minv, a);
    maxv = max(maxv, a);
  }

  printf("%d\n", maxv-minv);
}


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

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


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

typedef long long ll;
const ll mod = 1e9+7;
int cnt[26] = {0};

int main() {
    int N;
    string S;
    cin >> N;
    cin >> S;
    for (int i=0; i<N; i++) {
            cnt[S[i] - 'a'] += 1;
    }
    ll ans = 1;
    for(int i=0; i<26; i++) {
        ans *= cnt[i] + 1;
        ans %= mod;
    }
    cout << ans - 1 << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<set>
#include<map>
using namespace std;
int main(){
	while(1){
		int n,m,day[200]={},flag=0,ans=0,out;
		cin >> n >> m;
		if(n==0&&m==0)	break;
		for(int i=0;i<n;i++){
			int x,y;
			cin >> x;
			for(int j=0;j<x;j++){
				cin >> y;
				day[y]++;
			}
		}
		for(int i=0;i<200;i++){
			if(day[i]>=m&&day[i]>ans){
				ans = day[i];
				out = i;
				flag=1;
			}
		}
		if(!flag)	cout << 0 << endl;
		else	cout << out << endl;
	}
}


Measured memory_bytes: 3080
import java.math.BigInteger
import kotlin.math.abs
import kotlin.math.min

fun main() = msolutions2020e()

@OptIn(ExperimentalStdlibApi::class)
fun msolutions2020e() {
    val n = readLine()!!.toInt()
    val xList = IntArray(n)
    val yList = IntArray(n)
    val pList = IntArray(n)
    repeat(n) { i ->
        val (x, y, p) = readLine()!!.split(" ").map { it.toInt() }
        xList[i] = x
        yList[i] = y
        pList[i] = p
    }

    val choosePatterns = 1 shl n
    // 何もしてないのときの移動距離
    val baseDistances = (0 until n).map { min(abs(yList[it]), abs(xList[it])) }.toIntArray()
    // [その集合の街を基準に『横』に線路を引いたとき][i番目の街の] = 移動距離の最小
    val costsVert = Array(choosePatterns) { baseDistances.copyOf() }
    // [その集合の街を基準に『縦』に線路を引いたとき][i番目の街の] = 移動距離の最小
    val costsHorz = Array(choosePatterns) { baseDistances.copyOf() }

    val diffVert = Array(n) { IntArray(n) { Int.MAX_VALUE } }
    val diffHorz = Array(n) { IntArray(n) { Int.MAX_VALUE } }

    for (from in 0 until n) for (to in 0 until n) {
        diffVert[from][to] = min(diffVert[from][to], abs(yList[from] - yList[to]))
        diffHorz[from][to] = min(diffHorz[from][to], abs(xList[from] - xList[to]))
    }

    for (choose in 0 until choosePatterns) {
        for (from in (0 until n)) {
            if ((choose shr from) and 1 == 0) continue
            for (to in 0 until n) {
                costsVert[choose][to] = min(costsVert[choose][to], diffVert[from][to])
                costsHorz[choose][to] = min(costsHorz[choose][to], diffHorz[from][to])
            }
        }
    }

    val answers = LongArray(n + 1) { Long.MAX_VALUE }

    for (b in 0 until (3).powExact(n)) {
        var chooseVertBit = 0
        var chooseHorzBit = 0
        var bitOfDigit2 = 1

        b.toString(3).padStart(n, '0').forEach {
            when (it) {
                '1' -> chooseVertBit = chooseVertBit or bitOfDigit2
                '2' -> chooseHorzBit = chooseHorzBit or bitOfDigit2
            }
            bitOfDigit2 = bitOfDigit2 shl 1
        }

        var costSum = 0L
        for (i in 0 until n) {
            costSum += min(costsVert[chooseVertBit][i], costsHorz[chooseHorzBit][i]).toLong() * pList[i]
        }

        val chooseCount = Integer.bitCount(chooseVertBit or chooseHorzBit)
        answers[chooseCount] = min(answers[chooseCount], costSum)
    }

    val answer = answers.joinToString(System.lineSeparator())

    println(answer)
}

private fun Int.powExact(p: Int): Int {
    var x = BigInteger.valueOf(this.toLong())
    var y = p.toLong()
    var result = BigInteger.valueOf(1L)
    val cap = BigInteger.valueOf(Int.MAX_VALUE.toLong())
    while (y > 0) {
        if (y % 2 == 1L) result = result.multiply(x)
        y = y shr 1
        x = x.multiply(x)
        if (result > cap) throw ArithmeticException("int overflow")
    }
    return result.toInt()
}


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

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

  int n;
  cin >> n;
  map<string, int> mp;
  while (n--) {
    string s;
    cin >> s;
    mp[s]++;
  }
  cout << "AC x " << mp["AC"] << "\n";
  cout << "WA x " << mp["WA"] << "\n";
  cout << "TLE x " << mp["TLE"] << "\n";
  cout << "RE x " << mp["RE"] << "\n";
}


Measured memory_bytes: 3648
li = input().split()
N = int(li[0])
Y = int(li[1])
p = "-1 -1 -1"

for i in range(2001):
  for j in range(2001):
    if N -i -j < 0:
      break
    if 10000 * i + 5000 * j + 1000 * (N - i - j) == Y:
      p = "{} {} {}".format(i, j, N- i - j)

print(p)

Measured memory_bytes: 2940
//https://codeforces.com/gym/102465/problem/E
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
ll gcd(ll x, ll y){
	return y == 0 ? x : gcd(y, x%y);
}
char s[maxn];
int p[4][maxn];
int main(){
	int n;
	cin >> n;
	scanf("%s", s + 1);
	for (int i = n; i >= 1; i--){
		p[1][i] = p[1][i + 1];
		p[2][i] = p[2][i + 1];
		p[3][i] = p[3][i + 1];
		if (s[i] == 'R') p[1][i]++;
		else if (s[i] == 'G') p[2][i]++;
		else p[3][i]++;
	}
	ll ans = 0;
	for (int i = 1; i <= n; i++){//R
		for (int j = i + 1; j <= n; j++){//G
			if (s[i]!=s[j]){
				if (s[i] != 'R'&&s[j] != 'R') {
					ans += p[1][j];
					if (s[j + j - i] == 'R')
						ans--;
				}
				if (s[i] != 'G'&&s[j] != 'G') {
					ans += p[2][j];
					if (s[j + j - i] == 'G')
						ans--;
				}
				if (s[i] != 'B'&&s[j] != 'B') {
					ans += p[3][j];
					if (s[j + j - i] == 'B')
						ans--;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3776
n=int(input())
a=list(map(int,input().split()))
ans=0
cnt0=[0]*60
cnt1=[0]*60
mod=10**9+7
tp=[0]*60
for i in range(60):
  tp[i]=(1<<i)%mod
for i in range(60):
    x=1<<i
    one=sum(1 for j in a if j&x)
    ans+=tp[i]*one*(n-one)
print(ans%mod)



Measured memory_bytes: 42156
n = int(input())
a = list(map(int, input().split()))

def chk(a,t):     # t=True(奇数項が正), t=False(偶数項が正) 
    cnt=0   # 操作回数
    x=0     # 塁積和        
    for i in a:
        x+=i      
        if t==True and x<=0:       # 正項予定なのに累積が負か0
            cnt+=1-x                              
            x=x+(1-x)               # 今回のcntで符号変更
        elif t==False and x>=0:   # 負項予定なのに累積が正か0
            cnt+=1+x              
            x=x-(1+x)              # 今回のcntで符号変換
        t = not t                  # 次の項は符号が逆
    return cnt

print(min(chk(a,True),chk(a,False)))

Measured memory_bytes: 20028
#include <stdio.h>

int main()
{
 int x;
 int a;
 int b;

 scanf("%d %d %d",&x,&a,&b);
 if((x-a)*(x-a)>(x-b)*(x-b))
 {
   printf("B\n");
 }else{
   printf("A\n");
 }

 return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void){

    int n, i, j, r = 1, t;
    int A[999];
    int tmp;

    scanf("%d", &n);

    for(i = 0; i < n; i++){
        scanf("%d", &A[i]);
    }

    for(i = 0; i < n - 1; i++){
        for(j = 0; j < n - 1; j++){
            if(A[j + 1] < A[j]){
                tmp = A[j];
                A[j] = A[j + 1];
                A[j + 1] = tmp;
            }
        }
    }

    t = A[0];
    for(i = 1; i < n; i++){
        if(t != A[i]){
            t = A[i];
            r++;
        }
    }

    printf("%d\n", r);



    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
    #include<string.h>
     
    int main(void)
    {
       char a[11], b[11], c[11];
     
       scanf("%s%s%s" , a, b, c);
       if ((a[strlen(a) - 1] == b[0])&&(b[strlen(b) - 1] == c[0]))
       printf ("YES\n");
       else printf ("NO\n");
       return 0;
    }

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

vector<ll> Primes;
set<ll> m;
set<ll> m2;

P f(ll x){
	P ret = P(1,1);
	rep(i,Primes.size()){
		ll p = Primes[i];
		ll cnt = 0;
		while(x%p ==0){
			x /= p;
			cnt ++;
		}
		if(cnt%3 == 1){
			ret.fr *= p;
			ret.sc *= p*p;
		}
		else if(cnt%3 == 2){
			ret.fr *= p*p;
			ret.sc *= p;
		}
		if(ret.sc > 10000000000)return P(-1,-1);
	}
	if(m.find(x) != m.end()){
		ret.fr *= x;
		ret.sc *= (ll)(sqrt((ld)x)+0.5);
		x = 1;
	}
	else if(m2.find(x) != m2.end()){
		ret.fr *= x;
		ret.sc *= x;
		if(ret.sc > 10000000000)return P(-1,-1);
		ret.sc *= x;
		x = 1;
	}
	if(x != 1)return P(-1,-1);
	else return ret;
}

int main(){
	bool prime[100010];
	rep(i,100010)prime[i] = true;
	for(ll i = 2 ; i < 100010 ; i ++){
		if(prime[i]){
			if(i < 3000)Primes.pb(i);
			else {
				m.insert(i*i);
				m2.insert(i);
			}
			for(ll j = i*i ; j < 100010 ; j += i){
				prime[j] = false;
			}
		}
	}
	//cout << Primes.size() << endl;
	
	int n;
	ll s[100010];
	scanf("%d",&n);
	rep(i,n)scanf("%lld",&s[i]);
	
	map<ll,P> MAP;
	int cnt = 0;
	bool t = false;
	rep(i,n){
		P p = f(s[i]);
		if(p.fr == -1)cnt ++;
		else if(p.fr == 1)t = true;
		else {
			if(p.fr < p.sc)MAP[p.fr].fr ++;
			else MAP[p.sc].sc ++;
		}
	}
	
	if(t)cnt ++;
	for(map<ll,P>::iterator itr = MAP.begin() ; itr != MAP.end() ; itr++){
		cnt += max ( itr->sc.fr , itr->sc.sc );
	}
	cout << cnt << endl;
}



Measured memory_bytes: 7168
#include<stdio.h>
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
long long int c;
long long int merge(int S[], int min, int mid, int max)
{
	int i, j, k;
	c = 0;
	int n1 = mid - min;
	int n2 = max - mid;
	
	for(i = 0; i < n1; i++)
	{
		L[i] = S[min + i];
	}
	for(i = 0; i < n2; i++)
	{
		R[i] = S[mid + i];
	}
	
	L[n1] = SENTINEL;
	R[n2] = SENTINEL;
	i = 0;
	j = 0;
	
	for(k = min; k < max; k++)
	{
		if(L[i] <= R[j])
		{
			S[k] = L[i];
			i++;
		}
		else
		{
			S[k] = R[j];
			j++;
			c += n1 - i;
		}
	}
	return c;
}

long long int mergeSort(int S[], int min, int max)
{
	long long int v1, v2, v3;
	if(min + 1 < max)
	{
		int mid = (min + max) / 2;
		v1 = mergeSort(S, min, mid);
		v2 = mergeSort(S, mid, max);
		v3 = merge(S,min, mid, max);
		return (v1 + v2 + v3);
	}
	else return 0;
}

int main(void)
{
	int n, i;
	
	scanf("%d", &n);
	int S[n];
	
	for(i = 0; i < n; i++)
	{
		scanf("%d", &S[i]);
	}
	
	c = mergeSort(S, 0, n);
	
	printf("%lld\n", c);
	
	return 0;
}


Measured memory_bytes: 3312
use std::io::stdin;
fn get_string() -> String {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

macro_rules! input {
    ($single:ty) => ( get_string().parse::<$single>().unwrap() );
    ($plural:ty,) => ({
        let line = get_string();
        line.split_whitespace().map(|v| v.parse::<$plural>().unwrap()).collect::<Vec<$plural>>()
    });
    ($($plural:ty),+) => ({
        let line = get_string();
        let mut iter = line.split_whitespace();
        ($(iter.next().unwrap().parse::<$plural>().unwrap()),+)
    });
    ($single:ty; $times:expr) => ( (0..$times).map(|_| input!($single)).collect::<Vec<$single>>() );
    ($($plural:ty),+; $times:expr) => ( (0..$times).map(|_| input!($($plural),+)).collect::<Vec<($($plural),+)>>() );
}

#[allow(dead_code)]
fn get_value<T: std::str::FromStr>() -> T {
    get_string().parse().ok().unwrap()
}
#[allow(dead_code)]
fn get_values_for<T: std::str::FromStr>(times: u64) -> Vec<T> {
    (0..times).map(|_| get_value()).collect()
}
#[allow(dead_code)]
fn get_vector<T: std::str::FromStr>() -> Vec<T> {
    get_string()
        .split_whitespace()
        .map(|v| v.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn get_vectors_for<T: std::str::FromStr>(times: u64) -> Vec<Vec<T>> {
    (0..times).map(|_| get_vector()).collect()
}

fn main() {
    let s = input!(String);
    let t = input!(String);

    let s_chars: Vec<_> = s.chars().collect();

    for i in 0..s.len() {
        let rotated: String = format!(
            "{}{}",
            s_chars[i..].iter().map(|c| *c).collect::<String>(),
            s_chars[..i].iter().map(|c| *c).collect::<String>(),
        );
        if rotated == t {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


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

using namespace std;

typedef long long int lli;

// ####################
//  Calc nCr
// ####################
const lli MAX = 1000000;
const lli MOD = 1000000007;

lli fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void NCRinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
lli NCR(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// ####################
//  Calc nCr END
// ####################

int main() {
    lli n, m, k;
    const lli MOD = 1000000007;

    cin >> n >> m >> k;

    lli ans = 0;
    // X
    for (int i=1; i<m; i++) {
        ans += n * n * (m-i) * i;
        ans %= MOD;
    }

    // Y
    for (int i=1; i<n; i++) {
        ans += m * m * (n-i) * i;
        ans %= MOD;
    }

    if (k > 2) {
        NCRinit();
        //cout << NCR((int)m*n-2, (int)k-2) << endl;
        ans *= NCR(m*n-2, k-2);
        ans %= MOD;
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 23680