akhauriyash/Code-Regression huggingface dataset:
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {
	
	void solve() {
		long H = sc.nextLong();
		long W = sc.nextLong();
		
		long ans = min(solve2(H, W),
						solve2(W, H));
		out.println(ans);
	}
	
	final long INF = 1L << 58;
	long solve2(long H, long W) {
		long ans = INF;
		if (H >= 3) {
			long s = W * (H%3 > 0 ? 1 : 0);
			ans = min(ans, s);
		}
		
		for (int h = 1; h <= H / 2; h++) {
			long h1 = h;
			long h2 = H - h;
			long a1 = W * h1;
			long a2 = h2 * (W / 2);
			long a3 = h2 * (W/2 + W%2);
			long s = max(max(a1, a2), a3) - min(min(a1, a2), a3);
			ans = min(ans, s);
		}
		return ans;
	}
	
	static void tr(Object... os) { System.err.println(deepToString(os)); }
	static void tr(int[][] as) { for (int[] a : as) tr(a); }

	void print(int[] a) {
		out.print(a[0]);
		for (int i = 1; i < a.length; i++) out.print(" " + a[i]);
		out.println();
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}

	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;

		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		public String next() {
			eat();
			return tokenizer.nextToken();
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(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;
		}
	}
}

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

int main(){
  int N;  cin >> N;
  int count = 0;

  for(int i = 1;i <= N;i+=2){//割られる数
    int yakusuu = 0;
    for(int j = 1;j <= i;j+=2){//割る数,割られる数は奇数のみなので偶数を取らなくてよい.
      if(i % j == 0)yakusuu++;
    }
    if(yakusuu == 8)count++;
  }

  cout << count << endl;



}


Measured memory_bytes: 256
#![allow(dead_code, unused_imports, unused_variables)]

use proconio::*;

fn main() {
    input! {
        n: usize,
        d: i64,
        data: [(i64, i64); n],
    }
    let mut cnt: usize = 0;
    for (x, y) in data {
        if x * x + y * y <= d * d {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 7780
#include<stdio.h>
int main(void){
	int n,a,i;
	long long int max=-1000000,min=1000000,sum=0;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		if(min>=a){
			min=a;
		}
		if(max<=a){
			max=a;
		}
		sum+=a;
	}
	printf("%lld %lld %lld\n",min,max,sum);
	return 0;
}


Measured memory_bytes: 2148
require 'pp'

a, b, m = gets.split.map(&:to_i)
a_a = gets.split.map(&:to_i)
b_b = gets.split.map(&:to_i)
tickets = Array.new(m)
m.times do |i|
    x, y, c = gets.split.map(&:to_i)
    tickets[i] = [x, y, c]
end

min = 9999999999999
tickets.each do |x, y, c|
    sum = a_a[x - 1] + b_b[y - 1] - c
    if sum < min
        min = sum
    end
end

puts [
    a_a.sort![0] + b_b.sort![0],
    min
].min


Measured memory_bytes: 21100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

using pi = pair<int,int>;
using P = pair<int,pi>;

struct edge{int to,cost,time,company;};

const int V=100;
const int INF=123456789;

vector<edge> G[V];

int dp[300];
int d[100][25];

int main()
{
    int N,M,H,K;
    while(scanf(" %d %d %d %d", &N, &M, &H, &K),N)
    {
        rep(i,V) G[i].clear();

        rep(i,M)
        {
            int a,b,c,h,r;
            scanf(" %d %d %d %d %d", &a, &b, &c, &h, &r);
            --a;
            --b;
            --r;
            G[a].pb({b,c,h,r});
            G[b].pb({a,c,h,r});
        }

        int S,T;
        scanf(" %d %d", &S, &T);
        --S;
        --T;

        int PASS;
        scanf(" %d", &PASS);

        vector<int> pass_cost(PASS),mask(PASS);
        rep(i,PASS)
        {
            int l;
            scanf(" %d %d", &l, &pass_cost[i]);

            rep(j,l)
            {
                int k;
                scanf(" %d", &k);
                --k;

                mask[i] |= 1<<k;
            }
        }

        fill(dp,dp+300,INF);
        dp[0]=0;
        rep(i,1<<K)rep(j,PASS)
        {
            int nx = i|mask[j];
            dp[nx] = min(dp[nx],dp[i]+pass_cost[j]);
        }

        int ans=INF;
        rep(i,1<<K)
        {
            if(ans<dp[i]) continue;

            fill(d[0],d[100],INF);
            d[S][0]=0;

            priority_queue<P,vector<P>,greater<P>> pq;
            pq.push(P(0,pi(S,0)));
            while(!pq.empty())
            {
                P now = pq.top();
                pq.pop();

                int v = now.se.fi, h = now.se.se;
                if(now.fi>d[v][h]) continue;

                for(const auto &e:G[v])
                {
                    int nh = h+e.time;
                    if(nh>H) continue;

                    int COST = e.cost;
                    if(i>>e.company&1) COST = 0;

                    if(d[e.to][nh] > d[v][h]+COST)
                    {
                        d[e.to][nh] = d[v][h]+COST;
                        pq.push(P(d[e.to][nh],pi(e.to,nh)));
                    }
                }
            }

            rep(j,H+1) ans = min(ans,d[T][j]+dp[i]);
        }

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

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

main(){
	int a[4];
	for(int i=0;i<4;i++){
		cin >> a[i];
	}
	sort(a,a+4);
	if(a[0]==1 && a[1]==4 && a[2]==7 && a[3]==9 ){
		cout << "YES" <<endl;
	}else{
		cout << "NO" <<endl;
	}
}




Measured memory_bytes: 256
def main():
    k = int(input())

    def runrun(n):
        n = list(map(int, list(str(n))))
        for i in range(len(n)-1):
            if abs(n[i] - n[i+1]) > 1:
                if n[i] > n[i+1]:
                    n[i+1] = n[i]-1
                    for j in range(i+2, len(n)):
                        n[j] = 0
                else:
                    n[i] = n[i+1]-1
                    for j in range(i+1, len(n)):
                        n[j] = 0
                return int("".join(list(map(str, n))))
        return False

    run = []
    i = 1
    cnt = 0
    while cnt < k:
        j = runrun(i)
        if j:
            i = j
        else:
            run.append(i)
            cnt += 1
            i += 1
    print(run[k-1])


main()


Measured memory_bytes: 7228
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int i=0,j=0,c,n,m,a[100000],dp[100000],MOD=1000000007,b=0;
    dp[1]=1;
    dp[2]=2;
    cin >> n >> m;
    for(i=0;i<n;i++)
    {
        cin >> a[i];
        if(a[i]==1)
        {
            dp[1]=0;
            dp[2]=1;
            j=1;
            b++;
        }
        if(a[i]==2)
        {
            dp[2]=0;
            dp[1]=1;
            j=1;
            b++;
        }
    }
    if(b==2)
    {
        cout << '0' << endl;
        return 0;
    }
    a[m]=0;
    for(i=3;i<=n;i++)
    {
        if(a[j]==i)
        {
            dp[i]=0;
            j++;
        }
        else
        {
          dp[i]=(dp[i-1]+dp[i-2])%MOD;  
        }
    }
    cout << dp[n] << endl;
    return 0;

}


Measured memory_bytes: 4704
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    inf = 10 ** 9
    n, m = map(int, input().split())
    dp = [inf] * (1 << n)
    dp[0] = 0

    for _ in range(m):
        a, b = map(int, input().split())
        cc = list(map(int, input().split()))
        mask = 0
        for c in cc:
            mask += 1 << (c - 1)
        for i in range((1 << n) - 1, -1, -1):
            if dp[i] == inf: continue
            ni = i | mask
            if not 0 <= ni < (1 << n): continue
            dp[ni] = min(dp[ni], dp[i] + a)
#        print(dp)
    ans = dp[-1]
    if ans == inf:
        print(-1)
    else:
        print(ans)

main()


Measured memory_bytes: 3188
#include<iostream>
#include<array>
#include<map>
#include<algorithm>

using namespace std;

typedef array<int,5> A;

void rot(int &i,int s){
  if(i){
    i+=s;
    if(i>=5){
      i-=4;
    }
  }
}

int score(A a){
  int s=0;
  for(auto e:a){
    int t[]={0,0,60,70,80};
    s+=t[e];
  }
  return s;
}

int main(){
  int n;
  cin>>n;
  while(n--){
    array<A,5> g;
    for(int i=0;i<5;i++){
      for(int j=0;j<5;j++){
	cin>>g[i][j];
      }
    }
    map<A,int> m[5];
    m[0][g[0]]=0;
    for(int i=0;i<4;i++){
      for(auto e:m[i]){
	int a[4];
	for(a[0]=0;a[0]<4;a[0]++){
	  for(a[1]=0;a[1]<4;a[1]++){
	    for(a[2]=0;a[2]<4;a[2]++){
	      for(a[3]=0;a[3]<4;a[3]++){
		A u=e.first;
		A l=g[i+1];
		for(int j=0;j<4;j++){
		  rot(u[j],a[j]);
		  rot(u[j+1],a[j]);
		  rot(l[j],a[j]);
		  rot(l[j+1],a[j]);
		}
		auto d=m[i+1][l];
		m[i+1][l]=max(d,e.second+score(u));
	      }
	    }
	  }
	}
      }
    }
    int mx=0;
    for(auto e:m[4]){
      mx=max(mx,e.second+score(e.first));
    }
    cout<<mx<<endl;
  }
}

Measured memory_bytes: 1260
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine();
        int count = 0;
        int maxCount = 0;
        for (int i = 0; i < s.Length; i++)
        {
            if (s.ToCharArray()[i] == 'R')
            {
                count++;
                continue;
            }
            maxCount = Math.Max(maxCount, count);
            count = 0;
        }
        maxCount = Math.Max(maxCount, count);
        Console.WriteLine(maxCount);
    }
}


Measured memory_bytes: 25848
#include <bits/stdc++.h>
using namespace std;
#define show(x) cout << #x << " : " << x << endl
typedef long long ll;
int arr[100];
int main ()
{
    int n;
    cin >> n;
    for(int i = 1; i <= 9; i++)
    {
        for(int j = 1; j <= 9; j++)
        {
            int in = i * j;
            arr[in] = 1;
        }
    }
    if(arr[n] == 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}


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

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

    int ord[N], p[N];
    for(int i=0; i<N; i++) cin >> ord[i];
    for(int i=0; i<N; i++) cin >> p[i];

    int ex[N-1];
    for(int i=0; i<N-1; i++) cin >> ex[i];

    int ANS = 0;
    for(int i=0; i<N; i++){
        ANS += p[ord[i]-1];

        if(i!=N-1 && ord[i+1]-ord[i]==1){
            ANS += ex[ord[i]-1];
        }
    }

    cout << ANS << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long LL;

LL n;
int a[25];

int main()
{
	cin>>n;
	int tot=0;
	while (n) a[++tot]=n%10,n/=10;
	int ans=0,s=0;
	for (int i=tot;i>=1;i--)
	{
		if (a[i]) ans=max(ans,s+a[i]-1+(i-1)*9);
		s+=a[i];
	}
	ans=max(ans,s);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main()
{
	int A, B;
	cin >> A >> B;

	double tmp = abs(A - B) / 2.0;

	int tmp2 = tmp;
	if (tmp2 != tmp)
	{
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}

	int ans = abs(max(A, B) - tmp2);
	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 256
N,A,B= map(int,raw_input().split())
h=[input() for _ in range(N)]

high=max(h)/B+1
low=1

def enough(T):
	cnt=0
	for i in h:
		i-=T*B
		if i>0:
			if i%(A-B)==0:
				cnt+=i/(A-B)
			else:
				cnt+=i/(A-B)+1
	if cnt<=T:
		return True
	else:
		return False

ans=0
while low<=high:
	c= (low + high) / 2
	if enough(c):
		high=c-1
		ans=c
	else:
		low=c+1


print ans



Measured memory_bytes: 8964
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int A, B, C;
  
  std::cin >> A >> B >> C;

  std::cout << (A <= C && C <= B ? "Yes" : "No") << std::endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
BC = [list(map(int, input().split())) for _ in range(Q)]

cnt = {}
for i, Ai in enumerate(A):
    cnt.setdefault(str(Ai), 0)
    cnt[str(Ai)] += 1

ans = 0
for key, val in cnt.items():
    num = int(key)
    ans += num * val

for j, (Bj, Cj) in enumerate(BC):
    key_B = str(Bj)
    cnt.setdefault(key_B, 0)
    val_B = cnt[key_B]
    cnt[key_B] = 0
    ans -= Bj * val_B
    #
    key_C = str(Cj)
    cnt.setdefault(key_C, 0)
    cnt[key_C] += val_B
    ans += Cj * val_B
    #
    print(ans)

Measured memory_bytes: 45292
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	Scanner sc;
	
	public void run(){
		sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			calc(n);
		}
	}
	public void calc(int n){
		int count = 0;
		String b = null;
		String a = null;
		for(int i = 0; i < n ; i++){
			if(i % 2 == 0){
				b = sc.next();
			}
			else {
				a = sc.next();
				if(b.equals("lu") && a.equals("ru")) count++;
				else if(b.equals("ru") && a.equals("lu")) count++;
				else if(b.equals("ld") && a.equals("rd")) count++;
				else if(b.equals("rd") && a.equals("ld")) count++;
			}
		}
		System.out.println(count);
	}
	
	public static void main(String[] args){
		new Main().run();
	}
	
}

Measured memory_bytes: 37972
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
	int l, r;
  int ans = INT_MAX;
	cin >> l >> r;
	const int mod = 2019;
  
  if (r - l > mod){
    puts("0"); 
    return 0;
  }
  
  r %= mod;
  l %= mod;
	for(int i=l; i<=r; i++) {
	  for(int j=i+1; j<=r; j++) {
      ans = min(ans,i*j%mod);
    }
	}
  
  cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    ll x;
    in(x);
    ll ans=x/11;
    ans*=2;
    if(x%11<=6&&x%11>=1)ans++;
    else if(x%11>=7&&x%11<=10)ans+=2;
    out(ans);
}

Measured memory_bytes: 3820
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

ll dp[100005][2];

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

    int n;
    cin >> n;

    vector <ll> a(n, 0);
    for (int i = 0; i < n; i++) cin >> a[i];

    dp[1][0] = a[0];
    dp[1][1] = -a[0];
    for (int i = 1; i < n-1; i++) {
        dp[i+1][0] = max(dp[i][0] + a[i], dp[i][1] - a[i]);
        dp[i+1][1] = max(dp[i][1] + a[i], dp[i][0] - a[i]);
    }

    cout << max(dp[n-1][0] + a[n-1], dp[n-1][1] - a[n-1]) << "\n";
    return 0;
}

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

int main(){
	string str;
	cin >> str;
	int num[12];
	int x;
	int ans = -1;
	rep(i,str.size()){
		if(str[i] != '?')num[i] = str[i]-'0';
		else x = i;
	}
	rep(i,10){
		num[x] = i;
		int sum = 0;
		rep(j,11){
			if(j <= 4) sum += (11-j-5)*num[j];
			else sum += (11-j+1)*num[j];
		}
		sum %= 11;
		if(sum <= 1) sum = 0;
		else sum = 11-sum;
		if(sum == num[11]){
			if(ans == -1){
				ans = i;
			} else{
				cout << "MULTIPLE" << endl;
				return 0;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ass 1e18
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define debug(x) cout << #x << ": " << x << endl;
#define debug2(x,y) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<< endl;
#define debug3(x,y,z) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<<" "<<#z<<" : "<<z<< endl;
using namespace std;
typedef long long int ll;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll n,m,i,a,b,maxi,j;
double arr[3005],dp[3005][3005],sum;

int main()
{
	boost
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>arr[i];
	for(i=0;i<=3003;i++)
	{
		for(j=0;j<=3003;j++)
			dp[i][j]=0;
	}
	dp[1][0]=1-arr[1];
	dp[1][1]=arr[1];
	for(i=2;i<=n;i++)
	{
		for(j=0;j<=n;j++)
		{
			if(j!=0)
				dp[i][j]=dp[i-1][j]*(1-arr[i])+dp[i-1][j-1]*arr[i];
			else
				dp[i][0]=dp[i-1][0]*(1-arr[i]);
		}
	}	
	for(i=0;i<=n;i++)
	{
		if(i>n-i)
			sum+=dp[n][i];
	}
	cout<<fixed<<setprecision(9);
	cout<<sum;
	return 0;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

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

	int N; cin >> N;
	
	cout << "ABC" << N << endl;
	
	return 0;
}

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;


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

	string s;cin>>s;

	int ct=0;int ans =0;
	for(int i=0; i<s.length(); i++){

		if(s[i] =='A' || s[i] =='T' || s[i] =='C' || s[i] =='G' ){
			ct++;
		}else {
			ct =0;
		}

		ans = max(ct,ans);
	}

	writeln(ans);
}




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

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

  int digit = 0;
  while(N / K != 0){
    N /= K;
    digit += 1;
  }

  cout << digit + 1 << endl;
}

Measured memory_bytes: 3576
#pragma region header
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
const int MINF=-2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll kind(vi SYURUI) {//vector<int>型の配列の要素の種類数
    int size = SYURUI.size();
    sort(all(SYURUI));
    int cnt = 1;
    rep(i, size-1) {
        if (SYURUI[i] != SYURUI[i + 1])cnt++;
    }
    return cnt;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int A, B, C, D, K; cin >> A >> B >> C >> D >> K;
    cout << (60 * C + D) - (60 * A + B) - K << endl;
}






Measured memory_bytes: 3456
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
double distance(double x, double y, double z){
  return sqrt(x*x+y*y+z*z);
}

int main(){
  int N;
  while(cin>>N && N){
    double px[30], py[30], pz[30];
    REP(i, N) cin>>px[i]>>py[i]>>pz[i];
    double x = 50, y = 50, z = 50;
    double p = 0.5;
    REP(iter, 100){
      REP(iter2, 100){
        int idx = 0;
        REP(i, N){
          if(distance(px[idx]-x, py[idx]-y, pz[idx]-z) < distance(px[i]-x, py[i]-y, pz[i]-z)){
            idx = i;
          }
        }
        x += (px[idx] - x) * p;
        y += (py[idx] - y) * p;
        z += (pz[idx] - z) * p;
      }
      p *= 0.5;
    }
    double ans = 0;
    REP(i, N) ans = max(ans, distance(px[i]-x, py[i]-y, pz[i]-z));
    printf("%.6f\n", ans);
  }
  return 0;
}

Measured memory_bytes: 1248
#include <iostream>
#include <iomanip>
#include <array>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <numeric>
#include <cassert>
#include <functional>
using namespace std;

typedef unsigned long long int llui;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
constexpr double pi = 3.141592653589793238462643383279502884L;

// TODO: Mod class

const int sz = 1e5;

int main() {
  ios::sync_with_stdio(false);
  ll n, k;
  cin >> n >> k;
  ll ans = 0;

  for (ll p = k + 1; p <= n; ++p) {
    ll init = (n - k) / p + 1;
    ll j = p - k;
    ll rr = (n - k) % p + 1;
    ans += min(j, rr) * init;
    j -= min(j, rr);
    ll minus = (j + p - 1) / p;
    if (minus <= init) {
      ans += (j % p) * (init - minus);
    }
    j -= j % p;
    ll cc = j / p;
    cc = min(init, cc);
    ans += init * j - p * ((1 + cc) * cc) / 2;
  }
  if (k == 0) {
    ans -= n;
  }
  cout << ans << endl;
}


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

int q;
char s[3*N];

int main(){
    scanf("%s",s);
    scanf("%d",&q);
    int slen = strlen(s);
    int t, sMin=2*N, sMax=sMin+slen-1, reverse=0; 
    char f, c, sMod[5*N];

    strncpy(sMod+sMin, s, slen);
    for (int i = 0; i < q; i++){
        scanf("%d",&t);
        if(t==1){
            reverse = (reverse+1)&1;
        }
        else{
            scanf("%d %c", &f, &c);    //　型がごちゃごちゃ
            if(f==1){
            //先頭にc
                if(reverse==0){
                    sMin--;
                    sMod[sMin] = c;
                }
                else{
                    sMax++;
                    sMod[sMax] = c;
                }
            }
            else{
            //末尾にc
                if(reverse==0){
                    sMax++;
                    sMod[sMax] = c;
                }
                else{
                    sMin--;
                    sMod[sMin] = c;
                }
            }
        }
    }
    if(reverse==0){
        strncpy(s, sMod+sMin, sMax-sMin+1 );
    }
    else{
        int cnt = 0;
        for(int i = sMax; i>=sMin; i--){
            s[cnt] = sMod[i];
            cnt++;
        }
    }
    slen = strlen(s);
    s[slen] = '\0';
        
    printf("%s\n", s);
    return 0;
}


Measured memory_bytes: 2200
#include <cassert>
//PXjUXeZStdX
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
// #include <boost/foreach.hpp>
// #include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
//#define INF 1e9
#define LINF (1LL<<40)
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};
typedef pair<int,int> P;

const long long MOD=1000000007LL;
bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)||islower(c));}
template<typename T> 
void print(vector<T> v){
    for(int i=0;i<v.size();i++){
        if(i)cout<<" ";
        cout<<v[i];
    }
    cout<<endl;
}
int INF=1e18;

template<typename T>
void printendl(vector<T> v){
    for(auto date:v)cout<<date<<endl;
}

template<typename T>
void printvv(vector<vector<T>> v){
    for(int i=0;i<v.size();i++){
        for(int j=0;j<v[i].size();j++){
            if(j)cout<<" ";
            cout<<v[i][j];
        }
        cout<<endl;
    }
}
int gcd(int a,int b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    else return gcd(b,a%b);
}

struct Edge{
    int to,cost;
};

signed main (){
    int a,b;
    cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b))<<endl;
    
    
    


}
/*
6
12 32 45 76 33 89

*/



Measured memory_bytes: 256
S = input()
ok = True
while len(S) > 0:
    if S[0] == 'd':
        if len(S) >= 7 and S[:7] == 'dreamer':
            if len(S) == 7 or S[7] != 'a':
                S = S[7:]
            else:
                S = S[5:]
        elif S[:5] == 'dream':
            S = S[5:]
        else:
            ok = False
    elif S[0] == 'e':
        if len(S) >= 6 and S[:6] == 'eraser':
            if len(S) == 6 or S[6] != 'a':
                S = S[6:]
            else:
                S = S[5:]
        elif S[:5] == 'erase':
            S = S[5:]
        else:
            ok = False
    else:
        ok = False
    if not ok:
        print("NO")
        exit()
print("YES")



Measured memory_bytes: 3188
import sys
N = int(input())
T = []
for i in range(N):
    a = [i-1 for i in map(int,input().split())]
    T.append(a)

update = list(range(N))
ans = 0
L = [N-1]*N
while(True):
    K = []
    M = [0]*N
    for i in update:
        if L[i] != 0 and M[i] == 0:
            s = T[i][0]
            if L[s] != 0:
                if T[s][0] == i and M[s] == 0:
                    K.append(i)
                    K.append(s)
                    M[i] = 1
                    M[s] = 1
    for j in K:
        del T[j][0]
        L[j] -= 1
    if len(K) == 0:
        break
    ans += 1
    update = K

for i in range(N):
    if L[i] != 0:
        print(-1)
        sys.exit()
print(ans)

Measured memory_bytes: 63196
import sys
 
N,M = list(map(int,input().split()))	
A= list(map(int,input().split()))	
A.sort(reverse=True)
all_A=sum(A)

for i in range(M):
  #print(A[i]/all_A,1/(4*M))
  if not(A[i]/all_A >= 1/(4*M)):
    print("No")
    sys.exit( )
print("Yes")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
inline long long read () {
	long long num = 0;
	char c = ' ';
	bool flag = true;
	for (;c > '9' || c < '0';c = getchar())
		if (c == '-')
			flag = false;
	for (;c >= '0' && c <= '9';num = (num << 1) + (num << 3) + c - 48, c = getchar());
	return flag ? num : -num;
}
namespace graph {
	const int maxn = 100020;
	struct node {
		int y, next;
	} a[maxn << 1];
	int head[maxn], top = 0;
	void insert (int x, int y) {
		a[top].y = y;
		a[top].next = head[x];
		head[x] = top ++;
	}
} using namespace graph;

namespace INIT {
	map <long long, int> m;
	int n; long long d[maxn];
	void init () {
		n = read ();
		for (int i = 1;i <= n;i ++) {
			d[i] = read ();
			m[d[i]] = i;
		}
		sort (d + 1,d + 1 + n);
	}
} using namespace INIT;

namespace WORK {
	int size[maxn];
	void work () {
		memset (head, -1, sizeof head);
		for (int i = 1;i <= n;i ++)
			size[i] = 1;
		for (int i = n;i > 1;i --) {
			int x = m[d[i]];
			long long t = n - 2 * size[x];
			t = d[i] - t;
			/*if (m.count(t) == 0) {
				printf ("-1\n");
				exit (0);
			}*/
			int y = m[t];
			insert (y, x);
			insert (x, y);
			size[y] += size[x];
		}
	}
} using namespace WORK;

namespace CHECK {
	int dis[maxn];
	void dfs (int x, int fa) {
		for (int i = head[x];i + 1;i = a[i].next) {
			int y = a[i].y;
			if (y == fa) continue;
			dis[y] = dis[x] + 1;
			dfs (y, x);
		}
	}
	void check () {
		dfs (m[d[1]], -1);
		long long s = 0;
		for (int i = 1;i <= n;i ++)
			s += dis[i];
		if (s != d[1]) printf ("-1\n");
		else for (int i = 0;i < top;i += 2) 
				printf ("%d %d\n",a[i].y, a[i ^ 1].y);
	}
} using namespace CHECK;
int main () {
	init ();
	work ();
	check ();
	return 0;
}

Measured memory_bytes: 14080
N, M = gets.split.map(&:to_i)
c = Array.new(9) { Array.new(9, false) }
M.times do
  a, b = gets.split.map(&:to_i)
  c[a][b] = c[b][a] = true
end

p((2..N).to_a.permutation.count do |arr|
  ([1] + arr).each_cons(2).all? { |i,j| c[i][j] }
end)


Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int a,b,c,k;
 	cin >> a>>b>>c>>k;
 	ll aa[a],bb[b],cc[c];
 	for (int i = 0; i < a; i++){
 		cin >> aa[i];
 	}
 	for (int i = 0; i < b; i++){
 		cin >> bb[i];
 	}
 	for (int i = 0; i < c; i++){
 		cin >> cc[i];
 	}
 	sort(cc,cc+c);
 	ll ab[a*b];
 	for (int i = 0; i < a; i++){
 		for (int j = 0; j < b; j++)
 		ab[i*b+j]=aa[i]+bb[j];
 	}
 	sort(ab,ab+a*b);
 	ll abc[min(a*b,k)*(min(c,k))];
 	for (int i = 0; i < min(a*b,k); i++){
 		for (int j = 0; j < min(c,k); j++){
 			abc[i*(min(c,k))+j]=ab[a*b-i-1]+cc[c-j-1];
 		}
 	}
 	sort(abc,abc+(min(a*b,k))*(min(c,k)));
 	for (int i = 0; i < k; i++){
 		cout << abc[(min(c,k))*(min(a*b,k))-i-1] << endl;
 	}
 }

Measured memory_bytes: 31488
//https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2017/1216_arc087
#include<cstdio>
#include<cstring>
const int N=2e5+6;
typedef long long LL;
int ch[N][2],nod,n;LL L,g;
char s[N];
inline LL lbt(LL x){return x&-x;}
void dfs(int now,int dep){
    if(dep==L)return;
    if(ch[now][0])dfs(ch[now][0],dep+1);else g^=lbt(L-dep);
    if(ch[now][1])dfs(ch[now][1],dep+1);else g^=lbt(L-dep);
}
int main(){
    scanf("%d%lld",&n,&L);
    if(!n)return puts("Bob"),0;
    while(n--){
        scanf("%s",s);
        int nw=0;
        for(int i=0;s[i];++i){
            int c=s[i]-'0';
            if(!ch[nw][c])ch[nw][c]=++nod;
            nw=ch[nw][c];
        }
    }
    dfs(0,0);
    puts(g?"Alice":"Bob");
    return 0;
}

Measured memory_bytes: 2560
n, m = map(int, input().split())
A = [int(input()) for i in range(m)]
A = set(A)

mod = 10**9+7

dp = [0]*(n+2)
dp[0] = 1
for i in range(n):
    if i not in A:
        dp[i+1] += dp[i]
        dp[i+1] %= mod
        dp[i+2] += dp[i]
        dp[i+2] %= mod
print(dp[n]%mod)


Measured memory_bytes: 56664
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N,K=input_int()
P= many_int()

kitaiti = [0]
for p in P:
    kitaiti.append((p+1)/2 )



maxs = 0
temp = sum(kitaiti[:K])
for i in range(N-K+1):

    temp += kitaiti[i+K]
    temp -= kitaiti[i]

    if temp > maxs:
        maxs = temp


print(maxs)

Measured memory_bytes: 80392
#include<bits/stdc++.h>
#define F first
#define S second
#define mod 1000000007

using namespace std;
pair<int,int> arr[300000];
int main()
{
    int i,n;
    cin>>n;
    
    for(int i=0;i<n;i++){int a;cin>>a;arr[i]=make_pair(a,i);}
    
    sort(arr,arr+n);
    int ans[300000];
    
    int p1= n/2,p2=n/2-1;
    for(i=0;i<n;i++)
    {
        if(i<=p2)ans[arr[i].S]=arr[p1].F;
        if(i>=p1)ans[arr[i].S]=arr[p2].F;
    }
    for(i=0;i<n;i++)cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 4480
s = input()
t = input()
ans = 0
for i in range(len(s)-len(t)+1):
    ss = s[i:i+len(t)]
    tmp = 0
    for j in range(len(t)):
        if ss[j]==t[j]:
            tmp += 1
    ans = max(ans,tmp)
print(len(t)-ans)

Measured memory_bytes: 67560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans=0;
const ll mod=1e9+7;
ll ksm(ll a,ll n)
{
    a%=mod;
    ll ans=1,base=a;
    while(n)
    {
        if(n&1)
            ans=(ans*base)%mod;
        base=(base*base)%mod;
        n>>=1;
    }
    return ans%mod;
}
ll fa(int x)
{
    ll sum=1;
    for(int i=2;i<=x;i++)
        sum=(sum*i)%mod;
    return sum;
}
int main()
{
    int x,y;
    scanf("%d%d",&x,&y);
    int a=(2*y-x)/3;
    int b=(2*x-y)/3;
    if((x+y)%3==0&&x*2>=y&&y*2>=x)
        printf("%lld\n",fa(a+b)*ksm(fa(a)*fa(b),mod-2)%mod);
    else printf("0\n");
    return 0;
}


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

using namespace std;

int main()
{
  int a, b;
  cin >> a >> b;
  if(a <= 0 && 0 <= b) {
    cout << "Zero" << endl;
  } else if((a > 0 && b > 0) || (b - a) % 2 == 1) {
    cout << "Positive" << endl;
  } else {
    cout << "Negative" << endl;
  }
}

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

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

    cout << a*b/2<< endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
        int c = sc.nextInt();

		if(a>b){
            int t = a;
            a = b;
            b = t;
        }
        if(b>c){
            int x = c;
            c = b;
            b = x;
        }
        if(a>b){
            int y = a;
            a = b;
            b = y;
        }
        System.out.println(a+" "+b+" "+c);


	}
}


Measured memory_bytes: 26108
//<============ Author --> @venom ============>//
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fo(i,n)           for(int i=0;i<n;i++)
#define int               long long
#define pb                emplace_back
#define mp                make_pair
#define ff                first
#define ss                second
#define all(x)            x.begin(), x.end()
#define sortall(x)        sort(all(x))
#define sortrev(x)        sort(all(x), greater<int>())
#define w(x)              int x; cin>>x; while(x--)
#define trunc(x,y)        fixed<<setprecision(y)<<x
#define mk(arr, n, type)  type *arr=new type[n];
#define PI                3.1415926535897932384626
#define mod               1000000007
#define inf               1e9 + 5
#define FIO               ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef pair<int, int>    pi;
typedef vector<int>       vi;
typedef vector<pi>        vpi;
typedef vector<vi>        vvi;
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update> indexed_set;
const int N = 3e5, M = 3000;
int mpow(int base, int exp);
int gcd(int a, int b) {if (a == 0) return b; return gcd(b % a, a);}
//<----------------------------------------------------------------------------->//
void fastIO()
{
  FIO;
#ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
#endif
}

int dp[M + 1][M + 1];

string getLCS(string& s, string& t, int len)
{
  string lcs;
  int i = 0, j = 0;

  while (len > 0)
  {
    if (s[i] == t[j])
    {
      lcs.push_back(s[i]);
      i++;
      j++;
      len--;
    }

    else
    {
      if (dp[i][j + 1] > dp[i + 1][j])
        j++;

      else
        i++;
    }
  }

  return lcs;
}

int lenLCS(string& s, string& t, int i, int j)
{
  if (i >= s.length() || j >= t.length())
    return 0;

  if (dp[i][j] != -1)
    return dp[i][j];

  if (s[i] == t[j])
    return dp[i][j] = 1 + lenLCS(s, t, i + 1, j + 1);

  else
  {
    return dp[i][j] = max(lenLCS(s, t, i, j + 1), lenLCS(s, t, i + 1, j));
  }
}

string solve(string s, string t)
{
  memset(dp, -1, sizeof dp);
  int len = lenLCS(s, t, 0, 0);

  return getLCS(s, t, len);
}

int32_t main()
{
  FIO;

  string s, t;
  cin >> s >> t;

  cout << solve(s, t);

  return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((int)result * base) % mod;
    base = ((int)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

Measured memory_bytes: 70912
/*
Author:		CraZYali
LANG: 		C++
FileName:	.cpp

CopyRIGHT!!!
*/

#define REP(i, s, e) for(register int i = s; i <= e ;i++)

#include <bits/stdc++.h>

using namespace std;
const int maxn = 100010;
bool a[maxn];
int n;

int main() {
	cin >> n;
	while(n--) {
		int l, r;
		scanf("%d%d",&l, &r);
		REP(i, l, r) a[i] = 1;
	}
	int ans = 0;
	REP(i, 1, maxn - 10) ans += a[i];
	cout << ans;
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        long n = long.Parse(Console.ReadLine());
        HashSet<string> a = new HashSet<string> { };
        for(long i = 0; i < n; i++)
        {
            string n1 = Console.ReadLine();
            if (a.Add(n1)) { a.Add(n1); }
            else { a.Remove(n1); }
        }
        List<string> s = a.ToList();
        Console.WriteLine(s.Count());
        Console.ReadLine();
    }

    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b)
    {
        return a / gcd(a, b) * b;
    }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;

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

}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] longs()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
    public static int Int()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] ints()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 27356
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);
 
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;
 
constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;
 
template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
	long double a,b,c; cin >> a >> b >> c;
	Yn(a+b+2*sqrtl(a*b)<c);
	
    return 0;
}


Measured memory_bytes: 256
import itertools
S=input()
N=len(S)

ans=[0]*N
cnt_R=0
index_R=0
cnt_L=0
index_L=0
flag=0
for i in range(N):
  if S[i]=='R' and flag==0:
    cnt_R+=1
  elif S[i]=='L' and flag==0:
    cnt_L+=1
    index_R=i-1
    index_L=i
    flag=1
  elif S[i]=='L' and flag==1:
    cnt_L+=1
  else:
    if (max(cnt_R,cnt_L)-1)%2==0:
      if cnt_R>=cnt_L:
        if (cnt_R+cnt_L)%2==0:
          ans[index_R]=(cnt_R+cnt_L)//2
          ans[index_L]=(cnt_R+cnt_L)//2
        else:
          ans[index_R]=(cnt_R+cnt_L)//2+1
          ans[index_L]=(cnt_R+cnt_L)//2
      else:
        if (cnt_R+cnt_L)%2==0:
          ans[index_R]=(cnt_R+cnt_L)//2
          ans[index_L]=(cnt_R+cnt_L)//2
        else:
          ans[index_R]=(cnt_R+cnt_L)//2
          ans[index_L]=(cnt_R+cnt_L)//2+1        
    else:
      if cnt_R>=cnt_L:
        if (cnt_R+cnt_L)%2==0:
          ans[index_L]=(cnt_R+cnt_L)//2
          ans[index_R]=(cnt_R+cnt_L)//2
        else:
          ans[index_L]=(cnt_R+cnt_L)//2+1
          ans[index_R]=(cnt_R+cnt_L)//2
      else:
        if (cnt_R+cnt_L)%2==0:
          ans[index_L]=(cnt_R+cnt_L)//2
          ans[index_R]=(cnt_R+cnt_L)//2
        else:
          ans[index_L]=(cnt_R+cnt_L)//2
          ans[index_R]=(cnt_R+cnt_L)//2+1
    flag=0
    cnt_R=1
    cnt_L=0
if (max(cnt_R,cnt_L)-1)%2==0:
  if cnt_R>=cnt_L:
    if (cnt_R+cnt_L)%2==0:
      ans[index_R]=(cnt_R+cnt_L)//2
      ans[index_L]=(cnt_R+cnt_L)//2
    else:
      ans[index_R]=(cnt_R+cnt_L)//2+1
      ans[index_L]=(cnt_R+cnt_L)//2
  else:
    if (cnt_R+cnt_L)%2==0:
      ans[index_R]=(cnt_R+cnt_L)//2
      ans[index_L]=(cnt_R+cnt_L)//2
    else:
      ans[index_R]=(cnt_R+cnt_L)//2
      ans[index_L]=(cnt_R+cnt_L)//2+1        
else:
  if cnt_R>=cnt_L:
    if (cnt_R+cnt_L)%2==0:
      ans[index_L]=(cnt_R+cnt_L)//2
      ans[index_R]=(cnt_R+cnt_L)//2
    else:
      ans[index_L]=(cnt_R+cnt_L)//2+1
      ans[index_R]=(cnt_R+cnt_L)//2
  else:
    if (cnt_R+cnt_L)%2==0:
      ans[index_L]=(cnt_R+cnt_L)//2
      ans[index_R]=(cnt_R+cnt_L)//2
    else:
      ans[index_L]=(cnt_R+cnt_L)//2
      ans[index_R]=(cnt_R+cnt_L)//2+1
print(*ans)

Measured memory_bytes: 6760