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

using namespace std;

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

int main(){
    int N;
    cin >> N;
    vector<int> x(N), y(N);
    for(int i = 0; i < N; ++i){
        cin >> x[i] >> y[i];
    }
    map<P, int> cnt;
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < N; ++j){
            if(i == j)      continue;
            
            cnt[P(x[i] - x[j], y[i] - y[j])]++;
        }
    }
    
    int max_cnt = 0;
    for(auto it = cnt.begin(); it != cnt.end(); ++it){
        int temp = it->second;
        if(temp > max_cnt){
            max_cnt = temp;
        }
    }
    
    int res = 1;
    res += N - 1 - max_cnt;
    cout << res << endl;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
void dfs (int cur, int par, int col_used, const vector<vector<int>>& g, map<pair<int, int>, int>& ans) {
  int col = 1;
  for (int child : g[cur]) if (par != child) {
    if (col == col_used) col++;
    ans[{min(child, cur), max(child, cur)}] = col;
    dfs (child, cur, col, g, ans);
    col++;
  }
}
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> g(n);
  vector<pair<int, int>> edges;
  for (int i = 0; i + 1 < n; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    edges.emplace_back(a, b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  map<pair<int, int>, int> ans;
  dfs (0, -1, -1, g, ans);
  int mx = 0;
  for (auto i : ans) mx = max(mx, i.second);
  cout << mx << '\n';
  for (auto e : edges) cout << ans[e] << '\n';
  return 0;
}

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

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

typedef pair<int, int> ii;

int A[25];
int B[25];

int perm[25];

ii set1[25];
ii set2[25];

const int INF = 1012345678;

long long nxs(long long r){
    long long ls1 = r&(-r);
    long long rest = r+ls1;
    return rest|(((rest^r)/ls1) >> 2);
}

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

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

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

    int ans = INF;
    int noBits = (N+1)>>1;
    for(int i = (1<<noBits)-1; i < (1<<N); i = nxs(i)){
        //printf("i=%d\n", i);
        int size1 = 0;
        int size2 = 0;
        for(int j = 0; j < N; j ++){
            if(i&(1<<j)){
                // Place in first set, parity is even (0-indexed)
                if((j&1) == 0){
                    set1[size1++] = ii(A[j], j);
                }else{
                    set1[size1++] = ii(B[j], j);
                }
            }else{
                // Place in second set, parity is odd
                if((j&1) == 0){
                    set2[size2++] = ii(B[j], j);
                }else{
                    set2[size2++] = ii(A[j], j);
                }
            }
        }

        sort(set1, set1+size1);
        sort(set2, set2+size2);

        bool boleh = true;
        for(int j = 0; j < (int)size2; j ++){
            //printf("set1[%d]=ii(%d, %d), set2[%d]=ii(%d, %d)\n", j, set1[j].first, set1[j].second, j, set2[j].first, set2[j].second);
            if(set1[j].first > set2[j].first){
                boleh = false;
                break;
            }

            if( ((N&1) == 0) && j == (int)size2-1 ){
                break;
            }

            if(set1[j+1].first < set2[j].first){
                boleh = false;
                break;
            }
        }

        if(boleh){
            for(int j = 0; j < size2; j ++){
                perm[j<<1] = set1[j].second;
                perm[(j<<1)|1] = set2[j].second;
            }
            if(N&1){
                perm[N-1] = set1[size2].second;
            }

            int inv = 0;
            for(int j = 0; j < N; j ++){
                for(int k = j+1; k < N; k ++){
                    if(perm[j] > perm[k]){
                        inv ++;
                    }
                }
            }

            ans = min(ans, inv);
        }
    }

    if(ans == INF){ans = -1;}
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define inf 999999999
int main(){
    int h,w,cost[52][52],cnt;
    char s[52][52];
    scanf("%d%d",&h,&w);
    for(int i=1;i<=h;i++) scanf("%s",s[i]+1);
    for(int i=0;i<52;i++) for(int j=0;j<52;j++) cost[i][j]=inf;
    cost[1][1]=1;
    for(int k=1;cost[h][w]==inf;k++){
        cnt=0;
        for(int i=1;i<=h;i++) for(int j=1;j<=w;j++){
            if(cost[i][j]==k){
                cnt++;
                if(s[i-1][j]=='.'&&cost[i-1][j]>k)cost[i-1][j]=k+1;
                if(s[i][j-1]=='.'&&cost[i][j-1]>k)cost[i][j-1]=k+1;
                if(s[i+1][j]=='.'&&cost[i+1][j]>k)cost[i+1][j]=k+1;
                if(s[i][j+1]=='.'&&cost[i][j+1]>k)cost[i][j+1]=k+1;
            }
        }
        if(cnt==0){
            printf("-1\n");
            return 0;
        }
    }
    cnt=0;
    for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) if(s[i][j]=='.') cnt++;
    printf("%d\n",cnt-cost[h][w]);
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

map<int, int> a;
int n, m;
vector<bool> isBroken;

int fibWithTopDownDP(int num) {
  if (a.count(num) == 0) {
    if (isBroken[num])
      a[num] = 0;
    else if (num == 1 || num == 0)
      a[num] = 1;
    else
      a[num] = fibWithTopDownDP(num - 1) + fibWithTopDownDP(num - 2);
    a[num] %= mod;
  }
  return a[num];
}

signed main() {
  cin >> n >> m;
  isBroken.resize(n + 1, false);
  REP(i, m) { isBroken[read()] = true; }
  print(fibWithTopDownDP(n));
}


Measured memory_bytes: 14336
import sys
import functools
# sys.setrecursionlimit(100000000)
n = input()
# import random
# n = ''.join(str(random.randint(1,9)) for _ in range(10**6))

#
# @functools.lru_cache(None)
# def doit(index: int, carry: int) -> int:
#     if index >= len(n):
#         return 0 if carry == 0 else 2
#     d = int(n[index])
#     if carry > 0:
#         return min(10 - d + doit(index + 1, 0), 9 - d + doit(index + 1, 1))
#     else:
#         return min(d + doit(index + 1, 0), d + 1 + doit(index + 1, 1))
#
#
# print(min(doit(0, 0), 1 + doit(0, 1)))


dp = [0, 2]
for d in reversed(n):
    d = int(d)
    dp = [min(d + dp[0], d + 1 + dp[1]), min(10 - d + dp[0], 9 - d + dp[1])]

print(min(dp[0], 1 + dp[1]))


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

using namespace std;

typedef long long ll;

ll a[5], res;

bool cmp(ll x, ll y) {
	x %= 10, y %= 10;
	if (x == 0) x = 10;
	if (y == 0) y = 10;
	return x < y;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	for (ll i = 0; i < 5; ++i) cin >> a[i];
	sort(a, a + 5, cmp);
	
	for (ll i = 1; i < 5; ++i) {
		while (a[i] % 10) ++a[i];
	}
	
	res = 0;
	for (ll i = 0; i < 5; ++i) res += a[i];
	cout << res;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char[] c = new char[s.length()];
    c = s.toCharArray();
    for(int i = s.length()-2; i >= 0; i--) {
      int j = (i + 1) / 2;

      for(int k = 0; k < j; k++) {
        if(k+j > i) break;
        if(c[k] != c[k+j]) {
          break;
        }
        if(k == j-1) {
          System.out.println(2*(k+1));
          return;
        }
      }
    }
  }
}


Measured memory_bytes: 23892
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;

std::string S, T;
std::deque<ll> deq;

int main()
{
  std::cin >> S >> T;

  if( S == T )
  {
    std::cout << "Yes" << std::endl;

    return 0;
  }

  rep( i, S.size() )
  {
    S = S.substr( 1, S.size()-1 )+S[0];

    if( S == T )
    {
      std::cout << "Yes" << std::endl;

      return 0;
    }
  }

  std::cout << "No" << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {

    int A , B, sum=0;

    scanf("%d %d", &A, &B);

    if(A >= B){
        sum = A;
        A--;
    }else{
        sum = B;
        B--;
    }

    if(A >= B){
        sum += A;
        A--;
    }else if(B > A){
        sum += B;
        B--;
    }

    printf("%d\n", sum);


    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
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 V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc172/tasks/abc172_a>
 問題文============================================================
 A - Calc
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll a; cin >> a;
    res = a + a*a + a*a*a;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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

using namespace std;

int main() {
   ios_base :: sync_with_stdio(0);
   cin.tie(0) , cout.tie(0);
   int n;
   cin >> n;
   vector<double> a(n , 0);
   for (int i = 0; i < n; i++) {
      cin >> a[i];
   }
   sort(a.begin() , a.end());
   reverse(a.begin() , a.end());
   double tot = 0.0;
   tot = (a.back() + a[n - 2]) / 2.0;
   a.pop_back();
   a.pop_back();
   while (!a.empty()) {
      double x = a.back();
      a.pop_back();
      tot = (tot + x) / 2.0;
   }
   cout << fixed << setprecision(6) << tot << '\n';
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define ll long long
#define mod 1000000007
#define bitcount    __builtin_popcountll
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define pi pair<int,int>
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n,m,i,j,k,l;
    string a[55],b[55];
    sd(n);
    sd(m);
    for(i=0;i<n;i++)
    	cin>>a[i];
    for(i=0;i<m;i++)
    	cin>>b[i];
    for(i=0;i<n-m+1;i++)
    {
    	for(j=0;j<n-m+1;j++)
    	{
    		for(k=0;k<m;k++)
    		{
    			for(l=0;l<m;l++)
    			{
    				if(b[k][l]!=a[i+k][j+l])
    					break;
    			}
    			if(l!=m)
    				break;
    		}
    		if(k==m)
    		{
    			printf("Yes\n");
    			return 0;
    		}
    	}
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define PI pair<int,int>
#define F first
#define S second
#define all(x) x.begin(),x.end()
using namespace std;
int a,b;
int main(){
    cin >> a >> b;
    cout << max(max(a+b,a-b),a*b) << "\n";
}

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

int a[110],n,k,x,y;

int main()
{
    scanf("%d%d",&n,&k);
    while(k--)
    {
        scanf("%d",&x);
        while(x--)
        {
            scanf("%d",&y);
            a[y]++;
        }
    }
    int ans = 0;
    for(int i = 1;i <= n; ++i)
        if(!a[i]) ans++;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3824
#include <iostream>
#include <vector>
#include <algorithm>
int k;
std::vector<int> r, c, que, used;
void solve(int i){
    if(i == 8){
        for(int j = 0; j < k; j++){
            if(que[r[j]] != c[j]) return;
        }
        for(int j = 0; j < 8; j++){
            for(int l = 0; l < 8; l++){
                if(j != l && std::abs(l - j) == std::abs(que[l] - que[j])) return;
            }
        }
        for(int j = 0; j < 8; j++){
            for(int l = 0; l < 8; l++){
                if(que[j] == l) std::cout << 'Q';
                else std::cout << '.';
                if(l == 7)std::cout << std::endl;
            }
        }
    }
    for(int j = 0; j < 8; j++){
        if(used[j] == 1) {
            que[i] = j;
            used[j] = 0;
            solve(i + 1);
            used[j] = 1;
        }
    }
}
int main(){
    std::cin >> k;
    r.resize(k);
    c.resize(k);
    used.resize(8, 1);
    que.resize(8);
    for(int i = 0; i < 8; i++) que[i] = i;
    for(int i = 0; i < k; i++) std::cin >> r[i] >> c[i];
    solve(0);
}


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

int main(){
int n;
cin>>n;
int count=0;
vector<char>s(n);
rep(i,n){
    cin>>s[i];
}
rep(i,n){
if(s[i]=='A'){
    if(s[i+1]=='B'){
        if(s[i+2]=='C'){
            count++;
        }
    }
}

}
cout<<count<<endl;

}

Measured memory_bytes: 3636
n = int(input())
s = {}
for _ in range(n) :
    s_sub = input()
    if s_sub in s.keys() :
        s[s_sub] += 1
    else :
        s[s_sub] = 1


s_sorted1 = sorted(s.items(), key = lambda value: -value[1])
max = s_sorted1[0][1]
ans = []
for j,k in s_sorted1 :
    if k == max :
        ans.append(j)
    else:
        break

for x in sorted(ans):
    print(x)


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

def main():
    N = int(input())
    s = sorted(list(map(int, input().strip().split())), reverse=True)
    check = [False] * (2**N)
    now = []
    now.append([s[0], 1])
    check[0] = True
    ok = True
    for i in range(N):
        next_ = []
        tmp = 0
        for j in range(len(now)):
            hp, start = now[j]
            start = max(start, tmp)
            ok = False
            for k in range(start, 2**N):
                if s[k] < hp and not check[k]:
                    tmp = k+1
                    now[j][1] = k+1
                    check[k] = True
                    next_.append([s[k], k+1])
                    ok = True
                    break
            if not ok:
                break
        now += next_
        now = sorted(now, reverse=True)
        if not ok:
            break
    
    if ok:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Measured memory_bytes: 56216
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] H = new int[N];
        for (int i = 0; i < N; i++) {
            H[i] = Integer.parseInt(sc.next());
        }

        int count = 0;
        int tmpCount = 0;
        for (int i = 0; i < N - 1; i++) {
            if (H[i] >= H[i + 1]) {
                tmpCount++;
                if (i == N - 2 && tmpCount > count) {
                    count = tmpCount;
                }
            } else {
                if (tmpCount > count) {
                    count = tmpCount;
                }
                tmpCount = 0;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 48516
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std ;
vector<int> g[111111];
int dp[111111];

int solve(int n){
    if(dp[n]!=-1)return dp[n];
    int res=0;
    for(int i=0;i<g[n].size();i++){
        res=max(res,solve(g[n][i])+1);
    }
    dp[n]=res;
    return dp[n];
}
int main(){
    int n,m;cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        g[a].push_back(b);
    }
    for(int i=0;i<n;i++)dp[i]=-1;
    int ans=0;
    for(int i=0;i<n;i++){
        ans=max(ans,solve(i));
    }
    cout<<ans;
}

Measured memory_bytes: 8448
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int t[26];
char xxx;
int main(void){
    string s;
    cin>>s;
    if(s=="zyxwvutsrqponmlkjihgfedcba"){cout<<-1<<endl;return 0;}
    if(s.size()<26){
        for(int i=0;i<s.size();i++){
            t[s[i]-'a']++;
        }
        for(int i=0;i<26;i++){
            if(t[i]==0){
                cout<<s+char('a'+i)<<endl;
                return 0;
            }
        }
    }
    else{
        int i;
        reverse(s.begin(),s.end());
        char ss=s[0];
        //cout<<s[0]<<endl;
        t[ss-'a']++;
        for(i=1;i<26;i++){
            if(ss-'a'<s[i]-'a'){
                t[s[i]-'a']++;
                ss=s[i];
            }
            else break;
        }
        if(s[i]!='z'){
        for(int j=25;j>=0;j--){
            if(t[j]==1&&s[i]-'a'<j){
                xxx=char('a'+j);
            }
        }
        //cout<<xxx<<endl;
        s.erase(0,i+1);
        reverse(s.begin(),s.end());
        cout<<s+xxx<<endl;
        return 0;
        }
        else{
            
            
            for(int j=0;j<26;j++){
            if(t[j]==1){
                xxx=char('a'+j);
                break;
            }
            }
            s.erase(0,i+1);
        reverse(s.begin(),s.end());
        cout<<s+xxx<<endl;
        return 0;
            
        }
    }
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ss second
#define ff first
#define Mem(x,val) memset(x,val,sizeof x)
#define pb push_back
#define all(v) v.begin(),v.end()
#define unik(v)  v.erase(unique(v.begin(),v.end()),v.end())
#define cerr(x) cerr << __LINE__ << " th Line : " << #x << " = " << x << "\n"
#define debug(a,b) cerr << #a<<" = "<<a<<"   |   "<<#b<<" = "<<b<<'\n'
#define endl '\n'
#define SZ(a) ((int)a.size())
using namespace std;
typedef pair<int, int> pi32;
typedef pair<ll, ll> pi64;
typedef vector<int> vi32;
typedef vector<ll> vi64;
typedef vector<pi32> vp32;
typedef vector<pi64> vp64;
const ll mod = 1e9 + 7;
const int MX = 1e5+7;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	//int x,y;
	//cin>>x>>y;
	//if(x*2==y || x*4==y || ((x-1)*2+4)==y || ((x-1)*4+2)==y)cout<<"Yes\n";
	//else cout<<"No\n";
	
	vi32 a(5);
	for(int i=0;i<5;i++)cin>>a[i];
	for(int i=0;i<5;i++){
		if(a[i]==0){
			cout<<i+1<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

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

    ll dp[105][5][5][5] = {0,};
    for(int c1 = 0; c1 < 4; c1++){
        for(int c2 = 0; c2 < 4; c2++){
            for(int c3 = 0; c3 < 4; c3++){
                if(c1==0 && c2==2 && c3==1){continue;}
                if(c1==2 && c2==0 && c3==1){continue;}
                if(c1==0 && c2==1 && c3==2){continue;}
                dp[3][c1][c2][c3] = 1;
            }
        }
    }
    for(int i = 4; i < n+1; i++){
        for(int c1 = 0; c1 < 4; c1++){
            for(int c2 = 0; c2 < 4; c2++){
                for(int c3 = 0; c3 < 4; c3++){
                    for(int j = 0; j < 4; j++){
                        if(c1==0 && c2==2 && c3==1){continue;}
                        if(c1==2 && c2==0 && c3==1){continue;}
                        if(c1==0 && c2==1 && c3==2){continue;}
                        if(j==0 && c2==2 && c3==1){continue;}
                        if(j==0 && c1==2 && c3==1){continue;}
                        dp[i][c1][c2][c3] += dp[i-1][j][c1][c2];
                        dp[i][c1][c2][c3] %= MOD;
                    }
                }
            }
        }
    }
    ll ans = 0;
    for(int c1 = 0; c1 < 4; c1++){
        for(int c2 = 0; c2 < 4; c2++){
            for(int c3 = 0; c3 < 4; c3++){
                ans += dp[n][c1][c2][c3];
                ans %= MOD;
            }
        }
    }
    cout << ans%MOD << endl;
    return 0;
}


Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod= 1e+9+7;

int main() {
    ll x,y;
    cin>>x>>y;
    if(x>=0&&y>=0&&x<y){
        cout<<y-x<<endl;
    }
    else if(x>=0&&y>=0&&x>y){
        if(y==0)cout<<x-y+1<<endl;
        else cout<<x-y+2<<endl;
    }
    else if(x<0&&y<0&&x>y){
        cout<<x-y+2<<endl;
    }
    else if(x<0&&y<=0&&x<y){
        if(y==0)cout<<-x<<endl;
       else cout<<abs(x)-abs(y)<<endl;
    }
    else {
        cout<<abs(abs(x)-abs(y))+1<<endl;
    }


}


 



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

int main(){
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        int x,max,cnt=0;
        cin >> x;
        while(x>=10){
            max=0;
            for(int j=10; j<x; j*=10){
                int val = x/j * (x%j);
                if(val > max){
                    max = val;
                }
            }
            x=max;
            cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}

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


int main(){
    string S,T,U;
    int A,B;
    cin >> S >> T >> A >> B >> U;
    if (U==S)
        cout << A-1 <<" " << B << endl;
    else
        cout << A << " " << B-1 << endl;
	return 0;
}



Measured memory_bytes: 256
import java.awt.Point;
import java.util.ArrayDeque;
import java.util.Scanner;
import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Collection;


 
public class Main{
	
        static final Scanner sc=new Scanner(System.in);
        static String S=sc.next();
        
        
        
        
        
        public static void main(String[]args){
                int x=0;
                for(int i=0;i<4;i++){
                        if(S.charAt(i)=='+'){
                                x++;
                        }else{
                                x--;
                        }

                }
                System.out.println(x);


                
                

        }
        
        
        

		
	
}


Measured memory_bytes: 22100
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	ans := 36
	for i := 0; i < N; i++ {
		var a int
		fmt.Scan(&a)
		tmp := 0
		for a % 2 == 0 {
			a /= 2
			tmp++
		}
		if tmp < ans {
			ans = tmp
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		sc.close();
		
		if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0) {
			System.out.println("Possible");
		}else {
			System.out.println("Impossible");
		}

	}

}


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

int a[200001];
int psum[200001];
unordered_map <int,int> cnt;
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n,k;

	cin >> n >> k;

	for(int i=1;i<=n;i++)
	{
		cin >> a[i];
		a[i]%=k;
	}

	for(int i=1;i<=n;i++)
	{
		psum[i] = psum[i-1] + a[i];
		psum[i]%=k;
	}

	for(int i=0;i<=n;i++)
	{
		psum[i] = ((psum[i] - i)%k +k)%k;
	}

	cnt[0] = 1;
	long long int res = 0;
	for(int i=1;i<=n;i++)
	{
		if(i-k>=0)
		{
			cnt[psum[i-k]]-=1;
		}
		if(cnt.find(psum[i])!=cnt.end())
		{
			res += cnt[psum[i]];
			cnt[psum[i]]+=1;
		}
		else
		{
			cnt[psum[i]] = 1;
		}
	}

	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 10056
S = str(input())[::-1]
words = ['maerd', 'esare', 'remaerd', 'resare']

leng = len(S)
while leng>=5:
    if S[:5] in words:
        S = S[5:]
        leng -= 5
    elif leng>=7 and S[:7] in words:
        S = S[7:]
        leng -= 7
    elif leng>=6 and S[:6] in words:
        S = S[6:]
        leng -= 6
    else:
        print('NO')
        break

if leng==0:
    print('YES')

Measured memory_bytes: 3188
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int[] p = new int[n];
    for (int i = 0; i < n; i++) {
      p[i] = Integer.parseInt(sc.next());
    }
    int min = p[0];
    int count = 0;
    for (int i = 0; i < n; i++) {
      int pi = p[i];
      if (pi <= min) {
        count++;
      }
      min = Math.min(min, pi);
    }
    pw.println(count);
  }
}


Measured memory_bytes: 56892
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int cnt = 0;
  string s;
  cin >> s;
  for (int i = 0; i < 6; ++i) {
    if (s[i] == '1') {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// Scannerクラスのインスタンスを作成
	    // 引数で標準入力System.inを指定する
	    Scanner scanner = new Scanner(System.in);
	    int R = scanner.nextInt();
	    
	    if((0 <= R)&&(R < 1200)) {
	    	System.out.println("ABC");
	    }else if ((1200 <= R)&&(R < 2800)) {
	    	System.out.println("ARC");
		}else {
			System.out.println("AGC");
		}

	    // Scannerクラスのインスタンスをクローズ
	    scanner.close();

	}

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
typedef long long ll;

using namespace std;
ll a, b, c, res;

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

if(a == b && b == c && a % 2 == 0){
  cout << -1;
}
else{
  while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0){
    int a2 = a, b2 = b, c2 = c;
    a = (b2 + c2) >> 1;
    b = (a2 + c2) >> 1;
    c = (a2 + b2) >> 1;
    res++;
  //  cout << a << ' ' << b << ' ' << c << '\n';
  }
  
  cout << res;
}
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define print(x) std::cout<<x<<"\n"
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SZ(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = lcm(a, v[i]);} return a;}
VI Bit2Vector(const ll bit, ll n) {	VI s;	rep(i,n) if (bit & (1 << i)) s.push_back(i); return s;}


bool check(ll i,ll j, ll k,string s){
	bool ret=false;
	if(s[i]!=s[j] && s[k]!=s[j] && s[k]!=s[i]) ret=true;
	return ret;
}

void Main()
{
	ll n,m,l; ll res=0;
	string s,t,u; string sres="No or NO";

	cin>>n;
	cin>>s;
	ll cnt=0;
	map<char,ll> mp;
	rep(i,SZ(s)) mp[s[i]]++;
	for (ll i = 0; i <=n-2 ; ++i) {
		for (ll j =i+1; j <= n-1; ++j) {
			ll k=2*j-i;
			if(k>=n) continue;
			if (check(i, j, k, s)) cnt++;
		}
	}
	res=mp['R']*mp['G']*mp['B']-cnt;
	cout << res << "\n";
	return;
}

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


Measured memory_bytes: 3612
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cerr << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int a,b,c;
int solve(int num, const vector<int> &d){
    //    show(num);
    int res = 1<<30;
    if(num == 0){
        int n = (int)d.size();
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(i==j)continue;
                for(int k = 0; k < n; k++){
                    if(i==k or j ==k)continue;
                    if(i!=j and j != k and k != i)res = min(res,abs(a-d[i])+abs(b-d[j])+abs(c-d[k]));
                }
            }
        }
    }else{
        int n = (int)d.size();
        for(int i = 0; i < n-1; i++){
            vector<int>dd;
            for(int j = 0; j < n; j++)if(j != i)dd.push_back(d[j]);
            for(int j = i; j < n-1; j++){
                dd[j]+=d[i];
                res = min(res, solve(num-1,dd)+10);
                dd[j]-=d[i];
            }
        }
    }
    return res;
}
int main(){
    int n;
    cin >> n >> a >> b >> c;
    vector<int>d(n);
    rep(i,n)cin >> d[i];
    int ans = 1<<30;
    //    solve(2,d);
    for(int i = 0; i <= n-3; i++){
        ans = min(ans, solve(i,d));
        //        show(solve(i,d));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;

int main(void) {
    ll n, i, tmp=0, ans=0;
    cin >> n;
    ll a[n];
    
    for(i=0; i<n; i++)
        cin >> a[i];
    sort(a, a+n);
    
    for(i=0; i<n; i++) {
        tmp=1;
        while(a[i]==a[i+1]) {
            tmp++;
            i++;
        }
        ans+=tmp%2;
    }
    cout << ans << endl;
}


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

int main() {
    int N, K, cut;
    cin >> N >> K;
    cut = (N-1)*(N-2)/2 - K;
    if (cut < 0) cout << -1;
    else {
        cout << N - 1 + cut << endl;
        for (int i = 1; i < N; i++) cout << "1 " << i+1 << endl;
        if (cut) {
            for (int i = 2; i < N; i++) {
                for (int j = 1; j < i; j++) {
                    cout << j + 1 << " " << i + 1 << endl;
                    cut--;
                    if (!cut) return 0;
                }
            }
        }
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    string S;
    cin >> S;
    string T;
    cin >> T;

    int ans = 0;
    REP(i,3){
        if(S[i] == T[i]) ans++;
    }

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		int cnt = 0;
		
		for(int i = a; i < b + 1; i++) {
			if(c % i == 0) {
				cnt += 1;
			}
		}
		
		System.out.println(cnt);
		
		sc.close();
	}

}



Measured memory_bytes: 26376
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
	string s;
	cin >> s;
	int N = s.size();
	int P = 0;
	for( auto c : s ) if( c == 'p' ) ++P;
	cout << ( N / 2 ) - P << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int w; cin >> w;
    for(int i = 0; i < S.length(); i += w) {
        cout << S[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
/*
  AOJ 0529
  Title:Darts
  @kankichi573
  13/10/10 TLE
*/
#include <stdio.h>
#include <string.h>

int N,M,P[1001];
int sum2[1002001];
int s2size;


int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int search(int x)
{
  int first,last,center;
  first=0;
  last=s2size-1;

  if(sum2[last]<x)
    return(sum2[last]);
  while(first<last)
    {
      center=(first+last)/2;
      //printf("%d %d %d [%d]\n",first,center,last,sum2[center]);
      if(x==sum2[center])
	return(x);
      if(sum2[center]<x && sum2[center+1]>x)
	return(sum2[center]);
      if(sum2[center]<x)
	first=center;
      else
	last =center;
    }
}

int solve()
{
  int max_,s,s2,i;
  max_=0;

  for(i=0;i<s2size;i++)
    {
      s=sum2[i];
      if(M-s < 0)
	continue;
      s2=s+search(M-s);

      if(max_<s2)
	max_=s2;
    }
  return(max_);
}

prepare()
{
  int i,j,c;
  c=0;
  for(i=0;i<N+1;i++)
    for(j=i;j<N+1;j++)
      {
	sum2[c]=P[i]+P[j];
	c++;
      }
  qsort(sum2,s2size,sizeof(int),compare_int);
}


main()
{
        int i,ret;

        while(EOF!=scanf("%d %d",&N,&M) && (N||M))
        {
	  memset(sum2,0,sizeof(sum2));
	  s2size=(N+1)*(N+2)/2;
	  for(i=0;i<N;i++)
	    scanf("%d",&P[i+1]);
	  prepare();

	  ret=solve();
	  printf("%d\n",ret);
        }
        return(0);
}

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

// mp[a] ????????????a????????°?????¨???
int main()
{
	int a, b;
	while(1){
		map<int, int> mp;
		mp.clear();
		while(1){
			if(!(cin >> a >> b)) return 0;
			//cin >> a;
			//cin >> b;

			if(mp[a]==0) mp[a] =1;
			//else(mp[a]); mp[a] +=1;  else????????¨if???????????????{}??§?????????????????????????????£?????????????????£?????????
			else if (mp[a]) mp[a] +=1;

			if(mp[b]==0) mp[b] =1;
			else if (mp[b]) mp[b] +=1;
			//cout << "degree of a: " << mp[a] << "\ndegree of b:" << mp[b] << "\n";
			// End condition
			if(a==0) break;

		}

		//????????¨??????
		int hantei1 = mp[1]%2;
		int hantei2 = mp[2]%2;
		bool hantei3 = true;
		//????????\??????Verteies
		for(map<int, int>::iterator it=mp.begin(); it!=mp.end(); ++it){
			if(it->first != 1 && it->first !=2){
				if(it->second %2 == 1){
					hantei3 = false;
					break;
				}
			}
		}
		
		if(hantei1==1 && hantei2==1 && hantei3==true){
			cout << "OK\n";
		}
		else {
			cout << "NG\n";
		}
	}

//	for(map<int, int>::iterator it=mp.begin(); it!=mp.end(); ++it){
//		cout << "degrees of " << it->first << ": " << it->second << '\n';
//	}
	
	return 0;
}

Measured memory_bytes: 3088
N,W=map(int,input().split())

wvlist=[]
for i in range(N):
  w,v=map(int,input().split())
  wvlist.append((w,v))
  
#normalize
w1=wvlist[0][0]

w2vlist=[]
for i in range(N):
  w,v=wvlist[i]
  w2vlist.append((w,w-w1,v))
#print(w2vlist)

dp=[[[0]*(3*N+1) for _ in range(N+1)] for _ in range(N+1)]
#print(dp)

for i in range(1,N+1):
  w,wd,v=w2vlist[i-1]
  for j in range(1,i+1):
    for k in range(3*N+1):
      dp[i][j][k]=dp[i-1][j][k]
      if k-wd>=0:
        dp[i][j][k]=max(dp[i][j][k],dp[i-1][j-1][k-wd]+v)

max_answer=0
for j in range(N+1):
  for k in range(3*N+1):
    if w1*j+k<=W:
      max_answer=max(max_answer,dp[N][j][k])
      #print(j,k,dp[N][j][k])
      
print(max_answer)

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

int main() {
  int n; cin >> n;
  int vec[n];
  rep(i,n){
    cin >> vec[i];
  }
  int ans = 1;
  bool flag = true;
  rep(i,n){
    //cout << vec[i] << endl;;
    if(vec[i] == ans){
      //printf("judged! => %d\n",ans);
      flag = false;
      ans++;
    }
  }
  if(flag) cout << -1 << endl;
  else cout << n-(ans-1) << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    int rem = a - b;
    c = max(0, c - rem);
    cout << c << endl;
    return 0;
}


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

int main() {
    while (true) {
        int n, k;
        cin >> n >> k;
        if ((n | k) == 0) {
            break;
        }
        int* a = new int [n];
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        int* s = new int [n - k + 1];
        s[0] = 0;
        for (int i = 0; i < k; i++) {
            s[0] += a[i];
        }
        int maxS = s[0];
        for (int i = 1; i <= n - k; i++) {
            s[i] = s[i - 1] - a[i - 1] + a[i + k - 1];
            if (maxS < s[i]) {
                maxS = s[i];
            }
        }
        cout << maxS << endl;
        delete[] a;
        delete[] s;
    }
}

Measured memory_bytes: 1280
#include <stdio.h>

#define N_MAX 30
#define QUEUE_MAX 1801 /* 2*N_MAX^2 + 1 */

//Queue

int Q[QUEUE_MAX], sp, rp;

void Qstore(int N){ Q[sp++%QUEUE_MAX]=N; }
void Qstore2(int N, int M){ Q[sp++%QUEUE_MAX]=N, Q[sp++%QUEUE_MAX]=M; }
int Qretrive(){ return Q[rp++%QUEUE_MAX]; }
int Qempty(){ return sp==rp; }

//Main

int H,W;

int main(void){
	int hpart[N_MAX][N_MAX], vpart[N_MAX][N_MAX], step[N_MAX][N_MAX], x, y, depth;	
		
	while(scanf("%d %d",&W,&H), W!=0){
	
		/* load */
		for(y=0; y<H-1; y++){
			for(x=0; x<W-1; x++) scanf("%d",&hpart[x][y]);
			for(x=0; x<W; x++) scanf("%d",&vpart[x][y]); }
		for(x=0; x<W-1; x++) scanf("%d",&hpart[x][y]);
		
		/* initialize */
		sp=0, rp=0;
		for(x=0; x<W; x++) for(y=0; y<H; y++) step[x][y]=-1;
		
		/* search */
		depth=0, step[0][0]=0, Qstore2(0,0), Qstore(-1);
		
		while(1){
			depth++;
			while((x=Qretrive())!=-1){
				y=Qretrive();
				if(W>x+1 && !hpart[x][y] && step[x+1][y]==-1) step[x+1][y]=depth, Qstore2(x+1,y);
				if(H>y+1 && !vpart[x][y] && step[x][y+1]==-1) step[x][y+1]=depth, Qstore2(x,y+1);
				if(x>0 && !hpart[x-1][y] && step[x-1][y]==-1) step[x-1][y]=depth, Qstore2(x-1,y);
				if(y>0 && !vpart[x][y-1] && step[x][y-1]==-1) step[x][y-1]=depth, Qstore2(x,y-1);
			}
			if(Qempty() || step[W-1][H-1]!=-1) break;
			else Qstore(-1);
		}
		
		/* out */
		if(step[W-1][H-1]==-1) printf("0\n");
		else printf("%d\n",step[W-1][H-1]+1);
	}
}

Measured memory_bytes: 0
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  int ans = INF;
  int upper = 2*max(X, Y);
  for(int i=0; i<=upper; i+=2){
    int v = i*C;
    v += max(X-i/2, 0)*A;
    v += max(Y-i/2, 0)*B;
    ans = min(ans, v);
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b>=c){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1000000007
#define mxval 1e9 + 7
#define grt [](auto x,auto y){return x>y;}
#define pii pair<int,int>
/*********VARIABLE****************/
using namespace std;
int i,j,n,m,k,l,q,t,a,b,sum[3],tot[3],cnt[3];
/*********FUNCTIONS**************/
int powom(int a,int b) {
    int result = 1;
    while (b > 0) {
        if (b & 1)
            result = result * a;
        a = a * a;
        b >>= 1;
    }
    return result;
}
/***********MAIN**************/
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cin>>n>>m;
    for(int i=m-n+1;i<=(m+n-1);i++){
        cout<<i<<" ";
    }
    return 0;
}
//.........

Measured memory_bytes: 256
n = int(input())
a_list = list(map(int, input().split()))
 
h_list = [0]*(n+10)
 
for i in range(1,len(a_list)):
    if a_list[i]  < a_list[i-1] + h_list[i-1]:
        h_list[i] = a_list[i-1] + h_list[i-1] - a_list[i] 
    elif a_list[i] >= a_list[i-1] + h_list[i-1]:
        h_list[i] = 0
        
print(sum(h_list))

Measured memory_bytes: 33184
WHITE = '.'
BLACK = '#'

N = gets.chomp.to_i
S = gets.chomp

whites = S.count(WHITE)

# しゃくとり法
# 全部白にする場合の要変更数をセット
cumulative = [whites]

N.times do |i|
  cumulative[i + 1] =
    if S[i] == BLACK
      cumulative[i] + 1
    else
      cumulative[i] - 1
    end
end

puts cumulative.min


Measured memory_bytes: 3916