akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
const double PI  =3.141592653589793238463;
using namespace std;
using ll = long long;
const ll INF = +10010010000;
typedef pair<ll,ll> P;
const int mod = 1000000007;

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

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

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

// ll ssum(vector<ll> a,int i, int m){
//     if(i==a.size()-1)return a[i]/m;
//     else return ssum(a, i+1, m)+a[i]
// }

int main(){
    int n;
    ll s=0;
    cin >> n;
    vector<ll> a(n), x(n);
    rep(i,n){
        cin >> a[i];
        s+=a[i];
    }
    x[0] = s;
    for(int i = 1;i<n; i+=2)x[0]-=2*a[i];
    rrep(i,n-1){
        x[i] = 2*a[i-1]-x[i-1];
    }
    rep(i,n){
        cout << x[i]<<" ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <cstdlib>
#include <queue>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>
#include <bitset>
using namespace std;

vector<vector<int>> c;
int w, h;

void search(int i, int j){
    if(i-1 >= 0 && j-1 >= 0 && c[i-1][j-1] == 1){
        c[i-1][j-1] = 0;
        search(i-1, j-1);
    }
    if(j-1 >= 0 && c[i][j-1] == 1){
        c[i][j-1] = 0;
        search(i, j-1);
    }
    if(i+1 < h && j-1 >= 0 && c[i+1][j-1] == 1){
        c[i+1][j-1] = 0;
        search(i+1, j-1);
    }
    if(i-1 >= 0 && c[i-1][j] == 1){
        c[i-1][j] = 0;
        search(i-1, j);
    }
    if(i+1 < h && c[i+1][j] == 1){
        c[i+1][j] = 0;
        search(i+1, j);
    }
    if(i-1 >= 0 && j+1 < w && c[i-1][j+1] == 1){
        c[i-1][j+1] = 0;
        search(i-1, j+1);
    }
    if(j+1 < w && c[i][j+1] == 1){
        c[i][j+1] = 0;
        search(i, j+1);
    }
    if(i+1 < h && j+1 < w && c[i+1][j+1] == 1){
        c[i+1][j+1] = 0;
        search(i+1, j+1);
    }
    return;
}

int main()
{
    int ans;
    while(true){
        cin >> w >> h;
        if(w == 0 && h == 0){
            break;
        }
        // init
        ans = 0;
        c.resize(h);
        for(int i=0; i<h; ++i){
            c[i].resize(w);
            for(int j=0; j<w; ++j){
                cin >> c[i][j];
            }
        }
        // search
        for(int i=0; i<h; ++i){
            for(int j=0; j<w; ++j){
                if(c[i][j] == 1){
                    ans++;
                    c[i][j] = 0;
                    search(i, j);
                }
            }
        }
        // output
        cout << ans << endl;
        // clear
        for(int i=0; i<h; ++i){
            c[i].clear();
        }
        c.clear();
    }
    return 0;
}


Measured memory_bytes: 3288
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
      if(s.equals("++++")){
       System.out.println(4);
      }
      else if(s.equals("+++-") || s.equals("++-+") || s.equals("+-++")|| s.equals("-+++")){
      System.out.println(2);
      }
      else if(s.equals("+---") || s.equals("-+--") || s.equals("--+-")|| s.equals("---+")){
      System.out.println(-2);
      }
      else if(s.equals("----")){
       System.out.println(-4);
      }
      else{
      System.out.println(0);
      }
      
    }
}

Measured memory_bytes: 22740
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

const ll mod = 998244353;

int n;
string s;
vector<int> vec;
ll d[200010][2];
ll cnt[200010];
ll ans;

signed main() {
	cin >> n >> s;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n%i == 0) {
			if (i % 2 && i != 1)vec.push_back(n / i);
			if ((n / i) % 2 && n / i != 1)vec.push_back(i);
		}
	}
    sort(all(vec));
	d[0][0] = 1;
	for (int i = 0; i < n; i++) {
		if (s[i] == '1') {
			d[i + 1][0] = d[i][0];
			d[i + 1][1] = (d[i][0] + d[i][1] * 2) % mod;
		}
		else {
			d[i + 1][0] = d[i][0];
			d[i + 1][1] = d[i][1] * 2 % mod;
		}
	}
	cnt[n] = (d[n][0] + d[n][1]) % mod;
	for (int i = 0; i < (int)vec.size(); i++) {
		d[0][0] = 1;
		for (int j = 0; j < vec[i]; j++) {
			if (s[j] == '1') {
				d[j + 1][0] = d[j][0];
				d[j + 1][1] = (d[j][0] + d[j][1] * 2) % mod;
			}
			else {
				d[j + 1][0] = d[j][0];
				d[j + 1][1] = d[j][1] * 2 % mod;
			}
		}
		cnt[vec[i]] += d[vec[i]][1];
		bool bl = true;
		for (int j = vec[i]; j < n; j++) {
			if ((j / vec[i]) % 2) {
				if (s[j % vec[i]] == '1'&&s[j] == '1') {
					bl = true;
					break;
				}
				if (s[j % vec[i]] == '0'&&s[j] == '0') {
					bl = false;
					break;
				}
			}
			else {
				if (s[j%vec[i]] == '0'&&s[j] == '1') {
					bl = true;
					break;
				}
				if (s[j%vec[i]] == '1'&&s[j] == '0') {
					bl = false;
					break;
				}
			}
		}
		if (bl)cnt[vec[i]]++;
		cnt[vec[i]] %= mod;
		for (int j = vec[i] * 2; j <= n; j += vec[i])cnt[j] = (cnt[j] - cnt[vec[i]] + mod) % mod;
		ans = (ans + cnt[vec[i]] * vec[i] * 2) % mod;
	}
	cnt[n] = (cnt[n] + mod) % mod;
	ans = (ans + cnt[n] * n * 2) % mod;
	cout << ans << endl;
}


Measured memory_bytes: 8468
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int A=sc.nextInt();
		int B=sc.nextInt();
		int C=sc.nextInt();
		sc.close();

		if(A==B&&B==C) {
			System.out.println("No");
		}
		else if(A==B||B==C||A==C) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};
fastio _fast_io;

const int N = 1e5 + 5;
int n, k;
string s;

int main() {
    cin >> n >> k;
    cin >> s;
    int res = 0;
    for (int i = 1; i < n; ++i) {
        if (s[i] == s[i - 1])
            ++res;
    }
    res = min(res + k * 2, n - 1);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3780
function mtx(ps)
    H, W = parse.(Int, split(ps[1]))
    org = fill("*", H, W)
    expd = fill("*", 2H, W)
    for i in 1:H
        for j in 1:W
            org[i, j] = ps[1+i][j:j]
        end
    end
    for i in 1:2H
        expd[i, :] = org[Int(floor((i+1)/2)), :]
    end
    return expd
end

function ret(arr)
    H, W = size(arr)
    str_arr = ["" for i in 1:H]
    for i in 1:H
        str_arr[i] = prod(arr[i, :])*"\n"
    end
    return println(prod(str_arr))
end

m = readlines()

ret(mtx(m))

Measured memory_bytes: 205012
#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;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

// 1 点更新区間取得
// 条件は要素がモノイドであること（あるいは半群？）
// 有名どころは 和, 積, min, max gcd lcm
// プラスアルファで行列 ?



template <typename T>
struct SegmentTree{
    using F = function<T(T, T)>;
    int n;
    F f;
    T ti;
    vector<T> dat;
    SegmentTree(){};
    SegmentTree(F f, T ti, const vector<T> &v):f(f),ti(ti){
        int sz = v.size();
        n = 1;
        while(n < sz) n <<= 1;
        dat.assign(2 * n - 1, ti);
        for(int i = 0; i < sz; i++) dat[n - 1 + i] = v[i];
        for(int i = n - 2; i >= 0; i--) dat[i] = f(dat[2 * i + 1], dat[2 * i + 2]);
    }

    // x 番目(0 - indexed) の要素を val に更新
    void update(int x, T val){
        x += (n - 1);
        dat[x] = val;
        while(x > 0){
            x = (x - 1) / 2;
            dat[x] = f(dat[2 * x + 1], dat[2 * x + 2]);
        }
    }

    // 区間[a, b)を取得する
    T query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return ti;
        if(a <= l && r <= b) return dat[k];
        T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return f(vl, vr);
    }
    
    T query(int a, int b){
        return query(a, b, 0, 0, n);
    }
};


signed main(){

    int n, q; cin >> n >> q;
    int ti = 2147483647;
    vector<int> v(n, ti);
    auto f = [](int a, int b){return min(a, b);};
    // 関数, 単位元, 元の配列の順に宣言
    SegmentTree<int> sg(f, ti, v);
    
    for(int i = 0; i < q; i++){
        int c, x, y; cin >> c >> x >> y;
        if(c) cout << sg.query(x, y + 1) << endl;
        else sg.update(x, y);
    }

    return 0;
}




Measured memory_bytes: 5752
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#define ll long long
#define rep(i,n) for(int i=0;i<(int) (n);i++)
using namespace std;
int main(){
  double n,anser;
  cin>>n;
  priority_queue<double> que;
  vector<double>v(n);
  rep(i,n){
    cin>>v[i];
    v[i]*=-1;
    que.push(v[i]);
  }

  anser=que.top();
  anser*=-1;
  que.pop();

  for(int i=0;i<n-1;i++){
    double a=que.top();
    a*=-1;
    anser=(anser+a)/2;
    que.pop();
  }

  cout<<anser;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;
#define pow10(n) int(1e##n + n)

void solve()
{
    int N, M;
    cin >> N >> M;
    map<int, int> mp;
    REP0 (i, M)
    {
        int a, b;
        cin >> a >> b;
        mp[a]++;
        mp[b]++;
    }

    for (auto p : mp)
    {
        if (p.second%2==1)
        {
            std::cout << "NO" << endl;
            return;
        }
    }
    std::cout << "YES" << endl;

}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 4352
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

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

	Int N;
	cin >> N;

	vector<Int> a(N);
	for (Int i = 0; i < N; i++) {
		cin >> a[i];
	}

	Int ans = 0;
	Int temp = 1;
	for (Int i = 0; i < N; i++) {
		if (a[i]==temp) {
			temp++;
		}
		else {
			ans++;
		}
	}

	if (temp==1) {
		cout << -1 << "\n";
		return 0;
	}
	cout << ans << "\n";
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define int long long
using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,d;
    cin>>n>>d;
    int s[n][d];
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < d; ++j) {
            cin>>s[i][j];
        }
    }


    int ans=0;

    for(int i=0;i<n;i++)
    {
        for (int k = i+1; k < n; ++k) {
            long double z = 0;
            for (int j = 0; j < d; j++) {
                z += pow(s[i][j]-s[k][j],2);
            }
            if(ceil(sqrt(z))==floor(sqrt(z)))
            {
                ans++;
            }
        }
    }

    cout<<ans;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    res = 0
    for _ in range(n):
        x, u = input().rstrip().split()
        x = float(x)
        if u=='JPY':
            res += x
        else:
            res += x*380000
    print(res)

if __name__ == '__main__':
    main()

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int H,W; cin >> H >> W;
    vector<vector<char>> P(H+2, vector<char>(W+2, '#'));
    REP(i,H){
        string s; cin >> s;
        REP(j,W){
            P[i+1][j+1] = s[j];
        }
    }
    REP(i,H+2){
        REP(j,W+2){
            cout << P[i][j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

const int maxn = 100 + 100;

int n,m;
int a[maxn],b[maxn],c[maxn],d[maxn];

int abs(int x, int y) {
    if (x > y) {
        return x - y;
    }

    return y - x;
}

int getDistance(int x1, int x2, int y1, int y2) {
    return abs(x1,x2) + abs(y1,y2);
}

int main() {

    // freopen("test.txt", "r", stdin);

    scanf("%d%d",&n,&m);

    for(int i=0; i<n; i++) {
        scanf("%d%d",&a[i],&b[i]);
    }

    for(int i=0; i<m; i++) {
        scanf("%d%d",&c[i],&d[i]);
    }

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

        for(int j=1; j<m; j++) {
            if (getDistance(a[i],c[r],b[i],d[r]) > getDistance(a[i],c[j],b[i],d[j])) {
                r = j;
            }
        }

        printf("%d\n", r+1);
    }

    return 0;
}



Measured memory_bytes: 256
fun main(arr: Array<String>) {
    val ans = isValid(readLine()!!)
    println(if(ans) "Yes" else "No")
}

fun isValid(txt:String):Boolean {
    val indexC = txt.indexOfFirst { it == 'C' }
    val indexF = txt.indexOfLast { it == 'F' }
    if(indexC >= 0 && indexF >= 0) {
        return indexC < indexF
    }
    return false
}


Measured memory_bytes: 34376
#include <bits/stdc++.h>
using namespace std;
int n,k;string s;
int main()
{
    cin>>k;
    cin>>s;
    n=s.length();
    if(n<=k)
    cout<<s;
    else
    {
        for(int i=0;i<k;i++)
        cout<<s[i];
        cout<<"...";
    }
    
}

Measured memory_bytes: 3620
#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>

using namespace std;


void output(vector<int> & V);

int main()
{
    vector<int> V;

    int n;
    cin >> n;

    int a;
    while (n--)
    {
        cin >> a;
        V.push_back(a);
    }


    int q, k;
    cin >> q;

    while (q--)
    {
        cin >> k;
        //法1
        //cout << any_of(V.begin(), V.end(), bind1st(equal_to<int>(), k));

        //法2（超时）
        // if (find(V.begin(), V.end(), k) != V.end())
        //     cout << true;
        // else
        //     cout << false;



        //法3（超时）
        // bool result = false;
        // vector<int>::iterator it = V.begin();
        // while (it != V.end())
        // {
        //     if (*it == k)
        //     {
        //         result = true;  
        //         break;              
        //     }
        //     it++;
        // }
        // if (result)
        //     cout << true;
        // else 
        //     cout << false;

        //法4
        cout << binary_search(V.begin(), V.end(), k);

        cout << endl;

    }

}        



Measured memory_bytes: 3504
#include<iostream>
using namespace std;
int main(){
  char a,b,c;
  int ans=0;
  cin>>a>>b>>c;
  if(a=='a'||b=='a'||c=='a'){
  if(a=='b'||b=='b'||c=='b'){
  if(a=='c'||b=='c'||c=='c')ans=1;
  }}
  if(ans)cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 256
s=input()
a=int(s[0])
b=int(s[1])
c=int(s[2])
d=int(s[3])
if a+b+c+d==7:
    print(a,"+",b,"+",c,"+",d,"=",7,sep="")
elif a+b+c-d==7:
    print(a,"+",b,"+",c,"-",d,"=",7,sep="")
elif a+b-c+d==7:
    print(a,"+",b,"-",c,"+",d,"=",7,sep="")
elif a+b-c-d==7:
    print(a,"+",b,"-",c,"-",d,"=",7,sep="")
elif a-b+c+d==7:
    print(a,"-",b,"+",c,"+",d,"=",7,sep="")
elif a-b+c-d==7:
    print(a,"-",b,"+",c,"-",d,"=",7,sep="")
elif a-b-c+d==7:
    print(a,"-",b,"-",c,"+",d,"=",7,sep="")
else:
    print(a,"-",b,"-",c,"-",d,"=",7,sep="")

Measured memory_bytes: 3064
#include <iostream>
#include <climits>
#include <vector>
#include <queue>
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF INT_MAX

using namespace std;

void bfs(int s, int n, int *color, int *d, vector<vector<int>> Adj){
    queue<int> Q;
    for (int u = s+1; u <= n; u++){
        color[u] = WHITE;
        d[u] = INF;
    }
    color[s] = GRAY;
    d[s] = 0;
    Q.push(s);
    while (Q.size() != 0){
        int zero = 0;
        int u = Q.front();
        Q.pop();
        for (int w = 1; w < Adj[u].size(); w++){
            int v = Adj[u][w];
            if (v == 0){
                break;
            }else if (color[v] == WHITE){
                color[v] = GRAY;
                d[v] = d[u] + 1;
                Q.push(v);
                zero++;
            }
        }
        color[u] = BLACK;
    }
}

int main(int argc, char* argv[]) {
    int n, u, k, v;
    cin >> n;
    n++;
    int color[n], d[n], f[n];
    vector<vector<int>> Adj(n, vector<int>(n, 0));

    for (int i = 1; i < n; i++){
        cin >> u >> k;
        for (int j = 1; j <= k; j++){
            cin >> v;
            Adj[i][j] = v;
        }
    }

    bfs(1, n, color, d, Adj);

    for (int i = 1; i < n; i++){
        if (d[i] == INF)
            printf("%d -1\n", i);
        else
            printf("%d %d\n", i, d[i]);
    }
    return 0;
}



Measured memory_bytes: 3272
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll

const int md = 1000000007;
const int INF = 1<<30;



int main(){
    string s; cin >> s;
    int k = s.size();

    int cnt = 0;
    rep(i,k){
        if(s[i] == 'o') cnt++;
    }

    if(cnt + (15-k) >= 8 ) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

int
main(void){  
  ios_base::sync_with_stdio(false);

  int n, m, a, b;
  cin >> n >> a >> b;


  cout << n * a / 2 << endl;
  
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _20190129_AOJ
{
    class ALDS1_12A
    {
        static void Main(string[] args)
        {
            for (;;)
            {
                string line = Console.ReadLine();
                if (string.IsNullOrEmpty(line))
                {
                    break;
                }

                int n = int.Parse(line);
                int[,] matrix = new int[n, n];
                HashSet<HashSet<int>> trees = new HashSet<HashSet<int>>();
                List <Vertex> vertices = new List<Vertex>();
                for(int i=0;i<n;i++)
                {
                    HashSet<int> th = new HashSet<int>();
                    th.Add(i);
                    trees.Add(th);

                    int[] iarr = ReadIntArr();
                    for(int j=0;j<iarr.Length;j++)
                    {
                        matrix[i, j] = iarr[j];
                        if (j > i && iarr[j] >= 0)
                        {
                            vertices.Add(new Vertex(i, j, iarr[j]));
                        }
                    }
                }

                int sum = 0;
                foreach(var v in vertices.OrderBy(x => x.W))
                {
                    HashSet<int> t1 = trees.First(x => x.Contains(v.P1));
                    HashSet<int> t2 = trees.First(x => x.Contains(v.P2));
                    if(t1 == t2)
                    {
                        // do nothing
                    }
                    else
                    {
                        t1.UnionWith(t2);
                        trees.Remove(t2);
                        sum += v.W;
                    }
                }

                Console.WriteLine(sum);
            }
        }

        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static int[] ReadIntArr(char dlm = ' ') { return Console.ReadLine().Trim().Split(dlm).Select(x => int.Parse(x)).ToArray(); }
        static double[] ReadDoubleArr(char dlm = ' ') { return Console.ReadLine().Split(dlm).Select(x => double.Parse(x)).ToArray(); }
        static string[] ReadStringArr(char dlm = ' ') { return Console.ReadLine().Split(dlm).ToArray(); }
    }

    class Vertex
    {
        public int P1 { get; set; }
        public int P2 { get; set; }
        public int W { get; set; }
        public Vertex(int _p1, int _p2, int _w)
        {
            P1 = _p1;
            P2 = _p2;
            W = _w;
        }
    }
}



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

uint_fast32_t N, M, a[101010], A;

constexpr uint_fast32_t z = static_cast<uint_fast32_t>('0'), n = static_cast<uint_fast32_t>('9');
template<class T>
void uread(T& x){
    do{
        x = static_cast<T>(fgetc(stdin));
    }while(z > x || x > n);
    x -= z;
    T c = static_cast<T>(fgetc(stdin));
    while(z <= c && c <= n){
        x = x * 10 + c - z;
        c = static_cast<T>(fgetc(stdin));
    }
}

int main(){
    scanf("%u%u", &N, &M);
    for(int i = 1; i <= N; ++i){
        uread(a[i]);
        a[i] += a[i - 1];
        a[i] %= M;
    }
    sort(a, a + N + 1);
    for(int i = 1, j = 1; i <= N; ++i){
        if(a[i] != a[i - 1])j = 0;
        A += j++;
    }
    cout << A << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
  int t,i,count1=0,count2=0,count3=0,count4=0;
  string s;
  cin>>t;
  for(i=0;i<t;i++)
  {
    cin>>s;
    if(s=="AC")
    {
      count1++;
    }else if(s=="WA")
    {
      count2++;
    }else if(s=="TLE")
    {
      count3++;
    }else if(s=="RE")
    {
      count4++;
    }
  }
  cout<<"AC x "<<count1<<endl;
  cout<<"WA x "<<count2<<endl;
  cout<<"TLE x "<<count3<<endl;
  cout<<"RE x "<<count4<<endl;
  return 0;
}

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

int main() {
    int n; cin >> n;
    long long A[n];
    for (int i = 0; i < n; i++) cin >> A[i];
    long long S[n+1] = {};
    for (int i = 0; i < n; i++) S[i+1] = S[i] + A[i];
    map<long long, long long> nums;
    for (int i = 0; i < n + 1; i++) nums[S[i]]++;

    long long ans = 0;
    for (auto it : nums) {
        long long num = it.second;
        ans += num * (num - 1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

int main() {
  int n;
  cin >> n;
  int minNumber = 10001, maxNumber = 0;
  REP(i, n) {
    int a;
    cin >> a;
    minNumber = min(minNumber, a);
    maxNumber = max(maxNumber, a);
  }
  cout << maxNumber - minNumber << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;

int main() {
	int n;
	cin >> n;
	vector<int> a(100000);
	for (int x = 1; x <= 100; x++) {
		for (int y = 1; y <= 100; y++) {
			for (int z = 1; z <= 100; z++) {
				a[x * x + y * y + z * z + x * y + y * z + z * x]++;
			}
		}
	}
	rep(i, n) {
		cout << a[i + 1] << endl;
	}
}


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

#ifndef __TOPCYBERFLOWER
#define debug(...) 0
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif

#define TYPEMAX(type)   numeric_limits<type>::max()
#define TYPEMIN(type)   numeric_limits<type>::min()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
ll MD=1e9+7;
int main(void){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    ll n,k; cin>>n>>k;
    ll res=0;
    for(ll i=k;i<=n+1;i++){
        res=(res+n*i-i*i+i+1)%MD;
    }
    cout<<res;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#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 M,x;
cin>>M;
x=48-M;
cout<<x<<endl;
  return 0;
}

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

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

void reset() {
    for (int i=0; i<102; ++i) {
        for (int j=0; j<102; ++j) {
            kaju[i][j] = '.';
        }
    }
}

void clr(int y, int x) {
    char t = kaju[y][x];
    kaju[y][x] = '.';
    for (int i=0; i<4; ++i) {
        if (kaju[y + dy[i]][x + dx[i]] == t) {
            clr(y + dy[i], x + dx[i]);
        }
    }
}

int main() {
    int H, W;
    while (cin >> H >> W, H) {
        reset();
        for (int i=0; i<H; ++i) {
            for (int j=0; j<W; ++j) {
                cin >> kaju[i][j];
            }
        }
        int cnt = 0;
        for (int i=0; i<H; ++i) {
            for (int j=0; j<W; ++j) {
                if (kaju[i][j] != '.') {
                    cnt ++;
                    clr(i, j);
                }
            }
        }
        cout << cnt << endl;
    }
    return 0;
}

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

using namespace std;

const int N = 1e5+20; 

vector<int> ve[N];
queue<int> q;
int in[N],f[N];

int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int a,b;
		cin>>a>>b;
		in[b]++;
		ve[a].push_back(b);
	}
	for(int i=1;i<=n;i++)
	{
		if(in[i]==0)
		{
			q.push(i);
		}
	}
	
	while(q.size()!=0)
	{
		int now=q.front();
		q.pop();
		int cd=ve[now].size();
		for(int i=0;i<cd;i++)
		{
			int next=ve[now][i];
			f[ve[now][i]]=max(f[next],f[now]+1);
			in[next]--;
			if(in[next]==0) q.push(next);
		}
	}
	int ans=0;
	for(int i = 1;i<=n;++i) ans = max(ans,f[i]);
	cout<<ans;
}



Measured memory_bytes: 6528
#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;
	string s;
	cin >> n >> s;
	int ans = 0;
	rep(i,n)
	{
		vector<bool> alph1(26,false),alph2(26,false);
		for(int j=0;j<i;j++)
		{
			alph1[s[j]-'a']=true;
		}
		for(int j=i;j<n;j++)
		{
			alph2[s[j]-'a']=true;
		}
		int c = 0;
		rep(j,26)
		{
			if(alph2[j]&&alph1[j])c++;
		}
		ans = max(ans,c);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int AB, CD;
		AB = A*B;
		CD = C*D;
		if(AB > CD){
			System.out.print(AB);
		}
		else if(AB < CD){
			System.out.print(CD);			
		}
		else{System.out.print(AB);
		}

	}

}


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

int main() {
  int A, B;
  scanf("%d%d", &A, &B);

  int sum_power_sorce = 1;
  int num_power_strip = 0;
  while (sum_power_sorce < B) {
    num_power_strip++;
    sum_power_sorce -= 1;
    sum_power_sorce += A;
  }

  printf("%d", num_power_strip);
  return 0;
}

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

using namespace std;

int main () {
    int a;
    cin >> a;
    int cont = 0, x;
    for (int i = 0; i < a; i++){
        cin >> x;
        while (x % 2 == 0){
            cont ++;
            x/=2;
        }
    }

    cout << cont<< endl;
    
    
    return 0;
}

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

int main(){
    int x,a;
    cin>>x>>a;
    if(x<a){
        cout<<0<<endl;
    }else{
        cout<<10<<endl;
    }
    return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef map<int,int> mint;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef deque<pair<ll,ll>> dep;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=1e9+1000;
const int mod=1e9+7;
ll infi=1e18+100;


int n;

int main(){
	cin>>n;
	int m=0;
	for(int i=0;i*i<=n;i++){
		m=i*i;
	}
	cout<<m<<endl;


	  return 0;
  }

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

using namespace std;
typedef long long ll;
int main(){

    int x, y;
    cin >> x >> y;
    int ans = INT_MAX;
    if(x < y){
        ans = abs(y-x);
    }

    int tmp = 0;
    if(abs(x) >= abs(y)){
        if(x > 0){
            tmp++;
            tmp += abs(abs(x) - abs(y));
            if(y > 0) tmp++;
        }
        else{
            tmp += abs(abs(x) - abs(y));
            if(y > 0) tmp++;
        }
    }
    else{
        if(x < 0){
            tmp++;
            tmp += abs(abs(x) - abs(y));
            if(y < 0) tmp++;
        }
        else{
            tmp = abs(abs(x)-abs(y));
            if(y < 0) tmp++;
        }
    }

    ans = min(ans, tmp);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import collections
from math import factorial

N = int(input())
S = [0]*N
for i in range(N):
    s = list(str(input()))
    s.sort()
    S[i] = "".join(s)

c = collections.Counter(S)
cnt = 0
r = 2

for n in c.values():
    if n >= 2:
        a = factorial(n)
        b = factorial(r)*factorial(n - r)
        cnt += a/b
print(int(cnt))


Measured memory_bytes: 68172
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


n = input()
m = len(n)
n = n[::-1] + '0'

dp = [[inf]*2 for _ in range(m+1)]
dp[0][0] = 0
for i in range(m):
    x = int(n[i])
    for j in range(2):
        x += j
        for a in range(10):
            b = a-x
            if a >= x:
                dp[i+1][0] = min(dp[i+1][0],dp[i][j]+a+b)
            else:
                dp[i+1][1] = min(dp[i+1][1],dp[i][j]+a+10+b)
ans = min(dp[-1][0],dp[-1][1]+1)
print(ans)

Measured memory_bytes: 202364
#include <stdio.h>

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



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define SORT(a) sort(a.begin(),a.end())
 
int main() {
	
	//string ans="";
	//vector<int> c(30,0);
	int n;
	
	cin >> n;
	
	for(int i=n/2-1;i<=n;i++){
		
		if((int)(i*1.08)==n){
			cout << i << endl;
			return 0;
		}
	}

	
    cout << ":(" << endl;
    
    return 0;

}

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

count = 0
for _ in range(N):
    An = list(map(int, input().split()))
    if sum([An[m] * B[m] for m in range(M)]) + C > 0:
        count += 1

print(count)


Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
	int n,b,f,r,v,i,j,k,l;
	int a[5][4][11]={0};
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		a[b][f][r]+=v;
	}
	
	for(j=1;j<=4;j++){
		for(k=1;k<=3;k++){
			for(l=1;l<=10;l++){
				if(a[j][k][l]!=0){
				printf(" %d",a[j][k][l]);
				}else{
					printf(" 0");
				}	
			}
			printf("\n");
		}
		if(j!=4){
			printf("####################\n");
		}
	}
return 0;
}


Measured memory_bytes: 2112
W, H, N = map(int, input().split())
x,y = 0,0
for i in range(N):
    xi, yi, a = map(int, input().split())
    if a == 1:
        x = max(x, xi)
    elif a == 2:
        W = min(W, xi)
    elif a == 3:
        y = max(y, yi)
    elif a == 4:
        H = min(H, yi)

print(0 if x >= W or y >= H else (W - x) * (H - y))


Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: int, B: int, C: int):
    if A == B and B == C :
        return NO
    isPoor = A==B or B==C or A==C
    return YES if isPoor else NO


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    print(solve(A, B, C))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
n=input()
N=int(n)

f=True
c=int(n[0])
if len(n)==1:
	x=N
else:
	for i in range(1, len(n)):
		if int(n[i]) != 9:
			f=False
	
	if f:
		x=c+9*(len(n)-1)
	else:
		x=c+9*(len(n)-1)-1

print(x)

Measured memory_bytes: 3060
#define rep(i,n) REP(i,0,n)
#define REP(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;

// const ll MAXN = (ll)1e3+10;
const ll DIV = (ll)1e9+7;
// ll dp[MAXN][MAXN];

int main(void) {
   ll N;
   cin>>N;
   ll A[N];
   rep(i,N) {
      ll p;
      cin>>p;
      A[i] = p-(i+1);
   }
   ll now = 0;
   ll ans = 0;
   rep(i,N) {
      if (A[i]==0) now++;
      if (A[i]!=0 || i==N-1) {
         ans += (now+1)/2;
         now = 0;
      }
   }
   cout<<ans<<endl;


   return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

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

    return 0;
}

Measured memory_bytes: 3628
/**
 * Created by hiramekun at 08:21 on 2019-11-24.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll h, w, k;
    cin >> h >> w >> k;

    vector<string> s(h);
    rep(i, h) cin >> s[i];

    vector<vector<ll>> ans(h, vector<ll>(w));
    vector<ll> s_idx;
    rep(i, k) s_idx.emplace_back(i + 1);

    auto dfs = [&](auto &&f, ll l, ll r, ll u, ll d, ll num) {
        if (l < 0 || w < r || u < 0 || h < d) return;
        if (r <= l || d <= u) return;
        ll prev_i = -1, prev_j = -1;
        for (ll i = u; i < d; ++i) {
            for (ll j = l; j < r; ++j) {
                if (s[i][j] != '#') continue;
                if (prev_i == -1) {
                    prev_i = i, prev_j = j;
                    continue;
                }

                ll next = s_idx.back();
                s_idx.pop_back();
                if (i != prev_i) { // 縦に分ける
                    f(f, l, r, u, i, num);
                    f(f, l, r, i, d, next);
                    return;
                }
                if (j != prev_j) { // 横に分ける
                    f(f, l, j, u, d, num);
                    f(f, j, r, u, d, next);
                    return;
                }
            }
        }
        for (ll i = u; i < d; ++i) 
            for (ll j = l; j < r; ++j) {
                ans[i][j] = num;
        }
    };
    ll num = s_idx.back();
    s_idx.pop_back();
    dfs(dfs, 0, w, 0, h, num);
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 2420
#include <iostream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int c = a + b;
    if (c % 2 == 0) {
        cout << c / 2 << endl;
    } else {
        cout << c / 2 + 1 << endl;
    }
    return 0;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  
  int ans;
  if(a>=6 && a<=12) {
    ans = b/2;
  }else if(a<=5) {
    ans = 0;
  }else{
    ans = b;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    ll x, y, z;
    ll k; 
    ll a[1005], b[1005], c[1005];
    cin>>x>>y>>z>>k;
    ll i;
    FOR0(i, x) cin>>a[i];
    FOR0(i, y) cin>>b[i];
    FOR0(i, z) cin>>c[i];
    sort(a, a+x, greater<ll>());
    sort(b, b+y, greater<ll>());
    sort(c, c+z, greater<ll>());
    ll mul = x*y*z;
    ll j, l;
    vector<ll> sums;
    FOR0(i, x) FOR0(j, y) FOR0(l, z)
    {
        if((i+1)*(j+1)*(l+1)<=k)
            sums.push_back(a[i]+b[j]+c[l]);
        else break;
    }
    sort(sums.begin(), sums.end(), greater<ll>());
    FOR0(i, k)
    {
        cout<<sums[i]<<endl;
    }
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

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

int main() {
    ll n, k;
    cin >> n >> k;
    vector<double> p(n);
    rep(i, n) {
        double pi;
        cin >> pi;
        p[i] = (1.0 + pi) / 2.0;
    }
    double sum = 0.0, ans = 0.0;
    for (int i = 0; i < n; i++) {
        sum += p[i];
        if (i >= k) {
            sum -= p[i - k];
        }
        ans = max(ans, sum);
    }
    printf("%.6f\n", ans);
}

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

string w[110];
int main(){
  int N;
  cin>>N;
  rep(i,N)cin>>w[i];
  bool ans=true;
  rep(i,N-1){
    if(w[i][w[i].length()-1] != w[i+1][0]){
      ans=false;
    }
  }
  rep(i,N){
    rep(j,i){
      if(w[i]==w[j]){
        ans=false;
      }
    }
  }
  if(ans){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


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

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

  long long n, ans=0;
  cin >> n;
  vector<ll> a(n), b(n), c(n-1);
  for(int i=0;i<n;i++){
    cin >> a[i];
    a[i]--;
  }
  for(int i=0;i<n;i++){
    cin >> b[i];
    ans+=b[i];
  }
  for(int i=0;i<n-1;i++){
    cin >> c[i];
  }
  for(int i=0;i<n-1;i++){
    if(a[i]+1 == a[i+1]){
      ans+=c[a[i]];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256