akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  int N;
  cin >> N;
  set<string> s;
  string w;
  cin >> w;
  char c = w[w.size() - 1];
  s.insert(w);
  for(int i = 1; i < N; i++){
    string w;
    cin >> w;
    if(w[0] != c || s.count(w)){
      cout << "No" <<endl;
      return 0;
    }
    s.insert(w);
    c = w[w.size() - 1];
  }
  cout << "Yes" <<endl;
}


Measured memory_bytes: 3556
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=5e5+5;
int a[N],cnt[25],n,res,sum;
inline int calc(R int x){R int res=0;while(x)x>>=1,++res;return res;}
int main(){
	scanf("%d",&n);
	fp(i,1,n)scanf("%d",&a[i]),res^=a[i],++cnt[calc(a[i]^(a[i]-1))];
	fd(i,29,0)if(res>>i&1)
		if(cnt[i+1])res^=(1<<(i+1))-1,++sum;
	printf("%d\n",res?-1:sum);
	return 0;
}

Measured memory_bytes: 640
a,b,c,d = map(int,list(input()))

if a+b+c+d==7:print('{}+{}+{}+{}=7'.format(a,b,c,d));exit()
if a-b+c+d==7:print('{}-{}+{}+{}=7'.format(a,b,c,d));exit()
if a+b-c+d==7:print('{}+{}-{}+{}=7'.format(a,b,c,d));exit()
if a+b+c-d==7:print('{}+{}+{}-{}=7'.format(a,b,c,d));exit()
if a-b-c+d==7:print('{}-{}-{}+{}=7'.format(a,b,c,d));exit()
if a-b+c-d==7:print('{}-{}+{}-{}=7'.format(a,b,c,d));exit()
if a+b-c-d==7:print('{}+{}-{}-{}=7'.format(a,b,c,d));exit()
if a-b-c-d==7:print('{}-{}-{}-{}=7'.format(a,b,c,d));exit()

            

        

    


Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>

int main() {
    long long n, k;
    scanf("%lld%lld", &n,&k);
  	long long ans=(k % 2 == 0)? (powl((n + k / 2) / k, 3) + powl(n / k, 3)):powl(n / k, 3);
    printf("%lld",ans);

    return 0;
}


Measured memory_bytes: 2216
#include <stdio.h>
int main()
{
    int cat,B,all;
    scanf("%d %d %d",&cat,&B,&all);
    if(cat>all){
        printf("NO\n");
    }else if(cat + B >= all){
        printf("YES\n");
    }else{
        printf("NO");
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cstdint>
#include <cmath>
using namespace std;
using i64 = int64_t;

long gcd(long a, long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
long lcm(long a, long b) {
	return a / gcd(a, b) * b;
}

void solve() {
	long a, b;
	cin >> a >> b;
	cout << lcm(a, b) << endl;
}

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


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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int solve(string& a, int r, int s, int p)
{
	int ans = 0;
	vector<string> all;
	string curr;
	curr += a[0];
	FOR(i, 1, SZ(a)) if (a[i] == a[i - 1]) curr += a[i];
	else
	{
		all.PB(curr);
		curr.clear();
		curr += a[i];
	}
	
	all.PB(curr);
	
	for(auto i: all)
	{
		char hto = i[0];
		int sz = SZ(i);
		sz = (sz + 1) >> 1;
		if (hto == 'r') ans += sz * p;
		if (hto == 'p') ans += sz * s;
		if (hto == 's') ans += sz * r; 
	}
	
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n, k, r, s, p;
	cin >> n >> k >> r >> s >> p;
	vector<string> a(k);
	FOR(i, 0, n)
	{
		char x;
		cin >> x;
		a[i % k] += x;
	}
	
	int ans = 0;
	FOR(i, 0, k) ans += solve(a[i], r, s, p);	
	cout << ans << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 5120
ARGF.each do |line|

  a = line.to_i

  break if a == 0

  b = gets.split.map(&:to_i)

  z = 0
  ave = b.inject(0.0){|r,i| r+=i } / a
  b.each do |p|
    z += (p - ave) ** 2
  end

  puts Math.sqrt(z / a)
end

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

using namespace std;

int cnt[4];

int main() {
    int n; cin >> n;
    while (n--) {
        string str; cin >> str;
        if (str == "AC") cnt[0]++;
        if (str == "WA") cnt[1]++;
        if (str == "TLE") cnt[2]++;
        if (str == "RE") cnt[3]++;
    }
    cout << "AC x " << cnt[0] << endl;
    cout << "WA x " << cnt[1] << endl;
    cout << "TLE x " << cnt[2] << endl;
    cout << "RE x " << cnt[3] << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vs = vector<string>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n;
vll to[100005];
// dp[i][j]: 頂点iを(j?黒く:白く)塗ったとき、iを親とする部分木の塗り方の場合の数
ll dp[100005][2];

void rec(int v, int p=-1) {
  dp[v][0] = 1;
  dp[v][1] = 1;
  for (int u : to[v]) {
    if (u == p) continue;
    rec(u, v);
    dp[v][0] = dp[v][0]*(dp[u][0]+dp[u][1])%mod;
    dp[v][1] = dp[v][1]*dp[u][0]%mod;
  }
}

int main () {
  cin >> n;
  rep(i,n-1) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    to[x].pb(y);
    to[y].pb(x);
  }

  rec(0);
  ll ans = (dp[0][0]+dp[0][1])%mod;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 14208
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

constexpr int kMax=1e5;
LL fact[kMax], finv[kMax], inv[kMax];

void ComInit(int N) {
//  fact = vector<LL>(N + 1);
//  inv = vector<LL>(N + 1);
//  finv = vector<LL>(N + 1);
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i <= N; i++){
    fact[i] = fact[i-1] * i % kMod;
    inv[i] = kMod - inv[kMod % i] * (kMod / i) % kMod;
    finv[i] = finv[i-1] * inv[i] % kMod;
  }
}

LL nCr(int n, int r) {
  LL numerator = fact[n];
  LL denominator = finv[r] * finv[n-r] % kMod;
  return (numerator * denominator) % kMod;
}

int main() {
  int N, K; std::cin >> N >> K;
  ComInit(5e4);
  for (int k = 1; k <= K; ++k) {
    std::cout << nCr(N - K + 1, k) * nCr(K - 1,  k - 1) % kMod << std::endl;
  }
}


Measured memory_bytes: 1408
package main

import (
	"fmt"
	"math"
)

func main() {
	for {
		var n int
		fmt.Scan(&n)
		if n == 0 {
			break
		}
		s := make([]float64, n)
		ave := 0.0
		for i := 0; i < n; i++ {
			fmt.Scan(&s[i])
			ave += float64(s[i])
		}
		ave /= float64(n)
		ans := 0.0
		for i := 0; i < n; i++ {
			ans += (s[i] - ave) * (s[i] - ave)
		}
		ans /= float64(n)
		fmt.Println(math.Sqrt(ans))
	}
}



Measured memory_bytes: 1264
#include <iostream>

using namespace std;

int main()
{
  int X, N;
  int L[101];
  cin >> N >> X;
  for(int i=0; i<N; i++){
    cin >> L[i];
  }
  bool flg = false;
  int D[100];
  D[0]=0;
  for(int i=0; i<N; i++){
    D[i+1] = D[i] + L[i];
    if (D[i+1] > X) {
      flg = true;
      cout << i+1 << endl;
      break;
    }
  }
  if(!flg) cout << N+1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
using namespace std;
typedef pair<int, int> pii;
#define MAX 9999999
int main(){
    vector<bool>Primecheck(MAX+1,true);
    vector<int>Primenumber(MAX+1,0); //Primearray
    int Primecounter =0;                  //Primearray counter;
    for(int i = 2; i<MAX+1;i++){
        if(Primecheck[i]){
            for(int j = 2;i*j<MAX;j++)
                Primecheck[i*j] = false;//?´???°??????Primearray???????´??????????????????°?????¨???false???
            Primenumber[Primecounter] = i;
            Primecounter++;
        }
    }
    Primecheck[1]=false;
    int n;
    while(cin>>n){
        if(n==1){cout<<0<<endl; continue;}
        int ans=0;
        for(int i=1;i<=n;i++)
            if(Primecheck[i]&&Primecheck[n-i+1])ans++;
        cout<<ans<<endl;
    }
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		String s = fs.next();
		
		System.out.println(s.replaceAll("2017", "2018"));
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 32972
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <algorithm>
#include <map>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <cstdlib>
#include <ctime>

using namespace std;

//#define HOME
void jakos() {
#ifdef HOME
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

#define endl '\n'
#define int long long
typedef long long ll;

const int mod = 1e9 + 7;
const int base = 179;
const int INF = 1e9;
const int N = 1e5 + 7;

signed main() {
    jakos();

    int n;
    cin >> n;
    bool ans = true;
    int tmp;
    for (int i = 0; i < n; i++) {
        cin >> tmp;
        if (tmp % 2 == 0 && !(tmp % 3 == 0 || tmp % 5 == 0)) {
            ans = false;
        }
    }
    if (ans) {
        cout << "APPROVED" << endl;
    }
    else {
        cout << "DENIED" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}
int modPow(long long a, long long n, long long p) {
	if (n == 0) return 1; // 0乗にも対応する場合
	if (n == 1) return a % p;
	if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
	long long t = modPow(a, n / 2, p);
	return (t * t) % p;
}
vector<ll> fact, factinv, inv;
ll mod = 1e9 + 7;
void prenCkModp(ll n) {
	fact.resize(n + 5);
	factinv.resize(n + 5);
	inv.resize(n + 5);
	fact.at(0) = fact.at(1) = 1;
	factinv.at(0) = factinv.at(1) = 1;
	inv.at(1) = 1;
	for (ll i = 2; i < n + 5; i++) {
		fact.at(i) = (fact.at(i - 1) * i) % mod;
		inv.at(i) = mod - (inv.at(mod % i) * (mod / i)) % mod;
		factinv.at(i) = (factinv.at(i - 1) * inv.at(i)) % mod;
	}

}
ll nCk(ll n, ll k) {
	if (n < k) return 0;
	else {
		return fact.at(n) * (factinv.at(k) * factinv.at(n - k) % mod) % mod;
	}
}



int main() {

	ll N, M;
	cin >> N >> M;
	vector<bool> box(N);
	vector<ll> nu(N);

	rep(i, N) {
		box.at(i) = false;
		nu.at(i) = 1;
	}
	box.at(0) = true;
	rep(i, M) {
		ll x, y;
		cin >> x>> y;
		if (box.at(x - 1)) {
			box.at(y - 1) = true;
		}
		nu.at(x - 1)--;
		nu.at(y - 1)++;
		if (nu.at(x - 1) == 0) {
			box.at(x - 1) = false;
		}
	}
	ll an = 0;
	rep(i, N) {
		if (box.at(i)&&nu.at(i)>0) an++;
	}
	cout << an << endl;

}



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

int main() {
  int n, k, board = 1;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    if (board * 2 > board + k) {
      board += k;
    } else {
      board *= 2;
    }
  }
  cout << board << endl;
}

Measured memory_bytes: 256
//
// Created by Akifumi Ohata on 2017/09/27.
//
#include<iostream>
#include <vector>

using namespace std;

int main(){

    int A ,B;

//    0≦A,B≦23
//    A,B は整数である。

    cin >> A >>B ;


    int starttime = A+B;
    
    int answer = starttime%24;


    cout << answer<<endl;

    return 0;
}

Measured memory_bytes: 256
from collections import Counter


def GCD(a: int, b: int) -> int:
    return a if b == 0 else GCD(b, a % b)


def check_pairwise_coprime(a):
    m = max(a)
    cnt_a = Counter(a)
    is_prime = [True] * (m + 1)
    for i in range(2, m // 2 + 1):
        if is_prime[i]:
            cnt = cnt_a[i]
            for j in range(2, m // i + 1):
                cnt += cnt_a[i * j]
                is_prime[i * j] = False
            if cnt > 1:
                return False
    return True


def check_setwise_coprime(a):
    gcd_all = a[0]
    for i in range(1, n):
        gcd_all = GCD(gcd_all, a[i])
    return gcd_all == 1


n = int(input())
a = list(map(int, input().split()))

if check_pairwise_coprime(a):
    print('pairwise coprime')
elif check_setwise_coprime(a):
    print('setwise coprime')
else:
    print('not coprime')


Measured memory_bytes: 127272
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
const int mod=1000000007;
int n;
vector<int> g[100010];
int dp[100010][2];
int dfs(int u,int par,int col){
	int &an=dp[u][col];
	if(~an)return an;
	an=1;
	for(auto x:g[u]){
		if(x==par)continue;
		int ans=0;
		if(col!=1){
			ans+=dfs(x,u,1);
			if(ans>=mod)ans-=mod;
		}
		ans+=dfs(x,u,0);
		if(ans>=mod)ans-=mod;
		an=(1LL*an*ans)%mod;
	}
	return an;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	memset(dp,-1,sizeof dp);

	cin>>n;
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	g[0].push_back(1);
	cout<<dfs(0,-1,0)<<endl;


	return 0;
}

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

int main() {
  string l;
  cin>>l;
  int n = l.length();
  int MOD = 1e9  + 7;

  long long cnt[n+1];
  cnt[0] = 1;
  for (int i=1; i<=n; i++) {
    cnt[i] = 3 * cnt[i-1];
    cnt[i] %= MOD;
  }

  long long ans = 1;
  long long x = 1;
  for (int i=0; i<n; i++) {
    if (l[i] == '1') {
      ans += x * cnt[n-i-1];
      ans %= MOD;
      x *= 2;
      x %= MOD;
    }
  }
  ans = (ans + x) % MOD - 1;
  cout<<ans<<endl;
}

Measured memory_bytes: 1280
public class Hello{
    public static void Main(){
        // Your code here!
        long N = long.Parse(System.Console.ReadLine());
        long a = yakusuu(N);
        long b = N/a;
        System.Console.WriteLine(a+b-2);
    }
    private static long yakusuu(long n)
    {
        long a=1;
        for(long i =1;i*i<=n;i++){
            if(n%i == 0)
                a = i;
        }
        return a;
    }
}


Measured memory_bytes: 13140
#include <iostream>
using namespace std;
int larger(int x,int y) {
	int z = 0;
	if (x > y)z = x;
	else z = y;
	return z;
}
int smaller(int x, int y) {
	int z = 0;
	if (x < y)z = x;
	else z = y;
	return z;
}
int main(void) {
	int s = 1;
	while (s == 1) {
		int sinsa, a[100], sum = 0, ave;
		cin >> sinsa;
		if (sinsa == 0)return 0;
		for (int i = 0; i < sinsa; i++) {
			cin >> a[i];
		}
		int n = a[0];
		for (int i = 0; i < sinsa; i++) {
			n = larger(n, a[i]);
		}
		int m = a[0];
		for (int i = 0; i < sinsa; i++) {
			m = smaller(m, a[i]);
		}
		for (int i = 0; i < sinsa; i++) {
			sum += a[i];
		}
		sum = sum - n - m;
		ave = sum / (sinsa - 2);
		cout << ave<<endl;
	}

	return 0;

}

Measured memory_bytes: 3088
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
using namespace std;
struct qw{
	string i;
	int j;
}flag[200010];
string s;
map<string ,int >p;
int n,m=0;
bool cmp(qw a,qw b)
{
	if(a.j==b.j)return a.i<b.i;
	return a.j<b.j;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		if(!p[s])
		{
			flag[++m].i=s;
			flag[m].j=1;
			p[s]=m;
		}
		else flag[p[s]].j++;
	}
	sort(flag+1,flag+m+1,cmp);
	for(int i=1;i<=m;i++)
	{
		if(flag[i].j==flag[m].j)
		cout<<flag[i].i<<endl;
	}
	return 0;
}

Measured memory_bytes: 28288
#include <iostream>

using namespace std;

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

    if (a < b)
        cout << "a < b" << endl;
    else if (a == b)
        cout << "a == b" << endl;
    else if (a > b)
        cout << "a > b" << endl;

    return 0;
}



Measured memory_bytes: 3104
// Problem : Div Game
// Contest : Virtual Judge - AtCoder
// URL : https://vjudge.net/problem/AtCoder-abc169_d
// Memory Limit : 1048 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")  // disable
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define lll __int128
#define lp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define vec(v, type, sz) vector<type> v(sz)
#define in(v) \
    for (auto &i : v) cin >> i
#define all(v) v.begin(), v.end()
#define prv(v)                         \
    for (auto i : v) cout << i << " "; \
    cout << "\n"
#define MOD 1000000007
#define INF 1000000000
#define INFL 1000000000000000000ll
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vi vector<int>
#define vl vector<ll>
#define vii(v, n, m, val) vector<vector<int>> v(n, vector<int>(m, val))
#define viii(v, i, j, k, val)        \
    vector<vector<vector<int>>> v(i, \
                                  vector<vector<int>>(j, vector<int>(k, val)))
#define pii pair<int, int>
#define pb push_back
#define file_io                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define testcases \
    int tcc;      \
    cin >> tcc;   \
    for (int tc = 1; tc <= tcc; tc++)
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while (!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(vector<string> __attribute__((unused)) args,
               __attribute__((unused)) int idx,
               __attribute__((unused)) int LINE_NUM) {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if (idx > 0)
        cerr << ", ";
    else
        cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss;
    ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef DB
#define debug(...) \
    debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
    fast_io;
    ll n;
    cin >> n;
    int cnt = 0;
    for (ll i = 2; i <= sqrt(n); i++) {
        int p = 0;
        while (n % i == 0) {
            p++;
            n /= i;
        }
        cnt += floor((sqrt(1 + 8 * p) - 1.0) / 2.0);
    }
    if (n != 1) {
        cnt++;
    }
    cout << cnt;
}

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

int main(){
    string s,t;
    cin>>s;
    t=s;
    reverse(t.begin(),t.end());
    string s1,s2;
    s1=s;
  	s2=t;
  int m;
  m=(s.length()-1)/2;
    s1.erase(m);
    s2.erase(m);
    string s1r,s2r;
    s1r=s1;s2r=s2;
    reverse(s1r.begin(),s1r.end());
    reverse(s2r.begin(),s2r.end());
    if(s==t){
        if(s1==s1r){
            if(s2==s2r){
                cout<<"Yes";
            }
            else{cout<<"No";}
        }
        else{cout<<"No";}
    }
    else{cout<<"No";}
    
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
import numpy as np
n,m,x= [int(x) for x in stdin.readline().rstrip().split()]
li = list(map(int,stdin.readline().rstrip().split()))

lin= [0]*(n+1)

for i in li:
    lin[i] = 1
print(min(sum(lin[:x]),sum(lin[x+1:])))

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

macro_rules! min {
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}

macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let m: usize = sc.cin();
    let ps: Vec<usize> = (0..n).map(|_| sc.cin()).collect();
    let mut neigh: Vec<Vec<usize>> = vec![vec![]; n];
    for _ in 0..m {
        let x = sc.cin::<usize>() - 1;
        let y = sc.cin::<usize>() - 1;
        neigh[x].push(y);
        neigh[y].push(x);
    }
    let mut used = vec![false; n];
    use std::collections::HashSet;
    let mut ans = 0;
    for i in 0..n {
        let mut a = HashSet::new();
        let mut b = HashSet::new();
        if used[i] { continue }
        let mut stack = vec![i];
        while let Some(u) = stack.pop() {
            a.insert(u + 1);
            b.insert(ps[u]);
            used[u] = true;
            for &v in neigh[u].iter() {
                if used[v] { continue }
                stack.push(v);
            }
        }
        ans += a.intersection(&b).count();
    }
    put!(ans);
}

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

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


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

int main()
{
    
    int a[3][3];
    bool appear[3][3];
    ref(i,3)
    {
        ref(j,3)
        {
            cin>>a[i][j];
        }
    }
    int n;
    cin>>n;
    int why[n];
    ref(i,n)
    {
        cin>>why[i];
    }
    ref(i,n){
        ref(j,n){
            appear[i][j] = false;
            ref(k,n){
                if(a[i][j] == why[k])
                    appear[i][j] = true;
            }
        }
    }
    string ans = "No";
    ref(i,3) // HORIZONTAL
    {
       if(appear[i][0] and appear[i][1] and appear[i][2])
        ans = "Yes";
    }
    ref(i,3) // VERICAL
    {
       if(appear[0][i] and appear[1][i] and appear[2][i])
        ans = "Yes";
    }
    if(appear[0][0] and appear[1][1] and appear[2][2]) // DAIGONAL1
        ans = "Yes";
    if(appear[0][2] and appear[1][1] and appear[2][0]) // DAIGONAL2
        ans = "Yes";
   cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cstdlib>

using namespace std;
int main(){

  string str;
  int n;
  cin >> str >> n;

  for(int i=0;i<n;i++){
    string cmd;
    cin >> cmd;

    if(cmd.compare("print") == 0){
      int a,b;
      cin >> a >> b;
      for(int j=a;j<=b;j++){
        cout << str[j];
      }
      cout << endl;
    }else if(cmd.compare("reverse") == 0){
      int a,b;
      cin >> a >> b;
      string tmp = str.substr(a,(b-a+1));
      for(int j=0,l=tmp.size();j<l;j++){
        str[j+a] = tmp[(l-1)-j];
      }
    }else if(cmd.compare("replace" ) == 0) {
      int a,b;
      cin >> a >> b;
      string p;
      cin >> p;
      for(int j=0;j<p.size();j++){
        str[j+a] = p[j];
      }
    }
  }


}





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

int main(){
  char a;
  cin >> a;
  if (a=='a' || a=='o' || a=='e' || a=='i' || a=='u'){
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

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

int main()
{
    string s,t;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    string u;
    cin>>u;
    if(s==u)
    {
        cout<<a-1<<" "<<b;
    }
    else
    {
        cout<<a<<" "<<b-1<<endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
    int r;
    std::cin >> r;
    
    if(r < 1200) {
        std::cout << "ABC" << std::endl;
    } else if(r < 2800) {
        std::cout << "ARC" << std::endl;
    } else {
        std::cout << "AGC" << std::endl;
    }
}

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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    string S, T;
    cin >> S >> T;
    cout << T << S << endl;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-

list = map(str, raw_input().split())
num = []
for i in list:
    if i == '+':
        num[len(num)-2] += num.pop()
    elif i == '-':
        num[len(num)-2] -= num.pop()
    elif i == '*':
        num[len(num)-2] *= num.pop()
    else:
        num.append(int(i))
print num[0]

Measured memory_bytes: 6452
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FOREACH(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define SIZE(v) ((int)(v).size())
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define ll long long
#define llint long long
#define pii pair<int, int>
#define UNVISITED -1


template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}
 
template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
 
class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

const ll mod = 998244353;
const int MAX = 500500;
ll dp[MAX], acc[MAX];
int L[MAX], R[MAX];

int main() {
    int N, K; scanf("%d %d", &N, &K);
    REP(i, K) scanf("%d %d", L + i, R + i);



    dp[N] = 1;
    acc[N] = 1;

    for(int i = N - 1; i >= 1; i--) {
        REP(j, K) {
            int l = i + L[j], r = i + R[j];
            dp[i] = (dp[i] + acc[l] - acc[r + 1] + mod)%mod;
        }
        acc[i] = (acc[i + 1] + dp[i])%mod;
    }

    printf("%lld\n", dp[1]);

}

Measured memory_bytes: 6960
#include <iostream>
 using namespace std;
 int main(){
 string S;
 cin >> S;
 int L = S.size();
 string ans = "AC";
 if(S[0] != 'A'){
 ans = "WA";
 }
 int cnt = 0;
 for(int i = 1; i < L; ++i){
 if(isupper(S[i])){
 if(i == 1 || i == L - 1 || S[i] != 'C'){
 ans = "WA";
 }
 ++cnt;
 }
 }
 if(cnt != 1){
 ans = "WA";
 }
cout << ans << endl;
 }


Measured memory_bytes: 256
n = io.read("*n")
t = {}
for i = 1, n do
  t[i] = 0
end
for x = 1, 100 do
  for y = 1, 100 do
    for z = 1, 100 do
      c = x * x + y * y + z * z
        + x * y + y * z + z * x
      if c <= n then
        t[c] = t[c] + 1
      end
    end
  end
end
print(table.concat(t, "\n"))


Measured memory_bytes: 2712
N = int(input())
CA = list(map(int, input().split()))
CB = list(map(int, input().split()))

def solve(n, w, v):
    dp = [0]*(n+1)
    for i in range(n):
        dp[i+1] = max(1+dp[i], dp[i+1])
        if i + w[0] < n+1:
            dp[i+w[0]] = max(dp[i] + v[0], dp[i+w[0]])
        if i + w[1] < n+1:
            dp[i+w[1]] = max(dp[i] + v[1], dp[i+w[1]])
        if i + w[2] < n+1:
            dp[i+w[2]] = max(dp[i] + v[2], dp[i+w[2]])
    return dp[-1]
print(solve(solve(N, CA, CB), CB, CA))

Measured memory_bytes: 228892
#include<bits/stdc++.h>
using namespace std;
#define pow107 int(pow(10,9) + 7)

bool comp(pair<int, int> a, pair<int, int> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

long int Func2(long int n,long int m){
    long int s2 = 1,
        r = 1;
    for(long int i = 1; i <= m; ++i){
        s2 = (s2*(n - (i - 1))/i) % (pow107);
    }
    return s2;
}

bool secsort(pair<int, int> a, pair<int, int> b){
    if(a.second == b.second)return a.first > b.first;
    else return a.second > b.second;
}

long int GCD(long int a,long int b){
    if(b == 0)return a;
    return GCD(b,a%b);
}

long int LCM(long int a,long int b){
    return a/GCD(a,b)*b;
}

void warfl(vector<vector<int> > &dist, int n){
  for(int k=0; k<n; k++){
    for(int i=0; i<n; i++){
      for(int j=0; j<n; j++){
        dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
      }
    }
  }
  return;
}
#define long long long

const int MAX = 1000000;
const int MOD = 1e9+7;

long mpow(long x, long n){
    long ans = 1;
    while(n != 0){
        if(n%2==1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n/2;
    }
    return ans;
}

long mfact(long n){
  long ans = 1;
  for(long i=2; i<=n; i++){
    ans = ans*i % MOD;
  }
  return ans;
}

long mcomb(long n, long m){ //aCbをmod計算
    if(n == 0 && m == 0) return 1;
    if(n < m || n < 0) return 0;
    long ans = mfact(n)*mpow(mfact(m), MOD-2) %MOD;
    ans = ans*mpow(mfact(n-m), MOD-2) %MOD;
    return ans;
}

long int jjjjj(long int n){
    long int x = 1;
    for(int i = 1; i <= n; ++i){
        x *=i;
    }
    return x;
}

int main(){
    int n,c = 0;
    string s;
    cin >> n >> s;
    for(int i = 0; i <= 9; ++i){
        int a = s.find(char('0'+i));
        if(a >= 0 && a < n){
            for(int j = 0;j <= 9;++j){
                int b = s.find(char('0' + j),a + 1);
                if(b >= 0 && b < n){
                    for(int k = 0; k <= 9; ++k){
                        int d = s.find(char('0'+k),b + 1);
                        //cout << i << a << j << b << k << d << endl;
                        if(d >= 0 && d < n)c++;
                    }
                }
            }
        }
    }
    cout << c << endl;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) 
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(T x,T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> T modinv(T x,const T mod){return modpow(x,mod-2,mod);}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),b.begin(),b.end());}
template<class T> void getand(const T &a,const T &b,T &c) {
  set_intersection(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getor(const T &a,const T &b,T &c) {
  set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getdiff(const T &a,const T &b,T &c) {
  set_difference(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> T deg2rad(T deg) {return deg*2*M_PI/360;}
template<class T> T rad2deg(T rad) {return rad*360/(2*M_PI);}

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD=1e9+7;
const ll MAX=5e6;

int main() {
  // 費用の最小（or-1）
  // -1になる条件は、鍵の開く箱が無い場合
  // まずはコストの小さい順に鍵をソート
  // そして、小さい方から順番に「まだ空いてない箱を開けられる」なら鍵を買っていき、12個全て開いたらbreak
  // 最後まで行っても開かなければ-1
  // つまり最高でも鍵は12個あればいい
  // 一度買う鍵を選んだら、次はその鍵のなかで、「どれかに一括化できるもの」を排除する
  int N,M;cin>>N>>M;
  typedef bitset<12> bs12;
  typedef pair<int,bs12> CP;
  // costと開けられる箱をbitset
  vector<CP> keys(M);
  REP(i,M) {
    int a,b;cin>>a>>b;
    bs12 bs;
    REP(j,b) {
      int c;cin>>c;
      bs.set(c-1);
    }
    keys[i] = {a,bs};
  }

  // i番目の鍵まで来たときにbitsetの買い方ができる最小コスト
  vector<vector<ll>> dp(M+1,vector<ll>(pow(2,N),LLONG_MAX/4));
  dp[0][0] = 0;

  // 鍵ごとにdp
  REP(i,M) {
    REP(j,pow(2,N)) {
      bs12 prevkey = bs12(j);
      REP(k,12) if (keys[i].second[k]==1) prevkey.reset(k);
      dp[i+1][j] = min(dp[i][j],dp[i][prevkey.to_ullong()]+keys[i].first);
    }
  }
  dp[M][pow(2,N)-1]==LLONG_MAX/4 ? OUT(-1) : OUT(dp[M][pow(2,N)-1]);

  return 0;
}

Measured memory_bytes: 32384
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
 
using namespace std;

signed main()
{
    fast;
    int l;
    cin>>l;

    long double side = 0;

    side = l/(double)3;

    cout<<fixed<<setprecision(20)<<side*side*side<<endl;
    return 0;
}

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

#define LOCAL 0

#define lli long long int
#define llu unsigned long long int
#define ld long double
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define slli(n) scanf("%lld",&n);
#define ss(n) scanf("%s",n);

const long double EPS = 1e-10;
const lli MOD = 1000000007ll;
const lli mod1 = 1000000009ll;
const lli mod2 = 1100000009ll;
int INF = (int)1e9;
lli INFINF = (lli)1e18;
int debug = 0;
long double PI = acos(-1.0);

using namespace std;

lli bit_count(lli _x){lli _ret=0;while(_x){if(_x%2==1)_ret++;_x/=2;}return _ret;}
lli bit(lli _mask,lli _i){return (_mask&(1<<_i))==0?0:1;}
lli powermod(lli _a,lli _b,lli _m=MOD){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli add(lli a,lli b,lli m=MOD){lli x=a+b;while(x>=m)x-=m;while(x<0)x+=m;return x;}
lli sub(lli a,lli b,lli m=MOD){lli x=a-b;while(x<0)x+=m;while(x>=m)x-=m;return x;}
lli mul(lli a,lli b,lli m=MOD){lli x=a*1ll*b;x%=m;if(x<0)x+=m;return x;}

string s;
int dp[100010];

int main()
{
if(LOCAL){
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    debug = 1;
}
    srand (time(NULL));

    cin>>s;
    int n = s.size();
    s = ' ' + s;
    dp[0] = 1;
    for(int i=1;i<=n;i++){
        if(i-5>=0 && s.substr(i-4,5)=="dream")
            dp[i] |= dp[i-5];
        if(i-7>=0 && s.substr(i-6,7)=="dreamer")
            dp[i] |= dp[i-7];
        if(i-5>=0 && s.substr(i-4,5)=="erase")
            dp[i] |= dp[i-5];
        if(i-6>=0 && s.substr(i-5,6)=="eraser")
            dp[i] |= dp[i-6];
    }

    if(dp[n])
        cout<<"YES";
    else
        cout<<"NO";

    return 0;
}


Measured memory_bytes: 892
//考え方はあまり変わらないがPDF解説に寄せてみる
#include<bits/stdc++.h>
using namespace std;

int main(){
  int n,k,suml,sumr,ans=1;
  cin>> n >> k;
  vector<int> divide,a(n);
  suml=0;
  for (int i=0; i<n; i++){
    cin>> a[i];
    suml+=a[i];
  }
  
  for (int i=1; i*i<=suml; i++){
    if (suml%i==0){
      divide.push_back(i);
      divide.push_back(suml/i);
    }
  }
  sort(divide.begin(),divide.end());
  reverse(divide.begin(),divide.end());
  
  for (auto d: divide){
    multiset<int> remain;
    suml=0; sumr=0;
    for (auto i: a){
      i%=d;
      if (i!=0){
        remain.insert(i);
        sumr+=d-i;
      }
    }
    
    for (auto i: remain){
      if (suml>k) break;
      if (suml==sumr){
        ans=d;
        break;
      }
      suml+=i; sumr-=d-i;
    }
    if (ans>1) break;
  }
  
  cout<< ans << endl;
}

Measured memory_bytes: 256
# /usr/bin/python
# -*- coding: utf-8 -*-
import math



class UnionFind():
  def __init__(self, size):
    self.par = [-1]*size
      
  def root(self,x):
    if self.par[x] < 0:
      return x
    else:
      return self.root(self.par[x])
      
  def issame(self,x,y):
    if self.root(x)==self.root(y):
      return True
    else:
      return False
  
  def merge(self,x,y):
    x, y = [self.root(x), self.root(y)]
    if x == y:
      return False
    if self.par[x] > self.par[y]:
      x, y = y, x
    self.par[x] += self.par[y]
    self.par[y] = x
    return True

  def get_list(self):
    return self.par


def main():
  N,M = map(int, input().split())
  uf = UnionFind(N)
  for _ in range(M):
    x,y,z = map(int, input().split())
    uf.merge(x-1,y-1)

  ret = 0
  for p in list(uf.get_list()):
    if p < 0:
      ret += 1
  return ret


if __name__ == "__main__":
  print(main())

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<ll, ll>;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
struct edge {
  ll to, cost;
};

// UnionFindを示す構造体
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main() {
  ll N, M; cin >> N >> M;
  vector<ll> A(M), B(M); 
  REP(i, M) {
    cin >> A[i] >> B[i];
    A[i]--; B[i]--;
  }
  UnionFind uf(N);
  ll res = N * (N - 1) / 2;
  vector<ll> ans;
  for(int i = M - 1; i >= 0; --i) {
    ans.push_back((res < 0) ? 0 : res);
    ll sizA = uf.size(A[i]); ll sizB = uf.size(B[i]);
    if(!uf.issame(A[i], B[i])) res -= sizA * sizB;
    uf.merge(A[i], B[i]);
  }
  for(int i = ans.size() - 1; i >= 0; --i) {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 6284
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

h,m,hh,mm,K=map(int,input().split())
t=h*60+m
tt=hh*60+mm
print(max(tt-t-K,0))

Measured memory_bytes: 61712
// At Corder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <algorithm>
#include <iostream>
using namespace std;
#include <vector>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using p = pair<int, int>;//<key,value>
#include <math.h>
int main()
{
int n, ans=0;
cin>>n;
vector<int> a(n);
rep(i,n) cin>>a[i];
rep(i,n)
while(a[i]%2==0){
	a[i]/=2;
	ans++;
}
cout<<ans<<endl;
	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント:
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  vector<string> vec(1200);
  for(int i=0;i<1200;i++){
    cin>>vec[i];
  }
  
  for(int i=0;i<1200;i++){
    for(int j=0;j<vec[i].size();j++){
      if(islower(vec[i].at(j))){
        vec[i].at(j)-=32;
      }
      else if(isupper(vec[i].at(j))){
        vec[i].at(j)+=32;
      }
    }
  }
  
  
  for(int i=0;i<1200;i++){
    if(vec[i].size()!=0&&vec[i+1].size()==0){
      cout<<vec[i]<<endl;
      break;
    }
    cout<<vec[i]<<" ";
  }
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,sum,dig;
    cin >> N;
    sum = 0;
    dig=N;
    while(dig>0){
        sum+=dig%10;
        dig/=10;
    }
    if(N%sum==0){
        cout << "Yes";
    } else {
        cout << "No";
    }
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if (500*i)+(100*j)+(50*k) == x:
                ans += 1

print(ans)

Measured memory_bytes: 39536