akhauriyash/Code-Regression huggingface dataset:
#coding:utf-8

N = int(raw_input())

X = map(int, raw_input().split())
Y = sorted(X)

median_idx = ((1 + N) / 2) - 1
median = Y[median_idx]

small_counter = 0
same_counter = 0
for i in X:
    if i < median:
        small_counter += 1
    elif i == median:
        same_counter += 1

tmp = median_idx - small_counter
if tmp == 0:
    small_num = 0
    big_num = same_counter - 1
else:
    small_num = tmp
    big_num = same_counter - small_num - 1
#print median

for i in X:
    c_s_num = 0
    if median < i:
        if (N % 2) == 0:
            new_median_idx = median_idx
        else:
            new_median_idx = median_idx - 1
    elif median > i:
        if (N % 2) == 0:
            new_median_idx = median_idx + 1
        else:
            new_median_idx = median_idx
    elif median == i:
        if c_s_num <= small_num:
            c_s_num += 1
            if (N % 2) == 0:
                new_median_idx = median_idx + 1
            else:
                new_median_idx = median_idx
        else:
            if (N % 2) == 0:
                new_median_idx = median_idx
            else:
                new_median_idx = median_idx - 1
    print Y[new_median_idx]


Measured memory_bytes: 20060
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
    int t,n,i,j,k,l;
    cin>>n;
    int a[n][2];
    for(i=0;i<n;i++) cin>>a[i][0]>>a[i][1];
    bool hi=false;
    for(i=0;i<=(n-3);i++)
    {
        if(a[i][0]==a[i][1]&&a[i+1][0]==a[i+1][1]&&a[i+2][0]==a[i+2][1])
        {
            hi=true;
            break;
        }
    }
    if(hi) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3572
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int N;
ll x[100], y[100];
ll h[100];

void init()
{
}

void solve()
{
    REP(cx, 101){
        REP(cy, 101){
            set<ll> s;
            REP(i, N){
                if(h[i] > 0){
                    ll hh = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
                    s.insert(hh);
                }
            }
            if(s.size() == 1){
                ll hh = *s.begin();
                bool ok = true;
                REP(i, N){
                    if(h[i] != max(hh - abs(x[i] - cx) - abs(y[i] - cy), 0ll)){
                        ok = false;
                    }
                }
                if(!ok) continue;
                cout << cx << " " << cy << " " << *s.begin() << endl;
                return;
            }
        }
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i, N) cin >> x[i] >> y[i] >> h[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


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

int main(){
	int n;
	scanf("%d", &n);
	vector<int> x(n);
	f(i, 0, n)scanf("%d", &x[i]);
	vector<int> an;
	bool ok;
	do {
		ok = false;
		for (int i = x.size() - 1; i >= 0; --i)if (x[i] == i + 1){
			an.push_back(x[i]);
			x.erase(x.begin() + i);
			ok = true;
			break;
		}
	}while (ok);
	if (!x.empty())printf("-1\n");
	else for (int i = an.size() - 1; i >= 0; --i)printf("%d\n", an[i]);
}

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

int main(){
    int i, j;
    int n = 0;
    int flag = 0;
    int N;
    cin >> N;
    int A[N];
    for(i = 0;i < N;i++){
        cin >> A[i];
    }
    for(j = 0;j < N;j++){
        if(A[j] % 2 == 0){
            n += 1;
            if(A[j] % 3 == 0 || A[j] % 5 == 0){
                flag += 1;
            }
        }
    }
    if(flag == n){
        cout << "APPROVED" << endl;
    }
    else{
        cout << "DENIED" << endl;
    }
    return 0;
}
    




Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long int;
 
#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define MOD 1000000007 //10^9+7
//#define MOD 1
 
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
const int MAX = 1000;
 
ll table[MAX][MAX];
 
// テーブルを作る前処理
void COMinit() {
    table[0][0] = table[0][1] = 1;
    FOR(i, 1, MAX-1){
      FOR(j, 0, i+1){
        if(j==0) table[i][j] = 1;
        else if(j == i+1) table[i][j] = 1;
        else table[i][j] = table[i-1][j-1]+table[i-1][j];
      }
    }
}
 
// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return table[n-1][k];
}

void sosuu(ll n, vector<ll> &v){

  vector<ll> num(n, 0);

  FOR(i, 1, sqrt(n)){
    if(num[i]==0){
      FOR(j, 0, n/i){
        num[i+(j*i)] = 1;
      }
    }
  }
  REP(i, n){
    if(num[i]==0) v.push_back(i+1);
  }
}

ll SORT(int n, vector<pair<ll, ll>> &v, int start){
  sort(v.begin()+start, v.end());
  return v[n-1].first;
}


int main(void){
  ll n;
  cin>>n;
  ll ans = -1000000000;
  ll F[n][10];
  ll P[n][11];

  REP(i, n){
    REP(j, 10){
      ll x;
      cin>>x;
      F[i][j] = x;
    }
  }

  REP(i, n){
    REP(j, 11){
      ll x;
      cin>>x;
      P[i][j] = x;
    }
  }


  for(int bit=1;bit<(1<<10);++bit){

    vector<ll> v;
    for(int i=0;i<10;i++){
      if(bit & (1<<i)) v.push_back(i);
      //cout<<i<<" ";
    }
    //cout<<endl;

    ll sum = 0;
    REP(i, n){
      ll count = 0;
      REP(j, v.size()){
        count += F[i][v[j]];
      }
      sum += P[i][count];
    }
    ans = max(ans, sum);
  }

  cout<<ans<<endl;
  return 0;


}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<limits>
//include<bits/stdc++.h>
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if ((a == b && a != c) || (a == c && a != b) || (b == a && b != c) || (b == c && b != a) || (c == a && b != c)|| (b == c && a != c))
	{
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    char S[5][105];
    scanf("%s %s %s", S[0], S[1], S[2]);
    printf("A%cC\n", S[1][0]);
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


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

using namespace std;

int n,a[(int)2e5+10];

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

    int i,j,num[2]={0,0};
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]>num[0])
            num[1]=num[0],num[0]=a[i];
        else if(a[i]>num[1])
            num[1]=a[i];
    }
    for(i=0;i<n;i++)
        if(num[0]==a[i])
            cout<<num[1]<<endl;
        else
            cout<<num[0]<<endl;
    return 0;
}


Measured memory_bytes: 2432
from bisect import bisect
import sys
input = sys.stdin.readline

a, b, q = map(int, input().split())
s = [0] * a
t = [0] * b
x = [0] * q
for i in range(a):
    s[i] = int(input())
for i in range(b):
    t[i] = int(input())
for i in range(q):
    x[i] = int(input())
sorted(s)
sorted(t)

for xx in x:
    ind = bisect(s, xx)
    ss = []
    if ind > 0:
        ss.append(s[ind-1])
    if ind < a:
        ss.append(s[ind])
    tt = []
    ind = bisect(t, xx)
    if ind > 0:
        tt.append(t[ind-1])
    if ind < b:
        tt.append(t[ind])
    ans = float('inf')
    for y in ss:
        ind = bisect(t, y)
        tmpt = []
        if ind > 0:
            tmpt.append(abs(y-t[ind - 1]))
        if ind < b:
            tmpt.append(abs(y-t[ind]))
        st = min(tmpt)
        tmp = abs(xx-y) + st
        if tmp < ans:
            ans = tmp
    for y in tt:
        ind = bisect(s, y)
        tmps = []
        if ind > 0:
            tmps.append(abs(y-s[ind - 1]))
        if ind < a:
            tmps.append(abs(y-s[ind]))
        ts = min(tmps)
        tmp = abs(xx-y) + ts
        if tmp < ans:
            ans = tmp
    print(ans)

Measured memory_bytes: 73692
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;


signed main(){
    int n;
    cin>>n;
    cout<<n*n*n<<endl;
   
   
    return 0;
}

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

int n;
vector<long long> a, b;

void Solve() {
    long long add = 0;
    for (int i = n - 1; i >= 0; --i) {
        long long cur = a[i] + add;
        long long rem = cur % b[i];
        if (rem != 0) {
            add += (b[i] - rem);
        }
    }
    cout << add << endl;
}

bool Read() {
    if (!(cin >> n)) {
        return false;
    }
    a.resize(n);
    b.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }
    return true;
}

int main() {
    // freopen("input.txt", "r", stdin);

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (Read()) {
        Solve();
    }

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int a[50];
int k;
int main()
{
   cin>>n;
   if(n==0)
   {
       cout<<n<<endl;
       return 0;
   }
   while(n)
   {
      int m=n;
      a[k++]=abs(n)%2;
      n/=-2;
      if(m<0&&abs(m)%2)
        n++;
   }
   for(int i=k-1;i>=0;i--)
    cout<<a[i];
   cout<<endl;

}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

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

    int amax = *max_element(a.begin(), a.end());

    bool valid = true;
    if(amax % 2){
        int half = amax / 2 + 1;
        for(int i=half; i<=amax; i++){
            if(2 <= cnt[i]) cnt[i] -= 2;
            else valid = false;
        }

        if(0 < cnt[half]) valid = false;
    }
    else{
        int half = amax / 2;
        if(1 <= cnt[half]) cnt[half]--;
        else valid = false;

        for(int i=half+1; i<=amax; i++){
            if(2 <= cnt[i]) cnt[i] -= 2;
            else valid = false;
        }

        if(0 < cnt[half]) valid = false;
    }

    

    if(valid) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
from fractions import gcd
from functools import reduce


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


def solve(string):
    n, m, *a = map(int, string.split())
    c = 2**len(bin(a[0]).split("1")[-1])
    l = reduce(lcm, (2 * m + 2 if _a % c or not _a // c % 2 else _a for _a in a))
    return str(max((m - l // 2) // l + 1, 0))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 17172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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(){
    string S;
    cin >> S;
    int s=S.size();
    int now=0,ans=0;
    while(now<s-1-now){
        if (S[now]!=S[s-1-now]) ++ans;
        ++now;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i++){
			if(s[i] == ',')cout << " ";
			else cout << s[i];
	}
	cout << endl;
	return 0;
}


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

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: i64 = sc.cin();
    let m: i64 = sc.cin();
    put!(n*(n-1)/2+m*(m-1)/2);
}

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

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


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

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr int mo2 = 998244353;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    cin>>n>>m;
    vector<int> E[1050];
    for(int i=0;i<m;++i){
        int a,b;cin>>a>>b;
        a--;b--;
        E[a].push_back(b);
    }
    vector<int> ret;
    for(int i=0;i<n;++i){
        vector<int> dist(n,-1),prev(n,-1);
        dist[i] = 0;
        queue<int> q;
        q.push(i);
        [&](){
            while(!q.empty()){
                auto u = q.front();q.pop();
                for(int v : E[u])if(dist[v] == -1){
                    dist[v] = dist[u] + 1;
                    prev[v] = u;
                    q.push(v);
                }else if(v == i and (ret.empty() or (int)ret.size() > dist[u]+1)){
                    vector<int>{}.swap(ret);
                    int cur = u;
                    while(cur != i){
                        ret.push_back(cur);
                        cur = prev[cur];
                    }
                    ret.push_back(cur);
                }
            }
        }();
    }
    if(ret.empty())cout << -1 << endl;
    else{
        cout << ret.size() << endl;
        reverse(ret.begin(),ret.end());
        for(auto &a : ret){
            cout << a+1 << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 384
#include <stdio.h>

int N;
int s[128];

char visited[128][16384];

int answer = 0;

void asumikana(int idx, int score) {
	if (score % 10 != 0 && score > answer) answer = score;
	if (idx >= N || visited[idx][score]) return;
	visited[idx][score] = 1;
	asumikana(idx + 1, score);
	asumikana(idx + 1, score + s[idx]);
}

int main(void) {
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &s[i]) != 1) return 1;
	}
	asumikana(0, 0);
	printf("%d\n", answer);
	return 0;
}


Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		//数取得
		int N = sc.nextInt();
		int D = sc.nextInt();

		int answer = 0;

		for(int i = 0; i < N; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			double distance = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
			//System.out.println(distance);

			if(distance <= D) {
				answer++;
			}
		}

		System.out.println(answer);
	}

}


Measured memory_bytes: 48852
#include<bits/stdc++.h>
#define F first
#define S second
using ll = long long;
const ll mod = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
using namespace std;
using vl = vector<ll>;
using pll =  pair<ll,ll>;

void  solve(){
    int n,cnt= 0,mn = mod,x;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x;
        if(x < mn) {
            cnt++;
            mn = x;
        }
    }
    cout<<cnt;
}
        
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //int n; cin>>n; for(int i=0;i<n;i++)
        solve();
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(500000)

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N = ii()
    T = list(mi())
    M = ii()
    P, X = i2(M)

    S = sum(T)
    for i in range(M):
        print(S-T[P[i]-1]+X[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 62496
#include<stdio.h>
int main(){
	int a,b;
	char op;
	while(1){
		scanf("%d %c %d",&a,&op,&b);
		if(op=='+')printf("%d\n",a+b);
		else if(op=='-')printf("%d\n",a-b);
		else if(op=='*')printf("%d\n",a*b);
		else if(op=='/')printf("%d\n",a/b);
		else if(op=='?')break;
	}
	return 0;
}


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

int main()
{
	int n,m,l;
	cin >> n >> m >> l;
	long A[n][m],B[m][l],C[n][l];
	for(int i = 0;i < n;i++){
		for(int j = 0;j < m;j++){
			cin >> A[i][j];
			}
		}
	
	for(int i = 0;i < m;i++){
		for(int j = 0;j < l;j++){
			cin >> B[i][j];
	}
}

	for(int i = 0;i < n;i++){
		for(int j = 0;j < l;j++){
			C[i][j] = 0;
		}
	}
	

	for(int i = 0;i < n;i++){
		for(int j = 0;j < l;j++){
			for(int k = 0;k < m;k++){
				C[i][j] += A[i][k] * B[k][j];
				}
				cout << C[i][j];
				if(j == l - 1) cout << endl;
				else cout << " ";
			}
		}
		
		return 0;
}

Measured memory_bytes: 3296
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=3.14159265358979323846;
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n,k;
    cin>>n>>k;
    vector<ll> a(n);
    rep(i,n) {
        cin>>a[i];
    }
    
    ll sum1=0,sum2=0;
    rep(i,n) {
        if(i<k) sum1+=a[i];
        else sum2+=max(0LL,a[i]);
    }
    
    ll ans=max(0LL,sum1)+sum2;
    rep(i,n-k) {
        sum2+=max(0LL,a[i]);
        sum1-=a[i];
        sum1+=a[i+k];
        sum2-=max(0LL,a[i+k]);
        ans=max(ans,max(0LL,sum1)+sum2);
    }
    
    cout<<ans<<endl;
    
}


Measured memory_bytes: 1024
// コメント修正して, 再提出.
#include <bits/stdc++.h>
using namespace std;
#define repx(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
const int MAX = 101010;
vector<int> member[MAX];
set<int> graph[MAX];
int memo[MAX];

// https://ja.wikipedia.org/wiki/幅優先探索
// ※bfsの動作確認用.
// @param m: 参加者.
// @param l: 連結成分番号.
// @param: 特に無し.
void bfs(int m, int l){
    
    // 1. 終了条件設定.
    if(memo[m] >= 1) return;
    
    // 2. 空のキュー.
    queue<int> q;
    
    // 3. 参加者 m をキュー q に追加.
    memo[m] = l;
    q.push(m);
    while(!q.empty()){
        
        // 4. キューから取り出す.
        int u = q.front();
        q.pop();
        
        // 5. 取り出した要素を処理.
        for(auto &e : graph[u]){
             // 6. 訪問済であれば, 処理をスキップ.
            if(memo[e] > 0)            continue;
            if(memo[e] == 0 && e != m) memo[e] = l, q.push(e);
        }
    }
    return;
}

int main(){
    
    // 1. 入力情報.
    int N, M;
    scanf("%d %d", &N, &M);
    
    // 2. 言語ごとに, 参加者情報を保存.
    rep(i, N){
        int K, L;
        scanf("%d", &K);
        rep(j, K) scanf("%d", &L), L--, member[L].pb(i);
    }
    
    // 3. 参加者情報をグラフに移し替える.
    rep(i, M){
        for(auto &p : member[i]){
            int f = member[i].front();
            if(f != p) graph[f].insert(p), graph[p].insert(f);
        }
    }
    
    // 4. 連結成分の個数をカウント.
    int ans = 1;
    rep(i, N) if(memo[i] == 0) bfs(i, ans), ans++;
    
    // 5. 出力.
    printf("%s\n", (ans == 2) ? "YES" : "NO");
    return 0;
    
}

Measured memory_bytes: 17912
#include <stdio.h>
int Search(int *,int, int);

int main(){
 int S[100000],T[50000];
    int n,q,i,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[i]);
        if(Search(S,n,T[i])==1) count++;
    }

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

    return 0;
}

int Search(int *A,int n,int key){
    int left=0,middle=0,right=0;
    right=n;

    while(left<right){
        middle=(left+right)/2;
        if(A[middle]==key) return 1;
        if(A[middle]<key) left=middle+1;
        else if(A[middle]>key) right=middle;
    }
    return 0;
}


Measured memory_bytes: 2268
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define tii tuple<int,int,int>
signed main(){
  string S,T;
  cin>>S>>T;
  sort(ALL(S));
  sort(ALL(T));
  reverse(ALL(T));
  string ans="No";
  if(S<T)
    ans="Yes";
  cout<<ans<<endl;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define allof(a) a.begin(),a.end()

typedef pair< int, int > pii;

int N, Q;
vector< int > s, id;
set< int > leader;

int count(int r) {
	if ((int)leader.size() == 0) return N;
	
	set< int >::iterator it = leader.begin(), eit = leader.end();
	int res = 0, p = 0;
	
	for (; it != eit; ++it) {
		int L = lower_bound(allof(s), s[*it] - r) - s.begin();
		res += max(0, L - p);
		int R = upper_bound(allof(s), s[*it]) - s.begin();
		p = R;
	}
	
	res += N - p;
	return res;
}

int check(int x) {
	int lb = -1, ub = (int)1e9 + 10;
	
	while (ub - lb > 1) {
		int med = (lb + ub) / 2;		
		if (x < count(med)) lb = med;
		else ub = med;
	}
	
	return ub;
}

void query() {
	for_(i,0,Q) {
		string t; int a; cin >> t >> a;
		
		if (t == "ADD") leader.insert(id[a-1]);	
		
		if (t == "REMOVE") leader.erase(id[a-1]);
		
		if (t == "CHECK") {
			int res = check(a);
			if (res > (int)1e9) cout << "NA" << endl;
			else cout << res << endl;
		} 
	}
}

int main() {
	cin.tie(0);
	std::ios::sync_with_stdio(0);
	
	cin >> N >> Q;
	
	vector< pii > vp;
	for_(i,0,N) {
		int s; cin >> s;
		vp.push_back(pii(s, i));
	}
	
	sort(allof(vp));
	
	s.assign(N, 0);
	id.assign(N, 0);
		
	for_(i,0,N) {
		s[i] = vp[i].first;
		id[vp[i].second] = i;
	}
	
	query();
	
	return 0;
}

Measured memory_bytes: 16816
#include <iostream>
#include <vector>

int main() {
    int n, m;
    std::vector<int> r, input;
    std::cin >> n >> m;
    r.resize(n + 1, 0);
    input.resize(2 * m);
    for (int i = 0; i < 2 * m; i++) {
        std::cin >> input[i];
    }
    for (int i = 0; i < 2 * m; i++) {
        r[input[i]]++;
    }
    for (int i = 1; i < n + 1; i++) {
        std::cout << r[i] << std::endl;
    }    
}

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

#include <bits/stdc++.h>
using namespace std; 
using ll = long long;
using ld = long double;
vector<vector<vector<ld>>> memo(3e2+5, vector<vector<ld>>(3e2+5, vector<ld> (3e2+5, -1)));

ld dp(int n, int n1, int n2, int n3){
	if(n1 == 0 && n2 == 0 && n3 == 0)
		return 0;
	if(memo[n3][n2][n1] != -1)
		return memo[n3][n2][n1];

	memo[n3][n2][n1] = 0;
	if(n3)
		memo[n3][n2][n1] += (1+dp(n, n1, n2+1, n3-1))*n3/(ld)n;
	if(n2)
		memo[n3][n2][n1] += (1+dp(n, n1+1, n2-1, n3))*n2/(ld)n;
	if(n1)
		memo[n3][n2][n1] += (1+dp(n, n1-1, n2, n3))*n1/(ld)n;
	memo[n3][n2][n1] += (n-n1-n2-n3)/(ld)n;
	memo[n3][n2][n1]/=(1-(n-n1-n2-n3)/(ld)n);
	return memo[n3][n2][n1];
}



signed main() { 
	cin.tie(0);
	cin.sync_with_stdio();
	int n; 
	cin>>n;
	vector<ld> v(n);
	int n1, n2, n3;

	n1 = n2 = n3 = 0;
	for(int i = 0; i < n; i++){
		int a;
		cin>>a;
		if(a == 1)
			n1++;
		else if(a == 2)
			n2++;
		else 
			n3++;
	}


	cout<<setprecision(20)<<dp(n, n1, n2, n3);
}


Measured memory_bytes: 448896
/*
 * DATE : 2017-06-03
 * Algo :
*/
#include<bits/stdc++.h>
using namespace std;
/*------- Constants---- */

#define Long                    long long
#define Ulong                   unsigned long long
#define FOR(I,A,B)              for(long long i=0; i < n ; i++ )
#define REP(i,n)                for(long long i=0; i < n ; i++ )
#define mp                      make_pair
#define pb                      push_back
#define all(x)                  (x).begin(),(x).end()
#define PI                      acos(-1.0)
#define EPS                     1e-9
#define F                       first
#define S                       second
#define lc                      ((n)<<1)
#define rc                      ((n)<<1|1)
#define db(x)                   cout << #x << " -> " << x << endl;
#define Di(x)                   int x; cin>>x
#define in(x)                   input(x)
#define in2(x,y)                input(x), input(y)
#define in3(x,y,z)              input(x), input(y),input(z)
#define ins(x)                  scanf("%s",x)
#define ind(x)                  scanf("%lf",&x)
#define ms(ara_name,value)      memset(ara_name,value,sizeof(ara_name))
#define IO                      ios_base::sync_with_stdio(0);cin.tie(0)
#define READ                    freopen("in.txt","r",stdin)
#define WRITE                   freopen("out.txt","w",stdout)

template<class T > void input(T &x){
    char c = getchar();x = 0;
    for(;(c<48 || c>57);c = getchar());
    for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}
}
inline long long bigmod(long long p,long long e,long long M){
    long long ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

/***************************** END OF TEMPLATE *******************************/

const int N = 4e5+5;
int n;
long long psum[N];
long long a[N];
long long k;
long long bit[N];

void update(int x,int v)
{

    while(x<N) bit[x] += v, x+=x&-x;
}

long long query(int x)
{
    long long ret= 0;
    while(x>0) ret+= bit[x], x-=x&-x;
    return ret;
}

int main()
{
    in2(n,k);
    for(int i=1;i<=n;i++ ) {
        in(a[i]);
        psum[i] = psum[i-1] + a[i];
    }

    long long ans = 0;

    vector<long long> v;
    for(int i=1;i<=n;i++) {
        v.push_back(psum[i] - i * k );
    }
    sort(all(v));
    for(int i=1;i<=n;i++) {
        int pos = lower_bound(all(v), psum[i]- i*k) - v.begin() + 1;

        ans += query(pos);
        update(pos,1);
        if(psum[i] - i * k >= 0 ) ans ++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9712
#include<stdio.h>
int main(void){
  
  int a[4];
  int S,i,sign=0;
  
  scanf("%d",&S);
  
  for(i=0;i<4;i++){
    a[i] = S%10;
    S = S/10;
  }
  
  for(i=0;i<3;i++){
    if(a[i] == a[i+1])sign = 1;
  }
  
  if(sign == 1)printf("Bad");
  else printf("Good");
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

int main(void)
{
	int A, B;
	cin >> A >> B;

	int ans = 0;
	ans = max(ans, A + A - 1);
	ans = max(ans, A + B);
	ans = max(ans, B + B - 1);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
const ll mod = 1000000007;
const int A = 0, C = 1, G = 2, T = 3;
int main() {
  int n;
  cin >> n;
  ll dp[n][4][4][4];
  rep(i, n) rep(j, 4) rep(k, 4) rep(l, 4) dp[i][j][k][l] =
    0LL;
  rep(j, 4) rep(k, 4) rep(l, 4) dp[2][j][k][l] = 1LL;
  dp[2][A][C][G] = 0LL;
  dp[2][G][A][C] = 0LL;
  dp[2][A][G][C] = 0LL;

  rep(i, n) {
    if(i < 3) continue;
    rep(j, 4) rep(k, 4) rep(l, 4) dp[i][k][l][A] =
      (dp[i][k][l][A] + dp[i - 1][j][k][l]) % mod;

    rep(j, 4) rep(k, 4) rep(l, 4) {
      if(j == A && k == G) continue;
      if(j == A && l == G) continue;
      if(k == G && l == A) continue;
      if(k == A && l == G) continue;
      dp[i][k][l][C] =
        (dp[i][k][l][C] + dp[i - 1][j][k][l]) % mod;
    }

    rep(j, 4) rep(k, 4) rep(l, 4) {
      if(k == A && l == C) continue;
      dp[i][k][l][G] =
        (dp[i][k][l][G] + dp[i - 1][j][k][l]) % mod;
    }

    rep(j, 4) rep(k, 4) rep(l, 4) {
      dp[i][k][l][T] =
        (dp[i][k][l][T] + dp[i - 1][j][k][l]) % mod;
    }
  }

  ll ans = 0;
  rep(j, 4) rep(k, 4) rep(l, 4) ans =
    (ans + dp[n - 1][j][k][l]) % mod;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int x,y;
    while(1){
        cin>>x>>y;
        if(x==0&&y==0)break;
        if(x>y)cout<<y<<" "<<x<<endl;
        if(x<=y)cout<<x<<" "<<y<<endl;
    }
    return 0;
    
}



Measured memory_bytes: 3060
package main

import (
    "fmt"
    "os"
    "bufio"
    "strings"
    "strconv"
    "math"
)

var sc = bufio.NewScanner(os.Stdin)

func StrStdin() (stringInput string){
  sc.Scan()
  OneLineString := sc.Text()
  stringInput = strings.TrimSpace(OneLineString)
  return 
}

func IntStdin() (int, error){
  stringInput := StrStdin()
  return strconv.Atoi(stringInput)
}

// ?????????????l??????????Split()
func SplitWithoutEmpty(stringTargeted string, delim string) (stringReturned []string) {
    stringSplited := strings.Split(stringTargeted, delim)

    for _, str := range stringSplited {
        if str != "" {
            stringReturned = append(stringReturned, str)
        }
    }

    return
}

// ?f???~?^??????????????X???C?X???��
func SplitStrStdin(delim string) (stringReturned []string) {
    // ???????1?s?��
    stringInput := StrStdin()
  
    // ???????
    // stringSplited := strings.Split(stringInput, delim)
    stringReturned = SplitWithoutEmpty(stringInput, delim)

    return
}

// ?f???~?^?????????????l?X???C?X???��
func SplitIntStdin(delim string) (intSlices []int, err error) {
    // ??????X???C?X???��
    stringSplited := SplitStrStdin(delim)
	
    // ?????X???C?X????
    for i := range stringSplited {
        var iparam int
        iparam, err = strconv.Atoi(stringSplited[i])
        if err != nil {
            return
        }
        intSlices = append(intSlices, iparam)
    }
    return
}

func main(){
  row1, _ := SplitIntStdin(" ")
  row2, _ := SplitIntStdin(" ")
  row3, _ := SplitIntStdin(" ")
  
  var abs = []float64{0,0,0}

  abs[0] = math.Abs(float64(row1[0] - row2[0]))
  abs[1] = math.Abs(float64(row1[1] - row2[1]))
  abs[2] = math.Abs(float64(row1[2] - row2[2]))
  
  var abs2 = []float64{0,0,0}
  
  abs2[0] = math.Abs(float64(row2[0] - row3[0]))
  abs2[1] = math.Abs(float64(row2[1] - row3[1]))
  abs2[2] = math.Abs(float64(row2[2] - row3[2]))

  var abs3 = []float64{0,0,0}
  
  abs3[0] = math.Abs(float64(row1[0] - row3[0]))
  abs3[1] = math.Abs(float64(row1[1] - row3[1]))
  abs3[2] = math.Abs(float64(row1[2] - row3[2]))
 
  if abs[0] == abs[1] && abs[0] == abs[2] && abs[1] == abs[2] {
    if abs2[0] == abs2[1] && abs2[0] == abs2[2] && abs2[1] == abs2[2] {
      if abs3[0] == abs3[1] && abs3[0] == abs3[2] && abs3[1] == abs3[2] {
        fmt.Println("Yes")
      }else{
        fmt.Println("No")
      }
    }else{
      fmt.Println("No")
    }
  }else{
    fmt.Println("No")
  }
}

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

const int N = 1e6 + 5;
char s[N * 2];
int nextm[N];
int sc[N];
int main()
{
    int n, q;
    scanf("%d%s%d", &n, s, &q);

    while (q--)
    {
        int k;
        scanf("%d", &k);

        ll ans = 0, now = 0;
        int m = 0, c = 0;
        for (int i = 0; i < k; ++i)
            if (s[i] == 'M')
                ++m;
            else if (s[i] == 'C')
            {
                now += m;
                ++c;
            }
        for (int i = 0; i < n; ++i)
        {
            if (s[i] == 'D')
                ans += now;

            if (s[i + k] == 'M')
                ++m;
            else if (s[i + k] == 'C')
            {
                now += m;
                ++c;
            }

            if (s[i] == 'M')
            {
                now -= c;
                --m;
            }
            else if (s[i] == 'C')
                --c;
        }

        printf("%lld\n", ans);
    }
}

Measured memory_bytes: 2944
program bbb

integer(8) :: n, k, i, j
integer(8),allocatable,dimension(:) :: h, dp

read*, n, k
allocate(h(n))
allocate(dp(-k:n))
read*, h

dp=10**9
dp(1)=0
do i=2, n
 do j=1, k
 dp(i)=min(dp(i-j)+abs(h(i-j)-h(i)),dp(i))
 end do
end do

write(*,'(i0)') dp(n)

end program

Measured memory_bytes: 2304
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;

int dist[55][2525];

signed main(){
	int N,M,S;
	cin >> N >> M >> S;
	vector<vector<tuple<int,int,int>>>g(N);
	REP(i,M){
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		--a;--b;
		g[a].emplace_back(b,c,d);
		g[b].emplace_back(a,c,d);
	}
	vector<int>c(N),d(N);
	REP(i,N){
		cin >> c[i] >> d[i];
	}
	if(S > 2500){
		vector<int>d(N,INF);
		d[0] = 0;
		priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>que;
		que.push({0,0});
		while(que.size()){
			auto[cost,now] = que.top();
			que.pop();
			if(d[now] != cost)continue;
			for(auto [to,hoge,time]:g[now]){
				if(CHMIN(d[to],d[now]+time)){
					que.push({d[to],to});
				}
			}
		}
		FOR(i,1,N)out(d[i]);
		return 0;
	}
	REP(i,55)REP(j,2525)dist[i][j] = INF;
	dist[0][S] = 0;
	priority_queue<tuple<int,int,int>,vector<tuple<int,int,int>>,greater<tuple<int,int,int>>>que;
	que.push({0,S,0});
	while(que.size()){
		auto[time,coin,now] = que.top();
		que.pop();
		if(dist[now][coin] != time)continue;
		if(CHMIN(dist[now][min(2500ll,coin + c[now])],time + d[now]))que.push({dist[now][min(2500ll,coin + c[now])],min(2500ll,coin + c[now]),now});
		for(auto[to,a,b]:g[now]){
			if(coin - a >= 0 && CHMIN(dist[to][coin - a],time + b))que.push({dist[to][coin - a],coin - a,to});
		}
	}
	FOR(i,1,N){
		int ans = INF;
		REP(j,2525)CHMIN(ans,dist[i][j]);
		out(ans);
	}
}

Measured memory_bytes: 7512
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cmath>
#define ll long long 
#define ull unsigned long long 
using namespace std;

char s[1110000];
int main()
{
	cin >> s;
	int ans = 0;
	for(int i=1; i<strlen(s); ++i)
		if(s[i] != s[i-1])
			ans++;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll=long long;

int main(){
    ll n,m,i,j,k;
    ll a,b,c,d;
    string tmp;

    cin>>n;
    set<string> st;
    for(i=0;i<n;i++){
        cin>>tmp;
        st.insert(tmp);
    }
    cout<<st.size();

    return 0;
}



Measured memory_bytes: 19116
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;

char str[N];
char a[N], b[N];

int main() {
    scanf("%s", str+1);
    int n = (int)strlen(str+1);
    for (int i = 1; i <= n; i++) {
        if (i%2) a[i] = '1';
        else a[i] = '0';
    }
    for (int i = 1; i <= n; i++) {
        if (i%2) b[i] = '0';
        else b[i] = '1';
    }
    int Sum = 0, Sum1 = 0;
    for (int i = 1; i <= n; i++) {
        if (str[i] != a[i]) Sum++;
    }
    for (int i = 1; i <= n; i++) {
        if (str[i] != b[i]) Sum1++;
    }
    printf("%d\n", min(Sum1, Sum));
    return 0;
}

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

int main(){
  int A, B, C, X, Y, price = 0;
  cin >> A >> B >> C >> X >> Y;
  price = min(X, Y) * min(A+B, C*2);
  if(X < Y){
  	price += (Y - X) * min(B, C*2);
  }else if(X > Y){
  	price += (X - Y) * min(A, C*2);
  }
  cout << price << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int read(){
    int cnt = 0;
    char ch = getchar();
    while (ch < '0' || '9' < ch)
        ch = getchar();
    while ('0' <= ch && ch <= '9'){
        cnt = cnt * 10 + ch - '0';
        ch = getchar();
    }
    return cnt;
}
int main(){
    int a, b;
    cin >> a >> b;
    cout << max(max(a + b, a - b), a * b) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

const int MOD = 1000000007;

template<typename T>
class Matrix {
public:
    explicit Matrix(int N) : m(N, vector<T>(N, 0)) {}
    static Matrix ident(int N) {
        Matrix res(N);
        for(int i=0;i<N;i++) res.m[i][i] = 1;
        return res;
    }
    vector<T>& operator [](int n) { return m[n]; }
    const vector<T>& operator [](int n) const { return m[n]; }
    int size() const { return m.size(); }
public:
    vector<vector<T>> m;
};

template<typename T>
Matrix<T> mul(const Matrix<T>& a, const Matrix<T>& b){
    const int N = a.size();
    Matrix<T> res(N);
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            res[i][j] = 0;
            for(int k=0;k<N;k++) res[i][j] += a[i][k] * b[k][j];
            res[i][j] %= MOD;
        }
    }
    return res;
}

template<typename T>
Matrix<T> pow(const Matrix<T>& a, int p){
    const int N = a.size();
    if(p == 0) return Matrix<T>::ident(N);
    auto res = pow(a, p/2);
    res = mul(res, res);
    if(p%2) res = mul(res, a);
    return res;
}

template<typename T>
vector<T> vecMul(const Matrix<T>& a, const vector<T>& v){
    const int N = a.size();
    vector<T> res(N, 0);
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            res[i] += a[i][j] * v[j];
        }
        res[i] %= MOD;
    }
    return res;
}

int solve(int N){
    Matrix<long long> m(21);
    for(int i=0;i<10;i+=2) m[i+1][i] = 1;
    for(int i=0;i<=10;i+=2){
        for(int j=1;j<=min(10, i+1);j+=2) m[i][j] = 1;
    }
    m[10][10] = 1;
    for(int i=11;i<=20;i++) m[i][i-1] = m[i][i] = 1;
    vector<long long> v(21, 0);
    for(int i=0;i<=10;i+=2) v[i] = 1;
    return vecMul(pow(m, N+5), v).back();
}

int main(){
    int T; cin >> T;
    for(int _=0;_<T;_++){
        int N; cin >> N;
        cout << solve(N) << endl;
    }
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(2 * n);
  rep(i, 2 * n){
    cin >> a[i];
  }
  int ans = 0;
  sort(a.begin(), a.end());
  for (int i = 0; i < 2 * n; i+= 2){
    ans += a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll sum=0;
ll a[3*123456];
bool cmd(ll x,ll y)
{
    return x>y;
}
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=3*n;i++)
    {
       cin>>a[i];
    }
    int i=2;
    sort(a+1,a+1+3*n,cmd);
    while((n)--)
    {
        sum+=a[i];
        //cout<<a[i]<<endl;
        i+=2;
    }
    cout<<sum<<endl;
    return 0;
}


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

int main() {
	int n;
	int a[101];
	cin >> n;
	int al=0,bo=0;
	bool flag=false;
	for(int i=0;i<n;i++)
		cin >> a[i];
	sort(a,a+n);
	for(int i=0;i<n;i++){
		if(!flag)al+=a[i];
		if(flag)bo+=a[i];
		flag=!flag;
	}
	
	cout << abs(al-bo) << endl;	
	return 0;
}	

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	int n;cin>>n;
	string s; cin >> s;
	
	int ans = 0;
	//全部黒
	rep(i,n)if(s[i]=='.')ans++;
	int k = ans;
	rep(i,n)
	{
		int f=ans;
		if(s[i]=='#')f++;
		if(s[i]=='.')f--;
		//cout<<f<<endl;
		ans = f;
		k = min (ans , k);
	}
	cout<<k<<endl;

	return 0;
}

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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int ans;
  ans = min(a * n, b);
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

const int contests[] = { 111, 222, 333, 444, 555, 666, 777, 888, 999 };
int main() {
    int n; cin >> n;
    rep(i, 9) {
        if (n <= contests[i]) {
            cout << contests[i] << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256