akhauriyash/Code-Regression huggingface dataset:
def make_map(X):
    X = list(map(lambda x: ord(x) - ord("a"), X))
    s = [-1]*26
    res = [0]+[-1]*(len(X)-1)
    cnt = 0
    for i, x in enumerate(X):
        if s[x] == -1:
            s[x] = res[i] = cnt
            cnt += 1
        else:
            res[i] = s[x]
    return res
print("Yes" if make_map(input())==make_map(input()) else "No")

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

int main(){
    char c;
    cin >> c;
    if(c == 'A'){
        cout << 'T';
    }else if(c == 'T'){
        cout << 'A';
    }else if(c == 'G'){
        cout << 'C';
    }else{
        cout << 'G';
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 301

int M;
int table[6];
int start,goal,command[NUM];
int min_dist[NUM],to_dist[NUM];

bool rangeCheck(int loc){
	if(loc >= 0 && loc <= M-1){
		return true;
	}else{
		return false;
	}
}

int recursive(int loc,int sum_dist){

	if(min_dist[loc] != -1){

		if(min_dist[loc] == BIG_NUM){
			return BIG_NUM;
		}else{
			return min_dist[loc]+sum_dist;
		}
	}

	int ret = BIG_NUM,next_loc = 0;

	for(int i = 0; i < 6; i++){

		//右方向
		next_loc = loc+table[i];
		if(rangeCheck(next_loc) == true){
			next_loc += command[next_loc];
			if(to_dist[next_loc] > sum_dist+1){
				to_dist[next_loc] = sum_dist+1;
				ret = min(ret,recursive(next_loc,sum_dist+1));
			}
		}
		//左方向
		next_loc = loc-table[i];
		if(rangeCheck(next_loc) == true){
			next_loc += command[next_loc];
			if(to_dist[next_loc] > sum_dist+1){
				to_dist[next_loc] = sum_dist+1;
				ret = min(ret,recursive(next_loc,sum_dist+1));
			}
		}
	}

	return ret;
}


int main(){

	scanf("%d",&M);

	for(int i = 0; i < 6; i++)scanf("%d",&table[i]);

	scanf("%d %d",&start,&goal);
	start--;
	goal--;

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

	for(int i = 0; i < M; i++){
		min_dist[i] = -1;
	}
	min_dist[goal] = 0;

	for(int i = 0; i < M; i++){
		if(i == goal)continue;
		for(int k = 0; k < M; k++)to_dist[k] = BIG_NUM; //そこへたどり着くまでのコスト

		to_dist[i] = 0;

		min_dist[i] = recursive(i,0);
	}

	int current_loc = start,dice;
	int right_loc,left_loc,right_dist,left_dist;

	while(true){

		scanf("%d",&dice);
		dice--;

		if(!rangeCheck(current_loc+table[dice])){
			right_dist = BIG_NUM;
		}else{
			right_loc = current_loc+table[dice];
			right_loc += command[right_loc];
			right_dist = min_dist[right_loc];
		}

		if(!rangeCheck(current_loc-table[dice])){
			left_dist = BIG_NUM;
		}else{
			left_loc = current_loc-table[dice];
			left_loc += command[left_loc];
			left_dist = min_dist[left_loc];
		}

		if(min_dist[current_loc] <= right_dist && min_dist[current_loc] <= left_dist){ //現在地が最適である場合

			printf("0\n");
			fflush(stdout);

		}else{

			if(left_dist < right_dist){
				printf("-1\n");
				fflush(stdout);
				current_loc = left_loc;
			}else{
				printf("1\n");
				fflush(stdout);
				current_loc = right_loc;
			}
		}

		if(current_loc == goal){
			return 0;
		}
	}

	return 0;
}



Measured memory_bytes: 3296
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX=1000;
static const int VMAX=10000;

int n,A[MAX],s;
int B[MAX],T[VMAX+1];

int solve() {
  int ans=0;
  bool V[MAX];
  for (int i=0; i<n; i++) {
    B[i]=A[i];
    V[i]=false;
  }
  sort(B,B+n);
  for (int i=0; i<n; i++) {
    T[B[i]]=i;
  }
  for (int i=0; i<n; i++) {
    if (V[i]) {
      continue;
    }
    int cur=i;
    int S=0;
    int m=VMAX;
    int an=0;
    while (true) {
      V[cur]=true;
      an++;
      int v=A[cur];
      m=min(m,v);
      S+=v;
      cur=T[v];
      if (V[cur]) {
        break;
      }
    }
    ans+=min(S+(an-2)*m,m+S+(an+1)*s);
  }
  return ans;
}
int main() {
  cin>>n;
  s=VMAX;
  for (int i=0; i<n; i++) {
    cin>>A[i];
    s=min(s,A[i]);
  }
  int ans=solve();
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
	int n = 10;
	vector<int> a(n), b(n);

	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];

	sort(a.begin(), a.end(), greater<int>());
	sort(b.begin(), b.end(), greater<int>());

	cout << a[0] + a[1] + a[2] << " " << b[0] + b[1] + b[2] << endl;

	return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
    string s;
    long long k;
    cin >> s >> k;
    for (int i = 0; i < min((long long)s.size(), k);i++){
        if(s[i]>='2'){
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << '1' << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		double W = sc.nextDouble();
      double H = sc.nextDouble();
      int x = sc.nextInt();
      int y = sc.nextInt();
      String isCenter = "0";
      if(x == W / 2 && y == H / 2){
        isCenter = "1";
      }
      System.out.println((W * H / 2) + " " + isCenter);
	}
}


Measured memory_bytes: 24404
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 7+1e18
#define lld long double
#define eps 0.000001
#define endl '\n'
using namespace std ;

int gcd(int a, int b)
{
    if (a == 0)   return b;
    if(b==0)      return a;
    if (a == b)   return a;
    if (a > b)    return gcd(a%b, b);
    return gcd(a, b%a);
}

/*seive
 int d[302]={0};
 int l=300;
  for(int i=2;i<l;i++)
		if(d[i]==0)
			for(int j=i;j<=l;j+=i)
				d[j]=d[j/i]+1;


  loop(i,1,301) cout<<i<<" "<<d[i]<<endl;
*/
bool vis[2005]={false};
int conn=0;
vector<int> v[2005];
void dfs(int q) 
{
	vis[q] = 1;
	
	for(int i=0;i<v[q].size() ;i++)
		if (!vis[v[q][i]])
			dfs(v[q][i]);
    
} 

/*lli power(lli x, lli y, lli p)
{
    lli res = 1;  
 
    x = x % p;  
    
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
 
        y = y>>1; 
		x = (x*x) % p;  
    }
    return res;
}*/
int main()
{
	////////////////////
	fastio;
	///////////////////
	
	lli a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<a[1]-a[0] + a[2]-a[1]<<endl;
	
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int MAX_N = 20000;
const int MAX_M = 16;
const int INF = 1e8;
const int y0 = 128;
int N, M;
int C[MAX_M + 1], x[MAX_N + 1];
int dp[MAX_N + 10][260];

int main()
{
    while (cin >> N >> M, N || M) {
        // Input
        for (int i = 0; i < M; ++i)
            cin >> C[i];
        for (int i = 0; i < N; ++i)
            cin >> x[i];

        // Init
        for (int i = 0; i <= N; ++i)
            fill(dp[i], dp[i] + 259, INF);
        dp[0][128] = 0;

        // Solve
        for (int n = 0; n < N; ++n) {
            for (int y = 0; y <= 255; ++y) {
                for (int i = 0; i < M; ++i) {
                    int next_y = y + C[i];
                    if (next_y < 0)
                        next_y = 0;
                    else if (next_y > 255)
                        next_y = 255;

                    dp[n + 1][next_y] = min(dp[n + 1][next_y],
                                            dp[n][y] + (x[n] - next_y) * (x[n] - next_y));
                }
            }
        }

        int ans = INF;
        for (int i = 0; i <= 255; ++i)
            ans = min(ans, dp[N][i]);

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 21556
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#define ll long long int
#define lim 100010
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))

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

int lowwer_bound(int *p, int num, int key){
	int min=0,max=num,mid=max/2;
	while(mid+1!=max && mid!=min ){
		if(key > p[mid]) min=mid;
		else max = mid+1;
		mid = min+(max-min)/2;
	}
	if(p[min] >= key) return min;
	if(p[mid] >= key) return mid;
	if(p[max] >= key) return max;
	return num;
}

int main(void){
	int n;
	scanf("%d",&n);
	int a[n],b[n],c[n];
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	for(int i=0;i<n;i++)scanf("%d",&b[i]);
	for(int i=0;i<n;i++)scanf("%d",&c[i]);
	qsort(a,n,sizeof(int),compare_int);
	qsort(b,n,sizeof(int),compare_int);
	qsort(c,n,sizeof(int),compare_int);
	ll ans=0,x,y;
	for(int i=0;i<n;i++){
		x = lowwer_bound(a,n,b[i]);
		y = lowwer_bound(c,n,b[i]+1);
		ans += x*(n-y);
	}
	printf("%lld",ans);
	
	
	return 0;
}

Measured memory_bytes: 1788
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
    
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] A = new int[M];
        int[] B = new int[M];
        
        for(int i = 0; i < M; i++){
            A[i] = sc.nextInt() - 1;
            B[i] = sc.nextInt() - 1;
        }
        
        long[] ans = new long[M];
        UnionFind uf = new UnionFind(N);
        for(int i = M-1; i >= 0; i--){
            int sizeA = uf.size(A[i]);
            int sizeB = uf.size(B[i]);
            
            if( !uf.isSame(A[i], B[i]) ){
                ans[i] = (long) sizeA * sizeB;
                uf.unite(A[i], B[i]);
            }
        }
        
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < M; i++){
            sb.append(ans[i]).append("\r\n");
            if(i != M-1) ans[i+1] += ans[i];
        }
        
        System.out.println(sb.toString());
        
    }
    
    static class UnionFind{
        int[] parent;
        int[] size;
        int N;
        
        public UnionFind(int N){
            parent = new int[N];
            size = new int[N];
            this.N = N;
            for(int i = 0; i < N; i++){
                parent[i] = i;
                size[i] = 1;
            }
        }
        
        public int size(int x){
            return size[root(x)];
        }
        
        public void unite(int x, int y){
            if( isSame(x, y) ) return;
            size[root(y)] += size[root(x)];            
            parent[root(x)] = root(y);
        }
        
        public int root(int x){
            if( parent[x] == x ) return x;
            return parent[x] = root(parent[x]);
        }
        
        public boolean isSame(int x, int y){
            return root(x) == root(y);
        }
    }

}


Measured memory_bytes: 72792
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
using namespace std;
string f(){
	string a="";
	char d;
	rep(i,10){
		cin>>d;
		if(d=='*')return "*";
		if(i==4||i==7)continue;
		a+=d;
	}
	return a;
}
int main(){
	int n;
	cin>>n;
	vector<vector<string> >in(n,vector<string>(3));
	rep(i,n){
		rep(j,2)cin>>in[i][j];
		in[i][2]=f();
	}
	int m;
	cin>>m;
	while(m--){
		string a,b,c,d;
		cin>>a>>b;
		c=f();
		d=f();
		vector<bool>h(n,true);
		if(a!="*")rep(i,n)if(in[i][0].find(a)==string::npos)h[i]=false;
		if(b!="*")rep(i,n)if(in[i][1].find(b)==string::npos)h[i]=false;
		if(c!="*")rep(i,n)if(atoi(&in[i][2][0])<atoi(&c[0]))h[i]=false;
		if(d!="*")rep(i,n)if(atoi(&in[i][2][0])>atoi(&d[0]))h[i]=false;
		rep(i,n)if(h[i])cout<<in[i][0]<<endl;
		if(m)cout<<endl;
	}
}

Measured memory_bytes: 1256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main()
{  
    string str,str1;
    cin>>str>>str1;
    
    str1.erase(str1.size()-1);
    if(str1==str) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
}

Measured memory_bytes: 3604
#include <set>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define MEQ(a,b) a = max((a), (b))

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

int memo[10][10][2];

int a[20];
int b[20];
int p[10];

int main(){
  int aa = getInt();
  int bb = getInt();
  int kk = getInt();

  REP(i,10){
    a[i] = aa % 10;
    b[i] = bb % 10;

    aa /= 10;
    bb /= 10;
  }

  p[0] = 1;
  REP(i,9) p[i + 1] = p[i] * 10;

  int ans = 0;

  memset(memo, -1, sizeof(memo));
  memo[0][0][0] = 0;

  REP(i,9) REP(k,kk + 1) REP(j,2) if(memo[i][k][j] >= 0){
    int c = a[i] - j - b[i];

    if(c < 0){
      c += 10;
      MEQ(memo[i + 1][k + 1][0], memo[i][k][j] + p[i] * c);
      MEQ(memo[i + 1][k    ][1], memo[i][k][j] + p[i] * c);
    }else{
      MEQ(memo[i + 1][k    ][0], memo[i][k][j] + p[i] * c);
    }

    // printf("%d %d %d: %d\n", i, k, j, memo[i][k][j] + p[i] * c);
  }

  REP(k,kk + 1) ans = max(ans, memo[9][k][0]);

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

  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int cost[] = new int[n + 1];

		for(int i = 0; i < m; i++){
			int a = sc.nextInt();
			int b = sc.nextInt();

			if(a == 1){
				cost[b]++;
			}
			else if(b == 1){
				cost[a]++;
			}
			else {
				cost[a]++;
				cost[b]++;
			}
		}

		for(int i = 0; i <= n; i++){
			if(cost[i] % 2 == 1){
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
	}
}


Measured memory_bytes: 49636
using System;
class Program {
    static void Main() {
        string[] str =  Console.ReadLine().Split(' ');

        int[] num = new int[str.Length];
        for(int i = 0; i < num.Length; i++) {
            num[i] = int.Parse(str[i]);
        }

        Array.Sort(num);
        Console.WriteLine("{0} {1} {2}", num[0], num[1], num[2]);
    }
}

Measured memory_bytes: 9316
#include <iostream>
using namespace std;
int ans = 0;

int dfs(int depth, int sum, int before) {
    int ret = 0;
    if(depth == 0) {
        if(sum == ans) return(1);
        else           return(0);
    }
    if(sum > ans || before > 9) return(0);
    for(int r = before; r <= 9; r++) {
        ret += dfs(depth - 1, sum + r, r + 1);
    }
    return(ret);
}

int main(void) {
    cin.tie();
    ios::sync_with_stdio(false);
    while(true) {
        int depth = -1;
        cin >> depth >> ans;
        if(depth + ans == 0) break;
        cout << dfs(depth, 0, 0) << endl;
    }
    
    return(0);
}

Measured memory_bytes: 1192
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <cmath>

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;


int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	//VI a(n);
	map<int, int> mp;
	int cnt =0;
	rep(i,n){
		int a; cin >>a; a--;
		if(mp.count(a) && mp[a] == i) cnt++;
		mp[i] =a;
	}
	cout << cnt <<endl;
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int ans;
int main()
{
	ios::sync_with_stdio(0);
	string x,y;
	cin>>x>>y;
	for(int i=0;i<x.size();i++) if(x[i]!=y[i]) ans++;	
	cout<<ans;
} 

Measured memory_bytes: 3836
/*/ Author: KaySeeKay /*/

#include<bits/stdc++.h>
using namespace std;	

/*/---------------------------Defines-----------------------------------------/*/

#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)	
#define fn1 for( int i =1;i<=n;	i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;	
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];

/*/-----------------------------Code begins----------------------------------/*/


signed main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		string s,t;
		cin >>s>>t;
		int n = s.size();
		int ans = INT_MAX;
		int m =t.size();
		for(int i =0 ; i < s.size();i++){
			int j =0 ,cur =0 ;
			for(;i+j<n&&j<m;j++)if(t[j]!=s[i+j])cur++;
			if(j==m)ans=min(ans,cur);
		}
		if(ans==INT_MAX)ans =m;
		cout<<ans;

	
	
	}
	return 0;
}

Measured memory_bytes: 3660
#include <limits>
#include <vector>
#include <functional>

template<typename T, typename F, typename G>
std::vector<std::vector<T>> warshall_floyd(const std::vector<std::vector<T>> &graph, F f, G g) {
    int n = graph.size();
    std::vector<std::vector<T>> ret(graph);
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                T dist = f(ret[i][k], ret[k][j]);
                if (g(ret[i][j], dist)) { ret[i][j] = dist; }
            }
        }
    }
    return ret;
}

template<typename T, typename AB>
std::vector<std::vector<T>> basic_warshall_floyd(const std::vector<std::vector<T>> &graph, AB ab) {
    auto f = [&](const T &a, const T &b) { return a == ab() || b == ab() ? ab() : a + b; };
    return warshall_floyd(graph, f, std::greater<T>());
}

#include <bits/stdc++.h>
using namespace std;

int main() {
    int V, E;
    cin >> V >> E;
    auto ab = []() { return INT_MAX; };
    vector<vector<int>> graph(V, vector<int>(V, ab()));
    for (int i = 0; i < V; i++) { graph[i][i] = 0; }
    for (int i = 0; i < E; i++) {
        int s, t, d;
        cin >> s >> t >> d;
        graph[s][t] = d;
    }
    vector<vector<int>> dist = basic_warshall_floyd(graph, ab);
    for (int i = 0; i < V; i++) {
        if (dist[i][i] < 0) {
            cout << "NEGATIVE CYCLE" << endl;
            return 0;
        }
    }
    for (int i = 0; i < V; i++) {
        for (int j = 0; j < V; j++) {
            cout << (dist[i][j] == ab() ? "INF" : to_string(dist[i][j])) << (j < V - 1 ? " " : "");
        }
        cout << endl;
    }
}


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

const int N = 1e5+5;
int n, a[N][3], dp[N][3];

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

  for (int i = 0; i < n; i++)
    scanf("%d%d%d", a[i], a[i]+1, a[i]+2);

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++)
      dp[i][j] = a[i][j];

    if (i != 0) {
      dp[i][0] += std::max(dp[i-1][1], dp[i-1][2]);
      dp[i][1] += std::max(dp[i-1][0], dp[i-1][2]);
      dp[i][2] += std::max(dp[i-1][1], dp[i-1][0]);
    }
  }

  printf("%d\n", std::max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}));
  return 0;
}


Measured memory_bytes: 2560
n = int(input())
s = [list(map(str,input().split())) for i in range(n)]
for i in range(n):
    s[i].append(i+1)
    s[i][1] = 100 - int(s[i][1])

s.sort()
for i in range(n):
    print(s[i][2])

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

int main() {
  int N;
  
  cin >> N;
  
  int total=N;
  int count=0;
  vector<int> A(N);
  
  for(int i = 0; i<N; i++){
  	cin >> A.at(i);
  }
  
  while(total == N){
    total = 0;
    for(int i=0;i<N;i++){
      if(A.at(i)%2 == 0){
        total += 1;
        A.at(i) /= 2;
      }
    }
    count += 1;
  }
  cout << count-1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N);
    vector<ll> F(N);
    for (int j = 0; j < N; ++j) {
        cin >> A[j];
    }
    for (int j = 0; j < N; ++j) {
        cin >> F[j];
    }
    sort(A.begin(),A.end());
    sort(F.begin(),F.end(),greater<ll>());
    ll l = 0;
    ll r = 1ll << 50;
    for(int loop = 0;loop < 100; loop++){
        ll tmpK = K;
        ll m = (l + r)/2;
        for (int i = 0; i < N; ++i) {
            if(A[i] * F[i] > m){
                tmpK -= ceil(double(A[i] * F[i] - m)/double(F[i]));
            }
        }
        if(tmpK < 0){
            l = m;
        }else{
            r = m;
        }
    }
    ll tmpK = K;
    for (int i = 0; i < N; ++i) {
        if(A[i] * F[i] > l){
            tmpK -= ceil(double(A[i] * F[i] - l)/double(F[i]));
        }
    }
    if(tmpK < 0){
        cout << r << endl;
    }else{
        cout << l << endl;
    }

}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
void dfs(int node,vector<int>adj[],int dp[],bool visited[])
{
    visited[node]=true;
    for(int i=0;i<adj[node].size();++i)
    {
        if(!visited[adj[node][i]])
        {
            dfs(adj[node][i],adj,dp,visited);
        }
        dp[node]=max(dp[node],dp[adj[node][i]]+1);
    }
}
int findLongest(vector<int>adj[],int n)
{
    int dp[n+1];
    bool visited[n+1];
    for(int i=0;i<=n;++i)
    {
        dp[i]=0;
        visited[i]=false;
    }
    for(int i=1;i<=n;++i)
    {
        if(!visited[i])
        {
            dfs(i, adj, dp, visited);
        }
    }
    int mx1=0;
    for(int i=0;i<=n;++i)
    {
        mx1=max(mx1,dp[i]);
    }
    return mx1;
    
}

int main()
{
    int n,m;
    cin>>n>>m;
    int max1=1e5+5;
    vector<int>adj[max1];
    while(m--)
    {
        int a,b;
        scanf("%d %d",&a,&b);
        adj[a].push_back(b);
    }
    cout<<findLongest(adj, n)<<endl;
    
    return 0;
}


Measured memory_bytes: 12936
#include <bits/stdc++.h>
using namespace std;
int main(){
    long w,h,x,y;
    cin >> w >> h >> x >>y;
    cout << (double)w*h/2 << " ";
    if((double)w/2 == x && (double)h/2 == y)cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 3740
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y-1);(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int i,j,k,T;
  cin>>T;
  while(T--){
    double xx,yy;
    ll x[4],y[4];
    rep(i,4){
      cin>>xx>>yy;
      x[i]=xx*1e6;
      y[i]=yy*1e6;
      //   cout<<x[i]<<","<<y[i]<<endl;
    }
    rep(i,2){
      x[i*2+1]-=x[i*2];
      y[i*2+1]-=y[i*2];
    }
    cout<<(x[1]*y[3]==x[3]*y[1]?"YES":"NO")<<endl;
  }
  return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;

int main(){
	int i, j, n;
	cin >> n;
	int a[n];
	int b[n];
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}

	int count = 0;
	int sum = 0;
	for (i = n - 1; i > -1; i--) {
		if (n / (i + 1) == 1) {
			if (a[i] == 1) {
				b[i] = 1;
				count++;
			} else {
				b[i] = 0;
			}
		} else {
			sum = 0;
			for(j = 2 * (i + 1) - 1; j < n; j += (i + 1)) {
				sum += b[j];
			}
			if (sum % 2 == a[i]) {
				b[i] = 0;
			} else {
				b[i] = 1;
				count++;
			}
		}
	}

	if(count == 0){
		cout << 0;
		return 0;
	}

	cout << count << endl;
	int count_ = 0;
	for(i = 0; i < n; i++){
		if(b[i] == 1){
			cout << i + 1;
			count_++;
			if (count == count_) {
				return 0;
			} else {
				cout << " ";
			}
		}
	}
}


Measured memory_bytes: 2432
import sys
from heapq import heappush, heappop
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    H = list(map(int, input().split())) + [-1]

    ans = 0
    for n in range(1, max(H) + 1):
        conti = 0
        exist = False
        for h in H:
            if h >= n and exist:
                continue
            elif h >= n:
                exist = True
            elif h < n and exist:
                conti += 1
                exist = False
        ans += conti
    print(ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 39024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

int main(){
	string a;
	map<string,int> untsun;
	untsun["SUN"]=7;
	untsun["SAT"]=1;
	untsun["FRI"]=2;
	untsun["THU"]=3;
	untsun["WED"]=4;
	untsun["TUE"]=5;
	untsun["MON"]=6;
	cin>>a;
	cout<<untsun[a]<<endl;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  ll ans = 0;
  for(int i = 1; i < n; ++i){
    ans += (n-1) / i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<map>
#include<stack>
#define FOR(i,a,b) for(int i=(a); i<int(b); ++i)
#define RFOR(i,a,b) for(int i=(b)-1; i>=int(a); --i)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,int(n)+1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
#define al(d) d.begin(),d.end()
using namespace std;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(int n){
	vector<T> vec;
	rep(i,n){
		T input;
		cin >> input;
		vec.emplace_back(input);
	}
	return vec;
}
using AdjList = vector<vector<int>>;
using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

// Recieve edge(=(int,int)) as an adj list.
vector<vector<int>> getadj(int N, int M){
	// Initialize all lists of the graph as a empty vector.
	vector<int> init;
	vector<vector<int>> graph(N,init);

	rep(i,M){
		int a, b;
		cin >> a >> b;
		graph[a-1].emplace_back(b-1);
		graph[b-1].emplace_back(a-1);
	}
// rep(i,N)
// 	putv(graph[i]);
	return graph;
}

#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
using namespace std;

int main(){
	int N,M;
	cin >> N;
	vector<int> T = getv<int>(N);
	cin >> M;
	int sum = 0;
	int P,X;
	rep(i,M){
		cin >> P >> X;
		rep(j,N){
			if(j==P-1) sum += X;
			else sum += T[j];
		}
		cout << sum << endl;
		sum = 0;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct P {
    bool operator<(const P &p) const {
        return c > p.c;
    }
    int d, m, c;
};

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

    int n;
    cin >> n;

    vector<P> p(n);
    string s;

    constexpr int INF = 1 << 30;
    for (int i = 0; i < n; i++) {
        int d = 0, m = 0;
        cin >> s;
        for (const auto &c : s) {
            d += c == '(' ? 1 : -1;
            m = min(m, d);
        }
        p[i] = { d, m, d > 0 ? INF + m : -INF + (d - m) };
    }
    sort(p.begin(), p.end());

    int b = 1;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        if (sum + p[i].m < 0) b = 0;
        sum += p[i].d;
    }
    cout << (b && sum == 0 ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 14940
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int N;
  cin >> N;
  vector <string> s(N);
  rep(i,N) cin >> s[i];

  int M;
  cin >> M;
  vector <string> t(M);
  rep(i,M) cin >> t[i];


  int ans = 0;

  rep(i,N){
    int score = 0;
    rep(j,N) if (s[j]==s[i]) score++;
    rep(j,M) if (t[j]==s[i]) score--;

    ans = max(ans, score);
  }

  cout << ans << endl;

}


Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Stack;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        //BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String s = sc.next();
        Stack<Character> st = new Stack();

        for(char c : s.toCharArray()){
            if(c == 'B'){
                if(!st.isEmpty()){
                    st.pop();
                }
            }
            else{
                st.push(c);
            }
        }

        StringBuilder sb = new StringBuilder();

        while(!st.isEmpty()){
            sb.insert(0, st.pop());
        }
        
        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 9812
#include <algorithm>
#include <array>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

int main(int argc, char** argv) {
	string s;
	cin >> s;

	if (s == "Sunny") {
		cout << "Cloudy" << endl;
	}
	else if (s == "Cloudy") {
		cout << "Rainy" << endl;
	}
	else if (s == "Rainy") {
		cout << "Sunny" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		String nl = System.getProperty("line.separator");
		StringBuilder p = new StringBuilder(500);
		StringBuilder d = new StringBuilder(".");
		StringBuilder s = new StringBuilder("#");
		Scanner r = new Scanner(System.in);
		int h, w, i, j, ww;
		String t, u;
		for (i = 0; i < 4; ++i) {
			d.append(d);
			s.append(s);
		}
		ww = d.length();
		while ((h = r.nextInt()) + (w = r.nextInt()) > 0) {
			while (w > ww) {
				d.append(d);
				s.append(s);
				ww += ww;
			}
			u = s.substring(0,w);
			p.append(u);
			p.append(nl);
			t = d.substring(0, w - 2);
			for (i = 2; i < h; ++i) {
				p.append('#');
				p.append(t);
				p.append('#');
				p.append(nl);
			}
			p.append(u);
			p.append(nl);
			p.append(nl);
		}
		System.out.print(p);
	}
}

Measured memory_bytes: 18408
#include<iostream>
#include<cstdio>
using namespace std;
char ch[7];
int main()
{
	for(int i=1;i<=6;i++)
		cin>>ch[i];
	if(ch[5]==ch[6]&&ch[3]==ch[4]) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;
using namespace chrono;
 
typedef long long ll;
typedef long double ld;

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

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

//#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define loop(x,n) for(int x = 0; x < n; ++x)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)

#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)
#define resz resize

const int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const int MX = 100001;

string get_str() {
    string temp;
    cin >> temp;
    return temp;
}
int get_int() {
    int temp;
    cin >> temp;
    return temp;
}


int main() {
    
    loop(i, 5) {
        int t;
        cin >> t;
        if(t == 0) {
            cout << i+1 << endl;
            break;
        }
    }

}


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

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

	int ans = 0;

	REP(i, a + 1){
		REP(j, b + 1){
			REP(k, c + 1){
				if (i * 500 + j * 100 + k * 50 == x) ans++;
				
			}
		}
	}

	cout << ans << endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<string>
#include<iostream>
#include<algorithm>
#define rep(i,s,t) for(int i=s;i<=t;i++)
#define dep(i,t,s) for(int i=t;i>=s;i--)
using namespace std;
string s;
long long mark[29],ans;
int main()
{
	cin>>s;
	rep(i,0,s.size()-1)	mark[s[i]-'a'+1]++;
	rep(i,1,26)
		if(mark[i]!=0)
			ans+=(mark[i]-1)*mark[i]/2;
	printf("%lld",(long long)s.size()*(s.size()+1)/2-ans-s.size()+1);
    return 0;
}


Measured memory_bytes: 640
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb push_back
#define res(v) v.resize(unique(v.begin(), v.end()) - v.begin());
#define cnt_res(v) std::distance(v.begin(),std::unique(v.begin(), v.end())); 
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e3+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
vi a;int n;pii dp[N][N];
pii f(int l,int r){
    if(l==r and l>=1 and r<=n)return dp[l][l]={0,a[l]};
    if(l>r or l<1 or r>n)return {0,0};
    if(dp[l][r]!=mp(0LL,0LL))return dp[l][r];
    int cost=inf,w;
    rep(i,l,r-1)
        if(f(l,i).F+f(i+1,r).F<cost)
            cost=f(l,i).F+f(i+1,r).F,w=f(l,i).S+f(i+1,r).S;
    return dp[l][r]={cost+w,w};
}
void solve(){
    cin>>n;a=vi(n+1);
    rep(i,1,n)cin>>a[i];
    cout<<f(1,n).F;
}
int32_t main()
{
  ibs;cti;
  solve()
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  // int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

Measured memory_bytes: 13184
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define fs first
#define sc second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 2e5+10;
using namespace std;

ll N,K;
int to[maxn];
int st[maxn][70];
void init_ST(){
	for(int i = 1;i<=N;i++) st[i][0] = to[i];
	for(int j = 1;j<=64;j++){
		for(int i = 1;i<=N;i++){
			st[i][j] = st[st[i][j-1]][j-1];
		}
	}
}
int solve(){
	int cur = 1;
	for(int j = 0;j<=64;j++){
		if(K == 0) return cur;
		if((K>>j) & 1){
			cur = st[cur][j];
			K -= (1LL<<j);
		}
	}
	return -1;
}
int main(){
	// debug;
	ios;
	cin>>N>>K;
	for(int i = 1;i<=N;i++) cin>>to[i];
	init_ST();
	cout<<solve()<<'\n';
	return 0;
}


Measured memory_bytes: 59132
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double EPS = 1e-10;


int main(void) {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> v(N);
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    v[a].push_back(b);
    v[b].push_back(a);
  }

  vector<int> perm(N - 1);
  for (int i = 0; i < perm.size(); ++i) {
    perm[i] = i + 1;
  }

  int ans = 0;
  do {
    bool ok = true;
    int old = 0;
    rep(i, perm.size()) {
      if (find(v[old].begin(), v[old].end(), perm[i]) == v[old].end()) {
        ok = false;
        break;
      }
      old = perm[i];
    }
    if (ok) ++ans;
  } while (next_permutation(perm.begin(), perm.end()));

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

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

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

const ll oo = 1e18;
const ll mod = 998244353,maxn = 3030;
const double PI = acos(-1);


int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    char mat[110][110];
    int n, m;
    cin >> n >> m;

    for (int i=0; i<n; i++){
        for (int j=0; j<m; j++){
            cin >> mat[i][j];
        }
    }

    for (int i=-1; i<=n; i++){
        cout << "#";

        for (int j=0; j<m; j++){
            if (i<n and i >-1) cout << mat[i][j];
            else cout << "#";
        }

        cout << "#\n" ;
    }

    return 0;
}

Measured memory_bytes: 3616
#include "bits/stdc++.h"
using namespace std;
int INF = numeric_limits<int>::max() / 2;
using ll = long long;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
    map<int, int> mp;
    cin >> n;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        mp[a]++;
    }
    int ans = 0;
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        int num = itr->first;
        int numofnum = itr->second;
        if(num > numofnum){
            ans += numofnum;
        }else if(num == numofnum){
            //nothing to do
        }else{
            ans += numofnum - num;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int a[200005];
map <long long, int> cnt;

int main(){
	int n;
	scanf("%d", &n);
	
	for(int i = 0; i < n; i++)
	scanf("%d", &a[i]);
	
	cnt[0] = 1;
	long long res = 0;
	long long cur = 0;
	
	for(int i = 0; i < n; i++){
		cur += a[i];
		res += cnt[cur];
		cnt[cur]++;
	}
	
	printf("%lld\n", res);
}


Measured memory_bytes: 13568
import sys

input = sys.stdin.readline
MOD = 1000000007

N = int(input())

num = [0]*(200)

S = {}

cnt = 0
for i in range(N):
    x = input()[:-1]
    if x not in S:
        S[x] = cnt
        num[cnt] = 1
        cnt+=1
    else:
        num[S[x]]+=1

M = int(input())
for i in range(M):
    x = input()[:-1]
    if x not in S:
        pass
    else:
        num[S[x]] -=1


res = 0
for i in num:
    if i > 0:
        res+= i

print(max(num))

Measured memory_bytes: 3064
#include<iostream>
#include <string>
 
int main()
{
	std::string str;
  	int counter = 0;
	std::cin >> str;
	if(str[0] == '1') counter++;
  	if(str[1] == '1') counter++;
  	if(str[2] == '1') counter++;
  
  	std::cout << counter << std::endl;
}

Measured memory_bytes: 3624
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program{
  static void Main(){
    var input = int.Parse(ReadLine());
    var nums = new int[32]{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    
    Write(nums[input-1]);
  }
}

Measured memory_bytes: 17432
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
 #define int ll
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add_self(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int add(int a,int b){
	int c=a+b;
	if(c>=mod){
		c-=mod;
	}
	return c;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=2000005;

ll dp[2][505][505];
 
void solve(){
	int n,k;
	cin>>n>>k;
	vi a(n);
	cin>>a;
    if(n<=k){
      cout<<0;
      return;
    }
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			dp[0][i][j]=dp[1][i][j]=1e18;
		}
	}
	vector<int>compress;
	compress=a;
	sort(all(compress));
	compress.resize(unique(all(compress))-compress.begin());
	debug(compress);
	for(auto &i:a){
		i=lower_bound(all(compress),i)-compress.begin();
	}
	for(int prv=0;prv<compress.size();prv++){
		dp[0][1][a[prv]]=compress[a[prv]];
	}
	dp[0][0][a[0]]=compress[a[0]];
	dp[0][1][a[0]]=1e18;
	for(int i=1;i<n;i++){
		for(int j=0;j<=k;j++){
			for(int prv=0;prv<compress.size();prv++){
				if(a[i]!=prv){
					dp[1][j+1][prv]=min(dp[1][j+1][prv],dp[0][j][prv]);
				}
				else{
					dp[1][j][prv]=min(dp[1][j][prv],dp[0][j][prv]);
				}
				dp[1][j][a[i]]=min(dp[1][j][a[i]],dp[0][j][prv]+max(0ll,compress[a[i]]-compress[prv]));
			}	
		}
		for(int j=0;j<=k;j++){
			for(int prv=0;prv<compress.size();prv++){
				dp[0][j][prv]=dp[1][j][prv];
				dp[1][j][prv]=1e18;
			}
		}
	}
	ll ans=1e18+700;
	for(int i=0;i<=k;i++){
		for(int prv=0;prv<compress.size();prv++){
			ans=min(ans,dp[0][i][prv]);
		}
	}
	cout<<ans;
}
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


Measured memory_bytes: 2688
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
template<class T> void _out(const T &x) { cout << x; }
void _out(const int &x) { printf("%d", x); }
void _out(const ll &x) { printf("%lld", x); }
void _out(const double &x) { printf("%.16f", x); }
void _out(const char &x) { putchar(x); }
void _out(const char *x) { printf("%s", x); }
template<class T,class U> void _out(const pair<T,U> &x) {_out(x.F); putchar(' '); _out(x.S);}
template<class T> void _out(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _out(*i++)) if (i != x.cbegin()) putchar(' '); }
void out() {}
template<class T, class... U> void out(const T &head, const U &... tail) { _out(head); putchar(sizeof...(tail) ? ' ' : '\n'); out(tail...); }
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int l, r, d;
    sf(l, r, d);
    int cnt  = 0;
    rep(i, l, r) {
        if (i % d == 0) ++cnt;
    }
    out(cnt);
    return 0;
}

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


int main(){
	int a,b,c,d;
	int counter=1;
	while(cin>> a >> b){
	c=a+b;
	
		while(c/10!=0){	
			
		c=c/10;
		counter++;
		}
	
	cout<<counter<<endl;
	counter=1;
}
	
}

Measured memory_bytes: 1160