akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
#define endl "\n"
#define ciosup cin.tie(0);ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int main()
{
    ciosup;
    int n;
    cin >> n;
    vint a(n);
    REP(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    int pos = 0, neg = 0;
    REP(i,n){
        if (a[i]>= 0) pos++;
        else neg++;
    }
    if (pos == 0){
        pos++;
        neg--;
    }else if (neg == 0){
        neg++;
        pos--;
    }
    ll ans = 0;
    REP(i,n){
        if (i < neg){
            ans -= a[i];
        }else{
            ans += a[i];
        }
    }
    cout << ans << endl;
    int x = a[0], y;
    FOR(i, neg,n - 1){
        y = a[i];
        cout << x << " " << y << endl;
        x = x - y;
    }
    a[0] = x;
    x = a[n - 1];
    REP(i, neg)
    {
        y = a[i];
        cout << x << " " << y << endl;
        x = x - y;
    }
}

Measured memory_bytes: 2304
d = int(input())
c = {}
s = []
C = list(map(int, input().split()))
for i in range(26):
    c[i] = C[i]
for i in range(d):
    s.append(list(map(int, input().split())))

t = 0
while t < 365:
    for i in range(26):
        if t < 365:
            t += 1
            a = -1
            b = 0
            for j in range(26):
                if b < s[t-1][j]:
                    a = j
                    b = s[t-1][j]
            print(a+1)
        else:
            break;
        if t < 365:
            t += 1
            print(26-i)
        else:
            break;

Measured memory_bytes: 9544
#include<bits/stdc++.h>
using namespace std;
int a,b,f,z;
int main()
{
    cin>>a>>b;
    while(a>0)
    {
    	f+=a%10;
    	a/=10;
	}
	if(f%3==0)
	{
		cout<<"Possible\n";
		return 0;
	}
	while(b>0)
    {
    	z+=b%10;
    	b/=10;
	}
	if(z%3==0||(f+z)%3==0)
	{
		cout<<"Possible\n";
		return 0;
	}
	cout<<"Impossible\n";
    return 0;
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m,w;
	cin>>n>>m;
	vector<pair<bool,ll>>v(n+2);
	for(int i=0;i<m;i++){
		cin>>w;
		v.at(w).first=true;
	}
	v.at(n).second=1;
	for(int i=n-1;i>=0;i--){
		if(v.at(i).first==true){
			v.at(i).second=0;
		}else{
			v.at(i).second=(v.at(i+1).second+v.at(i+2).second)%1000000007;
		}
	}
	cout<<v.at(0).second<<endl;
}


Measured memory_bytes: 1792
import Control.Applicative
import Control.Monad

main :: IO ()
main = do
  n <- readLn
  unless (n == 0) $ do
    solve <$> f <*> getLine >>= putStrLn
    main
  where
    f = map read <$> words <$> getLine

solve :: [Int] -> String -> String
solve ks ss = zipWith f ss (cycle ks)
  where
    tbl = cycle (['Z', 'Y' .. 'A'] ++ ['z', 'y' .. 'a'])
    f c d = head $ drop d $ dropWhile (/= c) tbl



Measured memory_bytes: 4168
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int N = 1e3+10;

struct point {
    double x,y;
//    point(double x=0,double y=0):x(x),y(y){}
//    bool operator < (const point &rhs)const{
//        return atan2(y,x) < atan2(rhs.y, rhs.x);
//    }
}p[N];

bool cmp(point a,point b){
	return atan2(a.y,a.x)<atan2(b.y,b.x);
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;++i){
        scanf("%lf%lf",&p[i].x,&p[i].y);
    }
    sort(p,p+n,cmp);
//    for(int i=0;i<n;i++)cout << p[i].x << " " << p[i].y << endl;
    double ans = 0;
    for(int i=0;i<n;++i){
        double x = 0,y = 0;
        int j = i;
        do{
            x += p[j].x, y += p[j].y;
            ans = max(ans,x*x+y*y);
            j = (j+1)%n;
        }while(i!=j);
    }
    printf("%.15lf\n",sqrt(ans));
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getlist():
    return list(map(int, input().split()))
import heapq
import bisect
import copy
import math
from collections import defaultdict, Counter

def warshall_floyd(d, N):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i * N +j] = min(d[i * N +j], d[i * N + k] + d[k * N + j])
    return d
MOD = 10**9 + 7
INF = 10**10

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def make_divisors(n):
    divisors = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            divisors.append(i)
            if i ** 2 != n:
                divisors.append(n // i)

    return divisors

def judge(anums, cand, k):
    anums = sorted([num % cand for num in anums])
    rem = sum([(cand - num) for num in anums])
    acc = [0]
    tmp = 0
    ue = 0
    # print(rem, anums)
    for num in anums:
        tmp += num
        acc.append(tmp)

    if acc[rem // cand] <= k:
        return True
    else:
        return False


def main():
    n,k = getlist()
    anums = getlist()

    candidates = make_divisors(sum(anums))
    # print(candidates)
    for cand in sorted(candidates, key=lambda x: -x):
        res = judge(anums, cand, k)
        if res:
            print(cand)
            return





if __name__ == '__main__':
    main()

"""
9999
3

2916
"""

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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

vector<int64_t> fact, fact_inv;

void create_mod_tables(int num){
    fact.assign(num+1, 1);
    fact_inv.assign(num+1, 1);
    for(int i=1; i<=num; i++) fact[i] = fact[i-1] * i % MOD;
    fact_inv[num] = inv_mod(fact[num]);
    for(int i=num; i>0; i--) fact_inv[i-1] = fact_inv[i] * i % MOD;
}

int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}

// P = {P[0], P[1], ..., P[N]}
int64_t LagrangeInterpolation(vector<int64_t> P, int64_t T){
    int N = P.size()-1;
    if(T <= N) return P[T];
    int64_t Qi = 1, QTA = 1;
    for(int i=0; i<=N; i++){
        if(i) mul(Qi, MOD-i);
        mul(QTA, T-i);
    }
    int64_t ans = 0;
    for(int i=0; i<=N; i++){
        add(ans, P[i] * inv_mod(Qi) % MOD * QTA % MOD * inv_mod(T-i));
        mul(Qi, (i+1) * inv_mod(MOD-N+i) % MOD);
    }
    return ans;
}

int64_t calc(int N){
    int64_t ans = 0;
    for(int i=0; 2*i+5<=N; i++) add(ans, comb_mod(i+4, 4) * comb_mod(N-2*i+5, 10));
    return ans;
}

void solve(){
    int N;
    cin >> N;
    int R = N%2;
    N /= 2;
    vector<int64_t> V(20);
    for(int i=0; i<20; i++) V[i] = calc(2*i+R);
    int64_t ans = LagrangeInterpolation(V, N);
    cout << ans << endl;
}

int main(){
    create_mod_tables(100);
    int T;
    cin >> T;
    while(T--) solve();
    return 0;
}


Measured memory_bytes: 3580
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Shift only
            int N = int.Parse(Console.ReadLine());
            var A = ReadLine();
            int count = 0;

            while (true)
            {
                int even = 0;

                for (int i = 0; i < N; i++)
                {                   
                    if (A[i] % 2 == 0)
                    {
                        A[i] /= 2;
                        even++;
                    }
                    else
                    {
                        break;
                    }
                }

                if (even == N)
                {
                    count++;
                }
                else
                {
                    break;
                }
            }            

            Console.WriteLine(count);
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).OrderBy(x => x).ToList();
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>

using namespace std;

int min(int x, int y)
{
	return (x > y) ? y : x;
}

int gcd(int x, int y)
{
	int n = min(x, y);

	for (; n >= 1; n--) {
		if (x % n == 0 && y % n == 0)
			return n;
	}
	return 1;
}

int main()
{
	int tate, yoko;

	cin >> yoko >> tate;

	cout << (tate + 1) + (yoko) + 1 - gcd(tate, yoko) - 1 << endl;

	return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#define rep(i, n) for (i = 0; i < n; i++)
#define int long long
using namespace std;

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

int n, m;
string s;
string t;

signed main() {
	cin >> n >> m >> s >> t;
	
	int l = n * m / gcd(n, m);
	int i;
	map<int, char> dict;
	
	rep(i, n) {
		dict[i * l / n] = s[i];
	}
	
	rep(i, m) {
		if (dict.find(i * l / m) == dict.end()) continue;
		if (dict[i * l / m] == t[i]) continue;
		cout << "-1" << endl; return 0;
	}
	
	cout << l << endl;
	return 0;
}

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

int main(){
  string s;
  int flag = 1;
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'b'){
      if(s[s.size()-(i+1)] != 'd'){
        flag = 0;
        break;
      }
    }
    if(s[i] == 'q'){
      if(s[s.size()-(i+1)] != 'p'){
        flag = 0;
        break;
      }
    }
    if(s[i] == 'd'){
      if(s[s.size()-(i+1)] != 'b'){
        flag = 0;
        break;
      }
    }
    if(s[i] == 'p'){
      if(s[s.size()-(i+1)] != 'q'){
        flag = 0;
        break;
      }
    }
  }
  if(flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int count = 0,a = n/10;
    if(a == 0)
    {
        cout << n << endl;
    }
    else if(a > 0 && a < 10)
    {
        cout << 9 << endl;
    }
    else if(a < 100 && a > 9)
    {
        cout << n-90 << endl;
    }
    else if(a<1000 && a>99)
    {
        cout << 909 << endl;
    }
    else if(a<10000 && a>999)
    {
        cout << n+909-9999 << endl;
    }
    else
    {
        cout << 90000+900+9 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)




int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    cout << a + b + c - max(a, max(b, c)) + max(a, max(b, c)) * pow(2, k) << endl;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
    long[][] c = new long[51][51];

    void solve(Scanner sc, PrintWriter pw) {
        int N = sc.nextInt();
        int K = sc.nextInt();
        long S = sc.nextLong();
        long T = sc.nextLong();
        long[] data = new long[N];
        for (int i = 0; i < N; i++) {
            data[i] = sc.nextLong();
        }
        for (int i = 0; i <= N; i++) {
            c[i][0] = 1;
            for (int j = 1; j <= i; j++) {
                c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
            }
        }
        long[] sum = new long[(N + 1)];
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= Math.min(i, K); j++) {
                sum[i] += c[i][j];
            }
        }
        long result = 0;
        List<Long> nums = new ArrayList<>();
        for (long mask = 0; mask < (1L << 18); mask++) {
            if (((T ^ S) & mask) != mask) {
                continue;
            }
            boolean isAdd = (Long.bitCount(mask) % 2) == 0;
            nums.clear();
            for (int i = 0; i < N; i++) {
                if ((data[i] & S) != S) {
                    continue;
                }
                if ((data[i] | T) != T) {
                    continue;
                }
                nums.add(data[i] & mask);
            }
            Collections.sort(nums);
            int begin = 0;
            int nextBegin;
            while (begin < nums.size()) {
                nextBegin = begin + 1;
                while (nextBegin< nums.size() && nums.get(nextBegin).equals(nums.get(nextBegin - 1))) {
                    nextBegin++;
                }
                result += (isAdd ? 1L : -1L) * (sum[nextBegin - begin]);
                begin = nextBegin;
            }
        }
        pw.println(String.format("%d", result));
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        new Main().solve(sc, pw);
        pw.flush();
        pw.close();
        sc.close();
    }
}


Measured memory_bytes: 62996
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i<n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0);
#define vint(v,n) vector<int> v(n); REP(i,n) scanf("%lld", &v[i]);
#define vstr(v,n) vector<string> v(n); REP(i,n) scanf("%lld", &v[i]);
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された

    if(n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である

    // 6の倍数前後の数を使って試し割りをする
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }

    return true;
}
//階乗
int factorial(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
int k=0,n=0, m=0, l=0,r=0,a=0, b=0, c=0, d=0,e=0,ans=1000,ans2=0,x=0,y=0;
string s,t,S;
signed main() {
  ios_base::sync_with_stdio(false);
    cin >> n;
    vector<int>A(n+1);
        REP2(x,100){
            REP2(y,100){
                REP2(z,100){
                  int t =(x*(x+y)+y*(y+z)+z*(z+x));
                    if(t<=n){
                        A[t]++;
                    }
                }
            }
        }
       REP2(i,n) cout <<A[i]<<endl;

}


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

int main()
{
    int x, y;
    cin >> x >> y;

    int a[] = {4, 6, 9, 11};

    if (x == 2 || y == 2) return cout << "No" << endl, 0;

    for (int i = 0; i < 4; i++) {
        if (x == a[i]) x = 0;
        if (y == a[i]) y = 0;
    }

    cout << (x && y ? "Yes" : (!x && !y ? "Yes" : "No")) << endl;

    return 0;
}


Measured memory_bytes: 256
N=int(input())
A=[int(i) for i in input().split(' ')]
for i in range(len(A)):
  A[i]-=i+1
A.sort()
if len(A)%2==1:
  b=A[(len(A)-1)//2]
else:
  b=A[(len(A))//2-1]
s=0
for i in range(len(A)):
  s+=abs(A[i]-b)
print(s)

Measured memory_bytes: 25196
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>
 
// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std
 
Jehian Norman Saviero;
 
// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;
 
// MACROS FOR PRINT
#define nl printf("\n")
 
// MACROS FOR ATTRIBUTE
#define fi first
#define se second
 
// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))
 
// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scd(x) scanf("%lf", &x)
#define scld(x) scanf("%Lf", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

int main() {
	ll A, B;
	scll(A), scll(B);
	printf("%lld\n", A * B / __gcd(A,B));
	return 0;
}


Measured memory_bytes: 256
N = int(input())

ans = float("inf")
for a in range(1, N+1):
    if a * a > N: break
    if N % a ==0:
        b = N / a
        f = max(a, b)
        keta = 0
        while True:
            keta += 1
            if 10 ** keta > f:
                break
        ans = min(ans, keta)
print(ans)


Measured memory_bytes: 65088
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int a=stdIn.nextInt(),b=stdIn.nextInt();
		System.out.print(a%3==0||b%3==0||(a+b)%3==0?"Possible":"Impossible");
	}
}

Measured memory_bytes: 21844
#include<iostream>
using namespace std;
#define endl '\n'

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char n;
    cin >> n;
    if(n>=97&&n<=122){
        cout << "a" << endl;
    }else{
        cout << "A" << endl;
    }
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;


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

    cin>>a>>b;
    cout << 6-a-b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

struct UnionFind {
    vector<int> par;
	vector<int> cnt;

    UnionFind(int N) : par(N), cnt(N) {
        for (int i = 0; i < N; i++) {par[i] = i; cnt[i] = 1;}
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    void merge(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
		cnt[ry] = cnt[rx] + cnt[ry];
    }

	int count(int x) {
		return cnt[root(x)];
	}
};

void solve() {
    ll n, m;
    cin >> n >> m;
    vll a(m), b(m);
    rep(i, m) {
        cin >> a[i] >> b[i];
        --a[i];
        --b[i];
    }
    UnionFind uf(n);
    rep(i, m) {
        uf.merge(a[i], b[i]);
    }
    ll ans = 0;
    rep(i, n) chmax(ans, (ll)uf.count(i));
    cout << ans << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 14104
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    T r;
    while((r=a%b)) {
        a = b; b = r;
    }
    return b;
}
bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};

bool more_body(ll w1, ll s1, ll w2, ll s2){
    return s1 * (w2 + s2) > s2 * (w1 + s1);
}

int main(){
    ll A, B, C, D, E, F; cin >> A >> B >> C >> D >> E >> F;
    
    ll ca = 100 * A, cb = 100 * B;
    ll max_w = ca; ll max_s = 0;
    for (ll a = 0;  a * ca <= F; a++) {
        for (ll b = 0; b * cb <= F; b++) {
            for (ll c = 0; c * C <= F; c++) {
                for (ll d = 0; d * D <= F; d++) {
                    ll w = a * ca + b * cb;
                    ll s = c * C + d * D;
                    if(w + s > F) continue;
                    if(more_body(w, s, 100, E)) continue;
                    if (more_body(w, s, max_w, max_s)){
                        max_w = w;
                        max_s = s;
                    }
                }
            }
        }
    }
    cout << (max_w + max_s) << " " << max_s << endstr;
    return 0;
}


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

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        String S = scan.next();
        char sChar[] = S.toCharArray();

        long answer = 1;
        char prev = sChar[0];
        for(int i = 1; i < N ; i++) {
            if(prev != sChar[i]) {
                answer++;
                prev = sChar[i];
            }
        }

        os.println(answer);

    }
}

Measured memory_bytes: 26580
#include <stdio.h>

int main(){
  int a[5],k;
  for(int i = 0; i < 5; ++i){
    scanf("%d\n",&a[i]);
  }
  scanf("%d",&k);
  int dis = a[4] - a[0];
  int flag = 0;
  if(dis > k) flag = 1;
  if(flag == 0) printf("Yay!\n");
  else printf(":(\n");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b);
#define chmin(a, b) a = min(a, b);
using namespace std;
using ll = long long;
using P = pair<int,int>;

int d, c[26];
int s[365][26];

int main() {
	cin >> d;
	rep(i, 26) cin >> c[i];
	rep(i, d) rep(j, 26) cin >> s[i][j];
	int mx = -1;
	int imx;
	rep(j, 26) {
		int t = 0;
		rep(i, d) t += s[i][j];
		if (t > mx) imx = j;
	}
	rep(i, d) cout << imx << endl;

	
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;

const int D = 60;
const int MAX_N = 200000; 
int to[D][MAX_N];

int main() {
  int n; ll k;
  cin >> n >> k;
  rep(i, n) {
    cin >> to[0][i];
    to[0][i]--;
  }
  rep(i, D-1) {
    rep(j, n) to[i+1][j] = to[i][to[i][j]];
  }

  int v = 0;
  for(int i = D-1; i >=0; i--) {
    ll l = 1ll << i;
    if(l <= k) {
      v = to[i][v];
      k -= l;
    }
  }
  cout << v + 1 << endl;
  return 0;
}

Measured memory_bytes: 50476
#今回は自力で組んでみます。図は見ましたが。
n = int(input())
a = [0]*n
b = [0]*n
c = [0]*n
dpa = [0]*n
dpb = [0]*n
dpc = [0]*n
for i in range(n):
    a[i], b[i], c[i] = map(int, input().split())
dpa[0] = a[0]
dpb[0] = b[0]
dpc[0] = c[0]
for i in range(1,n):
    dpa[i] = a[i]+max(dpb[i-1], dpc[i-1])
    dpb[i] = b[i]+max(dpc[i-1], dpa[i-1])
    dpc[i] = c[i]+max(dpa[i-1], dpb[i-1])
print(max(dpa[-1], dpb[-1], dpc[-1]))


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

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a_list;
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        a_list.emplace_back(tmp);
    }
    sort(a_list.begin(), a_list.end());
    int num_elems = a_list.at(n - 1);
    int num_choices = -1;
    int max_diff = -(1 << 29);
    for (int i = 0; i < n - 1; i++) {
        int a = a_list.at(i);
        int diff = min(a, num_elems - a);
        if (diff > max_diff) {
            num_choices = a;
            max_diff = diff;
        }
    }
    cout << num_elems << " " << num_choices << "\n";
}


Measured memory_bytes: 892
n=int(input())
t,a=map(int, input().split())
h=list(map(int, input().split()))
m = 10**10

for i in range(n):
    T = t-h[i]*0.006
    if m > abs(a-T):
        m = abs(a-T)
        ans = i+1
print(ans)

Measured memory_bytes: 3060
import math
n = int(input())
x = []

if n == 0:
    print(0)
else:
    if n > 0:
        a = math.ceil(math.log2(n * 3 + 1) / 2) 
        b = 2 * a - 1
        x = [[]] * (b)
    else:
        a = math.ceil(math.log2((-3 * n + 2) / 2) / 2)
        b = 2 * a
        x = [[]] * (b)
    while n != 0:
        if n > 0:
            a = math.ceil(math.log2(n * 3 + 1) / 2) 
            b = 2 * a - 1 
            n = n - (2) ** (b-1)
            x[-b] = "1"  
        else:
            a = math.ceil(math.log2((-3 * n + 2) / 2) / 2)
            b = 2 * a
            n = n - (-2) ** (b-1)
            x[-b] = "1"
x_replace = ["0" if i != "1" else i for i in x]
x_replace = "".join(x_replace)
print(x_replace)

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

using namespace std; using ll=long long; const int INF=1e9; using P=pair<int,int>;

const ll m = 1e9+7; vector<ll> sm(200005);
void sm_bulid() {
	sm[0]=1;for(ll i=1;i<200005;i++) sm[i]=sm[i-1]*i%m;
}
int main() {
  sm_bulid();
  ll x,y; cin>>x>>y;
  if (x==y-1 || x==y+1) {
    cout<<sm[x]*sm[y]%m<<endl;
  } else if (x==y) {
    cout<<sm[x]*sm[y]*2%m<<endl;
  } else {
    cout<<0<<endl;
  }
}

Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		double[] p=new double[N];
		for(int i=0; i<N; i++) {
			p[i]=sc.nextDouble();
		}
		Arrays.sort(p);
		double ans = 0d;
		ans=p[0];
		for(int i=1; i<N; i++) {
			ans=(ans+p[i])/2.0;
		}
		p(ans);
	}
	public static void p(Object o) {
		System.out.println(o);
	}
}

Measured memory_bytes: 23252
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }

    let mut count = 0;
    for (i, &e) in a.iter().enumerate() {
        if (i + 1) % 2 == 1 && e % 2 == 1 {
            count += 1;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 2200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll dpx[] = {0,-1, 1,0};
ll dpy[] = {1,0,0,-1};

int main(){
  ll a, b, c, k;
  cin >> a >> b >> c>>k;
  if(k%2==0){
    print(a - b);
  }
  else{
    print(b - a);
  }
}


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

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

    bool flg=false;
    for(int i=0; i<s.size(); i++){
        flg=true;
        for(int j=0; j<s.size(); j++){
            if(s[(i+j)%s.size()]!=t[j]) flg=false;
        }
        if(flg) break;
    }

    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

lli a, b, c, d;

int main(void){
    cin >> a >> b >> c >> d;
    lli ans = max({a*c, a*d, b*c, b*d});
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
using namespace std;
#define int long long
#define eb emplace_back
#define ef emplace_front
#define pb push_back
#define rep(i, x, n) for (int i = x; i < n; ++i)
#define mp make_pair
#define fi first
#define se second
#define ii pair<int, int>
#define endl '\n'
#define vi vector<int>
#define vii vector<pair<int, int>>
#define reverse(s) reverse(s.begin(), s.end())
#define ld long double
#define vs vector<string>
#define inf INT_MAX
#define vc vector<char>
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define vb vector<bool>
#define lb(a, x) lower_bound(a.begin(), a.end(), x)
#define ub(a, x) upper_bound(a.begin(), a.end(), x) 
#define vvi vector<vi>
#define mine(a) min_element(a.begin(),a.end())
#define maxe(a) max_element(a.begin(), a.end())
#define iota(a,i) iota(a.begin(),a.end(),i)
int findXOR(int n)
{
    int mod = n % 4;
    if (mod == 0)
        return n;
    else if (mod == 1)
        return 1;
    else if (mod == 2)
        return n + 1;
    else if (mod == 3)
        return 0;
}
int findXOR(int l, int r){
    return (findXOR(l - 1) ^ findXOR(r));
}
signed main() {
    fastio;
    int a, b;
    cin >> a >> b;
    if (a == b) {
        cout << a;
        return 0;
    }
    a = max(a, (int)1);
    cout << findXOR(a, b);
    return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;
const int inf = 1e9;


int n, m;
int L[maxn], R[maxn];

bool isect(int l, int r, int a, int b) {
    return max(l,a) <= min(r,b);
}

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

    cin>>n>>m;
    for (int i=1; i<=n; i++) {
	cin>>L[i]>>R[i];
    }



    map<int,int> a;
    multiset<int> ms;
    for (int i=1; i<=m; i++) {
	a[i] = 0;
	ms.insert(0);
    }
    a[0]=inf;
    ms.insert(inf);
    a[m+1]=inf;
    ms.insert(inf);
    

    auto print = [&]() {
	for (auto p: a) {
	    cout<<p.first<<": "<<p.second<<endl;
	}
	cout<<endl;
    };
    //print();



    assert(ms.size() == a.size());
    // a[i]: min # of left moves to get to column i



    auto update = [&](int l, int r) {
	vector<pair<int,int>> upds;
	auto iter = std::prev(a.lower_bound(l));
	set<int> rm;

	// update l
	upds.push_back({l,(l-iter->first) + iter->second});
	if (a.count(l)) rm.insert(l);

	// update r
	if (r+1<=m) {
	    auto iter = std::prev(a.lower_bound(r+1));
	    int res = r+1-iter->first+iter->second;
	    if (a.count(r+1)) {
		rm.insert(r+1);
		res = min(res, a[r+1]);
	    }
	    upds.push_back({r+1,res});
	}

	iter = a.lower_bound(l);
	while (iter != a.end() && iter->first <=r) {
	    rm.insert(iter->first);
	    ++iter;
	}

	for (int k: rm) {
	    ms.erase(ms.find(a[k]));
	}

	iter = a.lower_bound(l);
	while (iter != a.end() && iter->first <=r) {
	    iter = a.erase(iter);
	}

	for (auto p: upds) {
	    a[p.first] = p.second;
	    ms.insert(p.second);
	}


	// cout<<l<<" "<<r<<endl;
	// watch(ms.size());
	// watch(a.size());
	
	
	assert(ms.size() == a.size());
    };

    function<int()> qry = [&]() {
	assert(!ms.empty());
	return *ms.begin();
	// int res = inf;
	// for (auto p: a) {
	//     res = min(res, p.second);
	// }
	// return res;
    };
    
    
    for (int i=1; i<=n; i++) {
	int l=L[i]; int r=R[i];
	update(l,r);
	int res = qry() + i;
	if (res > inf/2) res = -1;
	cout<<res<<"\n";
	// cout<<l<<" "<<r<<endl;
	// print();
    }
    
    
    return 0;
}


Measured memory_bytes: 24076
s = input()

#文字列をリスト化
s = list(s)
s = set(s)
s = sorted(s)

#print(s)

t = 'abcdefghijklmnopqrstuvwxyz'
t = list(t)
#print(t)

if s == t:
	print('None')
else:
	for i in range(len(t)):
		#print(i)
		if i == 25:
			print(t[i])
			break
		elif s[i]!=t[i]:
			print(t[i])
			break



Measured memory_bytes: 3956
while True:
    n=int(input())
    if n==0:
        break
    
    a=[]
    for i in range(n):
        a.append(int(input()))
    A=max(a)
    B=min(a)
    C=sum(a)
    D=len(a)
    E=C-A-B
    F=D-2
    print(E//F)


Measured memory_bytes: 5592
import numpy as np
N=int(input())
H=list(map(int, input().split()))
H=np.array(H)

flag=0


iteration=H.max()
total=0
#print(iteration)


for x in range(iteration):
    count=0
    flag=0
    
    if H[0]>0:
        count+=1
    
    for i in range(len(H)):
        if H[i] <=0:
            flag=1
        elif H[i] >0 and flag==1:
            count+=1
            flag=0
        

        #print(H)
        #print('count',count)
    total+=count
    H-=1
    
print(total)
        

Measured memory_bytes: 21748
#include <iostream>
#include <queue>

using namespace std;

void solve()
{
	int n, m;
	while(cin >> n >> m, n || m)
	{
		deque<bool> deq(n);
		for(int i = 0; i < n; ++i)
		{
			deq[i] = true;
		}
		int remain = n;
		int pos = 0;
		int count = 0;
		while(remain != 1)
		{
			if(pos >= n)
			{
				pos = 0;
			}
			if(deq[pos])
			{
				++count;
			}
			if(count == m)
			{
				deq[pos] = false;
				count = 0;
				--remain;
			}
			++pos;
		}
		for(int i = 0; i < n; ++i)
		{
			if(deq[i])
			{
				cout << i + 1 << endl;
				break;
			}
		}
	}
}

int main()
{
	solve();
	return(0);
}

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

using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> s(n), p(m);
	for (int i = 0; i < n; i++)
		cin >> s[i].first >> s[i].second;
	for (int i = 0; i < m; i++)
		cin >> p[i].first >> p[i].second;
	for (int i = 0; i < n; i++)
	{
		int far = 1e9, ans = -1;
		for (int j = 0; j < m; j++)
			if (abs(s[i].first - p[j].first) + abs(s[i].second - p[j].second) < far)
			{
				far = abs(s[i].first - p[j].first) + abs(s[i].second - p[j].second);
				ans = j;
				cerr << i << " " << j << " " << m << endl;
			}
		cout << ans + 1 << endl;
	}

	return 0;
}


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

using namespace std;

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

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

void prework(){

}

void read(){

}

map<int, int> mp;

void solve(int casi){
	scanf("%d", &n);
	mp.clear();
	for(int i = 1; i <= n; i++){
		int x;scanf("%d", &x);
		mp[x]++;
	}
	int ans = 0, p = 0;
	for(auto x : mp){
		if (x.second >= 3){
			ans += (x.second - 1) / 2;
			x.second -= (x.second - 1) / 2 * 2;
		}
		p += x.second == 2;
	}
	ans += (p + 1) / 2;
	cout<<n - 2 * ans<<endl;
}

void printans(){

}


int main(){
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}


Measured memory_bytes: 4864
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    s = S()

    return s.replace("?", "D")

print(main())





Measured memory_bytes: 11176
#include <bits/stdc++.h>
using namespace std;
// types
typedef long long ll; 
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
// IO
#define fo(i, n) for (int i = 0; i < n; i++)
#define fo1(i, n) for (int i = 1; i <= n; i++)
#define sc(n) scanf("%d", &n) 
#define sca(a, n) fo(i, n) sc(a[i])
#define pd(a) printf("%d ", a)
#define pld(a) printf("%d\n", a)
#define pda(a, n) fo(i, n) pd(a[i])
#define pl printf("\n")
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b) 
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
// math
const ll mod = 1e9+7;
template<typename T> T gcf(T a, T b) {return (b == 0) ? a : gcf(b, a%b);} 
template<typename T> T lcm(T a, T b) {return (a*b)/gcf(a, b);}
template<typename T> T sumTo(T x) {return x * (x+1) / 2;}
template<typename T> T sumSquaresTo(T x) {return x * (x+1) * (2*x+1) / 6;}
template<typename T> T ceilDiv(T n, T d) {return (n+d-1)/d;}

void solve() {
    int n, k; cin >> n >> k;
    char last; cin >> last;
    char next;
    int runs = 1;
    fo(i, n-1) {
        cin >> next;
        if (next != last) {
            runs++;
            last = next;
        }
    }
    cout << min(n-1, n-runs+2*k);
}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=1e6+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("F.in","r",stdin);
	freopen("F.out","w",stdout);
#endif
}
int n;
char S[N],T[N];
void input()
{
	n=read<int>();
	scanf("%s%s",S+1,T+1);
}
int ans;
deque<int>q;
void work()
{
	int pos=n;
	if(!strcmp(S+1,T+1)){puts("0");return;}
	Fordown(i,n,1)
	{
		if(T[i]==T[i-1])continue;
		cmin(pos,i);
		while(pos&&S[pos]!=T[i])pos--;
		if(!pos){puts("-1");return;}
		while(!q.empty())
		{
			if(q.front()-(int)q.size()>=i)q.pop_front();
			else break;
		}
		q.push_back(pos);
		if(pos^i)cmax(ans,(int)q.size());
	}
	write(ans+1,'\n');
}
int main()
{
//	file();
	input();
	work();
	return 0;
}


Measured memory_bytes: 6272
#include<iostream>
using namespace std ;
int main ()
{
    long double a, b;
    cin>>a>>b;
    if( (a != 0)||(b != 0))
        {
            if(a>b)
                cout <<"GREATER ";
            else if(a <b )
                cout <<"LESS ";
            else
                cout <<"EQUAL ";
        }
return 0 ;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;
using pr  = pair<ll, ll>;

const ll MOD = 998244353;

int main()
{
	ll A, V;
	ll B, W;
	ll T;
	cin >> A >> V >> B >> W >> T;

	ll D = abs(A - B);
	D -= V*T;
	D += W*T;
	cout << ((D > 0) ? ("NO") : ("YES")) << endl;

	return 0;
}

Measured memory_bytes: 3636
def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    cumsum = A
    for i in range(1, N):
        cumsum[i] += cumsum[i - 1]
    ans = 10 ** 15
    for i in range(N - 1):
        ans = min([ans, abs(cumsum[i] - (cumsum[-1] - cumsum[i]))])
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 24832
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    long long N, T; cin >> N >> T;
    vector<long long> t(N); cin >> t[0];
    long long diff, ans = T;
    rep (i, 1, N) {
        cin >> t[i];
        diff = t[i] - (t[i-1] + T);
        if (diff >= 0)
            ans += T;
        else
            ans += (T + diff);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	ll N,K; cin >> N >> K;
	V<P<ll,ll>> dt;
	REP(i,N) {
		ll t,d; cin >> t >> d;
		dt.push_back({d,t});
	}
	sort(ALL(dt),greater<P<ll,ll>>());
	
	ll ans = 0,sum = 0;
	priority_queue<ll,V<ll>,greater<ll>> pq;
	map<ll,ll> mp;
	REP(i,K) {
		if(mp[dt[i].second]==0){
			mp[dt[i].second]++;
			sum += dt[i].first;
		}
		else{
			pq.push(dt[i].first);
			sum += dt[i].first;
		}
	}
	chmax(ans,sum+(ll)mp.size()*(ll)mp.size());
	FOR(i,K,N){
		if(pq.size() && mp[dt[i].second]==0){
			mp[dt[i].second]++;
			sum += dt[i].first;
			sum-= pq.top();
			pq.pop();
		}
		chmax(ans,sum+(ll)mp.size()*(ll)mp.size());
	}
	cout << ans << endl;

	return 0;	
}



Measured memory_bytes: 6128
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
constexpr int MAX = 100005;
constexpr int NIL = -1;
struct Node {
	int p, l, r;
};
Node T[MAX];
int D[MAX];
inline void rec(int u, int p) {
	D[u] = p;
	if(T[u].r != NIL) rec(T[u].r, p);
	if(T[u].l != NIL) rec(T[u].l, p + 1);
}
int main() {
	int n; cin >> n;
	rep(i, 0, n) T[i].p = T[i].l = T[i].r = NIL;
	int v, d, c, l;
	rep(i, 0, n) {
		cin >> v >> d;
		rep(j, 0, d) {
			cin >> c;
			if(j == 0) T[v].l = c;
			else T[l].r = c;
			l = c;
			T[c].p = v;
		}
	}
	int r;
	rrep(i, n - 1, -1) {
		if(T[i].p == NIL) { r = i; break; }
	}
	rec(r, 0);
	rep(u, 0, n) {
		cout << "node " << u << ": ";
		cout << "parent = " << T[u].p << ", ";
		cout << "depth = " << D[u] << ", ";
		if(T[u].p == NIL) p("root, ");
		else if(T[u].l == NIL) p("leaf, ");
		else p("internal node, ");
		p("[");
		for (int i = 0, c = T[u].l; c != NIL; ++i, c = T[c].r) {
			if (i) p(", ");
			p(c);
		}
		P("]");
	}
	return 0;
}

Measured memory_bytes: 6212
mod = 10**9+7
def power(m, n):
    if n == 0:
        return 1
    res = power(m*m%mod, n//2)
    if n%2 == 1:
        res = res*m%mod
    return res

m, n = map(int, input().split())
print(power(m, n))


Measured memory_bytes: 5600