akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1000000000 + 7;

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

    ll m = INF;
    for (int i = 1; i < n; i++) {
        m = min(m, abs((asum[i] - asum[0]) - (asum[n] - asum[i])));
    }
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 4744
#include <iostream>
#include <string>

using namespace std;

int main() {
  int c = 0;
  string s; cin >> s;
  if(s[0] != 'A') {
    cout << "WA" << endl;
    return 0;
  }
  if(isupper(s[1]) || isupper(s[s.size() - 1])) {
    cout << "WA" << endl;
    return 0;
  }
  for(int i = 2; i < s.size() - 1; i++) {
    if(s[i] == 'C') c++;
    else if(isupper(s[i])) {
      c = 0; break;
    }
  }
  if(c == 1) cout << "AC" << endl;
  else cout << "WA" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>

const int N = 100000;

int n, a[N];

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; ++ i) {
        scanf("%d", a + i);
        a[i] --;
    }
    int result = 0;
    for (int i = 0; i < n; ++ i) {
        result += a[a[i]] == i;
    }
    printf("%d\n", result >> 1);
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int  main()
{
  int n;
  cin>>n;
  int a[n][3];
  for(int i=0; i<n; i++)
  {
  	cin>>a[i][0]>>a[i][1]>>a[i][2];
  }
  int dp[n][3];
  dp[0][0]=a[0][0];
  dp[0][1]=a[0][1];
  dp[0][2]=a[0][2];
  for(int i=1; i<n; i++)
  {
  	dp[i][0]=max(dp[i-1][1]+a[i][0],dp[i-1][2]+a[i][0]);
  	dp[i][1]=max(dp[i-1][0]+a[i][1],dp[i-1][2]+a[i][1]);
  	dp[i][2]=max(dp[i-1][1]+a[i][2],dp[i-1][0]+a[i][2]);
  }
  cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
}


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

int main(){
  int A,B,T,ans;
  cin >> A >> B >> T;
  for(int i=0;i<100000;i++){
    if(A*(i+1)<=T)
      ans+=B;
    else
      break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
  string a,b="CODEFESTIVAL2016";
  cin>>a;
  for(int i=0; i<16; i++)
  {
    if(a[i]!=b[i])n++;
  }
  cout<<n;
  return 0;
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let input = read_vec::<usize>();
    let (n, k) = (input[0], input[1]);

    let vs = read_vec::<i64>();

    let mut max = 0;

    let u = std::cmp::min(n, k);

    for a in 0..u+1 {
        for b in 0..u+1 {
            if a + b > u {
                break;
            }
            let mut sum = 0;
            let mut minus = vec![];
            for i in 0..a {
                if vs[i] < 0 {
                    minus.push(vs[i]);
                }
                sum += vs[i];
            }
            for i in 0..b {
                if vs[n-i-1] < 0 {
                    minus.push(vs[n-i-1]);
                }
                sum += vs[n-i-1];
            }
            minus.sort();
            for &v in minus.iter().take(k-a-b) {
                sum -= v;
            }
            max = std::cmp::max(max, sum);
        }
    }
    println!("{}", max);
}

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

int main(){
    ll q, c, x;
    set<ll> s;
    cin >> q;
    for(ll i = 0; i < q; i++){
        cin >> c >> x;
        if (c == 0){
            s.insert(x);
            cout << s.size() << endl;
        }else if(c == 1){
            if (s.find(x) != s.end()){
                cout << "1" << endl;
            }else{
                cout << "0" << endl;
            }
        }else{
            auto i = s.find(x);
            if(i != s.end()){
                s.erase(i);
            }
        }
    }
    return 0;
}


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

 
int main() {

    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) {
        cin >> a[i];
        if(a[i] == 0) {
            cout<<0<<endl;
            return 0;
        }
    }

    ll ans = 1;
    rep(i,n) {
        rep(j,18) {
            if((ans/pow(10,j))*(a[i]/pow(10,18-j))>1) {
                cout<<-1<<endl;
                return 0;
            }
        }
        ans *=a[i];
        if(ans>1000000000000000000) {
            cout<<-1<<endl;
            return 0;
        }
    }

    cout<<ans<<endl;
    
 return 0;
}

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

int main() {
  string S,T;
  int c;
  c=0;
  cin >>S>>T;
  for(int i=0;i<3;i++){
    if(S.at(i)==T.at(i)){
      c++;
    }
  }
  cout <<c<<endl;

}


Measured memory_bytes: 256
using System;

namespace A___T_or_T
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var n = int.Parse (input[0]);
            var a = int.Parse (input[1]);
            var b = int.Parse (input[2]);
            var densha = n * a;
            var taxi = b;
            Console.WriteLine (Math.Min (densha, taxi));
        }
    }
}

Measured memory_bytes: 13140
/**
*    author:  boutarou
*    created: 25.07.2020 21:05:37
**/

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

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    for (int i = k; i < n; i++) {
        if (a[i] > a[i - k]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);


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

    vector<string> A(N,"");
    rep(h,N) {
        rep(w,N) {
            char a;
            cin >> a;
            A[h].push_back(a);
        }
    }

    int ans = 0;    
    rep(i,N) {
        bool t = true;
        vector<string> B(N,"");
        rep(h,N) {
            rep(w,N) {
                B[h] += A[h][(w+i)%N];
            }
        }



        rep(h,N) {
            rep(w,N) {
                if (B[h][(w+i)%N]!=B[(w+i)%N][h]) {
                    t = false;
                }
            }
        }

        if (t) {
            ans += N;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3920
N = int(input())
a = []
b = []
c = []
for i in range(N):
    aa,bb,cc = list(map(int,input().split()))
    a.append(aa)
    b.append(bb)
    c.append(cc)

dpa = [0]*N
dpb = [0]*N
dpc = [0]*N
dpa[0] = a[0]
dpb[0] = b[0]
dpc[0] = c[0]

for i in range(1,N):
    dpa[i] = max(dpb[i-1]+a[i],dpc[i-1]+a[i])
    dpb[i] = max(dpa[i-1]+b[i],dpc[i-1]+b[i])
    dpc[i] = max(dpa[i-1]+c[i],dpb[i-1]+c[i])

print(max(dpa[N-1],dpb[N-1],dpc[N-1]))

Measured memory_bytes: 27168
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#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
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}
ll gcd(ll(a), ll(b)) {
	ll c = a;
	while (a % b != 0) {
		c = a % b;
		a = b;
		b = c;
	}
	return b;
}
ll A, B, X;
bool isOK(ll g,ll X) {
	if (g > X) return true;
	else return false;
}
ll keta(ll a) {
	ll k = 0;
	a = abs(a);
	if (a == 0)return 1;
	while (a > 0) {
		k++;
		a /= 10;
	}
	return k;
}
ll binary_search(ll key,ll A,ll B,ll X) {
	int left = 0; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = 1000000000; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(A*mid+B*keta(mid),X)) right = mid;
		else left = mid;
	}

	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return left;
}

int main() {
	ll T1, T2, A1, A2, B1, B2;
	cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
	ll C1 = (A1 - B1)*T1;
	ll C2 = (A2 - B2)*T2;
	if (C1 > 0) {
		C1 *= -1; C2 *= -1;
	}
	if (C1 + C2 < 0) {
		cout << 0 << endl;
	}
	else if (C1 + C2 == 0) {
		cout << "infinity" << endl;
	}
	else if (-C1 % (C1 + C2) == 0) {
		cout << 2 * (-C1 / (C1 + C2)) << endl;
	}
	else {
		cout << 2 * (-C1 / (C1 + C2))+1 << endl;
	}
}



Measured memory_bytes: 3612
import math

def main():
    N,P = map(int,input().split())
    A = list(map(int,input().split()))
    odd = []
    even = []
    for i in A:
        if i%2 == 0:
            even.append(i)
        else:
            odd.append(i)

    num_even = 2**len(even)
    def combination(n,r):
        return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

    count = 0
    lo = len(odd)
    if P == 0:
        for i in range(lo//2+1):
            count += combination(lo,2*i)
        print(num_even*count)
    else:
        for i in range(-(-lo)//2):
            count += combination(lo,2*i+1)
        print(num_even*count)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
using System;

class Program
{
    static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');

        byte W = byte.Parse(input[0]);
        byte H = byte.Parse(input[1]);
        int x = int.Parse(input[2]);
        int y = int.Parse(input[3]);
        byte r = byte.Parse(input[4]);

		if (0 > x || W < x+r)
		{
			Console.WriteLine("No");
		} else if (0 > y || H < y+r)
		{
			Console.WriteLine("No");
		} else
			Console.WriteLine("Yes");
    }
}


Measured memory_bytes: 9708
use std::cmp;

#[allow(dead_code)]
pub struct Scanner<'a> {
    _buf: &'a str,
    iter: ::std::str::SplitWhitespace<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    pub fn new(buf: &'a str) -> Self {
        Scanner {
            _buf: buf,
            iter: buf.split_whitespace(),
        }
    }

    pub fn array<T>(&mut self, n: usize) -> Vec<T>
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        let mut res = Vec::with_capacity(n);
        for _ in 0..n {
            res.push(self.value());
        }
        res
    }

    pub fn value<T>(&mut self) -> T
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        self.next().parse().unwrap()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.next().chars().collect()
    }

    fn next(&mut self) -> &str {
        self.iter.next().unwrap()
    }
}

fn main() {
    let mut _input = String::new();
    {
        use ::std::io::Read;
        ::std::io::stdin().read_to_string(&mut _input).unwrap();
    }
    let mut sc = Scanner::new(&_input);

    let n = sc.value::<usize>();
    let k = sc.value::<usize>();
    let a = sc.array::<i64>(n);

    let mut ans = 10_i64.pow(18);
    for i in 0..n-k+1 {
        let mut cur = a[i+k-1] - a[i];
        cur += cmp::min(a[i].abs(), a[i+k-1].abs());
        if cur < ans {
            ans = cur;
        }
    }

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


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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(2000005);

mint g(int r, int c) {
  return comb(r+c+2, r+1) - 1;
}

int main() {
  int r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;
  --r1; --c1;

  mint ans = g(r2,c2);
  ans -= g(r1,c2);
  ans -= g(r2,c1);
  ans += g(r1,c1);
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 31488
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
const ll INF = (ll)(1<<30)*2 - 1;
template <typename X>
struct DST
{
  int n;
  vector<X> dat,delay;
  X init;
  vector<bool> flag;

  DST(int _n)
  {
    n = 1;
    while(n < _n) n *= 2;
    dat.assign(2*n-1,INF);
    delay.assign(2*n-1,0);
    flag.assign(2*n-1,0);
  }

  void eval(int k,int l,int r)
  {
    if(flag[k]){
      dat[k] += delay[k];
      if(k < n-1){
	delay[2*k+1] += delay[k];
	delay[2*k+2] += delay[k];
	flag[2*k+1] = true;
	flag[2*k+2] = true;
      }
      delay[k] = 0;
      flag[k] = false;
    }
  }
  
  void update(int a,int b,X x,int k,int l,int r)
  {
    eval(k,l,r);
    
    if(r<=a||b<=l) return ;
    
    if(a<=l&&r<=b){
      delay[k] += x;
      flag[k] = true;
      eval(k,l,r);
    }
    else{
      update(a,b,x,2*k+1,l,(l+r)/2);
      update(a,b,x,2*k+2,(l+r)/2,r);
      dat[k] = min(dat[2*k+1],dat[2*k+2]);
    }
  }

  X query(int a,int b,int k,int l,int r)
  {
    eval(k,l,r);
    
    if(r<=a||b<=l) return INF;

    if(a<=l&&r<=b) return dat[k];    
    else{
      X vl = query(a,b,2*k+1,l,(l+r)/2);
      X vr = query(a,b,2*k+2,(l+r)/2,r);
      return min(vl,vr);
    }
  }
};
int _n,q;
vector<int> com,s,t;
vector<ll> x;
int main()
{
  cin >> _n >> q;
  com.resize(q);
  s.resize(q);
  t.resize(q);
  x.resize(q);

  rep(i,q){
    cin >> com[i] >> s[i] >> t[i];
    if(com[i] == 0) cin >> x[i];
  }
  
  DST<ll> dst(_n);

  dst.update(0,_n,-INF,0,0,dst.n);
  /*
  rep(j,dst.n*2-1){
    cout << dst.dat[j] << " ";
  }
  cout << "\n";
  rep(j,dst.n*2-1){
    cout << dst.delay[j] << " ";
  }
  cout << "\n";
  rep(j,dst.n*2-1){
    cout << dst.flag[j] << " ";
  }
  cout << "\n";
  */
  
  rep(i,q){
    if(com[i] == 0){
      dst.update(s[i],t[i]+1,x[i],0,0,dst.n);
    }
    else{
      cout << dst.query(s[i],t[i]+1,0,0,dst.n) << "\n";
    }
    /*
    rep(j,dst.n*2-1){
      cout << dst.dat[j] << " ";
    }
    cout << "\n";
    rep(j,dst.n*2-1){
      cout << dst.delay[j] << " ";
    }
    cout << "\n";
    */
  }
  return 0;
}



Measured memory_bytes: 8936
#include<iostream>
#include<vector>
using namespace std;
int main(void){
    int H,W,K;
    cin >> H >> W >> K;

    vector<string> s(H);
    for(int i = 0;i < H;i++){
        cin >> s[i];
    }
    int ans = 0;
    for(int i = 0;i < 1 << H;i++){//縦のマスをビット全探索、各ビットをマスとしてみる。
        for(int j = 0;j < 1 << W;j++){//横のマスを全探索
            int black = 0;
            for(int k = 0;k < H;k++){
                for(int l = 0;l < W;l++){
                    if((i >> k & 1) == 1 && (j >> l & 1) == 1 && s[k][l] == '#'){
                        black++;
                    }
                }
            }
            if(black == K)ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#ifdef DEBUG
#define DEBUG_PRINT(...) printf(__VA_ARGS__)
#else
#define DEBUG_PRINT(...)
#endif

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

int H, W, N, A[10000];

int a[100][100];

int main(){
  scanf("%d %d", &H, &W);
  scanf("%d", &N);

  REP(N)scanf("%d", &A[i]);

  int color = 1, tmp = 0;
  For(i, H){
    For(j, W){
      if(tmp >= A[color-1]){DEBUG_PRINT("aa");color++;tmp = 0;}
      a[i][j] = color;
      tmp++;
    }
  }

  REP(H){
    if(i%2 == 1)reverse(a[i], a[i]+W);
  }

  For(i, H){
    For(j, W){
      printf("%d", a[i][j]);
      if(j!=W-1)printf(" ");
      else printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 384
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
D.sort()
T.sort()
j = 0
for i in range(M):
    while j < N:
        if D[j] == T[i]:
            break
        j += 1
    if j == N:
        print('NO')
        exit()
    j += 1
print('YES')


Measured memory_bytes: 118544
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<ll>;

#define nextline() (std::cerr << "\n")
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divUp(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }

/*****/

#define twe(a) ((a)*(a))

void Main()
{
	int n;
	cin >> n;
	vector<pair<int, int>> p(8);
	rep(i, n)
	{
		int x, y;
		cin >> x >> y;
		p[i] = pair(x, y);
	}

	ld sum = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			sum += sqrtl((ld)twe(p[i].first - p[j].first) + twe(p[i].second - p[j].second));
		}
	}

	//sum = sum * 2 / 3;
	//sum = sum * 3 / 5;
	sum = sum * 2 / n;

	cout << sum;
}

/*****/

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

	std::cout << std::fixed << std::setprecision(10);


	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/


	Main();

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<char>> vec(H,vector<char>(W));
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> vec.at(i).at(j);
    }
  }
  
  vector<vector<int>> dist(H,vector<int>(W,0));
  if(vec.at(0).at(0) == '#'){
    dist.at(0).at(0) = 1;
  }
  for(int j=1; j<W; j++){
    int c = 0;
    if(vec.at(0).at(j-1) == '.' && vec.at(0).at(j) == '#'){
      c = 1;
    }
    dist.at(0).at(j) = dist.at(0).at(j-1) + c;
  }
  for(int i=1; i<H; i++){
    int c = 0;
    if(vec.at(i-1).at(0) == '.' && vec.at(i).at(0) == '#'){
      c = 1;
    }
    dist.at(i).at(0) = dist.at(i-1).at(0) + c;
  }
  
  for(int i=1; i<H; i++){
    for(int j=1; j<W; j++){
      int h = dist.at(i-1).at(j);
      int w = dist.at(i).at(j-1);
      if(vec.at(i-1).at(j) == '.' && vec.at(i).at(j) == '#'){
        h++;
      }
      if(vec.at(i).at(j-1) == '.' && vec.at(i).at(j) == '#'){
        w++;
      }
      dist.at(i).at(j) = min(h,w);
    }
  }
  cout << dist.at(H-1).at(W-1) << endl;
  
  /*for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cout << dist.at(i).at(j) << " ";
    }
    cout << endl;
  }*/
}

Measured memory_bytes: 256
# フェルマーの小定理
K = int(input())
S = input()

m = 1000000007


def make_factorial_table(n):
    result = [0] * (n + 1)
    result[0] = 1
    for i in range(1, n + 1):
        result[i] = result[i - 1] * i % m
    return result


def mcomb(n, k):
    if n == 0 and k == 0:
        return 1
    if n < k or k < 0:
        return 0
    return fac[n] * pow(fac[n - k], m - 2, m) * pow(fac[k], m - 2, m) % m


fac = make_factorial_table(len(S) - 1 + K)

result = 0
for i in range(K + 1):
    result += pow(26, i, m) * mcomb(len(S) - 1 + K - i, K - i) * pow(25, K - i, m)
    result %= m
print(result)


Measured memory_bytes: 91708
#include <cstdio>
#include <queue>
#include <algorithm>
#include <vector>

using namespace std;

long long GCD(long long x, long long y){
	if(x < y) swap(x, y);
	long long r = x % y;
	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}
	
	return y;
}

int main(){
	long long a, b;
	while(scanf("%lld%lld", &a, &b) == 2){
		long long gcd = GCD(a, b);
		long long lcm = a / gcd * b;
		printf("%lld %lld\n", gcd, lcm);
	}
}


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

long long dp[2010][2010];

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<long long> a(n);
    for (auto &x: a) cin >> x;
    vector<int> c(n);
    int curr = 0;
    for (auto &x: c) x = curr++;
    auto cmp = [&](int i, int j) {
        return a[i] > a[j];
    };
    sort(c.begin(), c.end(), cmp);
    for (int i = 0; i < n; i++) {
        int k = n - i;
        auto x = a[c[i]];
        auto xi = c[i];
        for (int j = 0; j <= n-k; j++) {
            // dp[j][j+k]
            dp[j+1][j+k] = max(dp[j+1][j+k], dp[j][j+k]+x*abs(xi-j));
            dp[j][j+k-1] = max(dp[j][j+k-1], dp[j][j+k]+x*abs(xi-(j+k-1)));
        }
    }
    long long ans = 0;
    for (int i = 0; i <= n; i++) ans = max(ans, dp[i][i]);
    cout << ans << "\n";
    return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

const int N=65536;
const int INF=10000000;

int main()
{
    int n,m;
    cin >>n >>m;
    vector<int> b(n),p(m);
    rep(i,n) cin >>b[i];
    rep(i,m) cin >>p[i];

    int start=0;
    rep(i,n) start+=(b[i]<<(n-i-1));

    int g1=0,g2=0;
    int ct=0;
    rep(i,m)
    {
        int b=i%2;
        rep(j,p[i])
        {
            g1+=(b<<(n-ct-1));
            g2+=((!b)<<(n-ct-1));
            ++ct;
        }
    }

    //BFS
    int dist[N];
    fill(dist,dist+N,INF);
    queue<int> que;
    que.push(start);
    dist[start]=0;
    while(!que.empty())
    {
        int v=que.front();
        que.pop();
        rep(i,n-1)
        {
            int t=v;
            int a=(t>>(n-i-1))&1;
            int b=(t>>(n-i-2))&1;

            t-=(a<<(n-i-1))+(b<<(n-i-2));
            t+=(b<<(n-i-1))+(a<<(n-i-2));


            if(dist[t]>dist[v]+1)
            {
                dist[t]=dist[v]+1;
                que.push(t);
            }
        }
    }

    printf("%d\n", min(dist[g1],dist[g2]));
    return 0;
}

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

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

  if (s.at(0) == 'A') cout << "T" << endl;
  if (s.at(0) == 'T') cout << "A" << endl;
  if (s.at(0) == 'C') cout << "G" << endl;
  if (s.at(0) == 'G') cout << "C" << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, h, w;
  cin >> n >> h >> w;
  cout << (n - h + 1) * (n - w + 1) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = 998244353;
ll inf=1e17;
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2};
const int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1};
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif

int main(){
  fastIO();
  ll x;
  cin>>x;
  for(ll a=-505;a<=505;a++){
    for(ll b=-505;b<=505;b++){
      if(pow(a,5)-pow(b,5)==x){
        cout<<a<<" "<<b<<endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 4120
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return (x<0||x>=n||y<0||y>=m)?false:true;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
typedef pair<int,int> P;

int ord[100001],low[100001];
vector<int> G[100001];
struct edge{int u,v;};
void dfs(int u, int pre, int c, vector<int> G[], vector<edge> &B){
  ord[u] = low[u] = c++;
  for(int i=0;i<G[u].size();i++){
    int v = G[u][i];
    if(v != pre){
      if(ord[v] == -1){
        dfs(v,u,c,G,B);
        low[u] = min(low[u],low[v]);
      } else low[u] = min(low[u],ord[v]);
      if(ord[u] < low[v]) B.push_back((edge){u,v});
    }
  }
}

void bridge(int n, vector<int> G[], vector<edge> &B){
  B.clear();
  int c = 0;
  fill(ord,ord+n,-1);
  for(int i=0;i<n;i++) if(ord[i]==-1) dfs(i,-1,c,G,B);
}

int main() {
  int n,m;
  cin >> n >> m;
  rep(i,m) {
    int x,y;
    cin >> x >> y;
    G[x].pb(y);
    G[y].pb(x);
  }

  vector<edge> E;
  bridge(n,G,E);
  vector<P> ans;
  rep(i,E.size()) {
    if(E[i].u>E[i].v) swap(E[i].u,E[i].v);
    ans.pb(P(E[i].u,E[i].v));
  }
  sort(all(ans));
  rep(i,ans.size()) PR(ans[i].F,ans[i].S);
  return 0;
}


Measured memory_bytes: 5448
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000 * 1000 * 1000 + 7;
const int INF = MOD;
const int N = 101;
int mod(int n) {
    return (n % MOD + MOD) % MOD;
}   
int fp(int a, int p) {
    int ans = 1, cur = a;
    for (int i = 0; (1ll << i) <= p; ++i) {
        if ((p >> i) & 1) ans = mod(ans * cur);
        cur = mod(cur * cur);
    }
    return ans;
}   
void add(int &a, int b) {
    a = mod(a + b);
}
int h[N];
int dp[N][N];
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> h[i];
    vector <int> c;
    for (int i = 0; i < n; ++i) c.push_back(h[i]);
    sort(c.begin(), c.end()); 
    c.resize(unique(c.begin(), c.end()) - c.begin());
    int r = c.size();
    c.push_back(INF);
    dp[0][r] = 2;
    int p = 2;
    for (int i = r - 1; i >= 0; --i) {
        if (c[i] <= h[0] && c[i] > 1) {
            int down = 1;
            if (i) down = c[i - 1];
            dp[0][i] = mod(fp(2, h[0] - down + 1) - p);
            add(p, dp[0][i]);
        }   
    }   
    for (int i = 0; i + 1 < n; ++i) {
        for (int j = 0; j <= r; ++j) {
            if (dp[i][j]) {
                if (h[i + 1] <= h[i]) {
                    if (c[j] <= h[i + 1]) {
                        add(dp[i + 1][j], dp[i][j]);
                    }
                    else {
                        add(dp[i + 1][r], dp[i][j] << 1);
                    }   
                }
                else {
                    if (j == r) {
                        dp[i + 1][r] = 2;
                        int p = 2;
                        for (int k = r - 1; k >= 0; --k) {
                            if (c[k] <= h[i]) break;
                            if (c[k] <= h[i + 1]) {
                                int down = 1;
                                if (k) down = c[k - 1];
                                dp[i + 1][k] = mod(fp(2, h[i + 1] - down + 1) - p);
                                add(p, dp[i + 1][k]);
                            }   
                        }   
                        for (int k = r; k >= 0; --k) {
                            if (c[k] <= h[i]) break;
                            dp[i + 1][k] = mod(dp[i + 1][k] * dp[i][j]);
                        }   
                    }
                    else {
                        add(dp[i + 1][j], dp[i][j] * fp(2, h[i + 1] - h[i]));
                    }   
                }   
            }   
        }   
    }   
    int ans = 0;
    for (int i = 0; i <= r; ++i) add(ans, dp[n - 1][i]);
    cout << ans << '\n';
}   

Measured memory_bytes: 384
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap, VecDeque, BTreeSet, BTreeMap};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            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<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let (n, a) = get!(usize, isize);
    let xs = util::gets::<isize>();

    let mut dp = vec![vec![0u64; 5001]; n + 1];
    dp[0][2500] = 1;

    for (&x, i) in xs.iter().zip(1..) {
        let d = x - a;

        for k in 0..5001 {
            let j = k as isize + d;
            if j >= 0 && j < 5001 {
                dp[i][j as usize] += dp[i - 1][k as usize];
            }
            dp[i][k] += dp[i - 1][k];
        }
    }

    println!("{}", dp[n][2500] - 1);
}


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

const string hyou[] = {"afkpuz",
		       "bglqv.",
		       "chmrw?",
		       "dinsx!",
		       "ejoty "};
int main(){
  string in;
  while(cin >> in){
    cin.ignore();
    if(in.size()%2 == 1){
      cout << "NA" << endl;
      continue;
    }
    bool flag = true;
    string ans = "";
        for(int i = 0 ; i < in.size()-1 ; i+=2 ){
	  if(!('1' <= in[i+1] && in[i+1] <= '5')||
	     !('1' <= in[i] && in[i] <= '6')){
	    flag = false; 
	    break;
	  }
	  ans += hyou[in[i+1]-'0'-1][in[i]-'0'-1];
    }
	if(flag)cout << ans <<endl;
	else cout << "NA" << endl;
  }
  return 0;
}

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

int main() {
  int n; cin >>n;
  vector<int> a(n);
  int cnt1=0, cnt2=0, cnt4=0;
  for (int i=0; i<n; i++){
    int buf; cin >>buf;
    if (buf%4==0) cnt4++;
    else if (buf%2==0) cnt2++;
    else cnt1++;
  }
  /*4の倍数,2の倍数,その他を各々4,2,1とおく。
  隣同士は1,4か2,2か2,4。1,2,4の数を各々x,y,zとおくと、
  取り囲む4は各々x+1,2個必要。
  但し、数列の更に外側には4が2つあるとみなせるので
  4の数はz+2コとみなせる。*/
  
  int x=cnt1, y=cnt2, z=cnt4;
  bool ok;
  if (cnt1==0) ok = true;
  else if (cnt2==0 && x+1<=z+2) ok = true;
  else if (x+1+2-1<=z+2) ok = true;
  else ok = false;
  
  if (ok) cout <<"Yes" <<endl;
  else cout <<"No" <<endl;
}


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

using namespace std;
const int N = 1e5+1;

int a[N];
int main(){
    int n; cin >> n;
    for (int i = 0; i < n; ++ i)
        cin >> a[i];
    int i = max_element(a, a+n)-a,
        j = (i?0:1);
    for (int k = 0; k < n; ++ k){
        if (k == i) continue;
        if (abs(2*a[j]-a[i])>abs(2*a[k]-a[i]))
            j = k;
    }
    cout << a[i] << " " << a[j];
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,M; cin >> N >> M;
    vector<int> s(M),c(M);
    rep(i,M) {
        cin >> s[i] >> c[i];
        s[i]--;
    }

    rep(i,1000) {
        string S = to_string(i);
        if (S.size() != N) continue;
        bool ok = true;
        rep(j,M) {
            if (S[s[j]] - '0' != c[j]) ok = false;
        }
        if (ok) {
            cout << S << ln;
            return 0;
        }
    }

    cout << -1 << ln;
}

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

int main() {
  ll x,ans=0,mo,tmp;
  cin >> x;
  tmp=x/100;
  mo=x%100;
  if(mo<=tmp*5) ans=1;
  cout << ans <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int ans = 0,n,a = 0;
	string s;
	cin >> s;
	n = s.length();
	s += "LL";
	for(int i = 0;i < n;i++){
		if(s[i] == 'A') a++;
		else if(s[i] == 'B' && s[i + 1] == 'C'){
			ans += a;
			i++;
		}else a = 0;
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
# coding: utf-8
import sys
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 持っている宝石をDに詰めるのは最後
N, K = lr()
V = lr()
answer = 0
V = V[::-1] + V[::-1]
for x in range(K+1):
    # x回Dから取り出す、K-x回戻すことが可能
    x = min(x, N)
    for i in range(N-1, N-1+x+1):
        take = V[i-x+1:i+1]
        take.sort(reverse=True)
        result = sum(take)
        if result > answer:
            answer = result
        for j in range(K-x):
            if take:
                result -= take.pop()
                if result > answer:
                    answer = result

print(answer)


Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#define mp make_pair
using namespace std;
string str[55],str2[55];
int main(){
	int n,m;
	cin>>n>>m;
	for (int i=0;i<n;i++) cin>>str[i];
	for (int j=0;j<m;j++) cin>>str2[j];
	for (int i=0;i+m<=n;i++){
		for (int j=0;j+m<=n;j++){
			bool f=true;
			for (int ii=0;ii<m;ii++){
				for (int jj=0;jj<m;jj++){
					if (str2[ii][jj]!=str[ii+i][jj+j]) f=false;
				}
			}
			if (f){
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int i, j, N, A[100], flag, temp, count=0;

  scanf("%d",&N);

  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  
  flag=1;
  i=0;
  while(flag){
    flag=0;
    for(j=N-1; j>=i+1; j--){
      if(A[j]<A[j-1]){
	temp=A[j];
	A[j]=A[j-1];
	A[j-1]=temp;
	count++;
      }
      flag=1;
    }
    i++; 
  }
  for(i=0;i<N-1;i++){
    printf("%d ", A[i]);
  }
   printf("%d", A[N-1]);
  printf("\n%d\n",count);
  return 0;
}

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

string solve(char c, int n){
  string a = "";
  for(int i=0; i<n; i++)
    a += c;
  return a;
}

int main(){
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  int tate = ty - sy, yoko = tx - sx;
  
  string ans = "";
  ans += solve('U', tate);
  ans += solve('R', yoko);
  ans += solve('D', tate);
  ans += solve('L', yoko);

  ans += 'L';
  ans += solve('U', tate+1);
  ans += solve('R', yoko+1);
  ans += "DR";
  ans += solve('D', tate+1);
  ans += solve('L', yoko+1);
  ans += 'U';

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3660
//?????????????????¨
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner kb=new Scanner(System.in);
		int w=kb.nextInt(),h=kb.nextInt(),
				x=kb.nextInt(),y=kb.nextInt(),
				r=kb.nextInt();
		if(x>=r&&y>=r&&
				x+r<=w&&y+r<=h){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 26260
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define Endl endl

signed main(void){
    int A,P;
    cin >> A >> P;
    cout << (3*A+P)/2 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <queue>

#define MAX_N (50)

using namespace std;

int main(int argc, char *argv[]) {
  int N, vs[MAX_N];
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &vs[i]);
  }

  priority_queue<double> que;
  for (int i = 0; i < N; i++) {
    que.push(-vs[i]);
  }
  while (que.size() >= 2) {
    const double v0 = -que.top(); que.pop();
    const double v1 = -que.top(); que.pop();
    que.push(-(v0 + v1) / 2.0);
  }
  printf("%.12lf\n", -que.top());
  
  return 0;
}

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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if( (A == B && B != C) || (A == C && C != B) || (B == C && C != A))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define MAX 2000000
#define MOD 1000000007
#define endl "\n"
lli N,M,X;
lli ans = LONG_LONG_MAX;
bool flag = false;
vector <lli> C;
vector <lli> algo[14];
lli powa(lli k){
    lli mask = 1;
    for(lli i = 0; i<k; i++)
        mask *= 2;
    return mask;
}
void check(vector <lli> subset){
    lli costs = 0;
    vector <lli> algosum(M+5,0);
    for(lli i = 0; i<subset.size(); i++){
        costs += C[subset[i]];
        lli togo = subset[i];
        for(lli j = 0; j<M; j++)
            algosum[j] += algo[togo][j];
    }
    for(lli i = 0; i<M; i++){
        if(algosum[i] < X)
            return;
    }
   
    //cout<<endl;
    ans = min(ans,costs);
    //cout<<"Ans: "<<ans<<endl;
}
int main(){
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    lli t;
    t = 1;
    while(t--){
        lli tc;
        lli talgo;
        cin>>N>>M>>X;
        for(lli i =0; i<N; i++){
            cin>>tc;
            C.push_back(tc);
            for(lli j = 0; j<M; j++){
                cin>>talgo;
                algo[i].push_back(talgo);
            }
        }
        for(lli i = 1; i< powa(N); i++){
            vector <lli> ss;
            lli temp = i;
            lli ctr = 0;
            while(temp > 0){
                if(temp%2 == 1){
                    ss.push_back(ctr);
                }
                temp/=2;
                ctr++;
            }
            check(ss);
        }
        //cout<<"Final"<<endl;
        if(ans == LONG_LONG_MAX)
            cout<<"-1"<<endl;
        else    
        cout<<ans<<endl;
    }

}

Measured memory_bytes: 3632
a, b = input().split()

if a == 'H' and b == 'H':
    print('H')
elif a == 'D' and b == 'H':
    print('D')
elif a == 'D' and b == 'D':
    print('H')
elif a == 'H' and b == 'D':
    print('D')

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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

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

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

template<class T>
bool chmax(T &a, initializer_list<T> l)
{
	return chmax(a, *max_element(l.begin(), l.end()));
}

template<class T>
bool chmin(T &a, initializer_list<T> l)
{
	return chmin(a, *min_element(l.begin(), l.end));
}

constexpr ll MAX_B = 50;
ll dp[100][2];

int main(int argc, char **argv)
{
	ll N, K; cin >> N >> K;
	vector<ll> A(N); REP(i, N) cin >> A[i];

	for (ll i = 0; i < 100; ++i) dp[i][0] = dp[i][1] = -1;
	**dp = 0;

	REP(b, MAX_B)
	{
		ll mask = 1ll<<(MAX_B - b - 1);

		ll cnt1{0};
		REP(i, N)
		{
			if (mask & A[i]) ++cnt1;
		}

		ll add0 = cnt1 * mask;
		ll add1 = (N-cnt1) * mask;

		if (dp[b][true] != -1)
			chmax(dp[b+1][true], dp[b][true] + max(add0, add1));

		if (dp[b][false] != -1)
		{
			if (K & mask)
				chmax(dp[b+1][true], dp[b][false] + add0);
		}

		if (dp[b][false] != -1)
		{
			if (K & mask)
				chmax(dp[b+1][false], dp[b][false] + add1);
			else
				chmax(dp[b+1][false], dp[b][false] + add0);
		}
	}

	std::cout << max(dp[MAX_B][false], dp[MAX_B][true])<< std::endl;
}


Measured memory_bytes: 1024
//id:miiifa (AOJ,PEどちらも)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
int main(){
    int n,q;
    cin >> n;
    string S[n];
    REP(i,n) cin >> S[i]; 
    cin >> q;
    string T[n];
    REP(i,q) cin >> T[i];

    map<string,int>A;
    REP(i,n){
        A[S[i]]=1;
    }
    int cnt=0;
    REP(i,q){
        cnt+=A[T[i]];
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3836
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
sys.setrecursionlimit(10**6)

n,k = na()
xy = []

for i in range(n):
    x,y = na()
    xy.append((x,y))

xy.sort()
ans = 10000000000000000000000000000

for i in range(n):
    for j in range(i+1, n):
        x = xy[j][0] - xy[i][0]
        yy = sorted(xy[i:j+1], key=lambda x:x[1])
        for u in range(len(yy)-k+1):
            y = yy[u+k-1][1] - yy[u][1]
            ans = min(ans, y*x)
            
print(ans)


Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main()
{
	int i,j;
	char str[20],c;
	gets(str);
	j=strlen(str);
	for(i=0;i<j/2;i++)
	{
		c=str[i];
		str[i]=str[j-1-i];
		str[j-1-i]=c;
	}
	puts(str);
	return 0;
}

Measured memory_bytes: 524
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include <iostream>
#include <vector>
using namespace std;

int main(){
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> N_array(N);

    for (int i=0; i<N;i++){
        N_array.at(i) =K;
    }

    for (int i=0; i<Q; i++){
        int winner;
        cin >> winner;
        N_array[winner -1 ]++;
       // for (int j=0; j<N; j++){
         //   N_array[j]--;
            //cout << N_array[j];
        //}
    }
    for(int i=0;i<N;i++) N_array[i] = N_array[i] - Q;

    for (int i;i<N;i++){
        if (N_array[i] > 0){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }

}

Measured memory_bytes: 1024