akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

// ABC 64-C
// https://beta.atcoder.jp/contests/abc064/tasks/abc064_c

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		int[] nums = new int[9];
		
		for (int i = 0; i < N; i++) {
			int a = in.nextInt();
			if (a >= 3200) {
				nums[8]++;
			} else {
				nums[a / 400]++;
			}
		}
		
		int count = 0;
		for (int i = 0; i < 8; i++) {
			if (nums[i] > 0) {
				count++;
			}
		}
		int min = count;
		int max = count;
		if (min == 0) {
			min = 1;
		}
		if (nums[8] > 0) {
			max = count + nums[8];
		}
		System.out.printf("%d %d\n", min, max);
	}
}


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

typedef long long ll;
const int maxn = 100005, maxm = 200005;

inline int gi()
{
    char c = getchar();
    while (c < '0' || c > '9') c = getchar();
    int sum = 0;
    while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
    return sum;
}

int n, m, d[maxn];

struct edge
{
    int to, next,vis;
} e[maxm * 2];
int h[maxn], tot = 1;
int w[maxm], col[maxn], fa[maxn];

inline void add(int u, int v)
{
    e[++tot] = (edge) {v, h[u]}; h[u] = tot;
    e[++tot] = (edge) {u, h[v]}; h[v] = tot;
}

void dfs(int u)
{
    for (int i=h[u];i;i=e[i].next) {
	if(!e[i].vis)continue;
	int v=e[i].to;
	if (col[v] == -1) col[v] = 1-col[u] , dfs(v);
    }
}

int main()
{
    n = gi(); m = gi();
    for (int i = 1; i <= n; ++i) d[i] = gi();
    for (int i = 1; i <= m; ++i) add(gi(), gi());
    fill(w + 1, w + m + 1, 1e9);

    d[0] = 2e9;
    for (int u = 1; u <= n; ++u) {
	if(!h[u])return puts("-1"), 0;;
	int p=h[u];
	for(int i=e[p].next;i;i=e[i].next){
	    if(d[e[i].to]<d[e[p].to])p=i;
	    else if(d[e[i].to]==d[e[p].to]&&e[i].to<e[p].to)p=i;
	}
	if (d[e[p].to] > d[u]) return puts("-1"), 0;
	w[p>>1]=d[u];fa[u] = e[p].to;e[p^1].vis=1;
    }
	
    fill(col + 1, col + n + 1, -1);
    for (int i = 1; i <= n; ++i) if (fa[fa[i]] == i && col[i] == -1) col[i] = 0, dfs(i); 
    for (int i = 1; i <= n; ++i) putchar(col[i] == 0 ? 'B' : 'W');
    puts("");
    for (int i = 1; i <= m; ++i) printf("%d\n", w[i]);
	
    return 0;
}


Measured memory_bytes: 9472
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef  long long ll;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef vector<vector<int> > vvi;
#define clr(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mkp make_pair
#define forn(i, n) for(int i=0; i<(int)n; ++i)
#define forab(i, a, b) for(int i=(int)a; i<(int)b; ++i)

const int inf = (int)1e6+5;
const int nax = (int)3e5+5;

void compute(){
    int a, b, c;
    cin>>a>>b>>c;
    int res = min(b/a, c);
    cout<<res<<"\n";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //    int t;
    //    cin>>t;
    //    while(t--)
    compute();
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

int a[200000];

int main(){
	
	int N;
	cin >> N;
	
	for(int i = 0; i < N; i++){
		cin >> a[i];
	}
	
	int ans = 0;
	
	for(int i = 0; i < N; i++){
		if(a[i] == i + 1){
			ans++;
			i++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 768
#include<iostream>
using namespace std;
int main(void)
{
  
  while(true)
    {
      int a,b,ans;
      char op;
      cin>>a;
      cin>>op;
      cin>>b;
      if(op=='?')break;
      else if(op=='+')ans=a+b;
      else if(op=='-')ans=a-b;
      else if(op=='*')ans=a*b;
      else ans=a/b;
      cout<<ans<<endl;
    }
  return 0;
}

Measured memory_bytes: 1160
package main

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

var (
	n int   // 配列Aの要素数
	A []int // この配列の要素を任意に選んで数字を作る
)

// A[i]以降の値を用いてmを作ることができるかを返す関数
func solve(i, m int) bool {
	if m == 0 {
		return true
	}
	if i >= n {
		return false
	}
	return solve(i+1, m) || solve(i+1, m-A[i])
}

func answer(r io.Reader) string {
	scanner := bufio.NewScanner(r)
	var memo bytes.Buffer
	scanner.Scan()
	n, _ = strconv.Atoi(scanner.Text())
	scanner.Scan()
	A = make([]int, n)
	ss := strings.Fields(scanner.Text())
	for i := 0; i < n; i++ {
		A[i], _ = strconv.Atoi(ss[i])
	}
	scanner.Scan()
	q, _ := strconv.Atoi(scanner.Text())
	scanner.Scan()
	ss = strings.Fields(scanner.Text())
	for j := 0; j < q; j++ {
		m, _ := strconv.Atoi(ss[j])
		if solve(0, m) {
			memo.WriteString("yes\n")
			continue
		}
		memo.WriteString("no\n")
	}
	return strings.TrimRight(memo.String(), "\n")
}

func main() {
	fmt.Println(answer(os.Stdin))
}



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

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

int n,a,b;
int p[110];
int ca,cb,cc;

void input(){
	cin>>n>>a>>b;
	for(int i=0;i<n;i++){
		cin>>p[i];
		if(p[i]<=a)ca++;
		else if(p[i]>a&&p[i]<=b)cb++;
		else cc++;
	}
	return;
}

void solve(){
	cout<<min({ca,cb,cc})<<endl;
	return;
}

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

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	static class State implements Comparable<State>{
		int v, cost;
		State(int v, int cost){
			this.v=v;
			this.cost=cost;
		}
		public int compareTo(State s) {
			return this.cost-s.cost;
		}
	}
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int n=sc.nextInt();
			boolean[][] edge=new boolean[n+1][n+1];
			for(int i=0; i<n; i++) {
				int r=sc.nextInt();
				int k=sc.nextInt();
				for(int j=0; j<k; j++) {
					int t=sc.nextInt();
					edge[r][t]=true;
				}
			}
			int p=sc.nextInt();
			int[] dis=new int[n+1];
			PriorityQueue<State> pq=new PriorityQueue<>();
			int INF=100000000;
			while(p-->0) {
				int s=sc.nextInt();
				int g=sc.nextInt();
				int v=sc.nextInt();
				pq.clear();
				Arrays.fill(dis, INF);
				pq.add(new State(s, 0));
				while(!pq.isEmpty()) {
					State state=pq.poll();
					if(dis[state.v]!=INF) continue;
					dis[state.v]=state.cost;
					if(state.v==g) break;
					for(int i=1; i<=n; i++) {
						if(!edge[state.v][i]) continue;
						pq.add(new State(i, state.cost+1));
					}
				}
				if(dis[g]==INF || dis[g]>=v) System.out.println("NA");
				else System.out.println(dis[g]+1);
			}
			
		}

	}
}


Measured memory_bytes: 37916
import sys
import  math
from statistics import *
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

a = input()
b = input()
print("YES" if a == b[::-1] else 'NO')

Measured memory_bytes: 5084
#include<iostream>
using namespace std;
main(){
  string s;
  cin>>s;
  int n = s[s.size()-1] - '0';
  if (n ==3) cout<< "bon"<<endl;
  else if (n == 0) cout<< "pon"<<endl;
  else if (n == 1) cout<< "pon"<<endl;
  else if (n == 6) cout<< "pon"<<endl;
  else if (n == 8) cout<< "pon"<<endl;
  else cout<< "hon"<<endl;
  return 0;
}

Measured memory_bytes: 3612
/*-****************************************-*/

#define USE_CPP11

#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>

#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <bitset>
#ifdef USE_CPP11
# include <unordered_set>
# include <unordered_map>
# include <array>
# include <valarray>
#endif // USE_CPP11

#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>

using namespace std;

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

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

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

#define mp make_pair

#define sz_array(a) (sizeof(a) / sizeof((a)[0]))

#define all(a) (a).begin(),(a).end()
#define r_all(a) (a).rbegin(), (a).rend()

#define exists(container, elem) ((container).find(elem) != (container).end())

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

template<typename T> T MinAssign(T &a, T b) {
    if (a > b)
        a = b;
    return a;
}

template<typename T> T MaxAssign(T &a, T b) {
    if (a < b)
        a = b;
    return a;
}

template<typename T, size_t size> void Fill(void *ptr, T value) {
    fill((T *)ptr, (T *)ptr + size / sizeof(T), value);
}

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

static const double EPS = 1e-10;
static const double PI = acos(-1.0);
static const int INF = 1 << 28;

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

#ifdef DEBUG
#define ANSWER_PREFIX() cout << "[[ Answer ]] "
#else
#define ANSWER_PREFIX()
#endif // DEBUG

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
//////////////////////////////////////////////////

const int MaxN = 1000 + 10;
int n, m;
int A[MaxN], B[MaxN], C[MaxN];
int dist[MaxN];
unordered_set<int> M[MaxN];

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

    for (size_t i = 0; i < m; i++) {
        cin >> A[i] >> B[i] >> C[i];
        A[i]--;
        B[i]--;
    }

    unordered_set<int> ans;

    for (size_t s = 0; s < n; s++) {
        fill(begin(dist), end(dist), INF);
        dist[s] = 0;
        for (size_t i = 0; i < m; i++) {
            M[i].clear();
        }

        for (size_t _ = 0; _ < n - 1; _++) {
            for (size_t i = 0; i < m; i++) {
                for (auto& p : { mp(A[i], B[i]), mp(B[i], A[i]) }) {
                    int diff = dist[p.second] - (dist[p.first] + C[i]);

                    if (diff > 0) {
                        M[p.second].clear();
                        dist[p.second] = dist[p.first] + C[i];
                    }
                    if (diff >= 0) {
                        M[p.second].insert(i);
                    }
                }
            }
        }

        for (size_t i = 0; i < m; i++) {
            for (auto& j : M[i]) {
                ans.insert(j);
            }
        }
    }

    ANSWER_PREFIX();
    cout << (m - ans.size()) << endl;
}


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

#define endl '\n'
#define ll long long
#define rint register int

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll t, i, x, j, y, 	z, k, n;
	char c;
	cin >> c;
	if (c >= 'a')	ce('a')
		else ce('A')
		}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static char[] cs = { '.', '#' };

	public static void main(String[] args) {
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; ++i) {
			A[i] = Integer.parseInt(sc.next());
		}
		long ans = A[0] - 1;
		int min = 2;
		for (int i = 1; i < N; ++i) {
			if (A[i] == min) {
				++min;
				continue;
			}
			ans += (A[i] - 1) / min;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 32052
import java.util.Scanner;

public class Main {
    static final String KEY1 = "this";
    static final String KEY2 = "that";
    static final String KEY3 = "the";

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {

			String inputData = sc.nextLine();

			int count = 1;

			for (int i = 0; i < 27; i++) {
				StringBuilder sb = new StringBuilder();

				for (int j = 0; j < inputData.length(); j++) {
					char c = inputData.charAt(j);

					if ((int) c <= 127 && (int) c >= 92) {
						c = (char) ((int) c + count);

						if (c > 122) {
							c = (char) ((c - 122) + 96);
						} else if (c < 97) {
							c = (char) (123 - (97 - c));
						}
					}
					sb.append(c);
				}
				String aaa = sb.toString();

				if (aaa.matches(".*" + KEY1 + ".*")
						|| aaa.matches(".*" + KEY2 + ".*")
						|| aaa.matches(".*" + KEY3 + ".*")) {
					System.out.println(sb);
					
					break;
				}
				count++;
			}

		}
	}

}

Measured memory_bytes: 28848
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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 int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN3(n,a,b);
  cout << min(a,b) << " ";
  if(a+b > n) cout << a+b-n << endl;
  else OUT(0);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c,d,e,f;
	while(scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f),a+b+c+d+e+f){
		a+=d;b+=e;c+=f;
		int ret=0;
		for(int i=0;i<3;i++){
			if(i<=a&&i<=b&&i<=c)ret=max(ret,i+(a-i)/3+(b-i)/3+(c-i)/3);
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 1028
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;

int main() {
    int N, C;
    cin >> N >> C;
    int D[C][C];
    int c[N][N];
    for (int i = 0; i < C; i++) {
        for (int j = 0; j < C; j++) {
            cin >> D[i][j];
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> c[i][j];
        }
    }
    int diff[3][C];
    for (int i = 0; i < 3; i++) {
        fill(diff[i], diff[i] + C, 0);
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            for (int k = 0; k < C; k++) {
                diff[(i + j) % 3][k] += D[c[i][j] - 1][k];
            }
        }
    }
    ll ans = llmax;
    for (int i = 0; i < C; i++) {
        for (int j = 0; j < C; j++) {
            for (int k = 0; k < C; k++) {
                if (i == j || j == k || k == i) {
                    continue;
                }
                ll num = diff[0][i] + diff[1][j] + diff[2][k];
                if (num < ans) {
                    ans = num;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1280
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;
const auto MOD = 1000000007;
const int INF = 1e9;
const long long LINF = 1e18;
typedef pair<int , int>  PII;
typedef pair<long long , long long>  PLL;

bool Comp(const PLL& a, const PLL& b) {
	return a.second > b.second;
}

int n, m;
string s;

int main() {
	cin >> n;
	vector<PLL> ab(n);
	long long cnt = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> ab[i].first >> ab[i].second;
		cnt += ab[i].first;
	}
	sort(ab.begin(), ab.end(), Comp);
	for (int i = 0; i < n; i++)
	{
		if (ab[i].second < cnt) {
			cout << "No" << endl;return 0;
		}
		cnt -= ab[i].first;
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>

using namespace std;

char table[12][12]={0};

int main(void){
	int sx,sy;
	while(true){
		for(int y=1;y<=8;y++)
			for(int x=1;x<=8;x++)
				cin >> table[x][y],table[x][y]-='0';
		if(cin.eof())
			break;
		for(int y=1;y<=8;y++)
			for(int x=1;x<=8;x++)
				if(table[x][y])
					sx=x,sy=y,x=9,y=9;
		if(table[sx][sy]&table[sx+1][sy]&table[sx][sy+1]&table[sx+1][sy+1])
			cout << 'A' << endl;
		else if(table[sx][sy]&table[sx][sy+1]&table[sx][sy+2]&table[sx][sy+3])
			cout << 'B' << endl;
		else if(table[sx][sy]&table[sx+1][sy]&table[sx+2][sy]&table[sx+3][sy])
			cout << 'C' << endl;
		else if(table[sx][sy]&table[sx-1][sy+1]&table[sx][sy+1]&table[sx-1][sy+2])
			cout << 'D' << endl;
		else if(table[sx][sy]&table[sx+1][sy]&table[sx+1][sy+1]&table[sx+2][sy+1])
			cout << 'E' << endl;
		else if(table[sx][sy]&table[sx][sy+1]&table[sx+1][sy+1]&table[sx+1][sy+2])
			cout << 'F' << endl;
		else if(table[sx][sy]&table[sx+1][sy]&table[sx-1][sy+1]&table[sx][sy+1])
			cout << 'G' << endl;
	}
}

Measured memory_bytes: 1132
#include<iostream>
#include<string>
using namespace std;
int main(){
    string S;
    cin >> S;

    int tmp=0, ans=0;
    for(int i=0; i<S.size(); i++){
        if(S.at(i)=='A'||S.at(i)=='C'||S.at(i)=='G'||S.at(i)=='T'){
            tmp++;
            if(tmp>ans)ans=tmp;
        }else{
            tmp=0;
        }
    }

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

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



int main(){
	
	char a[3];
	int sum=0;
	for (int i = 0; i < 3; ++i)
	{
		cin>>a[i];
		if(a[i]=='1'){
			sum++;
		}
	}
	cout<<sum<<endl;


return 0;
}



Measured memory_bytes: 256
//Solution by Tima
#include <bits/stdc++.h>
 
#define f first
#define s second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define vi vector <int>
#define ld long double
#define pii pair<int, int>
#define y1 sda
 
using namespace std;    
const int N = int(3e5) + 12, mod = int(1e9)  + 7; 

int n,k;
string s,t;

ll get(int k){
	t = "";
	while(k > 0){
		t += s;
		k--;
	}
	ll res = 0;
	for(int i = 1; i < t.size(); i++){
		if(t[i] == t[i - 1]){
			t[i] = '#';
			res++;
		}
	}
	return res;
}

ll mycalc(int k){
    ll res = 0;
    for(int i = 0; i < s.size(); i++){
    	if(s[i] == s[0]) res++;
    }
    if(res == int(s.size())){
    	res *= k;
    	return (res) / 2;
    }
    if(k <= 4){
		return get(k);
	}
	else{
		return min(get(3) + (get(3) - get(2)) * (k - 3),get(4) + (get(4) - get(3)) * (k - 4));
	}
}

int main () {
	cin >> s >> k;
	cout << mycalc(k);
	return 0;
	srand(time(0));
	cin >> n;
	for(int i = 0; i < n; i++){
	    int len = rand() % 10 + 5;
	    s = "";
	    for(int j = 0; j < len; j++){
	    	s += char(rand() % 2 + 'a');
	    }
	    k = rand() % 100 + 50;
	    if(mycalc(k) != get(k)){
	    	cout << s << " " << k << endl;
	    	return 0;
	    }

	}
	
	
 
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;

using Real = double;
using Point = complex< Real >;
const Real EPS = 1e-8, PI = acos(-1);
using Polygon = vector< Point >;

namespace std {
  bool operator<(const Point &a, const Point &b) {
    return a.real() != b.real() ? a.real() < b.real() : a.imag() < b.imag();
  }
}

inline bool eq(Real a, Real b) { return fabs(b - a) < EPS; }
Real cross(const Point &a, const Point &b) {
  return real(a) * imag(b) - imag(a) * real(b);
}

Real dot(const Point &a, const Point &b) {
  return real(a) * real(b) + imag(a) * imag(b);
}

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_C
// 点の回転方向
int ccw(const Point &a, Point b, Point c) {
  b = b - a, c = c - a;
  if(cross(b, c) > EPS) return +1;  // "COUNTER_CLOCKWISE"
  if(cross(b, c) < -EPS) return -1; // "CLOCKWISE"
  if(dot(b, c) < 0) return +2;      // "ONLINE_BACK"
  if(norm(b) < norm(c)) return -2;  // "ONLINE_FRONT"
  return 0;                         // "ON_SEGMENT"
}

Point operator*(const Point &p, const Real &d) {
  return Point(real(p) * d, imag(p) * d);
}

istream &operator>>(istream &is, Point &p) {
  Real a, b;
  is >> a >> b;
  p = Point(a, b);
  return is;
}

ostream &operator<<(ostream &os, Point &p) {
  os << fixed << setprecision(10) << p.real() << " " << p.imag();
}

Polygon convex_hull(Polygon &p) {
  int n = (int) p.size(), k = 0;
  if(n <= 2) return p;
  sort(p.begin(), p.end());
  vector< Point > ch(2 * n);
  for(int i = 0; i < n; ch[k++] = p[i++]) {
    while(k >= 2 && cross(ch[k - 1] - ch[k - 2], p[i] - ch[k - 1]) < EPS) --k;
  }
  for(int i = n - 2, t = k + 1; i >= 0; ch[k++] = p[i--]) {
    while(k >= t && cross(ch[k - 1] - ch[k - 2], p[i] - ch[k - 1]) < EPS) --k;
  }
  ch.resize(k - 1);
  return ch;
}

int main(){
    int n;
    cin >> n;
    Polygon v(n);
    map<Point,int> ma;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        ma[v[i]] = i;
    }
    auto p = convex_hull(v);
    vector<double> ans(n,0.0);
    if(p.size()==2){
        for (int i = 0; i < p.size(); i++) {
            ans[ma[p[i]]] = 1./2;
        }
    }
    else{
        Point b = p[1] - p[0];
        for (int i = 0; i < p.size(); i++) {
            Point a = p[(i+1)%p.size()] - p[i];
            Point b = p[(i-1+p.size())%p.size()] - p[i];
            double theta = acos(dot(a,b) / abs(a) / abs(b));
            if(theta < EPS){
                continue;
            }
            ans[ma[p[i]]] = (PI - theta) / 2 / PI;
        }
    }
    for (int i = 0; i < n; i++) {
        cout << setprecision(30) << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
from collections import deque

n,m = map(int,input().split())
map_li = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a,b = a-1,b-1
    map_li[a].append(b)
    map_li[b].append(a)

ans_li = [-1]*n
queue=deque()
queue.append(0)

while queue:
    now = queue.popleft()
    for c in map_li[now]:
        if ans_li[c]==-1:
            ans_li[c]=now
            queue.append(c)

if -1 in ans_li[1:]:
    print('No')
else:
    print('Yes')
    for ans in ans_li[1:]:
        print(ans+1)

Measured memory_bytes: 35184
#include <bits/stdc++.h>
#define v(T) vector<T>
#define yn {puts("Yes");}else{puts("No");}
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double eps = 1e-10;

void solve() {
  int s, w;
  cin >> s >> w;
  if (w >= s) {
    cout << "unsafe" << endl;
  }else{
      cout << "safe" << endl;
  }
}

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


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ll unsigned long long 
using namespace std;
main () {
	ll h,w;
	cin>>h>>w;
	if (h==1 || w==1) cout<<1<<endl;
		else cout<<((h+1)/2)*((w+1)/2)+(h/2)*(w/2)<<endl;
}

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

int N,K;
int D[10];

int check(int n){
        while(n){
            int rem = n % 10;
            REP(i,K) if(rem == D[i]) return false;
            n /= 10;
        }
        return true;
}
int main(){
    cin >> N >> K;
    REP(i,K) cin >> D[i];
    int ans = N;
    while(true){
        if(check(ans)){
            cout << ans << endl;
            return 0;
        }
        ++ans;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;

int main() {
  string s;
  cin >> s;
  set<char> u;
  rep(i, s.size()) u.insert(s[i]);
  if(u.size() == 2) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const int MOD=1000000007;

int h[200000];
int main(){
	int n;cin>>n;
	rep(i,n)scanf("%d",&h[i]);
	int Max=0;
	int cnt=0;
	for(int i=n-1;i>=0;i--){
		if(i==n-1||h[i]<h[i+1])cnt=0;
		cnt++;
		Max=max(Max,cnt);
	}
	cout<<Max-1<<endl;
}

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

int main() {
    int a, b, c;
    char dm;
    int rectangles = 0, lozenges = 0;
    while (cin >> a >> dm >> b >> dm >> c) {
        if (a * a + b * b == c * c) {
            rectangles ++;
        } else if (a == b) {
            lozenges ++;
        }
    }
    cout << rectangles << endl;
    cout << lozenges << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
using ll = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;

int main() {
  int n; cin >> n;
  vector<int> ans(10050);
  for(int x = 1; x < 106; x++) {
    for(int y = 1; y < 106; y++) {
      for(int z = 1; z < 106; z++) {
        int t = x * x + y * y + z * z + x * y + y * z + z * x;
        if (t < 10050) {
          ans[t]++;
        }
      }
    }
  }
  for(int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 3624
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T1, class T2>bool chmax(T1& a, const T2& b) { return a < b ? a = b, 1 : 0; }
template<class T1, class T2>bool chmin(T1& a, const T2& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

string S, T;
vector<int> Schar_cnt(26);
vv<int> next_cindex;

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

    rep(i, S.size()) {
        Schar_cnt[S[i] - 'a']++;
    }

    bool ok = true;
    rep(i, T.size()) {
        if (Schar_cnt[T[i] - 'a'] == 0) {
            ok = false;
        }
    }

    if (!ok) {
        write(-1);
        return 0;
    }

    next_cindex = vvec(S.size(), 26, -1);
    vector<int> ci(26, -1);
    for (int i = S.size() - 1; i >= 0; --i) {
        ci[S[i] - 'a'] = i;

        for (int c = 0; c < 26; ++c) {
            next_cindex[i][c] = ci[c];
        }
    }

    ll ans = 0;
    int cur = 0;
    for (int i = 0; i < T.size(); ++i) {
        if (next_cindex[cur][T[i] - 'a'] >= 0) {
            ans += next_cindex[cur][T[i] - 'a'] - cur + 1;
            cur = next_cindex[cur][T[i] - 'a'] + 1;
        }
        else {
            ans += S.size() - cur;
            cur = 0;
            ans += next_cindex[cur][T[i] - 'a'] - cur + 1;
            cur = next_cindex[cur][T[i] - 'a'] + 1;
        }

        if (cur == S.size()) {
            cur = 0;
        }
    }

    write(ans);
}

Measured memory_bytes: 13776
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  map<ll,ll> M;
  ll N,K;
  cin>>N>>K;
  vector<ll> A(N);
  cin>>A;
  ll sum1=0;
  M[0]++;
  ll ans=0;
  vector<ll> dp(N+1,0);
  int idx=1;
  for(auto &I:A){
    sum1+=I;
    sum1+=K-1;
    sum1%=K;
    dp[idx++]=sum1;
  }
  for(int i=1;i<=N;i++){
    if(i>=K){M[dp[i-K]]--;}
    ans+=M[dp[i]];
    M[dp[i]]++;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int n,m;
int main()
{
	scanf("%d%d",&n,&m); int p=n;
		for (int i=1;i<=m;i++) 
		{
			if (n==2*(p-i) || n==(p-i)+(p-i)+2) p--;
			printf("%d %d\n",i,p--);
		}
return 0;
}

Measured memory_bytes: 3756
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int cnt = 0;
            int n = sc.nextInt();
            int x = sc.nextInt();
            if(n==0 && x==0) break;
            for(int i=1; i<=n-2; i++ ){
                for(int j=i+1; j<=n-1; j++){
                    for(int k=j+1; k<=n; k++){
                        if(i+j+k == x) cnt++;
                    }
                }
            }
            System.out.println(cnt);
        }
    }
}



Measured memory_bytes: 26644
#include <iostream>
#include <string.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
#define ii pair < int, int >
#define iii pair < int, ii >
#define INF 987654321
#define LINF 987654321987654321

ll fi[10000005];

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

	ll tot = 0;
	for (ll i = 1; i <= n; i++)
	{
		ll pos = n / i;

		tot += i * (pos * (pos + 1) / 2);
	}

	cout << tot;
}

Measured memory_bytes: 3188
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);for(int w,h,e,c,b;(w=s.nextInt())>0;System.out.println(c)){w=2*w-1;h=2*s.nextInt()-1;int[]m=new int[e=w*h],d={-1,1,w,-w},x;for(int i=1;i<e;i+=2)m[i]=s.nextInt();Queue<int[]>q=new LinkedList<int[]>();for(c=0,q.add(new int[]{0,1});!q.isEmpty();){x=q.poll();if(x[0]==e-1){c=x[1];break;}for(int i:d){b=x[0]+i;if(0<b&&b<w*h&&(x[0]/w==b/w||x[0]%w==b%w)&&m[b]<1){m[b]=1;q.add(new int[]{b+i,x[1]+1});}}}}}}

Measured memory_bytes: 12000
#include<cstdio>
#include<algorithm>
using std::sort;
#define int long long
struct node{
	int id,val,VAL;
}c[200100];
int tree[1000100],n,k,a[200100],sum[200100],ans;
bool cmp1(node x,node y){
	return x.val<y.val;
}
bool cmp2(node x,node y){
	return x.id<y.id;
}
void modify(int t,int l,int r,int pos){
	if(l==r){
		tree[t]++;
		return;
	}
	int mid=(l+r)/2;
	if(pos<=mid)modify(t*2,l,mid,pos);
	else modify(t*2+1,mid+1,r,pos);
	tree[t]=tree[t*2]+tree[t*2+1];
}
int query(int t,int l,int r,int L,int R){
	if(L>r||l>R)return 0;
	if(L<=l&&r<=R)return tree[t];
	int mid=(l+r)/2;
	return query(t*2,l,mid,L,R)+query(t*2+1,mid+1,r,L,R);
}
signed main(){
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)
		sum[i]=sum[i-1]+a[i];
	for(int i=1;i<=n;i++)
		c[i].id=i,c[i].val=sum[i]-k*i;
	sort(c+1,c+n+1,cmp1);
	c[0].val=-0x3f3f3f3f3f3f3f3f;
	for(int i=1;i<=n;i++)
		if(c[i].val!=c[i-1].val)c[i].VAL=i;
		else c[i].VAL=c[i-1].VAL; 
	sort(c+1,c+n+1,cmp2);
	for(int i=1;i<=n;i++){
		if(c[i].val>=0)ans++;
		ans+=query(1,1,n,1,c[i].VAL);
		modify(1,1,n,c[i].VAL);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 13696
#include <stdio.h>


int main(int argc, char *argv[]) {

    int a = 0, b = 0, c = 0;

    fscanf(stdin, "%d %d %d", &a, &b, &c);

    if(a < b && b < c) {
        fprintf(stdout, "Yes\n");
    }else {
        fprintf(stdout, "No\n");
    }

    return 0;

}

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

using namespace std;
typedef long long ll;

int main(){
	string S;
	cin >> S;
	if (S.substr(0,(S.length()-1)/2) == S.substr((S.length()+2)/2)){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}
		


Measured memory_bytes: 256
#include<stdio.h>

int main(){
		int k,x,i;
		scanf("%d%d",&k,&x);
		for(i=k-1;i>=0;i--)printf("%d ",x-i);
		for(i=1;i<k;i++)printf("%d ",x+i);
		puts("");
		return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>

using namespace std;

typedef long long ll;

const int Inf = 1e9;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector <vector <int>> g(n);
  for (int i = 0; i + 1 < n; ++i) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int ans = Inf; 
  for (int root = 0; root < n; ++root) {
    vector <int> cnt(n);
    vector <int> pot(n);
    vector <int> mn(n);
    function <void(int, int)> dfs = [&] (int u, int p) {
      cnt[u] = s[u] - '0';
      vector <int> gs;
      for (auto v : g[u]) {
        if (v != p) {
          gs.push_back(v);
          dfs(v, u);
          pot[u] += pot[v];
          pot[u] += cnt[v];
          cnt[u] += cnt[v];
        }
      }
      int sum = 0;
      int mx = 0;
      for (auto v : gs) {
        sum += pot[v] + cnt[v];
        mx = max(mx, pot[v] + cnt[v]);
      }
      mn[u] = sum;
      mn[u] = min(mn[u], max(0, 2 * mx - sum));
      for (auto v : gs) {
        int od = pot[v] + cnt[v];
        int nw = mn[v] + cnt[v];
        if (od == mx) {
          int nsum = sum - od + nw; 
          mn[u] = min(mn[u], max(0, 2 * nw - nsum));
        }
      }
      mn[u] = max(mn[u], sum % 2);
    };
    dfs(root, -1);
    int sum = 0, mx = 0;
    for (int v : g[root]) {
      sum += pot[v] + cnt[v];
      mx = max(mx, pot[v] + cnt[v]);
    }
    int cmn = sum;
    cmn = min(cmn, max(0, 2 * mx - sum));
    for (auto v : g[root]) {
      int od = pot[v] + cnt[v];
      int nw = mn[v] + cnt[v];
      if (od == mx) {
        int nsum = sum - od + nw; 
        cmn = min(cmn, max(0, 2 * nw - nsum));
      }
    }
    if (cmn == 0 && sum % 2 == 0) {
      ans = min(ans, sum / 2);
    }
  } 
  cout << (ans == Inf ? -1 : ans) << '\n';
}



Measured memory_bytes: 3988
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#define lli long long int
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);


using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 57;
const int M = 1e6 + 500;

lli dp[5000][5000];

void solve()
{
    string s, t;
    cin>>s>>t;
    s = '$' + s;
    t = '$' + t;
    for(int i = 1; i < s.size(); i ++)
    {
        for(int j = 1; j < t.size(); j ++)
        {
            if(s[i] == t[j])
                dp[i][j] = max(dp[i][j - 1], max(dp[i - 1][j], dp[i - 1][j - 1] + 1));
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    int i = s.size() - 1;
    int j = t.size() - 1;
    vector<char> v;
    while(dp[i][j] != 0)
    {
        if(dp[i - 1][j] == dp[i][j])
            i --;
        else if(dp[i][j - 1] == dp[i][j])
            j --;
        else
            v.push_back(t[j]), i --, j --;
    }
    reverse(v.begin(), v.end());
    for(auto i : v)
        cout<<i;
    return ;
}
/*
10
6
10 3 2 5 7 8
*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    lli t;
    t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 118400
import collections
import heapq

n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = []
for _ in range(m):
    b,c = map(int,input().split())
    bc.append((b,c))
cnt = collections.Counter(a).most_common()
heapq.heapify(cnt)


for i, set_bc in enumerate(bc):
    now0,now1 = heapq.heappop(cnt)
    b,c = set_bc
    if now0 >= c:
        heapq.heappush(cnt,(now0,now1))
        now1 = 0
        continue
    tmpb = 0
    for j in range(b):
        if now0 < c:
            if now1 >= b:
                now1 -= b
                tmpb += b
                heapq.heappush(cnt,(c,tmpb))
                break
            tmpb += now1
            b -= now1
            now0,now1 = heapq.heappop(cnt)
        else:
            heapq.heappush(cnt,(c,tmpb))
            break
    if now1 != 0:
        heapq.heappush(cnt,(now0,now1))
        now1 = 0
if now1 != 0:
    heapq.heappush(cnt,(now0,now1))
ans = 0

for i in range(len(cnt)):
    val, num = heapq.heappop(cnt)
    ans += val * num
print(ans)


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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pi;

const ll mod = 1000000007;

ll distS[100005], distE[100005], waysS[100005], waysE[100005];
vector<pi> AdjList[100005];
ll N, M, S, T;
ll U, V, D;
vector<pair<pi,ll> > edges;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> M;
	cin >> S >> T;
	for (int i = 1; i <= M; ++i){
		cin >> U >> V >> D;
		AdjList[U].push_back(pi(V,D));
		AdjList[V].push_back(pi(U,D));
		edges.push_back(make_pair(pi(U,V),D));
		//edges.push_back(make_pair(pi(V,U),D));
	}
	for (int i = 1; i <= N; ++i){
		distS[i] = distE[i] = 1e17;
		waysS[i] = waysE[i] = 0;
	}
	distS[S] = 0;
	distE[T] = 0;
	waysS[S] = 1;
	waysE[T] = 1;
	
	priority_queue<pi,vector<pi>,greater<pi> > pq;
	pq.push(pi(0,S));
	while (!pq.empty()){
		pi C = pq.top();
		pq.pop();
		if (C.first != distS[C.second]) continue;
		for (auto it : AdjList[C.second]){
			if (distS[it.first] > C.first + it.second){
				distS[it.first] = C.first + it.second;
				waysS[it.first] = waysS[C.second];
				pq.push(pi(distS[it.first],it.first));
			}
			else if (distS[it.first] == C.first + it.second){
				waysS[it.first] += waysS[C.second];
				waysS[it.first] %= mod;
			}
		}
	}


	pq.push(pi(0,T));
	while (!pq.empty()){
		pi C = pq.top();
		pq.pop();
		if (C.first != distE[C.second]) continue;
		for (auto it : AdjList[C.second]){
			if (distE[it.first] > C.first + it.second){
				distE[it.first] = C.first + it.second;
				waysE[it.first] = waysE[C.second];
				pq.push(pi(distE[it.first],it.first));
			}
			else if (distE[it.first] == C.first + it.second){
				waysE[it.first] += waysE[C.second];
				waysE[it.first] %= mod;
			}
		}
	}
	ll sdist = distS[T], w = (waysS[T]*waysE[S])%mod;
	//cout << w << '\n';
	for (int i = 1; i <= N; ++i){
		if (2*distS[i] == sdist && 2*distE[i] == sdist){
			w -= ((((waysS[i]*waysS[i])%mod)*((waysE[i]*waysE[i])%mod))%mod);
			w %= mod;
			w += mod;
			w %= mod;
		}
	}
	for (int i = 0; i < edges.size(); ++i){
		if (2*distS[edges[i].first.first] >= sdist){
			swap(edges[i].first.first,edges[i].first.second);
		}
		if (distS[edges[i].first.first]+distE[edges[i].first.second]+edges[i].second == sdist && 2*distS[edges[i].first.first] < sdist && 2*distE[edges[i].first.second] < sdist){
			w -= ((((waysS[edges[i].first.first]*waysS[edges[i].first.first])%mod)*((waysE[edges[i].first.second]*waysE[edges[i].first.second])%mod))%mod);
			w %= mod;
			w += mod;
			w %= mod;
		}
	}
	cout << w << '\n';
	cout << flush;
	//for (int i = 0; i < 1e9; ++i){for (int j = 0; j < 1e9; ++j){}}
}

Measured memory_bytes: 23716
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long double pi = (acos(-1));

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる
//時間を意識しろ
//コードテストちゃんとして
//画面とにらめっこするな書け
//WA出すたびにABCは五億円払え
//わからない問題はとばせ
//躊躇なくぐぐれ

//ここから
ll N;
ll Ans=0;

void dfs(ll num,ll &res,ll use7,ll use5,ll use3){
    if(num>N){
        return;
    }
    if(use7>0&&use5>0&&use3>0){
        res++;
    }
    dfs(num*10+7,res,use7+1,use5,use3);
    dfs(num*10+5,res,use7,use5+1,use3);
    dfs(num*10+3,res,use7,use5,use3+1);
}

int main() {
    cin>>N;
    dfs(0,Ans,0,0,0);
    cout<<Ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.regex.Matcher;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    Pattern p = Pattern.compile("ABC");
    Matcher m = p.matcher(s);
    int count = 0;
    while (m.find())
      count++;
    System.out.println(count);
  }
}

Measured memory_bytes: 23252
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


int main() {
    int H,W;
    cin >> H >> W;
    vector<vector<int> > v(H+2,vector<int>(W+2,0));
    REP(i,1,H+1){
        REP(j,1,W+1){
            char c;
            cin >> c;
            if(c == '#'){
                v[i][j] = -1;
            }
        }
    }

    REP(i,1,H+1){
        REP(j,1,W+1){
            int cnt = 0;
            for(int a = i-1; a <= i + 1; a++){
                for(int b = j-1; b <= j + 1; b++){
                    if(v[a][b] == -1) cnt++;
                }
            }
            if(v[i][j] != -1) v[i][j] = cnt;
        }
    }

    REP(i,1,H+1){
        REP(j,1,W+1){
            if(v[i][j] == -1) cout << "#";
            else cout << v[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  string t;
  for(int i=0;i<s.size();i++){
    if(s.at(i)!='B')
      t+=s.at(i);
    else if(!t.empty())
      t.pop_back();
  }
  cout<<t<<endl;
}

Measured memory_bytes: 256