akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const int INF_INT = 1 << 25;
const long long MOD = (ll) 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
const int loose = 0;
const int tight = 1;


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;
}

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll n,m;
	cin>>n>>m;

	Graph g(n);
	Array l;//左端から広げる
	Array r;//右端から広げる
	Array used(n,false);

	//最初の一辺からパスを広げてく
	ll a,b;
	cin>>a>>b;
	a--;b--;
	add_edge(g,a,b,1,true,1);
	l.push_back(a);
	r.push_back(b);
	used[a]=true;
	used[b]=true;

	REP(i,m-1){
		cin>>a>>b;
		a--;b--;
		add_edge(g,a,b,1,true,1);
	}

	bool flag_l=true;
	bool flag_r=true;

	while(flag_l){
		int v = l[l.size()-1];
		for(auto e:g[v]){
			if(!used[e.to]){
				l.push_back(e.to);
				used[e.to]=true;
				break;
			}
		}
		if(v==l[l.size()-1]) flag_l=false;
	}
	
	while(flag_r){
		int v = r[r.size()-1];
		for(auto e:g[v]){
			if(!used[e.to]){
				r.push_back(e.to);
				used[e.to]=true;
				break;
			}
		}
		if(v==r[r.size()-1]) flag_r=false;
	}

	cout<<l.size()+r.size()<<en;
	reverse(all(l));
	for(auto v: l){
		cout<<v+1<<" ";
	}
	for(auto v:r){
		cout<<v+1<<" ";
	}

	cout<<en;

    return 0;
}

Measured memory_bytes: 11636
// inputに入力データ全体が入る
function Main(input) {
 
  let val = parseInt(input);
  let ans = Math.floor(val / 500) * 1000;
  val %= 500;
  console.log(ans + Math.floor(val / 5) * 5)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  int n; cin >> n;
  vector<ll> a(n), sum(n+1);
  sum[0] = 0;
  rep(i,n) {
    cin >> a[i];
    sum[i+1] = a[i] + sum[i];
  }

  map<ll,int> mp;
  for (int i = 1; i <= n; ++i) {
    mp[sum[i]] += 1;
  }
  ll ans = 0;
  mp[0] += 1;
  for (auto itr : mp) {
    if (itr.second > 1) {
      ll t = itr.second;
      ans += (t-1) * t / 2;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
int n,a[100010],ans,mn,dap,t;
int main()
{
 //   freopen("input.txt","r",stdin);
    scanf("%d%d",&n,&t);
   int i;
    for(i=1;i<=n;i++){
        scanf("%d",&a[i]);

    }
    mn=INF;
    for(i=1;i<=n;i++){
        ans=max(ans,a[i]-mn);
        mn=min(mn,a[i]);
       // printf("%d %d\n",i,mn);
    }
    mn=INF;

    for(i=1;i<=n;i++){
        if(ans==a[i]-mn)
        dap++;
            mn=min(mn,a[i]);
    }
    printf("%d",dap);
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <map>

using namespace std;

int memo[100] = {0};

int main() {
	map<int, bool> m;
	for (int a = 0; a < 10; ++a)
		for (int b = 0; b < 10; ++b)
			for (int c = 0; c < 10; ++c)
				for (int d = 0; d < 10; ++d)
					++memo[a+b+c+d];

	int n;
	while (scanf("%d", &n) != EOF) {
		cout << memo[n] << endl;
	}
}

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

int dp[3005][3005];

int main() {
	string s, t;
	cin >> s >> t;
	int l1 = s.length(), l2 = t.length();

	for (int i = 0; i <= l1; i++) {
		for (int j = 0; j <= l2; j++) {
			if (i == 0 || j == 0)
				dp[i][j] = 0;
			else {
				if (s[i - 1] == t[j - 1]) {
					dp[i][j] =  dp[i - 1][j - 1] + 1;
				}
				else {
					dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
				}
			}
		}
	}
	string ans;
	int i = l1, j = l2;
	//Backtracking
	while (i > 0 && j > 0) {
		if (s[i-1]==t[j-1]) {
			ans.push_back(s[i-1]);
			i--; j--;
		} else if (dp[i][j] == dp[i - 1][j]) {
			i--;
		} else {
			j--;
		}
	}
	//cout << dp[l1][l2] << endl;
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 38836
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

void move_N(int D[]){
	int tmp=D[0];
	D[0]=D[1];
	D[1]=D[5];
	D[5]=D[4];
	D[4]=tmp;
}
void move_S(int D[]){
	int tmp=D[0];
	D[0]=D[4];
	D[4]=D[5];
	D[5]=D[1];
	D[1]=tmp;
}
void move_E(int D[]){
	int tmp=D[0];
	D[0]=D[3];
	D[3]=D[5];
	D[5]=D[2];
	D[2]=tmp;
}
void move_W(int D[]){
	int tmp=D[0];
	D[0]=D[2];
	D[2]=D[5];
	D[5]=D[3];
	D[3]=tmp;
}

void move_right(int D[]){//上から見て時計回り
	int tmp=D[1];
	D[1]=D[2];
	D[2]=D[4];
	D[4]=D[3];
	D[3]=tmp;
}

int main(){
	int D[6];
	int n;
	int u,d;
	int flag=0;

	for(int i=0;i<6;i++){
		scanf("%d",&D[i]);
	}
	scanf("%d",&n);

	for(int i=0;i<n;i++){
		scanf("%d %d",&u,&d);
		flag=0;
		for(int j=0;j<3;j++){
			if(D[0]==u){
				flag=1;
				break;
			}
			move_N(D);
		}
		if(flag==0){
			for(int j=0;j<3;j++){
				if(D[0]==u){
					flag=1;
					break;
				}
				move_E(D);
			}
		}

		for(int i=0;i<3;i++){
			if(D[1]==d){
				break;
			}
			move_right(D);
		}

		printf("%d\n",D[2]);
	}

	

	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  for (int i = 2; i < s.size(); i += 2) {
    if (s.substr(0, (s.size() - i) / 2) == s.substr((s.size() - i) / 2, (s.size() - i) / 2)) {
      cout << s.size() - i << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    static String classify(double w) {
        if (w <= 48.00)
            return "light fly";
        else if (w <= 51.00)
            return "fly";
        else if (w <= 54.00)
            return "bantam";
        else if (w <= 57.00)
            return "feather";
        else if (w <= 60.00)
            return "light";
        else if (w <= 64.00)
            return "light welter";
        else if (w <= 69.00)
            return "welter";
        else if (w <= 75.00)
            return "light middle";
        else if (w <= 81.00)
            return "middle";
        else if (w <= 91.00)
            return "light heavy";
        else
            return "heavy";
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String line;
        while ((line = br.readLine()) != null) {
            System.out.println(classify(Double.parseDouble(line)));
        }

    }
}


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

int main() {
    int64_t K;
    cin >> K;

    unordered_set<int64_t> exist_mod;
    int64_t mod = 0;
    for (uint64_t i = 1; true; i++) {
        mod = (mod * 10 + 7) % K;
        if (exist_mod.count(mod) > 0) {
            cout << -1 << endl;
            break;
        }
        if (mod == 0) {
            cout << i << endl;
            break;
        }
        exist_mod.insert(mod);
    }
}


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

int main(void){
    int n,t;
    cin >> n >> t;
    int a[1001],b[1001];
    for(int i = 0;i < n;i++)cin >> a[i] >> b[i];
    int min = 1001;
    for(int i = 0;i < n;i++){
        if(min > a[i] && t >= b[i])min = a[i];
    }
    if(min == 1001)cout << "TLE";
    else cout << min;
}

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

int main(){
    string S;
    cin >> S;
    int a;
    int M = 1000;

    for(int i=0;i<=S.length()-3;i++){
        int b=(int)(S[i]-'0');
        int c=(int)(S[i+1]-'0');
        int d=(int)(S[i+2]-'0');
        a = 100*b + 10*c + d;
        M = min(M,abs(753-a));
    }
    cout << M << endl;
}


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

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

    scanf("%d%d", &a, &b);

    if(a<=b){
        i = a;
    }

    else{
        i = a-1;
    }

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

    return 0;
}

Measured memory_bytes: 128
h, w = map(int, input().split())
s = [input()+ "#" for i in range(h)] +["#"* (w+1)]

yoko = [[0] * (w) for i in range(h)]


for i in range(h+1):
    cnt = 0
    start = 0
    for j in range(w+1):
        if s[i][j] == ".":
            cnt += 1
        else:
            for k in range(start, j):
                yoko[i][k] += cnt
            cnt = 0
            start = j + 1
for i in range(w+1):
    cnt = 0
    start = 0
    for j in range(h+1):
        if s[j][i] == ".":
            cnt += 1
        else:
            for k in range(start, j):
                yoko[k][i] += cnt
            cnt = 0
            start = j + 1
ans = 0
for i in range(h):
    ans = max(max(yoko[i]), ans)
print(ans - 1)
    

Measured memory_bytes: 97624
N = gets.to_i
ans = 10**10
(1..(N/2+1)).each do |a|
    b = N - a
    result = a.to_s.split('').map(&:to_i).inject(0, :+) + b.to_s.split('').map(&:to_i).inject(0, :+)
    ans = result if ans > result
end
puts ans

Measured memory_bytes: 2044
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		int cnt = 0;
		if(a==b)
			cnt++;
		if(a==c)
			cnt++;
		if(b==c)
			cnt++;
		
		System.out.println(cnt==1 ? "Yes" : "No");
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
int n,i,a=-1,z=-1;
string s;
cin>>s;
n=s.size();
for(i=0;i<n;++i){
    if(s[i]=='A'&&a==-1){
        a=i;
    }
    else if(s[i]=='Z'){
        z=i;
    }
}
printf("%d",z-a+1);


    return 0;
}


Measured memory_bytes: 3840
typedef long long ll;
#include "bits/stdc++.h"
using namespace std;
int main() {
	int n;
	cin >> n;
	
	if (n == 25) {
		cout << "Christmas" << endl;
	}
	else if (n == 24) {
		cout << "Christmas Eve" << endl;
	}
	else if (n == 23) {
		cout << "Christmas Eve Eve" << endl;
	}
	else if (n == 22) {
		cout << "Christmas Eve Eve Eve" << endl;
	}

	
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    char s[3]={};
    scanf("%s",&s);
    if(s[0]=='a'&&s[1]=='b'&&s[2]=='c')printf("Yes");
    else if(s[0]=='a'&&s[1]=='c'&&s[2]=='b')printf("Yes");
    else if(s[0]=='b'&&s[1]=='a'&&s[2]=='c')printf("Yes");
    else if(s[0]=='b'&&s[1]=='c'&&s[2]=='a')printf("Yes");
    else if(s[0]=='c'&&s[1]=='a'&&s[2]=='b')printf("Yes");
    else if(s[0]=='c'&&s[1]=='b'&&s[2]=='a')printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define int LL
#define upto(a, b, i) for(int i = (a), b_ = (b); i <= b_; ++i)
#define uptil(a, b, i) for(int i = (a), b_ = (b); i < b_; ++i)
#define downto(a, b, i) for(int i = (a), b_ = (b); i >= b_; --i)
#define downtil(a, b, i) for(int i = (a), b_ = (b); i > b_; --i)
#define times(n, i) uptil(0, n, i)
#define rtimes(n, i) downto((n)-1, 0, i)

#define sp <<" "
#define ln <<endl
#define size(x) ((int)x.size())
template<class T> using vec = vector<T>;
template<class T> using vvec = vec<vec<T>>;

constexpr int mod = 1e9 + 7;

int N, K, ans;
vvec<int> edges;

void dfs(int a, int p, int lv, int bro) {
  ans = ans * max(0ll, K - min(2ll, lv) - bro) % mod;

  int i = 0;
  for(int c : edges[a]) if(c != p) {
    dfs(c, a, lv + 1, i);
    ++i;
  }
}

void solve() {
  while(cin >> N >> K) {
    ans = 1;
    edges.clear();
    edges.resize(N);

    times(N-1, i) {
      int A, B; cin >> A>>B; --A; --B;
      edges[A].push_back(B);
      edges[B].push_back(A);
    }

    dfs(0, 0, 0, 0);
    cout << ans ln;
    cerr ln;
  }
}

signed main() {
  cout << fixed << setprecision(20);
  cerr << fixed << setprecision(6);
  solve();
  return 0;
}


Measured memory_bytes: 10368
from queue import Queue
INF = 10 ** 6
N, M = map(int,input().split())
Q = Queue()
edges = [[] for _ in range(N+1)]
guidepost = [INF for _ in range(N+1)]
for _ in range(M):
    A, B = map(int,input().split())
    edges[A].append(B)
    edges[B].append(A)
Q.put(1)
while not Q.empty():
    parent = Q.get()
    for i in edges[parent]:
        if guidepost[i] == INF:
            guidepost[i] = parent
            Q.put(i)
print('Yes')
for i in range(2,N+1):
    print(guidepost[i])

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vi d(n);
  for(int i=0;i<n;++i) {
    cin >> d[i];
  }
  sort(d.begin(), d.end());

  int mi = d[n/2-1], ma = d[n/2];
  cout << ma - mi << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

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

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

int main() {
    string S, T, U;
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    cin >> U;
    if (S == U) {
        A--;
    } else {
        B--;
    }
    cout << A << " " << B << endl;
    return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int cases;
int p,q;

int main(){
	cin.sync_with_stdio(false);
	cin>>cases;
	while(cases--){
		cin>>p>>q;
		bool is_prime=true;
		for(int m=-sqrt(p*p+q*q);m*m<=p*p+q*q;m++){
			for(int n=-sqrt(p*p+q*q-m*m);n*n<=p*p+q*q-m*m;n++){
				if((m==1&&n==0)||(m==0&&n==1)||(m==-1&&n==0)||(m==0&&n==-1)||
					(m==p&&n==q)||(m==-p&&n==-q)||(m==-q&&n==p)||(m==q&&n==-p))continue;
				if((m*m+n*n)!=0&&(m*p+n*q)%(m*m+n*n)==0&&(m*q-n*p)%(m*m+n*n)==0){
					is_prime=false;
				}
			}
		}
		if(is_prime)cout<<"P"<<endl;
		else cout<<"C"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3032
#include<stdio.h>
#include<string.h>

int ch(int input,int count){
	int tmp;
	tmp=input/10;
	if(tmp>0){
		count++;
		ch(tmp,count);
	}
	else{
		return  count;		
	}
}

int ren(int m,int n){
	int x;
	int y;
	x=(n+m)/2;
	y=(n-m)/2;
	if((x+y)==n && (x-y)==m && x>=0 && y>=0){
		return 1;
	}
	else return 0;
}
	

int main(){
	
	int x;
	int y;
	int input;
	int keta=1;
	int count=1;
	int i;
	int m;
	int n;
	int output=0;
	int Nc=1;
	int Nk=1;
	int s;
	
	scanf("%d",&input);
	
	count = ch(input,count);
	for(i=0;i<count;i++){
		keta*=10;
	}
	for(i=keta;i>0;i=i/10){
		
		m = input/i;
		n = input%i;
		Nc = ch(n,Nc);
		for(s=1;s<Nc;s++){
			Nk*=10;
		}
		if(Nk==(i/10)){
			output+=ren(m,n);
		}
		Nk=1;
		Nc=1;
	}
	printf("%d\n",output);
	
	
	return 0;
}

Measured memory_bytes: 596
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        n: usize,
        m: usize,
        bd: [[usize1]; n],
    }

    let mut cnt = vec![0; m];
    for ref row in bd.iter() {
        for &c in row.iter() {
            cnt[c] += 1;
        }
    }

    let ans = cnt.iter().filter(|&&c| c == n).count();

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define rep(I,N) up(I,0,N-1)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<"\n";}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<"\n";}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<"\n";}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<"\n";}
inline void                                              out(ld p){printf("%.12Lf\n",p);}
template<class T>inline void outml(T p){for_each(all(p),out<decltype(p[0])>);}//ml=multi line
template<class T>inline void outol(T V){auto n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}//ol=one line
ld a,b;
inline void solve(void){
  in(a,b);
  out((long)(a*b));
}
int main(void){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 3748
def mainC():
    #import numpy as np
    N = int(input())
    a = list(map(int, input().split()))
    s = sum(a)
    d2 = a[0]
    m = abs(s-2*d2)
    for i in range(1, N-1):
        d2 += a[i]
        m = min( m, abs(s-2*d2) )
    print( m )

mainC()

Measured memory_bytes: 23800
#include <iostream>
#include <vector>

using namespace std;

int gcd(int x, int y){
    while(true)
        if(y > 0 && x > y) x = x % y;
        else if(x > 0 && y > x) y = y % x;
        else break;

    return max(x, y);
}

int main(void){
    int n;
    cin >> n;
    vector<int> v, gcdL, gcdR;
    v.reserve(n);
    gcdL.reserve(n);
    gcdR.reserve(n);
    for(int i = 0; i < n; ++ i) cin >> v[i];
    for(int i = 0; i < n - 1; ++ i){
        gcdL[i] = ((i == 0)? v[i] : gcd(gcdL[i - 1], v[i]));
        gcdR[n - 1 - i] = ((i == 0)? v[n - 1 - i] : gcd(gcdR[n - i], v[n - 1 - i]));
    }
    int tmpmax = 1;
    for(int i = 0; i < n; ++ i){
        tmpmax = max(tmpmax, ((i == 0)? gcdR[1] : ((i == n - 1)? gcdL[n - 2] : gcd(gcdL[i - 1], gcdR[i + 1]))));
    }

    cout << tmpmax << endl;
    
    return 0;
}


Measured memory_bytes: 1408
using System;

namespace OJcsharp
{
    class Program
    {
        static void Main(string[] args)
        {
            double high, low;
            string str = Console.ReadLine();
            high = double.Parse(str);
            low = double.Parse(str);
            do
            {
                if (high < double.Parse(str))
                    high = double.Parse(str);
                if (low > double.Parse(str))
                    low = double.Parse(str);
                str = Console.ReadLine();
            } while (string.IsNullOrEmpty(str) == false);
            Console.WriteLine(high - low);
        }
    }
}

Measured memory_bytes: 5752
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int m = sc.nextInt();
    int n = sc.nextInt();
    
    int mMinusOne = m - 1;
    int nMinusOne = n - 1;
    
    System.out.println(mMinusOne * nMinusOne);
  }
}

Measured memory_bytes: 19412
#include <cstdio>

int G[101];
int A[1000002];

int insertion_sort(int *A, int n, int g)
{
    int cnt = 0;
    for (int i = g; i < n; ++i)
    {
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v)
        {
            A[j+g] = A[j];
            j -= g;
            cnt++;
        }
        A[j+g] = v;
    }
    return cnt;
}

int shell_sort(int *A, int n)
{
    int cnt = 0;
    G[0] = 1;
    int m = 0;
    do {
        G[m+1] = G[m] * 3 + 1;
    } while (G[++m] < n);
    printf("%d\n", m);
    for (int i = m-1; i >= 0; --i) {
        if (i < m-1) putchar(' ');
        printf("%d", G[i]);
        cnt += insertion_sort(A, n, G[i]);
    }
    printf("\n%d\n", cnt);
    for (int i = 0; i < n; ++i)
        printf("%d\n", A[i]);
}

int main(int argc, char const *argv[])
{
    int N;
    scanf("%d", &N);
    for (int i = 0; i < N; ++i)
        scanf("%d", &A[i]);

    shell_sort(A, N);

    return 0;
}

Measured memory_bytes: 4936
/*

    author : s@if

*/

#include<bits/stdc++.h>
using namespace std;
#define NIL -1
#define fi first
#define sec second
#define MAX INT_MAX
#define INF 99999999
#define ll long long
#define PI acos(-1.0)
#define MOD 1000000007
#define PLL pair<ll,ll>
#define PII pair<int,int>
#define triplell pair<pair<ll,ll> , ll>
#define triple pair<pair<int,int> , int>
#define For(i,n) for(int i=0;i<(int)n;i++)
#define Forn(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define forba(i,a,b) for(int i=(int)b;i>=(int)a;i--)

int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};
int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hr[]={-2,-2,-1,+1,+2,+2,-1,+1};
int hc[]={+1,-1,+2,+2,-1,+1,-2,-2};

const int MAXN = (int)1e5+9;

const int N = 100000;

int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */
    
    ll i,j,k,l,m,n,p,q,r,tc,t;
    
    cin>>n>>m;
    
    PLL ara[n+9];
    
    for(i=1;i<=n;i++)
    {
    	cin>>ara[i].fi>>ara[i].sec;
	}
	
	sort(ara+1,ara+n+1);
	
	ll ans = 0;
	
	for(i=1;i<=n;i++)
	{
		if(m==0)
			break;
			
		if(ara[i].sec<m)
		{
			ans+=ara[i].sec*ara[i].fi;
			m-=ara[i].sec;
		}
		else
		{
			ans+=ara[i].fi * (min(m,ara[i].sec));
			m-=min(m,ara[i].sec);
		}
	}
	
	cout<<ans<<endl;
	
//	main();

    return 0;
}

Measured memory_bytes: 1920
//#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

const long long MOD = 1e9 + 7;

int main() {
	long long n, k;
	cin >> n >> k;
	long long ans = 0;

	for (long long i = k; i <= n + 1; i++) {
		long long minv = (0 + i - 1) * i / 2;
		long long maxv = (n - i + 1 + n) * i / 2;
		ans = ans + maxv - minv + 1;
		ans = ans % MOD;
	}

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

Measured memory_bytes: 3584
class Node:
    def __init__(self, key):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None
        
    def insert(self, z):
        if z.key < self.key:
            if self.left:
                self.left.insert(z)
            else:
                self.left = z
                z.parent = self
        else:
            if self.right:
                self.right.insert(z)
            else:
                self.right = z
                z.parent = self

    def find(self, key):
        if self.key == key:
            return True
        elif not(self.left or self.right):
            return False
        else:
            if key < self.key:
                return self.left.find(key)
            else:
                return self.right.find(key)
    def preo(self):
        tmp = ""
        tmp += " " + str(self.key)
        if self.left:
            tmp += self.left.preo()
        if self.right:
            tmp += self.right.preo()
        return tmp
    
    def ino(self):
        tmp = ""
        if self.left:
            tmp += self.left.ino()
        tmp += " " + str(self.key)
        if self.right:
            tmp += self.right.ino()
        return tmp
    
m = int(input())
root = None
for i in range(m):
    com = input().split()
    if com[0] == "insert":
        node = Node(int(com[1]))
        try:
            root.insert(node)
        except AttributeError :
            root = node
    elif com[0] == "find":
        try:
            if root.find(int(com[1])):
                print("yes")
            else:
                print("no")
        except AttributeError:
            print("no")
    else:
        try:
            print(root.ino())
            print(root.preo())
        except AttributeError:
            print("None")


Measured memory_bytes: 94892
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

const ll MOD = 998244353ll;

ll power(ll x, ll e) {
  ll v = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) {
      v = v * x % MOD;
    }
    x = x * x % MOD;
  }
  return v;
}

ll inverse(ll x) {
  return power(x, MOD - 2);
}

vector<ll> fact, factInv;
void initFact(int N) {
  fact.resize(N + 1);
  factInv.resize(N + 1);
  fact[0] = 1;
  for (int i = 1; i <= N; i++) {
    fact[i] = fact[i - 1] * i % MOD;
  }
  factInv[N] = inverse(fact[N]);
  for (int i = N - 1; i >= 0; i--) {
    factInv[i] = factInv[i + 1] * (i + 1) % MOD;
  }
}

ll choose(int n, int k) {
  if (n < 0 || k < 0 || k > n) {
    return 0;
  } else {
    return fact[n] * factInv[k] % MOD * factInv[n - k] % MOD;
  }
}

vec<ll, 2> tbl;
void init(int N) {
  initFact(N);
  tbl.resize(N + 1);
  for (int i = 0; i <= N; i++) {
    tbl[i].resize(N + 2);
    tbl[i][0] = 0;
    for (int j = 0; j <= N; j++) {
      tbl[i][j + 1] = (tbl[i][j] + choose(i - j, j)) % MOD;
    }
  }
}

ll solveLess(int N, int X) {
  ll res = 0;
  for (int two = 0; two <= N; two++) {
    int one = N - two;
    if (2 * two + one < X) {
      ll ways = choose(N, two);
      res = (res + ways) % MOD;
    }
  }
  return res;
}

ll solveOverSub(int N, int R, int T) {
  ll lb = max({0, R - N + 1});
  ll ub = min({N, R / 2, T - N + R});
  if (lb > ub) return 0;
  ll res = (tbl[R][ub + 1] - tbl[R][lb] + MOD) % MOD;
  return res;
}

ll solveOver(int N, int X) {
  ll res = 0;
  if (2 * N > X && X % 2 == 1) {
    ++res;
  }
  for (int two = 0; two < N && 2 * two + 1 < X; two++) {
    res += solveOverSub(N - two - 1, X - 2 * two - 2, two);
    res %= MOD;
  }
  return res;
}

ll solve(int N, int X) {
  return (solveLess(N, X) + solveOver(N, X)) % MOD;
}

int main() {
#ifdef DEBUG
  ifstream cin("in.txt");
#endif
  init(6010);
  int N, X;
  while (cin >> N >> X) {
    ll res = 0;
    for (int zero = 0; zero <= N; zero++) {
      ll ways = solve(N - zero, X) * choose(N, zero) % MOD;
      res = (res + ways) % MOD;
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 282880
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <math.h>

using namespace std;

int main()
{
	int a, b, ans = 0;
	cin >> a >> b;
	for (int t = 0; t < 2; t++) {
		if (a > b) {
			ans += a;
			a--;
		}
		else {
			ans += b;
			b--;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int inf=1000000000;
char ch;
int a[611][611],c[611],i,j,k,n,m,ans,w,t;
int main(){
	scanf("%d",&n);memset(c,0,sizeof(c));
	for (i=1,k=0;i<=n;i++)
	 for (j=1;j<=n;j++){
	 	for (ch=getchar();ch!='#'&&ch!='.';ch=getchar());
	 	a[i][j]=(ch=='#')?1:0;k+=a[i][j];c[j]+=a[i][j];
	 }
	if (!k){
		puts("-1");return 0;
	}
	for (i=1,w=0;i<=n;i++)
	 if (c[i]<n) w++;
	for (i=1,ans=inf;i<=n;i++){
		for (j=1,k=t=0;j<=n;j++)
		 if (!a[i][j]){
		 	if (!c[i]){
		 		if (!t) t=1,k+=2;else k++;
			}else k++;
		 }
		 ans=min(ans,k+w);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1408
function Main(input) {
  
    input = input.split("")
    let All_plus = input.reduce(function(a, b) {
        return Number(a) + Number(b);
    })
    
  	if(All_plus%9 === 0){
	console.log("Yes");
    }else{
    console.log("No");
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define int long long

using namespace std;

int a[10001];
int d[1001][4];

 main () {
	int n, p;
	cin >> n >> p;
	for (int i = 1;i <= n;i ++) cin >> a[i];
	d[0][0] = 1;
	for (int i = 1;i <= n;i ++) {
		d[i][0] = d[i - 1][0];
		d[i][1] = d[i - 1][1];                
		if (a[i] % 2) {
			d[i][(a[i] % 2 + 1) % 2] += d[i - 1][a[i] % 2];
			d[i][a[i] % 2] += d[i - 1][(a[i] % 2 + 1) % 2];
		}
		else {
			d[i][(a[i] % 2 + 1) % 2] += d[i - 1][(a[i] % 2 + 1) % 2];
			d[i][a[i] % 2] += d[i - 1][a[i] % 2];
		}
	}
	cout << d[n][p];
	return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
ans = 0
i = 0

while True:
    if max(h) == 0:
        break
    while i < n:
        if h[i] != 0:
            for j in range(i,n):
                if h[j] == 0:
                    #print(j)
                    break
                h[j] -= 1
            #print(h)
            ans += 1
        else:
            i += 1

print(ans)
                


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

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

  vector<int> s(n + 1, 0);
  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;

    for (int j = 0; j < d; j++) {
      int a;
      cin >> a;
      s[a]++;
    }
  }

  int num = 0;
  for (int i = 1; i <= n; i++) {
    if (s[i] == 0) {
      num++;
    }
  }

  cout << num << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

typedef struct {
  char c;
  int n;
} card;

void Bubblesort(card *, int);
void SelectionSort(card *, int, card *);

int main() {

  card A[36],B[36],x;
  int i,j,k,N;

  scanf("%d",&N);

  for(i = 0; i < N; i++) {
    scanf(" %c%d",&A[i].c,&A[i].n);
  }
   for(i = 0; i < N; i++) {
      B[i].c = A[i].c;
      B[i].n = A[i].n;
    }

  Bubblesort(A,N);
  SelectionSort(B,N,A);
  return 0;
}


//??????????????????                                                                                                                                 
void Bubblesort(card *A, int N) {
  int i,j,k;
  card x,B[36];
   for(i = 0; i < N; i++) {
      B[i] = A[i];
    }

  for(i = 0; i < N-1; i++) {
    for(j = N-1; j > i; j--) {
      if(A[j].n < A[j-1].n) {
     x.c = A[j].c;
     x.n = A[j].n;
     A[j].c = A[j-1].c;
     A[j].n = A[j-1].n;
     A[j-1].c = x.c;
     A[j-1].n = x.n;

      }
    }
  }
 for(i = 0; i < N; i++) {
    printf("%c%d",A[i].c,A[i].n);
    if(N-1 != i) printf(" ");
  }
  printf("\n");
printf("Stable\n");
  return ;
}


//?????¬????????§????????????                                                                                                                           
void SelectionSort(card *A, int N, card *C) {
  int i,j,flag,min,a,b;
  card x,B[36];
     for(i = 0; i < N; i++) {
      B[i].n = A[i].n;
      B[i].c = B[i].c;
    }


  for(i = 0; i < N; i++) {
    min = i;
    flag = 0;
    for(j = i; j < N; j++) {
      if(A[j].n < A[min].n) {
    min = j; /*????°????????????£??????????????????????¨???¶?????????????????????*/
    flag = 1; /*for?????§?¢??????????????????§???????°???????????????£??????flag???1????????????*/

      }
    }
    if(flag == 1) {
      x.c = A[i].c;
      x.n = A[i].n;
      A[i].c = A[min].c;
      A[i].n = A[min].n;
      A[min].c = x.c;
      A[min].n = x.n;
    }
  }      for(i = 0; i < N; i++) {
    printf("%c%d",A[i].c,A[i].n);
      if(N-1 != i) printf(" ");
    }
    printf("\n");
    for(i = 0; i < N; i++) {
      if(A[i].c != C[i].c) flag = 2;
    }
   if(flag == 2) printf("Not stable\n");
  else printf("Stable\n");
  return;
}

Measured memory_bytes: 612
downQsort :: [Int] -> [Int]
downQsort [] = []
downQsort (p:xs) = downQsort gt ++ [p] ++ downQsort lt
  where gt = [x | x <- xs, x >= p]
        lt = [x | x <- xs, x < p ]


main :: IO()
main = do
  line <- getLine
  let line' = map read (words line) ::[Int]
  putStrLn $ unwords $ map show $ downQsort line'

Measured memory_bytes: 3600
import itertools
N = int(input())
A = list(range(1,N+1))
P = [int(i) for i in input().split()]
Q = [int(i) for i in input().split()]
P = tuple(P)
Q = tuple(Q)
cnt = 0
for i in itertools.permutations(A):
  cnt += 1
  if i == P:
    a = cnt
  if i == Q:
    b = cnt
print(abs(a-b))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,c,x,y,sum;
	cin>>a>>b>>c>>x>>y;
	if((a+b)>=c*2)
	{
		if(x>=y)
		{
			if(a<=c*2)  sum=y*2*c+(x-y)*a;
			if(a>c*2)  sum=y*2*c+(x-y)*2*c;
		}
		if(x<y)
		{
			if(b<=c*2)  sum=x*2*c+(y-x)*b;
			if(b>c*2)  sum=x*2*c+(y-x)*2*c;
		}
	}
	if((a+b)<c*2)
	{
		if(x>=y)
		{
			if(a<=c*2)  sum=y*(a+b)+(x-y)*a;
			if(a>c*2)  sum=y*(a+b)+(x-y)*2*c;
		}
		if(x<y)
		{
			if(b<=c*2)  sum=x*(a+b)+(y-x)*b;
			if(b>c*2)  sum=x*(a+b)+(y-x)*2*c;
		}
	}
	cout<<sum<<endl;
	return 0;
}

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

using namespace std;

int main(){
	int r,g,b; cin >> r >> g >> b;
	int ans = r*100 + g*10 + b;
	if(ans % 4 == 0)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}



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

int W, H, N;

int dist(int nowx, int nowy, int nextx, int nexty) {
	if (nowx > nextx) {
		swap(nowx, nextx);
		swap(nowy, nexty);
	}

	int shortcut = min(nextx - nowx, nexty - nowy);
	if (shortcut < 0) shortcut = 0;
	nowx += shortcut;
	nowy += shortcut;

	int ret = shortcut;
	ret += abs(nextx - nowx) + abs(nexty - nowy);

	return ret;
}

signed main()
{
	cin >> W >> H >> N;

	int ans = 0;	//???????????¢
	int nowx, nowy, nextx, nexty;

	cin >> nowx >> nowy;
	rep(i,N-1) {
		cin >> nextx >> nexty;
		ans += dist(nowx, nowy, nextx, nexty);
		nowx = nextx; nowy = nexty;
	}

	cout << ans << endl;
}

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

int main() {
    string X;
    cin >> X;
    int T = 0, S = 0;
    for (char i : X) {
        if (i == 'S') ++S;
        if (i == 'T' && S == 0) ++T;
        else if (i == 'T' && S != 0) --S;
    }
    cout << T + S << endl;
}


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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	double t, x; cin >> t >> x;
	cout.setf(ios::fixed);
	cout.precision(20);
	cout << t / x << '\n';
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    val aList = readInputLine().split(" ").map { it.toInt() }

    var ans = 0
    var now = 1

    for (a in aList) {
        if (a != now) {
            ans++
        } else {
            now++
        }
    }

    println(if (ans != N) ans else -1)
}

fun readInputLine(): String {
    return readLine()!!
}



Measured memory_bytes: 82780
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func scanInts(n int) []int {
	sl := make([]int, n)
	for i := range sl {
		sl[i] = scanInt()
	}
	return sl
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	fmt.Println(a * b)
}

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

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

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


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

const int inf = 1e9+5;


int main()
{
    int n;
    scanf("%d",&n);
    vector<int>ara(n);
    for(int& x: ara){
        scanf("%d",&x);
    }
    vector<int>dp(n,inf);

    dp[0] = 0;
    for(int i = 0; i < n;i++){

        for(int j = i+1; j <= i+2;j++){
            if(j < n)dp[j] = min(dp[j],dp[i]+abs(ara[i]-ara[j]));
        }
    }
    printf("%d\n",dp[n-1]);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
typedef pair<ll,ll> pll;
ll n, k;
string s;
vector< pll > zro;
vector< pll > on;
ll st[100005];
int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL); cout.tie(NULL);
        cin >> n>>k>>s;
        ll ans = 0;
        for(ll i=n-1;i>=0;i--) {
                ll j = i;
                while(j >= 0 && s[j] == s[i]) j--;
                if(s[i] == '0') zro.pb(make_pair(j+1,i));
                else {
                        on.pb(make_pair(j+1,i));
                        st[j+1] = i-j;
                }
                ll id = zro.size() - k;
                //cout << id << endl;
                j++;
                if(id < 0) {
                        ans = max(ans , n-j);
                }else {
                        ans = max(ans , zro[id].second - j + 1 + st[zro[id].second + 1]);
                }
                i = j;
        }
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 2892
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int main(void){
  long long int N;
  cin>>N;
  vector<long long int> A(N);
  long long int S=0;
  map<long long int,long long int> mp;
  mp[0]=1;
  for(int i=0;i<N;i++){
      cin>>A[i];
      S+=A[i];
      mp[S]+=1;
  }
  long long int ans=0;
  for(auto x:mp){
    ans+=x.second*(x.second-1)/2;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> t(n),a(n);
    REP(i,n) cin >> t[i] >> a[i];
    ll x = 1, y = 1, m = 1;
    REP(i,n) {
        if(i==0) m=1;
        else m = max((t[i-1]*m + t[i]-1)/t[i], (a[i-1]*m + a[i]-1)/a[i]);
        x = t[i]*m, y = a[i]*m;
    }
    ll ans = x+y;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for ( int i = 0; i < (int)n; i++ )
#define NMAX 200
#define MMAX 100
#define INFTY (1<<21)
int n, m, T[NMAX][NMAX], P[MMAX][MMAX];
void valid(int sx, int sy, int &lx, int &ly) {
	int ax = -1, ay;
	rep(y, m)
		rep(x, m)
		{
			if (P[x][y] == -1)
				continue;
			if (P[x][y] != T[sx + x][sy + y])
				return;
			if (ax == -1) {
				ay = y;
				ax = x;
			}
		}
	if (ay < ly || (ay == ly && ax < lx)) {
		ly = sy + ay;
		lx = sx + ax;
	}
}
bool rotate(int sx, int sy) {
	int tmp[MMAX][MMAX];
	int ly = INFTY, lx;
	rep(r, 4)
	{
		valid(sx, sy, lx, ly);
		rep(y, m)
			rep(x, m)
				tmp[x][y] = P[x][y];
		rep(y, m)
			rep(x, m)
				P[y][m - x - 1] = tmp[x][y];
	}
	if (ly == INFTY)
		return false;
	cout << lx + 1 << " " << ly + 1 << endl;
	return true;
}
void compute() {
	rep(y, n-m+1)
		rep(x, n-m+1)
			if (rotate(x, y))
				return;
	cout << "NA" << endl;
}
int main() {
	while (cin >> n >> m && n) {
		rep(y, n)
			rep(x, n)
				cin >> T[x][y];
		rep(y, m)
			rep(x, m)
				cin >> P[x][y];
		compute();
	}
	return 0;
}

Measured memory_bytes: 3168
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
using namespace std;
typedef long long s64;

const int ONE = 1000005;
const int INF = 2147483640;

int get()
{
		int res = 1, Q = 1; char c;
		while( (c = getchar()) < 48 || c > 57)
			if(c == '-') Q = -1;
		if(Q) res = c - 48;
		while( (c = getchar()) >= 48 && c <= 57)
			res = res * 10 + c - 48;
		return res * Q;
}

int n, m;
int sum[ONE];
int x, y;

struct point {int x, y;} a[ONE];

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

int vis[ONE], Ans;

struct power {int id, val;} Node[ONE], res;
namespace Seg
{
		void Update(int i, int l, int r, int L, power x)
		{
			if(L <= l && r <= L)
			{
				Node[i] = x;
				return;
			}
			int mid = l + r >> 1;
			if(L <= mid) Update(i << 1, l, mid, L, x);
			else Update(i << 1 | 1, mid + 1, r, L, x);
			Node[i] = Node[i << 1];
			if(Node[i << 1].val > Node[i << 1 | 1].val) Node[i] = Node[i << 1 | 1];
		}
		void Query(int i, int l, int r, int L, int R)
		{
			if(L > R) return;
			if(L <= l && r <= R)
			{
				if(res.val > Node[i].val)
					res = Node[i];
				return;
			}
			int mid = l + r >> 1;
			if(L <= mid) Query(i << 1, l, mid, L, R);
			if(mid + 1 <= R) Query(i << 1 | 1, mid + 1, r, L, R); 
		}
}

int main()
{
		//freopen(".in","r",stdin);
		//freopen(".out","w",stdout);
		n = get(), m = get();
		for(int i = 1; i <= n; i++)
		{
			a[i].x = x = get(), a[i].y = y = get();
			if(x != 0) sum[1]++, sum[x + 1]--;
			if(y != m + 1) sum[y]++, sum[m + 1]--;
		}
		for(int i = 1; i <= m; i++) sum[i] += sum[i - 1];
		sort(a + 1, a + n + 1, cmp);

		for(int i = 1; i <= m; i++)
			Seg::Update(1, 1, m, i, (power){i, sum[i]});

		for(int i = 1; i <= n; i++)
		{
			int pos = 0, minn = INF;
			res = (power){0, INF};
			Seg::Query(1, 1, m, 1, a[i].x);
			Seg::Query(1, 1, m, a[i].y, m);
			if(res.id == 0) {Ans++; continue;}
			Seg::Update(1, 1, m, res.id, (power){INF, INF});
		}

		cout << Ans;

}

Measured memory_bytes: 14592
#include <iostream>
#include <cstring>
#include <sstream>
using namespace std;
int main(){
	string n,s;
	cin>> n;
	int q=0;
	while (cin>> s){
		for (int i=0;i<s.size();i++){
			if (s[i]<97){
				s[i]=s[i]+32;
			}
		}
		if (s==n){
			q++;
		}
	}
	cout<< q<< endl;
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    string day;
    cin >> day;
    int n = 0;
    if (day == "SUN") {
        n = 7;
    } else if (day == "MON") {
        n = 6;
    } else if (day == "TUE") {
        n = 5;
    } else if (day == "WED") {
        n = 4;
    } else if (day == "THU") {
        n = 3;
    } else if (day == "FRI") {
        n = 2;
    } else if (day == "SAT") {
        n = 1;
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,D,X;
  cin >> N >> D >> X;
  int A[N];
  for (int i=0;i<N;i++){
    cin >> A[i];
  }
  int sum=X;
  for (int i=0;i<N;i++){
    sum+=(D-1)/A[i]+1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean canCalc = false;
		outer:
		for (int i = 1; i * i <= n; i++) {
			for (int j = 1; j <= 9; j++) {
				if (i * j == n) {
					canCalc = true;
					break outer;
				}
			}
		}
		String ans = canCalc ? "Yes" : "No";
		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 21844
#include <stdio.h>

int main()
{
    int N[100],i,a,count = 0;

    scanf("%d",&a);

    for(i = 0;i < a;i++)
    {
        scanf("%d",&N[i]);

        if(N[i] % 2 == 1 &&(i + 1) % 2 == 1)
            count++;
    }

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

    return 0;
}

Measured memory_bytes: 1724
n = int(input())
t = int((n*2)**(0.5))
if t*(t+1)//2!=n:
    print("No")
    quit()
l = [[] for _ in range(t+1)]
ind = 1
for i in range(t,0,-1):
    for j in range(i):
        l[t-i].append(j+ind)
    for j in range(i):
        l[t-i+1+j].append(j+ind)
    ind += i
print("Yes")
print(t+1)
for i in range(t+1):
    print(t,*l[i])

Measured memory_bytes: 17264