akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

int N;
long long int H[100005];

int main(void) {

	cin >> N;

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

	int ans = 0;
	int tmp = 0;

	H[N + 1] = 9999999999999;

	for (int i = 1; i <= N; i++) {
		if (H[i] >= H[i + 1]) { tmp++;   ans = max(ans, tmp); }
		else { tmp = 0; }
	}
	cout << ans << endl;


	return 0;
}

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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  sort(a.begin(), a.end());
  for (int i=1; i<n; i++) {
    if (a[i] == a[i-1]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


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

using namespace std;

#define PB push_back
#define f first
#define s second

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

const int MOD = 1000000007;
const int INF = 1000000007;
const int MAXN = (int)3e5+1;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n;
    cin >> n;
    ll ans = 60 * ((n/15) * (n/15));
    ll j = (n/15) * 15 + 1;
    while(j <= n)
    {
        if(j%3 != 0 && j%5 != 0)
        {
            ans += j;
        }
        j++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3652
/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define all(vec) vec.begin(),vec.end()
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;


void virus(){
          ll k;
          cin >> k;
          for(auto i=0; i<k; i++) cout<<"ACL";
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t = 1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
           //cerr << "\n Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Measured memory_bytes: 3556
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
#define u64 uint64_t
#define ll long long
#define endl "\n"
#define PI acos(-1)
#define pi pair<ll,ll>
#define fi first
#define si second
#define mkp make_pair
#define pb push_back
#define clr(arr) memset(arr,0,sizeof(arr))
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
deque<ll>dq;
map<ll,ll>mp;
set<ll>st;
vector<ll>vt;
ll mod=1e9+7;
const int N=1e6+5;
ll arr[N];

int main()
{
    IOS;
    ll n,m,x,y,z,i,j,k,p,f=0,tc,cnt=0,sum=0,mul=1,mi=1e18,ma=-1e18,a,b,c,d,sz;
    string str;
    char ch;
    double db;
    //code
    cin>>n;
    for(i=0;i<n;i++)
        cin>>arr[i];
  x=100;
  for(i=-100;i<=x;i++)
  {
      sum=0;
      for(j=0;j<n;j++)
      {
          p=abs(i-arr[j]);
          sum+=p*p;
      }
      mi=min(sum,mi);
  }

   cout<<mi<<endl;



    //code
    return 0;
}



Measured memory_bytes: 3664
N = int(input())
T = list(map(lambda x:int(x)*2,input().split()))
V = list(map(lambda x:int(x)*2,input().split()))

sumt = sum(T)
maxv = [min(i, sumt-i) for i in range(sumt+1)]

ct = 0
for t,v in zip(T,V):
    for i in range(ct,ct+t+1):
        maxv[i] = min(maxv[i], v)
    ct += t

for i in range(sumt):
    maxv[i+1] = min(maxv[i+1], maxv[i] + 1)
for i in reversed(range(sumt)):
    maxv[i] = min(maxv[i], maxv[i+1] + 1)

print(sum(maxv) / 4)

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

int main(){
	int X;
	cin >> X;
	
	for(int p=1;p<=10000;p++){
		if(p*100<=X && X<=p*105){
			cout << "1" << endl;
			return 0;
		}
	}
	cout << "0" << endl;
	return 0;
}

Measured memory_bytes: 256
a,b = map(int, input().split())

s = list(input())

if len(s) != a+b+1:
  print("No")
else:
  for i in range(a):
    if s[i] == "-":
      print("No")
      exit()
  if s[a] != "-":
    print("No")
    exit()
  for j in range(a+1,a+b+1):
    if s[j] == "-":
      print("No")
      exit()
print("Yes")

Measured memory_bytes: 3064
k=int(input())


cnt=0
if k>6:
    for i in range(7,k):
        for j in range(1,k):
            
                
            if i*j<k:
                cnt+=1
            else:
                break
print(cnt+k-1+((k-1)//2)+((k-1)//3)+((k-1)//4)+((k-1)//5)+((k-1)//6))

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

int main() {
int x,y;
cin >> x>>y;
rep(ik,x+1){
	if(ik*4+(x-ik)*2==y){
	cout << "Yes"<<endl;break;
	}
	if(ik==x){
	cout << "No"<<endl;break;
	}
}

}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
 
ll MOD = 1000000007;
ll INF =1<<29;
 
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    map<int,int> mp;
    rep(i,n){
        mp[a[i]]++;
    }
    vector<int>b;
    for(auto p:mp){
         b.push_back(p.second);
    }
    sort(b.begin(),b.end());
    int m = b.size();
    int ans = 0;
    rep(i,m-k){
        ans +=b[i];
    }
    cout << ans <<endl;
}


Measured memory_bytes: 11516
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair

void Fast_IO(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// #ifndef ONLINE_JUDGE
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	// freopen("debug.out","w",stderr);
	// #endif
}

vector <int> visited;
vector <int> visited_bfs;
vector <int> a[100032];
vector <int> ans;

void dfs(int x){
	int i,z;
	visited[x]=1;
	for(i=0;i<a[x].size();i++){
		//cout<<z<<'\n';
		z=a[x][i];
		if(visited[z]==0){
			dfs(z);
		}
	}
}

void BFS(int v){
	int i,val;
	queue <int> bfs;

	bfs.push(v);
	visited_bfs[v]=1;

	while(bfs.size()>0){
		v=bfs.front();
		//cout<<v<<' ';
		bfs.pop();

		for(i=0;i<a[v].size();i++){
			val=a[v][i];
			
			if(visited_bfs[val]==0){
				ans[val]=v;
				visited_bfs[val]=1;
				bfs.push(val);
			}
		}
	}
}

int main(){
	Fast_IO();
	int n,i,m,x,y;
	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>x>>y;
		a[x].pb(y);
		a[y].pb(x);
	}
	for(i=0;i<=n;i++){
		visited_bfs.pb(0);
		visited.pb(0);
		ans.pb(0);
	}
	dfs(1);
	BFS(1);
	int flag=1;
	for(i=1;i<=n;i++){
		if(visited[i]==0){
			flag=0;
			break;
		}
	}
	if(flag){
		cout<<"Yes"<<'\n';
		for(i=2;i<=n;i++){
			cout<<ans[i]<<'\n';
		}
	}
	else{
		cout<<"No"<<'\n';
	}

	return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();
            var sucCount = t.Length;
            var qCount = s.Count(z => z == '?');
            int end = 0;
            var count = sucCount - 1;
            var nothing = false;
            // ?無しで既に含まれている場合・・・
            if (s.Contains(t)) nothing = true;

            if (nothing)
            {
                count = -1;
                end = -1;
            }
            else
            {
                for (var i = s.Length - 1; i >= 0; i--)
                {
                    if (s[i] != '?' && s[i] != t[count])
                    {
                        count = sucCount - 1;
                        continue;
                    }
                    count--;

                    if (count == -1)
                    {
                        end = i;
                        break;
                    }
                }
            }
            
            if (count != -1)
            {
                // 後で全部やり直すしかない
                var tmp = 0;
                var isOk = false;
                for (var i = 0; i < s.Length; i++)
                {
                    if (s[i] != '?' && s[i] != t[tmp])
                    {
                        tmp = 0;
                        continue;
                    }
                    tmp++;

                    if (tmp == 1) end = i;
                    if (tmp == sucCount)
                    {
                        isOk = true;
                        break;
                    }
                }
                if (!isOk)
                {
                    Console.WriteLine("UNRESTORABLE");
                    return;
                }
            }

            for (var i = 0; i < s.Length; i++)
            {
                if (i == end && qCount != 0)
                {
                    Console.Write(t);
                    i += sucCount - 1;
                    continue;
                }

                Console.Write(s[i] == '?' ? 'a' : s[i]);
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>

using lint = long long;

bool compare_robots(const std::pair<lint, lint> &left, const std::pair<lint, lint> &right)
{
    return (left.first - left.second) < (right.first - right.second);
}

int main()
{
    lint n;
    std::vector<std::pair<lint, lint>> robots;

    scanf("%lld", &n);

    for (size_t i = 0; i < n; i++)
    {
        lint x, l;
        scanf("%lld", &x);
        scanf("%lld", &l);
        robots.push_back(std::make_pair(x, l));
    }

    std::sort(robots.begin(), robots.end(), compare_robots);

    auto pivot = robots.begin();
    lint ans = robots.size();

    for (auto next = robots.begin() + 1; next != robots.end(); next++)
    {

        if (next->first - next->second < pivot->first + pivot->second)
        {
            ans--;
            if (next->first + next->second < pivot->first + pivot->second)
            {
                pivot = next;
            }
        }
        else
        {
            pivot = next;
        }
    }

    printf("%lld", ans);

    return 0;
}


Measured memory_bytes: 2420
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  ll xyz[n][3];
  FOR(i,0,n){
    FOR(j,0,3){
      cin>>xyz[i][j];
    }
  }
  ll ans = 0;
  FOR(i,0,1<<3){
    vector<ll> v(n);
    FOR(j,0,n){
      FOR(k,0,3){
        // +
        if(i&(1<<k)){
          v[j] += xyz[j][k];
        }
        // -
        else {
          v[j] -= xyz[j][k];
        }
      }
    }
    sort(v.rbegin(), v.rend());
    ll tmp = 0;
    FOR(j,0,m) tmp += v[j];
    ans = max(ans, tmp);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
    	cin>>a[i];
    }
    if(n&1){
    	ll ans=-1e18;
    	ll sum=0;
    	for(int i=0;i<n;i++){
    		if(i%2==0)sum+=a[i];
    	}
    	for(int i=0;i<n;i++){
    		if(i%2==0)ans=max(ans,sum-a[i]);
    	}

    	ll dp[n];
    	dp[0]=0;
    	for(int i=1;i<n;i++){
    		if(i%2==0)dp[i]=dp[i-1];
    	    else{
    	    	ll num=a[i]-a[i-1];
    	    	dp[i]=max(dp[i-1]+num,0LL);
    	    }
    	}
    	ll m=-1e18;
    	for(int i=0;i<n;i++){
    		if(i&1){
    			dp[i]-=a[i+1];
    			m=max(dp[i],m);
    		}
    	}
    	ans=max(ans,sum+m);
    	cout << ans <<endl;
    }
    else{
    	ll b[n+1];
    	b[n]=0;
    	for(int i=n-1;i>=0;i--){
    		if(i&1)b[i]=b[i+1]+a[i];
    		else b[i]=b[i+1];
    	}
    	ll sum=0;
    	ll ans=-1e18;
    	for(int i=0;i<n-1;i++){
    		if(i%2==0)ans=max(ans,sum+b[i+1]),sum+=a[i];
    	}
        ans=max(ans,sum);
        cout << ans <<endl;
    }
    return 0;
}


Measured memory_bytes: 6776
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    string s;
    cin >> s;
    set<char> setik;
    rp(i,s.length()){
        setik.insert(s[i]);
    }

    if(setik.size() == s.length()) cout <<"yes" <<endl;
    else cout << "no"<<endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
const ll INF = 1LL << 60;
#define MOD 1000000007
#define MAX_V 100010
#define MAX_N 100010
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}

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

ll junnretu(ll n){
    ll ans=1;
    for (ll i=1;i<=n;i++){
        ans*=i;
    }
    return ans;
}

int main(){
    ll n;
    cin >> n;
    vector<pair<ll,ll>> p;
    for (ll i=0;i<n;i++){
        ll x,l;
        cin >> x >> l;
        p.push_back(make_pair(x-l,x+l));
    }
    sort(p.begin(),p.end(),pairCompare);
    ll flag=p[0].second,ans=1;
    for (ll i=1;i<n;i++){
        if (p[i].first>=flag){
            ans++;
            flag=p[i].second;
        }
    }
    cout << ans << endl;
    return 0;
}






Measured memory_bytes: 2420
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない
//UnionFind

const int maxn=50;

int main(){
    
    ll n,a,b;
    vector<ll> v;
    vector<vector<ll>> comb(maxn+1);
    
    cin >> n>>a>>b;
    
    rep(i,n){
        ll x;
        cin >> x;
        v.push_back(x);
    }
    
    sort(all(v));
    
    for(int i=0;i<=n;i++){
        for(int j=0;j<=i;j++){
            if(j==0||j==i)comb[i].push_back(1);
            else comb[i].push_back(comb[i-1][j-1]+comb[i-1][j]);
        }
    }
    
    
    ll least=0;
    ll sum=0;
    
    rep(i,a){
        sum+=v[n-1-i];
        least = v[n-1-i];
    }
    
    ll cnt1=0,cnt2=0;
    rep(i,n){
        if(least==v[i])cnt1++;
        if(least==v[i]&&i>=n-a)cnt2++;
    }
    
    if(sum/a>=1e9+7){
        cout << (ull)sum/(ull)a<<endl;
    }else{
        cout << (float)sum/float(a)<<endl;
    }
    if(least!=v[n-1]){
        cout <<comb[cnt1][cnt2]<<endl;
    }else{
        ll ans=0;
        for(int i=a;i<=min(cnt1,b);i++){
            ans+=comb[cnt1][i];
        }
        cout << ans<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
)

const (
	SCANNER_BUF_SIZE = 2 << 20

	INF = int64(math.MaxInt64)
	MOD = 1e9 + 7
)

var (
	writer  *bufio.Writer
	scanner *bufio.Scanner
)

func init() {
	writer = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(writer, f, a...)
}

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func sstring() string {
	scanner.Scan()
	return scanner.Text()
}

func gcd(a, b int64) int64 {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

func abs(a int64) int64 {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

func main() {
	defer writer.Flush()
	n := sint64()
	a := make([]int64, n)
	for i := range a {
		a[i] = sint64()
	}
	printf("%d\n", sol(a))
}

func sol(a []int64) int64 {
	if len(a) < 2 {
		return 0
	}
	sort.Slice(a, func(i, j int) bool {
		return a[i] < a[j]
	})
	ans := int64(0)
	count := 0
	p := len(a) - 1
	for count < len(a)-1 {
		ans += a[p]
		count++
		if count%2 == 1 {
			p--
		}
	}
	return ans
}


Measured memory_bytes: 5468
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
int crd[100010];
bool num[100010];
int main(){
	int N,K,ctr,cfa;//N?????§K?????°
	vector<int> vt,vf,vt2;
	while(1){
		cin>>N>>K;
		if(N==0&&K==0) break;
		for(int i=0;i<=N;i++){
			num[i]=false;
		}
		for(int i=0;i<K;i++){
			cin>>crd[i];
			num[crd[i]]=true;
		}
		ctr=cfa=0;
		for(int i=1;i<=N;i++){
			if(num[i]){
				if(cfa!=0){vf.push_back(cfa);
				cfa=0;}
				ctr++;
			}
			else{
				if(ctr!=0){vt.push_back(ctr);
				ctr=0;}
				cfa++;
			}
		}

		if(!num[0]){//????´????????????¨???
			sort(vt.begin(),vt.end(),greater<int>());
			cout<<vt[0]<<endl;
		}
		else{//????´????????????¨???
			for(int i=0;i<vt.size()-1;i++){
				if(vf[i]==1){
					vt2.push_back(vt[i]+vt[i+1]+1);
				}
				else{
					vt2.push_back(vt[i]+1);
				}
			}
			sort(vt2.begin(),vt2.end(),greater<int>());
			cout<<vt2[0]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1936
#include<iostream>
#include<cstdio>

using namespace std;

int n,s[25];

int solve(int i,int cishi,int key)
{
    if(cishi==key){
        return 1;
    }else if(i>=n){
        return 0;
    }
    if(solve(i+1,cishi,key)){
        return 1;
    }else if(solve(i+1,cishi+s[i],key)){
        return 1;
    }else{
        return 0;
    }
}

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


Measured memory_bytes: 3148
# bit全探索 典型といえば典型（問題文の意味がよくわからんので読解力コンテスト）

n = int(input())
syogen = []
for i in range(n):
    syogen.append([])
    for _ in range(int(input())):
        syogen[i].append(list(map(int, input().split())))

ans = 0
for bit in range(1 << n):
    p = ["不親切"] * n
    ng = False
    # bitの立っているのを正直者と仮定
    for i in range(n):
        if bit >> i & 1 == 1:
            # 上位bit = 小さいインデックス、になる（ように実装してしまった わかりづらい
            p[n - i - 1] = "正直者"
    for i in range(n):
        if p[i] == "不親切":
            # まあ不親切な人間のことなんて聞かなくていい
            continue
        for s in syogen[i]:
            if p[s[0] - 1] == "正直者" and s[1] == 1:
                # 証言と一致する
                continue
            elif p[s[0] - 1] == "不親切" and s[1] == 0:
                # 証言と一致する
                continue
            else:
                # 証言と一致しない
                ng = True
                break

    if not ng:
        ans = max(ans, p.count("正直者"))
print(ans)


Measured memory_bytes: 9240
#include<bits/stdc++.h>
using namespace std;
int main(){
   long long s,m,p,r,q;
   cin>>s;
   if(s>=500){
        m=s/500;
        p=m*1000;
   }
    r=s%500;
    q=p+(r/5)*5;
    cout<<q;
}


Measured memory_bytes: 256
a1 = int(input())
b2 = input().split(" ")

def check(a , b):
  score = 1
  if '0' in b:
    return 0
  else:
    for i in range(a):
      score *= int(b[i])
      if score > 10 ** 18:
        return -1
    
    return score

print(check(a1 , b2))

Measured memory_bytes: 19448
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
int H,W,v[200][200];
ll dp[201][200][200];
int main(){
	cin>>H>>W;
	rep(i,H) rep(j,W) cin>>v[i][j];
	if(W==1){
		ll ans=0;
		rep(i,H) ans+=v[i][0];
		cout<<ans<<endl;
		return 0;
	}
	rep(i,H+1) rep(j,W) rep(k,W) dp[i][j][k]=-1;
	dp[0][0][0]=v[0][0];
	rep(i,H){
		rep(a,W) for(int b=a;b<W;b++) if(dp[i][a][b]){
			if(a+1<b) chmax(dp[i][a+1][b],dp[i][a][b]+v[i][a+1]);
		}
		rep(a,W) for(int b=a;b<W-1;b++) if(dp[i][a][b]){
			chmax(dp[i][a][b+1],dp[i][a][b]+v[i][b+1]);
		}
		if(i==H-1){
			ll ans=0;
			rep(a,W) rep(b,W) chmax(ans,dp[i][a][b]);
			cout<<ans<<endl;
			return 0;
		}
		rep(a,W) for(int b=a+1;b<W;b++) if(dp[i][a][b]){
			dp[i+1][a][b]=dp[i][a][b]+v[i+1][a]+v[i+1][b];
		}
	}
}


Measured memory_bytes: 63232
#!/usr/local/bin/python3
#coding:utf-8
import numpy as np


def main():

   in0 = input()

   IN = in0.split(' ')

   N = int(IN[0])
   D = int(IN[1])

   X = np.zeros((N,D))

   for i in range(N):
      in0 = input()
      IN = in0.split(' ')
      for j in range(D):
         X[i,j] = int(IN[j])


   cnt = 0
   for i in range(N-1):
      for k in range(i+1,N):
         dis = 0
         for j in range(D):
            dis = dis + (X[i,j]-X[k,j])**2

         dist = np.sqrt(dis)

         i_dist = int(dist)

         if((dist - i_dist)==0):
            cnt = cnt + 1


   print ("%s" % (cnt))




if __name__ == "__main__":
   main()

Measured memory_bytes: 12492
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;

template <typename T> inline constexpr bool chmin(T &a, T b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <typename T> inline constexpr bool chmax(T &a, T b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}
template <typename ite>
void print_ite(ite start, ite end, char sp = ' ', char en = '\n') {
  for (auto i = start; i != end; i++)
    cout << *i << sp;
  cout << en;
}
template <typename ite> void scan_ite(ite start, ite end) {
  for (auto i = start; i != end; i++)
    cin >> (*i);
}
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

char extra(char a, char b) {
  if ((a == 'R' && b == 'G') || (a == 'G' && b == 'R'))
    return 'B';
  else if ((a == 'R' && b == 'B') || (a == 'B' && b == 'R'))
    return 'G';
  else
    return 'R';
}

int encode(char a) {
  if (a == 'R')
    return 0;
  if (a == 'G')
    return 1;
  return 2;
}

int main() {
  int n;
  string s;
  cin >> n >> s;
  s = ' ' + s;
  vector<vector<int>> imos(n + 1, vector<int>(3, 0));
  for (int i = 1; i <= n; i++) {
    imos[i][0] = imos[i - 1][0];
    imos[i][1] = imos[i - 1][1];
    imos[i][2] = imos[i - 1][2];
    if (s[i] == 'R')
      imos[i][0]++;
    if (s[i] == 'G')
      imos[i][1]++;
    if (s[i] == 'B')
      imos[i][2]++;
  }
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (s[i] != s[j]) {
        char t = extra(s[i], s[j]);
        int tc = encode(t);
        int dis = j - i;
        ans += (imos[n][tc] - imos[j][tc]);
        if (j + dis <= n && s[j + dis] == t)
          ans--;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const ll INF = LLONG_MAX/3;

const int N = 3003;
int n;
ll a[N];

ll dp[N][N];
ll dfs(int l, int r){
    if(l>r) return 0;
    if(dp[l][r] != INF) return dp[l][r];

    int t = l+n-1-r;
    ll ret;
    if(t%2==0){
        // maximize
        ret = -INF;
        ret = max(ret, dfs(l+1,r)+a[l]);
        ret = max(ret, dfs(l,r-1)+a[r]);
    }
    else{
        // minimize
        ret = INF;
        ret = min(ret, dfs(l+1,r)-a[l]);
        ret = min(ret, dfs(l,r-1)-a[r]);
    }
    return dp[l][r] = ret;
}

int main(){
    cin >>n;
    rep(i,n) cin >>a[i];

    fill(dp[0],dp[N],INF);
    cout << dfs(0,n-1) << "\n";
    return 0;
}


Measured memory_bytes: 71040
#include<bits/stdc++.h>
#define reg register
using namespace std;
int n,m;
char s[190][190];
int f[190][190];
short dp[190][190][190][21];

int pd(reg int sx,reg int sy,reg int ex,reg int ey){
	return f[ex][ey]+f[sx-1][sy-1]-f[sx-1][ey]-f[ex][sy-1];
}

int main(){
	scanf("%d %d",&n,&m);
	for(reg int i=1;i<=n;i++) scanf("%s",s[i]+1);
	for(reg int i=1;i<=n;i++){
		for(reg int j=1;j<=m;j++) f[i][j]=f[i-1][j]+f[i][j-1]-f[i-1][j-1]+(s[i][j]=='#');
	}
	for(reg int i=1;i<=n;i++){
		for(reg int j1=1;j1<=m;j1++){
			for(reg int j2=j1;j2<=m;j2++){
				reg int l=i,r=n,p=i-1;
				while(l<=r){
					reg int mid=(l+r)/2;
					reg int tot=pd(i,j1,mid,j2);
					if(tot==0||tot==(mid-i+1)*(j2-j1+1)) p=max(p,mid),l=mid+1;
					else r=mid-1;
				}
				dp[i][j1][j2][0]=(short)p;
			}
		}
	}
	for(reg int k=1;;k++){
		if(dp[1][1][m][k-1]==n){printf("%d\n",k-1);return 0;}
		for(reg int len=1;len<=m;len++){
			for(reg int i=1;i<=n;i++){
				for(reg int j1=1;j1<=m-len+1;j1++){
					reg int j2=j1+len-1;
					if(dp[i][j1][j2][k-1]==n){dp[i][j1][j2][k]=n;continue;}
					reg int pre=(int)dp[i][j1][j2][k-1]+1;
					dp[i][j1][j2][k]=dp[pre][j1][j2][k-1];
					if(dp[i][j1][j2][k]==n) continue;
					reg int l=j1,r=j2-1,p=0;
					while(l<=r){
						reg int mid=(l+r)/2;
						reg int x=(int)dp[i][j1][mid][k-1],y=(int)dp[i][mid+1][j2][k-1];
						p=max(p,min(x,y));
						if(x<y) r=mid-1;else l=mid+1;
					}
					dp[i][j1][j2][k]=max(dp[i][j1][j2][k],(short)p);
				}
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 275456
n,m = map(int,input().split())
lr= [list(map(int,input().split()))for a in range(m)]
l,r = [list(b) for b in zip(*lr)]
left,right = max(l),min(r)
cnt = 0
for i in range(1,n+1):
	if left <= i and i <= right:
		cnt += 1
print(cnt)

Measured memory_bytes: 97964
N = int(input())
A = list(map(int, input().split()))

kabu = 0
money = 1000

for i in range(len(A)):
    if i == N-1:
        money += kabu * A[i]
        print(money)
        exit()
    else:
        if A[i] < A[i+1]:
            ki = money // A[i]
            kabu += ki
            money -= ki * A[i]

        else:
            money += A[i] * kabu
            kabu = 0

Measured memory_bytes: 8888
#include<stdio.h>

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

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

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

  return  0;
 
}

Measured memory_bytes: 128
#include<stdio.h>
#define max(a,b) ((a)>(b) ? (a):(b))
int dp[101][20000];
int main(void){
    int n,w;
    int V[101],W[101];
    int i,j;

    scanf("%d%d",&n,&w);
    for(i=1;i<=n;i++){
	scanf("%d%d",&V[i],&W[i]);
    }

    for(i=1;i<=n;i++){
	for(j=0;j<=w;j++){
	    dp[i][j]=max(dp[i][j],dp[i-1][j]);
	    dp[i][j+W[i]]=max(dp[i][j]+V[i],dp[i-1][j+W[i]]);
//	    printf("dp[%d][%d]=%d\n",i,j+W[i],dp[i][j+W[i]]);
	}
    }

    printf("%d\n",dp[n][w]);

    return 0;
}

Measured memory_bytes: 6912
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<bitset>
#define IL inline
#define RG register
#define db double
#define pi acos(-1.0)
#define inf 0x3f3f3f3f
#define LL long long
using namespace std;
IL int gi()
{
    RG int res=0,s=1;RG char ch;
    for(ch=getchar(); (ch<'0'||ch>'9')&&ch!='-' ;ch=getchar());
    if(ch=='-') s=-1,ch=getchar();
    for(;ch>='0'&&ch<='9';ch=getchar()) res=10*res+ch-48;
    return res*s;
}
int n,a[2005],sum;
bitset<4000005>b;
int main()
{
	n=gi();
	for(RG int i=1;i<=n;++i) a[i]=gi(),sum+=a[i];
	b[0]=1;
	for(RG int i=1;i<=n;++i)
		b=b|(b<<a[i]);
	for(RG int i=(sum+1)/2;i<=sum;++i) if(b[i]==1) {printf("%d\n",i);break;}
    return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int64 cnt(int64 X, int64 D) {
  return X/D;
}

int64 cnt(int64 A, int64 B, int64 D) {
  return cnt(B, D) - cnt(A-1, D);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int64 A, B, C, D;
  cin >> A >> B >> C >> D;
  cout << (B-A+1) - (cnt(A, B, C) + cnt(A, B, D) - cnt(A, B, C/__gcd(C, D)*D)) << endl;
}


Measured memory_bytes: 256
package main
import . "fmt"
import . "os"
func main() {
  var n int
  var s string
  Scan(&n)
  for i:=0;i<n;i++ {
    Scanf("%s",&s)
    if s == "Y" {
      Println("Four")
      Exit(0)
    }
  }
  Println("Three")
}

Measured memory_bytes: 512
import std.stdio, std.conv, std.string, std.algorithm;

void main() {
	int N, M;
	int [] t;
	t  = readln().chomp().split().to!(int[]);
	N = t[0]; M = t[1];

	long [][] a;
	foreach(int i; 0..N)
		a ~= readln().chomp().split().to!(long[]);

	long res = 0;
	foreach(int i; 0..(1<<3)) {
		long [] b;
		foreach(int j; 0..N) {
			long c = 0;
			foreach(int k; 0..3) {
				if(i&(1<<k))
					c += a[j][k];
				else
					c -= a[j][k];
			}
			b ~= c;
		}
		b.sort!("a > b");
		long d = 0;
		foreach(int j; 0..M) {
			d += b[j];
		}
		res = max(res,d);
	}
	writefln("%d",res);
}


Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N; cin >> N;
    vector<int> color(9,0);
    for(int i=0; i<N; i++){
        int a; cin >> a;
        if(a/400 < 8) color[a/400]++;
        else color[8]++;
    }

    int normal = 0;
    for(int i=0; i<8; i++) if(color[i]) normal++;

    int minv = max(1, normal);
    int maxv = normal + color[8];

    printf("%d %d\n", minv, maxv);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main()
{

   string s;
   cin>>s;
   map<char,ll>m;
   bool f=1;
   for(int i=0;i<s.size();i++)
   {
       m[s[i]]++;
   }
   for(auto it=m.begin();it!=m.end();it++)
   {
       ll x=it->second;
       if(x&1)
       {
           f=0;
           break;
       }
   }
   if(!f)
   {
       cout<<"No"<<endl;
   }
   else{
    cout<<"Yes"<<endl;
   }

}


Measured memory_bytes: 3512
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
short S[105][105];
struct Rect {
	int x1, x2, y1, y2;
	inline bool valid() {
		return x2 >= x1 && y2 >= y1;
	}
	inline short gain() {
		return S[y2][x2] - S[y1 - 1][x2] - S[y2][x1 - 1] + S[y1 - 1][x1 - 1];
	}
};
Rect inter(const Rect& a, const Rect& b) {
	return {max(a.x1, b.x1), min(a.x2, b.x2), max(a.y1, b.y1), min(a.y2, b.y2)};
}
char G[105][105];
int H, W;
int ex, ey;
short dp[101][101][101][101];
short f(int x1, int x2, int y1, int y2) {
	short& ret = dp[x1][x2][y1][y2];
	if (ret != -1) return ret;
	int l = x2 - ex + 1;
	int r = x1 + (W - ex);
	int u = y2 - ey + 1;
	int d = y1 + (H - ey);
	ret = 0;
	Rect allow{l, r, u, d};
	Rect slice;
	slice = inter({x1 - 1, x1 - 1, y1, y2}, allow);
	if (slice.valid()) {
		ret = max((int)ret, f(x1 - 1, x2, y1, y2) + slice.gain());
	}
	slice = inter({x2 + 1, x2 + 1, y1, y2}, allow);
	if (slice.valid()) {
		ret = max((int)ret, f(x1, x2 + 1, y1, y2) + slice.gain());
	}
	slice = inter({x1, x2, y1 - 1, y1 - 1}, allow);
	if (slice.valid()) {
		ret = max((int)ret, f(x1, x2, y1 - 1, y2) + slice.gain());
	}
	slice = inter({x1, x2, y2 + 1, y2 + 1}, allow);
	if (slice.valid()) {
		ret = max((int)ret, f(x1, x2, y1, y2 + 1) + slice.gain());
	}
	return ret;
}
int main() {
	scanf("%d%d", &H, &W);
	for (int i = 0; i < H; ++i) {
		scanf("%s", G[i]);
		for (int j = 0; j < W; ++j) {
			S[i + 1][j + 1] = S[i + 1][j] + S[i][j + 1] - S[i][j] + (G[i][j] == 'o');
			if (G[i][j] == 'E') {
				ex = j + 1;
				ey = i + 1;
			}
		}
	}
	memset(dp, -1, sizeof(dp));
	int ans = f(ex, ex, ey, ey);
	printf("%d\n", ans);
}


Measured memory_bytes: 203520
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
using namespace std;

int n;
int t[100001], x[100001], y[100001];

int Abs(int x) {
	if (x > 0) return x;
	return -x;
}

signed main() {
	int i;
	
	cin >> n;
	for (i = 1; i <= n; i++) cin >> t[i] >> x[i] >> y[i];
	
	for (i = 0; i < n; i++) {
		int xx = x[i + 1] - x[i];
		int yy = y[i + 1] - y[i];
		int tt = t[i + 1] - t[i];
		int d = Abs(xx) + Abs(yy);
		if (d > tt || d % 2 != tt % 2) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}
template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S>& p) {
	os << '(' << p.first << ',' << p.second << ')';
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

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

	vector<int> a(n);
	cin >> a;

	vector<int> dp(n, 1e9);
	dp[0] = 0;
	rep(i, n) {
		rep(j, k) {
			if (i + j + 1 < n)
				dp[i + j + 1] =
					min(dp[i + j + 1], dp[i] + abs(a[i] - a[i + j + 1]));
		}
	}
	cout << dp.back() << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string s, t, u;
cin >> s >> t;
int a, b;
char h;
a = s.size();
b = a + 1;
for (int i = 0; i < a; i++ ) {
h = s[0];
s.insert(a, "a");
s[a] = h;
s.erase(0, 1);
if (s == t) {
cout << "Yes" << endl;
break;
}
}
if (s != t) {
cout <<"No" << endl;
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
////////////////////////////////////////////////////////////
#define all(x) (x).begin(), (x).end()
const int inf = 1e9;
const long long INF=1e15;
#define endl '\n'
#define rep(i, n) for(int i=0;i<(n);++i)
#define repp(i, a, b) for(int i=(a);i<=(b);++i)
#define pb push_back
#define eb emplace_back
#define fastio ios::sync_with_stdio(false);cin.tie(0); //cout.tie(0);

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

using _Tp = long long;
static _Tp const mod = 1e9+7;
class modular {
	public:
	_Tp value;
	modular() {}
	modular(_Tp b) {value = b%mod;}
	_Tp operator=(_Tp b) {value = b%mod; return b;}
	auto operator+(modular b) {return modular{(value+b.value)%mod};}
	auto operator+(_Tp b) {return modular{(value+b)%mod};}
	auto operator-(modular b) {return modular{(value-b.value+mod)%mod};}
	auto operator-(_Tp b) {return modular{(value-b+mod)%mod};}
	auto operator*(modular b) {return modular{value*b.value%mod};}
	auto operator*(_Tp b) {return modular{value*b%mod};}
	auto operator/(modular b) {return modular{value*pow(b.value, mod-2)%mod};}
	auto operator/(_Tp b) {return modular{value*pow(b, mod-2)%mod};}
	operator _Tp() {return value;}
	static _Tp pow(_Tp v, _Tp k) {
		if(k == 0) return 1;
		if(k == 1) return v%mod;
		if(k % 2 == 0) {
			auto ret = pow(v, k/2);
			return ret*ret%mod;
		}
		return v*pow(v,k-1)%mod;
	}
};

void solve() {
	int n; cin >> n;
	vector<vi> e(n);
	rep(i, n-1) {
		int a, b; cin >> a >> b;
		a--, b--;
		e[a].pb(b);
		e[b].pb(a);
	}
	vi c(n, 0);
	vector<modular> dp1(n), dp2(n), fact(n+1);
	fact[0] = 1;
	repp(i, 1, n) fact[i] = fact[i-1] * i;
	// dp1[i] = see only child
	function<int(int,int)> dfs1 = [&](int here, int p) {
		int child = 0;
		dp1[here] = 1;
		for(auto next:e[here]) {
			if(next != p) {
				int ret = dfs1(next, here);
				dp1[here] = dp1[here] / fact[ret] * dp1[next];
				child += ret;
			}
		}
		dp1[here] = dp1[here] * fact[child];
		return c[here] = child+1;
	};
	dfs1(0, -1);
	function<void(int,int)> dfs2 = [&](int here, int p) {
		if(p == -1)
			dp2[here] = dp1[here];
		else {
			dp2[here] = dp1[here] * dp2[p] * c[here] / dp1[here] / (n-c[here]);
		}
		for(auto next:e[here]) {
			if(next != p) {
				dfs2(next, here);
			}
		}
	};
	dfs2(0, -1);
	rep(i, n) cout << dp2[i] << endl;
}
int main() {
	fastio;
	solve();
}

Measured memory_bytes: 19444
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll a,b;
    cin>>a>>b;
    if(a<10&&b<10){
        cout<<a*b<<endl;
    }
    else{
        cout<<-1<<endl;
    }
    
    return 0;
}

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

#define ll long long
#define ld long double
using namespace std;

const ll mod = (ll)1000000007;

int main() {
    ll n,m;
    cin >> n >> m;
    ll answ = 0;
    if (n*2 <= m)
    {
        answ += n;
        m -= n*2;
        n = 0;
    }
    else
    {
        answ += m/2;
        m = 0;
    }
    if (m >= 4)
    {
        answ += m/4;
    }
    cout << answ << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
long long MOD = (long long)1e9 + 7;

int n;
long long dat[3009][3009], combi[3009][3009], D0[3000009], D1[3009];

long long quickpow(long long b, int e)
{
	return e ? ((e & 1 ? b : 1)*quickpow((b*b) % MOD, e >> 1)) % MOD : 1;
}

long long gun(int a, int b)
{
	long long retval = 0;
	retval = dat[a][b];
	retval *= D0[(n - a)*b];
	retval %= MOD;
	retval *= D1[n - a];
	retval %= MOD;
	return retval;
}

long long fun(int x)
{
	long long retval = 0;
	for (int j = 0; j <= x; j++) {
		retval += gun(x, j);
		retval %= MOD;
	}
	return retval;
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> MOD;
	for (int i = 0; i <= n; i++) {
		dat[i][0] = 1;
		dat[i][i] = 1;
	}
	for (int i = 2; i <= n; i++) {
		for (int j = 1; j < i; j++) {
			long long tmp = ((j + 1)*dat[i - 1][j]) % MOD;
			dat[i][j] = (dat[i - 1][j - 1] + tmp) % MOD;
		}
	}
	for (int i = 0; i <= n; i++) combi[i][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= i; j++) {
			combi[i][j] = combi[i - 1][j - 1];
			if (j < i) combi[i][j] += combi[i - 1][j];
			combi[i][j] %= MOD;
		}
	}
	D0[0] = 1;
	for (int i = 1; i <= 2500000; i++) {
		D0[i] = D0[i - 1] * 2;
		D0[i] %= MOD;
	}
	D1[0] = 2;
	for (int i = 1; i <= n; i++) {
		D1[i] = D1[i - 1] * D1[i - 1];
		D1[i] %= MOD;
	}
	long long ans = 0;
	for (int i = 0; i <= n; i++) {
		long long tmp = combi[n][i] * fun(i);
		tmp %= MOD;
		if (i % 2) {
			ans += MOD - tmp;
		}
		else {
			ans += tmp;
		}
		ans %= MOD;
	}
	cout << ans << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 162944
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	while (cin >> n) {
		int ans = 0;
		for (int i = n; i < 600; i += n) {
			ans += n*i*i;
		}
		cout << ans << endl;
	}
	return 0;
}





Measured memory_bytes: 3076
//Name: Disciple Life is Hard
//Level: 3
//Category: 動的計画法,DP,累積和
//Note: RUPC 2014 Day3

/**
 */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

bool solve() {
    int S, T, U, N, O, D;
    if(!(cin >> S >> T >> U >> N >> O >> D)) return false;

    // [count][energy] = max cal
    vector<vector<int>> training(U+1, vector<int>(S+1, -1));
    training[0][0] = 0;
    for(int i = 0; i < T; ++i) {
        int e, c;
        cin >> e >> c;
        for(int u = U; u >= 1; --u) {
            for(int s = S; s >= e; --s) {
                if(training[u-1][s-e] == -1) continue;
                training[u][s] = max(training[u][s], training[u-1][s-e] + c);
            }
        }
    }

    // [cal] = max score
    vector<long long> doughnuts(10001, -1);
    doughnuts[0] = 0;
    for(int i = 0; i < N; ++i) {
        int h, a;
        cin >> h >> a;
        for(int c = a; c <= 10000; ++c) {
            if(doughnuts[c-a] == -1) continue;
            doughnuts[c] = max(doughnuts[c], doughnuts[c-a] + h);
        }
    }
    // cumulate
    for(int c = 1; c <= 10000; ++c) {
        doughnuts[c] = max(doughnuts[c], doughnuts[c-1]);
    }

    // [stamina] = max score
    vector<long long> dp(S+1, -1);
    dp[S] = 0;
    for(int day = 0; day < D; ++day) {
        vector<long long> next(S+1, -1);
        for(int prev = 0; prev <= S; ++prev) { // previous stamina
            if(dp[prev] == -1) continue; // cannot reach such situation
            for(int t = 0; t <= prev; ++t) { // training
                if(training[U][t] == -1) continue; // No such combination of training
                const int ns = min(S, prev - t + O);
                next[ns] = max(next[ns], dp[prev] + doughnuts[training[U][t]]);
            }
        }
        dp.swap(next);
    }
    cout << *max_element(begin(dp), end(dp)) << endl;
    return true;
}

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

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 1336