akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut 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")
    };
}

// x ** n % mods を求める
pub fn mod_pow(x: i64, n: i64, mods: i64) -> i64 {
    if n == 0 {
        return 1;
    }
    let mut res = mod_pow(x * x % mods, n / 2, mods);
    if n % 2 == 1 {
        res = res * x % mods;
    }
    return res;
}

// (1/n) % mods を求める
pub fn mod_inv(n: i64, mods: i64) -> i64 {
    return mod_pow(n, mods-2, mods);
}

// nCk % mods を求める
pub fn mod_comb(n: i64, k: i64, mods: i64) -> i64 {
    let sum1 = (n-k+1..n+1).fold(1, |ac, x| ac * x % mods);
    let sum2 = (1..k+1).fold(1, |ac, x| ac * x % mods);
    return sum1 * mod_inv(sum2, mods) % mods;
}

use std::collections::HashMap;

fn main() {
    input!{
        n: usize,
        s: [chars; n],
    }
    let mut map = HashMap::new();

    for word in s {
        let count = map.entry(word).or_insert(0);
        *count += 1;
    }
    println!("{}", map.len());
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int H,W,K; cin >> H >> W >> K;
    char S[H][W]; REP(i,H)REP(j,W) cin >> S[i][j];
    int A[H+1][W+1]; CLR(A);
    REP(i,H)REP(j,W) A[i+1][j+1] = S[i][j]-'0';
    REP(i,H)REP(j,W){
        A[i+1][j+1] += A[i+1][j] + A[i][j+1] - A[i][j];
    }

    int ans = INT_INF;
    REP(i,1<<(H-1)){
        int tmp = 0;
        VI cut; cut.push_back(0);
        REP(j,H-1) if(i & 1<<j) cut.push_back(j+1);
        cut.push_back(H);
        tmp = cut.size()-2;
        // 各jについてカットするべきか
        VI cutj; cutj.push_back(0);
        REP(j,W){
            int last = cutj.back();
            // cutiでの各ブロックの個数を取得
            int num;
            bool flag = false;
            REP(k,cut.size()-1){
                num = A[cut[k+1]][j+1] - A[cut[k]][j+1] - A[cut[k+1]][last] + A[cut[k]][last];
                if(num > K){
                    flag = true;
                    break;
                }
            }
            if(flag && last == j){
                tmp = INT_INF;
                break;
            }
            if(flag){
                cutj.push_back(j);
                tmp++;
            }
        }
        int last = cutj.back();
        int num;
        bool flag = false;
        REP(k,cut.size()-1){
            num = A[cut[k+1]][W] - A[cut[k]][W] - A[cut[k+1]][last] + A[cut[k]][last];
            if(num > K){
                flag = true;
                break;
            }
        }
        if(flag == false) chmin(ans, tmp);
    }
    cout << ans << en;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define mp            make_pair
#define PI            3.14159265
#define M             1000000007
#define MM            998244353
#define fr            first
#define sc            second
#define all(v)        (v).begin(),(v).end()
#define rall(v)       (v).rbegin(),v.rend()
#define vc            vector
#define vi            vector<int>
#define pii           pair<int,int>
#define psi           pair<string,int>
#define pis           pair<int,string>
#define mii           map<int,int>
#define msi           map<string,int>

int ans;
int solve(){
    int n,k,s=0; cin>>n>>k;
    int d[k];
    for (int i = 0; i < k; ++i)
    {
        cin>>d[i];
    }
    while(1){
        int flag=1;
        string str=to_string(n);
        for (int i = 0; i < str.length(); ++i)
        {
            for (int j = 0; j < k; ++j)
            {
                if(str[i]-'0'==d[j]){
                    flag=0;
                }
            }
        }
        if(flag){
            cout<<n;
            return 0;
        }
        else n++;
    }
    return 0;
}

signed main() {
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define nl "\n"
#define pi acos(-1)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pcase printf("Case %d:\n",ca)
int ca=1;
using namespace std;
int main(){
   string a;
   cin>>a;
   ll ans= 0;
   for(int i = 0;i<a.size();i++){
    ans += a[i]-'0';
   }
   if(ans %9 == 0){
    cout<<"Yes"<<nl;
   }else{
   cout<<"No"<<nl;
   }
}
 

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

ll mulmod(ll a, ll b, ll m) {
	ll r = a*b-(ll)((long double)a*b/m+.5)*m;
	return r < 0 ? r+m : r;
}

ll expmod(ll b, ll e, ll m) {
    if (e == 0) return 1;
    if (e&1) return mulmod(b, expmod(b, e-1, m), m);
    b = expmod(b, e>>1, m);
    return mulmod(b, b, m);
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    ll n, M = 1e9+7;
    cin >> n;
    vector<ll> c(n);
    fore(i,0,n) cin >> c[i];
    if (n == 1) {
        cout << mulmod(c[0], 2, M) << endl;
        return 0;
    }
    sort(c.rbegin(), c.rend());
    ll ans = 0, p2 = expmod(2, n-2, M);
    fore(i,0,n) {
        ll f = mulmod(i+2, p2, M);
        ans += mulmod(c[i], f, M);
        ans %= M;
    }
    p2 = expmod(2, n, M);
    ans = mulmod(ans, p2, M);
    cout << ans << endl;
}


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

int main()
{
    int N, A, B;
    string S;

    cin >> N >> A >> B;
    cin >> S;

    int a_cnt = 0;
    int b_cnt = 0;
    rep(i, N)
    {
        if (A + B <= a_cnt + b_cnt)
        {
            cout << "No" << endl;
        }
        else if (S.at(i) == 'a')
        {
            cout << "Yes" << endl;
            a_cnt++;
        }
        else if (S.at(i) == 'b' && b_cnt < B)
        {
            cout << "Yes" << endl;
            b_cnt++;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    return 0;
}

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

namespace ABC071B
{
    class Program
    {
        static void Main(string[] args)
        {
            string target = Console.ReadLine();
            HashSet<char> t = new HashSet<char>();
            for(int i=0; i< 26;i++){
                t.Add((char)(i + 'a'));
            } 
            for(int i=0; i< target.Length;i++){
                t.Remove(target[i]);
            } 
            if(t.Count == 0) Console.WriteLine("None"); else {
                HashSet<char>.Enumerator enumlator = t.GetEnumerator();
                enumlator.MoveNext();
                Console.WriteLine(enumlator.Current);
            }
        }
    }
}


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

int main() {
    int n, y;
    cin >> n >> y;
    bool finished = false;

    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= n-i; j++) {

            if(10000*i+5000*j+1000*(n-i-j) == y) {
                cout << i << " " << j << " " << n-i-j << endl;
                finished = true;
                break;
            }

            if(i == n) {
            cout << -1 << " " << -1 << " " << -1 << endl;
            }
        }

        if(finished == true) {
            break;
        }
    }
}

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

a = {'S':'W', 'W':'S'}
for t0, t1 in ('SS', 'SW', 'WS', 'WW'):
    T = [t0, t1]
    for i in range(2, N+2):
        if (S[(i-1)%N]=='o' and T[-1]=='S') or (S[(i-1)%N]=='x' and T[-1]=='W'):
            T.append(T[-2])
        else:
            T.append(a[T[-2]])

    if T[0]==T[-2] and T[1]==T[-1]:
        print(''.join(T[:-2]))
        exit()
print(-1)

Measured memory_bytes: 4860
s = input()

fc = s[0]
nc = ""

count = 0

if fc == "0":
    nc = "1"
else:
    nc = "0"

for i in range(1,len(s)):
    if s[i] != nc :
        count += 1
        nc = s[i]
    else:
        if nc == "0":
            nc = "1"
        else:
            nc = "0"

print(count)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

struct edge{int to,cost;};
const int inf=1e9;

int V,E;
vector<edge> G[1010];

void bellman_ford(int s)
{   
    vector<int> dist(V,inf); dist[s]=0;
    REP(c,V){
        REP(i,V) if(dist[i]!=inf) for(auto e:G[i]){
            if(dist[e.to]>dist[i]+e.cost){
                dist[e.to]=dist[i]+e.cost;
                if(c==V-1){
                    cout<<"NEGATIVE CYCLE"<<endl;
                    return;
                }
            }
        }
    }
    REP(i,V){
        if(dist[i]==inf) cout<<"INF"<<endl;
        else cout<<dist[i]<<endl;
    }
}

signed main()
{
    int r; cin>>V>>E>>r;
    REP(i,E){
        int s,t,d; cin>>s>>t>>d;
        G[s].push_back((edge){t,d});
    }
    bellman_ford(r);
}



Measured memory_bytes: 3188
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var (
	BufferSize = 2*10*10*10*10*10 + 10
)

func scanStr(sc *bufio.Scanner) string {
	if !sc.Scan() {
		panic(nil)
	}

	return sc.Text()
}

func scanInt(sc *bufio.Scanner) int {
	if !sc.Scan() {
		panic(nil)
	}

	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func check() {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, BufferSize)
	sc.Split(bufio.ScanWords)

	n := scanInt(sc)
	s := scanStr(sc)

	//  I don't know...
	//	for i := 0; i < n; i++ {
	//		if s[i] == '#' {
	//			countW++
	//		} else if s[i] == '.' && countW > 0 {
	//			countW--
	//			countB++
	//		}
	//	}

	// count all black or while stones
	countW := 0
	for i := 0; i < n; i++ {
		if s[i] == '.' {
			countW++
		}
	}

	// check split point
	//   (1) (|##.#) -> (|####) :            right . = 1
	//   (2) (#|#.#) -> (.|###) : left #   + right . = 2
	//   (3) (##|.#) -> (..|.#) : left ##  + right . = 4
	//   (4) (##.|#) -> (...|#) : left ##            = 2
	//   (5) (##.#|) -> (...#|) : left ###           = 3
	leftB := 0
	min := countW // (1)

	for i := 0; i < n; i++ { // (2)...
		if s[i] == '#' {
			leftB++
		} else {
			countW--
		}

		tmp := leftB + countW
		if tmp < min {
			min = tmp
		}
	}
	fmt.Printf("%d\n", min)
}

func main() {
	check()
}


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int k,t,a,ret=0; cin>>k>>t;
	while(t-->0)
		cin>>a, ret=max(ret,max(a-1-(k-a),0));
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
mod = 1000000007

aa = {}
for _ in range(m):
  aa[int(input())] = True

dp = [0] * (n+1)
dp[0] = 1

if n == 0:
  print(1)
  exit(0)

if 1 in aa:
  dp[1] = 0
else:
  dp[1] = 1

for i in range(2, n+1):
  if i in aa:
    dp[i] = 0
  else:
    dp[i] = (dp[i-1] + dp[i-2]) % mod
print(dp[n])


Measured memory_bytes: 15076
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

int main(){
    int n,x,ans=1,a=0;
    cin>>n>>x;
    for(int i=0;i<n;i++){
        int l;
        cin>>l;
        a+=l;
        ans+=(a<=x?1:0);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
X=list(map(int,input().split()))

X_dict={}
X_=X.copy()
X_.sort()
for x_idx,x in enumerate(X_):
    X_dict[x]=x_idx

median_idx = N//2-1
for x in X:
#     print('=====')
#     print(x)
    x_sort_idx=X_dict[x]
    if median_idx < x_sort_idx:
        ans = X_[median_idx]
    else:
        ans = X_[median_idx+1]
    print(ans)

Measured memory_bytes: 129544
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	
	
		public static void main(String[] args) {
			Scanner scan=new Scanner(System.in);
			int a=scan.nextInt();
			int b=scan.nextInt();
			int hani=b+b+1;
			System.out.println(a%hani==0?a/hani:a/hani+1);
		}
}

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

using lint = long long;

int main(){
    lint N, M;
    vector<pair<lint, lint>> AB;
    lint tmpA;
    lint tmpB;
    cin >> N >> M;
    for(lint i=0;i<N;i++){
        cin >> tmpA >> tmpB;
        AB.push_back(pair<lint, lint>(tmpA, tmpB));
    }
    sort(AB.begin(), AB.end());
    lint index = 0;
    lint ans = 0;
    while(true){
        lint A = AB[index].first;
        lint B = AB[index].second;
        if(M > B){
            ans += A*B;
            M -= B;
            index++;
        }
        else{
            ans += A*M;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int N;
    cin >> N;
    lint A[N], B[N];
    lint minimum = 1e18;
    for(int i = 0; i < N; i++){
        cin >> A[i] >> B[i];
        if(A[i] > B[i]){
            minimum = min(minimum, B[i]);
        }
    }
    if(minimum > 1e17){
        cout << 0 << endl;
    }else{
        cout << accumulate(A, A + N, 0ll) - minimum << endl;
    }
}


Measured memory_bytes: 512
def mapt(fn, *args):
    return tuple(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))


def main():
    n, m, x, y = Input()
    x_data = Input()
    y_data = Input()
    x_max = max(x_data)
    y_min = min(y_data)
    ans = False

    for i in range(-100, 101):
        if x_max < i <= y_min and x < i <= y:
            ans = True
            break

    if ans: print("No War")
    else: print("War")


main()

Measured memory_bytes: 9144
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int n,a;

int main()
{
	cin >> n;
	vector<int> v;
	int w = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		v.push_back(a);
		w ^= a;
	}
	for (int i = 0; i < n; i++)
	{
		cout<<(w^v[i])<<" ";
	}
	return 0;
}



Measured memory_bytes: 4308
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
class data{
public:
    ll penalty=0;
    ll corect=0;
    bool flag[1000];
    int wrong[1000]={0};
    void inti(){penalty=0; corect=0;rep(i,1000)flag[i]=false;}
};
int main(){
    int t,p,r;
    while(cin>>t>>p>>r,t+p+r){
        vector<data>gotiusa(t);
        rep(i,t)gotiusa[i].inti();
        rep(i,r){
            int tid,pid,_time;
            string s;
            cin>>tid>>pid>>_time>>s;
            --tid;
            if(s=="WRONG"){
                if(gotiusa[tid].flag[pid])continue;
                gotiusa[tid].wrong[pid]++;
            }else{
                if(gotiusa[tid].flag[pid])continue;
                gotiusa[tid].penalty+=gotiusa[tid].wrong[pid]*1200+_time;
                gotiusa[tid].corect++;
                gotiusa[tid].flag[pid]=true;
            }
        }
        typedef pair<pii,int>piii;
        vector<piii>rize;
        rep(i,t){
        rize.push_back(piii(pii(gotiusa[i].corect,-gotiusa[i].penalty),-i));
        }
        
        sort(all(rize),greater<piii>());
        //rep(i,rize.size())cout<<rize[i].second*-1+1<<endl;
        rep(i,t)cout<<-1*rize[i].second+1<<" "<<gotiusa[-1*rize[i].second].corect<<" "<<gotiusa[-1*rize[i].second].penalty<<endl;
        }
}

Measured memory_bytes: 3404
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

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

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N, D int

func main() {
	sc.Split(bufio.ScanWords)

	N, D = nextInt(), nextInt()
	x := make([][]int, N)
	for i := 0; i < N; i++ {
		x[i] = make([]int, D)
		for j := 0; j < D; j++ {
			x[i][j] = nextInt()
		}
	}

	ans := 0
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			d2 := 0
			for d := 0; d < D; d++ {
				//fmt.Println(i, j, d)
				d2 += powInt(x[i][d]-x[j][d], 2)
			}

			d2f := float64(d2)

			if math.Sqrt(d2f) == float64(int(math.Sqrt(d2f))) {
				ans++
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
a, b = [int(x) for x in input().split()]

if (b < a):
    temp = b
    b = a
    a = temp


x = 1
while True:
    if (int(x*0.08) == a and int(x*0.1) == b):
        print(x)
        break
    else:
        if (x > 1500):
            print(-1)
            break
        else:
            x += 1


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

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1;
	while (b) {
		while (!(b & 1))
			b >>= 1, a = (a * a) % MOD;
		--b;
		ans = (ans * a) % MOD;
	}
	return ans;
}
*/

char s[210000];
int cc[100];

int main() {
	scanf("%s", s);
	int n = strlen(s);
	ll ans = 1;
	for (int i = 0; i < n; ++i) {
		int x = s[i] - 'a';
		for (int j = 0; j < 26; ++j)
			if (j != x) {
				ans += cc[j];
			}
		++cc[x];
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 384
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int,int>P;
typedef vector<P>VP;
int main(void){
	int n;
	int u,k,v,c;
	int i,j;
	VP vp[10001];
	bool flg[10001]={false};
	int d[10001];
	P pp;
	int x,y,cost,ncost;
	priority_queue<P,VP,greater<P>>que;
	int cnt;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>u>>k;
		for(j=0;j<k;j++){
			cin>>v>>c;
			vp[u].push_back(make_pair(c,v));
		}
	}
	que.push(make_pair(0,0));
	cnt=0;
	while(!que.empty()){
		pp=que.top();
		que.pop();
		cost=pp.F;
		x=pp.S;
		if(!flg[x]){
			flg[x]=true;
			d[x]=cost;
			cnt++;
			if(cnt==n)	break;
			for(i=0;i<vp[x].size();i++){
				y=vp[x][i].S;
				ncost=vp[x][i].F;
				if(!flg[y]){
					que.push(make_pair(cost+ncost,y));
				}
			}
		}
	}
	for(i=0;i<n;i++)	cout<<i<<" "<<d[i]<<endl;
	return 0;
}
	
	
						
	


Measured memory_bytes: 9828
#include <stdio.h>

#define X 4
#define Y 3
#define Z 10

int main(void) {
    int n;
    int i, j, p;
    int b, f, r, v;
    int A[X][Y][Z] = {0};

    scanf("%d", &n);
    for(i=0; i<n; ++i) {
      scanf("%d %d %d %d", &b, &f, &r, &v);
      A[b-1][f-1][r-1] += v;
    }

    for(i=0; i<X; i++) {
      for(j = 0; j<Y; ++j) {
        for(p = 0; p<Z; ++p) {
          printf(" %d", A[i][j][p]);
        }
        printf("\n");
      }
      if(i != 3) {
        printf("####################\n");
      }
    }

    return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  ll n; cin>>n;
  ll m; cin>>m;
  ll s=0;
  rep(i, m) {
    ll a;cin>>a;
    s+=a;
  }
  if(s>n) cout << -1;
  else cout << n-s;
}

  

Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<queue>
#include<bitset>

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;

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

	cin >> a >> b >> c;

	if (b < a) {
		cout << 0;
	}
	else {
		cout << min(b / a, c);
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define mp make_pair;

const ll prime = 998244353;
const ld PI = 2 * acos(0.0);

/*
cout << fixed << setprecision(10);
*/

int main() {

	string s;
	ll n;
	cin >> n;
	cin >> s;
	if (n % 2 == 1) {
		cout << "No" << endl;
		return 0;
	}

	for (ll i = 0; i < n/2; i++)
	{
		if (s[i] != s[i + n / 2]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;



	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N, K;
  cin >> N >> K;
  
  vector<long long> score(N);
 
  for (long long i = 0; i < N; i++) {
    cin >> score.at(i);
  }
  
   for(long long i=K; i<N; i++){
    cout<<(score[i-K]<score[i] ? "Yes" : "No")<<endl;
  }


  return 0;
}

Measured memory_bytes: 4812
# Dice II
# 2018/11/17

class Dice:
    def __init__(self, *num):
        if len(num) != 6:
            raise ValueError("6!")
        self.numbers = num

    def east(self):
        index = (3, 1, 0, 5, 4, 2)
        self.numbers = tuple((self.numbers[i] for i in index))

    def west(self):
        index = (2, 1, 5, 0, 4, 3)
        self.numbers = tuple((self.numbers[i] for i in index))

    def south(self):
        index = (4, 0, 2, 3, 5, 1)
        self.numbers = tuple((self.numbers[i] for i in index))

    def north(self):
        index = (1, 5, 2, 3, 0, 4)
        self.numbers = tuple((self.numbers[i] for i in index))

    def rot_top(self):
        """topを変えないように時計周りにくるくる回す"""
        index = (0, 2, 4, 1, 3, 5)
        self.numbers = tuple((self.numbers[i] for i in index))

    @property
    def top(self):
        return self.numbers[0]

    @property
    def front(self):
        return self.numbers[1]

    @property
    def right(self):
        return self.numbers[2]

    def __repr__(self):
        return "Dice(" + ", ".join([str(i) for i in self.numbers]) + ")"


def main():
    num = [int(i) for i in input().rstrip().split()]
    dice = Dice(*num)
    n = int(input().rstrip())
    for _ in range(n):
        top, front = (int(i) for i in input().rstrip().split())

        # topを合わせる
        for i in range(4):
            if dice.top == top:
                break
            dice.east()

        for i in range(4):
            if dice.top == top:
                break
            dice.north()

        # frontを合わせる
        for i in range(4):
            if dice.front == front:
                break
            dice.rot_top()

        print(dice.right)


if __name__ == "__main__":
    main()


Measured memory_bytes: 5628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <tuple>
#include <random>
#include <unordered_map>
#include <unordered_set>
using namespace std ;

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

    string input ; 
    unordered_set<string> type ;
    for (int i=0;i<n;++i) {
        cin >> input ; 
        type.insert(input) ;
    } 
    cout << type.size(); 
}
 

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

int main() {
  vector<vector<int>> c(3, vector<int>(3)), cc(3, vector<int>(3));
  rep(i, 3) rep(j, 3) cin >> c[i][j];

  vector<int> max_a(3), max_b(3);
  rep(i, 3) rep(j, 3) max_a[i] = max(max_a[i], c[i][j]);
  rep(i, 3) rep(j, 3) max_b[i] = max(max_b[i], c[j][i]);

  rep(a1, max_a[0] + 1) rep(a2, max_a[1] + 1) rep(a3, max_a[2] + 1) {
    vector<int> a = {a1, a2, a3};
    int maxa = max({a1, a2, a3});
    vector<int> b = {max_b[0] - maxa, max_b[1] - maxa, max_b[2] - maxa};
    // rep(i, 3) cerr << a[i] << ' ';
    // cerr << " / ";
    // rep(i, 3) cerr << b[i] << ' ';
    // cerr << endl;
    rep(i, 3) rep(j, 3) cc[i][j] = a[i] + b[j];
    if (c == cc) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

int main() {
    string S;
  cin >> S;
  sort(S.begin(), S.end());
  if (S.at(0) == S.at(1) && S.at(2) == S.at(3) && S.at(0) != S.at(2)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> A(H);
    for (int i = 0; i < H; i++) cin >> A[i];

    vector<int> cnt(26);
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cnt[A[i][j] - 'a']++;
        }
    }

    int cnt_1 = (H % 2 == 1 && W % 2 == 1);
    int cnt_4 = (H / 2) * (W / 2);
    int cnt_2 = (H * W - cnt_1 - 4 * cnt_4) / 2;

    for (int i = 0; i < 26; i++) {
        while (cnt[i] >= 4 && cnt_4) {
            cnt[i] -= 4;
            cnt_4--;
        }
        while (cnt[i] >= 2 && cnt_2) {
            cnt[i] -= 2;
            cnt_2--;
        }
        while (cnt[i] >= 1 && cnt_1) {
            cnt[i] -= 1;
            cnt_1--;
        }
    }

    if (cnt_1 == 0 && cnt_2 == 0 && cnt_4 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a=0, b = 0,c,d, n, k;
string s, t;


int main()
{
	cin >> n;
	if (n / 10 == 9 || n % 10 == 9)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
function Main(input){
  var lines=input.split('\n');
  for(var x in lines){
    if(lines[x]=="")break;
    var ans="";
    for(var i=0;i<26;++i){
      var s=lines[x],ans="";
      for(var j=0,len=s.length;j<len;++j){
        if('a'.charCodeAt()<=s[j].charCodeAt()&&s[j].charCodeAt()<='z'.charCodeAt())
          ans+=String.fromCharCode((s[j].charCodeAt()-0x61+26-i)%26+0x61);
        else ans+=s[j];
      }
      if(ans.indexOf("the")!=-1||ans.indexOf("this")!=-1||ans.indexOf("that")!=-1) break;
    }
    console.log(ans);
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define mod 1000000007

typedef long long ll;

int N;
ll mem = 0,now;
ll dp[1000010] = {1};
ll ans = 0;

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)
    {
        mem += dp[i];
        dp[i + 1] += mem;
        dp[i + 1] %= mod;
        dp[i + 2] -= mem;
        dp[i + 2] = (dp[i + 2] + mod) % mod;
        dp[i + 3] += mem;
        dp[i + 3] %= mod;
        now = dp[i];
        //printf("    %lld\n",now);
        if(N - 1 == i)
        {
            ans += now * N % mod;
            ans %= mod;
            continue;
        }
        ans += now * (N - 1) % mod * (N - 1) % mod;
        ans %= mod;
        ans += now * (2 + i - (i == N - 2)) % mod;
        ans %= mod;
        //printf("  %lld\n",ans);
    }
    printf("%lld\n",ans);
    return 0;
}


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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);


int main(void)
{
    ll n,p,cnt=0,odd=0,even=0;
    cin>>n>>p;
    rep(i,n){
        ll a;
        cin>>a;
        if(a%2) odd++;
        else even++;
    }
    ll ans=1;
    if(even==n){
        if(p) ans=0;
        else{
            rep(i,n) ans*=2; 
        }
    }else{
        rep(i,n-1) ans*=2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3568
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = GL;
		var s = I[3] % 2 == 0 ? 1 : -1;
		WriteLine((I[0] - I[1]) * s);
	}
}


Measured memory_bytes: 11348
#include<bits/stdc++.h>
using namespace std;
int ara[10],tt[10],k,n;
vector<string>res;
string str,num1,num2;
bool visit[10];

void rec(int take)
{
    if(take==n)
    {
        str.clear();
        for(int i=0; i<n; i++)
        {
            str+=(tt[i]+'0');
        }
        res.push_back(str);
    }
    for(int i=1; i<=n; i++)
    {
        if(!visit[i])
        {
            visit[i]=true;
            tt[take]=ara[i];
            rec(take+1);
            visit[i]=false;
        }
    }
}

int main()
{
    int i,cnt,a,b;
    cin>>n;
    for(i=1; i<=n; i++)
    {
        ara[i]=i;
        scanf("%d",&a);
        num1.push_back(a+'0');
    }
    for(i=1; i<=n; i++)
    {
        scanf("%d",&a);
        num2.push_back(a+'0');
    }
    //cout<<num1<<" "<<num2<<endl;
    rec(0);
   // cout<<res.size()<<endl;
    sort(res.begin(),res.end());
    for(i=0; i<res.size(); i++)
    {
        if(res[i]==num1)//cout<<i<<endl;
            a=i+1;
        else if(res[i]==num2)//cout<<i<<endl;
            b=i+1;
    }
    if(num1==num2)a=b=0;
    cout<<abs(a-b)<<endl;
    return 0;
}


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

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
			// 文字列の入力
			string s = Console.ReadLine();

			for(int i = 0; i < s.Length; ++i) {
				if(CountChar(s, s[i]) != 1) {
					Console.WriteLine("no");
					return;
				}
			}

			Console.WriteLine("yes");
		}

		public static int CountChar(string s, char c)
		{
			return s.Length - s.Replace(c.ToString(), "").Length;
		}

	}
}

Measured memory_bytes: 11092
N = int(input())
n = list(map(int, input().split()))
sm=sum(n)
av = sm/2
c =0

for i in range(N):
	c += n[i]
	if c == av:
		print(0)
		exit()
	elif c > av:
		b1 = abs(c - (sm-c))
		b2 = abs((c-n[i]) - (sm-c+n[i]))
		print(b1 if b1<b2 else b2)
		exit()	


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int INF=1e18;
const int MOD=1e9+7;

signed main(){
    string s;cin>>s;
    int n=s.size();
    REP(i,n-1){
        if(s[i]==s[i+1]){
            cout<<i+1<<" "<<i+2<<endl;
            return 0;
        }
        if(i!=n-1&&s[i]==s[i+2]){
            cout<<i+1<<" "<<i+3<<endl;
            return 0;
        }
    }
    cout<<-1<<" "<<-1<<endl;
}

Measured memory_bytes: 512
import java.util.Scanner

object Main extends App  {
  val sc = new Scanner(System.in)

  val a = sc.nextInt
  val b = sc.nextInt
  val c = sc.nextInt

  val res = if( a + b == c || b + c == a || c + a == b) "Yes" else "No"

  println(res)
}


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

int main(){
    
    string S;cin>>S;
    vector<bool> C(4,false);
    for(int i=0;i<S.size();i++){
        if(S[i]=='N') C[0]=true;
        if(S[i]=='S') C[1]=true;
        if(S[i]=='W') C[2]=true;
        if(S[i]=='E') C[3]=true;
    }
    if(C[0]==C[1]&&C[2]==C[3]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 1001000;

char S[MAX];
char T[MAX];

int A[MAX];

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

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

	if ((string)(S) ==(string(T)))
	{
		cout<<0<<endl;
		return 0;
	}

	FILL(A, -1);
	int ind = n-1;
	RFOR(i, n, 0)
	{
		while (ind > i) ind--;
		while(ind >= 0 && S[ind] != T[i])
		{
			ind--;
		}

		if (ind == -1)
		{
			cout<<-1<<endl;
			return 0;
		}

		if (A[ind] == -1) A[ind] = i;
	}

	vector<PII> a;
	FOR (i, 0, n)
	{
		if (A[i] != -1) a.PB(MP(i, A[i]));
	}

	/*FOR (i, 0, SZ(a))
	{
		cout<<a[i].first<<' '<<a[i].second<<endl;
	}
	cout<<endl;*/

	int res = 0;

	ind = 0;
	int ind2 = 0;
	FOR (i, 0, SZ(a))
	{
		while(true)
		{
			if (ind2 == SZ(a)) break;
			if (a[ind2].first <= a[i].second)
			{
				ind2++;
				continue;
			}
			break;
		}
		while(true)
		{
			if (ind == SZ(a)) break;
			if (a[ind].first - (ind - i - 1) <= a[i].second)
			{
				ind++;
				continue;
			}
			break;
		}

		res = max(res, ind - i);
	}

	cout<<res<<endl;

}



Measured memory_bytes: 17232
/*input
3 10

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 998244353;
#define PI 3.14159265
#define endl '\n'
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
    int x = 1 % mod;
    while(b){
        if(b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}
inline int inv(int a){ return powr(a, mod - 2);}


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

  int pw[32];
  pw[0] = 1;
  for (int i = 1; i < 32; i++) {
    pw[i] = 2 * pw[i - 1];
  }
  int n, k;
  cin >> n >> k;
  ld ans = 0;
  for (int i = 1; i <= n; i++) {
    int l = 0;
    int m = i;
    while (m < k) {
      l++;
      m *= 2;
    }
    //debug(l);
    ld t = (1.0 / pw[l]);
    ans += t;
  }
  ans *= (1.0 / n);
  cout << fixed << setprecision(15) << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    long int a, b;
    int d, r;
    double f;
    cin >> a >> b;
    d = a/b;
    r = a%b;
    f = (double)a/(double)b;
    std::cout << std::fixed;

    cout << d << " " << a%b << " " << setprecision(6) << f << endl;
    return 0;
}



Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n)  RFOR(i,0,n)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
#define P pair<int,int>
#define PPi pair<P,int>
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	int Q,l,r,like2017[100005];
	bool check[100001];
	memset(check,true,100001);
	memset(like2017,0,100001);

	check[0]=false;
	check[1]=false;
	for(int i=2;i*i<=100000;i++)
		if(check[i]==true) for(int j=2;j*i<=100000;j++) check[i*j]=false;
	
	like2017[1]=0;
	for(int i=3;i<=100000;i+=2){
		if(check[(i+1)/2]&&check[i]) like2017[i]=like2017[i-2]+1;
		else like2017[i]=like2017[i-2];
	}
	cin>>Q;
	REP(i,Q){
		cin>>l>>r;
		print(like2017[r]-like2017[l-2]);
	}
	return 0;
}




Measured memory_bytes: 1152
N, M = map(int, input().split())

one2 = set()
toN = set()

for _ in range(M):
    a, b = map(int, input().split())

    if a == 1:
        one2.add(b)

    if b == N:
        toN.add(a)

inter = one2 & toN

if len(inter) > 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 18936
#include <iostream>
using namespace std;
int main(){
int a[3];
int emp;
cin>>a[0]>>a[1]>>a[2];
for(int i=0;i<3;i++){
for(int j=i;j<3;j++){
if(a[i]>a[j]){emp=a[i];a[i]=a[j];a[j]=emp;}
}
}
cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
return 0;
}

Measured memory_bytes: 3092
import std.algorithm;
import std.conv;
import std.stdio;
import std.string;

void main()
{
	auto abc = readln.split.map!( to!int );
	auto k = readln.strip.to!int;
	
	writeln( solve( abc[ 0 ], abc[ 1 ], abc[ 2 ], k ) );
}

int solve( in int a, in int b, in int c, in int k )
{
	return a + b + c + max( a, b, c ) * ( 2 ^^ k - 1 );

}

unittest
{
	assert( solve( 5, 3, 11, 1 ) == 30 );
	assert( solve( 3, 3, 4, 2 ) == 22 );
}


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

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

  if ( A + B > C + D ) {
    cout << "Left" << endl;
  }
  else if ( A + B == C + D){
	cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int H,W,i,q;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0&&W==0){
            break;
        }
        for(i=0;i<H;i++){
            for(q=0;q<W;q++){
                if(i!=0&&i!=H-1&&q!=0&&q!=W-1){
                    printf(".");
                }
                else{
                    printf("#");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1812