akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);


int main(){
	int N,T,H,L;
	cin>>N>>T>>H>>L;
	vi t(N),h(N);
	REP(i,N){
		cin>>t[i]>>h[i];
	}

	int cp=0;
	int remain=0;
	while(1){
		if(t[cp]>0){
			t[cp]--;
			T++;
			if(T>L){
				goto win;
			}
			remain+=10;
		}else if(h[cp]>0){
			h[cp]--;
			H++;
			remain+=100;
		}else{
			goto win;
		}
		if(remain>=90){
			remain-=90;
			if(T>=remain/10){
				T-=remain/10;
				t[cp]+=remain/10;
				remain=0;
			}else{
				goto win;
			}
		}
		cp++;
		if(cp>=N)cp=0;
	}
	win:
	cout<<cp+1<<endl;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

#define pll pair<ll,ll>
ll h,w,n;
map<pll,int> mp;
ll ans[10];

void p(int x,int y){
  FOR(i,y-2,y+1){
    FOR(j,x-2,x+1){
      if(1<=i&&i<=w-2&&1<=j&&j<=h-2)
        mp[pll(i,j)]++;
    }
  }
}

int main(){
  cin>>h>>w>>n;

  rep(i,n){
    int x,y;
    cin>>x>>y;
    p(x,y);
  }

  for(auto itr=mp.begin();itr!=mp.end();itr++){
    ans[itr->second]++;
  }
  ans[0]=(h-2)*(w-2)-mp.size();

  rep(i,10){
    cout<<ans[i]<<endl;
  }

  return 0;
}


Measured memory_bytes: 56448
N, M = map(int, input().split())
LR = [list(map(int, input().split()))[:2] for m in range(M)]

# 最初の 2つの値を初期の下限、上限を定めた範囲とする
minV, maxV = LR[0]

# 次の行以降について、下限と上限の範囲が狭まるならば更新していく
for m in range(1, M):
    if minV < LR[m][0]:
        minV = LR[m][0]
    if LR[m][1] < maxV:
        maxV = LR[m][1]

# 上限と下限の間に存在する整数値
w = maxV - minV + 1
if (w > 0):
    print(w)
else:
    print(0)


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

int main() {
  int A, B, N, sum;
  cin >> A >> B;
 
  for (int i = A; i <= B  ; i++) {
    if (i/10000 == i%10) {
      N = i;
      N -= (i/10000)*10000;
      N /= 10;
      if (N/100 == N%10) {
        sum++;
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) { 

 int n;

 int x;


 int num;

 int min = 1000001;

 int max = -1000001;

 long total = 0;





 scanf("%d",&n);


 for(x = 0; x < n; x++){


 scanf("%d",&num);


 if(min >num)min = num;


 if(max < num)max = num;


total += num;


}


printf("%d %d %ld\n",min,max,total);


return 0;


}


 

Measured memory_bytes: 600
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
double a,b,c,d;
cin>>a>>b>>c>>d;
double x=ceil(c/b),y=ceil(a/d);
string ans="No";
if(x<=y) ans="Yes";
  cout<<ans<<endl;
}


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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

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

    int N;
    std::cin >> N;
    vector<int> X(N), Y(N), H(N);
    REP(i, N) {
        std::cin >> X[i] >> Y[i] >> H[i];
    }

    [&]() {
        REP(cx, 101) {
            REP(cy, 101) {
                auto calc_H = [&](int &xi, int &yi, int &hi) -> int {
                                  return hi + abs(xi - cx) + abs(yi - cy);
                              };
                ll h = -1;
                REP(i, N) {
                    if(H[i] != 0) {
                        h  = calc_H(X[i], Y[i], H[i]);
                        break;
                    }
                }
                bool ok = true;
                for(int i = 0; i < N; i++) {
                    if(H[i] != max(h - abs(X[i] - cx) - abs(Y[i] - cy), 0LL)) {
                        ok = false;
                        break;
                    }
                }
                if(ok && h != -1) {
                    std::cout << cx << " " << cy << " " << h << std::endl;
                    return;
                }
            }
        }
    }();

    return 0;
}


Measured memory_bytes: 256
program prob2
    implicit none
    integer::AA, BB, M, i, x, y, c, ans
    integer, allocatable::A(:), B(:)
    read(*,*) AA, BB, M
    allocate(A(AA))
    allocate(B(BB))
    read(*,*) A
    read(*,*) B

    ans = minval(A) + minval(B)
    do i = 1, M
        read(*,*) x, y, c
        if(ans > A(x) + B(y) - c) then
            ans = A(x) + B(y) - c
        end if
    end do

    write(*,*) ans

    deallocate(A)
    deallocate(B)

    stop

end program prob2

Measured memory_bytes: 1536
// stdin
macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}


// Test
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

#[allow(dead_code)]
fn gcd(x: i64, y: i64) -> i64 {
    if y == 0 {
        return x;
    }
    gcd(y, x % y)
}

#[test]
fn test_primes() {
    assert_eq!(primes(1), vec![1]);
    assert_eq!(primes(140), vec![1, 2, 2, 5, 7])
}

#[allow(dead_code)]
fn primes(num: i64) -> Vec<i64> {
    let mut ans = vec![1];
    let mut cur = num;
    for i in 2.. {
        if i * i > num { break; }
        if cur % i == 0 {
            while cur % i == 0 {
                ans.push(i);
                cur /= i;
            }
        }
    }
    if cur > 1 {
        ans.push(cur);
    }
    return ans;
}


test! {
r"RRS
" => r"2",

r"SSS
" => r"0",

r"RSR
" => r"1"
}

use proconio::{input, fastout};
use proconio::source::auto::AutoSource;

fn solve(src: &str) -> String {
    let source = AutoSource::from(src);
    input! {
       from source,
       s:String,
    }
    let s: String = s;
    // todo s can be str?

    let ans = if s.contains("RRR") {
        "3"
    } else if s.contains("RR") {
        "2"
    } else if s.contains("R") {
        "1"
    } else {
        "0"
    };

    format!("{}", ans.to_string())
}



#[fastout]
fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&*s));
}



Measured memory_bytes: 2144
import java.util.Scanner;

class Main {
	public class UnknowNumbers{
		float x;
		float y;
	}

	public UnknowNumbers formula(float para_a, float para_b, float para_c, float para_d, float para_e, float para_f){
		UnknowNumbers numbers = new UnknowNumbers();
		/*
		if(para_a == 0){
			if(para_b == 0){
				System.out.println("a and b should not equals 0 at the same time!!!");
				System.exit(0);
			}
			numbers.y = para_c / para_b;
			if(para_d == 0){
				System.out.println("The parallel lines or the same line!!!");
				System.exit(0);
			}
			numbers.x = ((para_b * para_f) - (para_c * para_e)) / (para_d * para_b);

		} else if((para_a * para_e) - (para_d * para_b) == 0){
			System.out.println("The parallel lines or the same line!!!");
			System.exit(0);
		} else{*/
			numbers.y = ((para_a * para_f) - (para_d * para_c)) / ((para_a * para_e) - (para_d * para_b));
			numbers.x = (para_c - para_b * numbers.y) / para_a;
		//}
		return numbers;
	}
	public static void main(String[] args){

		Main equation = new Main();
		UnknowNumbers numbers;
		String[] strParameters;

		Scanner input = new Scanner(System.in);

		while(input.hasNext()){
			strParameters = input.nextLine().split(" ");

			float[] parameters = new float[strParameters.length];


			for(int iPara = 0; iPara < strParameters.length; iPara++){
				parameters[iPara] = Float.parseFloat(strParameters[iPara]);
				/*if(parameters[iPara] < -1000 || parameters[iPara] > 1000){
					System.out.println("Some parameters out of limit!");
					System.exit(0);
				}*/
			}
			numbers = equation.formula(parameters[0],parameters[1],parameters[2],parameters[3],parameters[4],parameters[5]);
			if(numbers.x == -0.0f)	numbers.x = 0.0f;
			if(numbers.y == -0.0f)	numbers.y = 0.0f;
			System.out.printf("%.3f %.3f\n",numbers.x,numbers.y);
		}
	}
}

Measured memory_bytes: 26396
def chat_in_a_circle():
    N = int(input())
    A = list(map(int,input().split()))
    A.sort()
    res = A.pop(-1)
    t = len(A) % 2 == 0
    a = 0
    for i in range(len(A) // 2):
        a = A.pop(-1)
        res += a*2
    if t:
        res -= a
        
    print(res)

chat_in_a_circle()

Measured memory_bytes: 31600
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
using namespace std;
#define ll long long int
#define all(v) begin(v), end(v)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;
using namespace std;

ll solve(ll r, ll d, ll x) {
	return r * x - d;
}

int main() {
	ll a, b;
	cin >> a >> b;
	if (a >= 13) {
		cout << b << endl;
	}
	else if(a>=6){
		cout << b / 2 << endl;
	}
	else {
		cout << 0 << endl;
	}
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val s = readLine()!!.toCharArray()
    val result = IntArray(s.size)
    var repeat = 0
    for (i in 0 until s.size) {
        if (s[i] == 'R') {
            repeat += 1
            if (s[i+1]  == 'L') {
                result[i+1] += repeat/2
                result[i] += (repeat+1)/2
            }
        }else{
            repeat = 0
        }
    }
    repeat = 0
    for (i in s.size-1 downTo 0) {
        if (s[i] == 'L') {
            repeat += 1
            if (s[i-1] == 'R') {
                result[i-1] += repeat/2
                result[i] += (repeat+1)/2
            }
        }else{
            repeat = 0
        }
    }
    println(result.joinToString(" "))
}


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

string s;
int r, b;

int main()
{
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == '0')
            r++;
        else
            b++;
    }
    cout << 2 * min(r, b) << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	string S;
	cin >> S;
	int ans = 0;
	rep(i, S.size() - 1)if (S[i] != S[i + 1])ans++;
	cout << ans << endl;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int W, H, x, y;
  cin >> W >> H >> x >> y;

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

  cout << (0.5 * W * H) << ' ' << (x * 2 == W && y * 2 == H);
}
#endif


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

typedef long long ll;

const ll mod = 1e9 + 7;

int n, k;
vector<ll> pos, neg;

int main (void) {
  ios::sync_with_stdio(false);cin.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    ll x; cin >> x;
    if (x < 0) neg.push_back(x);
    else pos.push_back(x);
  }
  sort(pos.begin(), pos.end());
  sort(neg.rbegin(), neg.rend());

  ll res = 1;
  if (n == k) {
    for (ll x : pos)
      res = res * x % mod;
    for (ll x : neg)
      res = res * x % mod;
  } else if (n == (int) neg.size()) {
    if (k & 1) {
      for (int i = 0; i < k; i++)
        res = res * neg[i] % mod;
    } else {
      for (int i = neg.size() - 1; i >= neg.size() - k; i--)
        res = res * neg[i] % mod;
    }
  } else {
    if (k & 1) {
      --k;
      res = pos.back();
      pos.pop_back();
    }
    while (k > 0) {
      ll pa = 0, pb = -1, na = 0, nb = -1;
      if (pos.size() < 2) {
        na = neg.back(); neg.pop_back();
        nb = neg.back(); neg.pop_back();
        res = res * na % mod * nb % mod;
      } else if (neg.size() < 2) {
        pa = pos.back(); pos.pop_back();
        pb = pos.back(); pos.pop_back();
        res = res * pa % mod * pb % mod;
      } else {
        pa = pos[pos.size() - 1];
        pb = pos[pos.size() - 2];
        na = neg[neg.size() - 1];
        nb = neg[neg.size() - 2];
        if (pa * pb > na * nb) {
          pos.pop_back();
          pos.pop_back();
          res = res * pa % mod * pb % mod;
        } else {
          neg.pop_back();
          neg.pop_back();
          res = res * na % mod * nb % mod;
        }
      }
      k -= 2;
    }
  }
  res = (res % mod + mod) % mod;
  cout << res << '\n';
  return 0;
}



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

// 木だと思ってたｗ
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n, m;
  cin >> n >> m;
  using P = pair<int, int>;
  vector<P> v(m);
  for(int i = 0; i < m; i++) {
    int a,b;
    cin >> a >> b; a--; b--;
    v[i] = P(b, a);
  }
  sort(begin(v), end(v));
  int ans = 0;
  int last = 0;
  for(int i = 0; i < m; i++) {
    if(v[i].second >= last) {
      last = v[i].first;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
const int MOD = 1000000007;
long long int POW(int n,int k,int m){
	long long int r;
	if(k==0)return 1;
	r=POW(n,k/2,m)%m;
	r=(r*r)%m;
	if(k%2)r=(n*r)%m;
	return r;
}
int main(){
	int N,ans[100000][13]={0},n,sur,pre;
	string S;
	cin>>S;
	N=S.length();
	for(int i=0;i<N;i++){
		sur=POW(10,N-i-1,13);
		if(S[i]=='?'){
			if(i>=1){
				for(int j=0;j<13;j++){
					for(int k=0;k<10;k++){
						pre=(sur*k)%13;
						ans[i][(j+pre)%13]+=ans[i-1][j];
						ans[i][(j+pre)%13]%=MOD;
					}
				}
			}else{
				for(int k=0;k<10;k++)ans[i][(sur*k)%13]+=1;
			}
		}else{
			n=S[i]-'0';
			sur=(sur*n)%13;
			if(i>=1){
				for(int j=0;j<13;j++)ans[i][(j+sur)%13]=ans[i-1][j];
			}else{
				ans[i][sur]=1;
			}
		}
	}
	cout<<ans[N-1][5];
	return 0;
}

Measured memory_bytes: 5504
#include <iostream>
#include <cstdlib>
#include <bitset>
#include <map>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
#include <sstream>
#include <math.h>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecchar vector<char>
#define vecstr vector<string>
#define vec2str vector<vector<string>>
#define vecbool vector<bool>
#define vec2bool vector<vector<bool>>
#define pairll pair<ll,ll>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

#define Pi 3.1415926535897932384626

int main() {
	ll n,x,t, ans = 0;
	bool flag = false;
	string s;

	cin >> s;

	forll(i, 0, s.size())
	{
		ans += (s[i] - '0');
	}

	if (ans % 9 == 0)
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 3756
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin, n;
    string s;
    cin, s;
    if (n % 2 != 0) {
        print("No");
        return 0;
    }
    n /= 2;
    REP(i, 0, n) {
        if (s[i] != s[i + n]) {
            print("No");
            return 0;
        }
    }

    print("Yes");
    return 0;
}


Measured memory_bytes: 3608
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	x=II()

	if x<600:
		a=8
	elif x<800:
		a=7
	elif x<1000:
		a=6
	elif x<1200:
		a=5
	elif x<1400:
		a=4
	elif x<1600:
		a=3
	elif x<1800:
		a=2
	elif x<2000:
		a=1
	print(a)

if __name__ == "__main__":
	main()


Measured memory_bytes: 61836
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

#define EPS 1e-6

int main(void){
  double x1,y1,x2,y2,xq,yq;
  double a,b,c,d;
  double X,Y;
  double retx, rety;
  while(cin >> x1){
	cin.ignore();
	cin >> y1; cin.ignore();
	cin >> x2; cin.ignore();
	cin >> y2; cin.ignore();
	cin >> xq; cin.ignore();
	cin >> yq;

	//calc ax+by+c=0
	X = x2 - x1;
	Y = y2 - y1;
	if(X == 0){
	  printf("%.6f %.6f\n", 2*x1-xq, yq);
	}else if(Y == 0){
	  printf("%.6f %.6f\n", xq, 2*y1-yq);
	}else{
	  a = Y / X;
	  b = y1 - (Y / X) * x1;

	  double theta;
	  theta = atan(a);
	  retx = xq * cos(2*theta) + yq * sin(2*theta) - b * sin(2*theta);
	  rety = xq * sin(2*theta) - yq * cos(2*theta) + b * cos(2*theta) + b;

	  if(fabs(retx) < EPS) retx = 0;
	  if(fabs(rety) < EPS) rety = 0;

	  printf("%.6f %.6f\n", retx, rety);
	}
  }
}

Measured memory_bytes: 0
# Volume0 - 0084
# Search Engine
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0084

line = $stdin.gets.chomp
words = line.split( /\.+|\s+|,+/)
words.delete_if{ |w| w.size <= 2 || w.size >= 7 }
words.each_with_index{ |w,i|
	print " " if i > 0
	print w
}
puts


Measured memory_bytes: 6104
n = 0
s = [""]

def format_input(filename = None):
	global n
	global s
	if filename == None:
		n = int(input())
		s = [input() for i in range(n)]

	elif filename == '__random__':
		from random import randint as rng
		from random import choices
		n = rng(1, 2 * 10**5)
		s = [''.join(choices('abcdefghijklmnopqrstuvwxyz', k = rng(1, 10))) for i in range(n)]

def get_answer():
	poll_dict = {}
	for i in s:
		if i in poll_dict:
			poll_dict[i] += 1
		else:
			poll_dict[i] = 1
	sorted_dict = sorted(poll_dict.items(), key=lambda x:x[1], reverse=True)
	name_list = [i for i, j in sorted_dict if j == sorted_dict[0][1]]
	name_list.sort()
	answer = ""
	for i in name_list:
		answer += i
		answer += '\n'
	answer = answer[:-1]
	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)

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

int main()
{
    int l,r;
    int temp;
    int ans=2018;
    cin>>l>>r;
    for(int i=0;i<=2019&&l+i<=r;i++)
    {
        for(int j=1;j<=2019&&l+i+j<=r;j++)
        {
            temp=(((l+i)%2019)*((l+i+j)%2019))%2019;
            if(temp<ans)
            {
                ans=temp;
            }
        }
    }
    cout<<ans<<endl;
}

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

int main() {
    int n;
    cin >> n;
    int a[2*n];
    for(int i = 0; i < 2 * n; i++) {
        cin >> a[i];
    }
    int res = 0;
    sort(a, a + 2 * n);
    for(int i = 0; i < 2 * n; i += 2) {
        res += a[i];
    }
    cout << res;
    return 0;
}


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

int main() {
    int n;
    string s;
    cin>>n>>s;
    vector<int> sum(n+1,0);
    sum[n]=0;
    for(int i=n-1; i>=0; i--) {
        if(s[i]=='E') {
            sum[i] = sum[i+1] + 1;
        } else {
            sum[i] = sum[i+1];
        }
    }
    int mins=n;
    for(int i=0; i<n; i++) {
        mins = min(mins, sum[i+1]+i-sum[0]+sum[i]);
    }
    cout<<mins<<endl;
}

Measured memory_bytes: 1796
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Integer[] array = new Integer[3];
        array[0] = sc.nextInt();
        array[1] = sc.nextInt();
        array[2] = sc.nextInt();

        java.util.Arrays.sort(array);
        System.out.println(array[0] + " " + array[1] + " " + array[2]);
    }
}



Measured memory_bytes: 26208
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        for (int i=0; i<n; i++) a[i] = sc.nextInt();
        Arrays.sort(a);

        Set<Integer> set = new HashSet<>();

        int gcd = a[0];

        boolean check = false;
        for (int i=0; i<n; i++) {
            gcd = gcd(gcd, a[i]);
            if (!check) {
                for (int key: getDivisors(a[i])) {
                    if (set.contains(key)) {
                        check = true;
                    }
                    set.add(key);
                }
            }
        }
//        System.out.print(set);
//        System.out.print(mapSum);
//        System.out.print(keySet.size());

        if (!check) {
            System.out.print("pairwise coprime");
            return;
        }


        if (gcd == 1) {
            System.out.print("setwise coprime");
            return;
        }

        System.out.print("not coprime");

    }

    int gcd(int c, int d) {
        if (c < d) return gcd(d, c);
        if (d == 0) return c;
        return gcd(d, c % d);
    }

    List<Integer> getDivisors(int n) {
        var list = new ArrayList<Integer>();
        for (var i = 1; i < (long) Math.sqrt(n) + 1; i++) {
            if (n % i == 0) {
                list.add(i);
                var divisor = n / i;
                if (divisor != i) {
                    list.add(divisor);
                }
            }
        }

        Collections.sort(list);
        list.remove(0);
        return list;
    }
}



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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 K, A, B;
	cin >> K >> A >> B;
	int64 nxt = B - B%K;
	if (A <= nxt) {
	  cout << "OK" << endl;
	} else {
	  cout << "NG" << endl;
	}
}


Measured memory_bytes: 3652
#include<stdio.h>
#define N 10000

int main(){
  int n,i,j,t,q,s[N],count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&t);
    for(j=0;j<n;j++){
      if(s[j]==t){
	count++;
	break;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2144
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#define FAST ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
const int maxn = (int)1e5 + 5;
using namespace std;

struct hia{
	int l, r;
};

bool cmp(hia x, hia y){
	return x.r < y.r;
}

hia z[maxn];

int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= m; i++)
		scanf("%d %d", &z[i].l, &z[i].r);
	sort(z + 1, z + m + 1, cmp);
	int pos = 0, sum = 0;
	for(int i = 1; i <= m; i++)
		if(z[i].l >= pos){
			pos = z[i].r;
			sum++;
		}
	printf("%d\n", sum);
	return 0;
}

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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;
template <typename Val>
Val gcd(Val a, Val b) {
//use ll or int for gcd
    if (b==0) return a;
    else return gcd(b, a%b);
}
template <typename Val>
Val vec_max(vector<Val> v){
  return *max_element(v.begin(),v.end());
}
template <typename Val>
Val vec_min(vector<Val> v){
  return *min_element(v.begin(),v.end());
}



//---------------------------------------------------------------

int main(){
  string S;
  cin>>S;
  int ans = 0;
  rep(i,S.size()-1){
    if(S.at(i)!=S.at(i+1))ans++;
  }

   cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


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

    // [0, i] までの和 -> acc[i + 1]
    vector<long long int> acc(N + 1, 0);
    long long int sum = 0;
    for (int i = 0; i < N; i++) {
        sum += A[i];
        acc[i + 1] = sum;
    }

    map<long long int, long long int> cnt;
    cnt[0]++;
    long long int ans = 0;
    for(int i = 0; i < N; i++) {
        long long int s1 = acc[i + 1];
        ans += cnt[s1];
        cnt[s1]++;
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 15872
#include<cstdio>
#include<list>
#include<algorithm>
using namespace std;

int main(){
  int q,x;
  char com[20];

  list<int> v;
  scanf("%d",&q);

  for(int i=0;i<q;i++){
    scanf("%s",com);

    if(com[0]=='i'){scanf("%d",&x);v.push_front(x);}
    else if(com[6]=='L'){v.pop_back();}
    else if(com[6]=='F'){v.pop_front();}
    else if(com[0]=='d'){scanf("%d",&x);
      for(list<int>::iterator it=v.begin();it!=v.end();it++){
        if(*it==x){v.erase(it);break;}
      }
    }
  }

  int i=0;
  for(list<int>::iterator it=v.begin();it!=v.end();it++){
    if(i++)printf(" ");
    printf("%d",*it);
  }

  printf("\n");
  return 0;
}

Measured memory_bytes: 34004
import queue

q = queue.Queue()
K = int(input())

for i in range(1, 10):
    q.put(i)
for i in range(K-1):
    x = q.get()
    if x % 10 != 0:
        q.put(10*x+x % 10-1)
    q.put(10*x+x % 10)
    if x % 10 != 9:
        q.put(10*x+x % 10+1)
print(q.get())


Measured memory_bytes: 12452
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    public static void main(String[] args) {
        new Main().run();
    }

    public void run() {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        } catch (Throwable t) {
            t.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    void solve() throws IOException {
        int n = readInt();
        int w = readInt();
        long[] dp = new long[(int)w+1];
        long res = 0;
        for(int i=0;i<n;i++) {
            int wi = readInt();
            int vi = readInt();
            for(int j=w-wi; j>=0; j--){
                if(dp[j+wi]<dp[j]+vi) {
                    dp[j + wi] = dp[j] + vi;
                    if(res<dp[j]+vi)
                        res=dp[j]+vi;
                }
            }
        }
        System.out.println(res);
    }
}



Measured memory_bytes: 22484
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <string.h>
using namespace std;
int main()
{
    long long n;
    long long tmp = 1;
    cin >> n;
    for (long long i = 2; i <= sqrt(n); i++)
    {
        if (n % i == 0)
            tmp = i;
    }
    cout << (int(log10(tmp < sqrt(n) ? n / tmp : tmp) + 1)) << endl;
    return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] strs = line.Split(' ');

            for(int i = 0; i < 5; i++)
            {
                if (strs[i] == "0")
                {
                    Console.WriteLine(i+1);
                }
            }
        }
    }
}


Measured memory_bytes: 25876
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+5;
int n,cnt=0;
char clr[maxn];
int main(){
	cin >> n;
	for (int i=1;i<=n;i++){
		cin >> clr[i];
		if (clr[i] == 'W') cnt++;
	}
	int cntt = cnt;
	for (int i=0;i<cntt;i++){
		if (clr[n-i]=='W') cnt--;	
	}
	cout << cnt;
	return 0;
}

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

const int INF = 1 << 28;
const int MAX_N = 50010;
const int MAX_M = 21;
int c[MAX_M];
int dp[MAX_N];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	fill(dp, dp + MAX_N, INF);
	
	int n, m;
	cin >> n >> m;
	
	dp[n] = 0;
	
	for(int i = 0; i < m; ++i){
		cin >> c[i];
	}
	
	for(int i = n; i > 0; --i){
		for(int j = 0; j < m; ++j){
			if(i >= c[j]){
				dp[i - c[j]] = min(dp[i] + 1, dp[i - c[j]]);
			}
		}
	}
	
	cout << dp[0] << endl;
	
	return 0;
}

Measured memory_bytes: 1388
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Echizen
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long n = in.nextLong();
            long a = in.nextLong();
            long b = in.nextLong();
            if (n == 1 && a != b) {
                out.println(0);
            } else if (n == 1 && a == b) {
                out.println(1);
            } else if (n > 1 && a > b) {
                out.println(0);
            } else {
                out.println((n - 2) * (b - a) + 1);
            }
        }

    }
}


Measured memory_bytes: 24148
import java.util.Scanner;
	public class Main {
		
		static void solve() {
			Scanner sc = new Scanner(System.in);
			long a = sc.nextLong();
			long b = sc.nextLong();
			long k = sc.nextLong();
			sc.close();
			long res1 = Math.max(0, a - k);
			long res2 = Math.max(0, Math.min(a+b-k,b));
			System.out.println(res1 + " " + res2);
		}
		public static void main(String[] args) {	
			solve();
		}
	
	}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  vector<Int> p,e(1e5);
  e[0]=e[1]=1;
  for(Int i=2;i<1e5;i++){
    if(i*i>1e9) break;
    if(e[i]) continue;
    p.push_back(i);
    for(Int j=i+i;j<(Int)e.size();j+=i) e[j]=1;
  }
  //cout<<p.size()<<endl;

	
  Int l,r;
  cin>>l>>r;
  vector<Int> dp(r-l+1),dp2(r-l+1);
  iota(dp2.begin(),dp2.end(),l);
  for(Int i=0;i<(Int)p.size();i++){
    Int x=l/p[i]*p[i];
    if(x<l) x+=p[i];
    for(Int j=x;j-l<(Int)dp.size();j+=p[i]){
      Int &k=dp2[j-l];
      while(k%p[i]==0) k/=p[i],dp[j-l]++;
    }
  }
  Int ans=0;
  for(Int i=l;i<=r;i++){
    if(dp2[i-l]!=1) dp[i-l]++;
    ans+=!e[dp[i-l]];
    //cout<<i<<":"<<dp[i-l]<<" "<<dp2[i-l]<<endl;
  }
  cout<<ans<<endl;
  
  return 0;
}



Measured memory_bytes: 19500
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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; }

int gcd(int a, int b) {
  return b != 0 ? gcd(b, a % b) : a;
}

int N,maxi;

int main(){
    cin>>N;
    int A[N],l[N+1],r[N+1],M[N];
    l[0]=0;
    r[N]=0;
    rep(i,N){
        cin>>A[i];
    }
    rep(i,N){
        l[i+1]=gcd(A[i],l[i]);
    }
    for(int i=N-1;i>=0;i--){
        r[i]=gcd(A[i],r[i+1]);
    }
    rep(i,N){
        M[i]=gcd(l[i],r[i+1]);
        maxi=max(maxi,M[i]);
    }
    out(maxi);
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int f = 0; int x;
int main() {
	cin >> x;
	int k = x / 100; // 使える量
	if (x % 5 == 0) {
		f = (x % 100) / 5;  // 必要量
	}
	else
		f = (x % 100) / 5 + 1;
	if (k >= f) {
		cout << 1 << endl;
	}
	else
		cout << 0 << endl;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 3e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string str;
	cin >> str;
	sort(str.begin(), str.end());
	for (int i = 0; i + 1 < str.length(); i++)
	{
		if (str[i] == str[i + 1])
		{
			puts("no"), exit(0);
		}
	}
	puts("yes");
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8


def main():
    N, A, B = map(int, input().split())

    ans = (B - A) // 2 if (B - A) % 2 == 0 else min(A - 1, N - B) + 1 + (B - A - 1) // 2

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9036
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define REP(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int
main(int argc, char *argv[])
{
  int n;
  scanf("%d", &n);

  int x = 100, k = 1;
  while(n > 0){
    n -= k;
    k++;
  }

  for(int j = 1; j < k; j++){
    if(j != -n) printf("%d\n", j);
  }

  return 0;
}

  


Measured memory_bytes: 128
def main():
    buf = input()
    buflist = buf.split()
    N = int(buflist[0])
    M = int(buflist[1])
    buf = input()
    S = buf
    buf = input()
    T = buf
    L = lcm(N, M)
    # main part
    i = 0
    j = 0
    while i < len(S) and j < len(T):
        if i * (L / N) == j * (L / M):
            if not S[i] == T[j]:
                print(-1) # faliure
                return
            else:
                i += 1
                j += 1
        elif i * (L / N) < j * (L / M):
            i += 1
        elif i * (L / N) > j * (L / M):
            j += 1
    print(L) # success
    return

# 最大公約数 & 最小公倍数
def gcd(a, b):
    while b > 0:
        a, b = b, a % b
    return int(a)

def lcm(a, b):
    return int(a * b / gcd(a, b))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include<stdio.h>
int bubbleSort(int* ,int);
int main(){
  int array[100],num,kai,i;
  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%d",&array[i]);
  }
  kai = bubbleSort(array,num);
  for(i=0;i<num;i++){
    if(i!=0)printf(" ");
  printf("%d",array[i]);
  }
  printf("\n%d\n",kai);
  return 0;
}
int bubbleSort(int* A,int N){
  int flag =1,dai,kai=0,j;
    while(flag){
    flag=0;
    for(j=N-1;j>=1;j--){
      if(A[j] < A[j-1]){
	dai=A[j];
	A[j]=A[j-1];
	A[j-1]=dai;
	kai++;
	flag=1;
      }
    }
  }
  return kai;
}



Measured memory_bytes: 2044
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    int N;
    long x;
    cin >> N >> x;
    long candies[N];
    for(int i = 0; i < N; i++){
        cin >> candies[i];
    }
    long ans = max(0l, candies[0] - x) + max(0l, candies[N - 1] - x);
    candies[0] = min(candies[0], x);
    candies[N - 1] = min(candies[N - 1], x);
    for(int i = 1; i < N - 1; i++){
        ans += max(0l, (candies[i - 1] + candies[i]) - x);
        candies[i] -= max(0l, (candies[i - 1] + candies[i]) - x);
    }
    cout << ans + max(0l, (candies[N - 2] + candies[N - 1]) - x) << endl;
}


Measured memory_bytes: 1024
n,a,b = map(int,input().split())
x = list(map(int,input().split()))
ti = 0
for i in range(n-1):
    s = x[i]
    t = x[i+1]
    if (t-s)*a<b:
        ti += (t-s)*a
    else:
        ti += b
print(ti)

Measured memory_bytes: 15020
#!/usr/bin/env python3
(R, C, K), *D = [[*map(int,o.split())] for o in open(0)]
V = [[0] * C for _ in [None] * R]
for r, c, v in D:
    V[r - 1][c - 1] = v

dp = [[[-1] * C for _ in [None] * R] for _ in [None] * 4]

dp[0][0][0] = 0
for r in range(R):
    for c in range(C):
        v = V[r][c]
        for i in range(4):
            if dp[i][r][c] > -1:
                if r < R - 1:
                    dp[0][r + 1][c] = max(dp[0][r + 1][c], dp[i][r][c])
                if c < C - 1:
                    dp[i][r][c + 1] = max(dp[i][r][c + 1], dp[i][r][c])
                if i < 3 and v:
                    if r < R - 1:
                        dp[0][r + 1][c] = max(dp[0][r + 1][c], dp[i][r][c] + v)
                    if c < C - 1:
                        dp[i + 1][r][c + 1] = max(dp[i + 1][r][c + 1], dp[i][r][c] + v)

v = V[R - 1][C - 1]
ans = dp[3][R - 1][C - 1]
for i in range(3):
    ans = max(ans, dp[i][R - 1][C - 1] + v)
print(ans)

Measured memory_bytes: 443904
import kotlin.math.*

fun main() {
  val (N, K) = readLine()!!.split(" ").map(Integer::parseInt)
  val h = readLine()!!.split(" ").map(Integer::parseInt)

  var dp = IntArray(N) { 0 }
  dp[1] = abs(h[0] - h[1])

  var n = 2
  while (true) {
    if (n == N) break
    val maxK = min(K, n)
    var cost = Integer.MAX_VALUE
    for (k in 1..maxK) {
      cost = min(cost, abs(h[n-k] - h[n]) + dp[n-k])
    }
    dp[n] = cost
    n++
  }

  println(dp[N-1])
}

Measured memory_bytes: 51428
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
bool solve(void){
	int n,i,j;cin>>n;
	if(n==0){return false;}
	string mae="#";
	bool dame=false;
	int zyun[26][26]={};
	int zi[26]={};
	for(i=0;i<n;i++){
		
		string now;cin>>now;
		now.pub('#');
		j=0;
		while(mae[j]!='#'&&mae[j]==now[j]){j++;}
		if(mae[j]=='#'){mae=now;continue;}
		if(now[j]=='#'){dame=true;}
		zyun[mae[j]-'a'][now[j]-'a']=1;
		
		
		mae=now;
		
	}
	for(i=0;i<26;i++){
		for(j=0;j<26;j++){
			if(zyun[i][j]){zi[j]++;}
		}
	}
	if(dame){cout<<"no"<<endl;return true;}
	queue<int>que;
	for(i=0;i<26;i++){
		if(zi[i]==0){que.push(i);}
	}
	while(que.size()){
		int t=que.front();que.pop();
		for(j=0;j<26;j++){
			if(zyun[t][j]){
				
				zi[j]--;
				if(zi[j]==0){que.push(j);}
			}
		}
	}
	for(i=0;i<26;i++){
		if(zi[i]>0){cout<<"no"<<endl;return true;}
	}
	cout<<"yes"<<endl;
	return true;
}

int main(void){
	while(solve()){}
	return 0;
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
    if (a % b == 0) return b;
    return gcd(b, a % b);
}
int main() {
    ll N, X;
    cin >> N >> X;
    vector<ll> x(N);
    for (int i = 0; i < N; i++) cin >> x[i];
    ll ans = abs(X - x[0]);
    for (int i = 1; i < N; i++) {
        ans = gcd(ans, abs(X - x[i]));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(N):
    ans += B[A[i] - 1]
    if i != N - 1:
        if A[i + 1] == A[i] + 1:
            ans += C[A[i] - 1]
print(ans)


Measured memory_bytes: 38384
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;

signed main()
{
	ios::sync_with_stdio(false);
	int a,b;
	cin>>a>>b;
	if(a==1) cout<<1<<endl;
	else if(b==1) cout<<1<<endl;
	else cout<<(a*b+1ll)/2ll<<endl;
	return 0;
}

Measured memory_bytes: 256