akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

// 二分探索ライブラリを作ったので

ll N, K;
vector<ll> A, F;

bool C1(ll x){
    ll cnt = K;
    for (int i = 0; i < N; ++i) {
        ll diff = A[i] - (x / F[i]);
        if(diff > 0) cnt -= diff;
        if(cnt < 0) return false;
    }
    return true;
}

// 開区間と判定関数を引数にして条件を満たす境界値を返す
ll BiSearch(ll ok, ll ng, function<bool(ll)> C){
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        if (C(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main() {
    cin >> N >> K;
    A.resize(N); F.resize(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    for (int i = 0; i < N; ++i) cin >> F[i];
    sort(A.begin(), A.end());
    sort(F.begin(), F.end(), greater<ll>());
    cout << BiSearch(1LL<<62, -1, C1) << "\n";
    return 0;
}

Measured memory_bytes: 3328
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


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

def calc_num(X, C, D, E):
    return X - (X/C + X/D - X/E)

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [A, B, C, D] = [long(input_raw[0]), long(input_raw[1]), long(input_raw[2]), long(input_raw[3])]
    E = lcm(C, D)
    print calc_num(B, C, D, E)  - calc_num(A - 1, C, D, E)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2936
using System;
using System.Linq;

namespace CF2016AC{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            var S = sr.Next<string>().Select(c => c - 'a').ToArray();
            var K = sr.Next<int>();

            for(var i = 0; i < S.Length - 1; i++){
                if(S[i] != 0 && 26 - S[i] <= K){
                    K -= 26 - S[i];
                    S[i] = 0;
                }
            }
            S[S.Length - 1] += K;

            Console.WriteLine(S.Select(x => (char)(x % 26 + 'a')).ToArray());
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];
        private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = _sr.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var ret = new T[x];
            for(var i = 0; i < x; ++i) ret[i] = Next<T>();
            return ret;
        }

        public T[][] Next<T>(int y, int x){
            var ret = new T[y][];
            for(var i = 0; i < y; ++i) ret[i] = Next<T>(x);
            return ret;
        }
    }
}

Measured memory_bytes: 6104
#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 all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

bool bridge[51][51];
bool jud[51];
int a[51];
int b[51];

void dfs(int a, int n) {
	jud[a] = true;
	rep(i, n) {
		if (i == a) continue;
		if (jud[i]) continue;
		if (!bridge[a][i]) continue;
		dfs(i, n);
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	rep(i, m) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		bridge[a[i]][b[i]] = true;
		bridge[b[i]][a[i]] = true;
	}
	int ans = 0;
	rep(i, m) {
		bridge[a[i]][b[i]] = false;
		bridge[b[i]][a[i]] = false;
		rep(i, n) jud[i] = false;
		dfs(0, n);
		bool elf = true;
		rep(i, n) if (!jud[i]) elf = false;
		if (!elf) ans++;
		bridge[a[i]][b[i]] = true;
		bridge[b[i]][a[i]] = true;
	}
	dunk(ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <queue>

using namespace std;


int main () {
	int A, B, K;
	cin >> A >> B >> K;
	bool flag = 1;
	for(int i = 0; i<K; i++){
		if(flag){
			if (A%2 == 1){
				A--;				
			}
			A = A/2;
			B = B+A;
		}
		else{
			if (B%2 == 1){
				B--;				
			}
			B = B/2;
			A = A+B;		
		}
		flag = 1-flag;
	}
	cout << A << " " << B << endl;	
	return 0;
}

Measured memory_bytes: 256
/*-------enazuma11----------------*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define F first
#define S second
#define M 1000000007
 
/* int x[]={-1,-1,0,1,1,1,0,-1};
int y[]={0,1,1,1,0,-1,-1,-1};
*/
/* int x[]={-1,0,1,0};
int y[]={0,1,0,-1};
*/
const int N=3e5+5;
vector<ll> g[N];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		ll n;
		cin>>n;
		ll a[n];
		ll i,j;
		rep(i,0,n)
		{
			cin>>a[i];
		}
		ll dp[n];
		dp[0]=0;
		rep(i,1,n)
		{
			if(i==1)
			{
				dp[i]=abs(a[i]-a[i-1]);
			}else{
				dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
				if(i-2>=0)
				dp[i]=min(dp[i-2]+abs(a[i-2]-a[i]),dp[i]);
			}
		}
		cout<<dp[n-1]<<'\n';
	}
	return 0;
}


Measured memory_bytes: 8832
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define repi(i,a) for(auto i = a.begin(); i!= a.end() ;++i) 
#define repdi(i,a) for(auto i = a.begin(); i!=a.end();++i) 
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define INF 1e18
#define sz(a) (ll)a.size() 
#define all(a) a.begin(),a.end()
#define M 998244353
#define limit 100000000

typedef vector<ll> vll;
typedef pair<ll,ll> pii;
typedef vector<pii> vpi;
typedef vector<vector<ll> > vv;

void solve() {
	
	int n,m; cin >> n >> m;
	int s=0;
	rep(i,0,m) {
		int t; cin >> t;
		s+=t;
	}
	if(s>n) cout << "-1";
	else cout << n-s ;
}


int main() {

    fast;
	int t=1;
	// cin>>t;
	rep(i,0,t) {
		solve() ;
	}
	return 0;
}

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

int n, a[50];

int solve(int i, int m){
  if (m == 0) return 1;
  if (i >= n) return 0;
  int res = solve(i + 1, m) || solve (i + 1, m - a[i]);
  return res;
}

int main(){
  int q, m, i;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  scanf("%d", &q);
  for(i = 0; i < q; i++){
    scanf("%d", &m);
    if (solve(0, m)) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}



Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
int n,m;
const long long N=1<<13;
long long dp[N];
int main() {
	memset(dp,0x3f,sizeof(dp));
	scanf("%d%d",&n,&m);
	for(int i=1; i<=m; i++) {
		long long val,tot;
		cin>>val>>tot;
		long long bit=0;
		for(int j=1; j<=tot; j++) {
			long long x;
			cin>>x;
			bit+=(1<<(x-1));
		}
		dp[bit]=min(dp[bit],val);
	}
	long long s=(1<<n)-1;
	for(int i=1; i<=s; i++)
		for(int j=1; j<=s; j++)
			dp[i|j]=min(dp[i|j],dp[i]+dp[j]);
	if(dp[s]==0x3f3f3f3f3f3f3f3f)cout<<-1<<endl;
	else cout<<dp[s]<<endl;
	return 0;
}

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

int main(){
    string s, t;
    int a = 0;
    cin >> s >> t;
    if(s[0] == t[0])a++;
    if(s[1] == t[1])a++;
    if(s[2] == t[2])a++;
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
N,K = map(int, input().split())
cnt = 0
while 2**cnt < K:
    cnt += 1
result = ((1/2)**cnt)/N
for i in range(2,N+1):
    while (2**cnt)+(2**cnt)*(i-1) >= K and cnt >= 0:
        cnt -= 1
    if cnt == -1:
        result += (N-i+1)/N
        break
    cnt += 1
    result += ((1/2)**cnt)/N
print(result)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
using namespace std;
const double EPS = 1e-9;

int main() {
    double a, b, c, d, e, f;
    while (cin >> a >> b >> c >> d >> e >> f) {
        double x = (c * e - b * f) / (a * e - b * d);
        double y = (c - a * x) / b;
        printf("%.3f %.3f\n", x + EPS, y + EPS);
    }
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)

#define MAX_DM 1000000

int N, M, HP[111];
vector< int > singleMP, allMP;
vector< int > singleDM, allDM;

int singleDP[MAX_DM], allDP[MAX_DM];
const int INF = (int)1e9;

int main() {
	while (cin >> N, N) {
		for_(i,0,N) cin >> HP[i];
		
		string dumy, type;
		cin >> M;
		
		singleMP.clear(); allMP.clear();
		singleDM.clear(); allDM.clear();
		
		for_(i,0,M) {
			int MP, DM;
			cin >> dumy >> MP >> type >> DM;
			
			DM = min(DM, 100000);
			if (DM == 0) continue;
			
			if (type == "All") {
				allMP.push_back(MP);
				allDM.push_back(DM);
			} else {
				singleMP.push_back(MP);
				singleDM.push_back(DM);
			}
		}
		
		// single DP
		int S = singleMP.size();
		fill(singleDP, singleDP + MAX_DM, INF);
		singleDP[0] = 0;
		
		for_(i,0,S) {
			int DM = singleDM[i], MP = singleMP[i];
			
			for_(j,DM,MAX_DM) {
				singleDP[j] = min(singleDP[j], singleDP[j - DM] + MP);
			}
		}
		
		vector< int > smp(MAX_DM, singleDP[MAX_DM-1]);
		for_rev(d,MAX_DM-2,0) smp[d] = min(smp[d + 1], singleDP[d]);
		
		// all DP
		int A = allMP.size();
		fill(allDP, allDP + MAX_DM, INF);
		allDP[0] = 0;
		
		for_(i,0,A) {
			int DM = allDM[i], MP = allMP[i];
			
			for_(j,DM,MAX_DM) {
				allDP[j] = min(allDP[j], allDP[j - DM] + MP);
			}
		}
		
		vector< int > amp(MAX_DM, allDP[MAX_DM-1]);
		for_rev(d,MAX_DM-2,0) amp[d] = min(amp[d + 1], allDP[d]);
		
		int ans = INF;
		
		for_(d,0,MAX_DM) {
			int sum = amp[d];
			
			for_(i,0,N) if (HP[i] - d > 0) {
				sum += smp[HP[i] - d];
				sum = min(sum, INF);
			}
			
			ans = min(ans, sum);
		}
		
		cout << ans << endl;
	}
}

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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

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

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

template<class T>
bool chmax(T &a, initializer_list<T> l)
{
	return chmax(a, *max_element(l.begin(), l.end()));
}

template<class T>
bool chmin(T &a, initializer_list<T> l)
{
	return chmin(a, *min_element(l.begin(), l.end));
}


const ll MAX_N = 15;
const ll MAX_M = 1010;
ll dp[1ll<<MAX_N][MAX_M];
ll A[MAX_M]{};
ll B[MAX_M]{};
ll C[MAX_M]{};

int main(int argc, char **argv)
{
	ll N, M; cin >> N >> M;
	REP(m, M)
	{
		cin >> A[m] >> B[m];
		REP(c, B[m])
		{
			ll t; cin >> t;
			--t;
			C[m] |= (1ll<<t);
		}
	}

	ll BMAX = 1ll<<N;

	REP(b, BMAX) REP(m, MAX_M) dp[b][m] = INF;
	**dp = 0;


	REP(b, BMAX)
	{
		REP(m, M)
		{
			chmin(dp[b][m+1], dp[b][m]);
			ll tmp = b | C[m];
			chmin(dp[tmp][m+1], dp[b][m] + A[m]);
		}
	}

	ll res = dp[BMAX-1][M];
	std::cout << (res == INF ? -1 : res) << std::endl;
	
}


Measured memory_bytes: 33024
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
#define MOD int(1e9 + 7)

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

    long long cx = 0, cy = 0, ct = 0;
    for (long long i = 0; i < N; i++)
    {
        long long t, x, y;
        cin >> t >> x >> y;

        long long d = abs(x - cx) + abs(y - cy);
        if (t - ct >= d && (t - ct - d) % 2 == 0)
        {
            cx = x;
            cy = y;
            ct = t;
        }
        else
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
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();
		int n = fs.nextInt();
		int m = fs.nextInt();
		
		ArrayList<Set<Integer>> setList = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			setList.add(new HashSet<>());
			setList.get(i).add(i);
		}
		
		for(int i = 0; i < m; i++) {
			int a = fs.nextInt()-1;
			int b = fs.nextInt()-1;
			
			Set<Integer> aSet = setList.get(a);
			Set<Integer> bSet = setList.get(b);
			
			if(aSet == bSet) {
				continue;
			}
			
			Set<Integer> smallSet;
			Set<Integer> bigSet;
			
			if(aSet.size() < bSet.size()) {
				bigSet = bSet;
				smallSet = aSet;
			}else {
				bigSet = aSet;
				smallSet = bSet;
			}
			
			bigSet.addAll(smallSet);
			for(Integer human : smallSet) {
				setList.set(human.intValue(), bigSet);
			}
		}
		
		int biggestSetSize = 0;
		for(int i = 0; i < n; i++) {
			biggestSetSize = Math.max(setList.get(i).size(), biggestSetSize);
		}
		
		System.out.println(biggestSetSize);
	}

	

	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: 105772
import math
from functools import reduce
import numpy as np
from itertools import combinations
def gcd(*numbers):
    return reduce(math.gcd, numbers)
def gcd_list(numbers):
    return reduce(math.gcd, numbers)

s = int(input())
qwe = np.arange(s+1)

sum = (1+s)*s/2

for i in range(1, s+1):
    for j in range(i + 1, s+1):
        sum += gcd(i, j, j) * 3
        sum += gcd(i, i, j )* 3
        # print(i, j)
        for k in range(j + 1, s+1):
            sum += gcd(i, j, k) * 6
            # print(i, j, k)
print(int(sum))



Measured memory_bytes: 27140
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int a[3][3];
bool af[3][3];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	REP(i,3) REP(j,3){
		af[i][j] = false;
		cin >> a[i][j];
	}
	int n;
	cin >> n;
	REP(i,n){ 
		int b;
		cin >> b;
		REP(i,3) REP(j,3){
			if(b==a[i][j]) af[i][j] = true;
		}
	}
	bool ans = false;
	REP(i,3){
		bool f1 = af[i][0] && af[i][1] && af[i][2];
		if(f1) ans = true;
	}
	REP(j,3){
		bool f2 = af[0][j] && af[1][j] && af[2][j];
		if(f2) ans = true;
	}
	if(af[0][0] && af[1][1] && af[2][2]) ans = true;
	if(af[0][2] && af[1][1] && af[2][0]) ans = true;
	cout << (ans ? "Yes\n" : "No\n");
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<long, long> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const LL MOD=1e9+7;


int X[11][11];
int main(){
    LL L,R;
    cin>>L>>R;
    LL tmp=2019;
    bool flag=false;
    while(tmp<=R){
        if(L<=tmp&&tmp<=R)flag=true;
        tmp+=2019;
    }
    if(flag){
        cout<<0<<endl;return 0;
    }
    LL res=2018;
    FOR(i,L,R)FOR(j,i+1,R+1){
        LL tmp2=i*j%2019LL;
        res=min(res,tmp2);
    }
    cout<<res<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  
  int K,N; cin>>K>>N;
  if(K%2==0){
    cout<<K/2<<" ";
    rep(i,N-1) cout<<K<<(i==N-2?'\n':' ');
  }else{
    vector<int> ans(N,K/2+1);
    int cnt=N/2,r=N-1;
    while(cnt--){
      ans[r]--;
      if(ans[r]>0){
        for(int i=r+1;i<N;i++) ans[i]=K;
        r=N-1;
      }else r--;
    }
    rep(i,N){
      if(ans[i]==0) break;
      else cout<<ans[i]<<" ";
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 3456
N = int(input())
H = list(map(int, input().split()))
cnt = ans = 0

for i in range(1, N):
  if H[i-1] < H[i]:
    ans = max(ans, cnt)
    cnt = 0
  elif H[i-1] >= H[i]:
    cnt += 1

print(max(ans, cnt))

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
bool dp[2005];
int main(){
	int n,q,m;
	cin>>n;
	int A[n];
	for(int i=1;i<=n;i++)
		scanf("%d",&A[i]);
	memset(dp,0,sizeof(dp));
	dp[0] = dp[A[1]] = 1;
	for(int i=2;i<=n;i++)
		for(int j=2000;j>=A[i];j--)
			dp[j] += dp[j-A[i]];
	cin>>q;
	for(int i=1;i<=q;i++){
		scanf("%d",&m);
		printf("%s\n",(dp[m]?"yes":"no"));
	}
    return 0;
}


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

using namespace std;

int main(int argc, char *argv[])
{
    
    
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);

    int n, temp;
    long sum;
    vector<int> a;
    cin >> n;
    sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> temp;
        a.push_back(temp);
        sum += temp;
    }
    cout << *min_element(a.begin(), a.end()) << ' ';
    cout << *max_element(a.begin(), a.end()) << ' ';
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 3332
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)
#define l_ength size

ll sq(ll x){
	return x*x;
}

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

bool isvowel(char c){
	int i;
	string v="aeiou";
	for(i = (v.size()-1); i>=0; --i){
		if(c == v[i]){
			return true;
		}
	}
	return false;
}

int main(void){
	char a,b;
	cin >> a >> b;
	cout << ((a==b)?"H":"D") << endl;
	return 0;
}

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

using namespace std;

int n;
int counter;

void dfs(vector<vector<int>> &G, int s, int depth, vector<bool> &seen) {
	if (depth == n) {

		counter++;
		return;
	}

	for (int i = 0; i < G[s].size(); i++) {
		if (seen[G[s][i]] == true) {
			continue;
		}
		seen[G[s][i]] = true;
		dfs(G, G[s][i], depth+1, seen);
		seen[G[s][i]] = false;

	}

}

int main() {
	int m;
	cin >> n >> m;
	counter = 0;
	vector < vector<int>> G(n + 1);

	//グラフ隣接リスト読み込み
	int a, b;
	for (int i = 1; i <= m; i++) {
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	int depth = 1;
	vector<bool> seen(n + 1, false);
//	for (int i = 1; i <= n; i++) {
	int i = 1;
//	if (seen[i]) { continue; }
		seen[i] = true;
		dfs(G, i, depth, seen);
//	}

	cout << counter << endl;
	return 0;

}

Measured memory_bytes: 3600
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
//		long[] a = new long[n];
		long sum = 0;
		long min = Long.MAX_VALUE;
		int c = 0;
		for (int i = 0; i < n; i++) {
			long a = scan.nextLong();
			if (a < 0) {
				c++;
				a *= -1;
			}
			min = Math.min(a, min);
			sum += a;
		}
		if (c % 2 == 0)
			System.out.println(sum);
		else
			System.out.println(sum - (min * 2));
	}

	int gcd (int a, int b) {
		int temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}

    public static void main(String[] args) {
    	new Main().run();
    }
}


Measured memory_bytes: 48316
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<(int)(n);i++)
#define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define pb(a) push_back(a)
#define ZERO(a) memset(a,0,sizeof(a))
#define int long long
#define INF 1<<29
#define MAX 100000
using namespace std;

int n,m,p[MAX],a[MAX],b[MAX],c[MAX],sum[MAX];

void solve(){
 cin>>n>>m;
 ZERO(sum);
 FOR(i,m) scanf("%lld",&p[i]);
 FOR(i,n-1) scanf("%lld %lld %lld",&a[i],&b[i],&c[i]);
 FOR(i,m) p[i]--;
 FOR(i,m-1){
  sum[max(p[i],p[i+1])]--;
  sum[min(p[i],p[i+1])]++;
 }
 int ans=0LL;
 FOR(i,n-1){
  sum[i+1]+=sum[i];
  ans+=min(sum[i]*a[i],sum[i]*b[i]+c[i]);
 }
 printf("%lld\n",ans);
}

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

Measured memory_bytes: 5140
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void) {
	char a[10];
	int i, ans = 0;
	scanf("%s", &a);
	for (i = 0; i < 4; i++) {
		if (a[i] == '+') {
			ans++;
		}
		else {
			ans--;
		}
	}
	printf("%d", ans);
}

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

ll INF = 1e18;
ll MOD = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}




//最小公倍数、最大公約数を使って求める
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

int main() {
    ll N; cin >> N;
    vector<ll> V(N); for(int i = 0; i < N; i++) cin >> V[i];
    if(N == 1){cout << V[0] << endl; return 0;}
    ll LCM = lcm(V[0], V[1]);
    for(int i = 2; i < N; i++) LCM = lcm(LCM, V[i]);
    cout << LCM << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define emp emplace

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

const int N = 110, K = 100010;

bool pd[K];
int a[N];

int main()
{
	int n, k;
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++)
		scanf("%d", a+i);
	for (int j = 1; j <= k; j++)
	{
		for (int i = 0; i < n and a[i] <= j; i++)
		{
			if (!pd[j - a[i]])
			{
				pd[j] = true;
				break;
			}
		}
	}
	printf("%s\n", pd[k] ? "First" : "Second");
	return 0;
}



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

// using mint = modint1000000007;
// using mint = modint998244353;

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

void solve() {
    bool x;
    cin >> x;
    print(not x);
}

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


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

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

  int ret = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    ret += (a >= k);
  }
  cout << ret << "\n";

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b){
    if(b==0)return a;
    else return gcd(b,a%b);
}
int main(){
    long long x,y;
    cin>>x>>y;
    cout<<(x>=y ? gcd(x,y) : gcd(y,x))<<endl;
    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	x=0;char c=getchar();bool f=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return  x;
}
template<class t> inline void write(t x){
	if(x<0){putchar('-'),write(-x);}
	else{if(x>9)write(x/10);putchar('0'+x%10);}
}

const int N=1e5+5;
int n,m,a[N],f[N],g[N];
deque<int> q;
vector<int> ans;

signed main(){
	read(n);read(m);
	for(int i=0;i<=n;i++) scanf("%1d",&a[i]),f[i]=0x3f3f3f3f;
	f[0]=0;
	f[n+1]=0x3f3f3f3f;
	q.push_back(0);
	for(int i=1;i<=n;i++) if(!a[i]){
		g[i]=n+1;
        while(!q.empty()&&q.front()+m<i) q.pop_front();
		if(!q.empty()) g[i]=q.front();
		f[i]=f[g[i]]+1;
		while(!q.empty()&&f[q.back()]>f[i]) q.pop_back();
		q.push_back(i);
	}
	if(f[n]>n){
		write(-1);
		return 0;
	}
	for(;n;n=g[n]){
		ans.push_back(n-g[n]);
	}
	for(int i=ans.size()-1;i>=0;i--) write(ans[i]),putchar(' ');
	// for(int i=1;i<=n;i++) write(f[i]),putchar(' ');puts("");
	// for(int i=1;i<=n;i++) write(g[i]),putchar(' ');
}


Measured memory_bytes: 2172
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define out(xxx) printf("%.10lf %.10lf\n",xxx.first,xxx.second)
using namespace std;
typedef pair<double,double> P;
const double theta = 60.0*M_PI/180.0;

void Koch_Curve(P st, P go, int n){
    if(n == 0) return;
    
    double stx = st.first;
    double sty = st.second;
    double gox = go.first;
    double goy = go.second;

    P s;
    s.first = (2.0*stx + gox )/3.0;
    s.second = (2.0*sty + goy)/3.0;
    P t;
    t.first = (stx + 2.0*gox)/3.0;
    t.second = (sty + 2.0*goy)/3.0;

    double vx = t.first - s.first;
    double vy = t.second - s.second;

    P u;
    u.first = vx*cos(theta) - vy*sin(theta) + s.first; 
    u.second = vx*sin(theta) + vy*cos(theta) + s.second; 
    
    Koch_Curve(st,s,n-1);
    out(s);
    Koch_Curve(s,u,n-1);
    out(u);
    Koch_Curve(u,t,n-1);
    out(t);
    Koch_Curve(t,go,n-1);

}

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

    int n;
    cin >> n;

    P s,g;
    s.first = 0.0, s.second = 0.0;
    g.first = 100.0, g.second = 0.0;
    out(s);
    Koch_Curve(s,g,n);
    out(g);

    return 0;
}



Measured memory_bytes: 3244
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    string s;
    cin >> s;
    ll n = s.size();
    ll sum = 0;
    rep(i, n) sum += s[i] - '0';
    cout << ((sum % 9 == 0) ? "Yes" : "No") << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 3748
import sys

input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
m = 0
zero = 0
ans = 0
odd = 10**9
for i in A:
    if i < 0:
        m += 1
    if i == 0:
        zero = 1
    ans += abs(i)
    if odd > abs(i):
        odd = abs(i)
if m %2 == 0 or zero:
    print(ans)
else:
    print(ans-odd*2)

Measured memory_bytes: 20252
#include<bits/stdc++.h>
using namespace std;
int main(){
    map<string,string> mp;
    mp["Sunny"] = "Cloudy";
    mp["Cloudy"] = "Rainy";
    mp["Rainy"] = "Sunny";
    string s;cin>>s;
    cout<<mp[s]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<queue>
using namespace std;
typedef pair<long long, long long> P;
int v,e,r;
struct edge{
    int to;
    long long cost;
    edge(int _to, long long _cost) :to(_to),cost(_cost){}
};
vector <edge> G[100010];
long long d[100100];

void dijkstra(int start){
    priority_queue<P,vector<P>,greater<P> > que;
    for(int i=0;i<v;i++) d[i]=1e12;
    d[start]=0;
    que.push(P(d[r],r) );

    while(!que.empty()) {
        P p=que.top();
        que.pop();
        int v=p.second;
        
        if(d[v]<p.first) continue;
        
        for(int i=0;i<G[v].size();i++){
            edge e=G[v][i];
            
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}
int main(){
    cin>>v>>e>>r;
    for(int i=0;i<e;i++){
        int s,t,d;
        cin>>s>>t>>d;
        G[s].push_back(edge(t,d));
    }

dijkstra(r);
for(int i=0;i<v;i++){
    if(d[i]!=1e12) cout<<d[i]<<endl;
    else cout<<"INF"<<endl;
}
}

Measured memory_bytes: 19528
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

void blockfall(vector< vector<int> > &board) {
    int H = board.size(), W = board[0].size();
    for(int i=H-1; i>=0; i--) {
        for(int j=0; j<W; j++) {
            if(board[i][j] == 0) continue;
            int r = i;
            while(r+1 < H and board[r+1][j] == 0) {
                swap(board[r+1][j], board[r][j]);
                r++;
            }
        }
    }
}

int disappear(vector< vector<int> > &board) {
    int H = board.size(), W = board[0].size();
    vector< vector<int> > checked(H, vector<int>(W));
    int ans = 0;
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            if(checked[i][j] or board[i][j] == 0) continue;
            int t = board[i][j], c = j, s = 0;
            while(c < W and board[i][c] == t) {
                s++; c++;
            }
            if(s < 3) continue;
            c = j;
            while(c < W and board[i][c] == t) {
                ans += t;
                board[i][c] = 0;
                c++;
            }
        }
    }
    return ans;
}

int solve_testcase() {
    int H; scanf("%d", &H);
    if(H == 0) return 1;

    const int W = 5;
    vector< vector<int> > board(H, vector<int>(W));
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            scanf("%d", &board[i][j]);
        }
    }

    int p, ans = 0;
    while(p = disappear(board), p > 0) {
        ans += p;
        blockfall(board);
    }
    printf("%d\n", ans);
    return 0;
}

int main() {
    while(!solve_testcase());
    return 0;
}



Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#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)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    ll q;cin>>q;
    rep(i,q){
        ll a,b;cin>>a>>b;
        ll mx=a*b-1;
        if(a==b){
            cout<<2*(a-1)<<endl;
            continue;
        }
        ll l=1,r=1ll<<31;
        while(r>l+1){
            ll mid=(l+r)/2;
            ll calc=(mid+1)/2*(mid+1-(mid+1)/2);
            if(calc>mx) r=mid;
            else l=mid;
        }
        cout<<l-1<<endl;
    }
    return 0;
}

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

#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back

using namespace std;

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

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  double ans = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    ans += 1.0 / a;
  }
  cout << fixed << setprecision(15) << 1.0 / ans << '\n';
  return (0);
}


Measured memory_bytes: 256
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


template<class T>
struct Pos2T
{
	Pos2T() {}
	Pos2T(T x, T y)
		: x(x)
		, y(y)
	{}

	bool operator== (const Pos2T &b) const
	{
		return x == b.x && y == b.y;
	}

	bool operator!= (const Pos2T &b) const
	{
		return x != b.x || y != b.y;
	}

	Pos2T operator*(T q) const
	{
		return Pos2T(x*q,y*q);
	}
	
	Pos2T operator+(const Pos2T &b) const
	{
		return Pos2T(x+b.x,y+b.y);
	}
	
	Pos2T &operator+=(const Pos2T &b)
	{
		x += b.x;
		y += b.y;
		return *this;
	}
	
	Pos2T operator-(const Pos2T &b) const
	{
		return Pos2T(x-b.x,y-b.y);
	}
	
	Pos2T &operator-=(const Pos2T &b)
	{
		x -= b.x;
		y -= b.y;
		return *this;
	}
	
	Pos2T operator-() const
	{
		return Pos2T(-x,-y);
	}
	
	Pos2T &operator*=(T q)
	{
		x *= q;
		y *= q;
		return *this;
	}
	
	T operator*(const Pos2T &b) const
	{
		return x*b.x + y*b.y;
	}
	
	T operator%(const Pos2T &b) const
	{
		return x*b.y - y*b.x;
	}

	const Pos2T &pos() const
	{
		return *this;
	}
	
	double len() const 
	{
		return sqrt(x*x+y*y);
	}
	
	T len2() const 
	{
		return x*x+y*y;
	}
	
	Pos2T norm() const
	{
		return (*this)*(1.0/len());
	}
	
	double dist(const Pos2T &p) const
	{
		return sqrt((x-p.x)*(x-p.x) + (y-p.y)*(y-p.y));
	}
	
	T dist2(const Pos2T &p) const
	{
		return (x-p.x)*(x-p.x) + (y-p.y)*(y-p.y);
	}	
	
	T x, y;
};

template<class T>
std::ostream& operator<<(std::ostream &s,const Pos2T<T> &p)
{
	s << "(" << p.x << "," << p.y << ")";
	return s;
}
typedef long double real;

typedef Pos2T<real> Pos;
typedef Pos2T<real> Vec;

const real eps = 1E-8;

int main()
{
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	vector<Pos> p(n);
	for(int i=0; i<n; ++i)
		cin >> p[i].x >> p[i].y;

	Pos mm[128][2];
	int nm[128] = {0};

	for(int i=0; i<n; ++i)
		for(int j=0; j<n; ++j) if(i != j)
		{
			Pos p1 = p[i];
			Pos p2 = p[j];
			bool ok = true;
			for(int k=0; ok && k<n; ++k) if(k != j && k != i)
			{
				real z = (p2-p1)%(p[k]-p1);
				if(eps < z)
				{
					ok = false;
				}
				
				if(fabs(z) < eps && (p2-p1)*(p[k]-p1) < -eps)
				{
					ok = false;
				}
				
				if(fabs(z) < eps && (p2-p1)*(p2-p[k]) < -eps)
				{
					ok = false;
				}				
			}
			if(!ok)
				continue;
			Pos m(-(p2.y-p1.y), p2.x-p1.x);
			//dprint(p1, p2, m);
			mm[i][1] = m;
			mm[j][0] = m;
			nm[i]++;
			nm[j]++;
		}
	
	real ans[128] = {0};
	for(int i=0; i<n; ++i) if(nm[i])
	{
		assert(1 < nm[i]);
		Pos n1 = mm[i][0].norm();
		Pos n2 = mm[i][1].norm();
		//dprint(p[i], n1, n2, mm[i][0], mm[i][1]);
		real cs = n1*n2;
		real sn = n2%n1;
		real angle = atan2(sn,cs);
		//assert(-eps < angle);
		angle = fabs(angle);
		ans[i] = angle/(2*M_PI);
	}
	
	for(int i=0; i<n; ++i)
		printf("%.19lf\n", (double)ans[i]);
		//cout << ans[i] << "\n";

	return 0;
}


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

int n;
int a[100];
int main() {
  cin >> n;
  --n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  long sum = 0;
  for (int i = 1; i < n; ++i) {
    sum += min(a[i], a[i - 1]);
  }
  sum += a[0];
  sum += a[n - 1];
  cout << sum << endl;
}

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

int main(){
  string s;cin>>s;
  if(s.at(s.size()-1)=='s') cout<<s<<"es"<<endl;
  else cout<<s<<"s"<<endl;

}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> S(H);

  for (int i = 0; i < H; i++) 
    cin >> S.at(i);

  for (int i = 0; i < W+2; i++) 
    cout << '#';
    cout << endl;
  for (int i = 0; i < H; i++) 
    cout << '#' << S.at(i) << '#' << endl;
  for (int i = 0; i < W+2; i++) 
    cout << '#';
    cout << endl;
}

Measured memory_bytes: 256
def retMax(a,b):
  if a>=b:
    return a
  else:
    return b

n = int(input())
r = []
dpList = [ [0] * 3 for x in range(n)]

for i in range(n):
  r.append(list(map(int,input().split())))

dpList[0][0] = r[0][0]  
dpList[0][1] = r[0][1]  
dpList[0][2] = r[0][2]  

for s in range(1,n):
  #b->a,c->aの最大値
  dpList[s][0] = retMax(dpList[s-1][1]+r[s][0],dpList[s-1][2]+r[s][0])
  #a->b,c->bの最大値
  dpList[s][1] = retMax(dpList[s-1][0]+r[s][1],dpList[s-1][2]+r[s][1])
  #a->c,b->cの最大値
  dpList[s][2] = retMax(dpList[s-1][0]+r[s][2],dpList[s-1][1]+r[s][2])

print(max(dpList[n-1]))
  

Measured memory_bytes: 75500
#include<iostream>
#include<vector>
using namespace std;
 
int N, node, value[30], value2[30], end_node;
vector<int> a, b, c;
int main(){
	scanf("%d", &N);
	int n = N;
	node = 1;
	value[0] = 1;
	value2[0] = 1;
	for (int i = 1; i < 22; i++) {
		value[i] = value[i - 1] * 2;
		//value2[i] = value2[i - 1] + value[i];
	}
	for (int i = 0; i < 22; i++) {
		if (N / value[i] == 0) {
			end_node = i;
			break;
		}
	}
	while(n != 1) {
		if (node == end_node - 1) {
			for (int i = 0; i < n; i++) {
				a.push_back(node);
				b.push_back(end_node);
				c.push_back(i * value[node - 1]);
			}
			break;
		}
		if (n % 2 != 0) {
			a.push_back(node);
			b.push_back(end_node);
			N -= value[node - 1];
			c.push_back(N);
		}
		a.push_back(node);
		a.push_back(node);
		b.push_back(node + 1);
		b.push_back(node + 1);
		c.push_back(0);
		c.push_back(value[node - 1]);
		node++;
		n = n / 2;
	}
	printf("%d %d\n", end_node, a.size());
	for (int i = 0; i < a.size(); i++) {
		printf("%d %d %d\n", a[i], b[i], c[i]);
	} 
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#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 all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

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

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int a, b, c, d; cin >> a >> b >> c >> d;
    while(true) {
        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    return 0;
}



























Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long int ll;
#define ipair pair<int,int>
#define mod 1000000007


int main()
{
   int a,b,c,d,e,f;
   cin>>a>>b>>c>>d>>e>>f;
   a*=100;
   b*=100;
   int t=a;
   int s=0;
   //cout<<f/a<<" "<<f/b<<endl;
   for(int i=0;i<=f/a;i++)
   {
      for(int j=0;j<=f/b;j++)
      {
         if((a*i+b*j)!=0)
          {
              int ms=f-a*i-b*j;
              //cout<<ms<<endl;
              if(ms<0) break;
              for(int p=0;p<=ms/c;p++)
              {
                  for(int q=0;q<=ms/d;q++)
                  {
                      if(p*c+q*d>ms) break;
                      if(100*(p*c+q*d)<=e*(a*i+b*j))
                      {
                          int nw=a*i+b*j;
                          int ns=p*c+q*d;
                          if(s*(ns+nw)<ns*(t))
                          {
                              t=ns+nw;
                              s=ns;
                          }
                          
                      }
                  }
              }
          }
      }
   }
   cout<<t<<" "<<s<<endl;
}



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

namespace AtCoder.ABC105.B
{
    class Program
    {
        static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                if (n < 4 * i) break;
                if ((n - 4 * i) % 7 == 0)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
            Console.WriteLine("No");
            return;
        }
    }
    class Scanner
    {
        string[] s;
        long i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public int Nextint()
        {
            return int.Parse(Next());
        }
        public int[] Arrayint(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Nextint() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }

        public double[] ArrayDouble(long N, double add = 0)
        {
            double[] Array = new double[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }

        public decimal NextDecimal()
        {
            return decimal.Parse(Next());
        }

        public decimal[] ArrayDecimal(long N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDecimal();
            }
            return Array;
        }
    }
}

Measured memory_bytes: 13140
import java.util.*;

public class Main {
    static long mod = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] lis = new int[n];

        for (int i = 0; i < n; ++i) {
            lis[i] = sc.nextInt();
        }

        int ans = 0;
        PriorityQueue<Integer> que = new PriorityQueue<Integer>();
        int lim = Math.min(n, m);
        for (int i = 0; i <= lim; ++i) {
            int lim2 = lim - i;
            for (int j = 0; j <= lim2; ++j) {
                int lim3 = m - i - j;
                int total = 0;
                que.clear();
                for (int a = 0; a < i; ++a) {
                    total += lis[a];
                    if (lis[a] < 0) {
                        que.add(lis[a]);
                    }
                }
                for (int a = 0; a < j; ++a) {
                    total += lis[n - a - 1];
                    if (lis[n - a - 1] < 0) {
                        que.add(lis[n - a - 1]);
                    }
                }

                for (int k = 0; k < lim3 && 0 < que.size(); ++k) {
                    total -= que.poll();
                }
                ans = Math.max(ans, total);
            }
        }
        System.out.println(ans);
    }
}


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

int main() {
  
  int N=6;
  
  vector<char> A(N);
 
 
  for(int i=0 ; i<N ; i++){
    
  	cin >> A.at(i);
    
   
  }
  
  if(A.at(2)==A.at(3)&&A.at(4)==A.at(5)){
  	cout << "Yes" << endl;
  }else{
  	cout << "No" << endl;
  }
  
}




Measured memory_bytes: 256