akhauriyash/Code-Regression huggingface dataset:
/*
* @Author Silviase(@silviasetitech)
* For ProCon
*/

import java.util.*;
import java.lang.*;
import java.math.*;

class Main{

        // usual use input int
        static int n;
        static int m;
        static int ni;
        static int hi;
        static int wi;
        static int lefi;
        static int rigi;
        static int ansi;
        //
        static String s;
        static String anss;
        // 
        static String[] sAr;
        //
        static long ansl;
        //
        static int[] ari;
        //
        static int[][] sqari;
        //

        // for dfs
        static int[] w;
        static int[] ww;
        static boolean[] isvisited;
        //
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
             
        s = sc.next();
        System.out.println(s.substring(0,s.length() - 8));
        sc.close();
    }


        public static int gcd_int(int a, int b) {
        
            if (a < b) {
                int tmpp = a;
                a = b;
                b = tmpp;
            }
            if (b == 0) {
                return a;
            }else{
                return gcd_int(b, a%b);
            }
        }

        public static long gcd_long(long a, long b) {
        
            if (a < b) {
                long tmpp = a;
                a = b;
                b = tmpp;
            }
            if (b == 0) {
                return a;
            }else{
                return gcd_long(b, a%b);
            }
        }

        public static int lcm_int(int a, int b) {
            int gcd = gcd_int(a,b);
            return a/gcd*b;
        }

        public static long lcm_long(long a, long b) {
            long gcd = gcd_long(a,b);
            return a/gcd*b;
        }

        public static void dfs(int placenow) {
            // if went all -> success! 
            // if not went all -> fail...
            
            /*
            dfs    
            Go All Place that there is way to and not having been yet. 

             if island 1 is start point, dfs(1);
            if there is way to island 2 and island 3,
            - island 2 changes non-visited -> visited, and dfs(2).
            - island 3 changes non-visited -> visited, and dfs(3).
    
            */

            isvisited[placenow] = true;
            boolean success = true;
            for (int i = 0; i < n; i++) {
                if (isvisited[i] == false) { // not go all place
                    success = false;
                    break;
                }
            }
            if (success) {
                ansi++;
                isvisited[placenow] = false;
                return;
            }

            for (int i = 0; i < n; i++) {
                if (w[i] == placenow && isvisited[ww[i]] == false ) {
                    dfs(ww[i]);
                }else if(ww[i] == placenow && isvisited[w[i]] == false){
                    dfs(w[i]);
                }else{
                    continue;
                }
            }
            isvisited[placenow] = false;
            return;
        }

}



Measured memory_bytes: 21844
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

const MAX_BIT: usize = 60;
fn main() {
    let n = read::<usize>();
    let mut seq = vec![0; n];
    let mut all = 0;
    for i in 0..n {
        seq[i] = read::<usize>();
        all ^= seq[i];
    }
    seq.sort();
    seq.reverse();
    let mut bases = vec![0; MAX_BIT];
    for i in 0..n {
        let mut v = seq[i];
        for j in (0..MAX_BIT).rev() {
            let bit = 1 << j;
            if (all & bit) != 0 {
                if (v & bit) != 0 {
                    v ^= bit;
                }
                continue;
            }
            if (v & bit) == 0 || bases[j] == 0 {
                continue;
            }
            v ^= bases[j];
        }
        if v != 0 {
            bases[63 - v.leading_zeros() as usize] = v;
        }
    }
    let mut red = 0;
    for i in (0..MAX_BIT).rev() {
        let bit = 1 << i;
        if (red & bit) != 0 {
            continue;
        }
        red ^= bases[i];
    }
    let blue = red ^ all;
    println!("{}", red + blue);
}


Measured memory_bytes: 3368
#!/usr/bin/env python3
import sys


def solve(N: int, D: int):
    res = 0
    while N > 0:
        res += 1
        N -= 1 + 2*D
    print(res)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(N, D)

if __name__ == '__main__':
    main()


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

int main() {
    int K,S;
    int count = 0;
    cin >> K >> S;

    for(int i=0; i<=K; i++)
    {
        for(int j=0; j<=K; j++)
        {
            if(0 <= S-i-j && S-i-j <= K)
            {
                count += 1;
            }
        }
    }
    cout << count << endl;
    return 0;
}

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

int main() {
  string s, t;
  cin >> s;
  cin >> t;
  
  int ans = 0;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == t.at(i)) {ans++;}
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    string s;
    cin >> n >> s;
    vector<ll> mx(n + 1);
    ll x = 0;
    rep(i, n){
        if(s[i] == 'I') x++;
        if(s[i] == 'D') x--;
        mx[i + 1] = max(mx[i], x);
    }
    cout << mx[n];
    cout << endl;
    return 0;
}




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

int main(){
	string s; cin >> s;
	int len = s.size();
	bool f1 = false;
	bool f2 = false;
	if( s.find('N')==string::npos && s.find('S')==string::npos ) f1 = true;
	if( s.find('E')==string::npos && s.find('W')==string::npos ) f2 = true;
	for(int i=0;i<len;++i){
		for(int j=i+1;j<len;++j){
			if((s[i]=='N' && s[j]=='S')||(s[i]=='S' && s[j]=='N')) { f1 = true; break; }
		}
	}
	for(int i=0;i<len;++i){
		for(int j=i+1;j<len;++j){
			if((s[i]=='E' && s[j]=='W')||(s[i]=='W' && s[j]=='E')) { f2 = true; break; }
		}
	}
	cout << (( f1 && f2 ) ? "Yes" : "No" ) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define max(X, Y) ((X) > (Y) ? (X) : (Y))
#define min(X, Y) ((X) < (Y) ? (X) : (Y))

typedef struct {
    int left, right;
}Range;

Range island[100005];

int Range_cmp(const void *p, const void * q);

int main()
{
    int n, m;
    int i, j, k;
    int ans = 1;
    Range temp;

    scanf("%d %d", &n, &m);
    for (i = 0; i < m; i++){
        scanf("%d %d", &island[i].left, &island[i].right);
    }

    qsort(island, m, sizeof(Range), Range_cmp);

    temp.left = 0; temp.right = n;
    for (i = 0; i < m; i++) {
        if (temp.right <= island[i].left || temp.left >= island[i].right) {
            ans++;
            temp.left = island[i].left; temp.right = island[i].right;
        } else {
            temp.left = max(temp.left, island[i].left);
            temp.right = min(temp.right, island[i].right);
        }
    }
    
    printf("%d\n", ans);
    
    return 0;
}

int Range_cmp(const void *p, const void * q)
{
    int ret;

    ret = (((Range *)p)->left < ((Range *)q)->left ? 1 :
           ((Range *)p)->left ==((Range *)q)->left && ((Range *)p)->right < ((Range *)q)->right ? 1 :
           0);
        
    return ret;
}


Measured memory_bytes: 1788
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


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

    int a, b;
    cin >> a >> b;

    if (b % a == 0) {
        cout << a + b << '\n';
    } else {
        cout << b - a << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;

namespace ABC103
{
    class D
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int M = input[1];

            int[][] ab = new int[M][];

            for (int i = 0; i < M; i++)
            {
                input = Console.ReadLine().Split().Select(int.Parse).ToArray();
                ab[i] = new int[] { input[1], input[0] };
            }
            Array.Sort(ab, StructuralComparisons.StructuralComparer);

            int R = ab[0][0];
            int res = 1;
            for (int i = 1; i < M; i++)
            {
                if (R <= ab[i][1])
                {
                    R = ab[i][0];
                    res++;

                }
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 21992
// 暗号化は、入力された順番にスワップ操作をしたものとする　←あ(察し
#include<iostream>
#include<cstdio>
#include<string>
#include<cstdlib>
#include<algorithm>
using namespace std;
int main(){
  string message;
  int n,a[111],b[111],c;
  while(1){
    cin >> n;
    if(n==0)break;
    cin >> message;
    for(int i=0;i<n;i++){
      cin >> a[i] >> b[i];
      a[i]--;b[i]--;
    }
    for(int i=n-1;i>=0;i--){
      c = abs(b[i] - a[i]);
      for(int j=0;j<c;j++){
	message[a[i]]++;
	message[b[i]]++;
	if(message[a[i]]>'z')message[a[i]]='a';
	if(message[b[i]]>'z')message[b[i]]='a';
      }
      swap(message[a[i]],message[b[i]]);
    }
    cout << message << endl;
  }
}

Measured memory_bytes: 1200
#include <iostream>
#include <map>
#include <string>

int main()
{
	std::map<char, std::string> m1; // char to string
	m1['A'] = "00000"; m1['B'] = "00001"; m1['C'] = "00010"; m1['D'] = "00011";
	m1['E'] = "00100"; m1['F'] = "00101"; m1['G'] = "00110"; m1['H'] = "00111";
	m1['I'] = "01000"; m1['J'] = "01001"; m1['K'] = "01010"; m1['L'] = "01011";
	m1['M'] = "01100"; m1['N'] = "01101"; m1['O'] = "01110"; m1['P'] = "01111";
	m1['Q'] = "10000"; m1['R'] = "10001"; m1['S'] = "10010"; m1['T'] = "10011";
	m1['U'] = "10100"; m1['V'] = "10101"; m1['W'] = "10110"; m1['X'] = "10111";
	m1['Y'] = "11000"; m1['Z'] = "11001"; m1[' '] = "11010"; m1['.'] = "11011";
	m1[','] = "11100"; m1['-'] = "11101"; m1['\''] = "11110"; m1['?'] = "11111";
	
	std::map<std::string, char> m2; // string to char
	m2["101"] = ' '; m2["000000"] = '\''; m2["000011"] = ','; m2["10010001"] = '-';
	m2["010001"] = '.'; m2["000001"] = '?'; m2["100101"] = 'A'; m2["10011010"] = 'B';
	m2["0101"] = 'C'; m2["0001"] = 'D'; m2["110"] = 'E'; m2["01001"] = 'F';
	m2["10011011"] = 'G'; m2["010000"] = 'H'; m2["0111"] = 'I'; m2["10011000"] = 'J';
	m2["0110"] = 'K'; m2["00100"] = 'L'; m2["10011001"] = 'M'; m2["10011110"] = 'N';
	m2["00101"] = 'O'; m2["111"] = 'P'; m2["10011111"] = 'Q'; m2["1000"] = 'R';
	m2["00110"] = 'S'; m2["00111"] = 'T'; m2["10011100"] = 'U'; m2["10011101"] = 'V';
	m2["000010"] = 'W'; m2["10010010"] = 'X'; m2["10010011"] = 'Y'; m2["10010000"] = 'Z';
	
	std::string input;
	while (getline(std::cin, input)) {
		std::string bincode;
		for (int i=0; i<input.length(); i++) bincode += m1[input[i]];
		std::string res;
		std::string tmp;
		for (int i=0; i<bincode.length(); i++) {
			tmp.push_back(bincode[i]);
			if (m2.find(tmp) != m2.end()) {
				res.push_back(m2[tmp]);
				tmp.clear();
			}
		}
		std::cout << res << std::endl;
	}
	
	return 0;
}



Measured memory_bytes: 3004
<?php
while (True){
    $num = trim(fgets(STDIN));
    if ($num == ""){
        break;
    }
    $total = 0;
    for ($x = 0; $x < 10; $x++){
        for ($y = 0; $y < 10; $y++){
            for ($z = 0; $z < 10; $z++){
                for ($w = 0; $w < 10; $w++){
                    if($x+$y+$z+$w == $num){
                        $total+=1;
                    }
                }
                
            }
        }
        
    }
    echo $total."\n";
    
}

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;
const double PI = acos(-1);

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

  double r;
  cin >> r;

  cout << 2 * PI * r << "\n";
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

const ll inf = 1e18;
ll n, s;

bool check(ll b) {
    ll aux = n, sum = 0;
    while (aux) {
        sum += aux % b;
        aux /= b;
    }
    return sum == s;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    cin >> n >> s;
    
    if (n == s) {
        cout << n+1 << endl;
        return 0;
    }
    
    ll ans = inf;
    
    for (ll b = 2; b <= n/b; ++b) {
        if (check(b)) {
            ans = b;
            break;
        }
    }
    
    for (ll d = 1; d <= (n-s)/d; ++d) {
        if ((n-s) % d == 0) {
            ll b = d + 1;
            if (check(b)) ans = min(ans, b);
            b = (n-s)/d + 1;
            if (check(b)) ans = min(ans, b);
        }
    }
    
    if (ans == inf) cout << "-1\n";
    else cout << ans << endl;
}


Measured memory_bytes: 3660
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		String line = input.readLine();
		String[] str = line.split(" ");
		
		double x1 = Double.parseDouble(str[0]);
		double y1 = Double.parseDouble(str[1]);
		double x2 = Double.parseDouble(str[2]);
		double y2 = Double.parseDouble(str[3]);
		
		double x = Math.pow(x1 - x2 , 2);
		double y = Math.pow(y1 - y2 , 2);
		
		double det = Math.sqrt(x + y);
		
		System.out.println(det);
		
	}

}

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

using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
double n,s;
 cin>>n;
vector<double> v(n,0);
for(int i=0;i<n;i++)
cin>>v[i];
sort(v.begin(),v.end());
s=v[0];
for (int i = 0; i < n; i++){
  s=(v[i]+s)/2;
}
cout<<s;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	ll n,p; cin>>n>>p;
	if(n==1) return cout<<p<<endl,0;
	map<ll,ll> soinsu;
	ll s=2;
	while(p>1){
		if(p%s){
			s++;
		}else{
			p/=s; soinsu[s]++;
		}
		if(s>1e6+5) break;
	}
	ll ans=1;
	for(auto it: soinsu){
		ll u,v; tie(u,v)=it;
		if(v>=n) ans*=pow(u,(v/n));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N,K=map(int,input().split())
    a=list(map(int,input().split()))
    ans=INF
    for i in range(2**N):
        c=0
        tmp=0
        l=a[0]
        for j in range(N):
            if j==0:
                if (i>>j)&1:
                    c+=1
                else:
                    break
            else:
                if (i>>j)&1:
                    c+=1
                    tmp+=max(0,l+1-a[j])
                    l=max(l+1,a[j])
                else:
                    l=max(l,a[j])
        if c>=K:
            ans=min(ans,tmp)
    print(ans)
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 42736
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
const int N=2010;
char mat[N][N];
int __deg[N][N],_deghor[N][N],_degver[N][N];
int main(){
	int n=ni,m=ni,tot=ni;
	for(int i=1;i<=n;i++){
		scanf("%s",mat[i]+1);
	}
	memset(__deg,0,sizeof(__deg));
	memset(_deghor,0,sizeof(_deghor));
	memset(_degver,0,sizeof(_degver));
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(mat[i][j]=='1'){
				__deg[i][j]=-2;
				static const int dx[]={-1,0,1,0},dy[]={0,1,0,-1};
				for(int d=0;d<4;d++){
					__deg[i][j]+=mat[i+dx[d]][j+dy[d]]=='1';
				}
			}
			__deg[i][j]+=__deg[i-1][j]+__deg[i][j-1]-__deg[i-1][j-1];
			_deghor[i][j]=_deghor[i][j-1]+(mat[i][j]=='1'&&mat[i-1][j]=='1');
			_degver[i][j]=_degver[i-1][j]+(mat[i][j]=='1'&&mat[i][j-1]=='1');
		}
	}
	while(tot--){
		int x1=ni,y1=ni,x2=ni,y2=ni;
		int sum=__deg[x2][y2]-__deg[x1-1][y2]-__deg[x2][y1-1]+__deg[x1-1][y1-1];
		sum-=_deghor[x1][y2]-_deghor[x1][y1-1];
		sum-=_deghor[x2+1][y2]-_deghor[x2+1][y1-1];
		sum-=_degver[x2][y1]-_degver[x1-1][y1];
		sum-=_degver[x2][y2+1]-_degver[x1-1][y2+1];
		printf("%d\n",(-sum)>>1);
	}
	return 0;
}

Measured memory_bytes: 53120
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut seen = 0;
    for a in a {
        if a == seen + 1 {
            seen += 1;
        }
    }
    if seen == 0 {
        puts!("-1\n");
    } else {
        puts!("{}\n", n - seen);
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

int main(){
	int n, r, t;
	cin >> n >> r >> t;
	vector<int> ps(n);
	for(int i = 0; i < n; ++i){
		cin >> ps[i];
	}
	int ans = 0;
	vector<int> cnt(r);
	for(int i = 1; i <= t; ++i){
		for(int j = 0; j < n; ++j){
			int x = i * ps[j] % r;
			if(cnt[x] == 0){ ++ans; }
			else{ --cnt[x]; }
		}
		if(i > 1){
			for(int j = 0; j < n; ++j){
				++cnt[i * ps[j] % r];
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

int h,w;
vector<vector<char>> s(400,vector<char>(400));
int black,white;
vector<int> dy,dx;

void dfs(int y,int x){
    (s[y][x]=='#'?black:white)++;
    char c=s[y][x];
    s[y][x]='-';
    rep(i,0,4){
        int ny=y+dy[i];
        int nx=x+dx[i];
        if(ny<0 || ny>=h || nx<0 || nx>=w) continue;
        if(s[ny][nx]=='-')  continue;
        if(s[ny][nx]==c) continue;
        //cout<<"("<<x<<","<<y<<") -> ("<<nx<<","<<ny<<")"<<endl;
        dfs(ny,nx);
    }
}

int main(){
    cin>>h>>w;
    rep(i,0,h) rep(j,0,w) cin>>s[i][j];
    dy={1,0,-1,0},dx={0,1,0,-1};
    
    ll ans=0;
    rep(i,0,h){
        rep(j,0,w){
            if(s[i][j]=='#'){
                black=0;
                white=0;
                dfs(i,j);
                //cout<<black<<white<<endl;
                ans+=(ll)black*white;
            }
        }
    }
    cout<<ans<<endl;
}



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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 a,b;
    cin >> a >> b;
    if(a > b)swap(a,b);
    REP(i,b)cout << a;
    cout << endl;
    return 0;
}

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

int main(){
	int N, M, C;
	cin >> N >> M >> C;
	int B[M], A[N][M], i, j;
	for(i=0; i<M; i++){
		cin >> B[i];
	}
	for(j=0; j<N; j++){
		for(i=0; i<M; i++){
			cin >> A[j][i];
		}
	}
	
	int ans = 0;
	for(j=0; j<N; j++){
		int tmp=C;
		for(i=0; i<M; i++){
			tmp += A[j][i]*B[i];
		}
		if(tmp > 0)	ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n) for(int i = 0; i < (n); i++)
const int MOD = 1e9+7;
int gcd(int a, int b){ //a>=0,b>=0,￢(a=b=0)
  while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);
}
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct Edge{int to,weight;};
/*----------------------------------------------*/

signed main(){
  int x,y;
  cin>>x>>y;
  int ans;
  if(x==-y) ans=1;
  else if(y>x){
    if(x*y<0) ans=1+abs(x+y);
    else ans=y-x;
  }
  else if(y==0){
    if(x<0) ans=-x;
    else ans=1+x;
  }else if(x==0){
    if(y>0) ans=y;
    else ans=-y+1;
  }
  else if(x*y>0) ans=x-y+2;
  else ans=abs(x+y)+1;
  cout<<ans<<endl;
  return 0;
}


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

int main(void){
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  bool flag = false;
  if(a + b <= 2 * c) flag = true;
  long long ans = 0;
  if(flag){
    ans += a * x + b * y;
  }else{
    if(x < y){
      ans += x * c * 2;
      long long temp = b * (y - x);
      ans += min(temp, (long long) c * 2 * (y - x));
    }else if(x > y){
      ans += y * c * 2;
      long long temp = a * (x - y);
      ans += min(temp, (long long) c * 2 * (x - y));
    }else{
      ans += x * c * 2;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

ll a,b;

void solve(){
 cin >> a >> b;
 vs s(100,string(100,'.'));
 rep(i,0,50) {
   rep(j,0,100) s[i][j]='#';
 }
   
   rep(i,0,50) {
     rep(j,0,100) {
  if(i%2||j%2) continue;
  if(a>1){
   s[i][j]='.';
   --a;
  }
 } 
   }
  
 rep(i,0,50) {
   rep(j,0,100) {
  if(i%2||j%2) continue;
  if(b>1){
   s[100-1-i][j]='#';
   --b;
  }
 } 
 }
  cout << 100 << " " << 100 << endl;
  rep(i,0,100) cout << s[i] << endl;

}

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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
unsigned long long sum=0;
int base=233;
char a[20];
unsigned long long ans[100010];
unsigned long long  has(char s[]){
	int len=strlen(s);
	unsigned long long out=0;
	for(int i=0;i<len;i++){
		out=(unsigned long long)(out*base+(unsigned long long)s[i]);
	}
	return out;
}
int p=1;
int main() {
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%s",a);
		sort(a,a+strlen(a));
		ans[i]=has(a);
	}
	sort(ans+1,ans+n+1);
	for(int i=1;i<n;i++){
		if(ans[i]==ans[i+1]){
		
			sum+=p;
			p++;
		}
		else p=1;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 1024
use proconio::{fastout, input};

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

    let mut index = 0;
    let mut max = 0;
    let mut step = 0;

    for i in 0..n - 1 {
        if h[i] < h[i + 1] {
            step = 0;
        } else {
            step += 1;
            max = std::cmp::max(max, step);
        }
    }

    println!("{}", max)
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    int maxi = 0, sum = 0;
    rep(i,0,N){
        int a;
        cin >> a;
        sum += a;
        maxi = max(maxi, a);
    }
    sum -= maxi / 2;
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>

using namespace std;

int main (){
  int q,t,x,y;
  multiset<int> a;

  cin >> q;

  for (int i = 0; i < q; i++){
    cin >> t;
    cin >> x;
    if (t==0){
      a.insert(x);
      cout << a.size() << endl;
    }else if(t==1){
      cout << a.count(x) << endl;
    }else if(t==2){
      a.erase(x);
    }else{
      cin >> y;
      auto it = a.lower_bound(x);
      auto last = a.upper_bound(y);

      while (it != last) {
        cout << *it << endl;
        ++it;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 12316
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int top = 0,S[1000];


void push(int x) {
	S[top ++] = x;
}

int pop() {
	return S[--top];
}
 
int main(void) {
	int a,b;
	top = 0;
	char s[100];
	
	while (scanf("%s",s) != EOF) {
        if ( s[0] == '+') {
            a = pop();
            b = pop();
            push ((a + b));
        }else if( s[0] == '-') {
            b = pop();
            a = pop();
            push ((a - b));
        }else if( s[0] == '*') {
            a = pop();
            b = pop();
            push ((a * b));
        }else{
            push(atoi(s));
        }
    }

    printf("%d\n",pop());

    return 0;
}

Measured memory_bytes: 548
public class
Main
{
  public void
  run (
    final java.util.Scanner sc,
    final java.io.PrintStream out
    )
  {
    int i;

    for ( ; ; )
    {
      int n;

      n = sc.nextInt ( );
      if ( n == 0 ) break ;
      for ( i = 0; i < n; ++i )
      {
        int x1, y1, z1, w1;
        int x2, y2, z2, w2;

        x1 = sc.nextInt ( ); y1 = sc.nextInt ( ); z1 = sc.nextInt ( ); w1 = sc.nextInt ( );
        x2 = sc.nextInt ( ); y2 = sc.nextInt ( ); z2 = sc.nextInt ( ); w2 = sc.nextInt ( );

        out.printf ( "%d %d %d %d\n"
                   , x1 * x2 - y1 * y2 - z1 * z2 - w1 * w2
                   , y1 * x2 + x1 * y2 - w1 * z2 + z1 * w2
                   , z1 * x2 + w1 * y2 + x1 * z2 - y1 * w2
                   , w1 * x2 - z1 * y2 + y1 * z2 + x1 * w2 );
      }
    }
  }

  public static void
  main (
    final String[ ] args
    )
  {
    ( new Main ( ) ).run ( new java.util.Scanner ( System.in ), System.out );
  }
}

Measured memory_bytes: 24404
def main():
    h, w, m = map(int, input().split())
    h_bomb_dict = {}
    w_bomb_dict = {}
    bombs = []
    for i in range(m):
        zh, zw = map(int, input().split())
        bombs.append((zh, zw))
        if zh in h_bomb_dict.keys():
            h_bomb_dict[zh] += 1
        else:
            h_bomb_dict[zh] = 1

        if zw in w_bomb_dict.keys():
            w_bomb_dict[zw] += 1
        else:
            w_bomb_dict[zw] = 1
    bombs = set(bombs)

    hbombs = max(h_bomb_dict.values())
    wbombs = max(w_bomb_dict.values())
    h_maxs = []
    w_maxs = []
    for key, v in h_bomb_dict.items():
        if v == hbombs:
            h_maxs.append(key)

    for key, v in w_bomb_dict.items():
        if v == wbombs:
            w_maxs.append(key)

    for h in h_maxs:
        for w in w_maxs:
            if not (h, w) in bombs:
                print(hbombs + wbombs)
                return
    print(hbombs + wbombs-1)
if __name__ == '__main__':
    main()

Measured memory_bytes: 84600
#include <stdio.h>

int main() {
  int R,G,B,N,r,g,b,count=0,balls,i,j,number[3],tmp;
  scanf("%d%d%d%d",&number[0],&number[1],&number[2],&N);
  for(i=0;i<3;i++){
    for(j=i+1;j<3;j++){
      if(number[i]>number[j]){
	tmp=number[i];
	number[i]=number[j];
	number[j]=tmp;
      }
    }
  }
  R=number[2];
  G=number[1];
  B=number[0];
  for(r=0;r<=N/R;r++){
    for(g=0;g<=N/G;g++){

      balls=R*r+G*g;
      b=(N-balls)/B;
      //printf("%d %d %d\n",b,g,r);
      if(b>=0){
	if(balls+B*(b-1)==N){
	  count++;
	}
	else if(balls+B*b==N){
	  count++;
	}
	else if(balls+B*(b+1)==N){
	  count++;
	}
      }
      
      /*
      for(b=0;b<=N/B;b++){
	balls=R*r+G*g+B*b; 
	if(balls==N){
	  count++;
	}
	else if(balls>N){
	  break;
	}
      }
      */
    }
  }
  
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, T;
  cin >> N >> T;
  vector<int> Cd(T + 1, 0);
  for (int i = 0; i < N; i++){
    int l, r;
    cin >> l >> r;
    Cd[l]++;
    Cd[r]--;
  }
  vector<int> C(T + 2, 0);
  for (int i = 0; i <= T; i++){
    C[i + 1] = C[i] + Cd[i];
  }
  int M = 0;
  for (int i = 0; i <= T + 1; i++){
    M = max(M, C[i]);
  }
  cout << M << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;

// #define DEBUG

int main()
{
#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, p, s, t;
    p = -1e9;
    cin >> n;
    cin >> s;
    for (int i = 0; i < n - 1; i++)
    {
        cin >> t;
        p = max(p, t - s);
        if (s > t)
            s = t;
    }
    cout << p << endl;
    return 0;
}

// getline(cin,s);
// a = strtok(s, ",");  ","で分解
// for (int i = 0; i < n; i++)


Measured memory_bytes: 3116
#include<iostream>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  998244353
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int link[N];
int sz[N];
void init(int n)
{
    rep(i,1,n+1)link[i]=i;
    rep(i,1,n+1)sz[i]=1;
}
int fnd(int x)
{
    if(link[x]==x)return x;
    return link[x]=fnd(link[x]);
}
void unite(int a,int b)
{
    a=fnd(a);
    b=fnd(b);
    if(sz[a]<sz[b])swap(a,b);
    sz[a]+=sz[b];
    link[b]=a;
}
int calc(int x)
{
    return (x*(x-1))/2;
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n,m;
   cin>>n>>m;
   int tot=calc(n);
   vector<pii>v;
   for(int i=0;i<m;i++)
   {
       int x,y;
       cin>>x>>y;
       v.pb({x,y});
   }
   reverse(all(v));
   init(n);
   //debug(v);
   vi answer;
   for(int i=0;i<m;i++)
   {   answer.pb(tot);
       int a=fnd(v[i].F);
       int b=fnd(v[i].S);
       if(a == b)continue;
       int val=calc(sz[a]) + calc(sz[b]);
       unite(a,b);
       a=fnd(a);
       val-=calc(sz[a]);
       val*=-1;
       tot-=val;
   }
   reverse(all(answer));
   for(auto x:answer)
    cout<<x<<endl;

}


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

ll N;
vector<ll> dvs;

void divisor(ll n) {
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      dvs.push_back(i);
      if (i != n / i) {
        dvs.push_back(n / i);
      }
    }
  }
}

void solve() {
  divisor(N);
  sort(dvs.begin(), dvs.end());

  ll n = dvs.size();
  ll res = 0;
  for (ll i = 0; i < n; i++) {
    if (N / dvs[i] < dvs[i] - 1) {
      res += dvs[i] - 1;
    }
  }
  cout << res << '\n';
}

int main() {
  cin >> N;
  solve();
  return 0;
}

Measured memory_bytes: 384
import java.util.*;
class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();
    
    if(s.equals("SUN")){
      System.out.println(7);
      }else if(s.equals("MON")){
      System.out.println(6);
      }else if(s.equals("TUE")){
      System.out.println(5);
      }else if(s.equals("WED")){
      System.out.println(4);
      }else if(s.equals("THU")){
      System.out.println(3);
      }else if(s.equals("FRI")){
      System.out.println(2);
      }else if(s.equals("SAT")){
      System.out.println(1);
    }
  }
}

Measured memory_bytes: 21332
N_num = int(input())

N = []

for i in range(N_num):
    N.append(input())
    

AC_num = 0
WA_num = 0
TLE_num = 0
RE_num = 0

for i in range(N_num):
    #print(i+1)
    
    if 'AC' == N[i]:
        AC_num += 1
        #print(AC_num)
    
    elif 'WA' == N[i]:
        WA_num += 1
        #print(WA_num)

    elif 'TLE' == N[i]:
        TLE_num += 1
        #print(TLE_num)
    
    elif 'RE' == N[i]:
        RE_num += 1
        #print(RE_num)


print('AC x {}'.format(AC_num))
print('WA x {}'.format(WA_num))
print('TLE x {}'.format(TLE_num))
print('RE x {}'.format(RE_num))

Measured memory_bytes: 16144
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>

using namespace std;


int main(){
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  cout << (H - h) * (W - w) <<endl;
}


Measured memory_bytes: 256
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

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

print(max(0, N-2*M))


Measured memory_bytes: 77444
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

inf = 10 ** 18
mod = 10 ** 9 + 7

n = ir()
c = [ir() for i in range(n)]
dp = [0 for i in range(n+1)]
dp[0] = 1
pre_ind = [-inf for i in range(2*(10**5)+1)]
num_ind = [0 for i in range(2*(10**5)+1)]
for i in range(n):
    now = c[i]
    if pre_ind[now] == -inf or pre_ind[now] == i-1:
        dp[i+1]=dp[i]
        if pre_ind[now] == -inf:
            num_ind[now] = dp[i+1]
        pre_ind[now] = i
    else:
        dp[i+1]=(dp[i]+num_ind[now])%mod
        num_ind[now] = dp[i+1]
        pre_ind[now] = i
print(dp[n])

Measured memory_bytes: 133324
import sys
s = list(input())
t = list(input())

s.sort()
t.sort(reverse = True)
flag = False

S = len(s)
T = len(t)
# print ('a' < 'b')

# print (s, t)

for i in range(min(S,T)):
    if s[i] < t[i]:
        print ('Yes')
        sys.exit()
    if s[i] > t[i]:
        print ('No')
        sys.exit()
    if i == min(S,T) - 1 and T <= S:
        print ('No')
        sys.exit()

print ('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int N, K;
    cin >> N >> K;

    vector<int> x(N);
    bool flag = false;
    int count = 0;

    for(int i = 0; i < N; i++) {
        cin >> x[i];
        if(x[i] == 0) {
            if(K == 1) {
                cout << 0 << endl;
                return 0;
            }
            N--;
            i--;
            K--;
        } else if(!flag && x[i] > 0) {
            flag = true;
            count = i;
        }
    }

    if(!flag) {
        count = N;
    }

    int ans = pow(10, 9);

    int n = K - 1;
    if(K <= count) {
        n = count;
        ans = - x[count - K];
        //cerr << ans << endl;
    }

    for(int i = n; i < N; i++) {

        if(i - K + 1 == count) {
            break;
        }

        int a = - x[i - K + 1] * 2 + x[i];
        int b = - x[i - K + 1] + x[i] * 2; 
        ans = min(ans, min(a, b));
        //cerr << "a " << a << " b " << b << endl;
    }

    if(N - count >= K) {
        ans = min(ans, x[count + K - 1]);
        //cerr << x[count + K - 1] << endl;
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#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)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    int X,Y;
    cin >> X >> Y;
    if(Y%2 == 1){
        cout << "No" << "\n";
    }else if(X*2 <= Y && Y <= 4*X){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }
}

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

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

  int ans = 0;
  for (int i = 0; i < s.size() / 2; i++) {
    if (s[i] != s[s.size()-i-1]) {
      ans++;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i,c;
  int k = 0;
  char S[200];
  scanf("%s",S);
  for(i=0;S[i]!='\0';i++);
    for(c=0;c<i/2;c++){
      if(S[c]!=S[i-1-c])++k;
    }
  printf("%d",k);
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
  int n,V[20],C[20], z=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> V[i];
  }
  for(int i=0;i<n;i++){
    cin >> C[i];
  }
  for(int i=0;i<n;i++){
    if(V[i]>C[i]) z += V[i]-C[i];
  }
  cout << z;
  return 0;
}

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

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    //int a[10000];
    long x[1000], y[1000], z[1000];
    for(int i = 0; i < N; i++){
      //  cin >> a[i];
        cin >> x[i] >> y[i] >> z[i];
        
    }
    long res = 0;
    long a=-1, b = -1, c = -1;
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < 2; j++){
            for(int k = 0; k < 2; k++){
                //cout << a << b<< c << endl;
                long s = 0;      
                vector<long> v;          
                for(size_t n = 0; n < N; n++){
                    long t = x[n]*a + y[n]*b + z[n]*c;
                    
                    v.push_back(t);
                    
                }
                sort(v.begin(), v.end());
                //for(int n = 0; n < N; n++){
                //    cout << v[n] << endl;
                //}
                for(int n = 0; n < M; n++){
                    //cout << v[M-1-n] << endl;
                    s+=v[N-1-n];
                }
                //cout << s << endl;
                res = max(res, s);
                c*=-1;
            }b*=-1;
        }a*=-1;
    }
    cout << res << endl;


    return 0;
}

Measured memory_bytes: 256
c=[chr(i) for i in range(65,65+26)]
#print(c)
n=int(input())
s=input()
for i in range(len(s)):
    if c.index(s[i])+n<26:
        print(c[c.index(s[i])+n],end="")
    else:
        print(c[c.index(s[i])+n-26],end="")
print()


Measured memory_bytes: 4468