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

using namespace std;

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

    vector<int> C(m,-1);
    for ( int i = 0; i < m; ++i ) {
        cin >> C[i];
    }

    int min = 500000;
    vector<int> dp(n+1,-1);
    dp[0] = 0;
    for ( int v = 1; v <= n; ++v ) {
        for ( int j = m-1; j >= 0; --j ) {
            if ( C[j] <= v && dp[v-C[j]] != -1 )
            {
                if ( dp[v-C[j]] < min ) min = dp[v-C[j]];
            }
            
        }
        dp[v] = min + 1;
        //cout << "dp[" << v << "] : " << dp[v] << endl;
        min = 500000;
    }

    cout << dp[n] << endl;
}


Measured memory_bytes: 3172
op = ""
A=[]
B=[]
C=[]
while not op == "?":
    a,op,b = map(str, input().split())
    A.append(int(a))
    B.append(int(b))
    C.append(op)


for i in range(len(A)-1):
    if C[i] =="+":
        print(A[i]+B[i])
    elif C[i] =="-":
        print(A[i] - B[i])
    elif C[i] =="*":
        print(A[i] * B[i])
    else:
        print(int(A[i] / B[i]))

Measured memory_bytes: 7620
#include<stdio.h>

int main(){
  int x;
  int i,j;
  int y[10000];
  for(i=0;i<10000;i++){
    scanf("%d",&x);
    if(x==0){
      break;
    }
    y[i] = x;
  }
  for(j=0;j<i;j++){
    printf("Case %d: %d\n",j+1,y[j]);
  }
  return 0;
}

Measured memory_bytes: 2740
def main():
 a = int(input())
 b = int(input())
 c = int(input())
 d = int(input())
 e = int(input())
 lim = int(input())
 if max(a,b,c,d,e) - min(a,b,c,d,e) <= lim:
     print('Yay!')
 else:
     print(':(')
main()

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

using namespace std;
typedef long long ll;
const long long mod=1e9+7; //10^9+7

int main() {
    int n,a[200001];
    cin >> n;
    int maxl[200001],maxr[200001];
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(i==0) maxl[i]=a[i];
        else maxl[i] = max(a[i],maxl[i-1]);
    }
    for(int i=n-1;i>=0;i--){
        if(i==n-1){
            maxr[i] = a[i];
        }else{
            maxr[i] = max(a[i],maxr[i+1]);
        }
    }
    for(int i=0;i<n;i++){
        if(i==0){
            cout << maxr[1];
        }else if(i==n-1){
            cout << maxl[n-2];
        }else{
            cout << max(maxl[i-1],maxr[i+1]);
        }

        cout << endl;
    }


  return 0;
}


Measured memory_bytes: 3968
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
        final int N = Integer.parseInt(sc.next());
        final int K = Integer.parseInt(sc.next());
        final int Q = Integer.parseInt(sc.next());
        int[] ar = new int[N];
        for (int i = 0; i < Q; i++) {
            int index = Integer.parseInt(sc.next()) - 1;
            ar[index]++; 
        }
        
        for (int i = 0; i < N; i++) {
            if (K - (Q - ar[i]) > 0) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }

        out.flush();
    }
}

Measured memory_bytes: 48840
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] ret = new int[2];
            string s1 = Console.ReadLine();
            string s2 = Console.ReadLine();

            uint N = uint.Parse(s1);
            string[] ss = s2.Split(' ');

            int[] num = new int[N];

            for (int i = 0; i < N; i++)
            {
                num[i] = int.Parse(ss[i]);
            }

            Array.Sort(num);
            int max = num[N - 1];
            int cen = max / 2;
            if (max % 2 > 0)
            {
                cen++;
            }
            int tmp = max;

            for (int i = 0; i < N; i++)
            {
                if (num[i] >= cen)
                {
                    if ((cen - tmp) == (num[i] - cen))
                    {
                        ret[1] = tmp;
                    }
                    else if ( (cen - tmp) < (num[i] - cen) )
                    {
                        ret[1] = tmp;
                    }
                    else
                    {
                        ret[1] = num[i];
                    }
                    break;
                }
                tmp = num[i];
            }

            //uint cp = N / 2;

            ret[0] = max;
            Console.WriteLine(ret[0] + " " + ret[1]);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 20448
#include<bits/stdc++.h>
using namespace std;
int main(){
  int alice,bob,n,k;
  vector<int> num;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>k;
    num.push_back(k);
  }
  sort(num.begin(),num.end(),greater<int>());
  for(int i=0;i<n;i++){
    if(i%2==0)
      alice+=num.at(i);
    else
      bob+=num.at(i);
  }
  cout<<alice-bob;
}

Measured memory_bytes: 256
#include <atcoder/dsu.hpp>
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <atcoder/all>

using boost::multiprecision::cpp_int;
using namespace std;
using namespace atcoder;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<p> v(m);
  dsu uni(n);
  rep(i, m){
    int from, to;
    cin >> from >> to;
    from--;to--;
    v[i] = {from, to};
    uni.merge(from, to);
  }

  set<int> s;
  rep(i, n){
    s.insert(uni.leader(i));
  }

  cout << s.size() - 1 << endl;
}


Measured memory_bytes: 7624
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<cstdlib>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#include<string>
#include<bitset>
#define lmid l,mid,rt<<1
#define rmid mid+1,r,rt<<1|1
#define ll long long
using namespace std;
int main()
{
     int n;
     scanf("%d",&n);
     printf("%d\n",48-n);
     return 0;
}


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

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

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

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

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

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	map<string,int> ma;
	string s;
	pair<int,string> m1(0,"");
	pair<int,string> m2(0,"");
	while(cin>>s){
		if(ma.count(s)==0) ma[s]=0;
		ma[s]++;
		maxs(m1,mkp((int)s.size(),s));
	}
	for(auto x:ma){
		maxs(m2,mkp(x.S,x.F));
	}
	cout<<m2.S<<" "<<m1.S<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 3172
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

vector<vector<int>> check(100010, vector<int>());
vector<bool> flag(100010);
/*bool ok = true;

void dfs(int n, int p) {
	if (flag[n]) {
		ok = false;
		cout << n << endl;
		return;
	}
	flag[n] = true;
	for (int i : check[n]) {
		if (i == p) continue;
		else dfs(i, n);
	}
}*/

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n, m;
	cin >> n >> m;
	vector<vector<P>> graph(n, vector<P>());
	vector<int> l(m), r(m), d(m);
	vector<int> cnt(n);
	rep(i, m) {
		cin >> l[i] >> r[i] >> d[i];
		l[i]--; r[i]--;
		graph[l[i]].pb(P(r[i], d[i]));
		//if (d[i] > 0) check[l[i]].pb(r[i]);
		cnt[r[i]]++;
	}
	/*rep(i, n) {
		if (!flag[i]) {
			dfs(i, -1);
		}
	}
	if (!ok) {
		cout << "No" << endl;
		return 0;
	}*/
	vector<int> dis(n, -1);
	vector<bool> used(n);
	priority_queue<P> que;
	rep(i, n) {
		if (cnt[i] == 0) {
			que.push(P(0, i));
			dis[i] = 0;
			used[i] = true;
		}
	}
	while (!que.empty()) {
		P p = que.top(); que.pop();
		int pf = p.first; int ps = p.second;
		flag[ps] = true;
		//cout << pf << ' ' << ps << endl;
		for (P i : graph[ps]) {
			if (dis[i.first] != -1 && dis[i.first] != dis[ps] + i.second) {
				cout << "No" << endl;
				return 0;
			}
			else {
				dis[i.first] = dis[ps] + i.second;
				if (!used[i.first]) {
					que.push(P(dis[i.first], i.first));
					used[i.first] = true;
				}
			}
		}
	}
	bool ans = true;
	rep(i, n) if (!flag[i]) ans = false;
	cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 18544
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
	int R[MAX],n;
	cin >> n;
	for(int i = 0;i<n;i++){
		cin >> R[i];
	}
	int maxv = -2000000000;
	int minv = R[0];
	
	for (int i = 1; i< n; i++){
		maxv = max(maxv,R[i] - minv);
		minv = min(minv ,R[i]);
	}
	
	cout << maxv << endl;
	
	return 0;
} 


Measured memory_bytes: 3868
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <sstream>
#include <fstream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <tuple>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;

using ll=long long;

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <vll> vl2d;
typedef vector <vi> vi2d;
typedef vector <char> vc;
typedef vector <bool> vb;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <char,int> mci;
typedef map <int,int> mii;
typedef map <long,long> ml;
typedef map <string,string> mss;
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define foreach(x,arr) for(auto& x:arr)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define endl '\n' // Normal `cout << endl` flushes the output every time wich hit performance badly
#define INF 1000000000LL
#define MOD 1000000007ll
#define deb(x) cout<<#x<<": "<<x<<endl;
#define printArray(arr) for(auto x: arr) { cout<<x<<"\t"; }
#define printMatrix(mat) for(auto x: mat) { cout<<" "; printArray(x); cout<<endl; }
#define printMap(mmap) for(auto p: mmap) { cout<< p.first<<": "<<p.second<<endl; }
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define forch(ch,str) for(char& c : str)
#define FILL(a,b) memset(a,b,sizeof(a))
//Swift related stuff
#define append push_back
#define nil nullptr
#define guard(_condition) if (bool(_condition)){}
#define count size()
#define let const auto
#define var auto
#define startsWith(str) rfind(str, 0)
#define prq priority_queue
#define tostr(argument) to_string(argument)
#define alphabet "abcdefghijklmnopqrstuvwxyz"


int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); // Fast input
    
    ll n,m;
    cin>>n>>m;
    map<ll, vll> g;
    rep(i,0,m) {
        ll s,d;
        cin>>s>>d;
        g[s-1].push_back(d-1);
        g[d-1].push_back(s-1);
    }
    
    bool visited[n];
    memset(visited, false, sizeof visited);
    deque<ll> q;
    q.push_back(0);
    vll res(n,0);
    ll total = n;
    while (!q.empty()) {
        ll cur = q.front();
        q.pop_front();
        foreach(n, g[cur]) {
            guard(!visited[n]) else {
                continue;
            }
            visited[n] = true;
            res[n] = cur+1;
            q.push_back(n);
            total -= 1;
        }
    }
    guard(total == 0) else {
        cout<<"No"<<endl;
        return 0;
    }
    
    cout<<"Yes"<<endl;
    rep(i,1,n) {
        cout<<res[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 19544
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  int mi=1e9+7,ma=0;
  rep(i,n)
  {
    int m;cin>>m;
    chmin(mi,m);
    chmax(ma,m);
  }
  cout<<ma-mi<<endl;

  return 0;

}


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

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt(), q = fs.nextInt();
		String s = fs.next();
		char c[] = s.toCharArray();
		int t[] = new int[n];
		for(int i=0;i<n-1;i++) {
			if(c[i]=='A'&&c[i+1]=='C') {
				t[i] = 1;
			}
		}
		
		int sum[] = new int[n+1];
		for(int i=0;i<n;i++)sum[i+1] = sum[i] + t[i];
		 
		for(int i=0;i<q;i++) {
			int l = fs.nextInt()-1, r = fs.nextInt()-1;
			int res = sum[r] - sum[l];
			System.out.println(res);
		}
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 72192
S = input()
T = input()

ans = 1000
N = len(S)
M = len(T)
for i in range(N - M + 1):
    a = 0
    for j in range(M):
        if S[i + j] != T[j]:
            a += 1
    ans = min(a, ans)
print(ans)

Measured memory_bytes: 9052
#include <bits/stdc++.h>
// #include<iostream>
// #include<vector>
// #include<cmath>
// #include<iomanip>
using namespace std;
 
const double PI= acos(-1.0);
 
int gcd_func(int a, int b){
    return b? gcd_func(b, a%b) : a;
} 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    long long a; double b; cin >> a >> b;
    long long al = a;
    b*=100;
    int bl = (int)(b+0.5);
    cout << (al*bl)/100;
    return 0;
}

Measured memory_bytes: 3732
n, m = gets.chomp.split(" ").map(&:to_i)
lands,one = [], []
flag = false

for i in 0..m-1
	kouho = gets.chomp.split(" ").map(&:to_i)
	if kouho[0] == 1
		one.push(kouho[1])
	elsif kouho[1] == n
		lands.push(kouho[0])		
	end
end

puts one & lands != [] ? 'POSSIBLE' : 'IMPOSSIBLE'



Measured memory_bytes: 9868
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


def main():
    abcd = input()
    bits = []

    for i in range(2 ** 3):
        eq = []
        for j in range(4):
            eq.append(abcd[j])
            if j > 2:
                break
            if (i >> j) & 1:
                eq.append('+')
            else:
                eq.append('-')
        eveq = ''.join(eq)
        if eval(eveq) == 7:
            print(eveq + '=7')
            return


if __name__ == '__main__':
    main()


Measured memory_bytes: 5420
"use strict";
main(
  require("fs")
    .readFileSync("/dev/stdin", "UTF-8")
    .trim()
    .split("\n")
);
function main(input) {
  input = input[0].split("");
  let num = 2;
  let isSame = true;
  while (num > 0) {
    if (input[num] !== input[0]) {
      isSame = false;
      break;
    }
    num--;
  }
  console.log(isSame ? "No" : "Yes");
}


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

int main() {
    string s, t;
    cin >> s >> t;

    for(int i = 0; i < s.length(); i++) {
        if(s == t) {
            cout << "Yes";
            return 0;
        }
        char temp = s.back();
        s.pop_back();
        s.insert(s.begin(), temp);
    }

    cout << "No";
}

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

int main(void){
	char s[1010],m[100],c[1010],p[1010];
	int q,i,j,a,b;
	scanf("%s %d",s,&q);
	strcpy(c,s);
	for(i=0;i<q;i++){
		scanf("%s",m);
		if(strcmp(m,"print")==0){
			scanf("%d %d",&a,&b);
			for(j=a;j<=b;j++){
				printf("%c",s[j]);
			}
			strcpy(c,s);
			printf("\n");
		}
		if(strcmp(m,"reverse")==0){
			scanf("%d %d",&a,&b);
			for(j=a;j<=b;j++){
				s[j]=c[b-j+a];
			}
			strcpy(c,s);
		}
		if(strcmp(m,"replace")==0){
			scanf("%d %d %s",&a,&b,p);
			for(j=a;j<=b;j++){
				s[j]=p[j-a];
			}
			strcpy(c,s);
		}
	}
	return 0;
}

Measured memory_bytes: 588
from collections import Counter

N = int(input())
V = list(map(int, input().split()))
S1 = Counter([V[i] for i in range(0, N, 2)])
S2 = Counter([V[i] for i in range(1, N, 2)])

S1 = sorted(S1.items(), key=lambda x: x[1], reverse=True)
S2 = sorted(S2.items(), key=lambda x: x[1], reverse=True)
S1.append([0, 0])
S2.append([0, 0])

if S1[0][0] == S2[0][0]:
    ans = min(N-(S1[0][1]+S2[1][1]), N-(S1[1][1]+S2[0][1]))
else:
    ans = N - (S1[0][1] + S2[0][1])
print(ans)


Measured memory_bytes: 18656
N = int(input())
ans = 0
l = [[0 for _ in range(10)] for _ in range(10)]
for A in range(1, N + 1):
    A = str(A)
    a = int(A[0])
    z = int(A[-1])
    l[a][z] += 1

for i in range(10):
    for j in range(10):
        ans += l[i][j] * l[j][i]

print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define INT(a) scanf("%d",&a)
#define STR(a) scanf("%s",a)
#define DBL(a) scanf("%lf",&a)
#define LNG(a) scanf("%lld",&a)
#define PI acos(-1)

int main(){
	int n;
	cin>>n;
	double ans=0;
	for(int i=1;i<=n;i++){
		double x;
		string s;
		cin>>x>>s;
		if(s=="JPY"){
			ans+=x;
		} else{
			ans+=(380000.0*x);
		}
	}
	cout<<setprecision(10)<<fixed<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = 0;
    
    reps(i, 1, n) {
        if (a[i - 1] == a[i]) {
            ans++;
            a[i] = INT_MAX;
        }
    }
    
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N, i;
  string S;
  cin >> N;

  // ここにプログラムを追記
  for (i = 0; i < N; i++){
    cin >> S;
    
    if (S == "Y"){
        cout << "Four" << endl;
        break;
    }
    
    if (i == N-1){
      cout << "Three" << endl;    
    }
  }
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		int i=1;
		int car[]=new int[100];
		car[0]=s.nextInt();
		while(s.hasNext()){
			car[i]=s.nextInt();
			if(car[i]==0){
				System.out.println(car[i-1]);
				i--;
			}
			else{
				i++;
			}
		}
	}
}

Measured memory_bytes: 12000
package main

import (
	"fmt"
	"math"
)

func factorial(a int) int{
	res := 1
	for a > 0 {
		res = res*a
		a--
	}
	return res
}

func dictionary(a []int) int{
	res := 1
	for i,_ := range a {
		c := 1
		for ii := i+1; ii < len(a); ii++ {
			if a[i] > a[ii] {
				c++
			}
		}
		res += factorial(len(a)-(i+1))*(c-1)
	}
	return res
}

func main() {
	var n int
	fmt.Scan(&n)
	p := make([]int,n)
	q := make([]int,n)
	for i := 0; i < n; i++ {
		fmt.Scan(&p[i])
	}
	for i := 0; i < n; i++ {
		fmt.Scan(&q[i])
	}

	pdic := dictionary(p)
	qdic := dictionary(q)
	fmt.Println(math.Abs(float64(pdic-qdic)))
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();

int32_t main(){
    int X,Y;cin>>X>>Y;

    int b=(Y-2*X)/2;
    int a=(4*X-Y)/2;
    // cout<<a<<" "<<b<<"\n";

    if(a>=0&&b>=0&&2*a+4*b==Y&&a+b==X){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
    
    return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>

int main()
{
	int a,b,x,y,z;
	scanf("%d %d",&a,&b);
	x=a+b;
	y=a-b;
	z=a*b;
	if(x>=y && x>=z){
		printf("%d",x);
	}else if(y>=x && y>=z){
		printf("%d",y);
	}else{
		printf("%d",z);
	}
	
	return 0;
}

Measured memory_bytes: 128
while line = gets
t,h,s = line.split.map(&:to_i)
break if t == -1 && h == -1 && s == -1
lt = (t * 3600) + (h * 60) + s

rt = 120 * 60 - lt
rt3 = 3 * rt
printf("%02d:%02d:%02d\n",(rt / 3600),(rt / 60) % 60,rt % 60)
printf("%02d:%02d:%02d\n",rt3 / 3600, (rt3 / 60) % 60, rt3 % 60)
end


Measured memory_bytes: 6848
a,b,c,d = map(int,input().split())
for i in range(10**5):
    if i%2 == 0:
        c -= b
        if c <= 0:
            print("Yes")
            break
    elif i%2 == 1:
        a -= d
        if a <= 0:
            print("No")
            break

Measured memory_bytes: 9052
#include <bits/stdc++.h>
using namespace std;
 
string S; int N, cnt;
 
int main() {
	cin >> N >> S;
	for (int i = 0; i < 1000; i++) {
		int c[3] = {i / 100, (i / 10) % 10, i % 10};
		int f = 0;
		for (int j = 0; j < N; j++) {
			if (S[j] == ('0' + c[f])) f++;
			if (f == 3) break;
		}
		if (f == 3) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3700
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<functional>
#include<vector>
#include<queue>
using namespace std;
#define f(i,n) for(int i=0;i<(int)n;i++)
#define MOD 1000000009
struct dice{
	int up;
	int down;
	int east;
	int west;
	int north;
	int south;
};
dice a;
char s[101]="NNNNENWNNNNENWNNNNENWNNNNENWENNNNWWNNNNE";
int x;
void input(void){
	scanf("%d", &x);
	a.up = x;
	scanf("%d", &x);
	a.south = x;
	scanf("%d", &x);
	a.east = x;
	scanf("%d", &x);
	a.west = x;
	scanf("%d", &x);
	a.north = x;
	scanf("%d", &x);
	a.down = x;
}
void nr(void){
			x = a.north;
			a.north = a.up;
			a.up = a.south;
			a.south = a.down;
			a.down = x;
			return;
}
void sr(void){
			x = a.south;
			a.south = a.up;
			a.up = a.north;
			a.north = a.down;
			a.down = x;
			return;
}
void er(void){
	x = a.east;
	a.east = a.up;
	a.up = a.west;
	a.west = a.down;
	a.down = x;
	return;
}
void wr(void){
	x = a.west;
	a.west = a.up;
	a.up = a.east;
	a.east = a.down;
	a.down = x;
	return;
}
int main(void){
	int n;
	int q;
	int c, d;
	input();
	n = strlen(s);
	scanf("%d", &q);
	f(qq, q){
		scanf("%d %d", &c, &d);
		f(i, n){
			if (s[i] == 'N'){
				nr();
			}
			else if (s[i] == 'S'){
				sr();
			}
			else if (s[i] == 'E'){
				er();
			}
			else if (s[i] == 'W'){
				wr();
			}
			if (a.up == c&&a.south == d)break;
		}
		printf("%d\n",a.east);
	}

	return 0;
}

Measured memory_bytes: 2728
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))

typedef long long ll;
typedef __int128_t lll;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5+1;
int n, w;
ll DP[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> w;
  FOR(i, 0, n){
    ll a, b;
    cin >> a >> b;
    FORR(j, w, a) maxs(DP[j], DP[j-a] + b);
  }
  cout << DP[w] << endl;
}

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

cnt = 0
s = 0

for i in range(N):
    s += A[i]

for i in range(N):
    if 4*M*A[i] < s:
        cnt += 1

print(['No', 'Yes'][N - cnt >= M])

Measured memory_bytes: 9124
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#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=1e9+7;
const LL LINF=1LL<<62;
const int INF=1<<30;

vector<int> v[100001],dp(100001,-1);

int dfs(int k){
    if(~dp[k]) return dp[k];
    int ret = 0;
    vector<int> t;
    for (int i = 0; i < v[k].size(); i++) {
        t.pb(dfs(v[k][i]));
    }
    sort(ALL(t));
    for (int i = 0; i < t.size(); i++) {
        ret = max((int)t.size()-i+t[i],ret);
    }
    return dp[k] = ret;
}



int main(){
    int n;cin >> n;
    for (int i = 2; i <= n; i++) {
        int a;cin >> a;
        v[a].pb(i);
    }
    cout << dfs(1) << endl;
    return 0;
}


Measured memory_bytes: 15488
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)();
typedef long long ll;
 
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}
 
const ll big=998244353;
int exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x)%big;
    ll t=exp(x,y/2);
    return (t*t)%big;
}
 
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(0);
    /*--------------------------------*/
    
    string s;cin >> s;
    rep(i,3)cout << s[i];
    cout << endl;
}

Measured memory_bytes: 3656
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;

import com.sun.org.apache.xalan.internal.xsltc.compiler.Pattern;

import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			final char[] chs = sc.next().toCharArray();
			
			int R = 0;
			for(char ch : chs) {
				R += ch == 'R' ? 1 : 0;
			}
			final int B = chs.length - R;
			
			System.out.println(R > B ? "Yes" : "No");
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21332
using System;
using System.Collections.Generic;

namespace Gacha
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var items = new HashSet<string>();

            for(int i=0; i < n; i++)
            {
                var item = Console.ReadLine();
                if (!items.Contains(item))
                {
                    items.Add(item);
                }
            }

            Console.WriteLine(items.Count);
        }
    }
}

Measured memory_bytes: 47100
#define _CRT_SECURE_NO_WARNINGS

#include<fstream>
#include<iostream>
#include<string>
#include<iomanip>
#include<list>
#include<math.h>
#include<stack>
#include<queue>

using namespace std;

queue<int> q;
list<int> l;
int *map = new int[12 * 12 * 20];
static int count;

void loop(int i){
	map[i] = 0;
	if (i / 12 > 0) {
		if (map[i - 12] == 1) {
			loop(i - 12);
		}
	}
	if (i / 12 < 11) {
		if (map[i + 12] == 1) {
			loop(i + 12);
		}
	}
	if (i % 12 > 0) {
		if (map[i - 1] == 1) {
			loop(i - 1);
		}
	}
	if (i % 12 < 11) {
		if (map[i + 1] == 1) {
			loop(i + 1);
		}
	}
}

int main(int argc, char **argv)
{
	int count = 0;
	string str;

	while (cin >> str) {
		for (int j = 0; j < 12; j++) {
			map[j] = str[j] - '0';
		}
		for (int i = 1; i < 12 && cin >> str; i++) {
			for (int j = 0; j < 12; j++) {
				map[i * 12 + j] = str[j] - '0';
			}
		}
		count = 0;
		for (int i = 0; i < 12 * 12; i++) {
			if (map[i] == 1) {
				loop(i);
				count++;
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1192
/* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod 998244353
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 1000005


// Driver code to test above functions
int32_t main()
{
  
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, ans = 0;
    cin >> n;
    map<int, int> mp;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin >> x;

        ans += mp[i-x];

        mp[i+x]++;
    }

    cout << ans;

    return 0;

} 


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

int f(int n) {
    int ans = 0;
    while (n) {
        ans += n%10;
        n/=10;
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(false);
    int n, a, b, ans = 0;
    cin >> n >> a >> b;
    
    for (int i = 1; i <= n; i++) {
        if (a <= f(i) && f(i) <= b)
            ans += i;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()

import random
from collections import Counter

res = 1
val = Counter(s).values()
if len(val) < 3:
    print(0)
    exit()

for i in val:
    res *= i

count = 0
for i in range(n):
    j = 1
    while i + 2 * j < n:
        if (s[i] != s[i+j]) and (s[i+j] != s[i+2*j]) and (s[i] != s[i+2*j]):
            count += 1
        j += 1

print(res - count)

Measured memory_bytes: 9796
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 7;
int k,s,z,ans = 0;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin>>k>>s;
    for(int i = 0; i <= k; i++)
    {
        for(int j = 0; j <= k; j++)
        {
            z = s - i - j;
            if(z >= 0 && z <= k)
            {
                ans++;
               // cout<<"x="<<i<<" y="<<j<<" z="<<z<<endl;
            }
          //  if(z == i && i ==j && z == j) ans -= 3;

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


Measured memory_bytes: 888
loop do
	h, w = gets.chomp.split.map(&:to_i)
	break if h == 0 && w == 0
	h.times do |i|
		if i%2 == 0
			puts (w%2 == 0 ? "#."*(w/2) : "#."*(w/2) << "#")
		else
			puts (w%2 == 0 ? ".#"*(w/2) : ".#"*(w/2) << ".")
		end
	end
	puts
end

Measured memory_bytes: 8716
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class B81 {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        in>>N;
        for(int i=1;i<10;++i){
            if(N%i) continue;
            if(N/i<10){
                out<<"Yes\n";
                return;
            }
        }
        out<<"No\n";
    }
};


int main() {
	B81 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

#define Debug(x) x
typedef int regular_int;
// #define int ll
typedef long long ll;

regular_int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(12) << fixed;

	int N;
	cin >> N;
	cout << (N - 2) * 180 << endl;
	return 0;
}


Measured memory_bytes: 256
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,x=map(int,input().split())
m=[int(input()) for i in range(n)]
x-=sum(m)
print(n+x//min(m))

Measured memory_bytes: 69156
use std::collections::HashMap;
use std::io::*;
use std::str::FromStr;


pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

struct Edge {
  to: usize,
  weight: i32,
}


fn main() {
  let n = read::<usize>();
  let mut graph: HashMap<usize, Vec<Edge>> = HashMap::new();
  let mut colors = vec![-1; n + 1];

  for _ in 0..n - 1 {
    let a = read::<usize>();
    let b = read::<usize>();
    let w = read::<i32>();

    add_edge(a, b, w, &mut graph);
    add_edge(b, a, w, &mut graph);
  }

  dfs(1000, 1, &mut colors, 0, &graph);

  colors.remove(0);
  for i in colors {
    println!("{:?}", i);
  }
}

fn add_edge(from: usize, to: usize, weight: i32, graph: &mut HashMap<usize, Vec<Edge>>) {
  if graph.contains_key(&from) {
    graph.get_mut(&from).unwrap().push(Edge {
      to: to,
      weight: weight,
    });
  } else {
    graph.insert(
      from,
      vec![Edge {
        to: to,
        weight: weight,
      }],
    );
  }
}

fn dfs(
  from: usize,
  to: usize,
  colors: &mut Vec<i32>,
  color: i32,
  graph: &HashMap<usize, Vec<Edge>>,
) {
  colors[to] = color;

  for edge in graph.get(&to).unwrap() {
    if edge.to != from {
      let new_color = (color + edge.weight) % 2;
      dfs(to, edge.to, colors, new_color, graph);
    }
  }
}


Measured memory_bytes: 18684
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    vector<string> dp(3001);
    vector<string> dp2(3001);

    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < t.size(); j++) {
            if (s[i] == t[j]) {
                if (dp[j].size() + 1 > dp[j + 1].size()) {
                    if (dp[j].size() + 1 > dp2[j].size())
                        dp2[j + 1] = dp[j] + s[i];
                    else
                        dp2[j + 1] = dp2[j];
                } else if (dp[j + 1].size() > dp2[j].size())
                    dp2[j + 1] = dp[j + 1];
                else
                    dp2[j + 1] = dp2[j];
            } else {
                if (dp[j + 1].size() > dp2[j].size())
                    dp2[j + 1] = dp[j + 1];
                else
                    dp2[j + 1] = dp2[j];
            }
        }
        swap(dp, dp2);
    }
    cout << dp[t.size()] << "\n";
}

Measured memory_bytes: 7808
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int n;
int a[105000];
int num[105000];
int d[105000];

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

	d[0] = num[0] + num[1];
	
	for (int i = 1; i < 100000; i++) {
		d[i] = num[i - 1] + num[i] + num[i + 1];
	}

	int max = 0;
	for (int i = 0; i < 100000; i++) {
		if (d[i] > max)max = d[i];
	}
	cout << max << endl;

	return 0;
}

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

int main() {
 int a,b,k;
 cin >> a >> b >> k;
  if(a+k-1>=b-k+1){
   for(int i=a;i<=b;i++){
   cout << i << endl;
   }
  }
  
  else{
    for(int i=a;i<a+k;i++){
    cout << i << endl;
    }
    for(int i=b-k+1;i<=b;i++){
    cout << i << endl;
    }
  }
}

Measured memory_bytes: 256
#include"stdio.h"
int main(void){
  int N,sum=0;
  scanf("%d",&N);
  int i,j, d[N];
  for(i=0; i<N;i++){
    scanf("%d",&d[i]);
  }
  for( i=0;i<N;i++){
    for( j=i+1;j<N; j++){
      sum+=d[i]*d[j];
    }
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 256
s=list(input())
k=int(input())

def toA(char):
    return (ord('z')-ord(char)+1)%26

def toC(char,k):
    if(ord('z')-ord(char)>=k%26):
        return chr(ord(char)+k%26)
    else:
        return chr(ord('a')+k-ord('z')-ord(char))
for i in range(len(s)):
    if(k==0):
        break
    if(k>=toA(s[i])):
        k-=toA(s[i])
        s[i]='a'
    if(i==len(s)-1) and k>0:
        s[i]= toC(s[i],k)
print("".join(s))


Measured memory_bytes: 4280
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(auto &t:a)cin>>t;return i;}
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T> void prArr(T a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

class CumulativeSum{
public:
  vector<int> sum;
  CumulativeSum(){}
  CumulativeSum(vector<int> A){
    int n = A.size();
    sum.resize(n+1,0);
    for(int i=1;i<=n;i++) sum[i] += (sum[i-1] + A[i-1])%mod;
  }
  
  int get(int l,int r){
    assert(l>=0 && r<=(int)sum.size());
    return (sum[r] - sum[l] + mod)%mod;
  } 
};

int n,C;
vector<int> A,B;
CumulativeSum sum[410];

int Add(int &a,int b){return a = (a%mod + b%mod + mod)%mod;}
int add(int a,int b){return (a%mod + b%mod + mod)%mod;}

int DP(){
  vector<vector<int> > dp(n+1,vector<int>(C+1));
  
  for(int c=0;c<=C;c++) dp[0][c] = sum[c].get(A[0],B[0]+1);
  for(int i=0;i<n-1;i++)
    for(int j=0;j<=C;j++)
      for(int c=0;c<=C;c++){
        if(j - c < 0) continue;
        int s = dp[i][j-c] * sum[c].get(A[i+1],B[i+1]+1) % mod;
        Add(dp[i+1][j],s);
      }
  
  return dp[n-1][C];
}

ll mod_pow(ll x,ll n){
  ll res=1;
  while(n){
    if(n%2) res=res*x%mod;
    x=x*x%mod;
    n/=2;
  }
  return res;
}


signed main(){
  cin>>n>>C;
  A.resize(n);
  B.resize(n);
  cin>>A>>B;
  vector<int> tmp[410];
  for(int i=0;i<=400;i++){
    tmp[i].resize(410,1);
    for(int j=0;j<=400;j++) tmp[i][j] = mod_pow(j,i);
  }
  for(int i=0;i<=400;i++) sum[i] = CumulativeSum(tmp[i]);
  cout<<DP()<<endl;
  
  return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
//#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//const ll MOD = 1000000007;
const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    ll n, a, b;
    cin >> n >> a >> b;
    ll m = a + b;
    ll ans = 0;
    ans += (n / m) * a;
    n %= m;
    ans += min(n, a);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)
#define min(a,b) (a>b?b:a)
#define max(a,b) (a>b?a:b)
#define yn(f) (f?"Yes":"No")
#define YN(f) (f?"YES":"NO")


signed main(){
	cout<<fixed<<setprecision(7);
	
	int a, b , k;
	
	cin>>a>>b>>k;
	
	for(int i = 1; i <= k; i++){//cout<<a<<" "<<b<<endl;
		if(i%2==1){
			if(a%2 == 1) a--;
			a /= 2;
			b += a;
		}else{
			if(b%2 == 1) b--;
			b /= 2;
			a += b;
		}
	}
	
	cout<<a<<" "<<b<<endl;
	
	
	
	return 0;
}

Measured memory_bytes: 256
s = str(input())
t = str(input())
ns = len(s)
nt = len(t)

ans = nt
for i in range(ns-nt+1):
    count=0
    for j in range(nt):
        if not s[i+j] == t[j]:
            count += 1
    ans = min(count,ans)

print(ans)


Measured memory_bytes: 67544