akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n;
    cin >> n;
    vector<vector<ll>> G(n);
    rep(i, n) {
        ll u, k;
        cin >> u >> k;
        u--;
        rep(j, k) {
            ll v;
            cin >> v;
            v--;
            G[u].emplace_back(v);
        }
    }
    vector<ll> dist(n, -1);
    dist[0] = 0;

    queue<ll> que;
    que.push(0);

    while(!que.empty()) {
        auto v = que.front();
        que.pop();

        for(auto nv : G[v]) {
            if (dist[nv] != -1) continue;
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }
    rep(i, n) cout << i+1 << " " << dist[i] << endl;
}



Measured memory_bytes: 3144
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

int main()
{
	int n;s(n);
	string str;
	cin>>str;
	vector<int> pre,suf;
	pre.push_back(0);
	suf.push_back(0);
	int one1 = 0 , one2 = 0;
	for(int i = 0;i<n;i++)
	{
		if(str[i] == 'R')	one1++;
		if(str[n-i-1] == 'R') one2++;
		
		pre.push_back(one1);
		suf.push_back(one2);
	}
	
	int mini = INF;
	
	for(int i = 0;i<=n;i++)
	{
		int val = max(i - pre[i] , suf[n-i]);
		mini = min(mini , val);
	}
	
	cout<<mini<<endl;
	return 0;
}

Measured memory_bytes: 5444
#include <stdio.h>
#include <string.h>
#define N  4
int main(){
  const char abc[N] = "ABC";
  const char arc[N] = "ARC";
	char s[N];
  scanf("%s", s);
  if(strcmp(abc, s) == 0){
    puts("ARC");
  }else if(strcmp(arc, s) == 0){
    puts("ABC");
  }

  return 0;
}

Measured memory_bytes: 2064
#include<stdio.h>
int main()
{
    int i,j,max;
    int a[10]={0};
    for(i=0;i<10;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<3;i++)
    {
        max=a[i];
        for(j=i;j<10;j++)
        {
            if(a[j]>max){max=a[j];a[j]=a[i];a[i]=max;}
        }
    }
    printf("%d\n%d\n%d\n",a[0],a[1],a[2]);
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 
  char a, b;
  cin >> a >> b;
  
  if(a == 'H') cout << b;
	else {
    	if(b == 'H') cout << 'D' << endl;
      else cout << 'H' << endl;
    }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
##############################

N = int(input())
A = list(map(int, input().split()))

ans = INF
for i in range(min(A), max(A)+1):
    x = 0
    for j in range(N):
        x += (A[j]-i)**2

    ans = min(ans, x)

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> c(n-1), s(n-1), f(n-1);
    for (int i = 0; i < n - 1; i++) {
        cin >> c[i] >> s[i] >> f[i];
    }
    for (int i = 0; i < n; i++) {
        if (i < n - 1) {
            int t = s[i];
            t += c[i];
            for (int j = i + 1; j < n - 1; j++) {
                if (t <= s[j])
                    t = s[j];
                else
                    if (t % f[j] != 0)
                        t = (t/f[j] + 1)*f[j];
                t += c[j];
            }
            cout << t << endl;
        } else  {
            cout << 0 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int i,q,H,W;
    while(1){
        scanf("%d %d",&H,&W);
        if(!(H&&W)){
            break;
        }
        for(i=0;i<H;i++){
            for(q=0;q<W;q++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define f first
#define s second
#define sz(x) (ll)x.size()
#define lnt(s) (ll)s.length()
#define mt(cnt) cnt.empty()
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> osSet;

using pll = pair<ll, ll>;
using pl = pair<ll, pll>;
using tll = tuple<ll, ll, ll>;

const ll maxN = 1e5;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

ll func(ll x){
	return (x*(x+1))/2;
}

ll _pow(ll b, ll p){
	if(p == 0) return 1;
	if(p == 1) return b;
	ll exB = b*b;
	if(p&1) return b*_pow(exB, p/2);
	return _pow(exB, p/2);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll n;
	string s;
	cin >> n >> s;
	ll l=0, r=lnt(s)-1;
	ll ans = 0;
	while(l<r){
		if(s[l] == 'W' and s[r] == 'R'){
			ans++;
			l++;
			r--;
		}
		while(s[r] != 'R' and l<r)
			r--;
		while(s[l] != 'W' and l<r)
			l++;
	}
	cout << ans;
	return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	int abm=1e9,mc=0;
	vector<int>a(n);
	int64_t ans=0;
	for(auto&&i:a){
		cin>>i;
		mc+=(i<0);
		i=abs(i);
		ans+=i;
		abm=min(abm,i);
	}
	cout<<(mc&1?ans-abm*2:ans)<<"\n"s;
}


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

#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;

typedef pair<int, int> P;
typedef vector<int> vi;

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

int n;
vi a, b;

void solve() {
  cin >> n;
  a.resize(n + 1);
  b.resize(n);
  rep(i, 0, n + 1) cin >> a[i];
  rep(i, 0, n) cin >> b[i];

  int ans = 0;
  rep(i, 0, n) {
    if (a[i] >= b[i]) {
      a[i] -= b[i];
      ans += b[i];
    } else {
      ans += a[i];
      b[i] -= a[i];
      a[i] = 0;
      if (a[i + 1] >= b[i]) {
        a[i + 1] -= b[i];
        ans += b[i];
      } else {
        ans += a[i + 1];
        a[i + 1] = 0;
      }
    }
  }
  cout << ans << endl;
}

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

  // cout << fixed << setprecision(10);

  solve();

  return 0;
}


Measured memory_bytes: 1792
using System;

public class Hello
{
    public static void Main()
    {
        var s1 = Console.ReadLine().Trim();
        var s2 = Console.ReadLine().Trim();
        var s3 = Console.ReadLine().Trim();
        var a = new char[3];
        a[0] = s1[0];  a[1] = s2[1]; a[2] = s3[2];
        Console.WriteLine(new string(a));
    }
}

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

int main() {
  ll n,m;
  cin >> n >> m;
  
  vector<ll>a(n),b(n),c(m),d(m);
  for(int i=0; i<n; i++) cin >> a[i] >> b[i];
  for(int j=0; j<m; j++) cin >> c[j] >> d[j];
  
  for(int i=0; i<n; i++){
    ll mini=10e9;
    ll place;
   for(int j=0; j<m; j++ ){
     ll x = pow(pow(c[j]-a[i],2),0.5)+pow(pow(d[j]-b[i],2),0.5);
     if(x<mini){
       mini = min(mini,x);
       place=j+1;
     }
   }
    cout << place << endl;
  }

}


Measured memory_bytes: 256
w = int(input())
n = int(input())
a = range(w)
a = list(a)
for i in range(n):
    p, q = map(int, input().split(","))
    t = a[p - 1]
    a[p - 1] = a[q - 1]
    a[q - 1] = t
for each in a:
    print(each + 1)


Measured memory_bytes: 5592
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int ma=max(a,b);
    if(c%ma==0)
        printf("%d\n",c/ma);
    else
        printf("%d\n",c/ma+1);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for (ll i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;

long long pow_mod(long long n, long long k, long long mod) {
    long long ret = 1, a = n % mod;
    while (k > 0) {
        if (k & 1) ret = (ret * a) % mod;
        a = (a * a) % mod;
        k >>= 1;
    }
    return ret;
}

long long inv_mod(long long n, long long mod) {
    long long a = n % mod, b = mod - 2, ret = 1;
    while (b > 0) {
        if (b & 1) ret = (ret * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ret;
}

const ll MOD = 1000000007LL;
ll N,Q;
ll A[3010];
ll X[3010];
ll Y[3010];

ll dp[3010][3010];

int main ()
{
    cin >> N >> Q;
    REP(i,N) cin >> A[i + 1];
    REP(i,Q) cin >> X[i] >> Y[i];

    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            dp[i][j] = (A[i] > A[j]);
        }
    }

    ll inv2 = inv_mod(2LL, MOD);
    for (int i = 0; i < Q; i++) {
        dp[X[i]][Y[i]] = dp[Y[i]][X[i]] = ((dp[X[i]][Y[i]] + dp[Y[i]][X[i]]) * inv2) % MOD;
        for (int j = 1; j <= N; j++) {
            if (X[i] != j && Y[i] != j) {
                dp[X[i]][j] = dp[Y[i]][j] = ((dp[X[i]][j] + dp[Y[i]][j]) * inv2) % MOD;
                dp[j][X[i]] = dp[j][Y[i]] = ((dp[j][X[i]] + dp[j][Y[i]]) * inv2) % MOD;
            }
        }
    }

    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        for (int j = i; j <= N; j++) {
            ans += dp[i][j];
            ans %= MOD;
        }
    }

    cout << (ans * pow_mod(2LL, Q, MOD)) % MOD << endl;

    return 0;
}


Measured memory_bytes: 70912
/*

Code for problem  by cookiedoth
Generated 28 Jun 2020 at 03.06 PM


   ,##.                   ,==.
 ,#    #.                 \ o ',
#        #     _     _     \    \
#        #    (_)   (_)    /    ; 
 `#    #'                 /   .'  
   `##'                   "=="

z_z
=_=
¯\_(ツ)_/¯

*/

#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <complex>
#include <cassert>
#include <random>
#include <cstring>
#include <numeric>
#define ll long long
#define ld long double
#define null NULL
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define debug(a) cerr << #a << " = " << a << endl
#define forn(i, n) for (int i = 0; i < n; ++i)
#define sz(a) (int)a.size()

using namespace std;

template<class T> int chkmax(T &a, T b) {
	if (b > a) {
		a = b;
		return 1;
	}
	return 0;
}

template<class T> int chkmin(T &a, T b) {
	if (b < a) {
		a = b;
		return 1;
	}
	return 0;
}

template<class iterator> void output(iterator begin, iterator end, ostream& out = cerr) {
	while (begin != end) {
		out << (*begin) << " ";
		begin++;
	}
	out << endl;
}

template<class T> void output(T x, ostream& out = cerr) {
	output(x.begin(), x.end(), out);
}

void fast_io() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

const int K = 26;
const int MAX_D = 365;
int D, c[K], s[MAX_D][K];

void read() {
	cin >> D;
	for (int i = 0; i < K; ++i) {
		cin >> c[i];
	}
	for (int i = 0; i < D; ++i) {
		for (int j = 0; j < K; ++j) {
			cin >> s[i][j];
		}
	}
}

int t[MAX_D];

void read_t() {
	for (int i = 0; i < D; ++i) {
		cin >> t[i];
		t[i]--;
	}
}

int lst[K];

void solveB() {
	fill(lst, lst + K, -1);
	int sat = 0;
	for (int i = 0; i < D; ++i) {
		sat += s[i][t[i]];
		lst[t[i]] = i;
		for (int j = 0; j < K; ++j) {
			sat -= c[j] * (i - lst[j]);
		}
		cout << sat << "\n";
	}
}

signed main() {
	fast_io();
	read();
	read_t();
	solveB();
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  int N; cin >>N;
  string a,b,c; cin>>a>>b>>c;
  int count = 0;
  REP(i,N){
    char d[3] = {a[i],b[i],c[i]};
    sort(d,d+3);
    if(d[0]!=d[2]){
      if(d[0]==d[1] || d[1]==d[2]){ ++count;}
      else{ count += 2;}
    }
  }
  cout << count<<"\n";
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  string A,B;
  cin >> A >> B;
  string ans = "H";
  if(A=="H" && B=="D") ans="D";
  if(A=="D" && B=="H") ans="D";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int
const int mod = (int)1e9 + 7;
int pre[401][401] = {0};
//int dp[401][401] = {0};
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    for(int p = 0; p <= 400; p++){
        for(int val =1; val <= 400; val++){
            if(p == 0)pre[p][val] = 1;
            else pre[p][val] = pre[p-1][val] * val;
            pre[p][val] %= mod;
        }
    }
    for(int p  =0; p <= 400; p++){
        int sum =0;
        for(int val = 1; val <= 400;val++){
            pre[p][val] = pre[p][val]+ pre[p][val -1];
            pre[p][val] %= mod;
        }
    }

    int n;cin >> n;
    int c;cin >>c;
    vi a(n), b(n);
    FOR(i, n)cin >> a[i];
    FOR(i, n)cin >> b[i];
    vi prev(c+ 1, 0);
    prev[0] = 1;
    vi dp(c+1, 0);
    for(int i = 0; i < n; i++){
        for(int cons = 0; cons <= c; cons++){
            dp[cons] = 0;
            for(int given = 0; given <= cons; given++){
                dp[cons] += prev[cons-given]*(pre[given][b[i]] - pre[given][a[i] -1]);
                dp[cons] %= mod;
            }
//            cout << dp[cons] << " ";
        }
 //       cout << endl;
        swap(dp, prev);
    }
    prev[c] %= mod;
    while(prev[c] < 0)prev[c] += mod;
    cout << prev[c];
}




Measured memory_bytes: 1536
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using namespace std;
//LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }
//max_element

int N;
int A[100010];
int O[100010];
int M[100010];
int B[100010];

signed main()
{
	cin >> N;
	REP(i, N + 1)
	{
		cin >> A[i];
	}

	if (N == 0)
	{
		if (A[0] == 1)
		{
			cout << 1 << endl;
		}
		else if (A[0] == 0)
		{
			cout << -1 << endl;
		}
		else
		{
			cout << -1 << endl;
		}
		return 0;
	}

	O[0] = 1 - A[0];
	if (O[0] < 0)
	{
		cout << -1 << endl;
		return 0;
	}

	for (int i = 1; i <= N; i++)
	{
		O[i] = O[i - 1] * 2 - A[i];
		if (O[i] < 0)
		{
			cout << -1 << endl;
			return 0;
		}
		O[i] = min(LLONG_MAX / 2, O[i]);
	}

	O[N] = A[N];
	M[N] = A[N];

	for (int i = 0; i < N; i++)
	{
		M[i] = O[i] + A[i];
	}

	B[N] = A[N];
	for (int i = N - 1; i >= 0; i--)
	{
		B[i] = B[i + 1] + A[i];
		B[i] = min(M[i], B[i]);
	}

	int ans = 0;
	for (int i = 0; i <= N; i++)
	{
		ans += B[i];
	}
	cout << ans << endl;
}




Measured memory_bytes: 6756
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	var v = make([]int, n)
	var c = 0
	for i := 0; i < n; i++ {
		fmt.Scan(&v[i])
		if v[i] == c+1 {
			c++
		}
	}
	if c == 0 {
		fmt.Println(-1)
		return
	}
	fmt.Println(n - c)
}

Measured memory_bytes: 7464
/* チェビシェフの定理の確認 */
#include <stdio.h>
#define MAX_PRIME_AMOUNT 70000 // 最大の素数の個数
#define MAX 123456 // 入力される値の上限

void get_primes(int*, int); // 指定された上限までの素数を全て求めて配列に格納

int main(void) {
  int primes[MAX_PRIME_AMOUNT]; // 素数の配列
  int n, i;
  int count; // nから2nまでにある素数の個数
  
  get_primes(primes, MAX*2); // MAX*2までの素数をすべて求める
  
  while (scanf("%d", &n) != EOF) { // nに数値を読み込んで
    

    if (n == 0) // nが0なら終了
      break;
    
    count = 0;
    for (i=0; primes[i] <= 2*n; i++) { // 素数がn*2を越えない間
      if (primes[i] > n) // n<p<=2nだったら
	count++; // 個数をカウント（インクリメント）
    }
    
    printf("%d\n", count); // 個数を表示
  }

  return 0;
}


/* 2からmaxまでの素数をすべて求めて配列primeに格納 */
void get_primes(int *prime, int max) {
  int n, i;
  int prime_amount; // 現在求めた素数の個数
 
  prime[0] = 2; // 一番初めの素数は2
  prime_amount = 1; 
  for (n=3; n<=max; n++) { // nが素数かどうか調べる
    for (i=0; i<prime_amount; i++) { // 現在求めた素数で
      if (n % prime[i] == 0) // nがわり切れるかどうか調べる
	break;
    }

    /* もし、現在求めた素数でnが全て割り切れなかったら、nは素数 */
    if (i == prime_amount) { // iがprime_amountと等しかったら、最後までnは割り切れなかったので
      prime[prime_amount] = n; // nは新たな素数
      prime_amount++; // 個数をひとつ増やす
    }
  }

}
	 

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

lli funFrogJump(lli n,lli k,lli *dp,lli *values){
	if(n==0||n==1){
		dp[n] = 0;
		return 0;
	}
	if(n==2){
		dp[n] = abs(values[n-1]-values[n-2]);
		return dp[n];
	}
	if(dp[n]!=-1) return dp[n];
	lli minNum = INT_MAX;
	for(lli i=1;i<=k;i++){
		if(n-i-1>=0) minNum = min(minNum,funFrogJump(n-i,k,dp,values)+abs(values[n-1]-values[n-i-1]));
	}
	dp[n] = minNum;
	return dp[n];
}

int main(){
	lli n,k;
	cin>>n>>k;
	lli a[n];
	for(lli i=0;i<n;i++) cin>>a[i];
	lli dp[n+1];
	for(lli i=0;i<=n;i++) dp[i] = -1;
	cout<<funFrogJump(n,k,dp,a)<<endl;
	return 0;
}

Measured memory_bytes: 9600
# include <bits/stdc++.h>
 
using namespace std;
 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i; ris; }
    eni(==) ris << range(begin(i), end(i)); }
    sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
    }
    sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
    }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
# define forn(i, n) for (ll i = 0; i < int(n); i++)
# define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
# define all(V) V.begin(), V.end()
# define rall(V) V.rbegin(), V.rend()
# define len(V) (int)V.size()
# define ll long long
# define ld long double
# define ff first
# define ss second
# define pb push_back
# define mp make_pair
# define endl '\n'
# define M_PI 3.14159265358979323846
 
void solve()
{
        ll n, m, x; cin >> n >> m >> x;
        vector<int> a(m);
        forn(i, m) cin >> a[i];
        ll l = 0, r = 0;
        for(int i = 0; i < m; ++i)
        {
                if(a[i] < x) l++;
                else r++;
        }
        cout << min(l, r);

}
 
int main()
{
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        solve();
}

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

int main(){
    double a, b, c;
    cin>>a >>b >>c;
    c = c*3.1415926535/180;
    printf("%f\n", a*b*sin(c)/2);
    printf("%f\n", a+b+sqrt(a*a+b*b-2*a*b*cos(c)));
    printf("%f\n", b*sin(c));
    return 0;
}



Measured memory_bytes: 3388
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
/*
time:
wa:
反省:
考察:
*/
int main() {
    string s;
    cin >> s;
    int n = s.size();
    if(s[n-1] == 's') s += "es";
    else s += 's';
    cout << s << endl;
    return 0;
}


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

int main() {
  int a; cin >> a; // 入力値ａ
  int b; cin >> b; // 入力値ｂ
  
  int x; x = a*b; // a * b
    
  if ( x % 2 == 0 ) {
    cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }


}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int top,S[1000];
void push(int x){
  S[++top] = x;
}
int pop(){
  top--;
  return S[top+1];
}
int main(){
  int x,a,b,c;
  top=0;
  char s[100];

  while(1){
    if(scanf("%s",s)==EOF){
      break;
    }
    if ( s[0] == '+' ){
      a=pop();
      b=pop();
      push(a+b);
    } else if ( s[0] == '-' ){
      b=pop();
      a=pop();
      push(a-b);
    } else if ( s[0] == '*' ){
      a=pop();
      b=pop();
      push(a*b);
    } else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",pop());
  return 0;
}


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

const int mod=2019;
string s;
int n, suf[200003], ans=0, cnt[2020];

int modpow(int x, int y){
	int ret=1;
	while (y>0){
		if (y&1){
			ret*=x;
			ret%=mod;
		}
		x*=x;
		x%=mod;
		y>>=1;
	}
	return ret;
}

int main(){
	cin >> s;
	memset(suf,0,sizeof suf);
	memset(cnt,0,sizeof cnt);
	n=s.length();
	for(int i=n-1;i>=0;i--){
		suf[i]=(s[i]-'0')*modpow(10,n-1-i);
		suf[i]+=suf[i+1];
		suf[i]%=mod;
	}
	cnt[0]=1;
	for (int i=n-1;i>=0;i--){
		ans+=cnt[suf[i]];
		cnt[suf[i]]++;
	}
	cout << ans << "\n";
}

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

public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArr = br.readLine().split(" ");
		long h = Long.parseLong(strArr[0]);
		long w = Long.parseLong(strArr[1]);
		long surface = h * w;
		long length = (h + w) << 1;
		System.out.printf("%d %d%n", surface, length);
	}
}

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

typedef long long llint;
typedef long double ld;
typedef pair<int,int> P;

#define inf 1e18
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())


priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }



void solve(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>>s(m);
    for(int i=0;i<m;i++){
        int k;
        cin >> k;
        s[i].resize(k);
        for(int j=0;j<k;j++){
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    vector<int>p(m);
    for(int i=0;i<m;i++)cin >> p[i];
    int ans=0;
    for(int bit=0;bit<(1<<n);bit++){
        bool f=true;
        for(int i=0;i<m;i++){
            int c=0;
            for(int d:s[i]){
                if(bit & (1<<d))c++;
            }
            c%=2;
            if(c!=p[i])f=false;
        }
        if(f)ans++;
    }
    cout << ans << endl;
}

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





Measured memory_bytes: 3624
#include <stdio.h>
int main(void){
    int line,i,a,b,c;
    scanf("%d",&line);
    for (i=0;i<line;i++){
        scanf("%d %d %d",&a,&b,&c);
        if((a*a)+(b*b)==(c*c) || (a*a)+(c*c)==(b*b) || (b*b)+(c*c)==(a*a) )
             printf("YES\n");
        else{
            printf("NO\n");
        }
        
    }
}

Measured memory_bytes: 1732
#include <iostream>

using namespace std;

int main() {
  int N; cin >> N;
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    int a, b; cin >> a >> b;
    if (a == b) {
      cnt++;
    } else {
      cnt = 0;
    }
    if (cnt == 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
#define N 1002
int main() {
    char card[N] = "", tmp[N], *p1, *p2 = "";
    int i, h, m, num, j;
    while (1) {
        tmp[0] = '\0';
        scanf("%s", tmp);
        if (strcmp(tmp, "-") == 0) break;
        scanf("%d", &m);
        for (i = 0; i < m; i++) {
            p1 = tmp;
            card[0] = '\0';
            p2 = card;
            scanf("%d", &h);
            strcat(p2, p1 + h);
            *(p1 + h) = '\0';
            strcat(p2, p1);
            *p1 = '\0';
            strcat(tmp, p2);
        }
        printf("%s\n", p2);
    }
    return 0;
}


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

const int MAXN = 1e6+5;
const ll p = 1e9+7;

ll exp(ll x, ll k) {
	if (k == 0)
		return 1;
	if (k%2 == 1)
		return x*exp(x, k-1)%p;
	ll y = exp(x, k/2);
	return y*y%p;
}

ll inv(ll x) { return exp(x, p-2); }

ll fact[MAXN], invfact[MAXN], n;

ll binom(ll a, ll b) {
	if (a < b || a < 0 || b < 0)
		return 0;
	return fact[a]*invfact[b]%p*invfact[a-b]%p;
}

ll s = 0;

int main() {
	cin >> n;
	n--;

	fact[0] = invfact[0] = 1;
	for (int i = 1; i < MAXN; ++i) {
		fact[i] = i*fact[i-1]%p;
		invfact[i] = inv(fact[i])%p;
	}

	for (int k = 1; k <= n; ++k) {
		s += (p + 1 - binom(k-1, n-k)*inv(binom(n, k)));
		s %= p;
	}

	s++;

	for (int i = 1; i <= n; ++i)
		s = s*i%p;
	cout << s << endl;
}


Measured memory_bytes: 15872
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template
vector<vector<int>> G;

class scc_decomposition{
public:
    int V;
    vector<vector<int>> E, rE;
    vector<int> pos, used, cmp;
    scc_decomposition() {}
    scc_decomposition(int v){
        V = v;
        E.resize(v);
        rE.resize(v);
        cmp.resize(v);
        used.resize(v, 0);
    }
    
    void add(int from, int to){
        E[from].push_back(to);
        rE[to].push_back(from);
    }
    
    void dfs(int v){
        used[v] = 1;
        rep(i, E[v].size()){
            if (!used[E[v][i]]) dfs(E[v][i]);
        }
        pos.push_back(v);
    }
    
    void rdfs(int v, int k){
        used[v] = 1;
        cmp[v] = k;
        rep(i, rE[v].size()){
            if (!used[rE[v][i]]) rdfs(rE[v][i], k);
        }
    }
    
    int scc(){
        rep(v, V){
            if (!used[v]) dfs(v);
        }
        used.assign(V, 0);
        int k = 0;
        for (int i = (int)pos.size() - 1; i >= 0; i--) {
            if (!used[pos[i]]) rdfs(pos[i], k++);
        }
        return k; // return the number of sccs
    }
};

scc_decomposition scc;

int dfs(int cur, int par = -1){
    vector<int> tmp;
    for(int a: scc.E[cur]){
        
        if(scc.cmp[a] != scc.cmp[cur]){
            tmp.pb(dfs(a));
        }
    }
    sort(all(tmp));
    rep(i, tmp.size()){
        if(tmp[i] != i){
            return i;
        }
    }
    return (int)tmp.size();
}

bool same(vector<int> &V){
    int a = V[0];
    rep(i, V.size()){
        if(a != V[i]) return false;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    
    scc = scc_decomposition(N);
    rep(i, N){
        int p;
        cin >> p;
        scc.add(p - 1, i);
    }
    scc.scc();
    
    
    vector<vector<int>> A(N);
    rep(i, N){
        A[scc.cmp[i]].pb(i);
    }
    
    vector<int> B;
    rep(i, N){
        if(A[i].size() >= 2) B = A[i];
    }
    
    vector<int> grd(B.size());
    rep(i, B.size()){
        grd[i] = dfs(B[i]);
    }
    
    if(same(grd) && grd.size() % 2 == 1){
        output("IMPOSSIBLE");
    }
    else{
        output("POSSIBLE");
    }
    
    
    
    return 0;
}

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

int main() {
    int n, m, X, Y;
    cin >> n >> m >> X >> Y;
    int x[n];
    rep(i, n) cin >> x[i];
    int y[m];
    rep(i, m) cin >> y[i];
    int xmax = -101;
    rep(i, n) xmax = max(xmax, x[i]);
    int ymin = 101;
    rep(i, m) ymin = min(ymin, y[i]);
    ((ymin <= X) || (xmax >= Y) || (ymin <= xmax)) ? cout << "War" << endl : cout << "No War" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.nextLine());
		int[] a=new int [n+2];
		int sum_yen=0;
		Arrays.fill(a, 0);
		for (int i= 1; i <= n; ++i ){
			a[i] = Integer.parseInt(scan.next());
			sum_yen+=Math.abs(a[i-1]-a[i]);
		}
		sum_yen+=Math.abs(a[n]-a[n+1]);
		int diff;
		int ans;
		for (int i=1;i<n+1;++i){
			diff=Math.abs(a[i-1]-a[i])+Math.abs(a[i]-a[i+1]);
			ans=sum_yen-diff+Math.abs(a[i-1]-a[i+1]);
			System.out.println(ans);
		}





	}
}
//end

Measured memory_bytes: 55876
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll A, B, K; cin >> A >> B >> K;
    ll tmp = A;
    A -= K; if (A < 0) A = 0;
    K -= tmp; if (K < 0) goto END;
    B -= K; if (B < 0) B = 0;
END:
    cout << A << " " << B << endl;
}


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

int main() {
	int H,W; cin>>H>>W;
	vector<int> a(26,0);
	char ch;
	for (int i=0; i<H*W; i++)
		cin>>ch, a[ch-'a']++;
	int one=0,two=0;
	for (int x:a) {
		if(x%4) two++;
		if(x%2) one++;
	}
	int two_max=((H%2)*W+(W%2)*H)/2;
	cout<<(one<=1&&two<=two_max?"Yes":"No")<<"\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int min=0,max=0,x;long sum=0;
        for(int i=0;i<n;i++){
            if(i==0){
                x=sc.nextInt();
                min=x;max=x;sum+=x;continue;
            }
            x=sc.nextInt();
            max=Math.max(max,x);
            min=Math.min(min,x);
            sum+=x;
        }
        System.out.printf("%d %d %d\n",min,max,sum);
    }
}


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

//int arr1[13];

//int arr2[13];

double dist(int x1, int y1, int x2, int y2)
{
    double d = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
    return d;

}



int main()
{
    ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

    int n;

    cin >> n;

    int arr[n];

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

    int arr1[n+9];
    int arr2[n+9];

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



    double sum = 0;

    do
    {
        for(int i=0; i<n-1; i++)
        {
            sum +=  dist(arr1[arr[i]], arr2[arr[i]], arr1[arr[i+1]], arr2[arr[i+1]]);
        }

    }while(next_permutation(arr, arr+n));

    ll fact = 1;

    for(int i=1; i<=n; i++)
    {
        fact *= i;
    }

    //cout << sum << " " << fact << endl;

    double res = sum / fact;

    printf("%.10lf\n", res);


}


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



int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,m,ans=0;
    cin>>n>>m;
    vector<bool>a(n+1);
    vector<int>c(n+1,1);
    a[1]=true;

    rep(i,m){
        int x,y;
        cin>>x>>y;
        c[x]--;
        c[y]++;
        if(a[x])a[y]=true;
        if(c[x]==0)a[x]=false;
    }

    rep(i,n+1)if(a[i])ans++;
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    N = int(readline())
    A = [int(i) for i in readline().split()]
    K = int(1e9)+7
    acum = [0]
    for i  in range(N):
        acum.append(acum[i]+A[i])
    ans = 0
    for i in range(N):
        ans += A[i]*(acum[N]-acum[i+1])
        ans %= K
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 29540
candidates = []

def get_candidate(indices, current, num):
  global candidates

  if len(current) == num:
    candidates.append(current.copy())
    return
  
  for i, v in enumerate(indices):
    current.append(v)
    get_candidate(indices[i+1:], current, num)
    current.pop()
  
n, m, x = list(map(lambda x: int(x), input().split(' ')))
books = []

for i in range(0, n):
  p = list(map(lambda x: int(x), input().split(' ')))
  books.append((p[0], p[1:]))

indices = list(range(0, n))

for i in range(1, n+1):
  get_candidate(indices, [], i)

flag = False
min_price = 1000000000

for c in candidates:
  price = 0
  a = [0] * m
  
  for s in c:
    price += books[s][0]

    for i in range(m):
      a[i] += books[s][1][i]

  for t in a:
    if t < x:
      flag = True
      break

  if flag:
    flag = False
    continue
  
  min_price = min(min_price, price)

if min_price == 1000000000:
  print("-1") 
else:
  print(min_price)

Measured memory_bytes: 72136
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline vector<T> convert_to_binary_number(T x) { vector<T> binary_num; while (x != 1) { binary_num.push_back(x % 2); x /= 2; } binary_num.push_back(1); return binary_num; }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl;}
vector<LL> make_divisors(LL n){vector<LL> divisors;for(int i = 1; i <= sqrt(n); i++) {if(n%i == 0){divisors.push_back(i);if(i != n/i){divisors.push_back(n / i);}}}return divisors;}
const LL MOD = 1e9 + 7;
const LL INF = 1LL << 60;

int main(void){
    LL X;
    cin >> X;

    int t = 0;
    int place = 0;
    while(place < X) {
        t++;
        place += t;
    }
    cout << t << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 50;
ll n, b, r;

int main() {
    cin>>n>>b>>r;
    ll cnt = n % (b + r);
    ll ans = n / (b + r);
    ans = ans * b;
    cnt = min(cnt, b);
    ans = ans + cnt;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
#define db double
#define zero(x) (fabs(x)<eps)
#define sgn(x) (zero(x)?0:((x)>0?1:-1))
const db eps=1e-10;
struct point{
    db x,y;
    point(){}
    point(db x,db y):x(x),y(y){}
    point operator + (point B){ return point(x+B.x,y+B.y); }
    point operator - (point B){ return point(x-B.x,y-B.y); }
    point operator * (db k){ return point(k*x,k*y); }
    db operator * (point B){ return x*B.y-y*B.x; }
    db operator ^ (point B){ return x*B.x+y*B.y; }
    bool operator < (point B){ return (y>0)!=(B.y>0)?y>0:((*this)*B)>0; }
};
db dis2(point A,point B){ return (A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y); }
struct line{
    point A,B;
    line(){}
    line(point A,point B):A(A),B(B){}
};
point projection(line l,point P){
    point dir=l.B-l.A; P=P-l.A;
    return dir*((P^dir)/dis2(l.A,l.B))+l.A;
}
point reflection(line l,point P){
    return projection(l,P)*2-P;
}
int direction(point P0,point P1,point P2){
    db det=(P2-P0)*(P1-P0); return sgn(det);
}
bool parallel(line l1,line l2){
    return zero((l1.B-l1.A)*(l2.B-l2.A));
}
bool orthogonal(line l1,line l2){
    return zero((l1.B-l1.A)^(l2.B-l2.A));
}
bool intersect(line l1,line l2){
    int d1=direction(l1.A,l1.B,l2.A),d2=direction(l1.A,l1.B,l2.B);
    int d3=direction(l2.A,l2.B,l1.A),d4=direction(l2.A,l2.B,l1.B);
    if (d1>0&&d2>0||d1<0&&d2<0||d3>0&&d4>0||d3<0&&d4<0) return false;
    if (l1.A.x>l1.B.x) swap(l1.A.x,l1.B.x);
    if (l1.A.y>l1.B.y) swap(l1.A.y,l1.B.y);
    if (l2.A.x>l2.B.x) swap(l2.A.x,l2.B.x);
    if (l2.A.y>l2.B.y) swap(l2.A.y,l2.B.y);
    return !(l1.B.x<l2.A.x||l2.B.x<l1.A.x||l1.B.y<l2.A.y||l2.B.y<l1.A.y);
}
int main(){
    int q; scanf("%d",&q);
    while (q--){
        db x1,y1,x2,y2; line l1,l2;
        scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2); l1=line(point(x1,y1),point(x2,y2));
        scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2); l2=line(point(x1,y1),point(x2,y2));
        printf("%d\n",intersect(l1,l2));
    }
}



Measured memory_bytes: 3252
import statistics

n = int(input())
x = list(map(int, input().split()))

y = sorted(x)
med = statistics.median(x)
med_1 = y[int((n-2)/2)]
med_2 = y[int(n/2)]

for i in range(n):
    if x[i] < med:
        print(med_2)
    elif x[i] >= med:
        print(med_1)

Measured memory_bytes: 27180
n = gets.chomp.to_i
l_arr = gets.chomp.split(" ").map(&:to_i)

count = 0
(0..n-3).each do |i|
  (i+1..n-2).each do |j|
    (j+1..n-1).each do |k|
      l1 = l_arr[i]
      l2 = l_arr[j]
      l3 = l_arr[k]
      count += 1 if l1 != l2 && l2 != l3 && l3 != l1 && l1 < l2 + l3 && l2 < l3 + l1 && l3 < l1 + l2
    end
  end
end

puts count

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

string GetUnitPencil(int);

int main(void){
  int N;
  cin>>N;
  cout<<GetUnitPencil(N)<<endl;
  return 0;
}

string GetUnitPencil(int value){
  auto Keta1=value%10;
  string result;
  switch(Keta1){
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      result="hon";
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      result="pon";
      break;
    case 3:
      result="bon";
      break;
    default:
      result="error";
  }
  return result;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000

int main(){
    int N;
    cin>>N;
    int d[N];
    for(int i=0;i<N;i++){
        cin>>d[i];
    }
    sort(d,d+N);
    int ans=1;
    for(int i=1;i<N;i++){
        if(d[i]>d[i-1])ans++;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const int inf = 0x3f3f3f3f;
#define LOCAL
char a[100][100];
int h, w;
bool judge(int i, int j){
	return (a[i][j - 1] != '#' && a[i][j + 1] != '#' && a[i - 1][j] != '#' && a[i + 1][j] != '#');
}

int main(int argc, char * argv[]) 
{
	ms(a);
	int flag = 1;
	cin >> h >> w;
	for (int i = 1; i <= h; i++){
		for (int j = 1; j <= w; j++){
			cin >> a[i][j];
		}
	}

	for (int i = 1; i <= h; i++){
		for (int j = 1; j <= w; j++){
			if (a[i][j] == '#')
				if(judge(i, j)){
					flag = 0;
					break;
				}
		}	
		if(!flag) break;
	}

	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/extc++.h>
#include <bits/stdc++.h>
using namespace std;
#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3f
#define ll long long
#define db double
#define eps 1e-3
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
const ll mod = 1e9 + 7;
const ll maxn = 1e3 + 10;

signed main()
{

    string s;
    cin >> s;
    s = '.' + s;
    if(s[3] == s[4] && s[5]==s[6]){
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
def main():
    n = int(input())
    p = []
    for _ in range(n):
        p.append(int(input()))
    q = [0 for i in range(n)]
    for i in range(n):
        q[p[i]-1] = i
    m,cnt = 1,1
    for i in range(1,n):
        if q[i]>q[i-1]:
            cnt += 1
            if cnt > m:
                m = cnt
        else:
            cnt = 1
    print(n-m)

if __name__ == "__main__":
    main()

Measured memory_bytes: 24672
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<class T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<class T>inline auto vec2(class vector<T>::size_type h,class vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
template<class RandomAccessIterator>inline void psortb(RandomAccessIterator first,RandomAccessIterator last){using P=pair<decltype(first->first),decltype(first->second)>;sort(first,last,[](const P&p1,const P&p2){return p1.second<p2.second||(p1.second==p2.second&&p1.first<p2.first);});}

int main()
{
    cout<<in<string>().substr(0,3)<<endl;
}



Measured memory_bytes: 3628