akhauriyash/Code-Regression huggingface dataset:
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

#[inline]
#[allow(dead_code)]
fn gcd(mut m: u64, mut n: u64) -> u64 {
    if m < n {
        std::mem::swap(&mut m, &mut n);
    }

    loop {
        let k = m % n;
        if k == 0 {
            return n;
        }

        m = n;
        n = k;
    }
}

#[inline]
#[allow(dead_code)]
fn lcm(m: u64, n: u64) -> u64 {
    m / gcd(m, n) * n
}

macro_rules! eprint(
    ($($arg:tt)*) => { {
        use std::io::Write;
        let r = write!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

macro_rules! eprintln(
    ($($arg:tt)*) => { {
        use std::io::Write;
        let r = writeln!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

macro_rules! dbg {
    ($val:expr) => {
        // Use of `match` here is intentional because it affects the lifetimes
        // of temporaries - https://stackoverflow.com/a/48732525/1063961
        match $val {
            tmp => {
                eprintln!(
                    "[{}:{}] {} = {:#?}",
                    file!(),
                    line!(),
                    stringify!($val),
                    &tmp
                );
                tmp
            }
        }
    };
}

fn main() {
    input! {
        a: [u64; 3],
    }

    let max = a.iter().max().unwrap();
    let sub_sum = a.iter().fold(0, |acc, x| acc + (max - x));
    let answer = if sub_sum % 2 == 0 {
        sub_sum / 2
    } else {
        (sub_sum + 1) / 2 + 1
    };
    println!("{}", answer);
}


Measured memory_bytes: 4352
/*
 * FileName:     change_making
 * CreatedDate:  2020-04-03 01:16:56 +0900
 * LastModified: 2020-04-03 01:22:51 +0900
 */

#include <stdio.h>

int main(void){
    int n,count=0;
    scanf("%d",&n);
    count+=n/25;
    int n_1=n-n/25*25;
    count+=n_1/10;
    int n_2=n_1-n_1/10*10;
    count+=n_2/5;
    int n_3=n_2-n_2/5*5;
    count+=n_3;
    printf("%d\n",count);
    return 0;
}



Measured memory_bytes: 2112
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        final int N = sc.nextInt();
        final long D = sc.nextLong();
        final long DD = D * D;
        
        final long[] Xs = new long[N];
        final long[] Ys = new long[N];
        
        for (int i = 0; i < N; i++) {
            Xs[i] = sc.nextLong();
            Ys[i] = sc.nextLong();
        }
        
        long count = IntStream.range(0, N).parallel()
                .filter(i -> Xs[i] * Xs[i] + Ys[i] * Ys[i] <= DD)
                .count();
        
        System.out.println(count);
    }
}


Measured memory_bytes: 63732
#include<bits/stdc++.h>
#define ll long long
const int mod = 998244353;
const int N = 1e6+10;

using namespace std;

ll fac[N+10],rfac[N+10];
int n,k;
inline ll fpm(ll x,ll y){
	ll s=1;
	while(y){
		if(y&1) s=s*x%mod;
		y>>=1; x=x*x%mod;
	}
	return s;
}

void init(){
	fac[0]=1ll;
	for(int i=1; i<=N; ++i) fac[i]=fac[i-1]*i%mod;
	rfac[N]=fpm(fac[N],mod-2);
	for(int i=N-1; i>=0; --i) rfac[i]=rfac[i+1]*(i+1)%mod;
}

ll c(int x,int y){
	if(x<y) return 0;if(x<0) return 0; if(y<0) return 0;
	return fac[x]*rfac[y]%mod*rfac[x-y]%mod;
}

ll rv(int x) { return fpm(x,mod-2);}
int main(){
	//freopen("e.in","r",stdin);
	//freopen("e.out","w",stdout);
	init();
	scanf("%d%d",&n,&k);
	long long ans=0;
	for(int i=n; i<=k; ++i){
		int r=i,b=k-i;
		int t=max(r-n+1,0);
		ans+=c(r+b,b)-c(r+b,b-t);
		ans=(ans%mod+mod)%mod;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 15872
import collections

n, k = map(int, input().split())
A = list(map(int, input().split()))

c = collections.Counter(A)
c = sorted(c.values(),reverse=True)

if len(c) <= k:
    print(0)
    exit()

cnt = 0
for i in range(k):
    cnt += c[i]
print(n-cnt)

Measured memory_bytes: 32572
using System;

namespace ConsoleApplication{
    public class Program{
        public static void Main(string[] args){
            int battleCount = int.Parse(Console.ReadLine());
            int count = 0;
            string battle = null;
            int scoreTaro = 0;
            int scoreHanako = 0;

            //?°????????????±?????????
            while(true){
                count++;
                battle = Console.ReadLine();
                string[] battles = battle.Split(' ');
                //??????????????????????????´??????????????????????????¨?????????
                if(battles[0].Equals(battles[1])){
                    scoreTaro += 1;
                    scoreHanako += 1;
                }else{
                    //??????????¢??????????????????????
                    if(GetWinner(battles)){
                        scoreTaro += 3;
                    }else{
                        scoreHanako += 3;
                    }
                }
                if(count == battleCount){
                    break;
                }
            }
            Console.WriteLine(scoreTaro +" "+ scoreHanako);

        }
        ///????????????????????????
        ///string[0]:taro  ??????????????´???true
        ///string[1]:hanako??????????????´???false
        private static bool GetWinner(string[] players){
            string taro = players[0];
            string hanako = players[1];
            bool winTaro = true;
            bool winHanako = false;

            for(int i=0; i<taro.Length; i++){
                //??????????°??????????????????????(????????????????????\???????????????????????????????????????)
                if(hanako.Length <= i){
                    return winTaro;
                }
                //??????????????????????????????
                if(taro[i] < hanako[i]){
                    return winHanako;
                }else if(hanako[i] < taro[i]){
                    return winTaro;
                }
            }
            return winHanako;
        }
    }
}

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

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

    int ans = 0;
    for(int i=0;i<n;i++){
        if(i+2 >= n) continue;
        int mx = max({p[i],p[i+1],p[i+2]});
        int mn = min({p[i],p[i+1],p[i+2]});
        int mid = p[i] + p[i+1] + p[i+2] - mx - mn;
        if(p[i+1] == mid){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cstring>
#define rg register
#define LL long long
using namespace std;
const int MAXN=5000;
int N,A,B,X;
int fir,sec,thi,ans=0x7fffffff;

template <typename T> inline void in(T &a) {
	T ch = getchar(), f = 1;
	for(a = 0; !isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
	for( ; isdigit(ch); ch = getchar()) a = (a << 3) + (a << 1) + ch - '0';
	a *= f;
}

template <typename T> inline void print(T x) {
	if(x < 0) putchar('-'), x = -x;
	if(x > 9) print(x / 10);
	putchar(x % 10 + '0');
}

int main(){
	in(N),in(A),in(B);
	
	for(rg int i=1;i<=N;i++){
		in(X);
		if(X<=A) fir++;
		else if(A<X&&X<=B) sec++;
		else thi++;
	} 

	ans=min(ans,min(fir,min(sec,thi)));
	
	print(ans),puts("");
	
    return 0;
}


Measured memory_bytes: 256
/*
    e
*/
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define N 15
#define bit(i) (1 << i)

using namespace std;

int n, m;
int f[5000];

inline void cmin(int &u, const int delta) { (u > delta) && (u = delta); }
inline int Rd() {
	int x = 0; char ch = getchar();
	while(!isdigit(ch)) ch = getchar();
	while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
	return x;
}

int main() {
	n = Rd(), m = Rd();
	int upp = 1 << n;
	memset(f, 32, sizeof f), f[0] = 0;
	for(int i = 1; i <= m; ++i) {
		int a = Rd(), b = Rd(), mask = 0;
		for(int j = 1; j <= b; ++j) {
			int v = Rd();
			mask |= bit(v - 1);
		}
		for(int sta = 0; sta < upp; ++sta) {
			cmin(f[sta | mask], f[sta] + a);
		}
	}
	
	if(f[upp - 1] == f[4999]) {
		puts("-1");
		return 0;
	}
	cout << f[upp - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <fstream>
#include <string>
#include <sstream>
#include <math.h>
#include <set>
#include <map>
using namespace std;
#define rep(i,n) for(int i = 0; i < n ; i++)
#define pb push_back
static const int INF = 1000000;

typedef pair<int, int> P;
typedef pair<P, int> PP;

int main(void){
  string a; cin >> a;
  int cnt = 0;
  rep(i,a.length()-1){
    if(a[i] != a[i+1]){
      cnt += 1;
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int main(void)
{
  int a, b, i, j, d = 0, f, g, h;
  scanf("%d",&a);
  int x[a];
  char c[12];
  for(i=0;i<a;i++)
  {
    scanf("%s %d",c,&b);
    if(c[0]=='i')
    {
      x[i]=b;
    }
    else if(c[6]=='F')
    {
      i-=2;a-=2;
    }
    else if(c[6]=='L'){
      i--;a--;d++;
    }
    else{
      i--;a--;
      f=0;
      for(j=i;j>=0;j--){
        if(f>0)break;
        if(b==x[j]){
          g=i-j;
          h=0;
          f++;
          while(g!=h++)x[j+h-1]=x[j+1+h-1];
          i--;a--;
        }
      }
    }
  }
  for(i=0;i<a-d;i++){
        if(i==a-d-1)printf("%d\n",x[a-1-i]);
    else printf("%d ",x[a-1-i]);
  }
    return 0;
}

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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    string S;
    std::cin >> S;

    vector<pair<int, int>> p;
    int  index   = 0;
    int  r_cnt   = 0;
    int  l_cnt   = 0;
    while(index < S.size() - 1) {
        if(S[index] == 'L' && S[index + 1] == 'R') {
            // 入力
            p.emplace_back(r_cnt, l_cnt + 1);
            r_cnt = 0;
            l_cnt = 0;
        }
        else if(S[index] == 'L') {
            l_cnt++;
        }
        else if(S[index] == 'R') {
            r_cnt++;
        }

        index++;
    }

    p.emplace_back(r_cnt, l_cnt + 1);

    for(const auto& v : p) {
        REP(i, v.first - 1) {
            std::cout << 0 << " ";
        }

        if((v.first + v.second) % 2 == 1) {
            if(v.first % 2 == 1) {
                std::cout << ((v.first + v.second) / 2) + 1 << " ";
                std::cout << ((v.first + v.second) / 2) << " ";
            }
            else {
                std::cout << ((v.first + v.second) / 2) << " ";
                std::cout << ((v.first + v.second) / 2) + 1 << " ";
            }
        }
        else {
            std::cout << ((v.first + v.second) / 2) << " ";
            std::cout << ((v.first + v.second) / 2) << " ";
        }

        REP(i, v.second - 1) {
            std::cout << 0 << " ";
        }
    }

    std::cout << std::endl;

    return 0;
}


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

using namespace std;

const int MOD=1e9+7;
const double PI=3.14159265359;



int main(){
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int h,w;
    cin>>h>>w;
    vector<string> v(h);
    
    for(auto& s:v)cin>>s;
    
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(v[i][j]=='#'){
                bool works=false;
                for(int i1=max(0, i-1); i1<=min(h-1, i+1); i1++){
                    for(int j1=max(0, j-1); j1<= min(w-1, j+1); j1++){
                        if(i1==i && j1==j) continue;
                        if((i1==i || j1==j) && v[i1][j1]=='#') works=true;
                    }
                }
                if(!works){
                    cout<<"No";
                    //cout<<i<<" "<<j<<endl;
                    return 0;
                }
            }
        }
    }
    
    cout<<"Yes";
    
    
    return 0;
    
    
}


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

int main(){
  string k;
  cin >> k;
  int m = k.size(),w=0,e=0,s=0,n=0;
  for(int i=0;i<m;i++){
    char a = k.at(i);
    if(a=='W') w++;
    if(a=='E') e++;
    if(a=='S') s++;
    if(a=='N') n++;
  }
  if(w==0&&e==0&&n>0&&s>0) cout << "Yes" << endl;
  else if(w>0&&e>0&&n==0&&s==0) cout << "Yes" << endl;
  else if(w>0&&e>0&&n>0&&s>0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int64_t dp[101][100001];

int main(){
    int N, W, w[100], v[100];
    cin >> N >> W;
    for(int i=0; i<N; i++) cin >> w[i] >> v[i];
    for(int i=0; i<N; i++){
        for(int j=0; j<=W; j++){
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            if(j+w[i] <= W) dp[i+1][j+w[i]] = max(dp[i+1][j+w[i]], dp[i][j] + v[i]);
        }
    }
    int64_t ans = 0;
    for(int j=0; j<=W; j++) ans = max(ans, dp[N][j]);
    cout << ans << endl;
    return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

void print_A(int *A, int N)
{
    REP(i, N)
    {
        cout << A[i];
        if (i != N-1) cout << " ";
    }
    cout << endl;
    return;
}

void insertionSort(int *A, int N)
{
    int v, j;
    FOR(i, 1, N)
    {
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v)
        {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        print_A(A, N);
    }
}

int main()
{
    int N;
    int A[100];

    cin >> N;
    REP(i, N)
    {
        cin >> A[i];
    }

    print_A(A, N);
    insertionSort(A, N);
}


Measured memory_bytes: 3100
#include<stdio.h>
#define ll long long 
int main(){
    ll w,h,x,y;
    scanf("%lld%lld%lld%lld",&w,&h,&x,&y);
    double W=w,H=h;
    printf("%lf ",W*H/2);
    printf("%d\n",x+x==w&&y+y==h);
    return 0;
}

Measured memory_bytes: 128
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

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

int main() {
    int n;
    cin >> n;
    vector<int> v(n), p(n), q(n);

    REP(i, n) {
        cin >> p[i];
    }
    REP(i, n) {
        cin >> q[i];
    }
    

    int cnt = 0;
    int num_p = 0;
    int num_q = 0;
    bool flag_same = false;

    iota(v.begin(), v.end(), 1);
    do {
 
        //for (auto x : v) cout << x << " "; cout << "\n";
        //for (auto x : p) cout << x << " "; cout << "\n";
        //for (auto x : q) cout << x << " "; cout << "\n";
        
        flag_same = true;
        REP(i, n) {
             if (v[i] != p[i]) {
                flag_same = false;
            }
        }
        if (flag_same == true) {
            num_p = cnt;
        }
        flag_same = true;
        REP(i, n) {
            if (v[i] != q[i]) {
                flag_same = false;
            }
        }
        if (flag_same == true) {
            num_q = cnt;
        }        
        cnt++;
    } while( next_permutation(v.begin(), v.end()) );

    cout << abs(num_p - num_q) << endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVL vector<vector<ll>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<ll,ll>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;
constexpr int MOD = 1000000007;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

VL prime_decomposition(ll n) {
	ll i = 2;
	VL table{};
	while (i * i <= n) {
		while (n % i == 0) {
			n /= i;
			table.emplace_back(i);
		}
		++i;
	}
	if (n > 1) {
		table.emplace_back(n);
		return table;
	}
}

int main() {
	ll n;
	ll t, a;
	cin >> n >> t >> a;
	VL h(n);
	REP(i, n) { cin >> h[i]; }

	ll ans = 0;
	double min = 1e10;
	//REPC(x, h) {
	REP(i, n) {
		double tmp = t - h[i] * 0.006;
		if (abs(tmp - a) < min) {
			ans = i;
			min = abs(tmp - a);
		}
	}

	cout << ans+1 << endl;
}

Measured memory_bytes: 256
read N M
julia -E"C=zeros(Int,10^5)
for x=split(readline())
C[parse(Int,x)]+=1end
M=$M
s=0
C=conv(C,C)
for i=2*10^5:-1:2
M-=t=min(M,C[i-1])
s+=t*i
end
s"

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

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

   int ans=0;
   for(int i=0;i<N-1;i++){
      int a=A*(x[i+1]-x[i]);
      int b=B;
      ans+=min(a,b);
   }
   cout<<ans<<endl;
}


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

#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i<=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    long long x,y;
    cin >> x >> y;
    if(x % y == 0){
        cout << "-1" << endl;
        return  0;
    }else{
         cout << x << endl;
        }
    
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a,b;
ll f(ll a,ll b){
    ll A=4*a*b-n*b-n*a;
    ll B=n*a*b;
    if(A>0&&B>0&&B%A==0)return B/A;
    return 0;
}
int main(void){
    cin>>n;
    for(ll i=1LL;i<=3500;i++){
        for(ll j=1LL;j<=3500;j++){
            if(f(i,j)==0)continue;
            else{
                cout<<i<<" "<<j<<" "<<f(i,j)<<endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int H,W;
  char pic[300][300];
  char str[300];
  int i,j;

  scanf("%d %d",&H,&W);

  //printf("%d %d\n",H,W);

  for(i = -1;i < H;i++)
    {
      //printf("i = %d\n",i);
      gets(str);
      sscanf(str,"%s",pic[i]);
    }

  for(i = 0;i < W + 2;i++)
    printf("#");
  printf("\n");

  for(i = 0;i < H;i++)
    {
      printf("#");
      for(j = 0;j < W;j++)
        printf("%c",pic[i][j]);
      printf("#\n");
    }

  for(i = 0;i < W + 2;i++)
    printf("#");
  printf("\n");

  return 0;
}





Measured memory_bytes: 256
import heapq
N,M = map(int,input().split())
h=[]
li = input().split()
for i in li:
    heapq.heappush(h, -int(i))

for i in range(M):
    z = heapq.heappop(h) / 2
    heapq.heappush(h, z)
c=0
for i in h:
    c += int(i)
print(-c)

Measured memory_bytes: 85400
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define int long long int
#define ull unsigned long long

using namespace std;
const int MOD = 1e9 + 7;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin>>n;
    int a[n], b[n], c[n-1];
    for(int i = 0;i<n;i++){
    	cin>>a[i];
    }
    for(int i = 0;i<n;i++){
    	cin>>b[i];
    }
    for(int i = 0;i<n-1;i++){
    	cin>>c[i];
    }
    int ans = 0;
    ans += b[a[0]-1];
    for(int i = 1;i<n;i++){
    	ans += b[a[i]-1];
    	if(a[i] == a[i-1]+1){
    		ans += c[a[i-1]-1];
    	}
    }
    cout<<ans<<endl;
    return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int x;
  cin >> x;
  vector<int> item(6);
  REP(i,6) item[i] = 100+i;

  vector<int> dp(100005); // 1円の買い物ができるかどうか
  dp[0] = 1;
  for (int i = 100; i <= x; i++) {
    REP(j,6) {
      int t = i-item[j];
      if (0 <= t && dp[t] == 1) {
        dp[i] = 1;
        break;
      }
    }
  }

  COUT(dp[x]);
  return 0;
}


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

int main() {
  int a,b; cin >>a >>b;
  if ((a-b)%2 == 0){
    if (a<b) cout <<a + (b-a)/2;
    else cout <<b + (a-b)/2;
  }else{
    cout <<"IMPOSSIBLE";
  }
  cout <<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <numeric>

/* debug macros */
#ifdef WAFDAYO
#define DBG_LINE() {std::cerr<<"\e[2m[L"<<__LINE__<<"]\e[m ";}
#define DBG_PRINT(s,t,u) {std::cerr<<(s)<<" \e[2m=\e[m \e[1m"<<(t)<<"\e[m"<<(u);}
#define SELECT_7TH(x1,x2,x3,x4,x5,x6,x7,...) x7
#define dbg1(x1) DBG_PRINT(#x1,x1,std::endl)
#define dbg2(x1,x2) DBG_PRINT(#x1,x1,", ")dbg1(x2)
#define dbg3(x1,x2,x3) DBG_PRINT(#x1,x1,", ")dbg2(x2,x3)
#define dbg4(x1,x2,x3,x4) DBG_PRINT(#x1,x1,", ")dbg3(x2,x3,x4)
#define dbg5(x1,x2,x3,x4,x5) DBG_PRINT(#x1,x1,", ")dbg4(x2,x3,x4,x5)
#define dbg6(x1,x2,x3,x4,x5,x6) DBG_PRINT(#x1,x1,", ")dbg5(x2,x3,x4,x5,x6)
#define dbg(...) DBG_LINE()\
SELECT_7TH(__VA_ARGS__,dbg6,dbg5,dbg4,dbg3,dbg2,dbg1)(__VA_ARGS__)
#else
#define dbg(...) {}
#endif

/* utility functions */
struct read_item{read_item(){};
template<class T>operator T(){T t;std::cin>>t;return t;}};
char splf(int i,int n){return(i+1<n)?' ':'\n';};
template<bool up>
struct _RI{int i;_RI(int a):i(a){}
int operator*(){return i;}void operator++(){i+=(up?1:-1);}
bool operator!=(const _RI& r){return up?i<r.i:i>=r.i;}};
template<bool up>
struct _RX{_RI<up> x,y;_RI<up> begin(){return x;}_RI<up> end(){return y;}
_RX(int a,int b):x(up?a:(a-1)),y(b){}_RX(int a):_RX(up?0:a,up?a:0){}};
typedef _RX<true> range;
typedef _RX<false> revrange;

/* types and constants */
typedef long long i64;
typedef unsigned long long u64;
const i64 mod = 1e9 + 7;
// const i64 inf = (i64)1.05e18;
// const int inf = (int)1.05e9;

using namespace std;

u64 modpow(u64 x, u64 k) {
	u64 y = 1;
	for(int i = 0; i < 64; i++) {
		if((k >> i) & 1) {
			y = y * x % mod;
		}
		x = x * x % mod;
	}
	return y;
}

i64 compute(i64 n, i64 a) {

	i64 y = 1;
	for(int r : range(n - a + 1, n + 1)) {
		y = y * r % mod;
	}

	i64 z = 1;
	for(int r : range(1, a + 1)) {
		z = z * r % mod;
	}

	return y * modpow(z, mod - 2) % mod;
}

int main() {

	const int n = read_item();
	const int a = read_item();
	const int b = read_item();

	i64 ans = modpow(2, n) - 1 - compute(n, a) - compute(n, b);
	while(ans < 0) {
		ans += mod;
	}
	ans = ans % mod;
	printf("%lld\n", ans);

	return 0;
}

/* wafdayo~~~ */


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
typedef long long ll;
const int maxn = 105;
int a[maxn];

int main()
{
    IO;
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    ll minn = 0x3f3f3f3f;
    for (int pos = 1; pos <= 100; ++pos)
    {
        ll t = 0;
        for (int i = 1; i <= n; ++i)
            t += (pos - a[i]) * (pos - a[i]);
        minn = min(minn, t);
    }
    cout << minn << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

vi arr;
vi velicina;

int find_set(int v)
{
    if(v==arr[v])return v;
    return arr[v]=find_set(arr[v]);
}

void unite(int a,int b)
{
    a=find_set(a);
    b=find_set(b);
    if(a!=b)
    {
        if(a<b)
        {
            arr[a]=b;
            velicina[b]+=velicina[a];
        }
        else
        {
            arr[b]=a;
            velicina[a]+=velicina[b];
        }
    }
}

int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    arr.resize(n+1);
    iota(all(arr),0);
    velicina.resize(n+1,1);
    vvi dobreVeze(n+1);
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        unite(a,b);
        dobreVeze[a].pb(b);
        dobreVeze[b].pb(a);
    }
    vvi loseVeze(n+1);
    for(int i=0;i<k;i++)
    {
        int a,b;
        cin>>a>>b;
        loseVeze[a].pb(b);
        loseVeze[b].pb(a);
    }

    for(int i=1;i<=n;i++)
    {
        int trenutnaVelicina=velicina[find_set(i)]-1-(int)dobreVeze[i].size();
        for(auto &e: loseVeze[i])
        {
            if(find_set(e)==find_set(i))
            {
                trenutnaVelicina--;
            }
        }
        cout<<trenutnaVelicina<<' ';
    }
    cout<<'\n';

    return 0;
}


Measured memory_bytes: 12536
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

#define no {cout<<"No"<<endl; continue;}
#define yes {cout<<"Yes"<<endl; continue;}

int gcd(int a,int b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    return gcd(b,a%b);
}

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

    int n; cin>>n;
    rep(i,n){
        int a,b; cin>>a>>b;
        if(a>b)swap(a,b);
        if(a==b)cout<<2*a-2<<endl;
        else if(a+1==b)cout<<2*a-2<<endl;
        else{
            int c=floor(sqrt(a*b));
            if(c*c==a*b)c--;
            if(c*(c+1)>=a*b)cout<<2*c-2<<endl;
            else cout<<2*c-1<<endl;
        }
    }
    
}

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


def m(n):
    res = []
    m = 1000000000010
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
#             divisors.append(i)
#             divisors.append(n//i)
            s = i + n//i
#             res.append(s)
            m = min(s,m)

    # divisors.sort()
    return m
print(m(a)-2)

Measured memory_bytes: 3060
// Problem : C. Buns
// Contest : Codeforces Beta Round #82 (Div. 2)
// URL : https://codeforces.com/problemset/problem/106/C
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define mod 1000000007
#define ss second
#define ff first
#define vpii vector<pii>
#define vvi vector<vi>
#define pb push_back
#define vs vector<string>
#define all(x) x.begin(),x.end()
#define mii map<int,int>
const int inf=0x3f3f3f3f3f3f3f3f;
void print(vi &v){
    for(int i=0;i<v.size();i++)cout<<v[i]<<" ";
    cout<<endl;
}
int power(int a,int b){
    int res = 1;
    while(b!=0){
        if(b&1){
            res *= a; 
        }
        a = (a * a);
        b = (b / 2);
    }
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t = 1;
    while(t--){
    	string s;
      cin>>s;
      if(s[2]==s[3] && s[4]==s[5])cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
    	
    }
    return 0;
}

Measured memory_bytes: 256
N,A,B,K=map(int,input().split())
mod = 998244353
#x!のmodP逆元を求めるx^-1=x^(p-2)
table=[1]
a=1
for i in range(1,N+1):
    a=(a*pow(i,mod-2,mod))%mod
    table.append(a)

num=1
for i in range(1,N+1):
    num = (num*i) %mod


number =0
for i in range(N+1):
    if (K-A*i)%B==0 and K-A*i>=0:
        j=(K-A*i)//B
        if 0<=j<=N:
            t = (num*num)%mod
            t = (t*table[i])%mod
            t = (t*table[j])%mod
            t = (t*table[N-i])%mod
            t = (t*table[N-j])%mod
            number = (number+t)%mod
print(number)

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

using namespace std;

int main() {
    int N; cin >> N;
    vector<int> A(N, 0);
    for (int i = 0; i < N; i++) cin >> A[i];
    const int LIM = (int)(1e5 + 5);
    vector<int> cnt(LIM, 0);
    for (auto a : A) {
        for (int j = -1; j <= 1; j++) {
            int b = a + j;
            if (b < 0 || b >= LIM) continue;
            cnt[b] += 1;
        }
    }
    cout << *max_element(cnt.begin(), cnt.end()) << endl;
}

Measured memory_bytes: 1272
#include <stdio.h>

int N, A[202020]; bool v[202020];

bool chk(int m)
{
	for (int i=1;i<2*N;i++) v[i] = A[i] >= m;
	int l = N, r = N;
	while (l > 1 && v[l-1] != v[l]) l--;
	while (r < 2*N-1 && v[r+1] != v[r]) r++;
	if ((l + r) >= N * 2) return v[l];
	return v[r];
}

int main()
{
	scanf("%d", &N);
	for (int i=1;i<2*N;i++) scanf("%d", &A[i]);

	int l = 1, r = 2*N-1;
	while (l + 1 < r){
		int m = (l + r) / 2;
		if (chk(m)) l = m;
		else r = m;
	}
	printf("%d\n", l);

	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

template<int mod> struct ModInt{
    long long x=0; 
    constexpr ModInt(long long x=0):x((x%mod+mod)%mod){}
    constexpr ModInt operator+(const ModInt& r)const{return ModInt(*this)+=r;}
    constexpr ModInt operator-(const ModInt& r)const{return ModInt(*this)-=r;}
    constexpr ModInt operator*(const ModInt& r)const{return ModInt(*this)*=r;}
    constexpr ModInt operator/(const ModInt& r)const{return ModInt(*this)/=r;}
    constexpr ModInt& operator+=(const ModInt& r){ if((x+=r.x)>=mod) x-=mod; return *this;}
    constexpr ModInt& operator-=(const ModInt& r){ if((x-=r.x)<0) x+=mod; return *this;}
    constexpr ModInt& operator*=(const ModInt& r){ if((x*=r.x)>=mod) x%=mod; return *this;}
    constexpr ModInt& operator/=(const ModInt& r){ return *this*=r.inv();}
    ModInt inv() const {
        long long s=x,sx=1,sy=0,t=mod,tx=0,ty=1;
        while(s%t!=0){
            long long temp=s/t,u=s-t*temp,ux=sx-temp*tx,uy=sy-temp*ty;
            s=t;sx=tx;sy=ty;
            t=u;tx=ux;ty=uy;
        }
        return ModInt(tx);
    }
    ModInt pow(long long n) const {
        ModInt a=1;
        while(n>0){
            if(n&1) a*=*this;
            *this*=*this;
            n>>=1;
        }
        return a;
    }
    friend constexpr ostream& operator<<(ostream& os,const ModInt<mod>& a) {return os << a.x;}
    friend constexpr istream& operator>>(istream& is,ModInt<mod>& a) {return is >> a.x;}
};
using mint = ModInt<MOD>;

struct combination{
    int N;
    vector<mint> fac,finv,inverse;
    combination(int N=0):N(N){
        fac.resize(N+1);finv.resize(N+1);
        fac[0]=1;
        for(int i=1;i<=N;++i){fac[i]=fac[i-1]*i;}
        finv[N]=fac[N].inv();
        for(int i=N-1;i>=0;--i){finv[i]=finv[i+1]*(i+1);}
    }
    void inverse_build(){
        inverse.resize(N+1);
        inverse[1]=1;
        for(int i=2;i<=N;++i){inverse[i]=finv[i]*fac[i-1];}
    }
    constexpr mint c(const int& n,const int& k){
        if(n<k||n<0||k<0) return 0;
        return fac[n]*finv[n-k]*finv[k];
    }
    constexpr mint p(const int& n,const int& k){
        if(n<k||n<0||k<0) return 0;
        return fac[n]*finv[n-k];
    }
};

int main(){
    combination com(1000000);
    int x,y;
    cin >> x >> y;
    mint ans = 0;
    if(2*y-x<0||2*x-y<0);
    else if((2*y-x)%3 != 0 || (2*x-y)%3 != 0);
    else{
        int s = (2*x-y)/3;
        int t = (2*y-x)/3;
        ans = com.c(s+t,s);
    }
    cout << ans << endl;
    return 0;
}

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

#define ll long long
#define ld long double
#define xx first
#define yy second
#define vi vector<int>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()

#define MAX 400005

ll mp[2000000];

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

    ll n, x;
    cin >> n;

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

    sort(all(a));

    if(mp[1] == 1)
    {
        cout << 1 << endl;
        return 0;
    }

    if(mp[1]>1)
    {
        cout << 0 << endl;
        return 0;
    }

    ll ans =0;

    for(int i=0;i<n;i++)
    {
        ll f=1;
        for(int j=2;j*j<=a[i];j++)
        {
            if(a[i]%j == 0)
            {
                if(mp[j]) f=0;
                if(mp[a[i]/j]) f=0;
            }
        }

        if(f && mp[a[i]] == 1) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 12600
s=input()
n=len(s)

ans=0
accum=[0]*n
for i in range(n-1):
    if s[i]=='B':
        accum[i+1]=accum[i]+1
    else:
        accum[i+1]=accum[i]

for i in range(n):
    if s[i]=='W':
        ans+=accum[i]
print(ans)


Measured memory_bytes: 11144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n;
	cin>>n;
	ll freq[n+1]={0};
	for(int i=0;i<n-1;i++){
		int a;
		cin>>a;
		freq[a]++;
		}
	for(int i=1;i<=n;i++)
	cout<<freq[i]<<"\n";
	
}


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

struct book{
  string name,auth,date;

  bool match(string a, string b, string c, string d){
    if(a!="*" && name.find(a)==string::npos)return false;
    if(b!="*" && auth.find(b)==string::npos)return false;
    if(c!="*" && date<c)return false;
    if(d!="*" && d<date)return false;
    return true;
  }
};

int main(){
  int n;
  cin >> n;
  vector<book> B(n);
  for(int i=0;i<n;i++){
    string a,b,c;
    cin >> a >> b >> c;
    B[i].name = a; B[i].auth = b; B[i].date = c;
  }

  int q;
  cin >> q;
  for(int i=0;i<q;i++){
    string a,b,c,d;
    cin >> a >> b >> c >> d;
    for(int j=0;j<n;j++){
      if(B[j].match(a,b,c,d))cout << B[j].name << endl;
    }
    if(i<q-1)cout << endl;
  }
}

Measured memory_bytes: 1240
import sys
from math import ceil

def main():
    T1, T2, A1, A2, B1, B2 = map(int, sys.stdin.read().split())

    BA1 = A1 - B1
    BA2 = A2 - B2

    if BA1 == 0:
        print(0)
        sys.exit()
    
    if BA1 < 0:
        BA1 = -BA1
        BA2 = -BA2
    
    d = BA1 * T1 + BA2 * T2

    if d > 0:
        print(0)
        sys.exit()
    if d == 0:
        print('infinity')
        sys.exit()

    # dは負なので
    n = ceil((- BA1 * T1) / d) 
    if n * d + BA1 * T1 == 0:
        ans = n * 2
    else:
        ans = n * 2 - 1

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String b = sc.next();
        int count = 0;
        for(int i=0; i<a-2; i++) {
            if("ABC".equals(b.substring(i, i+3))) {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <cmath>
#include <memory.h>
#include <iomanip>
#include <cassert>
using namespace std;

#define maxn 100002
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 y902
#define y1 y232
#define x0 x92
#define x1 x899
#define next asdfa
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<int, int> ii;
typedef vector<int> vi;
const int inf = 1e9;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

int n, m, a[maxn], nType1, type[maxn];
vector<int> p[maxn];

int main() {
    //freopen("guruguru.inp", "r", stdin);
    //freopen("", "w", stdout);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    FOR(i, 1, n) cin >> a[i];
    FOR(i, 1, n-1) {
        p[a[i]+1].push_back(i);
        p[a[i+1]+1].push_back(i);
    }
    ll res = 0;
    FOR(i, 1, n-1) {
        if (a[i]<a[i+1]) {
            res += (a[i+1]-a[i]);
        }
        else {
            type[i] = 1;
            ++nType1;
            res += a[i+1];
        }
    }
    ll tmp = res;
    FOR(i, 2, m) {
        REP(j, p[i].sz()) {
            int pos = p[i][j];
            if (type[pos]==0) {
                ++nType1;
                type[pos] = 1;
                ++tmp;
            }
            else {
                --nType1;
                if (a[pos]<a[pos+1]) tmp += (a[pos+1]-a[pos]-1);
                else tmp += (m-a[pos]+a[pos+1]-1);
                type[pos] = 0;
            }
        }
        tmp -= nType1;
        res = min(res, tmp);
    }
    cout << res;
}



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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    int a;
    cin >> a;
    cout << 3 * a * a << endl;

    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
        
        int H = sc.nextInt();
        int N = sc.nextInt();
        int A[] = new int[N];
        int sum = 0;
        
        for(int i=0;i<N;i++){
            A[i] = sc.nextInt();
            sum += A[i];
        }
		if(sum>=H){
    		System.out.println("Yes");
        }else{
        	System.out.println("No");
        }        
    }
}

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

int main(){
	string s;
	getline(cin,s);
	char c = 'A' - 'a';
	for(int i = 0; i < s.size(); i++){
		if(s[i] >= 'a' && s[i] <= 'z')s[i] += c;
		else if(s[i] >= 'A' && s[i] <= 'Z')s[i] -= c;

		cout << s[i];
	}
	cout << endl;
	return 0;
} 


Measured memory_bytes: 3208
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

int n, tab[100005], i, res, r, r2, bat[100005];

int main() {
scanf("%d", &n);
for (i=1;i<=n;i++) scanf("%d", &tab[i]);
tab[0] = tab[n + 1] = 0;
for (i=1;i<=n+1;i++) {
	bat[i] = abs(tab[i] - tab[i - 1]);
	res += bat[i];
}
for (i=1;i<=n;i++) {
	r = abs(tab[i + 1] - tab[i - 1]);
	r2 = res - bat[i] - bat[i + 1] + r;
	printf("%d\n", r2);
}
return 0;
}



Measured memory_bytes: 2048
import java.util.Scanner;
public class Main
{
    public static void main(String[]args)
    {
        Scanner laptm = new Scanner(System.in);
        String s = laptm.next();
        if(s.equals("SAT"))
        System.out.println("1");
        if(s.equals("SUN"))
        System.out.println("7");
        if(s.equals("MON"))
        System.out.println("6");
        if(s.equals("TUE"))
         System.out.println("5");
        if(s.equals("WED"))
        System.out.println("4");
        if(s.equals("THU"))
         System.out.println("3");
        if(s.equals("FRI"))
        System.out.println("2");
    }
}    

Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

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

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

    int H, W, h, w;
    cin >> H >> W >> h >> w;
    int rsl = H * W - H * w - W * h + h * w;
    cout << rsl << endl;

}


Measured memory_bytes: 256
import math

def median(l):
    n = len(l)
    ls = sorted(l)
    if n%2 == 0:
        m1 = ls[int(n/2)-1]
        m2 = ls[int(n/2)]
        return (m1+m2)/2
    
    return ls[int(n/2)]

N = int(input())
A = [int(i) for i in input().split()]

A_ = [A[i] - i - 1 for i in range(N)]

A_m = median(A_)
A_m1 = math.floor(A_m)
A_m2 = math.ceil(A_m)

A_b = [sum([abs(a - i) for a in A_]) for i in (A_m1, A_m2)]

print(min(A_b))

Measured memory_bytes: 28272
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=1;i<=N;i++)

signed main(){
  int N;
  cin>>N;
  int ans=0;
  rep(i,N){
    if(!(i%5==0||i%3==0)){
      ans+=i;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    int k,x;
    cin >> k >> x;
    if(500*k >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
typedef long long ll;


int main(){
    int r=0,a=0,s=0;
    ll N,res=0;
    cin >> N;
    vector<int> v(N);

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


    for (int l=0;l<N;++l) {
        while ((s+v[r])==(a^v[r]) && r<N){
            s += v[r];
            a ^= v[r];
            ++r;
        }
        res += r-l;
        int x=v[l];
        a = a^x;
        s -= x;
        
    }
    cout << res << endl;
  }


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,i;
    long long int sum=0;
    cin>>n>>k;
    int a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);

    for(i=0;i<k;i++)
        sum+=a[i];

    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        for (int i=1;i<=N;i++) {
            if (Math.floor((double)i*1.08)==N) {
                System.out.println(i);
                return;
            }
        }
        System.out.println(":(");
    }
}

Measured memory_bytes: 22356
public class Hello{
    public static void Main(){
        
        int x = int.Parse(System.Console.ReadLine());
        int gohyakuen,goen = 0;
        
        gohyakuen = x / 500;
        goen = x % 500 / 5;
        
        System.Console.WriteLine(gohyakuen * 1000 + goen * 5);
        
        
    }
}

Measured memory_bytes: 13140