akhauriyash/Code-Regression huggingface dataset:
n = int(input())

f = []
for i in range(n):
    f.append(list(map(int, input().split())))
p = []
for i in range(n):
    p.append(list(map(int, input().split())))

ans = -10**18
for ci in range(1, 2**10):
    score = 0
    for cn in range(n):
        cnt = 0
        for cj in range(10):
            x = ci >> cj & 1
            if x and f[cn][cj]:
                cnt += 1
        score += p[cn][cnt]
    ans = max(ans, score)
print(ans)


Measured memory_bytes: 74028
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}
void readS(T)(size_t n,ref T t){t=new T(n);foreach(ref v;t){auto r=readln.splitter;foreach(ref j;v.tupleof){j=r.front.to!(typeof(j));r.popFront;}}}

void main()
{
  dchar[] s; readV(s);
  s.sort();
  writeln(s == "abc" ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

int main() {
    int N, K;
    std::cin >> N >> K;
    std::vector<int> A(N);
    for (int i = 0; i < N; i++) std::cin >> A[i];
    int left = 0;
    int right = std::pow(10, 9) + 1;
    while (right - left > 1) {
        int mid = (right + left) / 2;
        long long cnt = 0;
        for (int i : A) {
            cnt += i / mid;
            if (i % mid != 0) cnt += 1;
            cnt--;
        }
        if (cnt <= K) right = mid;
        else left = mid;
    }
    std::cout << right << std::endl;
}

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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int d;
  scanf("%d",&d);
  printf("Christmas");
  d=25-d;
  while(d>0){
    d--;
    printf(" Eve");
  }
  printf("\n");
}

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


Measured memory_bytes: 128
s = input()
t = input()
if set(t) & set(s) == set(t):
    n = -1
    c = 0
    for i in t:
        n = s.find(i, n + 1)
        if n == -1:
            c += 1
            n = s.find(i)
    print(n + len(s) * c + 1)
else:
    print(-1)

Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;
typedef long long ll;
ll ans,a[N],b[N],c[N],d[N*4],A[N],B[N],C[N],x,y,q,w,e;
bool cmp(int x,int y)
{
    return x>y;
}
int main()
{
    cin>>x>>y>>q>>w>>e;
    for(int i=1;i<=q;i++)
        cin>>a[i];
    sort(a+1,a+q+1,cmp);
    int cnt=0;
    for(int i=1;i<=x;i++)
    {
        d[++cnt]=a[i];
    }
     for(int i=1;i<=w;i++)
        cin>>b[i];
    sort(b+1,b+w+1,cmp);
    for(int i=1;i<=y;i++)
    {
        d[++cnt]=b[i];
    }
    for(int i=1;i<=e;i++)
    {
        cin>>c[i];
    }
    for(int i=1;i<=x+y+e;i++)
    {
        d[++cnt]=c[i];
    }
    sort(d+1,d+x+y+e+1,cmp);
    for(int i=1;i<=x+y;i++)
    {
       ans+=d[i];
    }
        cout<<ans<<endl;

}

Measured memory_bytes: 9096
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>

using namespace std;
int a[100001] = { 0, };
int cnt = 0;

bool verify_num(int i) {
	if (i == a[a[i]]) {
		a[i] = 0;
		a[a[i]] = 0;
		return true;
	}
	return false;
}

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

	for (int i = 1; i <= N; i++) {
		cin >> a[i];
	}

	for (int i = 1; i <= N; i++) {
		if (a[i] == 0)
			continue;
		else {
			if (verify_num(i)) {
				cnt++;
			}
		}
	}
	cout << cnt << endl;

}

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

int main()
{
	long long N,K,C;
	cin >> N >> K >> C;
	string S;
	cin >> S;
	long long leftcount[N];
	leftcount[0] = 1;
	long long rightcount[N];
	rightcount[N-1] = 1;
	int i;
	int tmp1 = 0;
	int tmp2 = N-1;
	for(i=1;i<N;i++)
	{
		if( (S[i] == 'o') && ((i-tmp1)>=(C+1)) )
		{
			tmp1 = i;
			leftcount[i] = leftcount[i-1] + 1;
		}
		else
		{
			leftcount[i] = leftcount[i-1];
		}
	}
	for(i=N-2;i>=0;i--)
	{
		if( (S[i] == 'o') && ((tmp2-i)>=(C+1)) )
		{
			tmp2 = i;
			rightcount[i] = rightcount[i+1] + 1;
		}
		else
		{
			rightcount[i] = rightcount[i+1];
		}
	}
	long long Rightcount[N];
	long long Leftcount[N];
	Leftcount[0] = 0;
	Rightcount[N-1] = 0;
	for(i=1;i<N;i++)
	{
		Leftcount[i] = leftcount[i-1];
	}
	for(i=N-2;i>=0;i--)
	{
		Rightcount[i] = rightcount[i+1];
	}
	for(i=0;i<N;i++)
	{
		if(Rightcount[i] + Leftcount[i] < K)
		{
			cout << i + 1 << endl;
		}
	}
	return 0;
}

			
		
	

Measured memory_bytes: 8068
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <stdio.h>
#include <cmath>
#include <limits.h>
using namespace std;

typedef long long ll;

#define min(a, b) (((a) < (b))? (a):(b))
#define max(a, b) (((a) > (b))? (a):(b))
#define REP(i, a, n) for(int i=(a); i<(n); ++i)
#define rep(i, n) REP(i, 0, (n))
#define square(a) (a)*(a)
#define pb push_back


int main(void) {
    
    int n;
    cin >> n;
    int l[1100],r[1100];
    for(int i = 1;i <= n; i++)cin >> l[i] >>r[i];
    
    int sum;
    for(int i = 1;i <= n; i++) sum += r[i] - l[i] + 1;
    
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <iomanip>

using namespace std;

int main() {
    int H[10000], W[10000];
    int n = 0;

    while(true) {
        cin >> H[n] >> W[n];
        if(H[n] == 0 && W[n] == 0) break;
        ++n;
    }

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < H[i]; j++) {
            for(int l = 0; l < W[i]; l++) {
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3120
<?php
fscanf(STDIN, '%d %d', $n, $m);
$a = array_map('intval', explode(' ', trim(fgets(STDIN))));
$lcm = $a[0];
for ($i = 0; $i < $n; ++$i) {
    $lcm = lcm($lcm, $a[$i]);
    if ($lcm / $a[$i] % 2 === 0) {
        echo (0) . PHP_EOL;
        exit;
    }
}
$ans = floor((2 * $m + $lcm) / (2 * $lcm));
echo $ans . PHP_EOL;

// 最大公約数
function gcd($m, $n)
{
    if (!$n) return $m;
    return gcd($n, $m % $n);
}

// 最大公約数（3つ以上）
function gcdAll($arr)
{
    $gcd = $arr[0];
    for ($i = 0; $i < count($arr); $i++) {
        $gcd = gcd($gcd, $arr[$i]);
    }
    return $gcd;
}

// 最小公倍数（2つ）
function lcm($m, $n)
{
    return $m * $n / gcd($m, $n);
}

// 最小公倍数（3つ以上）
function lcmAll($arr)
{
    $lcm = $arr[0];
    for ($i = 0; $i < count($arr); $i++) {
        $lcm = lcm($lcm, $arr[$i]);
    }
    return $lcm;
}

Measured memory_bytes: 16884
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int n; R(n);
    int AA=0;
    int now=0,lt=0;
    FOR(i,1,n){
        int v; R(v);
        if(v<=lt){
            now++;
        }
        else now=0;
        AA=max(AA,now);
        lt=v;
    }
    W(AA);
    return 0;
}


Measured memory_bytes: 256
#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);
  }
  vector<int> B(100);
  for(int i =0;i<N;i++){
    if(A.at(i)%2 ==0){
      B.at(i) =A.at(i);
    }
  }
  bool ans = true;
  for(int j =0;j<100;j++){
    if(B.at(j)%3!=0&&B.at(j)%5!=0){
      ans =false;
    }
  }
  if(ans){
    cout<<"APPROVED"<<endl;
  }
  else{
    cout<<"DENIED"<<endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<string.h>
char s[100860];
bool a[30];
int main(){
	scanf("%s",&s);
	for(int i=0;i<strlen(s);i++)a[s[i]-'a']=1;
	for(int i=0;i<26;i++)if(!a[i]){printf("%c\n",i+'a');return 0;}
	puts("None");
}

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

ss = []
for _ in range(m):
    _s = (int(x) - 1 for x in input().split())
    next(_s)
    ss.append(set(_s))

*ps, = map(int, input().split())

ret = 0
for bit in range(1 << n):
    cnts = [0] * m
    for sw_id in range(n):
        if (bit >> sw_id) & 1:
            for light_id, _s in enumerate(ss):
                if sw_id in _s:
                    cnts[light_id] += 1
    if all(p == cnt % 2 for p, cnt in zip(ps, cnts)):
        ret += 1
print(ret)


Measured memory_bytes: 3064
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 1e5 + 10;
int n , Q , f[N];

int main(){
  scanf("%d%d",&n,&Q);
  int c = 1;
  f[2] = 1;
  rep(i,0,Q) {
    int a,b;
    scanf("%d%d",&a,&b);
    swap(f[a] , f[b]);
    if(c == a || c == b)
      c ^= a ^ b;
    if(c != 1) f[c - 1] = 1;
    if(c != n) f[c + 1] = 1;
  }
  f[c] = 1;
  int ans = 0;
  rep(i,1,n+1) ans += f[i];
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 640
N = int(input())
midium = int(N / 2)
hairetu = list(map(int, input().split()))
hairetu.sort()
kosuu = 0
if hairetu[midium - 1] != hairetu[midium]:
    kosuu = hairetu[midium] - hairetu[midium - 1]
    print(kosuu)
else:
    print(0)


Measured memory_bytes: 14396
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
def main():
  n = int(input())
  L = list(map(int,input().split()))
  
  L = sorted(L,reverse=True)
  if L[0] < sum(L[1:]):
    print('Yes')
  else:
    print('No')
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long l[87]; int i,n;
    l[1]=2; l[2]=1;
    cin>>n;
    for (i=3;i<=n+1;i++)
     l[i]=l[i-1]+l[i-2];
    cout<<l[n+1]<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
struct edge {int to,cost;};
#define VMAX 51
typedef std::pair<int,int> P;
    string S[3];
int main(){
    ios_base::sync_with_stdio(false);
    cin>>S[0]>>S[1];
    DEB(S[0][2])DEB(S[1][2])END
    if(S[0][0]==S[1][2]&&S[0][1]==S[1][1]&&S[0][2]==S[1][0]){
        cout<<"YES";
    }else cout<<"NO";
    return 0;
}


Measured memory_bytes: 256
def examA():
    s = S()
    ans = s.count("1")
    print(ans)


import sys,copy,bisect,itertools
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()


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

string S;
int K;
vector<int> P[26];

int cc[302][302][302];
int dp(int l, int r, int k) {
    if(l > r) return 0;
    int &ret = cc[l][r][k];
    if(ret != -1) return ret;

    ret = 0;
    ret = max(ret, dp(l + 1, r, k));

    int s = 0, e = (int)P[ S[l] - 'a' ].size() - 1, p = -1;
    while(s <= e) {
        int m = (s + e)>>1;

        if(P[ S[l] - 'a' ][m] <= r) {
            p = P[ S[l] - 'a' ][m];
            s = m + 1;
        }
        else e = m - 1;
    }

    if(l <= p && p <= r) {
        ret = max(ret, (p == l? 1 : 2) + dp(l + 1, p - 1, k));
    }

    if(S[l] != S[r] && k) {
        ret = max(ret, (l == r? 1 : 2) + dp(l + 1, r - 1, k - 1));
    }
    return ret;
}

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

    for(int i = 0; i < S.size(); i++) {
        P[ S[i] - 'a' ].push_back(i);
    }

    memset(cc, -1, sizeof(cc));
    printf("%d", dp(0, (int)S.size() - 1, K));
}


Measured memory_bytes: 107904
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 99999999999999999;

long long int N,C[101][101],res=0;

int main()
{
    cout << fixed << setprecision(18);
    cin>>N;
    for(long long int i = 0; i < N; i++){
        for(long long int j = 0; j < N; j++){
            cin>>C[i][j];
        }
    }
    for(long long int i = 0; i < N; i++){
        for(long long int j = i+1; j < N; j++){
            res+=min(C[i][j],C[j][i]);
        }
    }
    cout<<res<<endl;
}



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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    string s,t;
    cin >> s >> t;
    int count = 0;

    for(int i=0;i<3;i++){
        if(s[i]==t[i]){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);
fscanf(STDIN, "%d %d", $t, $a);
$h = fgets(STDIN);
$h_arr = explode(" ", $h);
//$tmp = [];
$ret = [];
for($i = 0; $i < $n; $i++) {
//    $tmp[$i + 1] = $t - $h_arr[$i] * 0.006;
    $ret[$i + 1] = abs($a - ($t - $h_arr[$i] * 0.006));
}
$min = min($ret);
echo array_search($min, $ret). "\n";

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

int main(){
  string s;
  cin>>s;
  
  sort(s.begin(),s.end());
  if(s[0] == s[1] && s[2] == s[3] && s[0] != s[2])
    cout<<"Yes";
  else
    cout<<"No";
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int search(int A[], int n, int key){
  int i = 0;
  A[n] = key;
  while ( A[i] != key ) i++;
  return i != n;
}

int main (){
  int i, n, A[10000], q, key, sum = 0;
  scanf ("%d",&n);
  for ( i = 0; i < n; i++ )
    scanf ("%d", &A[i]); 
 scanf ("%d",&q);
  for ( i = 0; i < q; i++ ){
    scanf ("%d", &key);
    if ( search(A, n, key) )
      sum++;
  }
  printf ("%d\n",sum);
  return 0;
}

Measured memory_bytes: 636
# https://atcoder.jp/contests/abc084/tasks/abc084_b

import itertools
import collections
import bisect

def main():
    A, B = map(int, input().split())
    S = input()

    try:
        fir = int(S[:A])
        sec = int(S[B:])
    except ValueError:
        print("No")
        exit()

    if S[A] == '-':
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  ll l = 0, r = 1e18;
  while (r-l > 1) {
    ll mid = (l+r)/2, cnt = 0;
    int j = n-1;
    rep(i, n) {
      while (j >= 0 && a[i]+a[j] >= mid)
        j--;
      cnt += n-1-j;
    }
    if (cnt >= m)
      l = mid;
    else
      r = mid;
  }
  vector<ll> s(n+1);
  rep(i, n) s[i+1] += s[i]+a[i];
  ll ans = 0, cnt = 0;
  int j = n-1;
  rep(i, n) {
    while (j >= 0 && a[i]+a[j] > l)
      j--;
    ans += a[i]*(n-1-j)+s[n]-s[j+1];
    cnt += n-1-j;
  }
  ans += l*(m-cnt);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
//C - Divide the Problems
//20190913

using System;
using System.Linq;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var d = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();

            if (d[n / 2 - 1] != d[n / 2])
            {
                int ans = 0;
                ans = d[n / 2] - d[n / 2 - 1];
                Console.WriteLine(ans);
            }
            else
            {
                Console.WriteLine("0");
            }



        }
    }
}


Measured memory_bytes: 21600
// Coordinate compression

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
 
#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(int i=a;i<b;i++)




int solve(){     

  int n,w;
  cin>>n>>w;
 int dp[w+1]={0};
 
 rep(j,0,n)
 {
  int x,y;
  cin>>x>>y;
   for(int i=w;i>=x;i--)
   {
      dp[i]=max(dp[i],dp[i-x]+y);
   }
 }
 cout<<dp[w];


return 0;
}

 
signed main()
{    

  

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

 
 int t=1;                                                                                                                  
 //cin>>t;
    while(t--)
     {
      solve();
     }
    return 0;
}

Measured memory_bytes: 1024
from collections import deque
l=deque()
a=list(input().split())
for i in range(len(a)):
    if a[i]=="+":
        b=l.pop()
        c=l.pop()
        l.append(b+c)
    elif a[i]=="-":
        b=l.pop()
        c=l.pop()
        l.append(c-b)
    elif a[i]=="*":
        b=l.pop()
        c=l.pop()
        l.append(b*c)
    else:
        l.append(int(a[i]))

print(l[0])



Measured memory_bytes: 6000
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    string S;
    cin >> S;
    int N = S.size();
    map<int, int> M;
    M[0]++;
    int i_ten = 1, last_mod = 0;
    rep(i, N){
        int a = ((S.at(N - 1 - i) - '0') * i_ten + last_mod) % 2019;
        last_mod = a;
        i_ten = (i_ten * 10) % 2019;
        M[a]++;
    }

    ll ans = 0;
    for(auto m : M){
        ll tmp = m.second;
        ans += tmp * (tmp - 1) / 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<ll> Size;
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n + 1); rank.resize(n + 1); Size.resize(n + 1);
        for (int i = 0; i <= n; ++i) par[i] = i, rank[i] = 0, Size[i] = 1;
    }

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

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        Size[x] += Size[y];
        return true;
    }

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

int N, M, K;
int A[105000], B[105000], C[105000], D[105000];
int ans[105000];

void input() {
    cin >> N >> M >> K;
    for(int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
    }
    for(int i = 0; i < K; i++) {
        cin >> C[i] >> D[i];
    }
}

void solve() {
    UnionFind uni(N + 1);
    for(int i = 1; i <= N; i++) ans[i] = 0;
    for(int i = 0; i < M; i++) {
        uni.merge(A[i], B[i]);
    }
    for(int i = 1; i <= N; i++) {
        ans[i] = uni.size(uni.root(i)) - 1;
    }
    for(int i = 0; i < M; i++) {
        if(!uni.issame(A[i], B[i])) continue;
        ans[A[i]]--;
        ans[B[i]]--;
    }
    for(int i = 0; i < K; i++) {
        if(!uni.issame(C[i], D[i])) continue;
        ans[C[i]]--;
        ans[D[i]]--;
    }
    for(int i = 1; i <= N; i++) {
        if(i != 1) cout << " ";
        cout << ans[i];
    }
    cout << endl;
    return;
}

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

Measured memory_bytes: 4352
n=int(input())
l=list(map(int,input().split()))
md=int(sum(l)/2)
s=[]
for i in range(n-1):
  s1=sum(l[:i+1])
  s2=sum(l[i+1:])
  s.append(abs(s1-s2))
print(min(s))

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

using namespace std;
#define ull unsigned long long

ull gcd(ull a, ull b) {
    if (a == b) return a;
    if (a > b) {
        return gcd(a - b, b);
    } else {
        return gcd(a, b - a);
    }
}

ull lcm(ull a, ull b) {
    return (a * b) / gcd(a, b);
}

int main() {
    ull a, b;
    while (cin >> a >> b) {
        cout << gcd(a, b) << " " << lcm(a, b) << endl;
    }
    return 0;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define ll long long
#define int long long int
#define MOD 1000000007
#define mkp make_pair
#define maxN 100005
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,a,b) for(int i=a;i<b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define  vi vector<int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define in cin>>
#define out cout<<
using namespace std;
const int infi=1e9+7;
void printVector(vector<int> v){
    for(int i=0;i<(int)v.size();i++)
        cout<<v[i]<<" ";
    out endl;
}

void printArray(int arr[],int n)
{
   for(int i=0;i<n;i++)cout<<arr[i]<<' ';
cout<<endl;
}
 set<pair<int,int>> primeset;
 vi prime_number;
void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
        for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
           primeset.insert(mkp(p,1));
}
ll modExp(ll base, ll power) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}
int32_t main()
{
fastio;
int t=1;
//in t;
while(t--){
string s;in s;
int start=0;
int end=s.size()-1;
int c=0;
while(start<=end){
    if(s[start]!=s[end])c++;
    start++;
    end--;
    //cout<<start<<" "<<end<<endl;
}
cout<<c<<endl;
}
    return 0;
}


Measured memory_bytes: 256
/**
 * @Author: yujirotakahashi
 * @Date:   2020-05-17T20:21:41+09:00
 * @Last modified by:   yujirotakahashi
 * @Last modified time: 2020-05-25T00:28:40+09:00
 */

#include<bits/stdc++.h>
using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
//const ll INF = (1LL << 60);
//const double pi=acos(-1.0);
using ll = long long;
using PAIR = pair<int, int>;
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
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; }
/**************************************/

/******** User-defined Function *******/
using Graph = vector<vector<int>>;
int dx[4] = {-1,0,0,1};
int dy[4] = {0,1,-1,0};
/**************************************/

/********** Main()  function **********/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n; cin >> n;
  ll dp[50];
  dp[0] = 1;
  dp[1] = 1;

  for(int i=2; i<=n; ++i){
      dp[i] = dp[i-1] + dp[i-2];
  }

  cout << dp[n] << endl;

  return 0;
}
/********  Main() Ends Here *************/



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

int main() {
    int N, K;
    cin >> N >> K;
    int r = 1;
    for(int i = 0; i < N; i++){
        if( r + K <= r * 2){
            r += K;
        }else{
            r *= 2;
        }
    }
    cout << r << endl;
  // ここにプログラムを追記
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    if(str.charAt(0) == str.charAt(1) || str.charAt(1) == str.charAt(2) || str.charAt(2) == str.charAt(3)) System.out.println("Bad");
    else System.out.println("Good");
  }
}


Measured memory_bytes: 23124
#include<stdio.h>

int main (void){

  int H , W , h , w;
  scanf("%d %d %d %d", &H , &W , &h , &w);

  int all_area = H * W;
  int minus_area = H * w + W * h - w * h;
  int ans = all_area - minus_area;

  printf("%d", ans );

return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;

typedef pair<int, int> val_idx;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  int p[n];
  for(int i = 0; i < n; i++) {
    cin >> p[i];
  }
  priority_queue<val_idx> lower_queue, higher_queue;
  for(int i = 0; i < k; i++) {
    lower_queue.push(val_idx(-p[i], i));
    higher_queue.push(val_idx(p[i], i));
  }
  int window_reversed = 0;
  for(int i = 0; i < k - 1; i++) {
    if(p[i] >= p[i + 1]) window_reversed++;
  }
  bool count_nonreverse = false;
  if(window_reversed == 0) {
    count_nonreverse = true;
  }
  int ans = 1;
  for(int i = k; i < n; i++) {
    int out = i - k;
    lower_queue.push(val_idx(-p[i], i));
    higher_queue.push(val_idx(p[i], i));
    while(lower_queue.top().second < out) {
      lower_queue.pop();
    }
    while(higher_queue.top().second < out) {
      higher_queue.pop();
    }
    val_idx low = lower_queue.top();
    val_idx high = higher_queue.top();
    if(p[out] >= p[out + 1]) {
      window_reversed--;
    }
    if(p[i - 1] >= p[i]) {
      window_reversed++;
    }
    if((low.second != out || high.second != i) && window_reversed != 0) {
      ans += 1;
    }
    if(window_reversed == 0) {
      if(count_nonreverse) continue;
      count_nonreverse = true;
      ans += 1;
    }
  }
  cout << ans << "\n";
  return 0;
}



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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

const int N = 100005;

int n;
int a[N], l[N], r[N], m[N];

int main() {

    FAST;

    cin >> n;
    for (int i = 1; i <= n; i ++) {
        cin >> a[i];
    }
    l[0] = 0;
    for (int i = 1; i <= n; i ++) {
        l[i] = __gcd(l[i - 1], a[i - 1]);
    }
    r[n + 1] = 0;
    for (int i = n; i >= 1; i --) {
        r[i] = __gcd(r[i + 1], a[i + 1]);
    }
    for (int i = 1; i <= n; i ++) {
        m[i] = __gcd(l[i], r[i]);
    }
    int ans = 0;
    for (int i = 1; i <= n; i ++) {
        ans = max(ans, m[i]);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll x = 0;
  cin >> x;
  ll now = 0;
  now = 100;
  ll count = 0;
  while(now < x){
    count++;
    now += now * 0.01;
  }
  cout << count << endl;
  return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;



void solve(){
	ll n,m,k;cin>>n>>m>>k;
	set<ll> s;
	for(int i=0;i<k && n+i<=m;i++)
		s.insert(n+i);
	for(int i=0;i<k && m-i>=n ;i++)
		s.insert(m-i);
	for(auto i: s)
		cout<<i<<"\n";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;

	//ll t;cin>>t;while(t--)
	solve();

}


Measured memory_bytes: 256
N, M = input().split(" ")
N = int(N)
M = int(M)

s = []
c = []

one_list = []
two_list = []
three_list = []

for i in range(M):
    tmp_s, tmp_c = input().split(" ")
    tmp_s = int(tmp_s)
    tmp_c = int(tmp_c)
    s.append(tmp_s)
    c.append(tmp_c)
    if tmp_s == 1:
        one_list.append(tmp_c)
    elif tmp_s == 2:
        two_list.append(tmp_c)
    elif tmp_s == 3:
        three_list.append(tmp_c)
    else:
        print("Error")


if len(set(one_list)) > 1:
    print(-1)
    exit()

if len(set(two_list)) > 1:
    print(-1)
    exit()

if len(set(three_list)) > 1:
    print(-1)
    exit()

result = ""
for i in range(N):
    result += "-"

str_list = list(result)
for i in range(M):
    str_list[s[i] - 1] = str(c[i])

if N > 1:
    if str_list[0] == "0":
        print(-1)
        exit()

str_list = list("".join(str_list).replace("-", "0"))
if N != 1:
    if str_list[0] == "0":
        str_list[0] = "1"

print("".join(str_list))


Measured memory_bytes: 3064
use std::io;

fn main() {
    loop {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        let mut v = s.trim().split_whitespace();
        let a: i32 = v.next().unwrap().parse().unwrap();
        let op = v.next().unwrap();
        let b: i32 = v.next().unwrap().parse().unwrap();
        println!(
            "{}",
            match op {
                "+" => a + b,
                "-" => a - b,
                "*" => a * b,
                "/" => a / b,
                _ => break,
            }
        );
    }
}



Measured memory_bytes: 5028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(i=a;i>=b;i--)
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf=1000000001;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

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

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <map>
#include <math.h>
#include <vector>
using namespace std;

int main(){
    string s, t;
    cin >> s >> t;
    if (s == t.substr(0, s.size())) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
using namespace std;

int main(){

    int n;
    cin >> n;

    string s;
    vector<long long> march(5);
    for(int i = 0; i < n; i++){
        cin >> s;
        if(s[0] == 'M') march[0]++;
        if(s[0] == 'A') march[1]++;
        if(s[0] == 'R') march[2]++;
        if(s[0] == 'C') march[3]++;
        if(s[0] == 'H') march[4]++;
    }
     
    long long ans = 0;
    for(int i1 = 0; i1 < 5; i1++){
        for(int i2 = i1 + 1; i2 < 5; i2++){
            for(int i3 = i2 + 1; i3 < 5; i3++){
                ans += march[i1] * march[i2] * march[i3];
            }
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#3
n, k, q = list(map(int, input().split()))
tokuten = [0]*n

for _ in range(q):
    tokuten[int(input()) - 1] += 1

for i in range(n):
    if k - (q - tokuten[i]) <= 0:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 4680
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	static class Node{
		List<Integer> adj;
		public Node() {
			adj = new ArrayList<Integer>();
		}
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		Node vs[] = new Node[N * 3];
		for(int i = 0 ; i < N ; ++i){
			vs[i] = new Node();
			vs[i + N] = new Node();
			vs[i + 2 * N] = new Node();
		}
		for(int i = 0 ; i < M ; ++i){
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			vs[a].adj.add(b + N);
			vs[a + N].adj.add(b + 2 * N);
			vs[a + 2 * N].adj.add(b);
		}
		int S = sc.nextInt() - 1;
		int T = sc.nextInt() - 1;
		int dist[] = new int[vs.length];
		Arrays.fill(dist, -1);
		dist[S] = 0;
		Queue<Integer> q = new LinkedList<Integer>();
		q.add(S);
		while(!q.isEmpty()){
			int cur = q.poll();
			int cd = dist[cur];
			for(int a : vs[cur].adj){
				if(dist[a] < 0){
					dist[a] = cd + 1;
					q.add(a);
				}
			}
		}
		if(dist[T] >= 0){
			System.out.println(dist[T] / 3);			
		}else{
			System.out.println(dist[T]);			
		}
	}
}


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

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> B(M);
  for (int i=0; i<M; i++) {
    cin >> B[i];
  }
  int ans = 0;
  for (int i=0; i<N; i++) {
    int sum = C;
    vector<int> A(M);
    for (int k=0; k<M; k++) {
      cin >> A[k];
    }
    for (int j=0; j<M; j++) {
      sum += A[j]*B[j];
    }
    if (sum > 0) ans++;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>
#include <unordered_map>
#include <stack>
#include <cstring>
#include <cctype>
#include <random>

using namespace std;
typedef long long  ll;
const ll INF = 1000000007;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (n); ++i)


int main() {
	ll N;
	cin >> N;
	vector<vector<ll>> d(N, vector<ll>(2));
	rep(i, N) {
		cin >> d[i][0] >> d[i][1];
	}
	for (int i = 2; i < N; i++) {
		bool aa = true;
		rep(j, 3) {
			if (d[i - j][0] != d[i - j][1]) {
				aa = false;
			}
		}
		if (aa) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>
int main() {

   int A[10000];
   int i, j, k, v, N;

   scanf("%d", &N);
 
   for (i = 0; i < N; i++) {
      scanf("%d", &A[i]);
   }
   for (i = 0; i < N; i++) {
      v = A[i];
      j = i - 1;
      while (j >= 0 && A[j] > v) {
         A[j + 1] = A[j];
         j--;
         A[j + 1] = v;
      }
      for (k = 0; k < N; k++) {
         printf("%d", A[k]);
         if (k != N -1) {
            putchar(' ');
         }
      }
      putchar('\n');
   }
   return 0;
}


Measured memory_bytes: 1928
#include <iostream>
#include <stdio.h>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>

using namespace std;

#define x first
#define y second
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define all(x) x.begin(),x.end()
#define SZ(x) int(x.size())
#define rep(i, a, b) for(int i = a; i < b; i++)
#define per(i, a, b) for(int i = b-1; i >= a; i--)
#define DBG(x) cerr << (#x) << "=" << x << "\n";
#define ll long long
#define inf 1000000007
#define mod 998244353 //1000000007
#define N 200005

template<typename U, typename V> void Min(U &a, const V & b){if(a > b)a = b;}
template<typename U, typename V> void Max(U &a, const V & b){if(a < b)a = b;}
template<typename U, typename V> void add(U &a, const V & b){a = (a + b) % mod;} 
template<typename U> U gcd(U a, U b){
	if(a == 0)return b;
    if(b == 0)return a;
	if(a >= b)return gcd(a-b, b);
	else return gcd(a, b - a);
} 
int pow(int a, int b){
    int ans = 1;
    while(b){
        if(b & 1)ans = 1LL * ans * a % mod;
        a = 1LL * a * a % mod;
        b >>= 1;
    }
    return ans;
}

int a[N], b[N], sm[N];
int main(){
    int T, m, n, i, j, k, K;
    scanf("%d%d", &n, &K);
    rep(i, 0, n)scanf("%d", &a[i]);
    set<int>s;
    int ans = 0, cnt = 0, flag = 0;
    j = 1;
    a[n] = inf;
    rep(i, 0, n-K+1){
        while(j < n && j - i < K){
            if(a[j] < a[j-1])cnt++;
            j++;
        }
        b[i] = cnt;
        if(a[i] > a[i+1])cnt--;
    }
    j = 0;
    rep(i, 0, n-K){
        while(j < n && j - i < K+1)s.insert(a[j++]);
        if(*s.begin() == a[i] && *s.rbegin() == a[j-1])sm[i+1] = 1;
        s.erase(a[i]);
    }
    rep(i, 0, n-K+1)if(!sm[i]){
        if(b[i])ans++;
        else flag = 1;
    }
    ans += flag;
    printf("%d\n", ans);
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	if(n%2==0) cout<<n/2-1<<'\n';
	else cout<<n/2<<'\n';
}	


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n; cin >> n;
    int cnt = 0, ans = 0;
    for(int i = 1; i <= n; i += 2){
        cnt = 0;
        for(int j = 1; j <= i; j += 2){
            if(i % j == 0) cnt++;
        }
        if(cnt == 8) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256