akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
int hako[100100];
int res[100100];
int main(){
  fill(hako,hako+100100,1);
  string s;
  cin >> s;
  int n = s.length();
  int pos = -1;
  rep(i,0,n){
    if(s[i] == 'R'){
      pos = 0;
    }else{
      hako[i] = pos;
    }
      pos++;
  }
  for(int i=n-1;i>=0;i--){
    if(s[i] == 'L'){
      pos = 0;
    }else{
      hako[i] = pos;
    }
      pos++;
  }
  rep(i,0,n){
   if(s[i] == 'R'){
    if(hako[i]%2==0){
      res[i+hako[i]]++;
    }else{
      res[i+hako[i]-1]++;
    }
   }else{
    if(hako[i]%2==0){
      res[i-hako[i]]++;
    }else{
      res[i-hako[i]+1]++;
    }
   }
  }
  rep(i,0,n){
    cout << res[i] << " ";
  }
  cout << endl;
	return 0;
}


Measured memory_bytes: 1408
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        if(S.equals("AAA") || S.equals("BBB")){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 21588
#include <iostream>
using namespace std;
int main()
{
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	if(n*a>=b)
	{
		printf("%d\n",b);
	}
	else
	{
		printf("%d\n",n*a);
	}
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,M,X=map(int,input().split())
    C=[]
    for i in range(N):
        C.append(list(map(int,input().split())))
    ans=INF
    for i in range(2**N):
        l=[0]*M
        c=0
        for j in range(N):
            if (i>>j)&1:
                c+=C[j][0]
                for k in range(M):
                    l[k]+=C[j][k+1]
        if min(l)>=X:
            ans=min(ans,c)
    if ans==INF:
        print(-1)
    else:
        print(ans)
        
if __name__ == '__main__':
    main()


Measured memory_bytes: 68712
#include<cstdio>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define ck(a) (0<=a&&a<n)
using namespace std;
int main(){
	int n,x,y,c=0;
	while(scanf("%d",&n),n){
		int ans[n][n],t=0;
		rep(s,2*n-1)for(s&1?x=min(n-1,s),y=max(s-x,0):(y=min(n-1,s),x=max(s-y,0));
			ck(x)&&ck(y);s&1?y++,x--:(x++,y--))ans[x][y]=++t;
		printf("Case %d:\n",++c);
		rep(i,n){
			rep(j,n)printf("%3d",ans[j][i]);printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();

        if (a.equals(b)) {
            System.out.println("H");
        } else {
            System.out.println("D");
        }
    }

}

Measured memory_bytes: 21844
import numpy as np

N, M = map(int, input().split())

ar = np.zeros((8,N), dtype=int)

for n in range(N):
  x,y,z = map(int, input().split())
  ar[0][n] = + x + y + z
  ar[1][n] = - x + y + z
  ar[2][n] = + x - y + z
  ar[3][n] = - x - y + z
  ar[4][n] = + x + y - z
  ar[5][n] = - x + y - z
  ar[6][n] = + x - y - z
  ar[7][n] = - x - y - z

for i in range(8):
  ar[i] = np.sort(ar[i])[::-1]


print(max([ar[i][:M].sum() for i in range(8)]))


Measured memory_bytes: 21796
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
k=int(input())
count=0
count+=k*(k+1)//2
for i in range(1,k+1):
  for j in range(1,k+1):
    if i!=j:
      count+=3*gcd(i,j)
for a in range(1,k+1):
  for b in range(a+1,k+1):
    for c in range(b+1,k+1):
      count+=6*gcd(gcd(a,b),c)
print(count)

Measured memory_bytes: 9204
N, M = map(int,input().split())
AC_list = [0 for _ in range(N)]
WA_list = [0 for _ in range(N)]


for i in range(M):
    # print(AC_list)
    # print(WA_list)
    p, S = map(str,input().split())
    p = int(p)-1
    if S == "AC" and AC_list[p] == 0:
        AC_list[p] = 1
    elif S == "WA" and AC_list[p] == 0:
        WA_list[p] +=1
    else:
        continue

for i in range(N):
    if AC_list[i] == 0:
        WA_list[i] = 0

print("{} {}".format(sum(AC_list), sum(WA_list)))

Measured memory_bytes: 85080
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int x = in.nextInt();
    int y = in.nextInt();
    int z = in.nextInt();
    
    if (x < y && y < z) {
        System.out.println("Yes");
    } else {
        System.out.println("No");
        }
    }
}

Measured memory_bytes: 26008
package main

import (
	"fmt"
)

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	x := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x[i])
	}
	result := 100000000000
	for i := 0; i < n-k+1; i++ {
		d := x[i+k-1] - x[i]
		m := min(abs(x[i+k-1]), abs(x[i]))
		r := d + m
		result = min(r, result)
	}
	fmt.Println(result)
}


Measured memory_bytes: 5504
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int n;
int deg[100];
int ans = 0;

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        int p = i;
        for (int j = 2; j <= p; j++)
        {
            while (p % j == 0)
            {
                p /= j;
                deg[j]++;
            }
        }
    }

    for (int i = 0; i < 100; i++)
    {
        for (int j = i + 1; j < 100; j++)
        {
            for (int k = 0; k < 100; k++)
            {
                if (i == j || j == k || i == k) continue;
                if (deg[i] >= 4 && deg[j] >= 4 && deg[k] >= 2) ans++;
            }
        }
    }

    for (int i = 0; i < 100; i++)
    {
        if (deg[i] >= 74) ans++;
    }

    for (int i = 0; i < 100; i++)
    {
        for (int j = 0; j < 100; j++)
        {
            if (i == j) continue;
            if (deg[i] >= 24 && deg[j] >= 2) ans++;
            if (deg[i] >= 14 && deg[j] >= 4) ans++;
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
n = int(input())
list_a = list(map(int, input().split()))
sum_a = sum(list_a)
list_dif = []
last_sum = 0
for a in list_a[:-1]:
  list_dif.append(abs(sum_a - 2 * (last_sum + a)))
  last_sum += a
print(min(list_dif))

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

int main()
{
    long long N, K, ans = 0;
    cin >> N >> K;
    vector<int> H(N);

    for (int i = 0; i < N; i++)
    {
        cin >> H.at(i);
    }

    if (K >= N)
    {
        cout << 0 << endl;
        exit(0);
    }

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

    for (int i = K; i < N; i++)
    {
        ans += H.at(i);
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<string,int>> vpsi;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;



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

int n;//税込み価格   n = floor(x * 1.08) が成立するか否か
cin >> n;
rep(i,n+1){//i=x x=n???
    if(floor(i*1.08)==n){//n = floor(x * 1.08)が成立したらxを出力
        fin(i);
        return 0;
    }
}//nまで検証して該当なければ :( を出力
fin(":(");
// n <= floor(n * 1.08)

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String args[])
    {
	Scanner sc = new Scanner(System.in);

	int n = sc.nextInt();
	int mn = 1000000000;
	
	for(int i = 0; i < n; i++) {
	    
	    int a = sc.nextInt();

	    int cnt = 0;
	    while(a % 2 == 0) {
		cnt++;
		a /= 2;
	    }

	    mn = Math.min(mn, cnt);
	}
	
	System.out.println(mn);
    }
    
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef long int li;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<ll, ll>P;
typedef tuple<ll,int,int,int,int,int,int,int>T;
#define PI 3.14159265358979
const int MAX = 510000;
const int MOD = 1000000007;

void chmax(string &a, string b) {
    if (a == "-") a = b;
    else if (a.size() < b.size()) a = b;
    else if (a.size() == b.size()) {
        if (a < b) a = b;
    }
}
int main(){
  ll N,M;
  cin>>N>>M;
  vector<ll>A(M);
  int use[10]={0,2,5,5,4,5,6,3,7,6};
  rep(i,M){
  	cin>>A[i];
  } 
  string dp[11000];
  rep(i,11000){dp[i]="-";}
  dp[0]="";
  for(int i=0;i<=N;i++){
    if(dp[i]=="-"){continue;}
  	for(auto a:A){
      chmax(dp[i+use[a]], dp[i] + (char)('0' + a));
    }
  }
  cout<<dp[N];
} 


Measured memory_bytes: 45056
// D - Knight
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define MOD 1000000007
#define MAX 700000

ll fac[MAX]; // 累乗 n!
ll inv[MAX]; // 逆元 1/n
ll finv[MAX]; // 逆元の累乗 (n^-1)! = (1/n)!

void init(int n, int p){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	rp(i, 2, n+1){
		fac[i] = fac[i-1] * i % p;
		inv[i] = p - inv[p%i] * (p/i) % p;
		finv[i] = finv[i-1] * inv[i] % p;
	}
}

ll comb(int n, int r, int m){
	if(n<r || n<0 || r<0) return 0;
	return fac[n] * (finv[n-r] * finv[r] % m) % m;
}

int main(){
	int X,Y; cin>>X>>Y;
	int r = (2*X-Y)/3, n = (2*Y-X)/3 + r;
	if((X+Y)%3 || n<0 || r<0){puts("0"); return 0;}
	else{
		init(n+1, MOD);
		cout<< comb(n, r, MOD) % MOD << endl;
	}
}

Measured memory_bytes: 16640
#include<iostream>
#include<queue>
#include<limits.h>
using namespace std;
typedef long long ll;
struct node{
	ll from,to,len;
};
node e[400005];
int tot,l[400005],r[400005],d[400005],n,m;
ll dis[400005],maxn,minn,inf=INT_MAX,head[400005];
bool inqueue[400005],vis[400005];
queue <int> q;
void operate()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	dis[i]=inf;
}
ll max(ll a,ll b)
{
	return a>b?a:b;
}
ll min(ll a,ll b)
{
	return a<b?a:b;
}
void add(int f,int t,int l)
{
	e[++tot].from=head[f];
	e[tot].to=t;
	e[tot].len=l;
	head[f]=tot;
}
bool spfa(int st)
{
	q.push(st);
	inqueue[st]=1;
	dis[st]=0;
	maxn=-1;
	minn=1;
	while(!q.empty())
	{
		int u=q.front();
		q.pop();
		inqueue[u]=0;
		for(int i=head[u];i;i=e[i].from)
		{
			int v=e[i].to;
			if(dis[v]==inf)
			{
				dis[v]=e[i].len+dis[u];
				maxn=max(maxn,dis[v]);
				minn=min(minn,dis[v]);
				if(maxn-minn>1e9) return false;
				vis[v]=1;
				if(!inqueue[v])
				q.push(v);
			}
			else if(dis[v]!=dis[u]+e[i].len) return false;
		}
	}
	return true;
}
void ready()
{
	for(int i=1;i<=m;i++)
	{
		cin>>l[i]>>r[i]>>d[i];
		add(l[i],r[i],d[i]);
		add(r[i],l[i],-d[i]);
	}
}
void judge()
{
	bool ok;
	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
		{
			ok=spfa(i);
			vis[i]=1;
			if(!ok)
			{
				cout<<"No"<<endl;
				return ;
			}
		}
	}
	cout<<"Yes"<<endl;
	return ;
}
int main()
{
	operate();
    ready();
    judge();
    return 0;
}

Measured memory_bytes: 20736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
	ll n;
  cin >> n;
ll ans = n-1;
  for (ll i = 2; i*i <= n; i++)
  {
    if (n % i == 0)
    {
		ll j = n/i;
      ans = min(ans, j+i-2);
    }
  }
  cout << ans << endl;
}

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

#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define mp12            make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pq1             priority_queue<int>
#define pqr1            priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)

void FIO(){
    #ifndef SHAILESH
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int modInv(int a,int b,int m){int res=1;a=a%m;while(b>0){if(b&1){res=(res*a)%m;}a=(a*a)%m;b=b>>1;}return res;}


void solve(){
    int n;
    cin>>n;
    int a[n];
    int dp[n+1];
    for(int i=0;i<n;i++) cin>>a[i];
    dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++){
		int op1=dp[i-1]+abs(a[i]-a[i-1]);
		int op2=dp[i-2]+abs(a[i]-a[i-2]);
		dp[i]=min(op1,op2);
	}
	cout<<dp[n-1];
}

int32_t main()
{
   // FIO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    solve();


    return 0;
}

Measured memory_bytes: 5152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
#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>
LL facctorialMethod(int k);
int main(){
    LL a,b,ans;
    cin >> a >> b;
    if(a < b) {
        swap(a, b);
    }
    ans = b;
//    cout << "ans :" << ans << endl;
    for(int i = 1; i <a; i++) {
        ans = (ans*10 + b); 
//    cout << "ans :" << ans << endl;        
    }
    cout << ans << endl;

    return 0;
}

LL facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i){
        sum *= i;
    }
    return sum;
}


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  llvec nums;
  llvec tmp;
  cin >> N;
  /*
  rep(i, N){
    tmp.push_back(i*i);
  }
  DUMP(i, tmp);
  auto it = lower_bound(ALL(tmp), 0);
  //tmp.erase(it);
  tmp.insert(it, 5);
  DUMP(i, tmp);
  */
  rep(i, N){
    ll a;
    cin >> a;
    if(nums.empty()){
      nums.push_back(a);
    }else{
      auto iter = lower_bound(ALL(nums), a);
      if(iter==nums.begin()){
        nums.insert(iter, a);
      }else{
        iter--;
        *iter = a;
      }
    }
  }
  //DUMP(i, nums);
  //cout << endl;
  cout << nums.size();
  
  return 0;
}


Measured memory_bytes: 1400
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Scanner;
 
public class Main {
 
	public static final MyScanner in = new MyScanner();
 
	public static void main(String[] args) {
 
		String S = in.next();
		int Q = in.nextInt();
		LinkedList<Character> pre = new LinkedList<>();
		LinkedList<Character> suf = new LinkedList<>();
		boolean reverse = false;
		for(int i=0; i<Q; i++) {
			int T = in.nextInt();
			if(T == 1) {
				reverse = !reverse;
				continue;
			}

			int F = in.nextInt();
			if (!reverse) {
				if(F == 1) {
					pre.addFirst(in.next().charAt(0));
				}else {
					suf.addLast(in.next().charAt(0));
				}
			}else {
				if(F == 1) {
					suf.addLast(in.next().charAt(0));
				}else {
					pre.addFirst(in.next().charAt(0));
				}
			}
		}

		StringBuffer answer = new StringBuffer();
		if (!reverse) {
			for(char c: pre) answer.append(c);
			answer.append(S);
			for(char c: suf) answer.append(c);
		}else {
			for(ListIterator<Character> it=suf.listIterator(suf.size()); it.hasPrevious();) answer.append(it.previous());
			char[] cs = S.toCharArray();
			for(int i=S.length()-1;i >= 0; i--) {
				answer.append(cs[i]);
			}
			for(ListIterator<Character> it=pre.listIterator(pre.size()); it.hasPrevious();) answer.append(it.previous());
		}

		System.out.println(answer.toString());
	}

	public static class MyScanner{
		Scanner sc = new Scanner(System.in);
		String nextLine() {return sc.nextLine();}
		String next() {return sc.next();}
		int nextInt() {return Integer.valueOf(sc.next());}
		long nextLong() { return Long.valueOf(sc.next());}
	}

}

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

#define ll long long
#define MAX 300005
#define pp pair<int,pair<int,pair<int,int>>>
#define pb push_back
#define mod 1000000007

using namespace std;

/*
 * author: Kruti_20
 */

ll power(ll x, ll y);

ll gcd(ll a, ll b);

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    double a[n];
    double sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] = 1.0 / a[i];
        sum += a[i];
    }
    cout << fixed << setprecision(5) << 1.0 / sum;


    return 0;
}

ll power(ll x, ll y) {
    ll res = 1;
    x = x % mod;
    while (y > 0) {
        if (y & 1) res = (res * x) % mod;
        y = y >> 1;
        x = (x * x) % mod;
    }
    return res;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e12 + 7;

vi u, v;

int32_t main()
{
	IO_OP;
	
	int a, b, q;
	cin >> a >> b >> q;
	for(int i=0;i<a;i++) {
		int t;
		cin >> t;
		u.PB(t);
	}
	for(int i=0;i<b;i++) {
		int t;
		cin >> t;
		v.PB(t);
	}
	v.PB(INF), v.PB(-INF);
	u.PB(INF), u.PB(-INF);
	sort(u.begin(), u.end());
	sort(v.begin(), v.end());
	while(q--) {
		int x;
		cin >> x;
		int i = lower_bound(u.begin(), u.end(), x) - u.begin();
		int j = lower_bound(v.begin(), v.end(), x) - v.begin();
		int k = upper_bound(u.begin(), u.end(), x) - u.begin() - 1;
		int l = upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
		int ans1 = max(u[i], v[j]) - x;
		int ans2 = x - min(u[k], v[l]);
		int ans3 = x - u[k] + v[j] - u[k];
		int ans4 = x - v[l] + u[i] - v[l];
		int ans5 = u[i] - x + u[i] - v[l];
		int ans6 = v[j] - x + v[j] - u[k];
		cout << min(min(min(ans1, ans2), min(ans3, ans4)), min(ans5, ans6)) << endl;
	}
}



Measured memory_bytes: 3060
#include <stdio.h>

int main() {
    char vetor[10];
	scanf("%s", vetor);
	if(vetor[0]=='S'){
	    printf("Cloudy\n");
	}
	else if(vetor[0]=='C'){
	    printf("Rainy\n");
	}    
	else{
	    printf("Sunny\n");
	}    
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int X,T,Y; cin>>Y>>X>>T;
    cout<<((Y-1)/X + 1)*T<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int main() {
	int i, N, L, sum = 0, min = 999;
	bool flag = false;

	scanf("%d %d", &N, &L);

	for (i = 1; i <= N; i++) {
		if (abs(L + i - 1) <= min) {
			if (L + i - 1 >= 0) {
				min = L + i - 1;
				flag = false;
			}
			else {
				min = abs(L + i - 1);
				flag = true;
			}
		}
		sum = sum + (L + i - 1);
	}

	printf("%d\n", flag == false ? sum - min : sum + min);

	return 0;
}

Measured memory_bytes: 128
def Output(A):
    print(' '.join(list(map(str, A))))

def main():
    N = int(input())
    A = list(map(int, input().split()))
    for i in range(1, N):
        Output(A)
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
    Output(A)

if __name__ == '__main__':
    main()



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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
  int n;
  cin>>n;
  double sum=0;
  vector<double> x(n);
  vector<string> u(n);
  r(i,n){
    cin>>x.at(i)>>u.at(i);
    if(u.at(i)=="BTC"){
        x.at(i)=x.at(i)*380000;
    }
    sum+=x.at(i);
  }

  cout<<sum<<endl;


return 0;}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
using namespace std;

int main(void) {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {   
        char s;
        cin >> s;
        if (s == 'Y') {
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
template<typename T>
map<T,ll> factorize(T x){
	map<T,ll> res;
	for(ll i=2;i*i<=x;i++){
		while(x%i==0){
			x/=i;
			res[i]++;
		}
	}
	if(x!=1) res[x]++;
	return res;
}
int main(){
  ll n;
  cin>>n;
  map<ll,ll> d=factorize(n);
  ll ans=0;
  for(auto p:d){
    ll now=p.fi;
    while(n&&n%now==0){
        ans++;
        n/=now;
        now*=p.fi;
    }
  }
  cout<<ans<<"\n";
}


Measured memory_bytes: 3656
#!/usr/bin/env python
# -*- coding: utf-8 -*-


"""
input:
1 2 1
4 2 2

output:
3
"""

import sys
from collections import namedtuple


class CircleIntersections(object):
    def __init__(self, ):
        _input = sys.stdin.readlines()
        x1, y1, r1 = map(int, _input[0].split())
        x2, y2, r2 = map(int, _input[1].split())

        Circle = namedtuple('Circle', ('centre', 'radius'))
        self.c1 = Circle(centre=x1 + y1 * 1j, radius=r1)
        self.c2 = Circle(centre=x2 + y2 * 1j, radius=r2)

    def calc_intersection(self):
        c_distance = abs(self.c2.centre - self.c1.centre)
        r1, r2 = self.c1.radius, self.c2.radius

        if c_distance > r1 + r2:
            return 4
        elif c_distance == r1 + r2:
            return 3
        elif abs(r1 - r2) < c_distance < r1 + r2:
            return 2
        elif c_distance == abs(r1 - r2):
            return 1
        else:
            return 0


if __name__ == '__main__':
    case = CircleIntersections()
    print(case.calc_intersection())

Measured memory_bytes: 8168
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_pair tree<pair<int,int>,null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_mutiset tree<int,null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> pi; 
#define PI 3.1415926535897932384
#define FOR(i,vv,n) for(ll i=vv;i<n;i++)
#define FORR(i,n,vv) for(ll i=n-1;i>=vv;i--)
#define ve vector 
#define maxind(v) (max_element(v.begin(),v.end())-v.begin())
#define minind(v) (min_element(v.begin(),v.end())-v.begin())
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007ll
#define INF 1000000000000000000ll
#define PRECISE cout.precision(18);
#define all(v) v.begin(),v.end()
#define BS(v,n) binary_search(all(v),n)
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(all(v),greater <ll>())
#define uni(v) v.resize(unique(all(v))-v.begin())
#define F first
#define S second
#define GET(i,p) get<p>(i)


ll bexp(ll a,ll b,ll m){
if(a==0)
	return 1%m;
ll ans=1;
ll d1=a%m;
while(b>0){
	if(b%2==0){
		d1=(d1*d1)%m;
		b/=2;
	}
	else{
		ans=(ans*d1)%m;
		b-=1;
	}
}
return ans;
}

int main(){

	#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

    FAST
	//PRECISE


ll n;
cin>>n;
ll ans=bexp(10,n,M)+bexp(8,n,M);
ans%=M;
ans=ans-bexp(9,n,M)*2;
ans=(ans+M*2)%M;
cout<<ans;

return 0;
 }



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

int main() {
	int n;
	cin>>n;
	int b[n-1];
	int a[n];
	for(int i=0;i<n-1;i++)
	{
		cin>>b[i];
	}
	int b_size=n-1;
	a[n-1]=b[b_size-1];
	for(int i=b_size-2;i>=0;i--)
	{
		if(b[i]>b[i+1])
		{
			a[i+1]=b[i+1];
		}
		else
		{
			a[i+1]=b[i];
		}
	}
	a[0]=b[0];
	long ans=0;
	for(int i=0;i<n;i++)
	   {
	   	 //cout<<a[i]<<" ";
	   	 ans+=a[i];
	   }
	   cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
const int INF=1e9;
//const int MOD=998244353;
const long long LINF=1e18;
#define int long long
//template
int dp[10][700];
//main
signed main(){
  int K;cin>>K;
  dp[0][0]++;
  for(int k=1;k<=600;k++)for(int i=1;i<=8;i++)for(int j=0;j<=i;j++)dp[i][k]+=dp[j][k-1];
  string s="FESTIVA";
  reverse(s.begin(),s.end());
  string ans;
  for(int k=600;k>0;k--){
    int a=K/dp[8][k];ans+=string(a,'L');
    K-=dp[8][k]*a;
    ans+=s;
  }
  reverse(ans.begin(),ans.end());
  cout<<ans<<endl;
}

/*
解説AC
大きい方から順番に決めるそれだろうとは思ったけどいい構成方法が思い浮かばず
600って数字そのまま使ったのはよくないね、しっかり自分で計算くらいはしてみないと
とりあえず適当にだんだん大きくなる数字作ってLを間に入れていけばいいって認識でいいんだろうか
*/


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int s = scanner.nextInt() - 1;
        int t = scanner.nextInt() - 1;
        List<Grid>[] yen = new ArrayList[n];
        List<Grid>[] snuuk = new ArrayList[n];
        for (int i = 0; i < n; i++) {
            yen[i] = new ArrayList<>();
            snuuk[i] = new ArrayList<>();
        }

        for (int i = 0; i < m; i++) {
            int u = scanner.nextInt() - 1;
            int v = scanner.nextInt() - 1;
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            yen[u].add(new Grid(v, a));
            yen[v].add(new Grid(u, a));
            snuuk[u].add(new Grid(v, b));
            snuuk[v].add(new Grid(u, b));
        }

        long[] dist1 = dijkstra(yen, s);
        long[] dist2 = dijkstra(snuuk, t);
        long[] ans = new long[n];

        for (int i = n - 1; i >= 0; i--) {
            ans[i] = Math.min(i == n - 1 ? Long.MAX_VALUE : ans[i + 1], dist1[i] + dist2[i]);
        }

        for (long a : ans) {
            System.out.println((long)1e15 - a);
        }
    }

    static long[] dijkstra(List<Grid>[] list, int start) {
        long[] cost = new long[list.length];
        Arrays.fill(cost, 1L << 62);
        cost[start] = 0;

        Queue<Grid> queue = new PriorityQueue<>(Comparator.comparing(grid -> grid.cost));
        queue.add(new Grid(start, 0));

        while (!queue.isEmpty()) {
            Grid grid = queue.poll();
            if (cost[grid.to] >= grid.cost) {
                for (Grid g : list[grid.to]) {
                    if (cost[g.to] > cost[grid.to] + g.cost) {
                        cost[g.to] = cost[grid.to] + g.cost;
                        queue.add(new Grid(g.to, cost[g.to]));
                    }
                }
            }
        }
        return cost;
    }

    static class Grid {
        int to;
        long cost;

        Grid(int to, long cost) {
            this.to = to;
            this.cost = cost;
        }
    }
}

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

const int MOD = 1e9 + 7;
inline void add(int &a, int b){a = (a + b) % MOD;}

int n, W;
int w[201];
int dp[10001];

int main()
{
	scanf("%d %d", &n, &W);
	for (int i = 1; i <= n; i++) scanf("%d", w + i);
	sort(w, w + (++n));
	
	int S = 0;
	for (int i = 0; i < n; i++) S += w[i];
	if (S <= W){
		puts("1");
		return 0;
	}
	
	int res = 0, sum = 0;
	for (int i = 0; i < n; i++){
		int tW = W - sum;
		sum += w[i];
		
		memset(dp, 0, sizeof(dp));
		dp[0] = 1;
		
		for (int j = i + 1; j < n; j++){
			for (int k = tW; k >= w[j]; k--){
				add(dp[k], dp[k - w[j]]);
			}
		}
		
		for (int j = tW - w[i] + 1; j <= tW; j++) if (j >= 0) add(res, dp[j]);
	}
	
	printf("%d\n", res);
}

Measured memory_bytes: 1248
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a;
    string s;
    cin >> s; 
    if(s[0]==s[2])
        cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int v[100001];
int main(){
  int N, M; cin >> N >> M;
  for (int i = 0; i < M; i++){
    int a, b; cin >> a >> b;
    v[a]++, v[b]++;
  }
  for (int i = 1; i <= N; i++){
    if (v[i]%2){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 640
(defun take (l n)
  (labels ((f (lst num ans)
              (if (zerop num)
                  ans
                  (f (cdr lst)
                     (1- num)
                     (cons (car lst) ans)))))
          (f l n '())))
      

(let* ((x (read))
       (y (read))
       (a (read))
       (b (read))
       (c (read))
       (lst-a (sort (loop repeat a
                          collect (read))
                    #'>))
       (lst-b (sort (loop repeat b
                          collect (read))
                    #'>))
       (lst-c (sort (loop repeat c
                          collect (read))
                    #'>))
       (lst (sort (append (take lst-a x)
                          (take lst-b y)
                          lst-c)
                  #'>)))
      (format t "~A" (apply #'+ (take (sort lst #'>)
                                      (+ x y)))))
      

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

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

    int n;
    cin >> n;
    vi v(n);
    REP(i, n) cin >> v[i];

    ll ans_pos = 0;
    ll s;
    if(v[0] <= 0) {
        ans_pos = 1 - v[0];
        s = 1;
    } else {
        s = v[0];
    }
    FOR(i, 1, n) {
        if(s > 0) {
            s += v[i];
            if(s >= 0) {
                ans_pos += s + 1;
                s = -1;
            }
        } else {
            s += v[i];
            if(s <= 0) {
                ans_pos += 1 - s;
                s = 1;
            }
        }
    }

    ll ans_neg = 0;
    if(v[0] >= 0) {
        ans_neg = v[0] + 1;
        s = -1;
    } else {
        s = v[0];
    }
    FOR(i, 1, n) {
        if(s > 0) {
            s += v[i];
            if(s >= 0) {
                ans_neg += s + 1;
                s = -1;
            }
        } else {
            s += v[i];
            if(s <= 0) {
                ans_neg += 1 - s;
                s = 1;
            }           
        }
    }
    cout << min(ans_neg, ans_pos) << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	set<int> s;
	queue<int> q;
	q.push(1);
	while(q.size()){
		int n=q.front();
		q.pop();
		if(!s.insert(n).second)
			continue;
		if(n*2<=1000000) q.push(n*2);
		if(n*3<=1000000) q.push(n*3);
		if(n*5<=1000000) q.push(n*5);
	}
	vi res(allof(s));
	
	for(int m,n;cin>>m,m;){
		cin>>n;
		cout<<upper_bound(allof(res),n)-lower_bound(allof(res),m)<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;cin>>n;
    vector<ll> x(n);
    rep(i,n) cin>>x[i];
    ll cnt=0,ans=1;
    rep(i,n){
        if(x[i]>=cnt*2+1)   cnt++;
        else                ans=ans*(cnt+1)%mod;
    }
    for(ll i=1;i<=cnt;i++) ans=ans*i%mod;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
import math
from decimal import *
A, B, H, M = map(int,input().split())
# 長針の角度
long = 6 * M
# 短針の角度
short = 30*(H) + 0.5*M
theta = abs(long - short)
if theta > 180:
    theta = 360 - theta
cos = math.cos(math.radians(theta))
x = A**2 + B**2 - 2*A*B*cos
x = math.sqrt(x) # 平方根に変換
n = 10 # 小数点10位以下を切り捨て
y = Decimal(str(x)).quantize(Decimal(str(10**(n*-1))), rounding=ROUND_DOWN)
print(y)

Measured memory_bytes: 10316
#!/usr/bin/env python3
import sys
from itertools import combinations

def _solve(y1, y2, sorted_points, K):
    y1, y2 = tuple(sorted([y1, y2]))
    x = tuple(x for x, y in sorted_points if y1 <= y <= y2)
    if len(x) < K:
        return float('inf')
    return min((y2 - y1) * (x2 - x1) for x1, x2 in zip(x, x[K-1:]))

def solve(N: int, K: int, x: "List[int]", y: "List[int]"):
    sorted_points = tuple(sorted(zip(x, y)))
    return min(_solve(y1, y2, sorted_points, K) for y1, y2 in combinations(y, 2))

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    print(solve(N, K, x, y))

if __name__ == '__main__':
    main()


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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;

int main() {
    lli n, q;
    cin2(n, q);
    string s;
    cin1(s);
    lli l[q], r[q];
    ncin2(q, l, r);

    lli count = 0;
    lli x[s.length() + 2];
    x[0] = x[1] = 0;
    REP(i, 1, s.length()) {
        if (s[i-1] == 'A' && s[i] == 'C') {
            count++;
        }
        // 2〜s.length()
        x[i+1] = count;
        //cout2(i+1, x[i+1]);
    }

    REP(i, 0, q) {
        //cout1(r[i]);
        //cout1(l[i]);
        //cout1(x[r[i]]);
        //cout1(x[l[i]]);
        cout << x[r[i]] - x[l[i]] << endl;
    }
}


Measured memory_bytes: 3456
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
from bisect import bisect_left
for _ in range(N):
    Xs = input()
    Ys = input()[::-1]
    lis = []
    for x in Xs:
        idx = Ys.find(x)+1
        while idx:
            j = bisect_left(lis, -idx)
            if j>=len(lis):
                lis.append(-idx)
            else:
                lis[j] = -idx
            idx = Ys.find(x, idx)+1
    print(len(lis))



Measured memory_bytes: 5656
import sys
def fastio():
    from io import StringIO
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
# from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br

s = input()
ans = 'No'
if s[2] == s[3] and s[4] == s[5]:
    ans = 'Yes'
print(ans)

Measured memory_bytes: 3316
use proconio::input;

fn main() {
    input! {
        n: usize,
        r#as: [u128; n],
    }

    if r#as.contains(&0) {
        println!("0");
        return;
    }

    if let Some(prod) = r#as.into_iter().fold(Some(1), |prod, a| match (prod, a) {
        (Some(prod), a) if prod * a <= 10u128.pow(18) => Some(prod * a),
        _ => None,
    }) {
        println!("{}", prod);
    } else {
        println!("-1");
    }
}


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

typedef long long ll;

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  ll ans=0;
  int right=0;
  int now=0;
  for(int left=0;left<n;left++){
    while(right<n && (now^a[right])==(now+a[right])){
      now^=a[right];
      right++;
    }
    ans+=(right-left);
    if(right==left) right++;
    else now^=a[left];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int d[]=new int[n];
		for(int i=0;i<n;i++) {
			d[i]=scan.nextInt();
		}
		scan.close();
		int sum=0;
		for(int i=0;i<n;i++) {
			for(int j=0;j<n;j++) {
				if(i!=j)sum+=d[i]*d[j];
			}
		}
		System.out.println(sum/2);
	}
}

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(m), res(n);
  rep(i,m) cin >> a[i];
  rep(i,n) res[i] = i;
  rep(i,m) swap(res[a[i]-1], res[a[i]]);

  int ans = m;
  sort(all(a));
  do {
    vector<int> h(n, 0);
    vector<int> tmp(n);
    rep(i,n) tmp[i] = i;
    for(auto p : a){
      swap(tmp[p-1], tmp[p]);
      int nh = max(h[p-1], h[p]) + 1;
      h[p-1] = nh;
      h[p] = nh;
    }
  
    int hh = *max_element(all(h));
    
    if(tmp == res) ans = min(ans, hh);
  
  } while(next_permutation(all(a)));
  
  cout << ans << endl;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    cout <<(max(2*a-1,max(a+b,2*b-1)))<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;

  ll t1 = h1 * 60 + m1;
  ll t2 = h2 * 60 + m2;

  ll ans = t2 - t1 - k;

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 3608
#!/usr/bin/env python3
def main():
    L = int(input())

    ans = 0
    for i in range(min(L, 1000)):
        for j in range(1000):
            a = i + (j / 1000)
            b = (L - a) / 2
            ans = max(ans, a * b * b)
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))

const long long INF = 1LL << 60;
typedef long long ll;
const long long MOD = 1000000000 + 7;

int main()
{
    int n;
    ll a;
    cin >> n;
    vector<ll> cnt(n, 0);
    vector<ll> asum(n + 1, 0);
    rep(i, n)
    {
        cin >> a;
        cnt[i] = a;
    }
    rep(i, n) asum[i + 1] = asum[i] + cnt[i];
    map<ll, ll> lap;
    rep(i, n + 1) lap[asum[i]]++;
    ll out = 0;
    for (auto it : lap)
    {
        out += it.second * (it.second - 1) / 2;
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
signed main(){
    string N; cin>>N;
    int ans =0;
    for(int i=0; i<N.size(); i++){
        int len = 0;
        while(N[i]=='A'||N[i]=='T'||N[i]=='C'||N[i]=='G'){
            len ++;
          i++;
        }
        ans = max(ans,len);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline


    n, k = map(int, input().split())

    aa = list(map(int, input().split()))

    """

    n = 100000
    k = 50000
    aa = [i for i in range(100000)]
    """

    import math

    if k == 1:
        print(0)
    else:
        def cmb(n, r, p):
            if (r < 0) or (n < r):
                return 0
            r = min(r, n - r)
            return fact[n] * factinv[r] * factinv[n-r] % p

        p = 10 ** 9 + 7
        N = 10 ** 5  # N は必要分だけ用意する
        fact = [1, 1]  # fact[n] = (n! mod p)
        factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
        inv = [0, 1]  # factinv 計算用

        for i in range(2, N + 1):
            fact.append((fact[-1] * i) % p)
            inv.append((-inv[p % i] * (p // i)) % p)
            factinv.append((factinv[-1] * inv[-1]) % p)

        aa.sort()

        cnt = 0

        c = 1
        large = k
        before = 0

        for i, j in zip(aa[k-1:], reversed(aa[:-k+1])):
            c = cmb(large, k, p)
            cnt += (i-j)*(c-before)
            cnt = cnt%(10**9+7)
            before = c
            large += 1

        print(int(cnt%(10**9+7)))


Measured memory_bytes: 20804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

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

    ll n = s.size()+1;

    ll l=0, r=0;
    ll ans = 0;
    rep(i, n-1){
        if(s[i]=='<') l++;
        if(s[i]=='>') r++;
        if(s[i]=='>' && s[i+1]=='<'){
            ll t = max(l, r);
            ll tm = min(l, r);
            ans += t*(t+1)/2 + (tm-1)*tm/2;
            l = 0;
            r = 0;
        }
    }

    ll t = max(l, r);
    ll tm = min(l, r);
    ans += t*(t+1)/2 + (tm-1)*tm/2;
    
    cout << ans << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 900
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int M = int.Parse(str[1]);
		string[] str2 = Console.ReadLine().Split();
		int sum = 0;
		int ct = 0;
		int[]A = new int[N];
		for(var i=0;i<N;i++){
			A[i] = int.Parse(str2[i]);
			sum += A[i];
		}
		string ans = "No";
		for(var i=0;i<N;i++){
			if(A[i] * 4 * M >= sum){
				ct++;
			}
		}
		if(ct >= M){
			ans = "Yes";
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
n = int(input())
s = []
for i in range(n):
  s.append(int(input()))
  
sums = sum(s)
s.sort()

if sums%10 != 0:
  print(sums)
  exit()
  
for i in s:
  if i%10 != 0:
    sums -= i
    print(sums)
    exit()
    
print(0)


Measured memory_bytes: 3060