akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;

int main() {
    string s; cin >> s;
    int ans = 0, can = 0;
    rep(i, s.size()) {
        if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
            can++;
        }
        else {
            chmax(ans, can);
            can = 0;
        }
    }
    chmax(ans, can);
    cout << ans << endl;
}

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

typedef long long ll;

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	stack<int> s1;
	stack<pair<int , int> > s2;
	
	char c;
	int sum = 0;
	
	for(int i = 0 ; cin>>c ; i++){
		if(c == '\\')
			s1.push(i);
		else if(c == '/' && s1.size()>0){
			int j = s1.top() ; s1.pop();
			sum += i-j;
			int a = i-j;
			while (s2.size()>0 && s2.top().first>j){
				a+= s2.top().second;
				s2.pop();
			}
			s2.push(make_pair(j,a));
		}
	}
	
	vector<int> ans;
	while (s2.size()>0){
		ans.push_back(s2.top().second);
		s2.pop();
	}
	reverse(ans.begin() , ans.end());
	cout<<sum<<endl;
	cout<<ans.size();
	for(int i = 0 ; i<ans.size() ; i++){
		cout<<" "<<ans[i];
	}
	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 3272
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int n;
	cin >> n;
	int ans = 1;
	rep3(i,1,n){
		// cout << i << ": " << (int)(i&(-i)) << endl;
		if(int(i&(-i)) > int(ans&(-ans))) ans = i;
	}
	cout << ans << endl;  
	return;
}

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

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

using namespace std;
long long a[100][100],b[100][100],c[100][100],ans,o[100][100],mod=1e9+7,k,n;
void mul(long long x)
{
    if (x==1)
    {
        for (int i=0; i<n; i++)
        {
            for (int j=0; j<n; j++)
            {
                c[i][j]=o[i][j];
            }
        }
        return;
    }
    if (x>1) mul(x/2);
    for (int i=0; i<n; i++)
    {
        for (int j=0; j<n; j++)
        {
            a[i][j]=c[i][j];
            b[i][j]=c[i][j];
            c[i][j]=0;
        }
    }
    for (int i=0; i<n; i++)
    {
        for (int j=0; j<n; j++)
        {
            for (int k=0; k<n; k++)
            {
                c[i][j]+=(a[i][k]*b[k][j])%mod;
                c[i][j]%=mod;
            }
        }
    }
    if (x%2==1)
    {
        for (int i=0; i<n; i++)
        {
            for (int j=0; j<n; j++)
            {
                a[i][j]=c[i][j];
                b[i][j]=o[i][j];
                c[i][j]=0;
            }
        }
        for (int i=0; i<n; i++)
        {
            for (int j=0; j<n; j++)
            {
                for (int k=0; k<n; k++)
                {
                    c[i][j]+=(a[i][k]*b[k][j])%mod;
                    c[i][j]%=mod;
                }
            }
        }
    }
    return ;
}
long long sum;
int main()
{
    cin>>n>>k;
    for (int i=0;i<n;i++)
    {
        for (int j=0;j<n;j++) cin>>o[i][j];
    }
    mul(k);
    for(int i=0;i<n;i++)
    {
            for (int j=0;j<n;j++)
        {
            sum+=c[i][j]%mod;
           // cout<< c[i][j]<<" ";
            sum%=mod;
        }
       // cout<<endl;
    }

    cout<<sum;
    return 0;
}


Measured memory_bytes: 384
H=int(input())
a=0
b=0
c=0
while H>1:
  H=H//2
  a=a+1
  b=2**(a-1)
  c=c+b
  #print(H,a,b,c)
a=a+1
b=2**(a-1)
c=c+b
print(c)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
inline int read(){
    int X=0,w=1; char ch=0;
    while(ch<'0' || ch>'9') {if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0' && ch<='9') X=(X<<3)+(X<<1)+ch-'0',ch=getchar();
    return X*w;
}
int main(){
	int n,ans=0,i,lst=n+1;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		if(i==read()){
			if(lst==i-1)lst=n+1;
		else{
			ans++;lst=i;
		}
	}
	}
	cout<<ans<<endl;
}

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

string grid[500];
int posy[26][2],posx[26][2];
int pos[26][2][2];
bool use[26];
int n,m;
int res;

bool cluck(int y,int x){
  int k;
  int cnt[26];
  for(int i=0;i<26;i++)cnt[i] = 0;

  k = 1;
  while(y+k<n && grid[y+k][x] == '.')k++;
  if(y+k<n)cnt[grid[y+k][x]-'A']++;

  k = 1;
  while(x+k<m && grid[y][x+k] == '.')k++;
  if(x+k<m)cnt[grid[y][x+k]-'A']++;

  k = 1;
  while(y-k>=0 && grid[y-k][x] == '.')k++;
  if(y-k>=0)cnt[grid[y-k][x]-'A']++;

  k = 1;
  while(x-k>=0 && grid[y][x-k] == '.')k++;
  if(x-k>=0)cnt[grid[y][x-k]-'A']++;

  bool f = false;
  for(int i=0;i<26;i++){
    if(cnt[i]==2){
      res += 2;
      grid[posy[i][0]][posx[i][0]] ='.';
      grid[posy[i][1]][posx[i][1]] ='.';
      use[i] = false;
      f = true;
    }
  }

  return f;
}

int main(){
  cin >> n >> m;
  for(int i=0;i<n;i++)cin >> grid[i];

  for(int i=0;i<26;i++){
    posy[i][0] = -1;
    posx[i][0] = -1;
    posy[i][1] = -1;
    posx[i][1] = -1;
    use[i] = false;
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if(grid[i][j] != '.'){
	if(posy[grid[i][j]-'A'][0]<0){
	  posy[grid[i][j]-'A'][0] = i;
	  posx[grid[i][j]-'A'][0] = j;
	  use[grid[i][j]-'A'] = true;
	}else{
	  posy[grid[i][j]-'A'][1] = i;
	  posx[grid[i][j]-'A'][1] = j;
	}
      }
    }
  }

  res = 0;
  while(1){
    bool f = false;
    for(int i=0;i<26;i++){
      if(use[i]){
	if(posy[i][0] == posy[i][1]){
	  int s = min(posx[i][0],posx[i][1]),g = max(posx[i][0],posx[i][1]);
	  for(int j=s+1;j<g;j++){
	    if(grid[posy[i][0]][j]=='.')f |= cluck(posy[i][0],j);
	  }
	}else if(posx[i][0] == posx[i][1]){
	  int s = min(posy[i][0],posy[i][1]),g = max(posy[i][0],posy[i][1]);
	  for(int j=s+1;j<g;j++){
	    if(grid[j][posx[i][0]]=='.')f |= cluck(j,posx[i][0]);
	  }
	}else{
	  if(grid[posy[i][0]][posx[i][1]] == '.')f |= cluck(posy[i][0],posx[i][1]);
	  if(grid[posy[i][1]][posx[i][0]] == '.')f |= cluck(posy[i][1],posx[i][0]);
	}
      }
    }
    if(!f)break;
  }

  cout << res << endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using mcq = map<char, queue<char>>;

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

vs bubble_sort(vs c, int n) {
  rep(i, n - 1) 
    for (int j = n - 1; j >= i + 1; j--) 
      if (c[j][1] < c[j - 1][1]) swap(c[j], c[j - 1]);
  
  return c;
}

vs selection_sort(vs c, int n) {
  rep(i, n - 1) {
    int minj = i;
    for (int j = i; j < n; j++) 
      if (c[j][1] < c[minj][1]) minj = j;

    if (i != minj) swap(c[i], c[minj]);
  }

  return c;
}

void print_vec(vs c, int n) {
  rep(i, n) {
    cout << c[i];
    i != n - 1 ? (cout << " ") : (cout << endl);
  } 
}

bool is_stable(mcq orig, vs sorted) {
  for (auto i: sorted) {
    auto &q = orig[i[1]];
    if (q.size()) {
      if (q.front() == i[0]) q.pop();
      else return false;
    }
  }

  return true;
}

int main() {
  int n;
  cin >> n;
  
  vs c(n);
  mcq orig;
  rep(i, n) {
    cin >> c[i];
    orig[c[i][1]].push(c[i][0]);
  } 
  
  auto bubble = bubble_sort(c, n);
  auto selection = selection_sort(c, n);
  
  print_vec(bubble, n); 
  cout << (is_stable(orig, bubble) ? "Stable" : "Not stable") << endl; 
  print_vec(selection, n); 
  cout << (is_stable(orig, selection) ? "Stable" : "Not stable") << endl; 
}



Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////
#define N 100004

ll kai[N];
ll kai2[N];
ll po(ll i,ll p){
    if(p==0)return 1;
    else if(p==1)return mod(i);
    else if(p%2==0)return mod(po(mod(mod(i)*mod(i)),p/2));
    else  return mod(mod(i)*mod(po(i,p-1)));
}
void calc(){
    kai[0]=1;
    kai2[0]=1;
    for(int i=1;i<N;i++){
        kai[i]=mod(kai[i-1]*i);
        kai2[i]=mod(po(kai[i],i_5));
    }
}
ll comb(ll n,ll k){
    if(n==0){
        if(k==0)return 1;
        else return 0;
    }
    else if(n<k)return 0;
    else return mod(mod(mod(kai[n])*mod(kai2[n-k]))*mod(kai2[k]));
}

//#include <time.h>

int main(){
   // clock_t start = clock();    // スタート時間
    calc();
    ll n,a,b,c,d;cin>>n>>a>>b>>c>>d;
    ll dp[n+5][n+5];
    memset(dp,0,sizeof(dp));
    dp[a][0]=1;
    
    rep(k,a,b){
        rep(j,0,n){
            for(ll p=0;j+p*k<=n&&p<=d;p++){
                ll add=comb(n-j,p*k);
                add=mod(add*dp[k][j]);
                add=mod(add*kai[p*k]);
                add=mod(add*kai2[p]);
                ll w=(ll)po(kai2[k],p);
                add=mod(add*w);
                Add(&dp[k+1][j+p*k],add);
                if(p==0)p=c-1;
            }
        }
    }
    
    /*rep(i,0,b+1){
        rep(j,0,n){
            cout<<dp[i][j]<<"  ";
        }cout<<endl;
    }*/
    
    cout<<mod(dp[b+1][n])<<endl;
    
    //clock_t end = clock();     // 終了時間
   // std::cout << "duration = " << (double)(end - start) / CLOCKS_PER_SEC << "sec.\n";
    return 0;
}




Measured memory_bytes: 9728
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
ll N,Y;
int main() {
	cin>>N>>Y;

	for(int i=0;i<N+1 && i*10000<=Y;i++){
		for(int j=0;i+j<N+1 && i*10000+j*5000<=Y;j++){
			for(int k=0;i+j+k<N+1 && i*10000+j*5000+k*1000<=Y;k++){
				if(i+j+k==N){
					if(i*10000+j*5000+k*1000==Y){
						cout<<i<<" "<<j<<" "<<k<<endl;
						return 0;
					}

				}
			}
		}
	}
	cout<<"-1 -1 -1"<<endl;

	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func inputAsInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func inputAsString() string {
	sc.Scan()
	return sc.Text()
}

//
//func splitInt(n int) []int {
//	sc := bufio.NewScanner(os.Stdin)
//	sc.Split(bufio.ScanWords)
//	arr := make([]int, n)
//	for i := 0; i < n; i++ {
//		sc.Scan()
//		arr[i] = mustAtoi(sc.Text())
//
//	}
//	return arr
//}

func mustAtoi(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		panic(err)
	}
	return i
}

//
//type sortable [][]int
//
//func (s sortable) Len() int { return len(s) }
//
//func (s sortable) Less(i, j int) bool { return s[i][0] < s[j][0] }
//
//func (s sortable) Swap(i, j int) { s[i], s[j] = s[j], s[i] }

func main() {
	sc.Buffer([]byte{}, 100000000)

	n := inputAsInt()
	as := strings.Split(inputAsString(), " ")

	ans := make([]string, n)
	for i, a := range as {
		ans[mustAtoi(a)-1] = strconv.Itoa(i + 1)
	}

	fmt.Println(strings.Join(ans, " "))
}


Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

int dp[2050][100100];
int k=11;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;cin>>n;
    int v[n+1],w[n+1];
    for(int i=1;i<=n;i++) cin>>v[i]>>w[i];

    rep(i,600)rep(j,100100) dp[i][j]=0;
    for(int cur=1;cur<=min((1<<k),n);cur++){
        int par=cur/2;
        for(int i=100000;i>=0;i--){
            chmax(dp[cur][i],dp[par][i]);
            if(i+w[cur]<100100) chmax(dp[cur][i+w[cur]],dp[par][i]+v[cur]);
        }
    }

    int q;cin>>q;
    while(q--){
        int node,l;cin>>node>>l;

        if(node<(1<<k)){
            cout<<dp[node][l]<<endl;
            continue;
        }
        vector<int> vv,ww;
        for(;node>=(1<<k);node>>=1) vv.push_back(v[node]),ww.push_back(w[node]);

        int t=(int)vv.size();
        ll ans=0;
        for(int bit=0;bit<(1<<t);bit++){
            ll wsum=0,vsum=0;
            rep(i,t)if((bit>>i)&1)wsum+=ww[i],vsum+=vv[i];
            if(wsum<=l) chmax(ans,vsum+dp[node][l-wsum]);
        }
        cout<<ans<<"\n";
    }
    return 0;
}


Measured memory_bytes: 806812
object Main extends App {
  val sc = new java.util.Scanner(System.in)
//  val l = List.fill(5)(sc.nextInt)
  val s = sc.next
  val ss = s.split("/").map(_.toInt)

  val ans = if (ss(1) <= 4) "Heisei" else "TBD"
  println(ans)
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

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

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

int main(){
    char ch; cin >> ch;
    if(ch >= 'a') cout << 'a' << endl;
    else cout << 'A' << endl;
    return 0;
}

Measured memory_bytes: 3632
class Node:
    def __init__(self, key=-1, parent=-1, left=-1, right=-1):
        self.key = key
        self.parent = parent
        self.left = left
        self.right = right


def insert(t, z):
    x, y = t, -1
    while x != -1:
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y

    if y == -1:
        t = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z

    return t


def find(x, k):
    while x != -1 and k != x.key:
        if k < x.key:
            x = x.left
        else:
            x = x.right

    return x


def print_tree(t):
    def in_order(z):
        if z == -1:
            return

        in_order(z.left)
        print(" {}".format(z.key), end="")
        in_order(z.right)

    def pre_order(z):
        if z == -1:
            return

        print(" {}".format(z.key), end="")
        pre_order(z.left)
        pre_order(z.right)

    in_order(t)
    print()
    pre_order(t)
    print()


def main():
    n = int(input())
    bst = -1

    for i in range(n):
        order = input().split()
        if order[0][0] == "i":
            bst = insert(bst, Node(int(order[1])))
        elif order[0][0] == "f":
            if find(bst, int(order[1])) == -1:
                print("no")
            else:
                print("yes")
        else:
            print_tree(bst)


if __name__ == '__main__':
    main()



Measured memory_bytes: 85272
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

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

    int k;
    cin >> k;

    queue<string> s;
    s.push("");
    int cnt = 0;
    while(!s.empty()) {
        string t = s.front();
        s.pop();
        if(t == "") {
            FOR(i, 1, 10) { s.push(string(1, '0' + i)); }
        } else {
            cnt++;
            if(cnt == k) {
                cout << t << endl;
                return 0;
            }
            if(t.back() != '0') {
                t.push_back(t.back() - 1);
                s.push(t);
                t.pop_back();
            }
            t.push_back(t.back());
            s.push(t);
            t.pop_back();
            if(t.back() != '9') {
                t.push_back(t.back() + 1);
                s.push(t);
            }
        }
    }

    return 0;
}

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

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

const int dx[] = { 1, 0, -1, 0 };
const int dy[] = { 0, 1, 0, -1 };
const char dir[4] = { 'u', 'l', 'd', 'r' };

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

const int N = 3, N2 = 9;

struct Puzzle {
	int board[N2];
	int space;
	string path;

	bool operator < (const Puzzle &p) const {
		for (int i = 0; i < N2; i++) {
			if (board[i] == p.board[i]) continue;
			return board[i] > p.board[i];
		}
		return false;
	}
};

bool isTarget(Puzzle p) {
	for (int i = 0; i < N2; i++) {
		if (p.board[i] != i + 1) return false;
	}
	return true;
}

string bfs(Puzzle p) {
	queue<Puzzle> que;
	map<Puzzle, bool> mp;
	p.path = "";
	que.push(p);
	mp[p] = true;

	while (!que.empty()) {
		Puzzle u = que.front(); que.pop();
		if (isTarget(u)) return u.path;
		const int sx = u.space / N;
		const int sy = u.space % N;
		for (int i = 0; i < 4; i++) {
			const int nx = sx + dx[i];
			const int ny = sy + dy[i];
			if (nx < 0 || ny < 0 || nx >= N || ny >= N) continue;
			Puzzle v = u;
			swap(v.board[v.space], v.board[nx * N + ny]);
			v.space = nx * N + ny;
			if (!mp[v]) {
				mp[v] = true;
				v.path += dir[i];
				que.push(v);
			}
		}
	}
}

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

	Puzzle puzzle;
	for (int i = 0; i < N2; i++) {
		cin >> puzzle.board[i];
		if (puzzle.board[i] == 0) {
			puzzle.board[i] = 9;
			puzzle.space = i;
		}
	}

	string res = bfs(puzzle);
	cout << res.size() << endl;
	return 0;
}

Measured memory_bytes: 30580
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}

	for _, v := range a {
		if v%2 == 0 {
			if v%3 != 0 && v%5 != 0 {
				fmt.Println("DENIED")
				return
			}
		}
	}
	fmt.Println("APPROVED")

}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>

int main(void){
    char str[1100];
    int q, i, j;
    char order[1100];
    int a, b;
    char tmp[1100], p[1100];
    
    scanf("%s", str);
    scanf("%d", &q);
    for(i=0; i<q; i++) {
        scanf("%s", order);
        if(strcmp(order, "print") == 0) {
            scanf("%d %d", &a, &b);
            for(j=a; j<=b; j++) {
                printf("%c", str[j]);
            }
            printf("\n");
        } else if(strcmp(order, "reverse") == 0) {
            scanf("%d %d", &a, &b);
            for(j=a; j<=a+(b-a)/2; j++) {
                tmp[j] = str[j];
                str[j] = str[a+b-j];
                str[a+b-j] = tmp[j];
            }
        } else if(strcmp(order, "replace") == 0) {
            scanf("%d %d %s", &a, &b, &p);
            for(j=a; j<=b; j++) {
                str[j] = p[j-a];
            }
        }
    }
    
    return 0;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mx = 1e5+10;
ll dp[mx];
ll H[mx];
ll n,m;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>H[i];
    }
    dp[0]=0;
    dp[1]=abs(H[1]-H[0]);
    dp[2]=abs(H[2]-H[0]);
    for(int i=3;i<n;i++)
    {
        dp[i] = min(abs(H[i]-H[i-1])+dp[i-1],abs(H[i]-H[i-2])+dp[i-2]);
    }
    cout<<dp[n-1]<<endl;
}


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

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

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  vector<int>a(N-1),b(N-1);
  for(int i=0;i<N-1;i++)cin>>a[i]>>b[i];
  for(int i=0;i<N-1;i++)a[i]--,b[i]--;
  vector<vector<pii>>v(N);
  for(int i=0;i<N-1;i++)v[a[i]].push_back({b[i],i}),v[b[i]].push_back({a[i],i});
  queue<pii>q;
  q.push({0,-1});
  vector<bool>used(N,false);
  used[0]=true;
  vector<int>ans(N-1);
  while(q.size()!=0){
    pii x=q.front();
    int now=x.first;
    int c=x.second;
    q.pop();
    int i=0;
    for(auto it:v[now]){
      if(i==c)i++;
      if(used[it.first])continue;
      used[it.first]=true;
      q.push({it.first,i});
      ans[it.second]=i;
      i++;
    }
  }
  int Max=0;
  for(auto it:ans)Max=max(Max,it);
  cout<<Max+1<<endl;
  for(auto it:ans)cout<<it+1<<endl;
  return 0;
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  string ans;
  if(S == "Sunny"){
    ans = "Cloudy";
  }else if(S == "Cloudy"){
    ans = "Rainy";
  }else if(S == "Rainy"){
    ans = "Sunny";
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    a,b=MI()
    ans=a+b
    if ans<=9:
        print(ans)
    else:
        print("error")

main()


Measured memory_bytes: 38256
import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
      	
		double T = sc.nextDouble();
      	double X = sc.nextDouble();
      	double a = T/X;
		System.out.println(a);	
    }
}

Measured memory_bytes: 23252
package main

import (
	"fmt"
)

func isAsc(a int, b int, c int) string {
	if a < b && b < c {
		return "Yes"
	}
	return "No"
}

func main() {
	var a, b, c int
	fmt.Scanf("%d %d %d", &a, &b, &c)
	fmt.Println(isAsc(a, b, c))
}



Measured memory_bytes: 1124
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>

using namespace std;
typedef long long ll;


ll ans,mx,mn=1e8,sum,cnt;
int main(){
	int n;
	cin>>n;
	int a[n],b[n];
	for(int i=0; i<n; i++){
		cin>>a[i];
		if(i>0) a[i] += a[i-1];
	}
	for(int i=0; i<n; i++){
		cin>>b[i];
	}
	
	for(int i=0; i<n; i++){
		for(int j=i; j<n; j++){
			sum += b[j];
		}
		ans = max(ans,sum+a[i]);
		sum=0;
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int r=1;
	if(a==b&&a!=c) r=0;
	if(b==c&&a!=c) r=0;
	if(a==c&&b!=c) r=0;
	if(r==1) cout<<"No";
	else cout<<"Yes";
}

Measured memory_bytes: 256
K = int(input())

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

ans = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            ans += gcd(gcd(a, b), c)

print(ans)

Measured memory_bytes: 73900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
int cnt[200001];
int main() {
    int N, K;
    cin >> N >> K;
    for(int i = 0; i < N; i++) {
        int A;
        cin >> A;
        cnt[A]++;
    }
    vector<int> vec;
    for(int i = 1; i <= N; i++) {
        if(cnt[i] > 0) vec.push_back(cnt[i]);
    }
    sort(vec.begin(), vec.end());
    int ans = 0;
    N = vec.size();
    for(int i = 0; i < N-K; i++) {
        ans += vec[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 
const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;
 
int main() {
    int n, a, b;
    cin >> n >> a >> b;

    cout << min(n*a, b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

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

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int R, C, N;
bool is_edge(int x, int y)
{
    if (x == 0 or x == R or y == 0 or y == C)
    {
        return true;
    }
    return false;
}
int convert(int x, int y)
{
    if (x == 0)
    {
        return y;
    }
    if (y == C)
    {
        return C + x;
    }
    if (x == R)
    {
        return C + R + (C - y);
    }
    if (y == 0)
    {
        return C + R + C + (R - x);
    }
    assert(0);
}
int main()
{
    cin >> R >> C >> N;
    vector<pii> positions;
    for (int i = 0; i < N; i++)
    {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        if (is_edge(x1, y1) and is_edge(x2, y2))
        {
            positions.emplace_back(mp(convert(x1, y1), i));
            positions.emplace_back(mp(convert(x2, y2), i));
        }
    }
    sort(positions.begin(), positions.end());
    stack<int> st;
    for (int i = 0; i < positions.size(); i++)
    {
        if (st.empty() or st.top() != positions[i].second)
        {
            st.push(positions[i].second);
        }
        else
        {
            st.pop();
        }
    }
    if (st.empty())
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	auto N=in();
	vector<bitset<64>> mask(N,0);
	REP(i,N){
		auto K=in();
		REP(j,K){
			mask[i][in()] = true;
		}
	}
	bitset<64> bs(0);
	int Q=in();
	REP(i,Q){
		int q=in();
		if(q==1){
			int m=in();
			for(int j=0;j<64;j++){
				if(mask[m][j]) bs[j] = true;
			}
		}
		else if(q==2){
			int m=in();
			for(int j=0;j<64;j++){
				if(mask[m][j]) bs[j] = false;
			}
		}
		else if(q==3){
			int m=in();
			for(int j=0;j<64;j++){
				if(mask[m][j]) bs[j].flip();
			}
		}
		else if(q==4){
			int m=in();
			bool all=true;
			for(int j=0;j<64;j++){
				if(!bs[j] && mask[m][j]){
					all=false;
					break;
				}
			}
			out(all?1:0);
		}
		else if(q==5){
			int m=in();
			bool any=false;
			for(int j=0;j<64;j++){
				if(bs[j] && mask[m][j]){
					any=true;
					break;
				}
			}
			out(any?1:0);
		}
		else if(q==6){
			int m=in();
			bool none=true;
			for(int j=0;j<64;j++){
				if(bs[j] && mask[m][j]){
					none=false;
					break;
				}
			}
			out(none?1:0);
		}
		else if(q==7){
			int m=in();
			int num=0;
			for(int j=0;j<64;j++){
				if(bs[j] && mask[m][j]){
					num++;
				}
			}
			out(num);
		}
		else if(q==8){
			int m=in();
			out((bs&mask[m]).to_ullong());
		}
		else{
			out(bs[in()]?1:0);
		}
	}

	return 0;
}


Measured memory_bytes: 3164
from operator import itemgetter

n = int(input())

j_list = []
for _ in range(n):
    a, b = [int(x) for x in input().split()]
    j_list.append((a, b))
j_list.sort(key=itemgetter(1))

ans = "Yes"
t = 0
for a, b in j_list:
    t += a
    if t > b:
        ans = "No"
        break
print(ans)


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

bool edge[9][9];
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m; cin >> n >> m;
	for(int i = 0; i < m; i++){
		int a, b; cin >> a >> b;
		edge[a][b] = edge[b][a] = true;
	}
	int ans = 0;
	vector<int> v(n);
	for(int i = 0; i < n; i++) v[i] = i+1;
	do {
		if(v[0] != 1) continue;
	    bool ok = true;
	    for(int i = 0; i < n-1; i++){
	    	if(!edge[v[i]][v[i+1]]) ok = false;
	    }
	    if(ok) ans++;
	} while(next_permutation(v.begin(), v.end()));
	cout << ans << endl;
	return 0;
}

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

int main(){
  int n;
  long long a[100000];
  long long sum=0, sum2=0;
  int ptt;
  int i;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a+n, greater<int>());
  //5 4 4
  //4 5 4 = 2
  //
  if(n==3){
    sum=a[0]+a[1]-a[2]*2;
    sum2=a[0]*2-a[1]-a[2];
    cout << max(sum, sum2) << '\n';
    return 0;
  }
  if(n==2){
    sum=a[0]-a[1];
    cout << sum << '\n';
    return 0;
  }

  if(n%2==1){
    ptt=n/2;
    for (i=0; i < ptt; i++) {
      sum+=(2*a[i]);
    }
    sum-=a[i];
    i++;
    sum-=a[i];
    i++;
    for(;i<n;i++){
      sum-=(2*a[i]);
    }
    ptt=n/2-1;
    for (i=0; i < ptt; i++) {
      sum2+=(2*a[i]);
    }
    sum2+=a[i];
    i++;
    sum2+=a[i];
    i++;
    for(;i<n;i++){
      sum2-=(2*a[i]);
    }
    if(sum<sum2){
      sum=sum2;
    }

  }else{
    ptt=n/2-1;
    for (i=0; i < ptt; i++) {
      sum+=(2*a[i]);
    }
    sum+=a[i];
    i++;
    sum-=a[i];
    i++;
    for(;i<n;i++){
      sum-=(2*a[i]);
    }
  }


  cout << sum << '\n';
  return 0;
}


Measured memory_bytes: 1152
R, C, K = map(int, input().split())

V = [[0]*(C+1) for _ in range(R+1)]
for _ in range(K):
    r, c, v = map(int, input().split())
    V[r][c] = v

max_pre = [0]*(C+1)
for i in range(R+1):
    now = [[0]*(3+1) for _ in range(C+1)]
    for j in range(C+1):
        v = V[i][j]
        la = lb = 0
        if j > 0:
            la = now[j-1][0]
            lb = now[j-1][1]
            now[j][2] = max(now[j][2], now[j-1][2], lb + v)
            now[j][3] = max(now[j][3], now[j-1][3], now[j-1][2] + v)
        if i > 0:
            now[j][0] = max(now[j][0], max_pre[j], la)
            now[j][1] = max(now[j][1], max_pre[j] + v, la + v, lb)
        max_pre[j] = max(now[j])

print(max(now[C]))


Measured memory_bytes: 222728
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
    int n, x;
    cin >> n >> x;
    if(n == 2){
        if(x == 2) cout << "Yes" << endl << 1 << endl << 2 << endl << 3 << endl;
        else cout << "No" << endl;
        return 0;
    }
    if(x == 1 || x == 2 * n - 1){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    int ans[200001];
    for(int i = 0; i < 2 * n; i++){
        ans[i] = i;
    }
    swap(ans[n], ans[x]);
    if(x > n){
        if(ans[n - 1] > x - 1) swap(ans[n - 1], ans[x - 1]);
        if(ans[n + 1] != x + 1) swap(ans[n + 1], ans[x + 1]);
        if(ans[n + 2] > x - 2) swap(ans[n + 2], ans[x - 2]);
    } else if(x < n) {
        if(ans[n - 1] < x + 1) swap(ans[n - 1], ans[x + 1]);
        if(ans[n + 1] != x - 1) swap(ans[n + 1], ans[x - 1]);
        if(ans[n + 2] < x + 2) swap(ans[n + 2], ans[x + 2]);
    }
    for(int i = 1; i < 2 * n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}

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

int main() {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    bool water[30];
    fill(water, water+30, false);
    water[0] = true;
    for (int i = 0; i < 30; i++) {
        if (water[i]) {
            if (i+A < 30) water[i+A] = true;
            if (i+B < 30) water[i+B] = true;
        }
    }

    bool sugar[3000];
    fill(sugar, sugar+3000, false);
    sugar[0] = true;
    for (int i = 0; i < 3000; i++) {
        if (sugar[i]) {
            if (i+C < 3000) sugar[i+C] = true;
            if (i+D < 3000) sugar[i+D] = true;
        }
    }

    int w=0, s=0;
    double concentration=0.0;
    for (int i = 1; i < 30; i++) {
        for (int j = 0; j < 3000; j++) {
            if (water[i] && sugar[j]) {
                if (i*100+j <= F && i*E >= j && concentration < (double)100*j/(double)(i*100+j)) {
                    w = i;
                    s = j;
                    concentration = (double)100*j/(double)(i*100+j);
                }
            }
        }
    }
    
    if (concentration == 0) {
        w = A;
    }

    cout << w*100+s << " " << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD =  998244353;
//

     signed main(){
       int x;
       cin>>x;
       cout<<(x/500)*1000+(x%500)/5 *5<<endl;
   }
         


        


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG
#define M 1000000007




int main() {
  ll N, K, ans;
  cin >> N >> K;

  ans = 0;

  for (ll i = K; i<=N+1; i++){
    ll min, max;
    min = i*(i+1)/2;
    max = i*((N+1) + (N+1-i + 1))/2;
    ans += (max - min +1);
    //ans %= M;
  }
   
  cout << ans % M << endl;

  return 0;
}


Measured memory_bytes: 3612
/*
ID: wangjun30
TASK:
LANG: C++
*/
#include<iostream>
using namespace std;
bool pd(int x){
	int s=0;
	while(x){
		x/=10;
		s++;
	}
	return s%2;
}
int main(){
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		if(pd(i))
			ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
template<class T> istream& operator>>(istream &is,vector<T> &st){
  for(size_t i=0;i<st.size();++i) is >> st[i];
  return is;
}
template<class T> istream& operator>>(istream &is,vector<vector<T>> &st){
  for(size_t i=0;i<st.size();++i) is >> st[i];
  return is;
}
template<class T> ostream& operator<<(ostream &os, const vector<T> &st){
  for(size_t i=0;i<st.size();++i){
    if(i==st.size()-1) os << st[i];
    else os << st[i] << " ";
  }
  return os;
}
template<class T> ostream& operator<<(ostream &os, const vector<vector<T>> &st){
  for(size_t i=0;i<st.size();++i){
    os << st[i];
    if(i!=st.size()-1) os << endl;
  }
  return os;
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;
  cin >> n >> k;
  int mx = (n-1)*(n-2)/2;
  if(mx<k){
    cout << -1 << endl;
    return 0;
  }
  //set<pii> s;
  //vvi gr(n);
  cout << n-1+mx-k << endl;
  FOR(i,2,n+1){
    cout << 1 << " " << i << endl;
    // pii p = {1,i+1};
    // s.insert(p);
  }
  int ct = 0;
  FOR(i,2,n+1)FOR(j,i+1,n+1){
    if(ct==mx-k) break;
    ct++;
    cout << i << " " << j << endl;
  }
}



Measured memory_bytes: 256
//
// Created by moono on 2018/10/27.
//

#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;



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

    unsigned int num = K;
    for (int i = 1; i < N; ++i) {
        num *= K-1;
    }

    cout << num << endl;



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define fastio      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int N = 3e3 + 3;
ll ara[N][N] , dp[N][N][5];

int main()  {
    fastio;
    int n, m , kk;
    cin>>n>>m>>kk;
    
    for(int i =0 ; i < kk ; i++ ) {
        int x , y, z ;
        cin>>x>>y>>z;
        ara[x][y] = z; 
    }

    for(int i =1 ; i <=n ; i++ ) {
        for(int j =1 ; j <=m ; j++ ) {
            
            dp[i][j][0] = max({ dp[i-1][j][0] , dp[i-1][j][1] , dp[i-1][j][2], dp[i-1][j][3] });
            dp[i][j][1] = max({ dp[i-1][j][0] , dp[i-1][j][1] , dp[i-1][j][2], dp[i-1][j][3] }) + ara[i][j];

            for(int k = 0 ; k <=3 ; k++ ) {
                dp[i][j][k] = max({dp[i][j][k] , dp[i][j-1][k]});
            }

            for(int k =1 ; k <=3 ; k++ ) {
                dp[i][j][k] = max({dp[i][j][k] , dp[i][j-1][k-1] + ara[i][j]});
            }

        }
    }
    ll ans = 0;
    for(int i =0 ; i <= 3 ; i++ ) ans = max(ans , dp[n][m][i]);
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 425620
#include <bits/stdc++.h>
using namespace std;
int main(){
  int D;
  cin >> D;
  vector<int> c(26);
  for (int i = 0; i < 26; i++){
    cin >> c[i];
  }
  vector<vector<int>> s(D, vector<int>(26));
  for (int i = 0; i < D; i++){
    for (int j = 0; j < 26; j++){
      cin >> s[i][j];
    }
  }
  vector<int> last(26, -1);
  for (int i = 0; i < D; i++){
    vector<vector<vector<vector<int>>>> d(26, vector<vector<vector<int>>>(26, vector<vector<int>>(26, vector<int>(26, 0))));
    for (int j = 0; j < 26; j++){
      for (int k = 0; k < 26; k++){
        for (int l = 0; l < 26; l++){
          for (int m = 0; m < 26; m++){
            d[j][k][l][m] += s[i][j];
            d[j][k][l][m] += c[j] * (i - last[j]) * 4;
            if (i < D - 1){
              d[j][k][l][m] += s[i + 1][k];
              d[j][k][l][m] += c[k] * (i - last[k] + 1) * 3;
            }
            if (i < D - 2){
              d[j][k][l][m] += s[i + 2][l];
              d[j][k][l][m] += c[k] * (i - last[l] + 2) * 2;
            }
            if (i < D - 3){
              d[j][k][l][m] += s[i + 3][m];
              d[j][k][l][m] += c[l] * (i - last[m] + 3);
            }
          }
        }
      }
    }
    int a = 0;
    int mx = 0;
    if (i % 2 == 0){
      for (int j = 0; j < 26; j++){
        for (int k = 0; k < 26; k++){
          for (int l = 0; l < 26; l++){
            for (int m = 0; m < 26; m++){
              if (d[j][k][l][m] > mx){
                a = j;
                mx = d[j][k][l][m];
              }
            }
          }
        }
      }
    } else {
      for (int j = 25; j >= 0; j--){
        for (int k = 25; k >= 0; k--){
          for (int l = 25; l >= 0; l--){
            for (int m = 25; m >= 0; m--){
              if (d[j][k][l][m] > mx){
                a = j;
                mx = d[j][k][l][m];
              }
            }
          }
        }
      }
    }
    cout << a + 1 << endl;
    last[a] = i;
  }
}

Measured memory_bytes: 6140
#include<ctype.h>
#include<stdio.h>

int main(void)
{
	char c;
	
	while(1){
		if(c=='\n') break;
		
		scanf("%c",&c);
		
		if(islower(c)){
			c=toupper(c);
		}
		else c=tolower(c);
		
		printf("%c",c);
	}
	return 0;
}

Measured memory_bytes: 2604
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt(), y = sc.nextInt();
		int[] group1 = {1,3,5,7,8,10,12};
		int[] group2 = {4,6,9,11};
		if(checkSameGroup(x, y, group1)) {
			System.out.println("Yes");
		}else if(checkSameGroup(x, y, group2)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
	static public boolean checkSameGroup(int x, int y, int[] group) {
		boolean sameX = false,sameY = false;
		for (int i : group) {
			if(i == x) sameX = true;
			if(i == y) sameY = true;
		}

		if(sameX && sameY) return true;
		return false;
	}
}


Measured memory_bytes: 21716
#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 cntA[1010101],cntB[1010101];

int main(){
  int N,M; cin>>N>>M;
  rep(i,N){
    int A; cin>>A;
    cntA[A]++;
  }
  rep(j,M){
    int B; cin>>B;
    cntB[B]++;
  }
  
  int sum=0;
  int n=0,m=0;
  ll ans=1;
  for(int i=N*M;i>=1;i--){
    if(cntA[i]==1&&cntB[i]==1){
      sum++;
    }else if(cntA[i]>1||cntB[i]>1){
      cout<<0<<endl;
      return 0;
    }else if(cntA[i]==1){
      (ans*=m)%=MOD;
      sum++;
    }else if(cntB[i]==1){
      (ans*=n)%=MOD;
      sum++;
    }else if(n==0||m==0){
      cout<<0<<endl;
      return 0;
    }else{
      (ans*=(n*m-sum))%=MOD;
      sum++;
    }
    n+=cntA[i];
    m+=cntB[i];
  }

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


Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;
typedef unsigned long long ull;

inline int scan() {
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
inline void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int maxs = max(a, max(b, c));
    int ans = 0;
    ans += (maxs-a)/2;
    a += (maxs-a)/2*2;
    ans += (maxs-b)/2;
    b += (maxs-b)/2*2;
    ans += (maxs-c)/2;
    c += (maxs-c)/2*2;
    int cha = maxs*3-a-b-c;
    if(cha == 2)ans += 1;
    if(cha == 1)ans += 2;
    cout << ans << endl;
    return 0;
}
/*
                 ___====-_  _-====___
           _--^^^#####//      \\#####^^^--_
        _-^##########// (    ) \\##########^-_
       -############//  |\^^/|  \\############-
     _/############//   (@::@)   \\############\_
    /#############((     \\//     ))#############\
   -###############\\    (oo)    //###############-
  -#################\\  / VV \  //#################-
 -###################\\/      \//###################-
_#/|##########/\######(   /\   )######/\##########|\#_
|/ |#/\#/\#/\/  \#/\##\  |  |  /##/\#/  \/\#/\#/\#| \|
`  |/  V  V  `   V  \#\| |  | |/#/  V   '  V  V  \|  '
   `   `  `      `   / | |  | | \   '      '  '   '
                    (  | |  | |  )
                   __\ | |  | | /__
                  (vvv(VVV)(VVV)vvv)
                  ÁúÉñ±£ÓÓ ÓÀÎÞbug
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    string s;cin>>s;
    int n=s.size();
    int now=1;
    vector<int> v;
    rep(i,1,n){
        if(s[i]!=s[i-1]){
            v.push_back(now);
            now=1;
        }
        else{
            now++;
        }
    }
    v.push_back(now);
    
    vector<int> ans;
    for(int i=0;i<v.size();i+=2){
        int r=v[i],t=v[i+1];
        rep(j,0,r-1)ans.push_back(0);
        if(r>=t){
            int y=(r+t)/2;
            int x=y;
            if((r+t)%2)x++;
            if(r%2==1){
                ans.push_back(x);
                ans.push_back(y);
            }
            if(r%2==0){
                ans.push_back(y);
                ans.push_back(x);
            }
        }
        else{
            int y=(r+t)/2;
            int x=y;
            if((r+t)%2)x++;
            if(t%2==1){
                ans.push_back(y);
                ans.push_back(x);
            }
            if(t%2==0){
                ans.push_back(x);
                ans.push_back(y);
            }
        }
        rep(j,0,t-1)ans.push_back(0);
    }
    rep(i,0,ans.size())cout<<ans[i]<<" ";
    cout<<endl;
}


Measured memory_bytes: 1592
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <iostream>

using namespace std;

bool is_prime(int32_t n) {
  if (n == 0 || n == 1) return false;

  for (uint32_t i = 2; i <= (uint32_t)sqrt((double)n); i++) {
    if (n % i == 0) return false;
  }
  return true;
}

vector<int32_t> primes(int32_t n) {
  int32_t count = 100;
  int32_t num = n + 1;
  vector<int32_t> ret;
  while (0 < count) {
    if (is_prime(num)) {
      ret.push_back(num);
      count--;
    }
    num++;
  }
  return ret;
}

int32_t main() {
  while (true) {
    int32_t N, P;
    cin >> N >> P;
    if (N == -1) break;

    vector<int32_t> ps = primes(N);
    vector<int32_t> sums;
    for (uint32_t i = 0; i < ps.size(); i++) {
      for (uint32_t j = i; j < ps.size(); j++) {
        sums.push_back(ps[i] + ps[j]);
      }
    }

    sort(sums.begin(), sums.end());

    cout << sums[P - 1] << endl;
  }

  return 0;
}

Measured memory_bytes: 3212