akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip> 

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define all(x) (x).begin(), (x).end()
#define fst first
#define snd second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef tuple<int,int,int> iii;

string to_string(string s) {
    return '"' + s + '"';
}
    
string to_string(const char* s) {
    return to_string((string) s);
}
    
string to_string(bool b) {
    return (b ? "true" : "false");
}
    
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
    
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

void fastIO() {
    cin.sync_with_stdio(false);
    cin.tie(0);
}

template<typename T>
vector<T> make_unique(vector<T> v) {
    sort(all(v));
    return v.resize(unique(all(v)) - v.begin());
}

int nxt() {
    int x;
    cin >> x;
    return x;
}


int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

//#############################
const int MAXN = 1000005;

int main() {
    string s,t;
    cin >> s >> t;

    t.pop_back();

    cout << (s == t ? "Yes\n" : "No\n"); 
    return 0;
}

Measured memory_bytes: 3068
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;


ll comb(ll N_, ll C_) {
	const int NUM_ = 3000001;
	static ll fact[3000002], factr[3000002], inv[3000002];
	if (fact[0] == 0) {
		inv[1] = fact[0] = factr[0] = 1;
		for (int i = 2; i <= NUM_; ++i) inv[i] = inv[mod % i] * (mod - mod / i) % mod;
		for (int i = 1; i <= NUM_; ++i) fact[i] = fact[i - 1] * i%mod, factr[i] = factr[i - 1] * inv[i] % mod;
	}
	if (C_<0 || C_>N_) return 0;
	return factr[C_] * fact[N_] % mod*factr[N_ - C_] % mod;
}
ll modpow(ll a, ll n = mod - 2) {
	ll r = 1;
	while (n) r = r * ((n % 2) ? a : 1) % mod, a = a * a%mod, n >>= 1;
	return r;
}


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

	int S; cin >> S;
	int ans = 0;

	eFOR(i, 1, S) {
		int cnt = S - i * 3;
		if (cnt < 0)break;
		ans += comb(cnt + i - 1, cnt);
		ans %= mod;
		//comb(S + L - 1, S);
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 73960
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1<<30;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[8]={1,0,-1,0,1,1,-1,-1} , dy[8]={0,1,0,-1,1,-1,1,-1} ;

int a[101010];
int main(){
    int n,m;
    cin>>n>>m;
    rep(i,m){
        int x,y;
        cin>>x>>y;
        a[y-1]=max(x,a[y-1]);
    }
    int cnt=0;
    int pos=0;
    rep(i,n){
        if(a[i]>pos){
            cnt++;
            pos=i;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <map>
#include <array>
#include <vector>

typedef long long ll;

using namespace std;

int main()
{
    int a, b, c, k;
    int min, max;

    cin >> a >> b >> c >> k;

    max = a;
    if (max < b) {
        min = max;
        max = b;
    }
    else min = b;
    if (max < c)
    {
        min += max;
        max = c;
    }
    else min += c;

    a = max;
    for (int i = 1; i <= k; i++) {
        a = a * 2;
    }

    cout << a + min << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    ll N, K;
    cin >> N >> K;
    vector<ll> a(N), cnt(60, 0);
    ll res = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        res += a[i];
        for (int j = 0; j < 50; j++)
        {
            if ((a[i] >> j) & 1)
                cnt[j]++;
        }
    }
    for (int i = 0; (1LL << i) <= K; i++)
    {
        ll mask = 0;
        for (int j = i; j >= 0; j--)
        {
            if ((mask | (1LL << j)) <= K && 2 * cnt[j] < N)
            {
                mask |= (1LL << j);
            }
        }
        ll sum = 0;
        for (int j = 0; j < N; j++)
            sum += (a[j] ^ mask);
        res = max(res, sum);
    }
    cout << res << endl;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>

int p,q;
int data[85];
int encount[10000000];
int prev[90];
int main(void){
	while(~scanf("%d%d",&p,&q)){
		memset(encount,0,sizeof(encount));
		memset(data,0,sizeof(data));
		for(int i=1;i<=80;i++){
			p*=10;
			if(encount[p]==0)encount[p]=i,prev[i]=p;
			else if(encount[p]!=0){
				prev[i]=p;
				for(int j=1;j<i;j++)printf("%d",data[j]);
				printf("\n");
				for(int j=1;j<i;j++)printf("%c",(encount[p]<=j && j<i)?'^':' ');
				printf("\n");
				break;
			}
			data[i]=p/q;
			p=p%q;
			if(p==0){
				for(int j=1;j<=i;j++)printf("%d",data[j]);
				printf("\n");
				break;
			}
		}
	}
	return 0;
}

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

int main(int argc, char *argv[]){
  long long int n;
  while(cin >> n, n){
    long long int sche[n];
    vector<long long int> used(n, 0);
    memset(sche, 0, sizeof(sche));
    for (int i = 0; i < n; i++) {
      used[i] += (1LL << i);
      int x;
      cin >> x;
      for (int j = 0; j < x; j++) {
        int tmp;
        cin >> tmp;
        sche[i] |= 1 << (tmp - 1);
      }
    }

    int day;
    for (day = 0; day <= 30; day++) {
      for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
          if((sche[i]&(1LL << day)) && (sche[j]&(1LL << day))){
            used[i] = used[j] = (used[i] | used[j]);
          }
        }
      }
      if(find(used.begin(), used.end(), (1LL << n) - 1) != used.end()){
        std::cout << day + 1 << std::endl;
        break;
      }
    }
    if(day > 30){
      std::cout << -1 << std::endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1212
#include<cstdio>
#include<vector>
#include<map>
#include<algorithm>
#include<functional>
#include<iterator>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


struct v_t
{
	int p;
	vi c;
};


using vvt=vector<v_t>;


ll uni(vvt&v, ll ans, int n, int a, int b)
{
	a=v[a].p;
	b=v[b].p;
	if(a==b) return ans;

	ll an=v[a].c.size();
	ll bn=v[b].c.size();

	if(an<bn)
	{
		swap(a, b);
		swap(an, bn);
	}

	for(int mbc:v[b].c)
	{
		v[mbc].p=a;
	}
	v[a].c.resize(an+bn);
	copy(v[b].c.begin(), v[b].c.end(), v[a].c.begin()+an);
	v[b].c.clear();

	return ans-an*(n-an)-bn*(n-bn)+(an+bn)*(n-(an+bn));
}


int main(void)
{
	int n, m;

	while(scanf("%d%d", &n, &m)==2)
	{
		vi a(m), b(m);
		vector<v_t> v(n+1);
		vll ans(m+1);

		for(int i=1;i<=n;i++)
		{
			v[i].p=i;
			v[i].c.push_back(i);
		}

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

		ans[m]=(ll)n*(n-1);
		for(int i=m-1;i>=0;i--)
		{
			ans[i]=ans[i+1];
			ans[i]=uni(v, ans[i+1], n, a[i], b[i]);
		}
		for(int i=1;i<=m;i++)
		{
			printf("%lld\n", ans[i]/2);
		}
	}

	return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var vals = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var N = vals[0];
            var K = vals[1];
            vals = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            //累積和を計算
            var cumsum = new long[N];
            var tmp = (long)0;//最大値
            foreach(var i in Enumerable.Range(0, N))
            {
                tmp += vals[i];
                cumsum[i] = tmp;
            }

            //部分和
            var subsets = new List<long>();
            for(var i = 0; i<N; i++)
            {
                subsets.Add(cumsum[i]);
                for(var j=0; j<i; j++)
                {
                    subsets.Add(cumsum[i] - cumsum[j]);
                }
            }

            //最大値のビットは？
            var sisuu = (int)(Math.Log(tmp) / Math.Log(2.0) + 0.0000001);
            var result = (long)0;
            var tmp_array = subsets;
            for(var i = sisuu; i >= 0; i--)
            {
                var target = (long)Math.Pow(2, i);
                var hantei = tmp_array.Where(x => (target & x) != 0).ToList();
                if(hantei.Count >= K)
                {
                    result = result | target;
                    tmp_array = hantei;
                }
            }
            
            Console.WriteLine(result);
        } 
    }
}


Measured memory_bytes: 31804
import java.util.Scanner;


public class Main {


	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner sc = new Scanner(System.in);
		
		int num=sc.nextInt();
		int i,a,b,c;
		
		
		
		
		
		for(i=0;i<num;i++){
			a = sc.nextInt();
			b = sc.nextInt();
			c = sc.nextInt();
			
			if(a*a == ((b*b) + (c*c)) || b*b == ((a*a) + (c*c)) || c*c == ((a*a) + (b*b)))
			{
				System.out.println("YES");
			}
			else
			{
				System.out.println("NO");
			}
		}
	}

}

Measured memory_bytes: 23532
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep2(i, s, e) for(int i=s; i<e; i++)
#define print(i) cout << i << endl;

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


    int n; cin >> n;

    queue<int> que[n];
    rep(i, n){
        rep(j, n-1){
            int temp; cin >> temp;
            temp--;
            que[i].push(temp);
        }
    }

    int ans = 0;
    bool flag;
    list<int> li;

    rep(i, n-1){
        li.push_back(i);
    }

    list<int>::iterator itr;
    vector<list<int>::iterator> vitr;

    int cntcnt = 0;
    bool bigflag = false;
    while(true){

        ans++;
        flag = false;
        vector<int> vi, vto;
        vitr.clear();
        if(cntcnt++ > 200000){
            bigflag = true;
            break;
        }

        
        for(itr = li.begin(); itr != li.end(); itr++){
            int i = *itr;
            // cout << "i " << i << endl;
            if(que[i].empty()){
                vitr.push_back(itr);
                continue;
            }

            int to   = que[i].front();
            int from = que[to].front();
            if(from == i && i < to){
                // cout << i << " " << to <<  endl;
                vi.push_back(i);
                vto.push_back(to);
                // que[i].pop();
                // que[to].pop();
                flag = true;
            }
        }
        for(auto x : vitr){
            li.erase(x);
        }

        rep(i, vi.size()){
            // cout << vi[i] << " " << vto[i] << endl;
            que[vi[i]].pop();
            que[vto[i]].pop();
        }

        if(li.empty()){
            flag = true;
            break;
        }
        if(flag == false) break;
        if(bigflag == true) break;
    }

    if(bigflag){
        cout << n*(n-1)/2;
    }
    else{
        cout << (flag ? ans-1 : -1);
    }

    return 0;
}

Measured memory_bytes: 6784
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  int l[N];
  for(int i=0;i<N;i++) cin >> l[i];

  sort(l,l+N);
  reverse(l,l+N);

  int ans = 0;
  for(int i=0;i<K;i++){
    ans += l[i];
  }

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


Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((int64_t *)a) < *((int64_t *)b) ? -1 : 1;
}

int compare_f2(const void *a, const void *b) {
	return *((uint64_t *)a) > *((uint64_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
	uint64_t result = 1;

	for (uint64_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m%n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

static char s[200001];

int main(void) {
	size_t W, a, b;

	scanf("%zu %zu %zu", &W, &a, &b);

	if (ABSS(a, b) <= W) {
		puts("0");
	}
	else {
		printf("%zu\n", ABSS(a, b) - W);
	}

	return 0;
}


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

int main(){
    int N;
    cin >> N;

    //求めたい数
    int ans = 0;
    for (int i = 0; i < 8; i++) {
        if (N >= pow (2, i)) {
            ans = pow (2, i);
        }
    }

    cout << ans << endl;

    return 0;
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n, k;
int p[200005];
double sum[1010];
void solve() {
    cin >> n >> k;
    rep(i, n) cin >> p[i];
    reps(i, 1000) reps(j, i) {
        sum[i] += (double)j / i;
    }

    double res = 0, ans = 0;
    int pos = 0;
    rep(i, k) res += sum[p[i]];
    rep(i, n - k + 1) {
        maxs(ans, res);
        res -= sum[p[i]];
        res += sum[p[i + k]];
    }

    cout << ans << endn;

}

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		   int a,b,c;
           cin>>a>>b>>c;
           cout<<a+b+c-max(max(a,b),c)<<endl;
}

Measured memory_bytes: 3560
import static java.util.Arrays.deepToString;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	public void run() {
		for (;sc.hasNext();) {
			int n = sc.nextInt();
			for (int i = 0; i < n; i++) solve();
		}
	}
	void solve() {
		int price1 = sc.nextInt();
		int price2 = sc.nextInt();
		int need1 = sc.nextInt();
		int need2 = sc.nextInt();
		
		int ans = buy(price1, price2, need1, need2);
		for (int buy1 = need1; buy1 <= Math.max(need1, 5); buy1++) {
		for (int buy2 = need2; buy2 <= Math.max(need2, 2); buy2++) {
			int k = buy(price1, price2, buy1, buy2);
			if (ans > k) ans = k;
		}
		}
		System.out.println(ans);
	}
	
	int buy(int price1, int price2, int q1, int q2) {
		int k = price1 * q1 + price2 * q2;
		if (q1 >= 5 && q2 >= 2) k = k * 4 / 5;
		return k;
	}
}

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

int main()
{
	string s,s1;
	cin>>s;
	s1=s;
	char temp;
	long long len=s.size(),i,c=0;
	for(i=0;i<len/2;i++)
	{
		temp=s1[i];
		s1[i]=s1[len-i-1];
		s1[len-i-1]=temp;
	}
	if(s==s1)cout<<0;
	else
	{
		for(i=0;i<len;i++)
		{
			if(s[i]!=s1[i]){
			s[i]=s1[i];
			s1[len-i-1]=s[i];c++;
			}
		}
		cout<<c;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define MEM(x,y) memset(x,y,sizeof(x))
#define MOD(x) ((x)%mod)
#define mod 1000000007
#define pb push_back
#define STREAM_FAST ios::sync_with_stdio(false)
using namespace std;
const int maxn = 1e5 + 7;
LL a[maxn], b[maxn];
int main()
{
	int n; scanf("%d", &n);
    LL op = 1;
    for (int i = 1; i <= n; i++) 
    {
        scanf("%lld", &a[i]);
        b[1] += op * a[i];
        op = -op;
    }
    for (int i = 2; i <= n; i++) b[i] = 2 * a[i - 1] - b[i - 1];
    for (int i = 1; i <= n; i++) printf("%lld ", b[i]);
	return 0;
}


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

int main(){
  int N;
  string S;
  cin>>N>>S;
  if(N%2){
    cout<<"No";
  }
  else{
    string halfa,halfb;
    halfa=S.substr(0,N/2);
    halfb=S.substr(N/2);
    if(halfa==halfb){
      cout<<"Yes";
    }
    else{
      cout<<"No";
    }
  }
}

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

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

typedef vector<int> VI;

int cnt;
int num[8];

void solve(VI board, int depth)
{
	//end check
	if(depth == 8)
	{
		bool is_end = true;
		REP(i, board.size())
		{
			if(board[i] == 0)
			{
				is_end = false;
				break;
			}
		}
		
		if(is_end){
	 		cnt++;
			return;
		}
	}

	//normal procedure
	bool is_set = false;
	REP(y, 4)
	{
		REP(x, 4)
		{
			if(board[y*4+x] == 0)
			{
				REP(i, 4)
				{
					int dx = num[i*2+0];
					int dy = num[i*2+1];
					int xx = x + dx;
					int yy = y + dy;
					if(xx>=0 && yy>=0 && xx<4 && yy<4) 
					{
						if(board[yy*4+xx] == 0)
						{
							VI v = VI(16);
							memcpy(&v[0], &board[0], sizeof(int)*16);
							v[y*4+x] = depth+1;
							v[yy*4+xx] = depth+1;
							solve(v, depth+1);
						}
					}
				}
				is_set = true;
				break;
			}
		}
		if(is_set) break;
	}	
}
   
int main()
{
	while( 1 )
	{
		scanf("%d", &num[0]);
		if(num[0] > 4) break;
		
		for(int i=1; i<8; i++)
		{
			scanf("%d", &num[i]);
		}

		cnt = 0;
		VI v = VI(16);
		memset(&v[0], 0, sizeof(int)*16);
		solve(v, 0);

		printf("%d\n", cnt);
	}
}

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

int main() {
	int n;
	cin >> n;
	n %= 10;
	if (n == 3) cout << "bon" << endl;
	else if (n == 0 || n == 1 || n == 6 || n == 8) cout << "pon" << endl;
	else cout << "hon" << endl;
}

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

using namespace std;

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

    map<string,int > mp;

    for (int i = 0; i < n; ++i) {
        string x;
        cin >> x;
        mp[x]++;
    }
    
    int mx = 0;
    for (auto p: mp) {
        mx = max(p.second, mx);
    }

    for (auto p: mp) 
        if(mx == p.second) cout << p.first << "\n";
    return 0;
}


Measured memory_bytes: 25216
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<list>
using namespace std;

signed main(){
	int a, b;
	while (cin >> a >> b) {
		list<int>d, e, f;
		for (int g = 0; g < a; g++)f.push_back(g);
		for (int S = 0; S < b; S++) {
			int c; cin >> c;
			d.clear(); e.clear();
			auto k = f.begin();
			for (int g = 0; g < a/ 2; g++, k++) {
				e.push_back(*k);
			}
			for (int g = a/ 2; g < a; g++, k++) {
				d.push_back(*k);
			}
			f.clear();
			while (d.size() || e.size()) {
				for (int g = 0; g < c&&d.size(); g++) {
					f.push_back(d.front());
					d.pop_front();
				}
				for (int g = 0; g < c&&e.size(); g++) {
					f.push_back(e.front());
					e.pop_front();
				}
			}
		}
		cout << f.back() << endl;
	}
}

Measured memory_bytes: 3008
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
#include <utility>
#include <queue>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;
const dd PI = 3.1415926435;

class UnionFind
{
public:
    UnionFind(int N) : par(N)
    {
        for (ll i = 0; i < N; i++)
        {
            par[i] = i;
        }
    }

    int root(int x)
    {
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        par[rx] = ry;
    }

    bool same(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

private:
    vector<int> par;
};

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

ll fact(ll n)
{
    if (n == 0)
    {
        return 1;
    }
    if (n == 1)
    {
        return 1;
    }
    return n * fact(n - 1) % MOD;
}

ll pow_fast(ll n, ll k)
{
    if (k == 0)
    {
        return 1;
    }
    if (k == 1)
    {
        return n;
    }

    if (k % 2 == 0)
    {
        ll tmp = pow_fast(n, k / 2LL);
        return tmp * tmp % MOD;
    }
    else
    {
        ll tmp = pow_fast(n, k / 2LL);
        tmp *= tmp;
        tmp %= MOD;
        return tmp * n % MOD;
    }
}

map<ll, ll> sosuu(ll n)
{
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            res[i] += 1;
            n /= i;
        }
    }
    if (n != 1)
    {
        res[n] += 1;
    }
    return res;
}

int main()
{
    string S;
    cin >> S;
    bool ok = false;
    bool ok2 = false;
    bool ok3 = true;

    if (S[0] == 'A') {
        ok = true;
    }

    for (ll i = 2; i < S.size() - 1; i++)
    {
        if (ok2 && S[i] == 'C') {
            ok2 = false;
            break;
        }
        if (S[i] == 'C') {
            ok2 = true;
        }
    }

    for (ll i = 0; i < S.size(); i++)
    {
        if (i == 0 || S[i] == 'C') {
            continue;
        }
        if ('a' > S[i] || S[i] > 'z') {
            ok3 = false;
        }
    }
    if (ok && ok2 && ok3) {
        cout << "AC" << endl;
    } else {
        cout << "WA" << endl;
    }
    
}

Measured memory_bytes: 256
k=input()
a=0
if k[0]=='R':
    if k[1]=='R':
        if k[2]=='R':
            a=3
        else:
            a=2
    else:
        a=1
elif k[1]=='R':
    if k[2]=='R':
        a=2
    else:
        a=1
elif k[2]=='R':
    a=1
print(a)


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

int main(){
    int n;
    cin >> n;
    int l[n];
    for(int i=0;i<n;i++)cin >> l[i];
    sort(l,l+n);
    int a=0;
    for(int i=0;i<n-1;i++)a+=l[i];
    if(l[n-1]<a){
        cout << "Yes" << endl;
        return 0;
    }
    else{
        cout << "No" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long N = lread();
    long n = N % 10;
    auto ans = [
        "pon", "pon", "hon", "bon", "hon", "hon", "pon", "hon", "pon", "hon"
    ];
    writeln(ans[n]);
}


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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> mi(N,10101010);
  int a,b;
  
  for (int i=0; i<M; i++) {
    cin >> a >> b;
    mi[a-1] = min(mi[a-1],b-1);
  }
  
  int ans = 0;
  for (int i=0; i<N-1; i++) {
    if (mi[i] == i+1) {
      ans++;
    }
    else {
      mi[i+1] = min(mi[i+1],mi[i]);
    }
  }
  
  cout << ans << endl;
    
    
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
		#include<unordered_map>	
		#include<unordered_set>
		#define pb emplace_back
		#define rt(v) return cout<<v,0
		#define sz(v) (int)(v.size())
		#define all(a) a.begin(),a.end()
		#define endl '\n'
		#define space " "
		typedef long long ll;
		typedef unsigned long long ull;
		const int N = 10 + 1e5;
		const int mod = 1e9 + 7;
		/*

		███╗   ███╗███████╗███╗   ███╗███████╗    ██╗      ██████╗ ██████╗ ██████╗
		████╗ ████║██╔════╝████╗ ████║██╔════╝    ██║     ██╔═══██╗██╔══██╗██╔══██╗
		██╔████╔██║█████╗  ██╔████╔██║█████╗      ██║     ██║   ██║██████╔╝██║  ██║
		██║╚██╔╝██║██╔══╝  ██║╚██╔╝██║██╔══╝      ██║     ██║   ██║██╔══██╗██║  ██║
		██║ ╚═╝ ██║███████╗██║ ╚═╝ ██║███████╗    ███████╗╚██████╔╝██║  ██║██████╔╝
		╚═╝     ╚═╝╚══════╝╚═╝     ╚═╝╚══════╝    ╚══════╝ ╚═════╝ ╚═╝  ╚═╝╚═════╝

		*/
		//
		int m1[150][150];
		int m2[150][150];
		using namespace std;
		void Ferrari() {
			ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
		}
	
		int main() {
			Ferrari();
			vector<int>divs;
			int a, b, k; cin >> a >> b >> k;
			for (int i = 1; i * i <= a; ++i) {
				if (a % i == 0)
				{
					divs.push_back(i);
					if (a / i != i) divs.push_back(a / i);
				}
			}
			sort(all(divs));
			vector<int>com;
			for (int i = 1; i * i <= b; ++i) {
				if (b % i == 0) {
					if (binary_search(all(divs), i))
						com.push_back(i);
					if (b / i != i)
						if (binary_search(all(divs), b / i))
							com.push_back(b / i);
				}
			}
			sort(all(com), greater<int>());
			cout << com[k - 1];
			return 0;
		}
		   

	


		/* stuff you should look for
			* keepin sharp mind.
			* int overflow, array bounds.
			* special cases (n=1?), set tle , make sure you understand the proble correctly.
			* don`t stuck in a problem.
			* test the idea on samples.
			*/

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,q;
    cin >> n;
    int s[n];
    int c=0;
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    cin >>q;
    int t[q];
    for(int i=0;i<n;i++){
        cin >> t[i];
    }
    for(int i=0;i<q;i++){
        for(int j=0;j<n;j++){
            if(t[i]==s[j]){
                c++;
                break;
            }
        }
    }cout << c << endl;
}


Measured memory_bytes: 3104
import math
import sys
from decimal import *

fin = sys.stdin.readline
A, B, C, D = [Decimal(elem) for elem in fin().split()]


# A以上B以下のCの倍数の個数
def warikiru(A, B, C):
    return (B // C) - math.ceil(A / C) + 1


# 最大公約数
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


# 最小公倍数
def lcm(a, b):
    return (a * b) // gcd(a, b)


warikiru_num = warikiru(A, B, C) + warikiru(A, B, D) - warikiru(A, B, lcm(C, D))

print(int(B - A + 1 - warikiru_num))


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

int main() {
    

    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    //Write code below
    
    int a, b;
    
    cin >> a >> b;
    
    cout << max({a + b, a - b, a * b}) << endl;
}


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

using namespace std;

int main()
 {
    int x;
    cin >> x;
    auto y = x / 100;
    auto z = x % 100;

    for (int a5 = 0; a5 < 1000000; a5++) {
        if (a5 > y)
            break;
        for (int a4 = 0; a4 < 1000000; a4++) {
            if ((a5 + a4) > y)
                break;
            for (int a3 = 0; a3 < 1000000; a3++) {
                if ((a5 + a4 + a3) > y)
                    break;
                for (int a2 = 0; a2 < 1000000; a2++) {
                    if ((a5 + a4 + a3 + a2) > y)
                        break;
                    for (int a1 = 0; a1 < 1000000; a1++) {
                        if ((a1 + a2 + a3 + a4 + a5) > y)
                            break;
                        auto a = a1 + a2 * 2 + a3 * 3 + a4 * 4 + a5 * 5;
                        if (a == z) {
                            cout << 1 << endl;
                            return 0;
                        }
                    }
                }
            }
        }
    }
    cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 384
#coding: UTF-8
A, B = map(int, input().split())
#最大公約数を求めるため互除法を使用
def GCD(M, N):
  if M > N:
    L = N
    N = M
    M = L
  m, n = M, N
  r = n % m
  while r != 0:
    n = m
    m = r
    r = n % m
  return(m)
#素因数分解関数を作成
def factorize(N):
  b = 2
  fct = []
  while b ** 2 <= N:
    while N % b == 0:
      N //= b
      fct.append(b)
    b += 1
  if N > 1:
    fct.append(N)
  return(fct)
#AとBの最大公約数の素因数の種類を抽出
key = set(factorize(GCD(A, B)))
#選ぶべき数の組み合わせはkeyに1を加えたもの
print(len(key) + 1)

Measured memory_bytes: 3064
# coding=utf-8

def solve(i, m):
    global A
    if ever_calc[i][m] != None:
        return ever_calc[i][m]
    if m == 0:
        ever_calc[i][m] = True
        return True
    elif m < 0:
        ever_calc[i][m] = False
        return False
    elif i == n:
        ever_calc[i][m] = False
        return False
    else:
        result = (solve(i+1, m) or solve(i+1, m-A[i]))
        ever_calc[i][m] = result
        return result

n = int(input())
A = tuple(map(int, input().split()))
q = int(input())
M = tuple(map(int, input().split()))
sum_A = sum(A)
ever_calc = [[None] * 2000 for i in range(n+1)]

for m in M:
    if m > sum_A:
        print('no')
    elif solve(0, m):
        print('yes')
    else:
        print('no')

Measured memory_bytes: 8024
using System;
class a{
  public static void Main(){
    int n = int.Parse(Console.ReadLine());
    double sum = 0;
    string[] str = Console.ReadLine().Split(' ');
    int[] b = new int[n];
    for (int i = 0; i < n; i++)
    {
      b[i] = int.Parse(str[i]);
      sum += (double)1 / b[i];
    }
    Console.WriteLine(1 / sum);
  }
}
      

Measured memory_bytes: 11220
//Heaplax
#include<bits/stdc++.h>
#define int long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
int n,a,b,c,d,f;
main()
{
	re(n),re(a),re(b),re(c),re(d);
	f=abs(a-b);
	for(int i=0;i<n;++i)
		if(c*(n-1-i)-d*i<=f && f<=-c*i+(n-1-i)*d)
			return puts("YES"),0;
	puts("NO");
}


Measured memory_bytes: 256
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    n = IS()
    if n[0]=='7' or n[1]=='7' or n[2]=='7': print('Yes')
    else: print('No')

if __name__ == '__main__':
    main()


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll = long long;
using P = pair<int, int>;

const double PI = 3.14159265358979;

// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
  vector<pair<ll,int>> factor(ll x) {
    vector<pair<ll,int>> res;
    for (int p : primes) {
      int y = 0;
      while (x%p == 0) x /= p, ++y;
      if (y != 0) res.emplace_back(p,y);
    }
    if (x != 1) res.emplace_back(x,1);
    return res;
  }
};

void solve()
{
  Sieve si(100000);

  vector<int> pr(100001, 0);
  for(int i = 3; i <= 100000; ++i)
  {
    pr[i] += pr[i - 1];
    if (si.isPrime(i) && si.isPrime((i + 1) / 2)) pr[i]++;
  }

  int q, l, r;
  cin >> q;
  for(int i = 0; i < q; ++i)
  {
    cin >> l >> r;
    cout << pr[r] - pr[l - 1] << endl;
  }  


}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 4244
#include<stdio.h>

int main()
{
    char a[3];

    int c=0;
    for(int i=0;i<3;i++){
        scanf("%c",&a[i]);
    }
    for(int i=0;i<3;i++){
        if(a[i]=='1'){
            c++;
        }
    }
    printf("%d\n",c);


}

Measured memory_bytes: 128
h, n = [int(i) for i in input().split()]

ab = []
for i in range(n):
    ab.append([int(i) for i in input().split()])

mp = [float("inf") for i in range(h+1)]
mp[0] = 0

for i in range(h):
    for j in range(n):
        if i + ab[j][0] >= h:
            mp[h] = min(mp[h], mp[i]+ab[j][1])
        else:
            mp[i+ab[j][0]] = min(mp[i+ab[j][0]], mp[i] + ab[j][1])

print(mp[-1])

Measured memory_bytes: 43868
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
    cin >> N;
    int list[N][3];
    for(int i = 0; i<N; i++) cin >> list[i][0] >> list[i][1] >> list[i][2];
    int dp[N][3];

    dp[0][0] = list[0][0];
    dp[0][1] = list[0][1];
    dp[0][2] = list[0][2];

    for(int i = 1; i<N; i++) {
        dp[i][0] = max(dp[i - 1][1],dp[i - 1][2]) + list[i][0];
        dp[i][1] = max(dp[i - 1][0],dp[i - 1][2]) + list[i][1];
        dp[i][2] = max(dp[i - 1][0],dp[i - 1][1]) + list[i][2];
    }
    int ans = max(dp[N - 1][0], dp[N - 1][1]);
    ans = max(ans, dp[N - 1][2]);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int cnt[10010];

int main()
{

    int n;

    while(scanf("%d",&n)!=EOF)
    {
        memset(cnt,0,sizeof(cnt));
        int a;
        for(int i=0;i<n;i++)
        {
            scanf("%d",&a);
            cnt[a]++;
        }

        bool flag=false;
        for(int i=0;i<10010;i++)
        {
            while(cnt[i])
            {
                if(flag)
                {
                    printf(" ");
                }
                printf("%d",i);
                flag=true;
                cnt[i]--;
            }
        }
        printf("\n");
    }



    return 0;
}



Measured memory_bytes: 3272
#include <cstdio>

int main() {
    int W,H,x,y,r;
    scanf("%d %d %d %d %d", &W,&H,&x,&y,&r);
    bool hoge,piyo;
    if (x>=r && x<=W-r && y>=r && y<=H-r) {printf("Yes\n");}
    else printf("No\n");
}


Measured memory_bytes: 2616
#![allow(non_snake_case)]
#![allow(unused_imports)]
 
use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;

#[fastout]
fn main() {
    input!{
        a: u64,
        b: f64,
    }

    let b = bigint::BigUint::from_u64((b * 1000.0) as u64).unwrap();
    let a = bigint::BigUint::from_u64(a).unwrap();

    println!("{}", a * b / bigint::BigUint::from_u64(1000).unwrap())
}


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

using namespace std;

int main()
{
  string s,s1;
  cin>>s>>s1;
  int c=0;
  for(int i=0;i<s.size();i++)
  {
    if(s[i]!=s1[i])c++;
  }
  cout<<c<<endl;

}

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

int main()
{
  string s;
  cin>>s;

  vector<int> a(4);
  for(int i=0; i<4; i++){
    a[i] = s[i] - '0';
  }

  bool ok = false;
  vector<char> op(3);
  for(int tmp=0; tmp<(1<<3); tmp++){
    long long sum = a[0];
    for(int j=2; j>=0; j--){
      long long t = a[3-j];
      if(tmp & (1<<j)){  // 1 のとき'+'
        sum += t;
        op[2-j] = '+';
      }
      else{
        sum -= t;
        op[2-j] = '-';
      }
    }
    if(sum == 7){
      ok = true;
      break;
    }
  }

  for(int i=0; i<3; i++){
    cout<<a[i]<<op[i];
  }
  cout<<a[3]<<"=7"<<endl;
  return 0;
}


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

int main()
{
    int l,r,d,i,j,k=0;
    cin>>l>>r>>d;
    for(i=l;i<=r;i++)
    {
        if(i%d==0)
        {
            k++;
        }
    }
    cout<<k<<endl;
    
     
}


Measured memory_bytes: 3560
#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 rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    vector<vector<int> > a(3, vector<int>(3));
    vector<vector<bool> > c(3, vector<bool>(3));
    rep (i, 3) rep (j, 3) cin >> a[i][j];
    int n;
    cin >> n;
    rep (i, n) {
        int b;
        cin >> b;
        rep (j, 3) {
            rep (k, 3) {
                if (b == a[j][k]) c[j][k] = true;
            }
        }
    }
    bool ok = false;
    rep (i, 3) {
        bool t = true;
        rep (j, 3) {
            if (!c[i][j]) t = false;
        }
        if (t) ok = true;
    }
    rep (j, 3) {
        bool t = true;
        rep (i, 3) {
            if (!c[i][j]) t = false;
        }
        if (t) ok = true;
    }
    if ((c[0][0] && c[1][1] && c[2][2]) || (c[0][2] && c[1][1] && c[2][0])) ok = true;
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    
    return 0;
}



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

// macros
#define int long long 
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef long double ld;

// template functions
template < typename A, typename B >
ostream &operator << ( ostream& os, const pair< A, B > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "{";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename A, typename B >
ostream &operator << ( ostream & os, const map< A, B > &v ) {
    os << "[";
    typename map< A, B >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " -> " << it -> second ;
    }
    return os << "]";
}
template<typename T>
T gcd(T a, T b) { if(a==0 or b==0) return a+b; return gcd(b, a%b) ; }
template<typename T>
T lcm(T a, T b) { if(a==0 or b==0) return 0; return a/gcd(a, b)*b; }

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// constants
const long double eps = LDBL_EPSILON;
const int inf = 1e15;
const int modn = 1e9+7;
const int maxn = 2e5+3;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
    int n;
    cin>>n;
    vvi a(n, vi(3));
    for(int i=0; i<n; i++) {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    vi dp(3);
    for(int i=0; i<n; i++) {
        vi dp2(3);
        for(int j=0; j<3; j++) {
            for(int jj=0; jj<3; jj++) {
                if(jj==j) continue;
                dp2[j] = max(dp2[j], a[i][j] + dp[jj]);
            }
        }
        swap(dp, dp2);
    }
    cout << max(dp[0], max(dp[1], dp[2])) << "\n";
    return 0;
}



Measured memory_bytes: 5760
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i): is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#
def main():
    s = IS()
    n = len(s)
    m = n-7
    for i in range(0,n-m):
        if s[:i]+s[i+m:] == 'keyence':
            print('YES')
            return None
    print('NO')

if __name__ == '__main__':
    main()

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

bool notallowed[10];

 bool check(int n)
 {
   while(n>0)
   {
     if(notallowed[n%10])
     { 
       return true;
     }
     n/=10;
   }
  return false;
 }
int main()
{
  int n,k,temp;
  cin>>n>>k;
   while(k)
   {
     cin>>temp;
     notallowed[temp]=true;
     k--;
   }
  while(check(n))
  {
 	 n++;
  }
  cout<<n;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
using namespace std;

int main() {
	int n, ans = 300000,sum[300001];
	cin >> n;
	sum[0] = 0;
	for (int i = 0; i < n; i++) {
		char c;
		cin >> c;
		sum[i + 1] = sum[i] + (c == 'E' ? 0 : 1);
	}
	for (int i = 0; i < n; i++) {
		ans = min(ans, sum[i] + (n-i-1)-(sum[n] - sum[i + 1]));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int n = sc.nextInt();
            if(n == 0) break;
            int[] s = new int[n];
            int sum = 0;
            for(int i = 0; i < n; i++){
                s[i] = sc.nextInt();
                sum += s[i];
            }
            double average = (double)sum / n;
            double variance = 0;
            for(int i = 0; i < n; i++){
                variance += (s[i] - average)*(s[i] - average)/n;
            }
            System.out.println((Math.sqrt(variance)));
        }
        sc.close();
    }
}



Measured memory_bytes: 31680