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

using namespace std;
// #define int long long
mt19937 rnd(time(0));
typedef long long ll;
typedef long double ld;

// #define _GLIBCXX_DEBUG
#define f first
#define s second
#define pb push_back
#define pii pair<int, int> 
#define vi vector<int>
#define int ll

void solve(){
    int n;
    cin >> n;
    int a[n];
    for (auto &i : a)
        cin >> i;
    int k = 1;
    for (int i = 0; i < n; ++i) {
        if (a[i] == k) {
            k++;
        }
    }
    if (k == 1) {
        cout << -1 << endl;
    } else {
        cout << n - k + 1 << endl;
    }
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int t = 1;
    while(t--){
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>

const int inf = 2e9;

int n, k = 2;
int h[100100], dp[100100];

int min(int a, int b) {
    return (a < b ? a : b);
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", &h[i]);
    for (int i = 0; i < n; i++) dp[i] = inf;
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        for (int j = i - 1; j >= i - k && j >= 0; j--) {
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
        }
    }
    printf("%d\n", dp[n - 1]);
}

Measured memory_bytes: 896
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_set>
# include <unordered_map>
using namespace std;


string s;
int n;
bool used[100];
int pos;


int main(int argc, const char * argv[]) {
#ifdef __APPLE__
    freopen("/Users/danya.smelskiy/Documents/Danya/Resources/input.txt","r",stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> s >> n;
    for (int i = 1; i <= n; ++i) {
        int x;
        cin >> x;
        used[x] = true;
    }
    s = "0" + s;
    bool tt = false;
    for (int i = 1; i < (int)s.size(); ++i) {
        int x = s[i] - '0';
        bool t = false;
        for (int j = x + 1; j <= 9; ++j)
            if (!used[j]) {
                t = true;
                break;
            }
        if (t) pos = i;
        if (used[x]) {
            tt = true;
            break;
        }
    }
    if (!tt) {
        for (int i = 1; i < (int)s.size(); ++i)
            cout << s[i];
        cout << '\n';
        return 0;
    }
    for (int i = 1; i < pos; ++i)
        cout << s[i];
    int x = s[pos] - '0';
    for (int i = x + 1; i <= 9; ++i)
        if (!used[i]) {
            cout << i;
            break;
        }
    for (int i = pos + 1; i < (int)s.size(); ++i) {
        for (int j = 0; j <= 9; ++j) if (!used[j]) {
            cout << j;
            break;
        }
    }
    cout << '\n';
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    while (scanner.hasNext()) {
      int a = scanner.nextInt();
      if (a < 0) {
        break;
      }
      if (a == 0) {
        System.out.println(0);
        continue;
      }
      System.out.println(aaa(a));
    }
  }
  public static String aaa (int a) {
    if (a == 0) {
      return "";
    }
    return String.format("%s%d", aaa(a / 4), a % 4);
  }
}

Measured memory_bytes: 34548
#include<stdio.h>

int n;
int a, b;

int main(void)
{
	int ta, tb;
	
	while(1) {
		
		scanf( "%d", &n );
		
		if ( n == 0 ) break;
		
		ta = tb = 0;
		while( n-- ) {
			
			scanf( "%d %d", &a, &b );
			if ( a > b ) ta += a + b;
			else if ( a < b ) tb += a + b;
			else {
				ta += a;
				tb += b;
			}
			
		}
		
		printf( "%d %d\n", ta, tb );
		
	}
	
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,z,w;
	cin>>n>>z>>w;
	vector<int> a(n);
	rep(i,n){
		cin>>a[i];
	}
	int ans=abs(a.back()-w);
	if(n>=2){
		chmax(ans,abs(a[n-1]-a[n-2]));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100005];
map<int, int> ht;
map<int, int>::iterator its;
int main(){
	int n;
	scanf("%d", &n);
	int ans = 0;
	for(int i=1;i<=n;i++){
		scanf("%d", &a[i]);
		ht[a[i]] = 1;
	}
	int hv = 1;
	for(its=ht.begin();its != ht.end();its++) its->second = hv++;
	for(int i=1;i<=n;i++){
		a[i] = ht[a[i]];
		if(i%2 != a[i]%2) ans++;
	}
	printf("%d\n", ans/2);
}

Measured memory_bytes: 5376
#include <iostream>
#include <cstdio>
#include <limits>
#define eps 1e-10
using namespace std;

int main(void) {
    double a, b, c, d, e, f;
    //double inf = numeric_limits<double>::infinity();
    while(scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF) {
        double ya = d * c - a * f;
        double yb = b * d - a * e;
        if(yb == 0) yb += eps;
        double y = ((ya) / (yb));
        //if(yb == 0) y = inf;
        if(a == 0) a += eps;
        double x = ((c - b * y) / a);
        //if(a == 0) x = inf;
        printf("%.3f %.3f\n",x, y);
    }
    
    return(0);
}

Measured memory_bytes: 1236
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(){
  int n,A[100],mini,count=0;
  cin>>n;
  for(int i=0;i<n;i++)cin>>A[i];
   
  for(int i=0;i<n-1;i++){
    mini=i;
    for(int j=i+1;j<n;j++){
      if(A[j]<A[mini])mini=j;
    }
     
    if(i!=mini){
      count++;
      swap(A[i],A[mini]);
    }
  }
   
  for(int i=0;i<n;i++){
    if(i)cout<<' ';
    cout<<A[i];
  }
  cout<<endl<<count<<endl;
 
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define optimize() ios_base::sync_with_stdio(0);
int n,lim;

ll w[100],cost[100],fin[100][100001];



ll knap(ll pos,ll weight)
{
    if(pos==n)
        return 0;
    if(fin[pos][weight]>0)
        return fin[pos][weight];


    ll x=0,y=0;

    if(weight>=w[pos])
    {
        x=cost[pos]+knap(pos+1,weight-w[pos]);

    }

    y=knap(pos+1,weight);

    return fin[pos][weight]=max(x,y);




}
int main()
{
    optimize();
    cin>>n>>lim;

    for(ll i=0;i<n;i++)
    {
        cin>>w[i]>>cost[i];
    }

    ll r=knap(0,lim);
    cout<<r<<endl;

}



Measured memory_bytes: 75540
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		while(sc.hasNext()) {
			String[] tmp = sc.next().split(",");
			int id = Integer.parseInt(tmp[0]);
			double a = Double.parseDouble(tmp[1]);
			double b = Double.parseDouble(tmp[2]);
			
			if(a / (b*b) >= 25) {
				out.println(id);
			}
		}
		out.flush();

	}
}
//------------------------------//
//-----------//
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    
    public int nextInt() {
    	return (int)nextLong();
    }
    

}

Measured memory_bytes: 15084
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()

	N, err := strconv.Atoi(scanner.Text())
	if err != nil {
		log.Fatal(err)
	}

	if N%2 == 0 {
		fmt.Println(float32((N / 2)) / float32(N))
	} else {
		fmt.Println(float32(((N + 1) / 2)) / float32(N))
	}
}


Measured memory_bytes: 1836
#include <iostream>
#include <stdio.h>
#define MAX 101


int main() {
    int n;
    int id = 0;
    int M[MAX][MAX] = { 0 };
    
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        int k = 0;
        scanf("%d %d", &id, &k);
        
        if (k == 0) continue;
        
        for (int j = 1; j <= k; j++) {
            int a = 0;
            scanf("%d", &a);
            M[i][a] = 1;
        }
    }
    
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (j >= 2) printf(" ");
            printf("%d", M[i][j]);
        }
        printf("\n");
    }
    
    return 0;
}

Measured memory_bytes: 3260
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
B = [int(x) for x in stdin.readline().rstrip().split()]

cnt1 = 0 
cnt2 = 0

for i in range(N):
    if A[i] > B[i]:
        cnt1 += (A[i] - B[i])
    else:
        cnt2 += ((B[i]-A[i])//2)
        
if cnt1 <= cnt2:
    print("Yes")
else:
    print("No")

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

int main() {
    string s;
    cin>>s;
    int S=s.size(), cnt=0;

    for(int i=1; i<S; i++){
        if(s.at(i-1)==s.at(i)){
            s.at(i-1)=='1'?s.at(i)='0':s.at(i)='1';
            cnt++;
        }
    }

    cout<<cnt<<endl;

}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222





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


  map<pll, ll> mp;
  vpll v;
  cin >> n;
  rep(i, n) {
    ll x, y;
    cin >> x >> y;
    mp[pll(x, y)]++;
    v.pb(pll(x, y));
  }
  if (n == 1) {
    cout << "1" << endl;
    return 0;
  }
  rep(i, n) FOR(j, i + 1, n) {
    ll x = v[i].first - v[j].first;
    ll y = v[i].second - v[j].second;
    ans = n;
    rep(k, n) ans -= mp[pll(v[k].first + x, v[k].second + y)];
    mi = min(mi, ans);
  }

  cout << mi << endl;


  return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}

int main(){
  string ans = "No";
  string S;
  cin >> S;
  for(int i=0; i<3; ++i){
    if(S[i] == '7') ans = "Yes";
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   if(Arr.length==0)break;
   var arr=Arr.shift().split(" ").map(Number);
   var M=[1,4,1,4,1,2,1,2];
   var m=[];
   for(var i=0;i<M.length;i++){
      M.push(M.shift());
      m.push(M.join("")-0);
   }
   m.sort(function(a,b){return b-a;});
   m=m.map(function(v){return (v+"").split("").map(Number);});
   var min=Infinity;
   var ans;
   m.forEach(function(v,i){
      var sum=0;
      arr.forEach(function(V,I){
         if(v[I]<V)sum+=(V-v[I]);
      });
      min=Math.min(min,sum);
      if(min==sum)ans=i;
   });
   console.log(m[ans].join(" "));
}

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

void chmax(int &a, int b){
    if(a < b)a = b;
}

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    map<int, int> ans;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        if(ans.count(A[i]))ans[A[i]]++;
        else ans[A[i]] = 1;
        if(ans.count(A[i] - 1))ans[A[i] - 1]++;
        else ans[A[i] - 1] = 1;
        if(ans.count(A[i] + 1))ans[A[i] + 1]++;
        else ans[A[i] + 1] = 1;
    }
    
    int res = 0;
    for(int i = 0; i < N; i++){
        int a = max({ans[A[i]], ans[A[i] + 1], ans[A[i] - 1]});
        chmax(res, a);
    }
    cout << res << endl;
    return 0;
}

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

int main(){
    int N,D,rs=0;
    double wa=0,ans=0;
    int digi=0;
    cin >> N >> D;

    vector<vector <int>> X(N,vector<int>(D));

    for(int i = 0;i < N;i++)
        for(int j = 0;j < D;j++){
            cin >> X.at(i).at(j);
        }

    for(int i = 0;i < N - 1;i++){
        for(int j = i + 1;j < N;j++){
            wa=0;
            for(int k = 0;k < D;k++){
                wa += (X.at(i).at(k) - X.at(j).at(k)) * (X.at(i).at(k) - X.at(j).at(k));
            }

            ans = sqrt(wa);

            digi = 0;
            while(digi < ans){
                digi++;
            }
            if((ans-digi) == 0)
                rs++;
        }
    }

    cout << rs << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define for(i,a,b) for(i=a;i<b;i++)
ll i;
int main(){
	ll n;
	cin>>n;
	ll wa=0,tle=0,re=0,ac=0;
	for(i,0,n){
		string str;
		cin>>str;
		if(str[0]=='A') ac++;
		else if(str[0]=='W') wa++;
		else if(str[0]=='T') tle++;
		else re++;
	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;
	return 0;
}

Measured memory_bytes: 3624
from sys import stdin
# import numpy as np
# import math
# import fractions
# import sys
# sys.setrecursionlimit(100000)
# N = int(stdin.readline().rstrip().split()[0])
# A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]
# S = stdin.readline().rstrip().split()[0]

N, K = [int(x) for x in stdin.readline().rstrip().split()]
print(N-K+1)

Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
using namespace std;
 

int main(){
    ll n,m,k;
    cin>>n>>m>>k;
    ll takashi;
    ll arie;
    if(k>=n+m){
        takashi=0;
        arie=0;
    }
    else if(k>=n){
        takashi=0;
        arie=n+m-k;
    }
    else if(k<n){
        takashi=n-k;
        arie=m;
    }
    
    cout<<takashi<<" "<<arie;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int q;
	cin>>q;
	while(q--)
	{
		int k;
		cin>>k;
		long long ret=0,dm=0;
		int d=0,m=0;
		for(int i=0;i<n;i++)
		{
			if(s[i]=='C')
			{
				ret+=dm;
			}
			else if(s[i]=='D')
			{
				d++;
			}
			else if(s[i]=='M')
			{
				dm+=d;
				m++;
			}
			if(i>=k-1)
			{
				int p=i-k+1;
				if(s[p]=='D')
				{
					dm-=m;
					d--;
				}
				else if(s[p]=='M')
				{
					m--;
				}
			}
		}
		cout<<ret<<endl;
	}
	return 0;
}

Measured memory_bytes: 1412
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

    n, k = map(int, input().split())
    as_ = list(map(int, input().split()))
    counter_a = collections.Counter(as_)
    counter_a = sorted(counter_a.items(), key=lambda x: x[1])
    types = len(counter_a)
    ans = 0
    for num, count in counter_a:
        if types > k:
            ans += count
            types -= 1
        if types <= k:
            print(ans)
            break

if __name__ == '__main__':
    main()

Measured memory_bytes: 39348
//https://bi.biopapyrus.jp/cpp/algorithm/sort/quick-sort.html

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, char> P;

int partition(P* A, int p, int r){
    
    int x = A[r].first;
    int i = p - 1;
    
    for (int j = p; j < r; j++){
        
        if (A[j].first <= x){
            
            i++;
            swap(A[i], A[j]);
        }
    }
    
    i++;
    swap(A[i], A[r]);
    return i;
}

void quicksort(P* A, int p, int r){
    
    //p >= rとなったとき, すでにクイックソートは完了している
    //この条件がないと, 無限ループに陥る
    if (p < r){
        int q = partition(A, p, r);
        quicksort(A, p, q-1);
        quicksort(A, q+1, r);
    }
    
    //quicksortが完了した時点で,もとの配列内でのソートが完了している
    //mergeは必要ない.
}


int main(){
    int n; 
    cin >> n;
    
    P A[n];
    
    for (int i = 0; i < n; i++) cin >> A[i].second >> A[i].first;
    
    map<int, string> m1, m2;
    
    for (int i = 0; i < n; i++) m1[A[i].first] += A[i].second;
    
    quicksort(A, 0, n-1);
    
    for (int i = 0; i < n; i++) m2[A[i].first] += A[i].second;
    
    bool flag = 1;
    
    for (int i = 0; i < n; i++){
        flag &= (m1[A[i].first] == m2[A[i].first]);
    }
    
    if (flag) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
    
    for (int i = 0; i < n; i++){
        cout << A[i].second << " " << A[i].first << endl;
    }
}










Measured memory_bytes: 9404
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] ps = new int[n];
		
		for(int i=0; i<ps.length; i++) {
			ps[i] = sc.nextInt();
		}
		sc.close();
		
		int count =0;
		
		for(int i=0; i<ps.length; i++){
			if(ps[i] == i+1) {
				swap(ps,i);
				count += 1;
			}
		}
		
		System.out.println(count);

	}
	
	public static void swap(int[] ps, int i) {
		if(i != ps.length-1) {
			int a = ps[i];
			ps[i] = ps[i+1];
			ps[i+1] = a;
		}
	}

}


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

ll fact(ll n)
{
      if( n<2 )
            return 1;
      return n*fact(n-2);
}
int main()
{
      ll n;
      cin >> n ;
      // ll f = fact(n);
      // cout << f << endl;
      if(n%2==0)
      {
            ll x = 10;
            ll ans = 0;
            while( n/x > 0)
            {
                  ans += n/x;
                  x*=5;
            }
            cout << ans << endl;
      }
      else
            cout << 0 << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N, W;
  cin >> N >> W;
  map<int, int> item;

  rep(i, N)
  {
    int v, w;
    cin >> v >> w;
    item[w] = max(item[w], v);
  }

  vector<vector<int> > dp(item.size() + 1, vector<int>(W + 1, -1));
  dp[0][0] = 0;
  int cnt = 0;

  for(pair<int, int> P : item)
  {
    rep(j, W + 1)
    {
      int v = P.second;
      int w = P.first;
      if(dp[cnt][j] != -1)
      {
        dp[cnt + 1][j] = max(dp[cnt + 1][j], dp[cnt][j]);
        for(int item_cnt = 1; ; item_cnt++)
        {
          int nw = j + item_cnt * w;
          int nv = dp[cnt][j] + item_cnt * v;
          if(nw <= W)
            dp[cnt +1][nw] = max(dp[cnt + 1][nw], nv);
          else
            break;
        }
      }
    } 
    cnt++;
  } 

  int ans = 0;
  rep(i, W + 1)
  {
    ans = max(ans, dp.back()[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6152
#include <iostream>
#include <cstring>

int main(){
  std::string text;
  std::string str;
  int count=0;

  std::cin >> str;

  for(int i=0; i<str.size(); i++){
    if('A' <= str[i] && str[i] <= 'Z') str[i] += 'a'-'A';
  }

  std::cin >> text;

  while(text != "END_OF_TEXT"){
    for(int i=0; i<text.size(); i++){
      if('A' <= text[i] && text[i] <= 'Z') text[i] += 'a'-'A';
    }
    if(text == str) count++;
    std::cin >> text;
  }

  std::cout << count << std::endl;

  return 0;
}



Measured memory_bytes: 3216
n,a,b,c,d=map(int,input().split())
s=input()

seq=0
tri=0
if c<d:
    seq=s[a-1:d-1].count("##")
    if seq==0:
        print("Yes")
    else:
        print("No")
else:
    seq=s[a-1:c-1].count("##")
    tri=s[b-2:d+1].count("...")
    if seq==0:
        if tri!=0:
            print("Yes")
        else:
            print("No")
    else:
        print("No")


Measured memory_bytes: 3512
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>

using namespace std;

int main() {
	const int N_max = 100;
	int N,tmp;
	vector<int> card;
	int alice = 0, bob = 0;


	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> tmp;
		card.push_back(tmp);
	}

	sort(card.begin(),card.end(),greater<int>());
	
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) {
			alice += card[i];
		}
		else {
			bob += card[i];
		}
	}

	cout << alice - bob;

	return 0;
}


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

using namespace std;

#define int long long
#define nl "\n"
#define sp " "

const int mod = 1e9 + 7;

signed main(){
	string s, t; cin >> s >> t;
	int cnt = LLONG_MAX;
	for (int i = 0; i <= s.size() - t.size(); i++){
		string tmp = s.substr(i, t.size()); int cntr = 0;
		for (int temp = 0; temp < t.size(); temp++){
			if (tmp[temp] != t[temp]){
				cntr++;
			}
		}
		cnt = min(cnt, cntr);
	}
	cout << cnt;
}


Measured memory_bytes: 3640
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl


signed main(){

	int N;
	cin >> N;
	vector<int> T(N), A(N);
	rep(i, N) cin >> T[i];
	rep(i, N) cin >> A[i];

	vector<int> lower(N), upper(N);

	rep(i, N){
		if (i == 0 || T[i] != T[i - 1]){
			lower[i] = T[i];
			upper[i] = T[i];
		}
		else{
			lower[i] = 1;
			upper[i] = T[i];
		}
	}

	for (int i = N - 1; i >= 0; i--){
		if (i == N - 1 || A[i] != A[i + 1]){
			lower[i] = max(lower[i], A[i]);
			upper[i] = min(upper[i], A[i]);
		}
		else{
			lower[i] = max(lower[i], 1LL);
			upper[i] = min(upper[i], A[i]);
		}
	}

	int ans = 1;
	rep(i, N){
		ans *= max(0LL, upper[i] - lower[i] + 1);
		ans %= mod;
	}
	cout << ans << endl;

	return 0;
}

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

const int MAX = 5100000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    vector<long long> A(N, 0);
    for(int k = (N + 1) / 2; k < N; ++k) {
        A[k] = (COM(k - 1, N - k - 1) * fac[k] % MOD) * fac[N - k - 1] % MOD;
    }

    long long res = 0;
    for(long long k = (N + 1) / 2; k < N; ++k) {
        res += k * (A[k] - A[k - 1] + MOD) % MOD;
        res %= MOD;
    }

    cout << res << endl;
}

Measured memory_bytes: 127616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

import static java.lang.Integer.parseInt;

/**
 * Problem A: Traffic Analysis
 */
public class Main {

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

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int n, m;
			n = Integer.parseInt(line.substring(0, line.indexOf(' ')));
			m = Integer.parseInt(line.substring(line.indexOf(' ') + 1));
			if ((n | m) == 0) break;

			int[] times = new int[n + m + 1];

			if (n != 0) {
				words = br.readLine().split(" ");
				for (int i = 0; i < n; i++) {
					times[i + 1] = parseInt(words[i]);
				}
			}

			if (m != 0) {
				words = br.readLine().split(" ");
				for (int i = 0; i < m; i++) {
					times[i + n + 1] = parseInt(words[i]);
				}
			}
			Arrays.sort(times);

			int max = 0;
			for (int i = 1; i < times.length; i++) {
				max = Math.max(max, times[i] - times[i - 1]);
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 35368
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n , ans = 1;
    cin >> n;
    while( ans <= n ) ans *= 2;
    cout << ans / 2;
}




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

int main(){
    string s;
    cin>>s;
    int ans=1000000;
    rep(i,s.size()-2){
        int a=atoi((s.substr(i,3)).c_str());
        
        ans=min(ans,abs(753-a));

    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  in6 k;
  cin >> k;
  in6 ans = 0;
  repa(a,1,k+1) repa(b,1,k+1) repa(c,1,k+1) ans += gcd(a,gcd(b,c));
  cout << ans;
  hinata;
}

Measured memory_bytes: 3620
import sys
input = sys.stdin.readline

N = int(input())
S = input()

ans = S.count("R") * S.count("G") * S.count("B")
for i in range(N-2):
  for j in range(i+1, N-1):
    k = 2 * j - i
    if k < N:
      A, B, C = S[i], S[j], S[k]
      if A != B and B != C and C != A: ans -= 1

print(ans)


Measured memory_bytes: 73604
n, m = map(int, input().split())

imp = 0
num = [0]*n

for i in range(m):
  c, a = map(int, input().split())
  if c==1 and n!=1 and a==0:
    imp = 1
  if c>n:
    imp = 1
  if num[c-1]>0 and num[c-1]!=a:
    imp = 1
  else:
    num[c-1] = a

if n>1 and num[0]==0:
  num[0] = 1

num = [str(i) for i in num]

if imp:
  print(-1)
else:
  print(int(''.join(num)))

Measured memory_bytes: 3064
#include<cstdio>
int f[5007];
int min(int a,int b){return a<b? a:b;}
int main()
{
    int n,p,ans=0;
    scanf("%d%d",&n,&p),f[0]=1;
    for(int i=1;i<n;++i) for(int k=min(i,n-i+1),j=k;j<n;++j) (f[j]+=f[j-k])%=p;
    for(int i=0;i<n;++i) (ans+=1ll*(n-i)*f[i]%p)%=p;
    printf("%d",ans);
}

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

class Proc{
    string name;
    int time;
    public:
    Proc(string n, int t): name(n), time(t){}
    Proc(): name(""), time(0){}
    int exec(int q){return time -= q;};
    string get_name(){return name;};
    int get_time(){return time;};
};

int main(int argc, char* argv[]) {
    int n, q, time, cnt = 0;
    string name;
    cin >> n >> q;
    Proc queue[n];

    for (int i = 0; i < n; i++){
        cin >> name >> time;
        queue[i] = Proc(name, time);
    }

    int size = n, abstime = 0, last = 0, i = 0, tmp;
    while (size){
        abstime += q;
        tmp = queue[i].exec(q);
        if (tmp <= 0){
            abstime += tmp;
            cout << queue[i].get_name() << " " << abstime << "\n";
            size--;
        }else{
            queue[last] = queue[i];
            last = ++last % n;
        }
        i = ++i % n;
    }
    return 0;
}



Measured memory_bytes: 6136
#include<bits/stdc++.h>
using namespace std;
long long  pow1[20];
int main(){
    #define int long long  
    int n;
    cin >> n;
    string A;
    while(n>0){
        int N=(n)%26;
        if(N==0){
            n-=1;
            A+='z';
        }
        else{
            A+=('a'+N-1);
        }
        n/=26;
    }
    for(int i=A.length()-1;i>=0;i--)
        cout << A[i];
    cout << '\n';
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	int n, *a, i;

	cin >> n;
	a = new int[n];

	for (i = 0; i < n; i++) {
		cin >> a[i];
	}

	sort(&a[0], &a[n]);

	cout << abs(a[n - 1] - a[0]);

	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] params = scanner.nextLine().split(" ");
        scanner.close();

        int k = Integer.parseInt(params[0]);
        int x = Integer.parseInt(params[1]);

        int min = x - k + 1;
        int max = x + k - 1;

        ArrayList<String> list = new ArrayList<>();
        for (int i = min; i <= max; i++) {
            if (i >= -1000000 && i <= 1000000) {
                list.add(String.valueOf(i));
            }
        }
        
        System.out.println(String.join(" ", list.toArray(new String[list.size()])));
    }
}

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

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

int main()
{
    long X, A, B;
    cin >> X >> A >> B;
    if(A >= B){
        cout << "delicious" << endl;
    }else if((B - A) <= X){
        cout << "safe" << endl;
    }else{
        cout << "dangerous" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int i, j, n, m;
  char k;
  int card[4][13] = {};
  scanf("%d%*c",&n);
  for(i = 0; i < n; i++){
    scanf("%c %d%*c",&k, &m);
    if(k == 'S'){
      for(j = 0; j < m; j++){
	if(j == (m - 1)){
	  card[0][j] = 1;
	}
      }
    } else if(k == 'H'){
      for(j = 0; j < m; j++){
	if(j == (m - 1)){
	  card[1][j] = 1;
	}
      }
    } else if(k == 'C'){
      for(j = 0; j < m; j++){
	if(j == (m - 1)){
	  card[2][j] = 1;
	}
      }
    } else if(k == 'D'){
      for(j = 0; j < m; j++){
	if(j == (m - 1)){
	  card[3][j] = 1;
	}
      }
    }
  }
  for(i = 0; i < 4; i++){
    for(j = 0; j < 13; j++){
      if(card[i][j] != 1){
	if(i == 0){
	  printf("S %d\n", j + 1);
	} else if(i == 1){
	  printf("H %d\n", j + 1);
	} else if(i == 2){
	  printf("C %d\n", j + 1);
	} else if(i == 3){
	  printf("D %d\n", j + 1);
	}
      }
    }
  }
  return 0;
}

Measured memory_bytes: 596
h, w = map(int, input().split())
an = [ input() for _ in range(h)]

answers = []

sharpColumn = ""
for _ in range(len(an[0])+2):
  sharpColumn += "#"

answers.append(sharpColumn)
for a in an:
  add = "#"
  for index in range(len(a)):
    if index == len(a)-1:
      add += a[index]+"#"
    else:
      add += a[index]
  answers.append(add)

answers.append(sharpColumn)

for answer in answers:
  print(answer)

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

int main(){
	int n;
	while(cin >> n,n){
		int mai;
		double y,ma = -10.0;
		cin >> y;
		for(int i = 0;i < n;i++){
			double b,r,t;
			double d;
			cin >> b >> r >> t;
			if(t == 1) d = 1.0 + y * r / 100.0;
			else d = pow(1.0 + r / 100.0,y);
			if(d > ma){
				ma = d;
				mai = b;
			}
		}
		cout << mai << endl;
	}
	return 0;
}

Measured memory_bytes: 3416
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

fn solve(a: u32, b: u32, c: u32, x: u32, y: u32) -> u32 {

    let p1 = a*x + b*y;
    let p2 = {
        c*2*x +
        if x < y {
            (y - x) * b
        } else {0}
    };

    let p3 = {
        c*2*y +
            if y < x{
                (x-y) * a
            } else {0}
    };

    let mut ps = vec![p1,p2,p3];
    ps.sort();

    ps[0]
}

fn main() {
    let (a,b,c,x,y) = parse_line!(u32,u32,u32,u32,u32);

    println!("{}", solve(a,b,c,x,y));
}

#[test]
fn solve_test() {
    assert_eq!(solve(1500, 2000, 1600, 3,2), 7900);
    assert_eq!(solve(1500, 2000, 1900, 3,2), 8500);
    assert_eq!(solve(1500, 2000, 500, 90000, 100000), 100000000);
}


Measured memory_bytes: 4352
#include <stdio.h>

void func1(int n);

int main(void) {
  int n;
  scanf("%d", &n);
  while(n >= 10) {
    if(n < 100) {
      n %= 10;
    } else if(n < 1000) {
      n %= 100;
    }
  }
  func1(n);
  return 0;
}

void func1(int n) {
  if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
    printf("hon");
  } else if(n == 0 || n == 1 || n == 6 || n == 8) {
    printf("pon");
  } else {
    printf("bon");
  }
}


Measured memory_bytes: 1716
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define ABS(a,b) max(a,b) - min(a,b)


int main() {
	ll a, b,ans = 0;
	cin >> a >> b;
	REP(i, INF) {
		ans++;
		a *= 2;
		if (a > b)break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
cnt_max_4 = N // 4
flag = False
for i_4 in range(cnt_max_4+1):
    money_4 = 4 * i_4
    res_money = N - money_4
    if res_money % 7==0:
        flag = True
        break
if flag:
    print('Yes')
else:
    print('No')
    

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

int main() {
  int n, m;
  cin >> n >> m;
  int ll = 1, lr = m+1, rl = m+2, rr = 2*m+1;
  while(true){
    cout << ll << " " << lr << endl;
    ++ll; --lr; --m;
    if(m <= 0) break;
    cout << rl << " " << rr << endl;
    ++rl; --rr; --m;
    if(m <= 0) break;
  }
}


Measured memory_bytes: 3636
n,a,b = map(int,input().split())
len =[]
anslen = []
for c in range(1,n+1):
    ci = c
    while c > 0:
        p = c % 10
        len.append(p)
        c = (c - p) / 10
    if a <= sum(len)  <= b:
          anslen.append(ci)
    len = []

ans = sum(anslen)

print(ans)


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

int pcnt(int x){
  return __builtin_popcount(x);
}

int f(int x){
  if(x==0)return 0;
  return f(x%pcnt(x))+1;
}

int main(){
  int n;
  string s;
  cin>>n>>s;
  vector<int>x(n);
  rep(i,n)x[i]=s[i]-'0';
  int pc=0;
  rep(i,n)pc+=x[i];
  vector<int>ans(n);
  rep(bit,2){
    int npc=pc;
    bit==0?npc++:npc--;
    if(npc<=0)continue;
    int r=0;
    rep(i,n){
      r=(r*2)%npc;
      r+=x[i];

    }
    int k=1;
    for(int i=n-1; i>=0; --i){
      if(x[i]==bit){
        int r2=r;
        if(bit==0)r2=(r+k)%npc;
        else r2=(r-k+npc)%npc;
        ans[i]=f(r2)+1;
      }
      k=(k*2)%npc;
    }
  }
  rep(i,n)cout<<ans[i]<<endl;
}

Measured memory_bytes: 5240
def myAnswer(A: list, B: list, N: int) -> str:
    bingoCard = [[0, 0, 0] for i in range(3)]
    row = [0, 0, 0]
    # マスが空くがどうかの判定
    for b in B:
        for i, a in enumerate(A):
            if(b in a):
                bingoCard[i][a.index(b)] = 1
                row[a.index(b)] += 1
                break
    for n, b in enumerate(bingoCard):
        if(sum(b) == 3):
            return "Yes"  # 横の判定

    # 縦の判定(列ごとの合計が3である列があったかどうか)
    if(3 in row):
        return "Yes"

    # 斜めの判定
    if(bingoCard[1][1]):
        if((bingoCard[0][0] and bingoCard[2][2]) or (bingoCard[0][2] and bingoCard[2][0])):
            return "Yes"

    # 縦、横、斜めに当てはまらなければ,No
    return "No"


def modelAnswer():
    tmp = 1


def main():
    A = []
    B = []
    for _ in range(3):
        A.append(list(map(int, input().split())))
    N = int(input())
    for _ in range(N):
        B.append(int(input()))
    print(myAnswer(A[:], B[:], N))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
n = int(input())
(t, a) = map(int, input().split())
h = list(map(int, input().split()))

min_i = 0
min_t = 10 ** 6
for i, h_i in enumerate(h):
    diff = abs(t - h_i * 0.006 - a)
    if min_t > diff:
        min_i = i
        min_t = diff
print(min_i + 1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    int n;cin>>n;
    ll cnt1=0,cnt2=0;
    ll h1;cin>>h1;
    rep(i,n-1){
        ll h;cin>>h;
        if(h1>=h)cnt1++;
        else{
            cnt2=max(cnt1,cnt2);
            cnt1=0;
        }
        h1=h;
    }
    cnt2=max(cnt1,cnt2);
    cout<<cnt2<<endl;
}

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

using i64 = int64_t;

int pop_count(int n){
    int res = 0;
    while(n > 0){
        if(n & 1)res++;
        n >>= 1;
    }
    return res;
}

int main(){
    int n, m;
    cin >> n >> m;
    vector<double> l, a, b;
    for(int i=0;i<n;++i){
        double x, y, z;
        cin >> x >> y >> z;
        l.push_back(x);
        a.push_back(y);
        b.push_back(z);
    }

    double ans = 0;
    for(int i=0;i<(1<<n);++i){
        if(pop_count(i) != m)continue;
        double sum = 0;
        for(int j=0;j<n;++j){
            if(((i>>j)&1) == 0)continue;
            for(int k=j+1;k<n;++k){
                if(((i>>k)&1) == 0)continue;
                sum += (l[j]-l[k])*(l[j]-l[k]);
                sum += (a[j]-a[k])*(a[j]-a[k]);
                sum += (b[j]-b[k])*(b[j]-b[k]);
            }
        }
        ans = max(ans , sum);
    }
    printf("%.10f\n", ans);

    return 0;
}



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

int feasibility(int n, int P, int k, std::vector<int> &S){
	int count=0;
	int acum=0;
	int i;
	for (i=0;i<n;i++){
		if (S[i]>P){
			return 0; 
		}
		acum+=S[i];
		if (acum>P){
			count++;
			acum=S[i];
		}
	}
	if (count+1 <= k){
		return 1;
	}else{
		return 0;
	}
}

int allocationSearch(int first,int last,int n,int k, std::vector<int> &S){
	if (last-first == 1){
		return last;
	}else{
		int m;
		m=(first + last)/2;
		if(feasibility(n,m,k,S)==1){
			return allocationSearch(first,m,n,k,S);
		}else{
			return allocationSearch(m,last,n,k,S);
			}
	}
}

int main(){
	int n,k,i;
	cin >> n >> k;
	vector<int> w(n);
	for (i=0;i<n;i++){
		cin >> w[i];
	}
	
	cout << allocationSearch(0,100000*10000,n,k,w) <<endl;
	return 0;
}

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

string S;
int dp[80010][11];

int main(){
    while(cin>>S,S!="0"){
        int ans=0;
        for(int i=0;i<S.size();i++){
            int d=S[i]-'0';
            for(int j=0;j<11;j++)dp[i+1][(j*10+d)%11]=dp[i][j];
            if(d)dp[i+1][d]++;
            ans+=dp[i+1][0];
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 6748
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

int main(){
	int k,s,a=0;
	cin>>k>>s;
	rep(x,k+1)rep(y,k+1){
	    if(s-x-y>=0 && s-x-y<=k) a++;
	}
	cout<<a<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        getAns(n, a);
    }
    static void getAns(int n, int[] a)
    {
        Array.Sort(a);
        Array.Reverse(a);
        long ans = a[0];
        var imax = n / 2 - 1;
        for (int i = 1; i <= imax; i++)
            ans += a[i] * 2;
        if (n % 2 == 1) ans += a[n / 2];
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 46400
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#define ll long long
#define add push_back

using namespace std; 

int main() {

    ios::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);

    int T;  T = 1; //cin >> t;
    while(T--){
        int n; cin >> n;
        vector<int> v(n);
        for(int i  = 0; i < n; i++){
            cin >> v[i];
        }
        ll answ = 0;
        for(int i = 1; i < n; i++){
            if(v[i] >= v[i - 1]) continue;
            answ += (v[i - 1] - v[i]);
            v[i] = v[i-1];
        }
        cout << answ << endl;

    }
    return 0;
}

Measured memory_bytes: 3992
import math
a, b, C = map(float, input().split())
S = (1/2)*a*b*math.sin(math.radians(C))
L = a + b + math.sqrt(a**2 + b**2 -2*a*b*math.cos(math.radians(C)))
h = S/((1/2)*a)
fn = lambda x: '{:10f}'.format(x)
print(f"{fn(S)} {fn(L)} {fn(h)}")



Measured memory_bytes: 5712
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-7
#define PII pair<int,int>
#define s second
#define f first
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
ll MOD = 998244353;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int random_int(int l,int r){return uniform_int_distribution<int>(l,r)(rng);}
ll fast_power(ll x, ll p){
    ll res = 1;
    while(p > 0){
        if(p & 1){
            res = (res * x)%MOD;
        }
        p = p >> 1;
        x = (x*x)%MOD;
    }
    return res;
}
int main() {
    IO;
    int n, w;
    cin >> n >> w;
    ll weight[n], value[n];
    for(int i = 0; i < n; i++){
        cin >> weight[i] >> value[i];
    }
    ll dp[n][w+1];
    for(int i = 0; i <= w; i++){
        dp[0][i] = 0;
        if(weight[0] <= i){
            dp[0][i]  = value[0];
        }
    }
    for(int i = 1; i < n ; i++){
        for(int j = 0; j <= w; j++){
            dp[i][j] = dp[i-1][j];
            if(weight[i] <= j){
                dp[i][j] = max(dp[i][j], value[i] + dp[i-1][j-weight[i]]);
            }

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


    return 0;
}


Measured memory_bytes: 78336
#include<iostream>
using namespace std;
int main(){
int a,b;
int c=0;
int sum=0;
cin >> a >> b;
  for(int i=0;i<b-a+1;i++){
    c = a+i;
    if((c-c%10000)/10000==c%10 && (c%100-c%10)==(c%10000-c%1000)/100){
    sum += 1;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

	if(a>b){
		if(a-1 > b)  cout << a + a - 1 << endl ;
		else cout << a + b << endl  ;
	}
	else{
		if(b-1 > a)  cout << b+ b-1 << endl;
		else cout << b + a << endl;
	}
	
	return 0;
} 

Measured memory_bytes: 256