akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    static int h;
    static int w;
    static String [] s;
    static int[] dx = { 1, 1, 0,-1,-1,-1, 0, 1};
    static int[] dy = { 0, 1, 1, 1, 0,-1,-1,-1};
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        h = sc.nextInt();
        w = sc.nextInt();
        s = new String [h];
        for(int i = 0; i < h; i++) {
            s[i] = sc.next();
        }
        String [] ans = solve();
        indicate(ans);
    }
    static void indicate (String [] arr) {
        for(int i = 0; i < arr.length; i++){
            System.out.println(arr[i]);
        }
    }
    static String[] solve () {
        String [] ans = new String [h];
        for(int y = 0 ; y < h; y++) {
            String tmp = "";
            for(int x = 0 ; x < w; x++) {
                if(s[y].charAt(x) == '#'){
                    tmp = tmp + "#";
                } else {
                    int count = 0;
                    for(int i = 0; i < 8; i++){
                        if(judge(x,y,i)){
                            count++;
                        }
                    }
                    tmp = tmp + count;
                }
            }
            ans[y] = tmp;
        }
        return ans;
    }
    
    static boolean judge(int x, int y, int i) {
        try{
            if(s[y+dy[i]].charAt(x+dx[i]) == '#') {
                return true;
            } else {
                return false;
            }
        } catch (Exception e) {
            return false;
        }
    }
}

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

int main() {
  
  	int N;
  	cin >> N;
  
  	vector<int> A(N);
  	for(int i=0;i<N;i++){
    	cin >> A.at(i);
    } 
  
  	int count,judge=0;
  	while(true){
      	count=0;
  		for(int i=0;i<N;i++){
    		if(A.at(i)%2==0){
        		count++;
        	}
      		A.at(i) /=2;
        }

      	if(count==N){
    		judge++;
    	}
      	else{
        	break;
        }
    }
  	
  	cout << judge << endl;
}

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

const int nax = 1e4 + 20;
char k[nax];
const int mod = 1e9 + 7;
 
void add_self(int& a, int b) {
    a += b;
    if(a >= mod) {
        a -= mod;
    }
}
 
int main() {
    scanf("%s", k);
    int D;
    scanf("%d", &D);
    int len = strlen(k);
    vector<vector<int>> dp(D, vector<int>(2));
    dp[0][0] = 1;
    for(int where = 0; where < len; ++where) {
        vector<vector<int>> new_dp(D, vector<int>(2));
        for(int sum = 0; sum < D; ++sum) {
            for(bool sm_already : {false, true}) {
                for(int digit = 0; digit < 10; ++digit) {
                    if(digit > k[where] - '0' && !sm_already) {
                        break;
                    }
                    add_self(new_dp[(sum+digit)%D][sm_already || (digit < k[where]-'0')],
                        dp[sum][sm_already]);
                }
            }
        }
        dp = new_dp;
    }
    int answer = (dp[0][false] + dp[0][true]) % mod;
    --answer;
    if(answer == -1) {
        answer = mod - 1;
    }
    printf("%d\n", answer);
}


Measured memory_bytes: 256
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	string output = "No";
	int input = 0;
	cin >> input;
	int digit1 = input / 100;
	int digit2 = (input - digit1 * 100) / 10;
	int digit3 = (input - digit1 * 100 - digit2 * 10);

	if (digit1 == 7 || digit2 == 7 || digit3 == 7)
		output = "Yes";

	cout << output << endl;

	return 0;
}

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

using namespace std;

int n, a[20];
long long P[20], X[20], Y[20], Re[20];

void Gen(int I, int A[])
{
    if (I == n)
    {
        int k1 = 0, k2=0;
        long long Vx[17], Vy[17], Mi[17];
        Vx[0] = 0;
        Vy[0] = 0;
        for (int i = 0; i < n; i++)
        {
            Mi[i] = 0;
            if (a[i] == 1)
            {
                Vx[k1+1] = X[i];
                k1++;
            }
            else if (a[i] == 2)
            {
                Vy[k2+1] = Y[i];
                k2++;
            }
            else
            {
                Mi[i] = 2000000000000;
            }
        }
        for (int i = 0; i < n; i++)
        {
            if (a[i] == 0)
            {
                for (int y = 0; y <= k1; y++)
                {
                    Mi[i] = min(Mi[i], abs(Vx[y] - X[i]));
                }
                for (int y = 0; y <= k2; y++)
                {
                    Mi[i] = min(Mi[i], abs(Vy[y] - Y[i]));
                }
            }
        }
        long long At=0;
        for (int i = 0; i < n; i++)
        {
            At += P[i]*Mi[i];
        }
        Re[k1+k2] = min(Re[k1+k2], At);
    }
    else
    {
        A[I] = 0;
        Gen(I+1, A);
        A[I] = 1;
        Gen(I+1, A);
        A[I] = 2;
        Gen(I+1, A);
        A[I] = 0;
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> X[i] >> Y[i] >> P[i];
    }
    //sort(VX,VX+n);
    //sort(VY,VY+n);
    for (int i = 0; i <= n; i++)
    {
        Re[i] = 2000000000000000;
        a[i] = 0;
    }
    Gen(0, a);
    for (int i = 0; i <= n; i++)
    {
        cout << Re[i] << "\n";
    }
    return 0;
}
/*
15
2 2 286017
3 1 262355
2 -2 213815
1 -3 224435
-2 -2 136860
-3 -1 239338
-2 2 217647
-1 3 141903
10 10 12212
12 12 92212
14 14 21855
19 13 12155
15 19 26555
135 544 78945
1561 5612 12398
*/


Measured memory_bytes: 3628
def gcd(a, b):
    if a < b:
        a, b = b, a
    while b > 0:
        a, b = b, a % b
    return a

def lcm(a, b):
    return (a * b) // gcd(a, b)

N = int(input())
T = [int(input()) for i in range(N)]

ans = T[0]

for t in T[1:]:
    ans = lcm(ans, t)

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    string S, T;
    cin >> S >> T;
    int ans = 0;
    for(int i = 0; i < 3; i++){
        if(S[i] == T[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define eps 0.000000001
using namespace std;
typedef long double ld;
typedef pair<int,int> p;
typedef pair<ld,p> P;

int n;
ld px[200],py[200],pz[200],vx[200],vy[200],vz[200],r[200],vr[200];

ld getlen(int a,int b,ld M){
  ld ax=px[a]+vx[a]*M,ay=py[a]+vy[a]*M,az=pz[a]+vz[a]*M,ar=r[a]-vr[a]*M;
  ld bx=px[b]+vx[b]*M,by=py[b]+vy[b]*M,bz=pz[b]+vz[b]*M,br=r[b]-vr[b]*M;
  ld dx=ax-bx,dy=ay-by,dz=az-bz;
  return sqrt(dx*dx+dy*dy+dz*dz)-(ar+br);
}

ld check(int a,int b){
  ld L=0,R=128,M;
  int s=0;
  while(s++<50){
    M=(L+R)/2;
    ld len=getlen(a,b,M),len1=getlen(a,b,M+eps);
    if(len<len1||len<0)R=M;
    else L=M;
  }
  if(getlen(a,b,R)>0)return 100;
  return R;
}

int main(){
  while(cin>>n,n){
    for(int i=0;i<n;i++)
      cin>>px[i]>>py[i]>>pz[i]>>vx[i]>>vy[i]>>vz[i]>>r[i]>>vr[i];
    priority_queue<P,vector<P>,greater<P> > q;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++)
	q.push(P(check(i,j),p(i,j)));
      q.push(P(r[i]/vr[i],p(i,i)));
    }
    ld used[200]={};
    while(!q.empty()){
      ld t=q.top().first;
      int a=q.top().second.first,b=q.top().second.second;
      q.pop();
      if(used[a]||used[b])continue;
      used[a]=used[b]=t;
    }
    for(int i=0;i<n;i++)printf("%.10Lf\n",used[i]);
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n; cin >> n;

    if (n % 2 != 0) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;
    ll t10 = 10;
//    ll t50 = 50;
    ll t50 = 5;

//    while (n / t10 > 0) {
//        ans += (n / t10);
//
//        t10 *= 10;
//    }

//    while (n / t50 > 0) {
//        ans += (n / t50) - ((n / t50) / 2);
//
//        t50 *= 5;
//    }

    while (n / t50 > 0) {
        ans += (n / t50) - (((n / t50) + 1)/ 2);

        t50 *= 5;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std ;

int main ()
{
	int i ;
	string s ;
	cin >> s ;
	int len=s.length();
	if ( s[0]!='A' ) puts("WA");
	else if ( s[1]=='C' || s[len-1]=='C' ) puts("WA");
	else
	{
		bool ok=1;
		int c=0;
		for ( i=0 ; i<len ; i++ ) 
		{
			c+=(s[i]=='C');
			if ( s[i]>='A' && s[i]<='Z' && s[i]!='A' && s[i]!='C' ) ok=0;
		}
		if ( !ok || c>1 || !c ) puts("WA");
		else puts("AC");
	}
	return 0 ;
}

Measured memory_bytes: 256
pub fn read<T: std::str::FromStr>() -> T {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
        read::<String>()
                .split_whitespace()
                .map(|e| e.parse().ok().unwrap())
                .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
        (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: u32) -> Vec<T> {
        (0..n).map(|_| read()).collect()
}

use std::cmp::min;

fn solve(dp: &mut Vec<Vec<u32>>, n: usize, m: usize, c: &Vec<u32>) {
        for i in 0..m {
                for j in 1..(n + 1) {
                        let tmp1;
                        if i == 0 {
                                tmp1 = 200000000;
                        } else {
                                tmp1 = dp[i - 1][j];
                        }
                        let tmp2;
                        let ct = c[i] as usize;
                        if j < ct {
                                tmp2 = 2000000000;
                        } else {
                                tmp2 = 1 + dp[i][j - ct];
                        }
                        dp[i].push(min(tmp1, tmp2));
                }
        }
}

fn main() {
        let v: Vec<usize> = read_vec();
        let n = v[0];
        let m = v[1] as usize;
        let c: Vec<u32> = read_vec();

        let mut dp: Vec<Vec<u32>> = vec![vec![0]; m];

        solve(&mut dp, n, m, &c);

        println!("{}", dp[m - 1][n]);
}



Measured memory_bytes: 9016
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

struct tri{
  ll f,s,t;
};

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;ll K;cin >> N >> K;
  if(2*K-1>N){
    cout << -1 << endl;
    return 0;
  }

  vector<PII> v(N);
  ll b;
  int index = 0;
  b = K+2*N-1-N/2;
  if(N%2==1 && K%2==1)--b;
  repp(x,K,K+N){
    if(x&1)continue;
    v[index].first = x+b;
    v[index].second = x;
    ++index;
    --b;
  }

  b = K+2*N-1;
  repp(x,K,K+N){
    if((x&1)==0)continue;
    v[index].first = x+b;
    v[index].second = x;
    ++index;
    --b;
  }

  sort(all(v));
  ll c = K+2*N;
  queue<tri> que;
  rep(i,N){
    que.push({v[i].second,v[i].first-v[i].second,c});
    ++c;
  }
  while(!que.empty()){
    tri t = que.front();que.pop();
    printf("%d %d %d\n",t.f,t.s,t.t);
  }
  return 0;
}


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

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

    int N;
    cin >> N;
    vector<string> s(N);
    REP(i, N) cin >> s[i];
    int ans = 0, a = 0, b = 0, ab = 0;
    for (string st : s) {
        REP(i, st.size() - 1) {
            if (st[i] == 'A' && st[i+1] == 'B') ans++;
        }
        if (st[0] == 'B' && st[st.size() - 1] == 'A') ab++;
        else if (st[0] == 'B') b++;
        else if (st[st.size() - 1] == 'A') a++;
    }
    if (ab == 0) ans += min(a, b);
    else if (a == 0 && b == 0) ans += ab - 1;
    else if (a == 0 || b == 0) ans += ab;
    else ans += ab + 1 + min(a - 1, b - 1);
    cout << ans << endl;
}

Measured memory_bytes: 768
#include<iostream>
#include<math.h>
using namespace std;

long double cost[1002][1002];
long double d[1002];
bool used[1002];

int main() {
	//D
	
	string s;
	cin >> s;
	if (s[0] == s[s.size() - 1]) {
		if (s.size() % 2 == 1) {
			cout << "Second" << endl;
		}
		else {
			cout << "First" << endl;
		}
	}
	else {
		if (s.size() % 2 == 1) {
			cout << "First" << endl;
			
		}
		else {
			cout << "Second" << endl;
		}
	}
	return 0;

	//E
	/*
	long double d[1002];
	long double x[1002], y[1002], r[1002];
	cin >> x[0] >> y[0] >> x[1] >> y[1];
	int i, n, j;
	cin >> n;
	r[0] = 0; r[1] = 0;
	for (i = 0; i < n; i++) {
		cin >> x[i + 2] >> y[i + 2] >> r[i + 2];
	}
	for (i = 0; i < n + 2; i++) {
		for (j = 0; j < n + 2; j++) {
			cost[i][j] = sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j])) - r[i] - r[j];
			if (cost[i][j] < 0)cost[i][j] = 0;
		}
	}
	long double INF = 3000000000;

	for (i = 0; i <= n + 1; i++) {
		d[i] = INF;
		used[i] = false;
	}
	d[0] = 0;
	while (true) {
		int v = -1;

		for (int u = 0; u < n + 2; u++) {
			if (!used[u] && (v == -1 || d[u] < d[v]))v = u;
		}
		if (v == -1)break;
		used[v] = true;
		for (int u = 0; u < n + 2; u++) {
			if (d[u] > d[v] + cost[v][u]) {
				d[u] = d[v] + cost[v][u];
			}
		}
	}

	printf("%.10Lf\n",d[1]);
	return 0;
	*/
	/*int n, x;
	cin >> n >> x;
	long long int a[100001];
	int i;
	for (i = 1; i <= n; i++) {
		cin >> a[i];
	}

	long long int counter = 0;
	for (i = 1; i <= n; i++) {
		if (a[i] + a[i - 1] > x) {
			//cout << i << endl;
			counter = counter + (a[i] + a[i - 1] - x);
			a[i] = a[i] - (a[i] + a[i - 1] - x);
			//cout << a[i] << endl;a
			
		}
	}
	cout << counter << endl;
	return 0;*/
}

Measured memory_bytes: 3660
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

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

    string high = S.substr(0, 2), low = S.substr(2, 2);
    int h = stoi(high), l = stoi(low);
    
    if ((h > 12 || h < 1) && (l > 12 || l < 1)) {
        write("NA");
    }
    else if (h > 12 || h < 1) {
        write("YYMM");
    }
    else if (l > 12 || l < 1) {
        write("MMYY");
    }
    else {
        write("AMBIGUOUS");
    }
}

Measured memory_bytes: 256
a,b = map(int,input().split())
n = 0
while 2**n < b:
    n += 1
ans = 0
for i in range(1,n):
    k = 2**i
    if a >= k:
        x = a - (k-1)
        y = b - (k-1)
        x1 = x%(k*2)
        y1 = y%(k*2)
        if x1 == 0 or x1 > k:
            if y1 <= k and y1 % 2 == 1:
                ans += k
        else:
            if x1 % 2 == 0:
                if y1 % 2 == 0 or y1 > k:
                    ans += k
            else:
                if y1 % 2 == 1 and y1 <= k:
                    ans += k
    else:
        y = b - (k-1)
        y1 = y % (k*2)
        if y1 < k and y1 % 2 == 1:
            ans += k
if b == 2**n and n > 0:
    ans += 2**n
if a % 4 == 0 or a % 4 == 1:
    if b % 4 == 1 or b % 4 == 2:
        ans += 1
else:
    if b % 4 == 0 or b % 4 == 3:
        ans += 1
print(ans)

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

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; }
template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
}fastio;





int main(){

    int n, d;
    cin >> n >> d;

    int x[n][d];

    for(int i = 0; i < n; ++i){
        for(int j = 0; j < d; ++j){
            cin >> x[i][j];
        }
    }

    int cnt = 0;
    for(int i = 0; i < n; ++i){
        for(int j = i+1; j < n; ++j){
            int sum = 0;
            for(int k = 0; k < d; ++k){
                sum += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            double tmp = (double)sum;
            double ans = sqrt(tmp);
            if((int)ans == ans) ++cnt;
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int pc = sc.nextInt();
			int n = sc.nextInt();
			if (pc == 0 && n == 0) return;
			int r = sc.nextInt();

			int time[][] = new int [n+1][1260+1];
			for (int i = 0; i < r; i++) {
				int t = sc.nextInt();
				int pcn = sc.nextInt();
				int m = sc.nextInt();
				int s = sc.nextInt();
				if (s == 1) time[m][t]++;
				if (s == 0) time[m][t]--;
			}

			for (int k = 1; k <= n; k++)
				for (int i = 540; i <= 1260; i++)
					time[k][i] += time[k][i-1];

			int q = sc.nextInt();
			for (int i = 0; i < q; i++) {
				int ts = sc.nextInt();
				int tg = sc.nextInt();
				int m = sc.nextInt();
				int count = 0;
				for (int j = ts; j < tg; j++) {
					if (time[m][j] > 0) count++;
				}
				System.out.println(count);
			}
		}
	}
}



Measured memory_bytes: 214820
#include <cstdio>
#include <iostream>
#define N 200010
using namespace std;
typedef long long i64;
i64 n, X, x[N], sum[N], Ans = 1LL << 62;

int main() {
    cin >> n >> X;
    for (int i = 1; i <= n; ++i)
        scanf("%lld", x + i),
        sum[i] = sum[i - 1] + x[i];
    for (i64 k = 1; k <= n; ++k) {
        i64 res = k * X; 
        for (int j = 0; j <= n / k; ++j) {
            i64 M = n - j * k, m;
            m = max(M - k, 0LL);
            i64 c = j == 0 ? 5 : j * 2 + 3;
            res += (i64) c * (sum[M] - sum[m]);
            if (res < 0) break;
        }
        if (res > 0) Ans = min(Ans, res);
    }
    cout << Ans + n * X;
    return 0;
}


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

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

int main()
{
  const long long INF = 1LL << 60;
  
  long long dp[100010];
  
  for ( int i = 0; i < 100010; ++i )
  {
    dp[i] = INF;
  }
  
  int n;
  cin >> n;
  
  int height[100010];
  for( int i = 0; i < n; i++ )
  {
    cin >> height[i];
  }
  
  dp[0] = 0;
  dp[1] = abs( height[1] - height[0] );
  
  for ( int i = 2; i < n; i++ )
  {
    chmin( dp[i], dp[i-1] + abs( height[i] - height[i-1] ) );
    chmin( dp[i], dp[i-2] + abs( height[i] - height[i-2] ) );
  }
  
  cout << dp[n-1] << endl;
  
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  string T[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  for(int i = 0; i < 7; ++i){
    if(T[i] == s){
      cout << 7-i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;
long long n,a[100],ans=1;
string s;
int main(){
	cin>>n>>s;
	for (int i=0;i<n;i++) a[s[i]-'a']++;
	for (int i=0;i<26;i++) if (a[i]!=0) ans=ans*(a[i]+1)%(long long)(1e9+7);
	cout<<ans-1<<endl;
	return 0;
}

Measured memory_bytes: 512
def choco(h, w):

    ans = [(h % 3 != 0) * w,
           (h - (h // 3)) * (w // 2 + (w % 2 != 0)) - min( (h // 3) * w, (h - (h // 3)) * (w // 2) ),
           (h // 3  + 1) * w - (h - (h // 3 + 1)) * (w // 2)]
    return(min(ans))
    
h, w = [int(i) for i in input().split()]   
print(min(choco(h, w), choco(w, h)))

Measured memory_bytes: 3064
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007
"""
#N,K,Mが入力
    n,k,m=LI() 
    #N
    #x1 y1
    #.  .
    #xn ynが入力
    N=I()
    p=LIR(N)
    print(n,k,m,p)
"""
def resolve():
    n=I()
    a=LI()

    numc=1
    breakc=0
    
    for i in range(n):
        if a[i]==numc:
            numc+=1
        else:
            breakc+=1
    if numc==1:
        print(-1)
    else:
        print(breakc)

    return

import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """3
2 1 2"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """3
2 2 2"""
        output = """-1"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """10
3 1 4 1 5 9 2 6 5 3"""
        output = """7"""
        self.assertIO(input, output)
    def test_入力例_4(self):
        input = """1
1"""
        output = """0"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Measured memory_bytes: 82688
MODE = "stdio"
require 'matrix'
line = Array.new

if(defined? MODE)
  line = STDIN.read.split("\n")
else
  tmp = "\
  vanceknowledgetoad
  advanced
  ".split("\n")
  tmp.each{|s|
    line << s.strip
  }
end


s = line[0]*2

if s.include?(line[1])
  puts "Yes"
else
  puts "No" 
end

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {
int a,b,c;
cin >> a >>  b >> c ;
if(a != b && a != c ) cout << a << endl;
else if(a != b && a ==c ) cout << b << endl;
else cout << c << endl;
    
}


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

using namespace std;
const double pi=acos(-1.0);
const double eps=1e-9;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define re return
#define vi vector <int> 
#define pii pair <int,int>
#define pll pair <long long , long long>
typedef long long ll;

string s;

int main()
{
	//ios:: sync_with_stdio(false);
	cin >> s;
	for(int i=0;i<4;i++)
		cout << s[i];
	cout << " ";
	for(int i=4;i<12;i++)
		cout << s[i];
	cout << endl;
	return 0;
}

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

using namespace std;

const long long mod = 1e9 + 7;

struct fact {
	long long val;
	int deg;
};

long long Bin(long long a, int n) {
	if (n == 0) return 1;
	long long l = Bin(a, n / 2);
	l = l * l % mod * ((n % 2 == 1) ? a : 1LL) % mod;
	return l;
}

long long rev(long long a) {
	return (Bin(a, mod - 2));
}

vector < long long > sim;

void Make_sim(long long n) {
	sim.push_back(2);
	for (long long i = 3; i <= n; i += 2) {
		bool f = true;
		for (int j = 0; sim[j] * sim[j] <= i && f; j++)
			if (i % sim[j] == 0) f = false;
		if (f) sim.push_back(i);
	}
}

int find(int a) {
	int l = 0, r = sim.size(), m;
	while (r - l > 1) {
		m = (l + r) / 2;
		if (sim[m] <= (long long)a) l = m; else r = m;
	}
	return l;
}

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector < long long > v(n);
	long long maxv = 0;
	for (int i = 0; i < n; i++)
		cin>>v[i], maxv = max(maxv, v[i]);
	
	Make_sim(maxv);
	
	/*for (int i = 0; i < sim.size(); i++)
		cout<<sim[i]<<" ";
	cout<<endl;*/
	
	vector < long long > deg(sim.size());
	
	for (int i = 0; i < n; i++) {
		long long cop = v[i];
		long long curr;
		for (int j = 0; j < sim.size() && cop > 1 && sim[j] * sim[j] <= v[i]; j++) {
			if (cop % sim[j] != 0) continue;
			curr = 0;
			while (cop % sim[j] == 0) {
				curr++;
				cop /= sim[j];
			}
			if (deg[j] < curr) deg[j] = curr;
		}
		if (cop > 1) {
			int l = find(cop);
			deg[l] = max(deg[l], 1LL);
		}
	}
	
	/*for (int i = 0; i < deg.size(); i++)
		cout<<deg[i]<<" ";
	cout<<endl;*/
	
	//cout<<"simple\n";
	
	long long lcm = 1;
	for (int i = 0; i < deg.size(); i++) {
		if (deg[i] == 0) continue;
		long long val = Bin(sim[i], deg[i]);
		lcm = lcm * val % mod;
	}
	
	//cout<<"lcm = "<<lcm<<endl;
	
	long long res = 0;
	for (int i = 0; i < n; i++) {
		res += lcm * rev(v[i]) % mod;
		res %= mod;
		//cout<<"i res "<<i<<" "<<res<<endl;
	}
	cout<<res;
}


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

int main(){
  long long n;
  cin >> n;
 
  string s;
  cin >> s;
  long long r=0,g=0,b=0;

  for(int i=0;i<n;i++){
    if(s[i] == 'R')r++;
    if(s[i] == 'G')g++;
    if(s[i] == 'B')b++;
  }

  int cnt = 0;
  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      int k = j+(j-i);
      if(k>=n)break;
      if(s[i] != s[j] && s[j] != s[k] && s[k] != s[i])cnt++;
    }
  }
  cout << r*g*b - cnt << endl;
  
  return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=2e5+10;
#define fi first
#define se second
#define pb push_back
int main() {
    ios::sync_with_stdio(false);
    string a,b;
    cin>>a>>b;
    cout<<b<<a;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <sstream>

using namespace std;

int main()
{
	long long n,m,k;

	cin >> n >> m >> k;

	if (n + m + k > 21)
		cout << "bust" << endl;
	else
		cout << "win" << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

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

	for i := 1; i <= a*b; i++ {
		if i*a%b == c {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
}


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

int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  if(!(a[0] == a[1] && a[1] == a[2]) && (a[0] == a[1] || a[1] == a[2])) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}


Measured memory_bytes: 3612
import java.util.Scanner;
import java.io.*;

public class Main{
	public static void main(String[] args) throws IOException{
		Scanner stdIn = null;
		int rect = 0;
		int rhomb = 0;
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
			while( stdIn.hasNext() ){
				String str = stdIn.next();
				String[] data;
				data = str.split(",");
				int[] s = new int[data.length];
				for(int i = 0; i < 3; i++){
					s[i] = Integer.parseInt(data[i]);
				}
				if( s[0] == s[1] ){
					rhomb++;
				}
				if( s[0]*s[0] + s[1]*s[1] == s[2]*s[2] ){
					rect++;
				}
			}
			System.out.println(rect);
			System.out.println(rhomb);
		} finally {
			if( stdIn != null ){
				stdIn.close();
			}
		}
	}
}

Measured memory_bytes: 12000
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] a = new int [3];
		int[] b = new int [3];

		for(int i = 0;i<3;i++) {
			a[i] = Integer.parseInt(sc.next());
			b[i] = Integer.parseInt(sc.next());
		}
		sc.close();
		int[] cnt = new int [4];
		for(int i = 0;i<3;i++) {
			cnt[a[i]-1] ++;
			cnt[b[i]-1] ++;
		}
		Arrays.sort(cnt);
		String res = "NO";
		if(cnt[3] < 3) {
			res = "YES";
		}
		System.out.println(res);
	}

}


Measured memory_bytes: 22868
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <fstream>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
typedef long long ll;

#define INF 1000000000
#define MAX 100000

bool isprime[MAX];
vector<int> primes;

void make_list(){
    fill(isprime, isprime+MAX, true);
    isprime[0]=isprime[1]=false;
    for(int i=2; i<=MAX/2; i++){
        if(isprime[i]){
            for(int j=i*2; j<=MAX; j+=i) isprime[j]=false;
            primes.pb(i);
        }
    }
}

int main(){
    make_list();
    int m,a,b;
    int n=primes.size();
    while(cin>>m>>a>>b, m|a|b){
        bool flg=true;
        int p,q;
        while(flg){
            rep(i,n){
                if(m <= primes[i]) continue;
                if( m%primes[i]==0 && isprime[m/primes[i]]==true ){
                    p = primes[i];
                    q = m/primes[i];
                    if(p>q) swap(p,q);
                    if(a*q>b*p) continue;
                    flg=false;
                    break;
                }
            }
            m--;
        }
        cout<<p<<" "<<q<<endl;
    }

    return 0;
}

Measured memory_bytes: 1368
// This template code suggested by KT BYTE Computer Science Academy
//   for use in reading and writing files for USACO problems.

// https://content.ktbyte.com/problem.java

import java.util.*;
import java.io.*;

public class Main {

    static StreamTokenizer in;

    static int nextInt() throws IOException {
        in.nextToken();
        return (int) in.nval;
    }

    public static void main(String[] args) throws Exception {
        in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

        int n = nextInt();
        int w = nextInt();

        Item[] items = new Item[n];

        for (int i = 0; i < n; i++) {
            items[i] = new Item(nextInt(), nextInt());
        }

        long[][] dp = new long[w + 1][n+1];

        for (int i = 1; i <= w; i++) {
            for (int j = 1; j <= n; j++) {
                dp[i][j] = dp[i][j-1];
                if (i - items[j-1].weight < 0) continue;
                dp[i][j] = Math.max(dp[i][j], dp[i - items[j-1].weight][j-1] + items[j-1].value);
            }
        }

        long result = 0;

        for (int i = 0; i <= w; i++) {
            result = Math.max(result, dp[i][n]);
        }

        out.println(result);

        out.close();
    }

    static class Item {
        int weight, value;

        Item(int weight, int value) {
            this.weight = weight;
            this.value = value;
        }
    }
}




Measured memory_bytes: 141644
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
signed main()
{
    IOS
    int a; cin>>a;
    string str; cin>>str;
    if(a>=3200) cout<<str;
    else cout<<"red";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
#define INF 1000000000000000000
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define mk make_pair
#define en endl
#define RE return 0
#define int ll
#define P pair<int,int>
using namespace std;
int dx[5]={1,0,-1,0,0},dy[5]={0,1,0,-1,0};
int gcd(int a,int b){if(a%b==0){return b;}else return gcd(b,a%b);}
int lcm(int a,int b){if(a==0){return b;} return a/gcd(a,b)*b;}

signed main(){
	int n; cin>>n;
	int maxl=-1;
	int sum=0;
	for(int i=0; i<n; i++){
		int a; cin>>a;
		maxl=max(maxl, a);
		sum+=a;
	}
	cout<<sum-(maxl/2)<<en;
}






Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias TOWN = Tuple!(long, "x", long, "y");

void main()
{
    auto n = lread();
    auto towns = new TOWN[](n);
    foreach (i; iota(n))
    {
        long x, y;
        scan(x, y);
        towns[i] = TOWN(x, y);
    }
    long cnt;
    double ave_dist = 0;
    foreach (e; towns.permutations())
    {
        cnt++;
        double dist = 0;
        foreach (i; iota(n - 1))
        {
            dist += sqrt(cast(real)(e[i + 1].x - e[i].x) ^^ 2 + (e[i + 1].y - e[i].y) ^^ 2);
        }
        ave_dist += dist;
    }
    writefln("%10.10s",ave_dist / cnt);
}

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 256
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 0, mod = (int) 0;

int main() {
	string s;
	cin >> s;
	string t = "";
	vector<int> p;
	int n = (int) s.size();
	p.push_back(-1);
	for (int j = 0; j < n; ++j) {
		if (s[j] != 'x') {
			t += s[j];	
			p.push_back(j);
		}
	}
	p.push_back(n);
	int m = (int) t.size(), res = 0;
	for (int j = 0; j < m; ++j) {
		if (t[j] != t[m - j - 1]) {
			cout << -1 << endl;
			return 0;
		}
	}
	m = (int) p.size();
	vector<int> cnt0, cnt1;
	for (int j = 0; j < m / 2 - ((m & 1) ^ 1); ++j) {
		cnt0.push_back(p[j + 1] - p[j] - 1);
	}
	for (int j = m - 1; j >= m - (m / 2 - ((m & 1) ^ 1)); --j) {
		cnt1.push_back(p[j] - p[j - 1] - 1);	
	}
	for (int j = 0; j < (int) cnt0.size(); ++j) {
		res += abs(cnt0[j] - cnt1[j]);
	}
	cout << res << endl;
	
	
}





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

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

 int main(){

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

  swap(a,b);
  swap(a,c);

  cout<<a<<" "<<b<<" "<<c<<endl;

 return 0;
 }

Measured memory_bytes: 3592
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Numerics;

namespace Local
{
  public class Solver
  {

    static void Main(string[] args) {
      var s = Console.ReadLine();
      
      char c = (char)(s[0] + 1);

      Console.WriteLine(c);
    }
  }

}


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

using namespace std;

typedef long long ll;

int main(){
    ll N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    ll latest = 1;
    ll broke = 0;
    bool match = false;
    for (ll a : A) {
        if(a == latest) latest++;
        else broke++;
        if(!match && a == 1) match = true;
    }

    if(match) cout << broke << endl;
    else cout << "-1" << endl;

    return 0;
}


Measured memory_bytes: 1152
from sys import stdin, stdout  
  
def main(): 
	#N = int(stdin.readline().rstrip())
	#for tc in range(N):
	h1, m1, h2, m2, k  = [int(x) for x in stdin.readline().split()]
	
	totalMin = (((h2 - h1) * 60 ) - m1) + m2
	ans = totalMin - k
	stdout.write(str(ans)+'\n')

if __name__ == "__main__": 
	main()

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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

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

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

  int N; cin >> N;
  set<int> A;
  int a;
  rep(i, 0, N) {
    cin >> a;
    A.insert(a);
  }

  if (A.size() == N) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
};


Measured memory_bytes: 9600
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cerrno>
#include<clocale>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<vector>
#include<cwchar>
#include<cwctype>
#define int long long
#define inf 1e17
using namespace std;
map<string,int>q;
int n;
string s;
signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		q[s]++;
	}
	printf("AC x %lld\n",q["AC"]);
	printf("WA x %lld\n",q["WA"]);
	printf("TLE x %lld\n",q["TLE"]);
	printf("RE x %lld\n",q["RE"]);
	return 0;
}

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

int main(void){
	int H,W;
	while(1){
		cin>>H>>W;
		if(H==0&&W==0)return 0;
		for(int i=0;i<H;i++){
			cout<<'#';
			for(int j=0;j<W-2;j++){
				if(i==0||i==H-1)cout<<'#';
				else cout<<'.';
			}
			cout<<'#';
			cout<<endl;
		}
		cout<<endl;
	}
}


Measured memory_bytes: 3072
n, k = (int(x) for x in input().split())

li = []
for i in range(n):
    li.append(0)

for i in range(k):
    d = int(input())
    a = input().split(" ")
    for num in a:
        li[int(num) - 1] = 1

cnt = 0
for i in li:
    if i == 0:
        cnt += 1

print(cnt)

Measured memory_bytes: 9196
def selectionSort(a,n):
    count = 0
    for i in range(n):
        minj = i
        for j in range(i, n):
            if(a[j] < a[minj]):
                minj = j
        if(minj != i):
            count += 1
        a[i], a[minj] = a[minj], a[i]
    return [a, count]
n = int(input())
a = list(map(int,input().split(' ')))
sa , c = selectionSort(a, n)
str = " ".join([str(i) for i in sa])
print("{}\n{}".format(str,c))


Measured memory_bytes: 5608
Q = 10**9+7

def getInv(N):#Qはmod
    inv = [0] * (N + 1)
    inv[0] = 1
    inv[1] = 1
    for i in range(2, N + 1):
        inv[i] = (-(Q // i) * inv[Q%i]) % Q
    return inv

def getFactorialInv(N):
    inv = [0] * (N + 1)
    inv[0] = 1
    inv[1] = 1
    ret = [1]*(N+1)
    for i in range(2, N + 1):
        inv[i] = (-(Q // i) * inv[Q%i]) % Q
        ret[i] = ret[i-1]*inv[i]
    return ret

def getFactorial(N):
    ret = [1]*(N+1)
    for i in range(2,N+1):
        ret[i] = ret[i-1]*i%Q
    return ret

modFact = getFactorial(2000)
modInvFact = getFactorialInv(2000)
N, K = map( int, input().split())
for i in range(1, K+1):
    if N-K+1 < i:
        print(0)
        continue
    ans = modFact[N-K+1]*modInvFact[i]%Q*modInvFact[N-K+1-i]%Q*modFact[K-1]%Q*modInvFact[K-i]%Q*modInvFact[i-1]%Q
    ans %= Q
    print(ans)


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

char S[200000][12];

int comp(const void* a, const void* b){
    return strcmp(a, b);
}

int main(void){
    int N;
    int i;
    scanf("%d", &N);
    for(i=0;i<N;i++){
        scanf("%11s", S[i]);
    }

    qsort(S, N, sizeof(*S), comp);

    int ans = 1;
    for(i=1;i<N;i++){
        if(strcmp(S[i-1], S[i]) != 0){
            ans++;
        }
    }
    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 6272
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int a, b;
  cin >> a >> b;
  if(a < b){
  	for(int i = 0 ; i < b ; i ++){
    	cout << a;
    }
  }
  else{
  	for(int i = 0 ; i < a ; i++){
    	cout << b;
    }
  }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

S = input().strip()

for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == "L":
            print("No")
            sys.exit()
    else:
        if S[i] == "R":
            print("No")
            sys.exit()

print("Yes")

Measured memory_bytes: 3060
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun solve() {
    val (N, K) = rd.readIntArray()
    val P = rd.readIntArray().map{ it-1 }
    val C = rd.readLongArray()

    var ans = -LINF
    for (i in 0 until N) {
        var pos = i
        val cs = ArrayList<Long>()
        while (true) {
            pos = P[pos]
            cs.add(C[pos])
            if (pos == i) break
        }

        val ln = cs.size
        val cycleSum = cs.sum()
        var sum = 0L
        for (j in 0 until ln) {
            sum += cs[j]
            if (j+1 > K) break
            var scr = sum
            if (cycleSum>0) {
                val loopNum = (K - (j+1))/ln
                scr += cycleSum*loopNum
            }
            ans = max(ans, scr)
        }
    }

    println(ans)
}


//val rd = debug.Reader("abc", "175", "d", "sample-1")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!!
    } catch (e: Exception) { throw e }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}
data class IntPair(val first: Int, val second: Int); data class LongPair(val first: Long, val second: Long)
data class To(val idx: Int, val cost: Long)
fun <T>edge(V: Int): Array<ArrayList<T>> { return Array(V){ArrayList<T>()} }
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
}


Measured memory_bytes: 57944
#include<iostream>
using namespace std;
int main()
{

  int N,M,sub,d=-1,c=0;
  cin>>N>>M;
  int b;
  for(int i=0; i<M; i++)
  {
      scanf("%d",&b);
      c=b+c;
  }
  sub=N-c;
if(sub>=0)
  {
      cout<<sub<<endl;
  }
  else
  {
      cout<<d<<endl;
  }



}


Measured memory_bytes: 3800