akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(){
    char s[11];
    int len;
    int AC = 1;
    int Ccnt = 0;
    scanf("%s",s);
    len = strlen(s);
    if(s[0] != 'A')
    {
       AC = 0;
    }
    for (int i = 2; i < len - 1; i++)
    {
        if(s[i] == 'C')
        {
            Ccnt++;
        }
    }
    if(Ccnt != 1)
    {
        AC = 0;
    }
    for (int i = 0; i < len; i++)
    {
        if(!(((s[i] == 'A') || (s[i] == 'C')) || (s[i] >= 'a' && s[i] <= 'z')))
        {
            AC = 0;
        }
    }
    if (AC){
        printf("AC\n");
    }else{
        printf("WA\n");
    }
    return 0;
}

Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;


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

  vector <int> graph[N], regraph[N], rest(N);
  for (int i = 1; i < N; i++){
    int A; cin >> A; A--;
    graph[i].push_back(A);
    regraph[A].push_back(i);
    rest[A]++;
  }

  queue <int> que;
  vector <int> depth(N);
  for (int i = 0; i < N; i++){
    if (rest[i] == 0) que.push(i);
  }

  while (!que.empty()){
    int Q = que.front(); que.pop();

    for (int i = 0; i < graph[Q].size(); i++){
      int next = graph[Q][i];
      rest[next]--;
      if (rest[next] == 0) que.push(next);
    }

    if (regraph[Q].size() > 0){
      vector <int> now;
      for (int i = 0; i < regraph[Q].size(); i++){
        int next = regraph[Q][i];
        now.push_back(depth[next]);
      }
      sort(now.begin(), now.end(), greater<int>());

      for (int i = 0; i < now.size(); i++){
        depth[Q] = max(depth[Q], now[i] + i + 1);
      }
    }
  }
  cout << depth[0] << endl;
  
  return 0;
}


Measured memory_bytes: 12032
unittest
{
	assert( [ "3 0", "3 3", "4 4", "2 5" ].parse.expand.solve == 8 );
	assert( [ "3 5", "3 3", "4 4", "2 5" ].parse.expand.solve == 8 );
	assert( [ "3 6", "3 3", "4 4", "2 5" ].parse.expand.solve == 9 );
	assert( [ "7 14", "10 5", "7 4", "11 4", "9 8", "3 6", "6 2", "8 9" ].parse.expand.solve == 32 );
}



import core.bitop;
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nk = input.front.split.to!( long[] );
	auto abs = new long[ 2 ][ nk[ 0 ] ];
	foreach( ref ab; abs )
	{
		input.popFront;
		ab = input.front.split.to!( long[] );
	}
	return tuple( nk[ 1 ], abs );
}

auto solve( long k, long[ 2 ][] abs )
{
	// i+1桁目を繰り下げしてi桁目以下が0でも1でもいいビットマスクを作成
	auto ms = [ k ];
	if( 0 < k )
	{
		foreach( i; 0L .. k.bsr )
		{
			auto b = 1L << i;
			if( ms.back & b ) continue;
			ms ~= ms.back - b;
		}
	}
	
	// ビットマスクごとに価値の総和を計算
	auto ans = 0L;
	foreach( m; ms )
	{
		auto t = 0L;
		foreach( ab; abs )
		{
			if( ( ab[ 0 ] & ~m ) == 0 ) t += ab[ 1 ];
		}
		ans = max( ans, t );
	}
	return ans;
}


Measured memory_bytes: 4860
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int INF = 1e9;

int main() {
    int N; cin >> N;
    vector<int> A(N); for (int i = 0; i < N; i++) cin >> A[i];

    int ans = INF;
    for (int i = 0; i < N; i++) {
        int num = 0;
        while (A[i]%2 == 0) {
            num++;
            A[i] /= 2;
        }
        ans = min(ans, num);
    }

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


Measured memory_bytes: 256
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let cs = sc.chars();
    let xs: Vec<usize> = cs.iter().map(|&c| ((c as u8) - ('0' as u8)) as usize).collect();

    let mut ans = 0;
    for x in 0..10 {
        for y in 0..10 {
            for z in 0..10 {
                let mut i = 0;
                let mut ok = true;
                while i < n && xs[i] != x { i += 1; }
                if i >= n || xs[i] != x { ok = false; continue; }
                i += 1;
                while i < n && xs[i] != y { i += 1; }
                if i >= n || xs[i] != y { ok = false; continue; }
                i += 1;
                while i < n && xs[i] != z { i += 1; }
                if i >= n || xs[i] != z { ok = false; continue; }
                if ok {
                    ans += 1;
                }
            }
        }
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4352
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

constexpr int N=2e5+1;
int n;
char t[N];

signed main() {

      SPEED;
      scanf("%d%s", &n, t);
      int m = strlen(t);

      // initialize vector size
      vector<vector<vector<int>>> v(3, vector<vector<int>>(n));
      int k = 1;
      rep(i, n) {
        rep(j, 3) {
          v[j][i].resize(k);
        }
        k *= 3;
      }
      int K = k;

      // initialize vector
      rep(i, n) {
        int idx = 0;
        rep(j, 3) {
          for(auto& e: v[j][i]) {
            e = idx;
            idx++;
          }
        }
      }

      rep(j, m) {
        if (t[j]=='S') {
          // swap vector
          swap(v[1], v[2]);
        } else {
          // swap by point
          int w = 0;
          rep(i, n) {
            auto v0 = v[0][i][w];
            auto v1 = v[1][i][w];
            auto v2 = v[2][i][w];
            v[1][i][w] = v0;
            v[2][i][w] = v1;
            v[0][i][w] = v2;
            w = v2;
          }
        }
      }

      // recover
      vector<int> ans(K);
      k = 1;
      rep(i, n) {
        for(int j=1; j<=2; j++) {
          for(auto e: v[j][i]) {
            for(int idx=e; idx<K; idx+=(k*3)) {
              ans[idx] += j*k;
            }
          }
        }
        k *= 3;
      }

      for(auto e: ans) {
        printf("%d ", e);
      }
      return 0;
    }


Measured memory_bytes: 9392
int main(void){
int week;
int money = 100000;
int i;
 
scanf("%d", &week);
 
for(i=0; i<week; i++){
money += money * 0.05;
if(money % 1000 > 0){
money += 1000;
money -= money%1000;
}
}
printf("%d\n", money);
return 0;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示

typedef pair<int, int> PI;
typedef pair<ll, ll> 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;
};

vector<int> divisor(int n) {
  vector<int> ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(All(ret));
  reverse(All(ret));
  return (ret);
};

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  int total_A = 0;
  rep(i, 0, N) {
    cin >> A[i];
    total_A += A[i];
  }

  auto ds = divisor(total_A);
  int l, r;
  for (auto gcd: ds) {
    if (gcd == 1) {
      cout << gcd << endl;
      return 0;
    }

    vector<int> mod_A;
    rep(i, 0, N) {
      if (A[i] % gcd != 0) {
        mod_A.pb(A[i] % gcd);
      }
    }

    if (mod_A.empty()) {
      cout << gcd << endl;
      return 0;
    }

    sort(All(mod_A));

    vector<int> mod_A2;
    for (int ele: mod_A) {
      mod_A2.pb(gcd - ele);
    }

    reverse(All(mod_A2));

    vector<int> mod_A_total = mod_A;
    rep(i, 1, mod_A_total.size()) {
      mod_A_total[i] += mod_A_total[i-1];
    }

    vector<int> mod_A2_total = mod_A2;
    rep(i, 1, mod_A2_total.size()) {
      mod_A2_total[i] += mod_A2_total[i-1];
    }

    int size = mod_A_total.size();

    rep(i, 0, mod_A_total.size()-1) {
      int mod_A_cnt = mod_A_total[i];
      int mod_A2_cnt = mod_A2_total[size - 2 - i];
      if (mod_A_cnt == mod_A2_cnt && mod_A_cnt <= K) {
        cout << gcd << endl;
        return 0;
      }
    }
  }

  return 0;
};


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

#define  ll         long long
#define  llu        unsigned long long
#define  mod        1000000007
#define  pi         ((2.0)*acos(0.0))
#define  pb         push_back
#define  pf         push_front
#define  eb         emplace_back
#define  mp         make_pair
#define  all(x)     (x).begin(),(x).end()
#define  X          first
#define  Y          second

/*loop*/
#define  fr(i,m,n)   for(ll i=m;i<n;++i)

/*output shortcuts*/
#define  nl         "\n"
#define  Yes        cout<<"Yes\n"
#define  yes        cout<<"yes\n"
#define  YES        cout<<"YES\n"
#define  No         cout<<"No\n"
#define  no         cout<<"no\n"
#define  NO         cout<<"NO\n"

ll a[10000000];

/*ll c(ll i,ll n)
{
    if(i>n)
        return 0;

    return abs(a[i]-a[i+1]);
}*/
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll n;
    cin>>n;

    ll a[n];
    fr(i,0,n)
    cin>>a[i];

    ll dp[n];
    dp[n-1]=0;

    for(ll i=n-2; i>=0; i--)
    {
       if(i+2 < n) dp[i]= min( (dp[i+1] + abs(a[i]-a[i+1]) ) , (dp[i+2] + abs(a[i]-a[i+2]) ) );
       else
        dp[i] = dp[i+1] + abs(a[i] - a[i+1]);
    }

    cout<<dp[0]<<nl;

return 0;
}



Measured memory_bytes: 5100
#include <iostream>

using namespace std;

int main(){
  int n,l,r,a,b;
  while(cin>>n,n){
    a=b=0;
    while(n--){
      cin>>l>>r;
      if(l==r){
	a+=l;b+=l;
      }
      else (r<l)?a+=l+r:b+=l+r;
    }
    cout<<a<<' '<<b<<endl;
  }
  return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    long double w, h, x, y; cin >> w >> h >> x >> y;

    if(x * 2 == w && y * 2 == h){
        printf("%.10Lf", w * h / 2);
        cout << ' ' << 1 << endl;
    }else{
        printf("%.10Lf", w * h / 2);
        cout << ' ' << 0 << endl;
    }

    return 0;
}


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


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    n, m = map(int, input().split())
    abl = []
    for _ in range(m):
        a,b = map(int, input().split())
        abl.append([a,b])

    uf = UnionFind(n)
    ans_r = []
    curr_ans_minus = 0
    for ab in reversed(abl):
        a,b = ab
        if not uf.same(a-1,b-1): 
            a_size = uf.size(a-1)
            b_size = uf.size(b-1)
            curr_ans_minus += (a_size+b_size)*(a_size+b_size-1)//2
            curr_ans_minus -= (a_size*(a_size-1)//2 + b_size*(b_size-1)//2)
            uf.union(a-1,b-1)
        ans_r.append(curr_ans_minus)


    all_sum = n*(n-1)//2
    for v in reversed(ans_r[:-1]):
        print(all_sum-v)
    print(all_sum)

if __name__ == "__main__":
    main()

Measured memory_bytes: 27648
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

void solve()
{
    ll n,x;
    cin>>n>>x;
    if(n*500>=x)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <bits/stdc++.h>
using namespace  std;
const int N=200005;
long long arr[N];
int main() {



 long long n;
 int maxi=0;
 int index;
 vector<int>vc;
 cin>>n;
multiset<int>ls;
 for(int i=0;i<n;i++) {
     cin >> arr[i];
    vc.push_back(arr[i]);
 }
 sort(vc.begin(),vc.end());
 int k=vc[vc.size()-1];
 int k2=vc[vc.size()-2];


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

if(arr[i]==k)cout<<k2<<endl;
else cout<<k<<endl;




}




    return 0;
}


Measured memory_bytes: 4084
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll mod = 998244353;

map<int, int> zip;
VI unzip;
void compress_coordinate(VI x){
    int n = x.size();
    REP(i,n) unzip.push_back(x[i]);
    sort(ALL(unzip));
    unzip.erase(unique(ALL(unzip)), unzip.end());
    REP(i,unzip.size()) zip[unzip[i]] = i;
}

struct BIT{
    int n;
    VL bit;

    BIT(){}
    BIT(int x){
        n = x;
        bit.assign(n+1, 0);
    }

    void init(int x){
        n = x;
        bit.assign(n+1, 0);
    }

    void add(int i, ll x){
        i++;
        while (i <= n){
            bit[i] += x;
            i += i & -i;
        }
    }

    // [0, i]
    ll sum(int i){
        i++;
        ll ret = 0;
        while (i > 0){
            ret += bit[i];
            i -= i & -i;
        }
        return ret;
    }

    // [l, r)
    ll sum(int l, int r){
        if (l >= r) return 0;
        return sum(r-1) - sum(l-1);
    }
};

int main() {
    int n;
    cin >> n;
    vector<P> p(n);
    VI cs(n);
    REP(i,n){
        p[i].first = in();
        p[i].second = in();
        cs[i] = p[i].second;
    }
    sort(ALL(p));
    compress_coordinate(cs);

    VI a(n);
    REP(i,n) a[i] = zip[p[i].second];

    VL two(n + 1);
    two[0] = 1;
    REP(i,n) two[i + 1] = (two[i] * 2) % mod;

    BIT bit(n);
    ll ans = 0;
    REP(i,n){
        ll tmp = two[n - 1] - 1;
        tmp -= two[i] - 1;
        tmp -= two[n - i - 1] - 1;
        tmp -= two[a[i]] - 1;
        tmp -= two[n - a[i] - 1] - 1;
        ll lb = bit.sum(a[i]);
        tmp += two[lb] - 1;
        tmp += two[i - lb] - 1;
        tmp += two[a[i] - lb] - 1;
        tmp += two[n - i - 1 - (a[i] - lb)] - 1;

        tmp = (tmp + two[n - 1]) % mod;
        tmp = (tmp + mod) % mod;
        ans = (ans + tmp) % mod;

        bit.add(a[i], 1);
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
	int n,q,l,r;
	string s;
	cin>>n>>q;
	cin>>s;
	vector<int> v(n,0);
	vector<int> sum(n,0);
	for(int i=0;i<n-1;i++){
		if(s[i]=='A'){
			if(s[i+1]=='C'){
				v[i+1]++;
			}
		}
	}
	for(int i=1;i<=n-1;i++){
		sum[i]=v[i]+sum[i-1];
	}
	while(q--){
		cin>>l>>r;
		cout<<sum[r-1]-sum[l-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1ll<<30;
const ll longINF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

template<typename T> struct BIT {
	vector<T> bit;
	int n;
	
	BIT() {}
	BIT(int n) : bit(vector<T>(n + 2, 0)), n(n) {}
	
	T sum(int i) {
		i++;
		T s = 0;
		while (i > 0) {
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}
	
	void add(int i, T x) {
		i++;
		while (i <= n) {
			bit[i] += x;
			i += i & -i;
		}
	}
	
	T pquery(int i) {
		return sum(i) - sum(i - 1);
	}
	
	int lower_bound(T x) {
		int l = -1, r = bit.size();
		while (r - l > 1) {
			int m = (l + r) / 2;
			
			if (sum(m) >= x) r = m;
			else l = m;
		}
		if (r == bit.size()) r = -1;
		
		return r;
	}
};

int N;
ll P[112345];
BIT<int> bit(112345);

int main() {
	cin >> N;
	REP(i, N) scanf("%lld", P + i);
	
	vector<pll> v;
	REP(i, N) v.push_back(pll(P[i], i));
	sort(ALL(v), greater<pll>());
	
	ll ans = 0, cc = 0;
	bit.add(v[0].se, 1);
	FOR(i, 1, N) {
		pll cur = v[i];
		int p = cur.se;
		int l1 = bit.lower_bound(bit.sum(p));
		int l2 = bit.lower_bound(bit.sum(p) - 1);
		
		int r1 = bit.lower_bound(bit.sum(p) + 1);
		int r2 = bit.lower_bound(bit.sum(p) + 2);
		if (bit.sum(p) == 0) l1 = l2 = -1;
		if (l1 > -1 && bit.sum(l1) == 1) l2 = -1;
		if (r1 == -1) r1 = N;
		if (r2 == -1) r2 = N;
		
		
		ll pat = 0;
		pat += (l1 - l2) * (r1 - p);
		pat += (p - l1 - 1) * (r2 - r1);
		pat += r2 - r1;
		
		ans += cur.fi * pat;
		bit.add(p, 1);
		cc += pat;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3700
N = int(input())
alist = list(map(int, input().split()))

blist = []
for i in range(N):
    blist.append(alist[i]-i-1)

blist.sort()
mid = blist[len(blist)//2]

ans = 0

for i in range(N):
    ans += abs(blist[i]-mid)

print(ans)


Measured memory_bytes: 99796
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((i8[:], ), cache=True)
def main(L):
    L.sort()
    N = len(L)
    ans = 0
    for k in range(N):
        for j in range(k):
            for i in range(j):
                if L[i] == L[j] or L[j] == L[k]:
                    continue
                if L[i] + L[j] > L[k]:
                    ans += 1
    return ans

L = np.array(read().split(), np.int64)[1:]

print(main(L))

Measured memory_bytes: 106808
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
m = n // 2
ca = Counter(a)

if n % 2 == 1 and ca[0] == 1 and all(ca[(i+1)*2] == 2 for i in range(m)):
    ans = (2 ** m) % (10 ** 9 + 7)
    print(ans)
elif n % 2 == 0 and all(ca[i*2 + 1] == 2 for i in range(m)):
    ans = (2 ** m) % (10 ** 9 + 7)
    print(ans)
else:
    print(0)


Measured memory_bytes: 14820
module SimpleUndirectedGraphic
    require 'set'

    def each_connected_component(&block)
        return enum_for(__method__) unless block_given?
        reached = Set.new
        each_node do |s|
            next if reached.include?(s)
            cc = Set[s]
            queue = [s]
            until queue.empty?
                u = queue.shift
                each_neighbour(u) do |v|
                    next if cc.include?(v)
                    cc << v
                    queue << v
                    reached << v
                end
            end
            block.call(cc)
        end
    end
end

class Hash
    include SimpleUndirectedGraphic
    alias each_node each_key
    def each_neighbour(u)
        self[u].each do |v|
            yield(v)
        end
    end
end

loop do
    n, m = gets.split.map(&:to_i)
    break if n == 0
    g = {}
    (1..n).map {|i| g[i] = Set.new}
    m.times do
        u, v = gets.split.map(&:to_i)
        g[u] << v
        g[v] << u
    end

    isolated = 0
    cc = 0

    g.each_connected_component do |a|
        if a.size == 1
            isolated += 1
        else
            cc += 1
        end
    end

    if cc > 0
        p (1 + 2 ** (cc + isolated)) % 1_000_000_007
    else
        p 2 ** isolated % 1_000_000_007
    end
end

Measured memory_bytes: 141328
fn main() {
    proconio::input! {
    a:usize,
    mut b:[isize;a],
    }
    b.sort();
    b.reverse();
    for i in 1..a {
        b.push(0);
        b.push(0);
        b[0]+=b[i*2];
        b[1]+=b[i*2+1];
    }
    println!("{}",b[0]-b[1])
}

Measured memory_bytes: 2140
"""

3つの閉路が作れる条件とは？

まず作れない条件を考えてみるか
奇数個の辺が出てる頂点があったら絶対作れない

グラフは連結→4本出ている頂点が2つ以上 or 6本出てる頂点が1つ以上あるはず

二つのサーキットを合体して1つにすることは可能か？→触れていれば可能
逆にサーキット上で2回以上同じ点を通るなら2つの閉路に分割可能
全ての頂点に2本以上通っていたら一つの大きい閉路にできる？→可能そう

4本出 * 2の時だけ(本当か)曲者か？
一つでも4本出の内一つの頂点で共通の辺があれば可能？
"""
import sys
from collections import deque

N,M = map(int,input().split())

lis =  [ [] for i in range(N) ]

for i in range(M):

    a,b = map(int,input().split())
    a -= 1
    b -= 1

    lis[a].append(b)
    lis[b].append(a)

four_queue = []
nums = [0] * max(5,N+1)
for i in range(N):
    nums[len(lis[i])] += 1
    if len(lis[i]) == 4:
        four_queue.append(i)

up_six = False
four_num = nums[4]


for i in range(N+1):

    if i % 2 == 1 and nums[i] > 0:
        print ("No")
        sys.exit()

    elif i >= 6 and nums[i] > 0:
        up_six = True

if up_six or four_num > 2:
    print ("Yes")
    sys.exit()
elif four_num < 2:
    print ("No")
    sys.exit()
else:

    x = four_queue[0]
    y = four_queue[1]
    flag = False

    #print (x,y)

    for i in lis[x]:

        dis = [float("inf")] * N
        dis[x] = 0
        dis[i] = 1
        q = deque([i])
        #print ("i",i)

        while len(q) > 0:

            #print (q)

            now = q.popleft()

            for j in lis[now]:
                #print (j)
                if i != now and j == x:
                    print ("Yes")
                    sys.exit()
                elif j == y:
                    break

                elif dis[j] > dis[now] + 1:
                    dis[j] = dis[now] + 1
                    q.append(j)

print ("No")

Measured memory_bytes: 68256
#include<bits/stdc++.h>
using namespace std;
int n,m;
int dp[100010];
vector<int> radj[100010];
int rec(int x){
	if(dp[x]>=0)
	   return dp[x];
	if(radj[x].empty())
	   return dp[x]=0;
	dp[x]=dp[radj[x][0]]+1;
	for(int i=0;i<radj[x].size();i++){
		dp[x]=max(rec(radj[x][i])+1,dp[x]);
	}
	return  dp[x];
}
int a,b;
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		cin>>a>>b;
		radj[a].push_back(b);
	}
	memset(dp,-1,sizeof(dp));
	int ans=0;
	for(int i=1;i<=n;i++)
	   ans=max(ans,rec(i));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8192
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R

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

	cin >> N >> M >> K;
	for (int i = 0; K > 0; i++) {
		K -= N;
		if (i % 7 == 6)K -= M;
		if (K <= 0)cout << i + 1 << endl;
	}
}


Measured memory_bytes: 3208
using System;
using System.IO;
using System.Linq;

namespace AtCoder {
	class Program {
		public static void Main(string[] args) {
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });

			var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int k = input[0];
			int n = input[1];
			int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int min = a[n - 1] - a[0];
			for (int i = 1; i < n; i++) {
				int x = a[i - 1] + k - a[i];
				min = min > x ? x : min;
			}
			Console.WriteLine(min);

			Console.Out.Flush();
		}
	}
}

Measured memory_bytes: 34780
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
#define int long long

int extgcd(int a, int b, int &x, int &y) {
  int g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}

signed main(void){
  int a,b,c;
  int buf1,buf2;
  int gcd;
  cin >> a >> b >> c;
  gcd = extgcd(a,b,buf1,buf2);
  if(c % gcd == 0){
    cout << "YES\r\n";
  }else{
    cout << "NO\r\n";
  }
  return 0;
}


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

int main() {

  int A,B,C;

  cin >> A >> B >> C ;
  if(A==5&&B==7&&C==5){
    cout << "YES" << endl;
  }
  else if(A==7&&B==5&&C==5){
    cout << "YES" << endl;
  }
  else if(A==5&&B==5&&C==7){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

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

#define all(x) begin(x), end(x)
#define cina(s, n, a) for(int quer = s; quer < n; quer++) cin >> a[quer]
#define mod(a, b) (abs(b) + (a % abs(b))) % abs(b)
#define setp(x) fixed << setprecision(x)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll MOD = 1e9 + 7;
const int N = 200500; // are you sure?
bool is(string &s){
    int n = s.size();
    for(int i = 0; i < n / 2; i++){
        if(s[i] != s[n - i - 1]) return false;
    }
    return true;
}
void solve(){
    string s;
    cin >> s;
    int n = s.size();
    string s1 = s.substr(0, n / 2), s2 = s.substr((n + 3) / 2 - 1);
    if(is(s) && is(s1) && is(s2)) cout << "Yes";
    else cout << "No";
}

int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q = 1;
    //cin >> q;
    for (int i = 1; i <= q; i++) {
        solve();
    }
}


Measured memory_bytes: 256
l = list(map(int, input().split(" ")))

a, b, c = sorted(l)[::-1]

diff_1 = a - b
diff_2 = a - c
diff = diff_1 + diff_2

if diff % 2 == 0:
    print(diff // 2)

else:
    print((diff + 3) // 2)


Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>

int main(){
    char str[1001];
    char order[10];
    char p[1001];
    char temp[1001];
    int a,b,q,i,j;
    scanf("%s%d",str,&q);
    
    for(i=0;i<q;i++){
        scanf("%s%d%d",order,&a,&b); 
        
        if(strcmp(order,"replace")==0){
            scanf("%s",p);
            for(j=0;j<=b-a;j++){
                str[a+j]=p[j];
            }
        }
        
        else if(strcmp(order,"reverse")==0){
            strcpy(temp,str);
            for(j=0;j<=b-a;j++){
                str[b-j]=temp[a+j];
            }
        }
        
        else if(strcmp(order,"print")==0){
            for(j=a;j<=b;j++){
                printf("%c",str[j]);
            }
            printf("\n");
        }
        
    }
    return 0;
}


Measured memory_bytes: 2108
#pragma region Macros

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

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int N;
    cin >> N;
    vvi txy(N, vi(3, 0));
    REP(i, N) {
        REP(j, 3) {
            cin >> txy[i][j];
        }
    }

    vi xy(2, 0);
    int diff = 0;
    int time = 0;

    REP(i, N) {
        time = txy[i][0] - time;
        diff = 0;
        diff += abs(xy[0] - txy[i][1]);
        diff += abs(xy[1] - txy[i][2]);
        if (time < diff) {
            cout << "No";
            return;
        }
        if ((time - diff) % 2 != 0) {
            cout << "No";
            return;
        }
        xy[0] = txy[i][1];
        xy[1] = txy[i][2];
        time = txy[i][0];
    }
    cout << "Yes";
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 8672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N;
ll M,temp;
vector<ll> a,b;
unordered_map<ll,ll> mp;

int main(){
    cin >> N >> M;
    a.push_back(0);
    for(int i = 1; i <= N; ++i){ cin >> temp; a.push_back(temp);}
    b.push_back(0);
    for(int i = 1; i <= N; ++i){
        b.push_back(a[i]);
        b[i] += b[i-1];
        b[i] %= M;
        mp[b[i]]++;
    }
    mp[0]++;
    
    ll sum = 0;
    
    for(auto itr = mp.begin(); itr != mp.end(); ++itr){
        sum += (itr->second)*(itr->second - 1)/2;
    }
    
    cout << sum << endl;
    
}

Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;

const int max_n = 100010;
ll dp[max_n];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,m;cin>>n>>m;

    int ary[n+1];
    rep(i,n)
    {
        cin >> ary[i];
    }
    ary[n] = 1e7;


    rep(i,n+1) dp[i]=0;
    dp[0] = 1;
    int now_at = 0;
    REP(i,1,n+1)
    {
        if (i==1)
        {
            if (ary[now_at]!=1)
            {
                dp[i] += dp[i-1];
            }
            else
            {
                now_at++;
            }
        }
        else
        {
            if (ary[now_at]!=i)
            {
                dp[i]+= dp[i-1]+dp[i-2];
            }
            else
            {
                now_at++;
            }
            
        }
        dp[i]%=MOD;
    }
    cout << dp[n]<< endl;

}

Measured memory_bytes: 1408
def list_add(li1, li2):
    return list(map(sum, zip(li1, li2)))


def dfs(price, knowledge, depth):
    if (min(knowledge) >= X):
        ansList.append(price)
    if depth == N:
        return
    dfs(price, knowledge, depth + 1)
    dfs(price + priceList[depth],
        list_add(KnowList[depth], knowledge), depth + 1)


N, M, X = map(int, input().split(" "))
KnowList = [[] for i in range(N)]
priceList = [0] * N
for i in range(N):
    tmp = [int(i) for i in input().split(" ")]
    priceList[i] = tmp[0]
    KnowList[i] = tmp[1:]
price = 0
ansList = []
knowledge = [0] * M
dfs(price, knowledge, 0)
if (len(ansList) == 0):
    ansList.append(-1)
print(min(ansList))


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

int main() {
  vector<char> a(9);
  rep(i,9) cin>>a[i];
  cout << a[0] << a[4] << a[8] << endl;
}


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    int a, b;
    cin >> a >> b;

    int ans = (a+b)/2;
    if((a+b)%2 != 0) cout << ans + 1 << endl;
    else cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
s = list(input())
k = int(input())
for i in range(len(s)):
    if s[i] != "a" and (123-ord(s[i])) <= k:
        k -= (123-ord(s[i]))
        s[i] = "a"
    if i == len(s)-1:
        s[i] = (chr((((ord(s[i])+(k%26))-97)%26)+97))

print("".join(s))



# a = "z"
# a = ord(a)
# print(a)

Measured memory_bytes: 4156
l=[list(input().split()) for i in range(3)]
n=int(input())
li=[input() for i in range(n)]
if l[0][0] in li and l[0][1] in li and l[0][2] in li:
    print('Yes')
elif l[1][0] in li and l[1][1] in li and l[1][2] in li:
    print('Yes')
elif l[2][0] in li and l[2][1] in li and l[2][2] in li:
    print('Yes')
elif l[0][0] in li and l[1][0] in li and l[2][0] in li:
    print('Yes')
elif l[0][1] in li and l[1][1] in li and l[2][1] in li:
    print('Yes')
elif l[0][2] in li and l[1][2] in li and l[2][2] in li:
    print('Yes')
elif l[0][0] in li and l[1][1] in li and l[2][2] in li:
    print('Yes')
elif l[0][2] in li and l[1][1] in li and l[2][0] in li:
    print('Yes')
else: print('No')

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vi2 vector<vector<int>>
#define vl vector<long long>
#define vl2 vector<vector<long long>>

template <class T> T maxAny(T a, T b){
    if(a > b) return a;
    else return b;
}

template <class T> T minAny(T a, T b){
    if(a > b) return b;
    else return a;
}

int main(){
    int a, b;
    cin >> a >> b;
    rep(i, maxAny(a, b)){
        cout << minAny(a, b);
    }
    cout << endl;
}

Measured memory_bytes: 3524
///=======================///
/// coder: Andy - Tohrumi ///
///=======================///

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define INF LLONG_MAX
#define pb push_back
#define mp make_pair
#define endl '\n'
#define rep(i, s, n) for(int i = s; i < n; i++)
#define Rep(i, n, s) for(int i = n; i > s; i--)
#define repl(i, s, n) for(ll i = s; i < n; i++)
#define Repl(i, n, s) for(ll i = n; i > s; i--)
using namespace std;
typedef pair<ll, ll> pll;	typedef pair<int, int> ii;
typedef vector<pll> vll;	typedef vector<string> vs;		typedef vector<ii> vii;
typedef vector<int> vi; 	typedef vector<ll> vl;

signed main() {
	fastio;
	ll n, k, s; cin >> n >> k >> s;
	ll a[n];
	rep(i, 0, k) {
		a[i] = s;
	}
	ll cur = k, val;
	if(s == 1000000000) val = 999999999;
	else val = s + 1;
	rep(i, cur, n) {
		a[i] = val;
	}
	rep(i, 0, n) cout << a[i] << " ";
	return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vpi = vector<pii>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpl = vector<pll>;
using vs = vector<string>;

int main()
{
    int n;
    cin >> n;
    vi ps;
    ps.resize(n);
    for(int i=0; i<n; i++) cin >> ps.at(i);

    int nin = ps.at(0);
    int cnt = 1;
    for(int i=1; i<n; i++)
    {
        if(ps.at(i) < nin)
        {
            nin = ps.at(i);
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val h = sc.nextLong()
    val n = sc.nextInt()
    val a = (0 until n).map {
        sc.next().toInt()
    }

    println(ans(h, a.sum()))
}

fun ans(h: Long, sum: Int): String {
    if (sum >= h) {
        return "Yes"
    }
    return "No"
}

Measured memory_bytes: 45860
#include <stdio.h>
#include <math.h>

#define SQ(X) \
  ( (X) * (X) )
#define SQDIST(X1,Y1,X2,Y2) \
  ( SQ( (X2) - (X1) ) + SQ( (Y2) - (Y1) ) )
#define DIST(X1,Y1,X2,Y2) \
  ( sqrt ( SQDIST(X1,Y1,X2,Y2) ) )

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int n;

  scanf ( "%d", &n );

  while ( n-- )
  {
    double  x1, x2, x3,
            y1, y2, y3;
    double  A[ 2 ][ 2 ], detA;
    double  B[ 2 ];
    double  C[ 2 ];

    scanf ( "%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3 );
    A[ 0 ][ 0 ] = 2 * x2 - 2 * x1;
    A[ 1 ][ 0 ] = 2 * x3 - 2 * x1;
    A[ 0 ][ 1 ] = 2 * y2 - 2 * y1;
    A[ 1 ][ 1 ] = 2 * y3 - 2 * y1;
    detA        = A[ 0 ][ 0 ] * A[ 1 ][ 1 ] - A[ 0 ][ 1 ] * A[ 1 ][ 0 ];
    B[ 0 ]      = SQ( x2 ) + SQ( y2 ) - SQ( x1 ) - SQ( y1 );
    B[ 1 ]      = SQ( x3 ) + SQ( y3 ) - SQ( x1 ) - SQ( y1 );

    C[ 0 ] = ( B[ 0 ] * A[ 1 ][ 1 ] - A[ 0 ][ 1 ] * B[ 1 ] ) / detA;
    C[ 1 ] = ( A[ 0 ][ 0 ] * B[ 1 ] - B[ 0 ] * A[ 1 ][ 0 ] ) / detA;

    printf ( "%.3lf %.3lf %.3lf\n",
      C[ 0 ], C[ 1 ],
      DIST( C[ 0 ], C[ 1 ], x1, y1 ) );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int j,k;
    cin >>n>>j>>k;
    if(j%n==0 || k%n==0) puts("OK");
    else{
        int s = (j/n)+1;
        if(s*n<=k) puts("OK");
        else{
            puts("NG");
        }
    }
}


Measured memory_bytes: 3544
L, R = map(int, input().split())
ans = 10000
 
for i in range(L, min(R + 1, L + 2020)):
  for j in range(i,  min(R + 1, L + 2020)):
    if i < j:
      ans = min(ans, (i * j)%2019)
 
print(ans)

Measured memory_bytes: 3060
V,E,r = map(int,input().split())
edges = [tuple(map(int,input().split())) for _ in range(E)]
dist = [float("inf") for _ in range(V)]
dist[r-1] = 0
for i in range(V+1):
    for edge in edges:
        if edge[0] != float("inf") and dist[edge[1]-1] > dist[edge[0]-1]+edge[2]:
            dist[edge[1]-1] = dist[edge[0]-1]+edge[2]
            if i==V-1: print("NEGATIVE CYCLE"); exit()
print("\n".join(str(dist[e-1]) if dist[e-1] != float("inf") else "INF" for e in range(V)))


Measured memory_bytes: 5992
#include <bits/stdc++.h>
  using namespace std;
 
int main(){
  int F=0;
  int S=0;
  for(int i=0;i<3;i++){
    int n;
    cin>>n;
    if(n==5){
      F++;
    }else if(n==7){
      S++;
    }
  }
  if((F==2)&&(S==1)){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll S;
    cin >> S;

    ll x3 = (S%1000000000L) == 0 ? 0 : (1000000000L - (S%1000000000L));
    ll y3 = (S/1000000000) + ((S%1000000000L)==0?0:1);

    if(y3 < 1){
        printf("%d %d %d %d %d %d\n", 0, 0, 1, 0, 0, S);
    }else{
        printf("%d %d %d %d %d %d\n", 0, 0, 1000000000, 1, x3, y3);
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
int main(){
  int64_t n,k,a=0;
  cin>>n>>k;
  for(int i=k;i<n+2;i++)a=(a+i*(n-i+1)+1)%MOD;
  cout<<a<<endl;
}

Measured memory_bytes: 3548
#include<iostream>
#include<algorithm>
 
using namespace std;
typedef long long Int;
#define INF (1LL<<60)

Int N;
Int res[900];

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
	Int X,Y,Z;
	cin >> X>>Y>>Z;

	Int n=0;
	while (Y*n+Z*(n+1) <= X) n++;
	cout << n-1 << endl;
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc081c()
}

fun abc081c() {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val aList = readLine()!!.split(" ").map { it.toInt() }

    val grouped = aList.groupBy { it }.map { it.value.size }.toIntArray()

    val answer = grouped.sorted().dropLast(k).sum()

    println(answer)
}


Measured memory_bytes: 110608
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]D - Banned K
            long N = long.Parse(Console.ReadLine());
            var A = ReadLine();

            var balls = new Dictionary<long, long>();

            foreach(var a in A)
            {
                if (!balls.ContainsKey(a))
                {
                    balls.Add(a, 1);
                }
                else
                {
                    balls[a]++;
                }
            }

            var counts = new Dictionary<long, long>();

            foreach(var b in balls)
            {
                var count = b.Value * (b.Value - 1) / 2;
                counts.Add(b.Key, count);
            }

            var sum = counts.Values.Sum();

            foreach(var a in A)
            {
                var ans = sum - counts[a];
                ans += (balls[a] - 1) * (balls[a] - 2) / 2;
                Console.WriteLine(ans);
            }
        }

        static List<long> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => long.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 47684
n,m = map(int,input().split())
l = [[] for i in range(8)]

for i in range(n):
    l1 = list(map(int,input().split()))

    for j in range(8):
        check = 0
        for k in range(3):
            if (j >> k ) & 1:
                check += l1[k]
            else:
                check -= l1[k]
        l[j].append(check)

ans = 0
for i in l:
    i.sort(reverse=True)
    check = sum(i[:m])
    ans = max(ans,check)
print(ans)


Measured memory_bytes: 3408