akhauriyash/Code-Regression huggingface dataset:
#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,b,c;
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    transform(ALL(s1),s1.begin(),::toupper);
    transform(ALL(s2),s2.begin(),::toupper);
    transform(ALL(s3),s3.begin(),::toupper);

    cout << s1[0] << s2[0] << s3[0] << endl;
    return 0;
}

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

int main() {
  long long N;
  cin >> N;
  
  long long min = 0;
  for (int i = 1; i <= sqrt(N) + 1; i++) {
    if (N % i == 0) {
      min = N/i + i;
    }
  }
  
  cout << min - 2;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  if(n % 2 == 1) cout << "No" << endl;
  else {
    int mid = n / 2;
    string front = s.substr(0, mid);
    string back = s.substr(mid, mid);
    if(front == back) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
have_8_divisors = 0

def count_up_divisor(check_num):
    cnt = 0
    for i in range(1, check_num + 1):
        # 1からcheck_numを順に探索して、nの約数かどうか判断して、約数の時はカウント
        if check_num % i == 0:
            cnt += 1
    return cnt


for i in range(1, n + 1):
    # 偶数の時はスキップ
    if i % 2 == 0:
        continue

    result = count_up_divisor(i) == 8
    if result:
        have_8_divisors += 1

print(have_8_divisors)

Measured memory_bytes: 8872
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        //Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        var kq = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var d = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var k = kq[0];
        var q = kq[1];
        long[] seq = new long[d.Length + 1];
        for (int _ = 0; _ < q; _++)
        {
            var nxm = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var n = nxm[0];
            var X = nxm[1];
            var m = nxm[2];
            seq[0] = 0;
            for (int i = 0; i < d.Length; i++)
            {
                var add = d[i] % m;
                if (add == 0) add = m;
                seq[i + 1] = seq[i] + add;
            }
            var sum = ((n - 1) / d.Length) * seq.Last();
            var remain = seq[(n - 1) % d.Length];
            sum = (X % m) + sum + remain;
            Console.WriteLine(n - 1 - sum / m);
        }
        //Console.Out.Flush();
    }
}


Measured memory_bytes: 15584
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        n: usize,
        aa: [f64;n]
    }
    let a1 = aa.iter().map(|a| 1.0 / a).sum::<f64>();
    println!("{}", 1.0 / a1);
}
/* vim:set foldmethod=marker: */


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

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

		String S = sc.next();
		int num = 0;

		for (int i = 0; i < 4; i++) {
			if (String.valueOf(S.charAt(i)).equals("+")) {
				num++;
			} else {
				num--;
			}

		}

		System.out.println(num);

	}

}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
#define MAXN 200005
int n, a[MAXN];
#define LL long long int
map<int,int> mymap;
LL ans;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
    {
        ans+=mymap[i-a[i]];
        mymap[a[i]+i]++;
    }
    printf("%lld\n",ans);
    return 0;
    
}


Measured memory_bytes: 21564
# -*- coding: utf-8 -*-

def do_binary_search(target_value, target_list, target_list_length=None):
    left = 0
    right = target_list_length

    while right - left > 0:
        mid = (right + left) / 2
        key = target_list[mid]
        if key == target_value:
            return True
        elif target_value < key:
            right = mid
        else:
            left = mid + 1
    return False



def main():
    s_length = int(raw_input())
    s = [int(x) for x in raw_input().strip().split(' ')]
    t_length = raw_input()
    t = [int(x) for x in raw_input().strip().split(' ')]

    counter = 0
    for value in t:
        counter += int(do_binary_search(value, s, s_length))

    print counter 

if __name__ == '__main__':
    main()

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

count = s[1:].count("E")
e = s[1:].count("E")
w = s[1:].count("W")
temp = []
temp.append(count)

for i in range(1,len(s)):
    count = temp[-1]
    if s[i-1] == "W":
        count += 1
    if s[i]=="E":
        count -= 1
    temp.append(count)

print(min(temp))

"""
n = input()
s = input()
l = int(n)
count = 0
for i in range(1,l):
    s1 = set(s[:i])
    s2 = set(s[i:])
    count = max(count,len(s1 & s2))
print(count)




"""

Measured memory_bytes: 15564
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a;
    int b[10]={};
    for(int i=0;i<4;i++){
    cin>>a;
    b[a]++;
    }
    if(b[1]==1 && b[4]==1 && b[7]==1 && b[9]==1) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;
typedef long long ll;

int main()
{
	ll N; cin >> N;
	string name = "";
	//1:a
	//26:z
	//27:aa
	while (N != 0) {
		int s = (N-1) % 26;
		name = (char)('a' + s) + name;
		N = (N-1)/ 26;
	}
	cout << name << endl;
}


Measured memory_bytes: 3156
import Control.Applicative
import Data.List
import Data.Char

deleteChrFromStr :: Char -> String -> String
deleteChrFromStr chr str = if elem chr str then deleteChrFromStr chr (delete chr str) else str

deleteComma str = deleteChrFromStr ',' str
deletePeriod str = deleteChrFromStr '.' str
deleteLF str = deleteChrFromStr '\n' str
deleteDoubleQuotation str = deleteChrFromStr '"' str

strLower []     = ""
strLower (x:xs) = (toLower x) : (strLower xs)

countElem elm []     = 0
countElem elm (x:xs) = (if x==elm then 1 else 0) + (countElem elm xs)

main = do{
    word <- getLine;
    count <- countElem word . map (strLower . deleteComma . deletePeriod . deleteLF . deleteDoubleQuotation) . words <$> getContents;
    print $ count;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define loop(x) for(int i=0;i<x;i++)
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define dd fflush(stdout)
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mt make_tuple //use tie
#define eb emplace_back
typedef tuple<int,int,int> State;//use in dijkstra

// ll power(ll x,ll y,ll mod){
//  ll ans=1;
//  while(y>0){
//   if(y&1){
//     ans=ans*x;
//   }
//   x=x*x;
//   y=y/2;
//  }
//  return ans;
// }
 
int main(){
    IOS;
    ll n,w;
 cin>>n>>w;
    ll wt[n+2],val[n+2];
    loop(n){
      cin>>wt[i]>>val[i];
    }
    ll dp[n+1][w+1];
    for(int i=0;i<=n;i++){
      for(int j=0;j<=w;j++){
        if(i==0||j==0)
        {
          dp[i][j]=0;
          continue;
        }
        if(wt[i-1]<=j)
        {
        dp[i][j]=max(dp[i-1][j] ,val[i-1]+dp[i-1][j-wt[i-1]]);
        }
      else 
         dp[i][j]=dp[i-1][j];
      }
    }
    cout<<dp[n][w]<<endl;
}
// https://atcoder.jp/contests/dp/tasks/dp_d
// https://codeforces.com/contest/1131/problem/C
 


Measured memory_bytes: 79232
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int F[][] = new int[N][10];
		int P[][] = new int[N][11];
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < 10; j++) {
				F[i][j] = sc.nextInt();
			}
		}
		for(int i = 0; i < N; i++) {
			for(int j = 0; j <= 10; j++) {
				P[i][j] = sc.nextInt();
			}
		}
		
		int ans = Integer.MIN_VALUE;
		for(int i = 0; i < Math.pow(2, 10); i++) {
			if(i == 0) continue;
			int temp = 0;
			for(int j = 0; j < N; j++) {
				int cnt = 0;
				for(int k = 0; k < 10; k++) {
					if((1 & i >> k) == 1) {
						if(F[j][k] == 1) cnt++;;
					}
				}
				temp += P[j][cnt];
			}
			ans = Math.max(ans, temp);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 26288
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scanf("%d", &N)
	max, min := 0, 1145141919
	var A int
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &A)
		if A > max {
			max = A
		}
		if A < min {
			min = A
		}
	}
	fmt.Printf("%d\n", max-min)
}


Measured memory_bytes: 512
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define cst first
#define dur second
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 2 * N + 5;

int f(int x){
    int ret = 0;
    while(x){
        ++ret;
        x /= 10;
    }
    return ret % 2;
}
int main(){
    IO;
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1 ; i <= n ; ++i)
        ans += f(i);
    cout << ans << endl;
}

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

dp = [[] for _ in range(l+1)]
dp[0].append('')

for i in range(l):
  for e in dp[i]:
    dp[i+1].append(e+'3')
    dp[i+1].append(e+'5')
    dp[i+1].append(e+'7')
ans = 0

for i in range(min(3,l+1),l+1):
  for e in dp[i]:
    if '3' in e and '5' in e and '7' in e and int(e) <= n:
      ans += 1
      
print(ans)



Measured memory_bytes: 5228
#include<stdio.h>
int main(void)
{
	int a,b,c,i,j,cd;
	
	scanf("%d %d %d",&a,&b,&c);
	
	j = 0;
	
	for(i=a;i<=b;i++){
		
		cd = c%i;
		
		if(cd==0){
			j = j+1;
		}
	}
	
	printf("%d\n",j);
	
	return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define int long long

signed main() {
    int n;
    cin >> n;
    int a[2][n];
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 1; i < n; i++) {
        a[0][i] += a[0][i - 1];
    }
    a[1][0] += a[0][0];
    for (int i = 1; i < n; i++) {
        a[1][i] += max(a[0][i], a[1][i - 1]);
    }
    cout << a[1][n - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int x, a;
    cin >> x >> a;

    if (x < a)
    {
        cout << "0" << endl;
    }
    else
    {
        cout << "10" << endl;
    }
}

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

#define what_is(x) cerr << #x << " is " << x << endl;

const ll LMAX = (1LL<<61);
const int IMAX = (1<<29);
const int BIG = 104206970;
const int PRIME = 104206969;

const int N = 100001;
const int MOD = 1e9+7;

int main () {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	// cout.precision(9); cout << fixed;
	int n; cin >> n;
	int a[n];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int m[n]; m[0] = a[0];
	for (int i = 1; i < n; i++)
		m[i] = min(m[i-1],a[i]);

	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] <= m[i])
			ans++;
	}
	cout << ans << endl;

	return 0;
}


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

using ll = long long;
using namespace std;

bool chack(vector<vector<bool>> mp)
{
    bool res = 1;
    for(int i = 0; i < 8; i++){
        for(int j = 0; j < 8; j++){
            int cnt = 0;
            for(int k = 0; k < 8; k++){
                if(i + k > 7 || j + k > 7)continue;
                cnt += mp[i + k][j + k];
            }
            if(cnt >= 2)res = false;
        }
    }
    for(int i = 0; i < 8; i++)reverse(mp[i].begin(), mp[i].end());
    for(int i = 0; i < 8; i++){
        for(int j = 0; j < 8; j++){
            int cnt = 0;
            for(int k = 0; k < 8; k++){
                if(i + k > 7 || j + k > 7)continue;
                cnt += mp[i + k][j + k];
            }
            if(cnt >= 2)res = false;
        }
    }
    return res;
}


int main()
{
    int n; cin >> n;
    vector<vector<bool>> ban(8,vector<bool>(8));
    vector<bool> flagy(8), flagt(8);


    for(int i = 0; i < n; i++){
        int y, x; cin >> y >> x;
        ban[y][x] = true;
        flagy[y] = true;
        flagt[x] = true;
    }

    vector<int> yokop; //横yokop[i]行目にはおける
    vector<int> tatep; //縦tatep[i]行目にはおける

    for(int i = 0; i < 8; i++){
        if(!flagy[i])yokop.push_back(i);
        if(!flagt[i])tatep.push_back(i);
    }

    do{
        auto cur = ban;
        for(int i = 0; i < (int)yokop.size(); i++){
            cur[yokop[i]][tatep[i]] = true;
        }

        if(chack(cur)){
            for(int i = 0; i < 8; i++){
                for(int j = 0; j < 8; j++){
                    cout << (cur[i][j] ? 'Q' : '.'); 
                }
                cout << endl;
            }
        }

    }while(next_permutation(yokop.begin(), yokop.end()));
}


Measured memory_bytes: 3168
#include<iostream>
#include<cstdio>
#include<algorithm>
int n,k;
int h[100001];

using namespace std;

int main()
{
	scanf("%d%d",&n,&k);
	
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&h[i]);
	}
	
	sort(h+1,h+n+1);
	
	int ans=1e9;
	
	for(int i=k;i<=n;i++)
	{
		ans=min(ans,h[i]-h[i-k+1]);
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 640
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#include <chrono> 
using namespace std::chrono;
#define fl(i,z,n) for(int i=z;i<=(n);i++)
#define flr(i,z,n) for(int i=z;i>=(n);i--)
using namespace std;
#define ll long long 
#define printa(a,s) fl(i,0,s-1) cout<<*(a+i)<<" "; cout<<nl;
#define printv(v) fl(i,0,v.size()-1) cout<<v[i]<<" "; cout<<nl;
#define all(v) v.begin(),v.end()
#define debnl(x) cout<<#x<<"="<<x<<nl;
#define deb(x) cout<<#x<<"="<<x<<" ";
#define mkp(x,y) make_pair(x,y)
#define ump unordered_map
#define in insert
#define sz size
#define len length
#define nl '\n'
#define pb push_back
#define in insert
#define ub upper_bound
#define lb lower_bound
#define ld long double
const int MXN=1e5;
ll mod=1e9+7;
void solve(){
    ll n,d;
    cin>>n>>d;
    ll ans=0;
    fl(i,0,n-1){
        ll x,y;
        cin>>x>>y;
        if(x*x + y*y <= d*d) ans++;
    }
    cout<<ans<<nl;
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); ll t=1;
    //cin>>t; //comment for single test
    while(t--) solve();
}

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

using namespace std;

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

    long long temp;
    long long counter = 0;
    map<long long,int> ms;
    for(int i = 0; i < n; i++) {
        cin >> temp;
        counter += ms[i - temp];
        ms[i + temp]++;
    }

    cout << counter << endl;
}

Measured memory_bytes: 26092
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
#define mod 1e9 + 7;

int main()
{
	ios_base::sync_with_stdio(false);

	ll a, b, c,n, k;
	string s,t;
	cin >> s >> t;
	rep(i, s.size()) {
		s = s[s.size() - 1] + s;
		s.pop_back();
		//cout << s << endl;
		if (s == t) { cout << "Yes" << endl; return 0; }
	}
	cout << "No" << endl;
	return 0;
}

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

int main()
{
    string S;
    int N;
    int P;
    cin >> N >> P >> S;

    ll ans = 0;
    if(10%P==0)
    {
        for(int i=0;i<N;++i)
        {
            if((S[i]-'0') % P == 0)
            {
                ans+=i+1;
            }
        }
        cout << ans << endl;
        return 0;
    }

    
    vector<int> cnt(P);
    int cu=0;
    int ten=1;
    for(int i=N-1;i>=0;--i)
    {
        cu = (cu+ten*(S[i]-'0')) % P;
        ten=(ten*10)%P;
        ans+=cnt[cu];
        if(cu==0)
        {
            ans++;
        }
        cnt[cu]++;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 640
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>

using namespace std;

int main() {
  string n;
  cin >> n;
  bool ans=true;
  for(int i=0;i<n.size();i++){
    if(n.at(i)!=n.at(n.size()-i-1)){
      ans=false;
      break;
    }
  }
  if(ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

string S;
int X[20];

int main(){
  cin >> S;

  int max_size = 0;
  rep(i, S.size()){
    repi(j, 1, S.size()-i+1){
      string s = S.substr(i, j);
      bool flag = true;
      for (auto x: s) {
        if (x!='A' and x!='T' and x!='G' and x!='C') flag=false;
      }
      if (flag){
        if (max_size < s.size()){
          max_size = s.size();
        }
      }
    }
  }
  cout << max_size << endl;
}


Measured memory_bytes: 3624
while true
    a, op, b = gets.split(" ")
    case op
    when '+'
        puts a.to_i+b.to_i
    when  '-'
        puts a.to_i-b.to_i
    when '*'
        puts a.to_i*b.to_i
    when '/'
        puts a.to_i/b.to_i
    when '?'
        break
    end
end

Measured memory_bytes: 8648
#include <iostream>

int main()
{
    char str[8];
    scanf("%s", str);

    for (int i = 0; i < 3; i++)
    {
        if (str[i] == '7')
        {
            printf("Yes");
            return 0;
        }
    }

    printf("No");
    return 0;
}

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

using namespace std;
#define int long long
#define float double
#define INF 1ll<<60

int32_t main(){
	ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
	int M, D, count=0;
	cin >> M >> D;

	for (int j = 1; j <= M; j++){
		for (int i = 1; i <= D; i++){
			if (i >= 10 && (i%10) >= 2 && (i/10) >= 2){
				if ((i % 10) * (i/10) == j) {
					count++;
				}
			}
		}
	}
	cout << count << "\n";
}

Measured memory_bytes: 256
n = int(input())
lis = list(map(int, input().split()))

lis = sorted(lis, reverse=True)

ans = lis[0]
t = 0
for i in range(1,n-1):
    if i % 2 != 0:
        t += 1
    ans += lis[t]
        

print(ans)

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

using namespace std;

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

    int dp[n];
    dp[0]=0;
    dp[1]=dp[0]+abs(arr[1]-arr[0]);

    for(int i=2;i<n;i++) {
        dp[i] = min(dp[i-1]+abs(arr[i-1]-arr[i]),dp[i-2]+abs(arr[i-2]-arr[i]));

    }
    cout << dp[n-1];
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <sstream>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define pri(a) cout << a << endl
#define pri2(a, b) cout << a << " " << b << endl
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define vi vector<int>
#define vs vector<string>
#define vc vector<char>

typedef long long ll;

/*以上テンプレ*/

int main () {
    int a,b;
    in2(a,b);
    if(a>12)
    {
        pri(b);
    }
    else if(a<6)
    {
        pri(0);
    }
    else
    {
        pri(b / 2);
    }
    
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
#define SIZE 300
#define INF 1000000
typedef pair<int, int>pii;
class maxflow
{
public:
	vector<int>pat[SIZE];
	vector<int>cap[SIZE];
	vector<int>rev[SIZE];
	bool flag[SIZE];
	int dist[SIZE];
	int now[SIZE], ind[SIZE];
	int idx[SIZE];
	int flow;
	int gd;
	void adde(int s, int t, int cp)//多重辺は消してから s->tの容量cpの辺をはる
	{
		pat[s].push_back(t);
		pat[t].push_back(s);
		cap[s].push_back(cp);
		cap[t].push_back(0);
		rev[s].push_back(pat[t].size() - 1);
		rev[t].push_back(pat[s].size() - 1);
	}
	void blockflow(int node, int len, int go, int pt)//ブロックフローを求めて流す
	{
		if (pt == len)
		{
			if (node != go)return;
			int mini = INF, rr = -1;
			for (int i = 0; i < pt; i++)if (cap[now[i]][ind[i]] < mini)mini = cap[now[i]][ind[i]], rr = i;
			for (int i = 0; i < pt; i++)cap[now[i]][ind[i]] -= mini, cap[pat[now[i]][ind[i]]][rev[now[i]][ind[i]]] += mini;
			flow += mini;//mini==INFになったら非有界
			gd = rr;
			return;
		}
		now[pt] = node;
		for (int i = idx[node]; i < pat[node].size(); i++)
		{
			if (dist[pat[node][i]] == dist[node] + 1 && cap[node][i]>0)
			{
				ind[pt] = i;
				blockflow(pat[node][i], len, go, pt + 1);
				if (gd < pt)break;
				else gd = INF;
			}
			idx[node]++;
		}
	}
	void dinic(int st, int go, int num)//dinicのアルゴリズムで最大流を求める 変数flowにmaxflowの値が入る
	{
		flow = 0;
		for (;;)
		{
			queue<pii>que;
			fill(dist, dist + num, INF);
			fill(flag, flag + num, false);
			que.push(make_pair(st, 0));
			for (;;)
			{
				if (que.empty())break;
				pii z = que.front();
				que.pop();
				if (flag[z.first])continue;
				flag[z.first] = true;
				dist[z.first] = z.second;
				for (int i = 0; i < pat[z.first].size(); i++)
				{
					if (dist[pat[z.first][i]]>z.second + 1 && cap[z.first][i] > 0)
					{
						dist[pat[z.first][i]] = z.second + 1;
						que.push(make_pair(pat[z.first][i], z.second + 1));
					}
				}
			}
			if (dist[go] == INF)return;
			gd = INF;
			fill(idx, idx + SIZE, 0);
			blockflow(st, dist[go], go, 0);
		}
	}
	vector<int>getcut(int st, int go, int num)//頂点iがmincutのst側なら1 そうでなければ0
	{
		dinic(st, go, num);
		vector<int>ret;
		for (int i = 0; i < num; i++)ret.push_back(flag[i]);
		return ret;
	}
};
maxflow gr;
int a[111], b[111], c[111], d[111];
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num; i++)scanf("%d%d", &a[i], &b[i]);
	for (int i = 0; i < num; i++)scanf("%d%d", &c[i], &d[i]);
	for (int i = 0; i < num; i++)for (int j = 0; j < num; j++)if (a[i] < c[j] && b[i] < d[j])gr.adde(i + 2, j + num + 2, 1);
	for (int i = 0; i < num; i++)gr.adde(0, i + 2, 1), gr.adde(i + num + 2, 1, 1);
	gr.dinic(0, 1, num + num + 2);
	printf("%d\n", gr.flow);
}

Measured memory_bytes: 384
N=int(input())
res = 0

def trans753(i):
    dict753=['0','3','5','7']
    num753=""
    while i>0:
        num753 = dict753[i%4] + num753
        i//=4
    return int(num753)

def verify753(i):
    if '0' in str(i):
        return False
    flag = [False for i in range(10)]
    while i>0:
        flag[i%10]=True
        i//=10
    return flag[7] and flag[5] and flag[3]

for i in range(1,4**10):
    num753 = trans753(i)
    if num753>N:
        break
    if verify753(num753):
        res+=1

print(res)


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    map<string, int> mp;
    int n, r;
    cin >> n;
    r = 0;
    for (int i = 0; i < n; i++) {
    	string s;
    	cin >> s;
    	if (!mp[s])
    		r++;
    	mp[s]++;
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 19208
#include <iostream>

using namespace std;

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

    int ans = 1000000000;
    for (int A = 1; A < N; ++A) {
        int B = N - A;

        int res = 0;
        for (int i = 0; i < to_string(A).size(); ++i) {
            res += to_string(A)[i] - '0';
        }

        for (int i = 0; i < to_string(B).size(); ++i) {
            res += to_string(B)[i] - '0';
        }

        ans = min(ans, res);
    }

    cout << ans << endl;
}

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


#define rep(i, a, b) for(int i = a; i < b; i++)

typedef long long ll;

using namespace std;


int n;
vector<pair<string,string> > prd;
int pas[110][110];
int cst[110];

int main(){

  cin >> n;

  rep(i, 0, n){
    string tmp, tmp2;
    cin >> tmp;
    if(tmp == "goto"){
      cin >> tmp2;
      tmp2.resize(tmp2.size()-1);
      prd.push_back(make_pair(tmp, tmp2));
    }else{
      tmp.resize(tmp.size()-1);
      prd.push_back(make_pair(tmp, ""));
    }
  }
  prd.resize(prd.size()+1);
  rep(i,0,n+1){
    cst[i] = 10000;
    rep(j,0,n+1) pas[i][j] = 10000;
  }
  rep(i, 0, n){
    if(prd[i].first != "goto"){
      int cnt = 0;
      rep(j, i+1, n+1){
	pas[i][j] = cnt; 
	if(prd[j].first == "goto"){
	  cnt++;
	}else{
	  break;
	}
      }
    }else{
      rep(j, 0, n){
	if(prd[j].first == prd[i].second){
	  pas[i][j] = 0;
	}
      }
    }
  }/*
  rep(i,0,n){
    rep(j,0,n+1){
      cout << pas[i][j];
    }
    cout << endl;
    }*/

  cst[0] = 0;
  bool changed = true;
  while(changed){
    changed = false;
    rep(i, 0, n){
      rep(j, 0, n+1){
	if(cst[j] > cst[i] + pas[i][j]){
	  cst[j] = cst[i] + pas[i][j];
	  changed = true;
	}
      }
    }
  }
  cout << cst[n] << endl;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const int INF=1e7;
const LL LINF=1e18;

int main(){
    LL x,y;
    cin >> x >> y;
    if(x%y==0) puts("-1");
    else cout << x << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <list>
#include <cmath>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <vector>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
// const ll MOD = 1000000009;

#define M 1000000007

enum state {
    inR = 0,
    inL = 1,
};

int main() {
    ll n;
    string s;
    cin >> s;
    n = s.length();
    enum state state = inR;
    ll lenR =0, lenL = 0;
    ll pos;
    vector<ll> res(n, 0);
    for (ll i = 0; i <= n; ++i) {
        switch (state)
        {
        case inR:
            if (s[i] == 'R') {
                ++lenR;
            } else {
                state = inL;
                lenL = 1;
                pos = i;
            }
            break;
        default:
            if (i == n || s[i] == 'R') {
                state = inR;
                // cerr << "lenR is " << lenR  << ", lenL is " << lenL << endl;
                res[pos-1] = lenR/2 + lenR%2 + lenL/2;
                res[pos] = lenR/2 + lenL/2 + lenL%2;
                lenR = 1;
                lenL = 0;
            } else {
                ++lenL;
            }
            break;
        }
    }

    for (ll i = 0; i < n; ++i) {
        cout << res[i];
        if (i != n -1) cout << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
//typedef __int64 LL;
typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;

const int MOD=1000000007;

LL beki(LL a,LL b)
{
	if(b==0)return 1;
	
	LL x=beki(a,b/2);
	if(b%2==0)return (x*x)%MOD;
	else return (((a*x)%MOD)*x)%MOD;
	
}

LL w[100010];
int main(){
	LL n=3,k;
	LL ans=0;
	cin>>k;
	
	for(LL i=k;i>=1;i--)
	{
		LL num=beki(k/i,n);
		for(LL j=i*2;j<=k;j+=i)
		{
			num=(num-w[j]+MOD)%MOD;
		}
		w[i]=num;
		ans=(ans+i*num)%MOD;
		//cout<<num<<"\n";
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3640
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))

max_score = -float('inf')

for i in range(n):
    loop_score_array = []
    loop_score = 0
    loop_len = 0
    pos = i
    while True:
        pos = p[pos] - 1
        loop_score += c[pos]
        loop_score_array.append(loop_score)
        loop_len+=1
        if pos == i:
            break
    for i, score in enumerate(loop_score_array):
        if k-i-1 < 0:
            continue
        loop_num = (k-i-1)//loop_len
        score_sum = score + max(0, loop_score)*loop_num
        max_score = max(score_sum, max_score)
print(max_score)

Measured memory_bytes: 80936
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

ll solve(ll L, ll R, ll S) {
	vector<ll> memo(61 * 4, -1);
	function<ll(int,bool,bool)> rec = [&](int i, bool gtL, bool ltR) -> ll {
		ll &r = memo[(i + 1) * 4 + gtL * 2 + ltR];
		if (r != -1) return r;
		if (i == -1)
			return 0;
		int Li = L >> i & 1, Ri = R >> i & 1, Si = S >> i & 1;
		r = 0;
		bool ok = false;
		rep(b, 2) {
			if (Si < b) continue;
			if (!gtL && Li > b) continue;
			if (!ltR && Ri < b) continue;
			ll x = rec(i - 1, gtL || Li < b, ltR || Ri > b);
			if (x != -2) {
				ok = true;
				r |= x;
				if (b == 1)
					r |= 1LL << i;
			}
		}
		return ok ? r : -2;
	};
	return rec(59, false, false);
}

int main() {
	long long A; long long B;
	while (~scanf("%lld%lld", &A, &B)) {
		vector<ll> bounds;
		ll a = A, b = B;
		for (int r = 59; r >= 0; -- r) {
			if ((A ^ B) >> r & 1) {
				ll mask = (1LL << (r + 1)) - 1;
				a &= mask;
				b &= mask;
				bounds.push_back(1LL << r);
				for (int k = r - 1; k >= 0; -- k) {
					if (b >> k & 1) {
						bounds.push_back((1LL << r) | (1LL << (k + 1)));
						break;
					}
				}
				bounds.push_back(a + (1LL << r));
				bounds.push_back(1LL << (r + 1));
				break;
			}
		}
		bounds.push_back(a);
		bounds.push_back(b + 1);
		sort(bounds.begin(), bounds.end());
		bounds.erase(unique(bounds.begin(), bounds.end()), bounds.end());
		ll ans = 0;
		rep(ix, (int)bounds.size() - 1) {
			ll L = bounds[ix], R = bounds[ix + 1];
			ll x = solve(a, b, L);
			if (x == L)
				ans += R - L;
		}
		printf("%lld\n", ans);
	}
	return 0;
}


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

int main(){
    int n,count = 0;
    cin >> n;
    vector<int> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }
    for(int i = 0; i < n; i++){
        int minj = i;
        for(int j = i; j < n; j++){
            if(A[j] < A[minj]){
            minj = j;
            }
        }
        if(i != minj){
        int b = A[i];
        A[i] = A[minj];
        A[minj] = b;
        count++;
        }
        }
for(int i =0; i< n; i++){
    if(i < n -1)
    cout << A[i] << " ";
    if(i == n - 1)
    cout << A[i] << endl;
}
cout << count << endl;
}


Measured memory_bytes: 3108
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
 String ans = (a>999)? "ABD" : "ABC" ;
		// 出力
		System.out.println( ans );
	}
}

Measured memory_bytes: 22868
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n;
   double a, ans = 0;
   cin >> n;
   for(int i = 0; i < n; i ++)
   {
      cin >> a;
      ans += 1/a;
   }
   ans = 1/ans;
   printf("%.6lf\n", ans);
   return 0;
}


Measured memory_bytes: 384
//AtCoder ABC073 C - Write and Erase
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll N;
    cin>>N;
    unordered_map<ll,ll> mp;
    for(ll i=0;i<N;++i){
        ll a;
        cin>>a;
        mp[a]^=1;
    }    
    ll ans=0;
    for(const auto& m:mp){
        ans+=m.second;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4388
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <tuple>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG

int main(void){
  char s;
  cin >> s;

  if (isupper(s)) {
    cout << "A" << endl;
  } else {
    cout << "a" << endl;
  }
}

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

template<typename T>
vector<T> cumulative_sum(vector<T> &v) {
    vector<T> sum(v.size() + 1);
    rep(i,v.size()){
        sum[i+1] = sum[i] + v[i];
    }
    return sum;
}


int main(void){
    ll n,m,k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];
    auto a_sum = cumulative_sum(a);
    auto b_sum = cumulative_sum(b);
    int res = 0;
    rep(i, a_sum.size()){
        ll rem = k - a_sum[i];
        if (rem < 0) break;
        int b_num = ub(b_sum, rem) - 1;
        res = max(res, i + b_num);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 9592
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std; 
typedef long long ll;
typedef unsigned long long int ull;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>  
#define ff first
#define ss second
#define pb push_back
#define Inf  1e18
#define inf -1e18
#define mod 1000000007
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll,ll>;
using umll = unordered_map<ll,ll>;
using sll = set<ll>;
using msll = multiset<ll>;
 
 
ll MUL(ll A,ll B){
  return (A%mod*B%mod)%mod;
}
 
ll ADD(ll A,ll B){
  return (A%mod+B%mod)%mod;
}
 
ull power(ll A,ll B) { 
    ull RES = 1;      
    while (B > 0) 
    { 
        if (B & 1) 
            RES = RES*A;  
        B = B>>1;  
        A = A*A;  
    } 
  return RES; 
}

 
void testcases(int cases){
  
 int N,K;
  cin >> N >> K;
  int arr[N+2];
  for(int i = 1 ;i <= N;i ++){
    cin >> arr[i];
  }
  sort(arr+1,arr+1+N);
  int ans=0;
  for(int i = 1 ;i <= K ; i ++)
    ans+=arr[i];
  cout << ans << "\n";
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
    ll t;
    t = 1;
   // cin >> t;
    ll Case =1 ;
    while(t--)
    {
      testcases(Case++);
    }
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
		public static void main(String args[]) {
			Scanner sc = new Scanner(System.in);
			int len = sc.nextInt();
			int array[] = new int[len];
			String swap[] = new String[2];
			String str;
			int temp;
			
			for(int i = 0; i < len; i++) {
				array[i] = i;
			}
			
			int cnt = sc.nextInt();
			for(int i = 0; i < cnt; i++) {
				str = sc.next();
				swap[0] = str.split(",", 2)[0];
				swap[1] = str.split(",", 2)[1];
				temp = array[Integer.parseInt(swap[0])-1];
				array[Integer.parseInt(swap[0])-1] = array[Integer.parseInt(swap[1])-1];
				array[Integer.parseInt(swap[1])-1] = temp;
				
			}
			sc.close();
			
			for(int i = 0; i < len; i++) {
				System.out.printf("%d\n", array[i]+1);
			}
	}
}


Measured memory_bytes: 26220
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef std::vector<ll> lls;
#define MIN(a, b) ( ((a)<(b)) ? (a) : (b) )
#define MAX(a, b) ( ((a)>(b)) ? (a) : (b) )

void cinv(lls& llVec, ll n) {
	ll val;
	llVec.reserve((size_t)(n));
	for (ll i = 0; i < n; i++) {
		cin >> val;
		llVec.push_back(val);
	}
}


int main()
{
	ll A, B, x;

	cin >> A >> B;

	x = (B - 1 + (A-1-1) ) / (A - 1);

	cout << x << '\n';

	return 0;
}



Measured memory_bytes: 256
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

A,B,C = LI()

if A==B and A!=C:
    print('Yes')
    exit()
if A==C and A!=B:
    print('Yes')
    exit()
if B==C and A!=B:
    print('Yes')
    exit()
print('No')

Measured memory_bytes: 38384
import java.io.*;
import static java.lang.Math.*;
import static java.lang.Integer.parseInt;

class Main {
   final static PrintWriter out = new PrintWriter( System.out );

   final static BufferedReader in =
         new BufferedReader( new InputStreamReader( System.in ) );

   static int lcs(String a, String b){
      final int alen = a.length();
      final int blen = b.length();
      int dp[][] = new int[alen+1][blen+1];
      int maxl = 0;

      for(int i=0; i<alen; ++i){
         for(int j=0; j<blen; ++j){

            if( a.charAt(i) == b.charAt(j) )
               dp[i+1][j+1] = dp[i][j] + 1;
            else
               dp[i+1][j+1] = max( dp[i][j+1], dp[i+1][j] );

            maxl = max(maxl, dp[i+1][j+1]);
         }
      }
      return (maxl);
   }

   public static void main(String[] args) throws IOException {
      final int N = parseInt( in.readLine() );
      for(int i=0; i<N; ++i){
         String a = in.readLine();
         String b = in.readLine();
         out.println( lcs(a,b) );
      }
      out.flush();
   }
}




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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()

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

int dy[4]={-1,1,0,0};
int dx[4]={0,0,1,-1};

string s;
int main(){
    ios::sync_with_stdio(false);
    cin >> s;
    int ans = 0;
    REP(i,s.size()-1) {
        if(s[i]!=s[i+1]) ans++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 512
import sys

iT = int(input())
aR = [[int(x) for x in sLine.split()] for sLine in sys.stdin.readlines()]

def fGcd(iX,iY):
    while iY:
        iX,iY= iY,iX%iY
    return iX

def fFunc(iA,iB,iC,iD):
    ig = fGcd(iB,iD)
    if iA < iB or iD < iB:
        return False
    elif iC >= iB :
        return True
#こういうことか。やっぱりわかってないなぁ。つらい
#   elif iC < iA % iB :
#       return False
#   elif iB <= ig + iC :

# AtCoder の解法
    elif iB <= iC +ig - iA % ig  :
        return True
    else:
        return False

for eR in aR:
    if fFunc(*eR) :
        print("Yes")
    else:
        print("No")


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

int main()
{
	int a, b, c, x, y;
	int min;

	cin >> a >> b >> c >> x >> y;

	if (x >= y)
	{
		min = c*2*x;
		for (int i = 0; i <= x; ++i)
		{
			if (min > a*i + c*(x-i)*2 + b*max(0,y-(x-i)))
			{
				min = a*i + c*(x-i)*2 + b*max(0,y-(x-i));
			}
		}
	}else{
		min = c*2*y;
		for (int i = 0; i <= y; ++i)
		{
			if (min > b*i + c*(y-i)*2 + a*max(0,x-(y-i)))
			{
				min = b*i + c*(y-i)*2 + a*max(0,x-(y-i));
			}
		}
	}

	cout << min << endl;

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
int pos[110];
int ge[110][110];
int main()
{
	scanf("%d %d",&n,&m);
	int a,b;
	for(int i=1;i<=m;i++)
	{
		scanf("%d %d",&a,&b);
		pos[a]++,pos[b]++;
		ge[a][b]=ge[b][a]=1;
	}
	bool flag;
	int x,sum=0;
	while(1)
	{
		flag=0;
		for(int i=1;i<=n;i++)
		{
			if(pos[i]==1)
			{
				sum++;
				x=i;
				flag=1;
				pos[i]--;
				break;
			}
		}
		if(!flag)break;
		for(int i=1;i<=n;i++)if(ge[x][i]==1)pos[i]--;
	}
	printf("%d",sum);
	return 	0;
}

Measured memory_bytes: 256
from functools import reduce
import heapq as hq
from sys import stdin
 
MOD = 10**9+7
N,M = map(int,stdin.readline().split())
S,T = map(int,stdin.readline().split())
S,T = S-1,T-1

inf = float('inf')
 
E = [[] for _ in range(N)]
lines = stdin.readlines()
for line in lines:
  u,v,d = map(int,line.split())
  E[u-1].append((v-1,d))
  E[v-1].append((u-1,d))
 
dS = [inf]*N
dT = [inf]*N
 
Q = [(0,S,False),(0,T,True)]

D = inf

 
while Q:
  d,v,f = hq.heappop(Q)
  if d*2 > D:
    break

  dM = dT if f else dS
  dN = dS if f else dT
  if dM[v] > d:
    dM[v] = d
    for u,dd in E[v]:
      if dM[u] > d and (d+dd)*2 <= D:
        hq.heappush(Q,(d+dd,u,f))
   
  D = min(dN[v]+d,D)
 
del Q


def helper(start,dist):
  cnts = [0]*N
  cnts[start] = 1

  for d,v in sorted((d,v) for v,d in enumerate(dist) if d != inf):
    c = cnts[v]
    for u,dd in E[v]:
      if dd+d == dist[u]:
        cnts[u] = (cnts[u]+c) % MOD

  return cnts

Sn = helper(S,dS)
Tn = helper(T,dT)


def it():
  for v in range(N):
    if dS[v] != inf:
      ds = dS[v]
      if dT[v] == ds and ds*2 == D:
        yield Sn[v]*Tn[v] % MOD
      else:
        for u,d in E[v]:
          if abs(dT[u]-ds) < d and ds+d+dT[u] == D:
            yield Sn[v]*Tn[u] % MOD


X = tuple(it())
 
total = reduce(lambda a,b:(a+b)%MOD, X,0)
total = total*total % MOD
 
sub = reduce(lambda a,b:(a+b)%MOD, map(lambda x: x*x % MOD, X),0)

print((total-sub)%MOD)

Measured memory_bytes: 102888
#include <stdio.h>
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int N;
    cin >> N;
    
    vector<int> d(N);
    for (int i = 0; i < N; i++){
        cin >> d[i];
    }

    int sum = 0;
    for (int i = 0; i < N - 1; i++){
        for (int j = i + 1; j < N; j++){
            sum += d[i] * d[j];
        }
    }

    cout << sum << endl;
    
    return 0;
}


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

int main()
{
	int a, b, c, k, flag = 1;  // a is red, b is green, c is blue
	//blue > green > red 
	//c > b > a
	cin >> a >> b >> c >> k;
	while (a >= b)
	{
		k--;
		b *= 2;
		if (k < 0)
		{
			flag = 0;
			break;
		}
	}
	while (b >= c)
	{
		k--;
		c *= 2;
		if (k < 0)
		{
			flag = 0;
			break;
		}
	}
	if (flag == 1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 3136
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    string S;
    cin>>S;
    if(S[0]=='7'||S[1]=='7'||S[2]=='7')cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define pb push_back
#define x first
#define y second
using namespace std;
const int N = 404;
int n, m, gx[4] = {-1, 1, 0, 0}, gy[4] = {0, 0, -1, 1};
pair < int , int > P[N][N];
char A[N][N];
pair < int , int > Find(int a, int b)
{
    if (P[a][b].x < 0 || P[a][b].y < 0)
        return make_pair(a, b);
    P[a][b] = Find(P[a][b].x, P[a][b].y);
    return P[a][b];
}
int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++)
        scanf("%s", &A[i]);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
        {
            if (A[i][j] == '#')
                P[i][j] = {-1, 0};
            else
                P[i][j] = {0, -1};
        }
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
        {
            for (int h = 0; h < 4; h++)
            {
                int ta = i + gx[h], tb = j + gy[h];
                if (ta < 0 || ta >= n || tb < 0 || tb >= m)
                    continue;
                if (A[i][j] == A[ta][tb])
                    continue;
                auto p1 = Find(i, j);
                auto p2 = Find(ta, tb);
                if (p1.x != p2.x || p1.y != p2.y)
                {
                    P[p1.x][p1.y].x += P[p2.x][p2.y].x;
                    P[p1.x][p1.y].y += P[p2.x][p2.y].y;
                    P[p2.x][p2.y] = p1;
                }
            }
        }
    long long tot = 0;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
        {
            if (P[i][j].x < 0 || P[i][j].y < 0)
                tot += 1LL * P[i][j].x * P[i][j].y;
        }
    return !printf("%lld", tot);
}

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int sum = a + b + c;
  if (sum > 21) cout << "bust" << endl;
  else cout << "win" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int MAXN = 1e6+1000;
bool ok[MAXN];

main(){
     ios_base::sync_with_stdio(false);
     cin.tie(nullptr);
     int N; cin >> N;
     memset(ok, true, sizeof(ok));
     set<int> s;
     for(int i = 0; i < N; i++){
          int n; cin >> n;
          if(s.count(n)) ok[n] = false;
          else s.insert(n);
     }
     int ans = 0;
     for(auto x : s){
          if(ok[x]) ans++;
          for(int j = 2*x; j < MAXN; j += x) ok[j] = false;
     }
     cout << ans;
}

Measured memory_bytes: 14008