akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 8e18;
//    const int mod = 2600000069;
    const int p = 10;
//    const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 8e18;
//    const int mod = 2600000069;
    const int p = 179;
//    const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")

const int MAXN = (int)2e5 + 100;

int f[MAXN];

const int mod = 1e9 + 7;

int powmod(int a, int p) {
    if (p == 0) return 1;
    if (p == 1) return a;
    int k = powmod(a, p / 2);
    if (p & 1) return (((k * k) % mod) * a) % mod;
    return (k * k) % mod;
}

int rev(int a) {
    return powmod(a, mod - 2);
}

int c(int n, int k) {
    int ans = f[n];
    ans = (ans * rev(f[n - k])) % mod;
    ans = (ans * rev(f[k])) % mod;
    return ans;
}

int sum(int l, int r) {
    return r * (r + 1) / 2 - (l - 1) * l / 2;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    f[0] = 1;
    for (int i = 1; i < MAXN; i++) f[i] = (f[i - 1] * i) % mod;
    int n, k;
    cin >> n >> k;
    int ans = 0;
    n++;
    for (int i = k; i <= n; i++) {
        ans += sum(n - i, n - 1) - sum(0, i - 1) + 1;
        ans %= mod;
        // cout << n - i - 1 << " " << n - 1 << " " << 0 << " " << i - 1 << "\n";
    }
    cout << ans;

}
/*

*/


Measured memory_bytes: 5204
#include <stdio.h>
int main(void){
    int N, T;
    scanf("%d %d", &N, &T);
    int c;
    int t;
    int min = 1001;
    for (int i = 0; i < N; i++){
        scanf("%d", &c);
        scanf("%d", &t);
        if ((t <= T) && (min > c)) {
            min = c;
        }
    }
    if(min == 1001) printf("%s\n", "TLE");
    else printf("%d\n", min);
    return 0; 
}

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

using namespace std;
typedef long long ll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repr(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<(int)(n);i++)
#define INF 999999999
#define MAX_V 100010
#define MAX_E 2019

    /*Solve*/

int main(){
    string s;
    ll ans;
    cin >> s;
    rep(i,s.size()){
        if(s[i]=='1'){
            s[i]='9';
        }else
            s[i]='1';
    }
    ans=stoll(s);
    cout << ans;
}

Measured memory_bytes: 256
#include<algorithm>
#include<chrono>
#include<climits>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
using namespace std;
 
struct Debug{
	int cnt = 0;
	bool on = false;
	char debug[10] = "debug";
	template<class T>
	Debug & operator<<(const T & v) {
		if(on && cnt++ == 0) cerr << "debug: ";
		if(on) cerr << v << ' ';
		return *this;
	}
	Debug & operator<<(ostream&(*pManip)(ostream&)) {
		if(on) cerr << (*pManip);
		cnt = 0;
		return *this;
	}
} debug;
#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) {if(debug.on){for(auto x : v) debug << x; debug << endl;}}
#define printn(v, n) {if(debug.on){for(int _i = 0; _i < n; _i++) debug << *(v + _i); debug << endl;}}
 

typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
 
const int MAXN = 2e5 + 20;


int main(int argc, char * argv[]) {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(argc > 1 && !strcmp(argv[1], debug.debug)) debug.on = true;

    int n;
    cin >> n;
    string s;
    cin >> s;

    int tot, a[MAXN] = {};
    for(int i = 0; i < n; i++) {
    	a[i] = (!i ? 0 : a[i - 1]) + (s[i] == '#');
    }
    tot = a[n - 1];
    int res = min(tot, n - tot);
    for(int i = 1; i < n; i++)
    	res = min(res, a[i - 1] + n - i - (tot - a[i - 1]));
    cout << res << endl;

    return 0;
}






















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

using pii = pair<int, int>;
using ll = long long;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<pii> v(N);
    for(int i = 0; i < N; ++i) {
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(), v.end());
    ll sum = 0;
    for(int i = 0; i < N; ++i) {
        if(sum + v[i].second >= K) {
            cout << v[i].first << endl;
            return 0;
        }
        sum += v[i].second;
    }
}


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

using namespace std;

const int mod = 1e9 + 7;

int n, a[21][21], dp[1 << 21];

int main(){
      cin >> n;

      for(int i = 0; i < n; i ++)
            for(int j = 0; j < n; j ++)
                  cin >> a[i][j];

      dp[0] = 1;

      for(int mask = 0; mask < (1 << n); mask ++){
            int bit = __builtin_popcount(mask);
            for(int i = 0; i < n; i ++){
                  if(a[bit][i] && !(mask & (1 << i))){
                        int msk = mask + (1 << i);
                        dp[msk] = (dp[msk] + dp[mask]) % mod;
                  }
            }
      }

      cout << dp[(1 << n) - 1];
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i = l; i < (n); i++)
using namespace std;
using ll = long long;
int main() {
  int a,b;
  scanf("%d %d",&a,&b);
  if(a < b) swap(a,b);
  rep(i,0,a) printf("%d",b);
  printf("\n");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#define pb push_back
#define mp make_pair
using namespace std;

int n, a, b;
int mx, mn;

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

    cin >> n >> a >> b;

    mn = min(a, b);
    mx = max(0, (a + b) - n);

    cout << mn << " " << mx << endl;

    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const ll INF = 1LL << 61;
const int MAX_N = 112345;
ll a[MAX_N];
ll b[MAX_N];
ll odd[MAX_N];

int check(int N, ll X, int K) {
  if (K*2 > N) return 0;
  ll d = abs(X - a[N-K]);
  int pos1 = distance(a, lower_bound(a, a+N, X-d));
  int pos2 = N-K;
  return pos2 - pos1 >= K-1;
}

ll query(int N, ll X) {
  // for (int K = 1; K < N; K++) {
    // cout << N << " " << X << " " << K << " -> " << check(N, X, K) << endl;
  // }
  int hi = N/2+1;
  int lo = 1;
  while ((hi - lo) > 1) {
    int K = (hi + lo) / 2;
    if (check(N, X, K) > 0) lo = K;
    else hi = K;
  }
  int K = lo;

  // cout << "X=" << X << " " << K << endl;

  ll ans = b[N] - b[N-K];
  ans += odd[N - 2*K];
  return ans;
}


int main2() {
  int N = nextInt();
  int Q = nextInt();
  
  // Nが奇数のときは -INF を先頭に追加し、常にNが偶数とする
  if (N % 2 == 1) {
    a[0] = -INF;
    REP(i, N) a[i+1] = nextInt();
    N++;
  } else {
    REP(i, N) a[i] = nextInt();
  }
  b[0] = 0;
  REP(i, N) b[i+1] = b[i] + a[i];
  odd[0] = 0;
  REP(i, N) {
    if (i % 2 == 1) odd[i+1] = odd[i] + a[i];
    else            odd[i+1] = odd[i] + 0;
  }

  // pv(a, a+N);
  // pv(odd, odd + N);
  // for (int X = 1; X <= a[N-1]; X++)
    // query(N, X);

  REP(qqq, Q) {
    ll X = nextInt();
    ll ans = query(N, X);
    printf("%lld\n", ans);
  }
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        var N = sc.ReadInt();
        var i = sc.ReadInt();
        var ans = N - i + 1;
        Console.WriteLine(ans);
    }

    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


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

using namespace std;
#define int long long
/*                      */    //#undef int
#define INF 1000000009ll
#define INFL 1000000000000000018ll
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define mk make_pair
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef priority_queue<pair<int, PA> , vector<pair<int, PA> >, greater<pair<int, PA> > >PQG;

int a, b;

signed main()
{
    cin >> a >> b;
    int ans = 0;
    for(int i = a; i <= b; i++){
        stringstream ss;
        ss << i;
        string s = ss.str();
        int len = s.size();
        bool flag = true;
        for(int j = 0; j < len; j++){
            if(s[j] != s[len - 1 - j]){
                flag = false;
            }
        }
        if(flag){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}
/*



*/


Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>

#define f			first
#define sz(a)       ((int)(a).size())
#define s			second
#define all(v)		v.begin(),v.end()
#define pii 		pair<int,int>
#define vpii 		vector<pii>
#define eb			emplace_back
#define pb			push_back
#define fo(i,n)		for(int i=0;i<n;i++)
#define Fo(i,k,n)	for(int i=k;i<n;i++)
#define vi			vector<int>

using namespace std;
using ll  = long long;
using lld = long double;

const int oo = 0x3f3f3f3f;
const ll MOD = 1000000007;



signed main(){

#ifndef ONLINE_JUDGE
	//freopen("in.txt" , "r" , stdin);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);

    string a , b;
    cin >> a >> b;
    int n = a.size();
    int m = b.size();
    int ans = oo;
    for(int i = 0 ; i + m <= n  ; i++){
        int cnt = 0;
        for(int j = 0 ; j < m ; j++)
            if(a[i + j] != b[j]) cnt++;
        ans = min(ans , cnt);
    }
    cout << ans << '\n';


    return 0;

}



Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define Maxn 2000010
using namespace std;
int a[Maxn], H;
void extract();
void insert(int t);
void HeapIncreaseKey(int now);
void maxHeapify(int t);
int main(){
	int t;
	string com;
	while(1){
		cin >> com;
		if(com == "insert"){
			cin >> t;
			insert(t);
		}
		else if(com == "extract") extract();
		else break;
		
	}
}
void insert(int t){
	H++;
	a[H] = t;
	HeapIncreaseKey(H);
}
void HeapIncreaseKey(int now){
	int p = now / 2;
	while(p > 0 && a[p] < a[now]){
		swap(a[p], a[now]);
		now = p;
		p /= 2;
	}
}
void extract(){
	printf("%d\n", a[1]);
	a[1] = a[H--];
	maxHeapify(1);
}
void maxHeapify(int t){
	int l = t * 2, r = t * 2 + 1, largest = t;
	if(l <= H && a[l] > a[largest]) largest = l;
	if(r <= H && a[r] > a[largest]) largest = r;
	if(largest != t){
		swap(a[t], a[largest]);
		maxHeapify(largest);
	}
}


Measured memory_bytes: 7104
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int a,b;
int main(){
	ios::sync_with_stdio(0);
	cin>>a>>b;
	cout<<a*b;
	re 0;
}

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

int main(){

    string s;
    cin >> s;

    int a = s[0]-'0', b = s[1]-'0', c = s[2]-'0', d = s[3]-'0';

    if(a+b+c+d == 7)cout << a <<'+'<< b <<'+'<< c <<'+'<< d<< "=7" << endl;
    else if(a+b+c-d == 7)cout << a <<'+'<< b <<'+'<< c <<'-'<< d<< "=7" << endl;
    else if(a+b-c-d == 7)cout << a <<'+'<< b <<'-'<< c <<'-'<< d<< "=7" << endl;
    else if(a-b-c-d == 7)cout << a <<'-'<< b <<'-'<< c <<'-'<< d<< "=7" << endl;
    else if(a-b+c+d == 7)cout << a <<'-'<< b <<'+'<< c <<'+'<< d<< "=7" << endl;
    else if(a-b+c-d == 7)cout << a <<'-'<< b <<'+'<< c <<'-'<< d<< "=7" << endl;
    else if(a-b-c+d == 7)cout << a <<'-'<< b <<'-'<< c <<'+'<< d<< "=7" << endl;
    else if(a+b-c+d == 7)cout << a <<'+'<< b <<'-'<< c <<'+'<< d<< "=7" << endl;

}

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

int main()
{
	int x; cin >> x;
	if(x< 1200)
	{
		cout << "ABC" << endl;
	}
	else if(x< 2800)
	{
		cout << "ARC" << endl;
	}
	else cout << "AGC" << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n,m;
    cin>>n>>m;
    Vec a(n);
    rep(i,n)cin>>a[i];
    ll ans=0;
    Vec s(n+1);
    rep(i,n){
        s[i+1] = s[i]+a[i];
    }
    Vec x(n+1);
    rep(i,n+1){
        x[i] = s[i]%m;
    }
    map<ll,ll>mp;
    rep(i,n+1){
        ans+=mp[x[i]];
        mp[x[i]]++;
    }
    cout<<ans<<endl;
    return  0;
}


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


int main(){
    int N;
    cin >> N;
    vector<int> pnt(N);
    rep(i,N) cin >> pnt.at(i);
    int min_pnt = *min_element(pnt.begin(), pnt.end());
    int max_pnt = *max_element(pnt.begin(), pnt.end());
    int sum_min = 1000000;
    
    for(int j=min_pnt;j<=max_pnt;j++){
        int sum = 0;
        rep(i,N){
            sum += (pnt.at(i)-j)*(pnt.at(i)-j);
        }
        sum_min = min(sum_min,sum);
    }
   
    cout << sum_min << endl;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int,input().split()))
l.sort(reverse=True)
l.append(0)
c = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    z = l[i]-l[j]
    if l[j+1] <= z:
      break
    else:
      a = j+1
      b = n+1
      while a+1 < b:
        m = (a+b)//2
        if l[m] > z:
          a = m
        else:
          b = m
      c += a-j
print(c)        
    

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    ll n, k; cin >> n >> k;
    ll t = n / k;
    cout << min(abs(n - t * k), abs(n - (t + 1) * k)) << endl;
    return 0;
}


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

using namespace std;

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

    vector<int> town(N + 1);
    vector<int> hero(N);

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

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

    unsigned long long count = 0;

    for (int i = 0; i < N; ++i) {
        if (town[i] > hero[i]) {
            count += hero[i];
            town[i] -= hero[i];
            hero[i] = 0;
        } else {
            count += town[i];
            hero[i] -= town[i];
            town[i] = 0;
        }

        if (town[i + 1] > hero[i]) {
            count += hero[i];
            town[i + 1] -= hero[i];
            hero[i] = 0;
        } else {
            count += town[i + 1];
            hero[i] -= town[i + 1];
            town[i + 1] = 0;
        }
    }

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

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
using namespace std;

int main(){
  int n,ans; string s;
  cin >> n >> s;
  int res=0;
  for(int i=0;i<n;i++){
    if(s[i]=='.') res++;
  }
  ans=res;
  for(int i=0;i<n;i++){
    if(s[i]=='.') res--;
    else res++;
    ans=min(ans,res);
  }
  cout << ans << endl;
}



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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  llong N, Q;
  string S;

  cin >> N >> S >> Q;

  array<set<int>, 26> s;
  for (int i = 0; i < 26; ++i) {
    s[i].insert(inf<int>);
  }

  for (int i = 1; S[i - 1]; ++i) {
    s[S[i - 1] - 'a'].insert(i);
  }

  llong q, p, l, r;
  char c;
  for (int i = 0; i < Q; ++i) {
    cin >> q;
    if (q == 1) {
      cin >> p >> c;
      s[S[p - 1] - 'a'].erase(p);
      S[p - 1] = c;
      s[S[p - 1] - 'a'].insert(p);
    }
    else {
      cin >> l >> r;
      int res = 0;
      for (int j = 0; j < 26; ++j) {
        res += (*s[j].lower_bound(l)) <= r;
      }

      cout << res << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 24196
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<string>
#define inf 0x3f3f3f3f
using namespace std;
const int maxn = 1e4+5;
char s[105];

int main(){
	int n; cin >> n;
	cin >> s;
	for(int i = 0; i < n/2; i++){
		if(s[i] != s[n/2+i]){
			cout << "No";
			return 0;
		}
	}
	if(n % 2) cout << "No";
	else cout << "Yes";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

int main(){
	char s[201];

	scanf("%s",s);

	int l = strlen(s)-2;

	for(;l>0;l-=2){
		bool found = true;
		for(int i=0;i<l/2;i++){
			if(s[i] != s[i+l/2]) found = false;
		}
		if(found){
			break;
		}
	}
	printf("%d\n",l);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

ll h, w;
char m[51][51] = {};
ll d[51][51] = {};
bool v[51][51] = {};

ll qy[1000001] = {};
ll qx[1000001] = {};

void maze() {
	ll s = 0;
	ll e = 0;
	ll y[4] = { 0,1,-1,0 };
	ll x[4] = { 1, 0,0,-1 };
	v[1][1] = true;
	d[1][1] = 0;
	qy[e] = 1;
	qx[e] = 1;
	e++;

	while (e != s) {
		ll cy = qy[s];
		ll cx = qx[s];
		s++;

		rep(i, 0, 4) {
			ll ny = cy + y[i];
			ll nx = cx + x[i];

			if (ny > 0 && ny <= h && nx > 0 && nx <= w && !v[ny][nx] && m[ny][nx] == '.') {
				qy[e] = ny;
				qx[e] = nx;
				v[ny][nx] = true;
				e++;
				d[ny][nx] = d[cy][cx] + 1;
			}
		}
	}
}

int main() {
	cin >> h >> w;
	ll wh = 0;
	repe(i, 1, h) {
		repe(j, 1, w) {
			cin >> m[i][j];
			if (m[i][j] == '.')wh++;
		}
	}

	maze();
	if (d[h][w] == 0) {
		cout << -1 << endl;
	}
	else {
		cout << wh - (d[h][w] + 1) << endl;
	}

	return 0;
}

Measured memory_bytes: 2304
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
from collections import deque

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)


    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]


    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1


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

    def update_all(self):
        for i in range(n+1):
            self.par[i] = self.find(i)


n, m = getList()

UF = UnionFind(n)
for i in range(m):
    a, b, c = getList()
    if not UF.same_check(a, b):
        UF.union(a, b)

UF.update_all()

print(len(list(set(UF.par))) - 1)

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

using ll = long long;

// ecnerwala

const int MAXN = 2.1e5;
int N;
int A[MAXN];
int B[MAXN];

[[noreturn]] void NOSAD() {
	cout << -1 << '\n'; exit(0);
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> B[i];
	}

	priority_queue<pair<int, int>> pq;
	for (int i = 0; i < N; i++) {
		if (B[i] < A[i]) {
			NOSAD();
		}
		if (B[i] > A[i]) {
			pq.emplace(B[i], i);
		}
	}
	ll ans = 0;
	while (!pq.empty()) {
		int i = pq.top().second; pq.pop();
		assert(B[i] > A[i]);
		int x = (i+N-1) % N;
		int y = (i+1) % N;
		assert(B[i] >= B[x]);
		assert(B[i] >= B[y]);
		if (B[i] <= B[x] + B[y]) {
			// then we're screwed, as no one can move
			NOSAD();
		}
		if (A[i] >= B[x] + B[y]) {
			// we'll go to A[i]
			if ((B[i] - A[i]) % (B[x] + B[y]) != 0) {
				NOSAD();
              /*
              If no more operation are to be done at indices X and Y, then if B[X] and
              B[Y] will not change, so we're screwed
              If changes are to be made to X and Y, they can't be made as A[i] >= B[x] + B[y]
              => A[i] > B[x] and A[i] > B[y] => Min B[i] can be A[i] and even then we can't do 
              any operation on X and Y, so B[i] has to be reduced to A[i]
              */
			}
			ans += (B[i] - A[i]) / (B[x] + B[y]);
			B[i] = A[i];
			continue;
		} else {
			ans += B[i] / (B[x] + B[y]);
			B[i] %= B[x] + B[y];
          // Similarly if we can't leave B[i] to be greater than B[x] and B[y]
          // as then no futher operation are possible for x and y, so make it less
          // than B[x] + B[y], so if A[i] > B[i], then we can't proceed further, 
          // otherwise push new (B[i], i) to the PQ
			if (B[i] < A[i]) {
				NOSAD();
			}
			if (B[i] > A[i]) {
				pq.emplace(B[i], i);
			}
		}
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3956
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = Long.parseLong(sc.next());
        long year = 0;
        long m = 100;
        while(m < x){
            m = m/100 + m;
            year++;
        }
        System.out.println(year);
        sc.close();
    }
}

Measured memory_bytes: 35660
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部変数
static FILE *szpFpI;											// 入力

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
long long
fMain(
)
{
	char lc1Buf[1024];

	// N, A, B - 取得
	long long llN, llA, llB;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%lld%lld%lld", &llN, &llA, &llB);

	// 差
	long long llDF = llB - llA;

	// 偶数
	if (llDF % 2 == 0) {
		return llDF / 2;
	}

	// 両者最小へ
	long long llMin = llB - 1;

	// 両者最大へ
	long long llCnt = llN - llA;
	if (llMin > llCnt) {
		llMin = llCnt;
	}

	// Aを最小後、中間へ
	llCnt = llA - 1;
	llCnt += (llB - llCnt) / 2;
	if (llMin > llCnt) {
		llMin = llCnt;
	}

	// Bを最大後、中間へ
	llCnt = llN - llB;
	llCnt += (llN - llA - llCnt + 1) / 2;
	if (llMin > llCnt) {
		llMin = llCnt;
	}

	return llMin;
}

// １回実行
int
fOne(
)
{
	long long llRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	llRet = fMain();

	// 出力
	sprintf(lc1Buf, "%lld\n", llRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



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

#define MAX 21

int main() {

  while( true ) {

    long long int n;
    cin >> n;
    if ( n == 0 ) break;

    long long int a[MAX], b[MAX], t[MAX];

    long long int c[MAX] = {0};

    long long int s = 0;

    for( int i = 0; i < n - 1; i++ ) {
      cin >> a[i] >> b[i] >> t[i];
      c[ a[i] ]++;
      c[ b[i] ]++;
      s += t[i];
    }

    bool flag[MAX] = {};
    for ( long long int i = 2; i <= n; i++ ) {
      if ( c[i] == 1 && flag[i] == false ) {
	for ( int j = 0; j < n - 1; j++ ) {
	  if ( a[j] == i || b[j] == i ) {
	    int x;
	    if ( a[j] == i ) {
	      x = b[j];
	    }else {
	      x = a[j];
	    }
	    a[j] = 0;
	    b[j] = 0;
	    c[i]--;
	    c[x]--;
	    flag[i] = true;
	    flag[x] = true;
	    s -= t[j];
	    break;
	  }
	}
      }
    }

    queue< int > q;
    q.push( 1 );
    long long int l[MAX] = {0};

    while( q.size() > 0 ) {

      long long int k = q.front();
      q.pop();
      flag[k] = true;

      for ( long long int i = 0; i < n - 1; i++ ) {
	if ( a[i] == k || b[i] == k ) {
	  int x;
	  if ( a[i] == k ) {
	    x = b[i];
	  }else {
	    x = a[i];
	  }
	  a[i] = 0;
	  b[i] = 0;
	  l[x] = l[k] + t[i];
	  q.push( x );
	}
      }

    }

    long long int lmax = 0;

    for ( long long int i = 1; i <= n; i++ ) {
      lmax = max( lmax, l[i] );
    }

    cout << s * 2 - lmax << endl;

  }

  return 0;

}

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

int main() {
	int a, b;
	cin >> a >> b;

	long long c = a * b;
	if (c % 2 == 0) {
		cout << "Even" << endl;
	}
	else {
		cout << "Odd" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import sys

fin = sys.stdin.readline
W, H, x, y = [int(elem) for elem in fin().split()]

center_x = W / 2
center_y = H / 2

if x == center_x and y == center_y:
    multi_hantei = 1
else:
    multi_hantei = 0

print((W*H)/2, multi_hantei)


Measured memory_bytes: 38384
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}
static const long long MOD_NUM = 1000000007LL;

static void B_task();

int main()
{
	B_task();
	fflush(stdout);
	return 0;
}

static void B_task()
{
	int N;
	char str[101] = { 0 };
	char str2[101] = { 0 };

	get1int(N);
	getstring(str);

	strcpy(str2, &str[N/2]);
	str[N/2] = '\0';

	const char* ans = "No\n";
	if (strcmp(str, str2) == 0) {
		ans = "Yes\n";
	}
	printf(ans);
}


Measured memory_bytes: 256
import scala.collection.mutable.ArrayBuffer
import scala.io.StdIn.readLine

object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val s = readLine
    val q = readLine.toInt
    val lines = new Array[String](q)
    for(i <- 0 until q) {
      lines(i) = readLine()
    }

    var reversed = false
    val prefix = new ArrayBuffer[String]()
    val suffix = new ArrayBuffer[String]()

    for (i <- 0 until q) {
      val line = lines(i)
      val t = line.split(" ")(0).toInt
      if (t == 1) {
        reversed = !reversed
      } else {
        val f = line.split(" ")(1).toInt
        val c = line.split(" ")(2)
        if (f == 1) {
          if (!reversed) {
            prefix.append(c)
          } else {
            suffix.append(c)
          }
        } else {
          if (!reversed) {
            suffix.append(c)
          } else {
            prefix.append(c)
          }
        }
      }
    }


    if (!reversed) {
      print(prefix.toList.reverse.mkString(""))
      print(s)
      print(suffix.mkString(""))
    } else {
      (suffix.toList.reverse ++ s.reverse ++ prefix).mkString("")
      print(suffix.toList.reverse.mkString(""))
      print(s.reverse)
      print(prefix.mkString(""))

    }

  }
}


Measured memory_bytes: 123120
//https://atcoder.jp/contests/abc088/tasks/abc088_d
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

struct edge {
    int to, cost;
	edge(ll _to) : to(_to), cost(1) {}
};
typedef vector<vector<edge> > AdjList;
AdjList graph;

typedef pair<int, int> P;

const int INF = 10000000;

vector<int> dist; 
vector<int> prever;

void dijkstra(int n, int s){
    dist = vector<int>(n,INF);
    prever = vector<int>(n,-1);
    dist[s] = 0;

    priority_queue<P, vector<P>, greater<P> > que;
    que.push(P(0,s));

    while(!que.empty()){
        P p = que.top();
        que.pop();
        int v = p.second;
        if(dist[v] < p.first){
            continue;
        }
        for(int i=0;i<graph[v].size();i++){
            edge e = graph[v][i];
            if(dist[e.to] > dist[v] + e.cost){
                dist[e.to] = dist[v] + e.cost;
                prever[e.to] = v;
                que.push(P(dist[e.to],e.to));
            }
        }
    }
}

vector<int> get_path(int t){ //頂点tへの最短路
    vector<int> path;
    for(; t != -1;t=prever[t]){
        path.push_back(t);
    }

    reverse(path.begin(), path.end());
    return path;
}

int main() {
#if LOCAL&0
    std::ifstream in("./input.txt"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#endif
    ll H,W; cin>>H>>W;
    vector<string> swh(H);
    ll n=0;//node数
    ll w=0;//wall数
    for(auto&& sw:swh){
        cin>>sw;
        for(const auto c:sw){
            if (c=='.') ++n;
            else ++w;
        }
    }

    auto getsw = [&](ll _x,ll _y){
        auto c = '#';
        assert(_x>=0);
        assert(_y>=0);
        if(_x < W && _y< H){
            c = swh.at(_y).at(_x);
        }
        return c;
    };
    auto getid = [&](ll _x, ll _y){
        return _y*W + _x;
    };
    auto check_and_add_edge = [&](ll from_x, ll from_y, ll to_x, ll to_y){
        auto c = getsw(to_x,to_y);
        if (c=='.'){
            auto from = getid(from_x, from_y);
            auto to = getid(to_x, to_y);
            graph.at(from).emplace_back(to);
            graph.at(to).emplace_back(from); //反対もいけるので
        }
    };

    graph = AdjList(H*W);
    REP(y,H){
        const auto& sw = swh.at(y);
        REP(x,W){
            auto c = sw.at(x);
            if (c=='.') {
                check_and_add_edge(x,y, x+1,y); //right
                check_and_add_edge(x,y, x,y+1); //down
            }
        }
    }

    dijkstra(H*W, 0);
    auto r = get_path(H*W-1);
#if LOCAL&0
    for(auto v:r){
        cout<<v<<endl;
    }
#endif
    if (r.size() <= 0 || *(r.begin()) != 0) cout<<-1<<endl;
    else {
        ll ans = H*W - w -r.size();
        cout<<ans<<endl;
    }
    return 0;
}

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

using namespace std;

#define lli long long int

#define ulli unsigned long long int

#define Pi 3.14159265358979323846264338327950288419716939937510

int main(){
	
    ios :: sync_with_stdio(false);
   
    //ifstream cin; ofstream cout; cin.open("input.txt"); cout.open("output.txt");
    
    int n,m;
    
    cin>>n>>m;
    
    cout<<(n*(n-1))/2+(m*(m-1))/2;
}

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

using namespace std;

static int64_t mask[101];
int64_t back(const vector<int>& A, int64_t current_mask, int position, int N) {
    if (3 * position > N) {
        int64_t answer = 0;
        for (int i = position; i <= N; ++i) {
            if (i < 2 * position || i % 2 == 1) { // it's not a double
                int x = A[i];
                if (current_mask & mask[i])
                    x = 0;
                int y = 0;
                if (2 * i <= N && (current_mask & mask[2 * i]) == 0)
                    y = A[2 * i];
                answer += max(x + y, max(x, 0));
            }
        }
        return answer;
    }

    int64_t best_value = numeric_limits<int64_t>::min();
    int now = A[position];
    if ((current_mask & mask[position]) == 0) {
        best_value = max(best_value, back(A, current_mask | (1LL << (position)), position + 1, N));
    } else
        now = 0;
    return max(best_value, now + back(A, current_mask, position + 1, N));
}

int main() {
    int N; cin >> N;
    for (int i = 1; i <= N; ++i)
        for (int j = 1; j < i; ++j)
            if (i % j == 0)
                mask[i] |= (1LL << j);

    vector<int> V(N + 1);
    for (int i = 1; i <= N; ++i) {
        cin >> V[i];
    }

    cout << back(V, 0, 1, N) << "\n";
}


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

int main() {
  int N;
  cin >> N;
  for(int i=0;i<N;i++){
    string S;
    cin >> S;
    if(S=="Y"){
      cout << "Four" << endl;
      break;
    }
    else if(i == N-1&&S != "Y"){
        cout << "Three" << endl;
      }
      
}
}


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


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}


int main(){
    int N;
    cin >> N;
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            if(i * j == N){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}
    




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

using namespace std;

typedef long long ll;

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

    ll q,h,s,d,n;
    cin>>q>>h>>s>>d>>n;
    ll mi=min(q*4,h*2);
    mi=min(mi,s);
    if(d>mi*2) cout<<mi*n<<endl;
    else{
        ll res= d*(n/2) + mi*(n%2);
        cout<<res<<endl;
    }
}


Measured memory_bytes: 764
#include <iostream>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int a, b;
  std::cin >> a >> b;

  double minv = (12.5 * a > 10 * b) ? 12.5 * a : 10 * b;
  double maxv = (12.5 * (a + 1) > 10 * (b + 1)) ? 12.5 * (a + 1) : 10 * (b + 1);

  for (int k = minv - 1; k <= maxv + 1; ++k) {
    if ((int)(k * 0.08) == a && (int)(k * 0.1) == b) {
      std::cout << k << '\n';
      return 0;
    }
  }

  std::cout << -1 << '\n';
  return 0;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#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 debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int a, b, c; cin >> a >> b >> c;
    if(a == b and b == c and c == a) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using i64 = long long;

int main() {
    i64 n;
    std::cin >> n;
    int ret = 0;
    for (i64 i = 2; i * i <= n; i++) {
        i64 e = 0;
        while (n % i == 0) {
            n /= i;
            e++;
        }
        int j = 0;
        for (int k = 1; j + k <= e; k++) {
            j += k;
            ret++;
        }
    }

    if (n > 1) ret++;

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
int u[maxn];
int find(int x){
	if(x == u[x]) return x;
	return u[x] = find(u[x]);
}
int main(){
	int n, m;
	iota(u, u + maxn, 0);
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		int x, y, z;
		cin >> x >> y >> z;
		u[find(x)] = find(y);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++) ans += find(i) == i;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1152
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
using namespace std;

#define LL long long int

int N;
LL A[100000];

LL ans = 0;

void solve(){
	//負の数が偶数個なら数列を全部正の数にできるのでその和が答え
	//奇数個なら絶対値最小の項にマイナスを押しつければOK
	int negative = 0;//負の数が何個あるかを記録
	for(int i=0;i<N;i++){
		if(A[i]<0) negative++;
	}
	//負の数が偶数個なら数列を全部正の数にできるのでその和が答え
	if(negative%2==0){
		for(int i=0;i<N;i++) ans += abs(A[i]);
		return;
	}
	//奇数個なら絶対値最小の項にマイナスを押しつければOK
	int absmin_index = 0;
	for(int i=0;i<N;i++){
		if(abs(A[i])<abs(A[absmin_index])) absmin_index = i;
		if(A[i]==0) break;
	}
	for(int i=0;i<N;i++){
		if(i==absmin_index) ans -= abs(A[i]);
		else ans += abs(A[i]);
	}
}
 
int main(){
	cin >> N;
	for(int i=0;i<N;i++) cin >> A[i];
 
	solve();

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


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

int dx[27] = {};
int dy[27] = {};
int dz[27] = {};

void solve(int n, int m, int p){
	int a[n+1][n+1][n+1];
	memset(a, 0, sizeof(a));
	bool f = false;
	for(int i=0; i<p; ++i){
		int x, y;
		cin >> x >> y;
		if(f) continue;
		int z=1;
		while(z<n && a[x][y][z] != 0) ++z;
		a[x][y][z] = i%2+1;
/*		for(int j=1; j<=n; ++j){
			cout << "z=" << j << "\n";
			for(int k=1; k<=n; ++k)
				for(int l=1; l<=n; ++l)
					cout << a[k][l][j] << (l == n ? "\n" : " ");
		}
*/		int len[27] = {};
		for(int j=0; j<27; ++j){
			if(j == 13) continue;
			int t = 0;
			int nx = x+dx[j];
			int ny = y+dy[j];
			int nz = z+dz[j];
			while(1<=nx && nx<=n && 1<=ny && ny<=n && 1<=nz && nz<=n && a[nx][ny][nz] == i%2+1){
				++t;
				nx += dx[j];
				ny += dy[j];
				nz += dz[j];
			}
			len[j] = t;
		}
//		for(int j=0; j<27; ++j)
//			cout << j << " " << len[j] << "\n";
		for(int j=0; j<13; ++j)
			if(len[j]+len[26-j]+1 >= m){
				cout << (i%2==0?"Black":"White") << " " << i+1 << "\n";
				f = true;
				break;
			}
	}
	if(!f) cout << "Draw\n";
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	for(int i=0; i<3; ++i)
		for(int j=0; j<3; ++j)
			for(int k=0; k<3; ++k){
				if(i == 1 && j == 1 && k == 1) continue;
				int t = 9*i+3*j+k;
				dx[t] = i-1;
				dy[t] = j-1;
				dz[t] = k-1;
			}
//	for(int i=0; i<27; ++i)
//		cout << dx[i] << " " << dy[i] << " " << dz[i] << "\n";
	while(1){
		int n, m, p;
		cin >> n >> m >> p;
		if(n + m + p == 0) return 0;
		solve(n, m, p);
	}
}


Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
constexpr ll MOD = 998244353;
constexpr int INF = 1 << 30;


int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N;
  string S;
  cin >> N >> S;
  
  ll ans = 0;
  for(int i = 0; i < 10; ++i) {
    for(int j = 0; j < 10; ++j) {
      for(int k = 0; k < 10; ++k) {
        bool mi = false, mj = false, mk = false;
        for(int l = 0; l < N; ++l) {
          if(S[l] - '0' == i && !mi) {
            mi = true;
          }
          else if(S[l] - '0' == j && mi && !mj) {
            mj = true;
          }
          else if(S[l] - '0' == k && mi && mj) {
            mk = true;
          }
        }
        if(mi&&mj&&mk) ++ans;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main() {
	int n;
	cin>>n;
	vector<int> l(n);
	rep(i,n) cin>>l[i];
	sort(all(l));
	ll ans=0;
	for(int i=2;i<n;i++){
		for(int j=i-1;j>=0;j--){
			int k=lower_bound(all(l),l[i]-l[j]+1)-l.begin();
			if(k<j) {
				ans+=j-k;
				//cout<<l[i]<<" "<<l[j]<<" "<<l[k]<<endl;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256