akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
using namespace std;

int b[50][50]={};
int c[50][50];

int sr(int x,int y){
    if(c[x][y]!=1000000){return c[x][y];}
    if(x==0){return c[x][y]=b[x][y]+sr(x,y-1);}
    if(y==0){return c[x][y]=b[x][y]+sr(x-1,y);}
    return c[x][y]=b[x][y]+min(sr(x-1,y),sr(x,y-1));
}

int main(){
    int h,w;
    cin>>h>>w;
    char a[50][50]={};

    for(int i=0;i<h;i++){
        for(int t=0;t<w;t++){
            c[i][t]=1000000;
            cin>>a[i][t];
            b[i][t]=a[i][t]-'0';
        }}
    c[0][0]=0;
    int ans=sr(h-1,w-1);
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << #x << " = " << x << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
typedef long long ll;
typedef double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAX=3000;
ld coins[MAX];
ld mem[MAX][MAX/2];
int n;

ld dp(int i,int sellos){
	if(sellos<0)return 0.0;
	if(i==n)return 1.0;
	ld &ans=mem[i][sellos];
	if(ans > -0.5) return ans;
	ans = coins[i]*dp(i+1,sellos)+(1.0-coins[i])*dp(i+1,sellos-1);
	return ans;
}
int main() {

#ifdef LOCAL
  // freopen("h.txt", "r", stdin);
  // freopen("main.out", "w", stdout);
#else
  ios::sync_with_stdio(0), cin.tie(0);
#define endl '\n'
#endif
  cin>>n;
  for(int i=0;i<=n;i++){
  	for(int j=0;j<=n;j++){
  		mem[i][j]=-1.0;
  	}
  }
  forn(i,n){
  	cin>>coins[i];
  }
  ld ans = dp(0, (n+1)/2-1);
  cout<<fixed<<setprecision(10)<< ans << endl;
  return 0;
}

Measured memory_bytes: 35584
while True:
    H, W = [int(x) for x in input().split(" ")]

    if H == 0 and W == 0: exit()

    for i in (range(H)):
        for j in (range(W)):
            if (i + j) % 2== 0:
                print("#", end="")
            else:
                print(".", end="")
        print("")

    print("")
    

Measured memory_bytes: 9072
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

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

    uint64_t mod[200000] = { 0 };
    mod[0] = 1;
    for (auto i = 1; i < 200000; i++) {
        mod[i] = mod[i - 1] * 10 % 2019;
        //s += "1";
    }
    //cout << s << endl;
    //return 0;

    uint64_t ans = 0, rest = 0;
    map<uint64_t, uint64_t> rest_count;
    rest_count[0]++;
    uint64_t tmp = (s[s.size() - 1] - '0') % 2019;
    rest_count[tmp]++;
    for (auto i = (int)s.size() - 2; i >= 0; i--) {
//        cout << s[i] << endl;
        tmp = ((s[i] - '0') * mod[s.size() - 1 - i] + tmp) % 2019;
        rest_count[tmp]++;
//        if(tmp == 0) ans++;
//        rest = tmp;
//        // cout << i << " " << 4 << " " << s.substr(i + 1 - 4, 4) << " " << tmp << endl;
//        for (auto j = i - 4; j >= 0; j--) {
//            // cout << s[j] << " " << rest << " " << mod[(i - j)] << endl;
//            tmp = ((s[j] - '0') * mod[(i - j)] + rest) % 2019;
//            if(tmp == 0) ans++;
//            rest = tmp;
//            // cout << i << " " << j << " " << tmp << " " << rest << endl;
//        }
//        // return 0;
    }

    for (auto elm : rest_count) {
        ans += (elm.second * (elm.second - 1)) / 2;
    }

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

Measured memory_bytes: 5264
#include<stdio.h>
int main()
{
	int a;
	scanf("%d",&a);
	if(a<=10||a==12||a==14||a==16||a==18||a==15||a==21||a==24||a==27||a==20||a==28||a==32||a==36||a==25||a==30||a==35||a==40||a==45||a==42||a==48||a==54||a==49||a==56||a==63||a==64||a==72||a==81)
	printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] K = new int[N];
    int ans = Integer.MAX_VALUE;
    for(int i=0; i<N; i++){
      K[i] = sc.nextInt();
    }
    for(int i=1; i<=100; i++){
      int sum = 0;
      for(int j=0; j<N; j++){
        sum += Math.pow(K[j]-i, 2);
      }
      ans = Math.min(ans, sum);
    }
    System.out.print(ans);
  }
}
    
       
    


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    ll a;double b;cin>>a>>b;
    ll x=a/1000;
    ll y=a%1000;
    double z=y;
    z*=b;
    ll w=z;
    b*=(double)1000;
    ll c=b;
    x*=c;
    ll ans=x+w;
    cout<<ans<<endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;

int gcd(int u, int v) {
  int r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}

signed main(){
    int m;
    cin >> n >> m;
    print(gcd(n,m));

    


    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}



Measured memory_bytes: 3108
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N,A,B;
    int SUM = 0;
    cin >> N >> A >> B;
    for(int i=1; i<=N; i++){
        int sum = 0;
        int t = i;
        while(t != 0){
            sum = sum + t%10;
            t = t/10;
        }
        if(A <= sum && sum <= B)  SUM = SUM + i;
    }
    cout << SUM << endl;
}


Measured memory_bytes: 256
def solve(h):
	best_p = abs(h[0] - h[1])
	best_pp = 0
	n = 2
	while n < len(h):
		cost1 = best_p + abs(h[n] - h[n-1])
		cost2 = best_pp + abs(h[n] - h[n-2])
		best = min(cost1, cost2)
		best_pp, best_p = best_p, best
		n = n + 1
	return best_p


def main():
	N = int(input())
	heights = list(map(int, input().split()))
	assert len(heights) == N
	assert N >= 2
	res = solve(heights)
	print(res)


if __name__ == '__main__':
	main()

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

int main(void){
    int n,k=0;
    int a[100];
    int x;
    long long b;
    cin>>n>>x;
    
    for(int i=0;i<n;i++){
        cin>>a[i];
        }
        
     for(int i=0;i<n;i++){
         for(int j=i+1;j<n;j++){
          if(a[i]>a[j]) std::swap(a[i],a[j]);
         }
     }
     
     
     /*for(int i=0;i<n;i++){
        cout<<a[i]<<endl;
        }*/
        
    for(int i=0;i<n;i++) b+=a[i];
    
    if(b==x) cout<<n<<endl;
     
    else if(x<b){
     while(1){
        if(x-a[k]>=0) {
            x=x-a[k];
            k++;
        }
        else if(x-a[k]<0) break;
      }
     cout<<k<<endl;
    }
    
    else if(b<x){
        cout<<n-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import numpy as np


def main():
	L, R = [int(x) for x in input().split()]
	tmp_min = np.inf
	for i in range(L, R+1):
		for j in range(i+1, R+1):
			if (i * j) % 2019 < tmp_min:
				tmp_min = (i * j) % 2019
				if tmp_min == 0:
					print(tmp_min)
					exit()
	print(tmp_min)

if __name__ == "__main__":
	main()


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

using namespace std;

int main() {
    int scores[2] = {0, 0};
    int points[2][10];
    for (int i = 0; i < 2; ++i) {
        for (int j = 0; j < 10; ++j) {
            cin >> points[i][j];
        }
        sort(points[i], points[i]+10);
        for (int j = 0; j < 3; ++j) {
            scores[i] += points[i][9 - j];
        }
    }
    cout << scores[0] << ' ' << scores[1] << endl;
    return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
const int dx[4]={-1,1,0,0};
const int dy[4]={0,0,-1,1};
signed main()
{
	int x;
	cin>>x;
	cout<<10-x/200;
	re 0;
}

Measured memory_bytes: 3620
#include <stdio.h>

#define SIEVE_SIZE (1000000)

int not_p[SIEVE_SIZE] = {1, 1};
int prime_count[SIEVE_SIZE]; // [n] -> [0, n]

int main()
{
  int i, j;
  int n;

  for (i = 2; i * i < SIEVE_SIZE; i++) {
    if (not_p[i]) continue;
    for (j = i * i; j < SIEVE_SIZE; j += i) {
      not_p[j] = 1;
    }
  }
  for (i = 2; i < SIEVE_SIZE; i++) {
    prime_count[i] = prime_count[i - 1] + !not_p[i];
  }

  while (scanf("%d", &n) == 1) {
    printf("%d\n", prime_count[n]);
  }
  return (0);
}

Measured memory_bytes: 8408
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int s = sc.nextInt();
		int w = sc.nextInt();
		
		// 計算
		String result = "safe";
		if(w >= s) result = "unsafe";
		
		// 出力
		System.out.println(result);
	}
}



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

int calctime(int x[]) {
	int f = x[3] - x[0];
	int g = x[4] - x[1];
	int h = x[5] - x[2];
	if (h < 0) {
		--g;
		h += 60;
	}
	if (g < 0) {
		--f;
		g += 60;
	}
	cout << f << " " << g << " " << h << endl;
	return 0;

}

int main() {
	int ar[6], br[6], cr[6];
	for (int i = 0; i < 6; i++) {
		cin >> ar[i];
	}
	for (int i = 0; i < 6; i++) {
		cin >> br[i];
	}
	for (int i = 0; i < 6; i++) {
		cin >> cr[i];
	}

	calctime(ar);
	calctime(br);
	calctime(cr);

	return 0;
}

Measured memory_bytes: 3080
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("9 45000");
            //4 0 5
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("20 196000");
            //-1 -1 -1
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("1000 1234000");
            //14 27 959
        }
        else if (InputPattern == "Input4") {
            WillReturn.Add("2000 20000000");
            //2000 0 0
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        long[] wkArr = InputList[0].Split(' ').Select(X => long.Parse(X)).ToArray();
        long N = wkArr[0];
        long Y = wkArr[1];

        for (long I = 0; I <= N; I++) {
            long SumVal = 10000 * I;
            if (SumVal > Y) break;
            for (long J = 0; I + J <= N; J++) {
                SumVal = 10000 * I + 5000 * J;
                long Rest = Y - SumVal;

                if (Rest < 0) break;
                if (Rest % 1000 > 0) continue;
                long K = Rest / 1000;

                if (I + J + K == N) {
                    Console.WriteLine("{0} {1} {2}", I, J, K);
                    return;
                }
            }
        }
        Console.WriteLine("-1 -1 -1");
    }
}


Measured memory_bytes: 13396
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INPUT()

    print("Yes" if N[0] == '7' or N[1] == '7' or N[2] == '7' else "No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9984
#include <iostream>
#include <string>
#include <vector>
#include <sstream>

using namespace std;


const double c = 380000;

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

	double out = 0;
	for(int i = 0; i < N; i++) {
		string s;
		double y;
		cin >> y >> s;
		if(s.compare("JPY") == 0) {
			out += y;
		} else {
			out += y * c;
		}

	}

	cout << out << endl;
}


Measured memory_bytes: 888
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();    
        int[] data = r.ii();
        int K = r.i();
        for(int i = 0; i < K; i++){
            Arrays.sort(data);
            data[2] *= 2;
        }
        print(data[0]+data[1]+data[2]);
    }
    static void print(Object o){
        System.out.println(o.toString());
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int Int(String s){
            return Integer.parseInt(s);
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
    }
}

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

int main() {
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int ans = 60 * h2 + m2 - 60 * h1 - m1 - k;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>
#include<bits/stdc++.h>
#include<string>
#include<stdlib.h>
#include<stdio.h>
#define long long

using namespace std;

int main() {
	int n,a,b,sum=0,sumb=0;
	string s;
	cin>>n>>a>>b>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='a'){
			if(sum<a+b){
				cout<<"Yes"<<endl;
				sum++;
			}
			else{
				cout<<"No"<<endl;
			}
		}
		if(s[i]=='b'){
			if(sum<a+b and sumb<b){
				cout<<"Yes"<<endl;
				sum++;
				sumb++;
			}
			else{
				cout<<"No"<<endl;
			}
		}
		if(s[i]=='c'){
			cout<<"No"<<endl;
		}
	}
}



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

typedef struct UnionFind{
  int *parent;
  int n;
} UnionFind;

UnionFind* newUnionFind(int n){
  UnionFind *u=(UnionFind *)calloc(1,sizeof(UnionFind));
  u->parent=(int *)calloc(n,sizeof(int));
  u->n=n;
  for(int i=0;i<n;i++) u->parent[i]=-1;
  return u;
}

void initUnionFind(UnionFind *u){
  for(int i=0;i<u->n;i++) u->parent[i]=-1;
}

int root(UnionFind *u,int x){
  if(u->parent[x]<0) return x;
  return u->parent[x]=root(u,u->parent[x]);
}

int same(UnionFind *u,int x,int y){
  return root(u,x)==root(u,y);
}

int getSize(UnionFind *u,int x){
  return -u->parent[root(u,x)];
}

void unite(UnionFind *u,int x,int y){
  x=root(u,x);
  y=root(u,y);
  if(x==y) return;
  if(u->parent[x]>u->parent[y]){
    int swap=x;
    x=y;
    y=swap;
  }
  u->parent[x]+=u->parent[y];
  u->parent[y]=x;
}

typedef long long int int64;

void run(void){
  int n,m;
  scanf("%d%d",&n,&m);
  int *a=(int *)calloc(m,sizeof(int));
  int *b=(int *)calloc(m,sizeof(int));
  int i;
  for(i=0;i<m;i++){
    scanf("%d%d",a+i,b+i);
    a[i]--;
    b[i]--;
  }
  UnionFind *u=newUnionFind(n);
  int64 *dp=(int64 *)calloc(m,sizeof(int64));
  for(i=m-1;i>=0;i--){
    if(same(u,a[i],b[i])) continue;
    dp[i]=(int64)getSize(u,a[i])*getSize(u,b[i]);
    unite(u,a[i],b[i]);
  }
  for(i=1;i<m;i++) dp[i]+=dp[i-1];
  for(i=0;i<m;i++) printf("%lld\n",dp[i]);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;
 
const int N = 111;
const int M = 111;
typedef bitset<M> b100;
 
int a[N+1];
int b[N+1];
int dp[N+1][M+1];
const int INF = int(1e9);
 
int solve(int n, int m)
{
	if(dp[n][m]>=0) return dp[n][m];
	if(n==m) return (dp[n][m]=0);
	if(n<=2*m) return (dp[n][m]=INF);
	for(int i=m+1;i<=n;i++)
	{
		if(solve(n%i, m)<INF)
		{
			return (dp[n][m] = i);
		}
	}
	assert(0);
	return INF;
}
 
ll add(ll a, ll b)
{
	a+=b;
	return a;
}
 
ll mult(ll a, ll b)
{
	return a*b;
}
 
ll pow2[1111];
 
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	memset(dp,-1,sizeof(dp));
	pow2[0]=1;
	for(int i=1;i<=1000;i++) pow2[i]=add(pow2[i-1],pow2[i-1]);
	/*
	int Z; cin>>Z;
	for(int i=Z;i<=M;i++)
	{
		cerr<<i<<' '<<Z<<' '<<solve(i,Z)<<'\n';
	}
	return 0;
	*/
	int n; cin>>n; int m = 0;
	for(int i=0;i<n;i++) {cin>>a[i]; m = max(m, a[i]);}
	for(int i=0;i<n;i++) cin>>b[i];
	for(int i=0;i<n;i++)
	{
		if(a[i]!=b[i]&&(a[i]<=2*b[i]))
		{
			cout<<-1<<'\n'; return 0;
		}
	}
	vector<b100> cur;
	vi ans;
	for(int i=0;i<n;i++)
	{
		b100 bit; bit.reset(); bit.set(a[i],1); cur.pb(bit);
	}
	while(1)
	{
		int M = 0;
		for(int i=0;i<n;i++)
		{
			int mini = INF;
			for(int j=0;j<=m;j++)
			{
				if(cur[i][j])
				{
					int minspot = solve(j, b[i]);
					mini = min(mini, minspot);
				}
			}
			M = max(M, mini);
		}
		if(M==0) break;
		ans.pb(M);
		vector<b100> nw;
		for(int i=0;i<n;i++)
		{
			b100 bit;
			for(int j=0;j<=m;j++)
			{
				if(cur[i][j])
				{
					if(solve(j, b[i]) < M)
					{
						bit.set(j,1);
					}
					if(solve(j%M, b[i]) < M)
					{
						bit.set(j%M,1);
					}
				}
			}
			nw.pb(bit);
		}
		cur = nw;
	}
	ll res = 0;
	for(int v:ans)
	{
		res = add(res, pow2[v]);
	}
	cout<<res<<'\n';
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include <string.h>
using namespace std;
int main(){
	int N,a;
	vector<int> dp;
	cin>>N;
	vector<int>cost;
	for(int i=0;i<N-1;i++){
		cin>>a;
		cost.push_back(a);
	}
	for(int i=2;i<=N;i++){
		vector<int> temp;
		for(int j=0;j<=i;j++){
			if(j==i||j==0){
				temp.push_back(0);
			}else if(j==1){
				temp.push_back(cost[i-2]);
			}else{
				temp.push_back(min(dp[j-1],cost[i-2]+dp[i-j]));
			}
		}
		dp=temp;
	}
	cout<<dp[N/2]<<endl;
}

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

using namespace std;

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

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

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

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) {
        return siz[root(x)];
    }
};

void solve() {
    int N, M;
    cin >> N >> M;
    UnionFind Friend(N);
    for (int i = 0; i < M; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        Friend.unite(a, b);
    }

    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans = max(ans, Friend.size(i));
    }
    
    cout << ans << endl;
}

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

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


int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a+b>c+d){
    cout << "Left";
  }
  if(a+b==c+d){
    cout << "Balanced";
  }
  if(a+b<c+d){
    cout << "Right";
  }
  return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;
public class Main {
   
    public static void main(String[] args) { 
		Scanner sc = new Scanner(System.in);
int N=sc.nextInt();
if(N>=100&&N<=999){
    String s=String.valueOf(N);
    if(s.contains("7"))
        System.out.println(" Yes ");
    else
        System.out.println(" No ");     
}
    } 
}

Measured memory_bytes: 35760
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop

import collections

a,b = input().split()
if a == "H" and b == "H":
    print("H")
elif a == "D" and b == "D":
    print("H")
else:
    print("D")

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s; cin >> s;
    vector <int> a;
    for(int i = 0; i < 4; i+=1) {
      a.push_back(int(s[i] - 'a'));
    }
    sort(a.begin(), a.end());
    if(a[0] == a[1] && a[2] == a[3] && a[1] != a[2]) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

struct mod_fac{
    private:
        vector<ll> f,i_f;
        int n;ll MOD;
    public:
        void init(int n,ll m){
            MOD=m;
            f.resize(n+1,0);
            i_f.resize(n+1,0);
            f[0]=1;
            rep(i,n){
                f[i+1]=f[i]*(i+1)%MOD;
            }
            i_f[n]=power(f[n],MOD-2);
            per(i,n){
                i_f[i]=(i_f[i+1]*(i+1))%MOD;
            }
        }
        ll power(ll a ,ll x){
            if (x==0) return 1;
            if (x==1) return a%MOD;
            if (x==2) return (a*a)%MOD;
            if (x%2==1) return (a*power(power(a,(x-1)/2),2))%MOD;
            return (power(power(a,x/2),2))%MOD;
        }
        ll fac(int x){
            return f[x];
        }
        ll invfac(int x){
            return i_f[x];
        }
        ll comb(int m,int k){
            if (m<0 or k<0) return 0;
            if (m<k) return 0;
            return (((f[m]*i_f[k])%MOD)*i_f[m-k])%MOD;
        }
};

int n;
string s;
vector<int> R,G,B,list;

void solve(){
    cin >> n;
    cin >> s;
    rep(i,3*n) {
        if (s[i]=='R') R.push_back(i);
        if (s[i]=='G') G.push_back(i);
        if (s[i]=='B') B.push_back(i);
    }
    list.resize(3*n,0);
    sort(R.begin(),R.end());
    sort(G.begin(),G.end());
    sort(B.begin(),B.end());
    rep(i,n){
        list[min(min(R[i],G[i]),B[i])]=-1;
        list[max(max(R[i],G[i]),B[i])]=1;
    }
    ll ans=1;
    int m=0,M=0;
    rep(i,3*n){
        if (list[i]==-1) {
            m+=1;
        }
        if (list[i]==0) {
            ans*=m;
            ans%=mod;
            m-=1;
        }
    }
    per(i,3*n){
        if (list[i]==1) {
            M+=1;
        }
        if (list[i]==0) {
            ans*=M;
            ans%=mod;
            M-=1;
        }
    }
    mod_fac mo;mo.init(n,mod);

    cout << ans*mo.fac(n)%mod << endl;
    
}

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

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    long long n; cin >> n;
    long long ans = 0;
    auto f = [&](long long n, long long k) {
        if (k == 1) return 0;
        while (n % k == 0) n /= k;
        if (n % k == 1) ans++;
    };
    set<long long> w;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            f(n, i);
            if (i * i != n) f(n, n / i);
            w.emplace(i), w.emplace(n / i);
        }
    }
    n--;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            if (!w.count(i)) ans++, w.emplace(i);
            if (!w.count(n / i)) ans++, w.emplace(n / i);
        }
    }
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
	char s1, s2, s3;
	cin >> s1 >> s2 >> s3;

	int ans = 0;
	if (s1 == '1') {
		ans++;
	}
	if (s2 == '1') {
		ans++;
	}
	if (s3 == '1') {
		ans++;
	}

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <functional>
#include <numeric>
#include <vector>
using namespace std;

const double PI=acos(-1);

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

    vector<int> aa(a), bb(b);
    int am = 999999, bm = 999999;
    for(int i = 0; i < a; i++){
        cin >> aa[i];
        am = min(am, aa[i]);
    }
    for(int i = 0; i < b; i++){
        cin >> bb[i];
        bm = min(bm, bb[i]);
    }
    int mi = am + bm;
    for(int i = 0; i < m; i++){
        int xx, yy, c;
        cin >> xx >> yy >> c;
        mi = min(mi, aa[xx-1]+bb[yy-1]-c);
    }

    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 1024
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<pair<ld,ld>> vec(n);
    rep(i,n){
        ld x, y;
        cin >> x >> y;
        vec[i] = {x, y};
    }
    sort(all(vec));
    ld res = 0;
    ll f = 0;
    //rep(i,n)cout<<vec[i].S<<" ";
  //  cout<<endl;
  //  cout<<(vec[0].F - vec[1].F) * (vec[0].F - vec[1].F)<<endl;
//    cout<<sqrt((vec[0].F - vec[1].F) * (vec[0].F - vec[1].F) + (vec[0].S - vec[1].S) * (vec[0].S - vec[1].S))<<endl;
    do{
        f++;
        ld res2 = 0;
        rep(i,n-1){
            res2 += sqrt((vec[i].F - vec[i + 1].F) * (vec[i].F - vec[i + 1].F) + (vec[i].S - vec[i + 1].S) * ((vec[i].S - vec[i + 1].S)));
            
        }
     //   cout<<res2<<" "<<f<<endl;
        res += res2;
    } while (next_permutation(all(vec)));
    cout << setprecision(20) << res / f << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]){
    int a,b,c;
    scanf("%d %d %d", &a, &b, &c);
    if(a<b && b<c){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<string>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

using namespace std;

typedef long long int ll;

const ll INF=(ll)1e18;

int N;

int main(){
    cin >> N;

    ll dp[N][3];
    REP(i,N)REP(j,3)dp[i][j] = 0;

    REP(i,3)cin >> dp[0][i];

    FOR(i,1,N){
      ll abc[3];
      REP(j,3){
        cin >> abc[j];
      }
      REP(j,3)REP(k,3){
        if(j==k)continue;
        ll tmp = dp[i-1][k] + abc[j];
        if(tmp > dp[i][j])dp[i][j] = tmp;
      }
    }
    ll ans = 0;
    REP(i,3){
      if(ans < dp[N-1][i]) ans = dp[N-1][i];
    }    
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<long,long>
#define INF 1000000000000000000
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; }
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<int, int> mp;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
class Union_Find {
private:
	vector<int> par;
	vector<int> rank;
public:
	Union_Find(int n) {
		rep(i, n) {
			par.push_back(i);
			rank.push_back(0);
		}
	}
	int find(int x) {
		if (par.at(x) == x) return x;
		else return par.at(x) = find(par.at(x));
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (rank.at(x) < rank.at(y)) {
			par.at(x) = y;
		}
		else {
			par.at(y) = x;
			if (rank.at(x) == rank.at(y)) rank.at(x)++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	rep(i, n) {
		cin >> a[i]; b[i] = a[i];
	}
	sort(a.begin(), a.end());
	int tmp1 = a[n / 2 - 1];
	int tmp2 = a[n / 2];
	for (int i = 0; i < n; i++) {
		if (b[i] <= tmp1)cout << tmp2 << endl;
		else cout << tmp1 << endl;
	}
	return 0;
}

Measured memory_bytes: 5376
package main

import "fmt"

func reverseStr(s string) string {

	runes := []rune(s)

	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}

	return string(runes)
}

func main() {
	// Code for A - Measure
	var S string
	fmt.Scanf("%s", &S)
	if len(S) == 2 {
		fmt.Println(S)
	} else {
		fmt.Println(reverseStr(S))
	}
}


Measured memory_bytes: 1832
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<utility>
#include<array>
#include<cassert>
#include<list>
#include<experimental/any>
#include<cstring>
#include<cctype>
#include<ctime>
#include<cstdbool>
#include<cstdint>
#include<cstddef>
#include<set>
#include<unordered_set>
#include<bitset>
 
using namespace std;
using experimental::any;
 
#define SPEEDY cin.tie(0);ios::sync_with_stdio(false);
 
#define REP(i,n) for(int i=0;i<(n);i++)
#define ARREP(i,n,X) for(int i=0;i<(n);i++)cin>>X[i]
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=n;i++)
#define BitFOR(N) REP(Bit,1<<(N))
 
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define TFDEB(f) (f)? cout<<"true ":cout<<"false ";
#define FORDEB(n,X) for(int i=0;i<(n);i++)ARDEB(i,X)
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define ARDEB(i,X) {}
#define TFDEB(f) {}
#define FORDEB(n,X) {}
#define END {}
#endif
 
typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ALL(X) X.begin(),X.end()
struct edge{int to,cost;};
//struct edge{int from,cost,to;};
struct P2{int x,y;};
#define BIT(Bit,n) bitset<n>(Bit)
#define Endl endl
 
const int MOD7=1000000007;
const int INF=100000000;
const int SET=1000;

#if 0
ll dp[1000][1000];
ll DP(int x,int y){
	if(dp[x][y]!=-1)return dp[x][y];
	if(x<0||y<0)return 0;
	if(x==0&&y==0)return 1;
	else if(x==0||y==0){
		if(x==0) return dp[x][y]=DP(x,y-1);
		if(y==0) return dp[x][y]=DP(x-1,y);
	}
	dp[x][y]=DP(x-1,y)+DP(x,y-1);
	return dp[x][y];
}
#endif

int main(){
	int n,m;
	string s[110];
	cin>>n>>m;
	REP(i,n){
		cin>>s[i];
	}
	for(int i=0;i<m+2;i++){
		cout<<"#";
	}
	cout<<endl;
	REP(i,n){
		cout<<"#"<<s[i]<<"#"<<endl;
	}
	REP(i,m+2){
		cout<<"#";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
// #include "Template.cpp"
#define endl "\n"

void solve()
{
    int n, k; cin >> n >> k;
    vector<int> arr(n, 0);
    for(int i = 0; i < n; i ++) cin >> arr[i];
    for(int i = k; i < n; i ++) {
        if(arr[i] > arr[i-k]) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
}

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


Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD=1e9+7;
template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}
void check(int &a){
  if(abs(a)>MOD)a%=MOD;if(a<0)a+=MOD;
}
void kakeru(int &a,int b){
  check(a);check(b);
  a*=b;a%=MOD;
}
void tasu(int &a,int b){
  check(a);check(b);
  a+=b;if(a>MOD)a-=MOD;
}
int pw(int n,int k){
  if(k<0)return pw(n,k+MOD-1);
  int res=1;
  while(k){
    if(k&1)kakeru(res,n);
    kakeru(n,n);
    k>>=1;
  }
  return res;
}

signed main(){
  int n;cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  map<int,int> m;
  for(int i=0;i<n;i++){
    int tmp=v[i];
    for(int j=2;j*j<=tmp;j++){
      int cnt=0;
      while(tmp%j==0)tmp/=j,cnt++;
      chmax(m[j],cnt);
    }
    chmax(m[tmp],1LL);
  }
  int lcm=1;
  for(auto p:m)kakeru(lcm,pw(p.first,p.second));
  int ans=0;
  for(int p:v)tasu(ans,lcm*pw(p,MOD-2));
  cout<<ans%MOD<<endl;
}


Measured memory_bytes: 1024
import std.stdio, std.range, std.random, std.conv, std.string, std.math;
import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.sorting;

void main()
{
    int[] input = readln().strip.split().to!(int[]);
    int N = input[0];
    int K = input[1];

    if((N+1)/2 >= K)
    {
        writeln("YES");
    }else
        writeln("NO");
}

Measured memory_bytes: 256
import java.io.PrintWriter

val pw = PrintWriter(System.out)
fun main(args: Array<String>) {
    var (n,d)=listOfInt()
    var pts = mutableListOf<List<Long>>()
    repeat(n) {
        pts.add(readLine()!!.split(" ").map { it.toLong() })
    }
    var sqs = mutableListOf<Long>()
    repeat(1000000) {
        sqs.add(it.toLong() * it)
    }
    var re=0
    repeat(n){ i ->
        repeat(i){ j ->
            var sum = 0L
            repeat(d) { k ->
                var tmp = pts[i][k] - pts[j][k]
                sum += tmp * tmp
            }
            if(sqs.binarySearch(sum)>=0) ++re
        }
    }
    pw.println(re)
    pw.flush()
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }
fun listOfLong() = listOfString().map { it.toLong() }
fun listOfDouble() = listOfString().map { it.toDouble() }


Measured memory_bytes: 84752
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		int n = s.length();
		long[] dp1 = new long[n];
		dp1[0] = 1;
		long[] dp2 = new long[n];
		dp2[0] = 2;
		for (int i = 1; i < n; i++) {
			if (s.charAt(i) == '1') {
				dp1[i] = dp1[i - 1] * 3 + dp2[i - 1];
				dp1[i] %= 1000000007;
				dp2[i] = dp2[i - 1] * 2;
				dp2[i] %= 1000000007;
			} else {
				dp1[i] = dp1[i - 1] * 3;
				dp1[i] %= 1000000007;
				dp2[i] = dp2[i - 1];
			}
		}
		long ans = dp1[n - 1] + dp2[n - 1];
		ans %= 1000000007;
		System.out.println(ans);
	}
}


Measured memory_bytes: 28432
#include<bits/stdc++.h>
#pragma warning(disable:4996)
#ifdef _MSC_VER
#  define __builtin_popcount __builtin_popcountll
#  define __builtin_popcountll __popcnt
#endif
#define int long long
using namespace std;
using ll = long long;
using ld = long double;
const long double PI = acos(-1.0);
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
inline void my_io() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout << fixed << setprecision(10);
}


bool pairCompare(const pair<int,int>& firstElof, const pair<int,int>& secondElof)
{
	
	return firstElof.second < secondElof.second;
}

signed main() {
	int n;
	cin >> n;
	vector<int>v(n);
	for (int i = 0; i < n; i++) {

		cin >> v[i];
	}
	int ans = 0;
	for (int i = 0; i < n-2; i++) {
		vector<int>test(3);
	
		for (int j = 0; j < 3; j++) {
			
			test[j] = v[i + j];
		}
		
		sort(test.begin(), test.end());
		if (v[i + 1] == test[1]) {
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);
$map = explode(" ", trim(fgets(STDIN)));

$now = 1;

$ans = 0;
foreach($map as $value){
    if($value == $now){
        $now++;
    }else{
        $ans++;
    }

}
if($ans == $n){
    echo "-1";
}else {
    echo $ans;
}

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

int main()
{
  long double a, b;
  cin >> a >> b;
  if (a > b)
  {
    cout << "GREATER" << endl;
  }
  else if (b > a)
  {
    cout << "LESS" << endl;
  }
  else
  {
    cout << "EQUAL" << endl;
  }
}


Measured memory_bytes: 3672
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;


public class Main {
    public static void main(String[] args) {
        FastScanner fsc = new FastScanner();
        long x=fsc.nextLong();
        long ans=x/11;
        x%=11;
        ans*=2;
        if(x>=7) ans+=2;
        else if(x>0) ans++;
        System.out.println(ans);
    }
}


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;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; 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() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


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

const ll mod = 1000000007;
const int INF = 1001001001;

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

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n);
	vector<int> num(1000001);
	set<int> st;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		num[a[i]]++;
		st.insert(a[i]);
	}
	int mx = *max_element(a.begin(), a.end());
	int full = a[0];
	bool ok1 = false, ok2 = false;
	for(int i = 1; i < n; i++){
		full = gcd(full, a[i]);
		if(full == 1){
			ok1 = true;
			break;
		}
	}
	for(int i = 2; i <= mx; i++){
		int cnt = 0;
		for(int j = 1; j * i <= mx; j++){
			int tmp = i * j;
			if(tmp > mx) break;
			if(st.count(tmp)){
				cnt += num[i * j];
			}
			if(cnt >= 2){
				ok2 = true;
				break;
			}
		}
		if(ok2) break;
	}
	if(!ok2) cout << "pairwise coprime" << endl;
	else if(ok2 && ok1) cout << "setwise coprime" << endl;
	else cout << "not coprime" << endl;

} 


Measured memory_bytes: 57792
import std.stdio, std.algorithm, std.string, std.conv, std.array;

void main() {
  bool first = true;
  int times;
  while((times = readln.chomp.to!int) != 0) {
    if (!first) writeln;
    else first = false;
    
    int[string] points;
    int[string] line;
    foreach(t; 0..times) {
      string name;
      string[] data = readln.chomp.split(" ");
      int[] point = data[1..$].map!(to!(int)).array;
      name = data[0];
      points[name] = point[0] * 3 + point[2] * 1;
      line[name] = t;
    }
    string[] names = points.keys;
    sort!((x, y) {
        if (points[x] == points[y]) return line[x] < line[y];
        else return points[x] > points[y];
      })(names);
    foreach(n; names) {
      writeln(n, ",", points[n]);
    }
  }
}

Measured memory_bytes: 1100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string vec;
  cin >> N;
  cin >> vec;
  
  int x=0;
 
  for (int i = 0; i < N-2; i++) {
    if (vec.at(i) == 'A' & vec.at(i + 1) == 'B' & vec.at(i + 2) == 'C')
      x ++;
  }
  
  cout << x << endl;
}

Measured memory_bytes: 256
using System;

public class Rectangle {
  static int Main(string[] args)
  {
    string data = Console.ReadLine();
    string[] dataArray = data.Split();
    int area = int.Parse(dataArray[0]) * int.Parse(dataArray[1]);
    int perimeter = (int.Parse(dataArray[0]) * 2) + (int.Parse(dataArray[1]) * 2);
    Console.WriteLine(area + " " + perimeter);
    return 0;
  }
}



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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m;
	cin >> n >> m;
	ll ans = 0;
	if(m < 2*n){
		ans = m/2;
		n -= m/2;
		m = 0;
	}
	else{
		ans = n;
		m -= 2*n;
		n = 0;
	}
	ans += m / 4;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
k=int(input())
a="0"
l=[]
if k%2==0:
  print("-1")
else:
  for i in range(k):
    a=a+"7"
    b=int(a)
    b=b%k
    if b==0:
      ans=i+1
      l.append(ans)
      print(ans)
      break
    a=str(b)
  if l==[]:
    print("-1")

Measured memory_bytes: 9180
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int a[3][3];
  for (int i=0; i<3; i++)
    scanf("%d%d%d", a[i], a[i]+1, a[i]+2);
  int n;
  scanf("%d", &n);
  int b;
  for (int i=0; i<n; i++){
    scanf("%d", &b);
    for (int j=0; j<3; j++)
      for (int k=0; k<3; k++)
        if (a[j][k] == b) a[j][k] = 0;
  }
  bool check = false;
  for (int i=0; i<3; i++) {
    int cnt = 0;
    for (int j=0; j<3; j++) {
      if (a[i][j] == 0) cnt++;
    }
    if (cnt == 3) check = true;
    cnt = 0;
    for (int j=0; j<3; j++) {
      if (a[j][i] == 0) cnt++;
    }
    if (cnt == 3) check = true;
  }
  int cnt = 0;
  for (int i=0; i<3; i++) {
    if (a[i][i] == 0) cnt++;
  }
  if (cnt == 3) check = true;
  cnt = 0;
  for (int i = 0; i < 3; i++)
  {
    if (a[2-i][i] == 0)
      cnt++;
  }
  if (cnt == 3)
    check = true;
  if (check)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}


Measured memory_bytes: 128
//Bismillahir Rahmanir Raheem
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<stdlib.h>
#include<queue>
#include<map>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<deque>
#include<set>
using namespace std;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long LL;
typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef pair<int, int> pii;
#define FF first
#define SS second
#define MP make_pair
#define mxN (int)2e5 + 2
#define sz(n) (int)(n).size()
#define fasterIO ios::sync_with_stdio(0); cin.tie(0);
LL gcd(LL a, LL b)
{
    if(b == 0LL) return a;
    return gcd(b, a % b);
}
LL bigmod(LL a, LL b, LL mod)
{
    if(b == 0LL) return 1LL;
    LL sq = bigmod(a, b/2LL, mod);
    sq = (sq * sq) % mod;
    if(b&1LL) return (sq * (a%mod)) % mod;
    return sq;
}


int main()
{
    fasterIO
    int n;
    cin >> n;
    vi a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    LL cnt = 0;
    for(int i = 1; i < n; i++)
    {
        if(a[i-1] > a[i]){
            cnt += a[i-1] - a[i];
            a[i] = a[i-1];
        }
    }
    cout << cnt << endl;
    return 0;
}





Measured memory_bytes: 3652