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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
// constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
constexpr long long MOD = 1777777777LL;
using ld = long double;
using tp = tuple<ll, ll, ll>;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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;
}

// long dobule
struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n;
    cin >> n;
    vec<ll> x(n), y(n);
    REP(i, n) {
        cin >> x[i] >> y[i];
    }

    ll pre = (abs(x[0]) + abs(y[0])) % 2;
    REP(i, n) {
        ll now = (abs(x[i]) + abs(y[i])) % 2;
        if(pre != now) {
            cout << -1 << en;
            return;
        }
    }

    ll m = 31;
    cout << 32 - pre << en;
    vec<ll> d(m);
    REP(i, m) {
        d[i] = 1LL << i;
    }
    for(auto i : d)
        cout << i << " ";
    if(!pre)
        cout << 1 << " ";
    cout << en;

    ll all = (1LL << 31) - 1;
    REP(i, n) {
        ll u = x[i] + y[i] + 1 - pre + all;
        u /= 2;
        ll v = x[i] - y[i] + 1 - pre + all;
        v /= 2;
        REP(j, m) {
            bool U = (u >> j) & 1;
            bool V = (v >> j) & 1;
            if(U and V) {
                cout << "R";
            } else if(!U and !V) {
                cout << "L";
            } else if(U and !V) {
                cout << "U";
            } else {
                cout << "D";
            }
        }
        if(!pre) {
            cout << "L";
        }
        cout << en;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    while(t--)*/
    solve();

    return 0;
}


Measured memory_bytes: 3680
n, k =map(int, input().split())
res = 0
a = [0 for x in range(n)]
for i in range(k):
    d = int(input())
    array = [int(x) for x in input().split()]
    for j in array:
        a[j-1]+=1
for aa in a:
    if aa == 0:
        res += 1
print(res)


Measured memory_bytes: 9180
#include <stdio.h>
#define M 100

void selectionSort(int[],int);
int count = 0;

int main (){
    int n,i;
    int A[M+1];
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }

    selectionSort(A,n);
    printf("%d\n",count);

    return 0;

}

void selectionSort(int A[],int N){
  int j,i,mini,temp;

  for (i = 0 ;i<N;i++){
    mini = i;
    for (j= i;j<N;j++){
      if(A[j] < A[mini])mini = j;
    }
    if(mini != i){
      temp = A[mini];
      A[mini] = A[i];
      A[i] = temp;
      count++;
    }
    
  }
  for (i=0;i<N-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);
    
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {
int N, A, B; 
cin >> N >> A >> B;
if((B-A) % 2 == 0){
cout << "Alice" << endl; 
}
else if((B-A) % 2 == 1){
cout << "Borys" << endl; 
}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
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; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


int main() {
    
    int n;
    cin >> n;
    
    vector<int> a(n), idx(n);
    rep(i, n) { cin >> a[i]; a[i]--; }
    
    rep(i, n) idx[a[i]] = i;
    
    set<int> s;
    ll ans = 0;
    rep(i, n) {
        int x = idx[i];
        s.insert(x);
        
        auto it = s.find(x);
        int r = n, l = -1;
        if (it != s.begin()) {
            it--;
            l = *it;
        }
        it = s.find(x);
        it++;
        if (it != s.end()) {
            r = *it;
        }
        // cout << l << " " << r << '\n';
        ll c = (ll)(r - x) * (x - l);
        ans += (ll)(i + 1) * c;
        // cout << ans << '\n';
    }
    cout << ans << '\n';
}


Measured memory_bytes: 11136
h, w = list(map(int, input().split()))
grid = []
for i in range(h):
    grid.append(input())

for i in range(h):
    for j in range(w):
        if grid[i][j] == ".":
            continue

        check = []
        if j != 0:
            check.append([i, j-1])
        if j != w-1:
            check.append([i, j+1])
        if i != 0:
            check.append([i-1, j])
        if i != h-1:
            check.append([i+1, j])

        p = False
        for c in check:
            if grid[c[0]][c[1]] == "#":
                p = True
                break

        if not p:
            print("No")
            exit()

print("Yes")

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

int main(){
  int K;
  int i, j, l, m;
  int ans = 0;
  
  cin >> K;

  for(i=0; i < K; i++){
    for(j=0; j < K; j++){
      for(l=0; l < K; l++){
        ans += gcd(gcd(i+1, j+1), l+1);
      }
    }
  }

  cout << ans;

}

Measured memory_bytes: 3672
#include<stdio.h>
#define N 100000
int partition(void);
void swap(int*,int*);
int n,A[N];
int main(){
  int i,r;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  r = partition();
  for(i=0;i<n;i++){
    if( i!=0 ){
      printf(" ");
    }
    if( r==i ){
      printf("[%d]",A[i]);
    }
    else{
      printf("%d",A[i]);
    }
  }
  printf("\n");
  return 0;
}
int partition(void){
  int i,j,p,r;
  r = A[n-1];
  i = -1;
  for(j=0;j<n-1;j++){
    if( A[j] <= r ){
      i++;
      swap(&A[i],&A[j]);
    }
  }
  swap(&A[i+1],&A[n-1]);
  return i+1;
}
void swap(int *x,int *y){
  int tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
  return ;
}

Measured memory_bytes: 992
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld double
#define mp make_pair
#define vl vector<ll> 
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
void solve()
{
    ll n, k;
    cin>>n>>k;
    vl stones(n);
    
    forr(i, n)  cin>>stones[i];
    vector<bool> dp(k+1, false);

    for(ll i=0; i<=k; i++)
    {
        for(ll j=0; j<n; j++)
        {
            if(i-stones[j]>=0&&dp[i-stones[j]]==false)
            dp[i]=true;
        }
    }
    puts(dp[k]?"First":"Second");
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
int main()
{
	ll n,k;
	cin>>n>>k;
	ll ans=0;
	ll dp1[n+1],dp[n+1];
	for(int i=0;i<=n;i++)
	{
		dp1[i]=i;
		dp[i]=i;
		if(i)
		dp1[i]+=dp1[i-1];
	}
	for(int i=n-1;i>=0;i--)
		dp[i]+=dp[i+1];
	for(int i=k;i<=n+1;i++)
	{
		ll l=dp1[i-1];
		ll r=dp[n-i+1];
		// cout<<l<<" "<<r<<endl;
		ans=(ans+(r-l+1))%1000000007;
	}
	cout<<ans<<endl;
}

 // 0 1 2 3

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

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

int main() { 
    string S,T;
    cin >> S;
    cin >> T;
    int count = 0, ans = 100000;
    for(int i = 0; i <= S.length() - T.length(); ++i) {
        count = 0;
        for(int j = 0; j < T.length(); ++j) {
            if (S[i+j] != T[j]) {
                ++count;
            }
        }
        ans = min(ans, count);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

constexpr ll INF=1e18;

int n;
ll xy[2][20], p[20];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  cin>>n;
  REP(i, n){
    cin>>xy[0][i]>>xy[1][i]>>p[i];
  }
  ll d[2][(1<<n)+1][n];
  REP(i, 1<<n){
    REP(j, n){
      REP(k, 2){
        d[k][i][j]=abs(xy[k][j]);
      }
      REP(k, n){
        if(i>>k&1){
          REP(l, 2){
            CHMIN(d[l][i][j], abs(xy[l][k]-xy[l][j]));
          }
        }
      }
    }
  }
  ll ans[n+1];
  REP(i, n+1){
    ans[i]=INF;
  }
  REP(i, 1<<n){
    int cnt=0;
    REP(j, n){
      if(i>>j&1){
        ++cnt;
      }
    }
    int j=i;
    do{
      // ここに処理を書く
      ll tmp=0;
      REP(l, n){
        if(!(i>>l&1)){
          tmp+=min(d[0][j][l], d[1][i-j][l])*p[l];
        }
      }
      CHMIN(ans[cnt], tmp);
      j=(j-1)&i;
    }while(j!=i);
  }
  REP(i, n+1){
    cout<<ans[i]<<'\n';
  }
  return 0;
}


Measured memory_bytes: 11344
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

int n;

int main(){


    cin>>n;
    
    if(n%10==9 || n/10==9){
        cout<<"Yes";
    } else{
        cout<<"No";
    }
}


Measured memory_bytes: 256
def resolve():
    S = input()
    K = int(input())

    ans = []
    for s in S:
        diff = ord(s) - ord("a")
        if diff == 0:
            ans.append("a")
            continue
        elif 26 - diff <= K:
            ans.append("a")
            K -= 26 - diff
        else:
            ans.append(s)

    K %= 26
    d = (K + ord(ans[-1]) - ord('a')) % 26
    ans[-1] = chr(d + ord('a'))

    print("".join(ans))


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 10128
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};



int main(){
    map<string,int> ma;
    int n;cin >> n;
    for (int i = 0; i < n; i++) {
        string s;cin >> s;
        ma[s]++;
    }
    vector<string> st;
    int mx = 0;
    for(auto m:ma){
        mx = max(mx,m.sc);
    }
    for(auto m:ma){
        if(mx == m.sc) st.pb(m.fs);
    }
    sort(ALL(st));
    for (int i = 0; i < st.size(); i++) {
        cout << st[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 26868
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N,K=MAP()

if N%2==0:
    if K<=N//2:
        YES()
    else:
        NO()
else:
    if K<=N//2+1:
        YES()
    else:
        NO()


Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))
ok = True
for i in range(N):
  if A[i] % 2 == 0:
    if A[i] % 3 != 0 and A[i] % 5 != 0:
      ok = False
print('APPROVED' if ok else 'DENIED')


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

int main() {
int A;
  int P ;
  cin>>A>>P;
  if((3*A+P)%2==0){
    cout<<(3*A+P)/2<<endl;
  }
    else if((3*A+P)%2==1){
      cout<<(3*A+P-1)/2<<endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
public static void main(String[] args){
Scanner scanner=new Scanner(System.in);
int N=scanner.nextInt();
boolean[] a=new boolean[N+2];
for(int i=1;i<N+1;i++){
a[i]=scanner.nextInt()==i;
}

int ans=0;
for(int i=1;i<N+1;i++){
if(a[i]){
a[i]=a[i+1]=false;
ans++;
}
}

System.out.println(ans);
}
}

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

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int t[] = new int[3];
			for(int i=0;i<3;i++) t[i] = sc.nextInt();
			if((t[0]|t[1]|t[2]) == 0) break;
			sort(t);
			int n= sc.nextInt();
			int w = t[0];
			int h = t[1];
			w = w*w;
			h = h*h;
			for(int i=0;i<n;i++) {
				int r = 2*sc.nextInt();
				if( r * r > w+h) System.out.println("OK");
				else System.out.println("NA");
			}
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12000
icase=0    
if icase==0:
    x,y=map(int,input().split())
    a=[1,3,5,7,8,10,12]
    b=[4,6,9,11]
    c=[2]
    if (x in a) and (y in a):    
        print("Yes")
    elif (x in b) and (y in b):    
        print("Yes")
    elif (x in c) and (y in c):    
        print("Yes")
    else:
        print("No")
    

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

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

Measured memory_bytes: 256
N, x = map(int, input().split())
nums = list(map(int, input().split()))
before = nums[0]
cnt = 0
for i in range(1, N):
  ope = before+nums[i]-x
  if ope > 0:
    before = max(nums[i]-ope, 0)
    cnt += ope
  else:
    before = nums[i]
print(cnt)


Measured memory_bytes: 14252
// AOJ 2035: It Prefokery Pio
// 2017.10.9 bal4u@uu
// 2017.11.21

#include <stdio.h>
#include <string.h>

char s[2005], t[2005];

int c[2005][2005];  // for LCS
char z[2005];
char f[2005][2005];
void LCS(char *x, int m, char *y, int n)
{
	int i, j, k;

	memset(c, 0, sizeof(int)*n); memset(f, 0, n);
	for (i = 1; i <= m; i++) for (j = 1; j <= n; j++) {
		if (x[i-1] == y[j-1])            c[i][j] = c[i-1][j-1]+1, f[i][j] =  0;
		else if (c[i-1][j] >= c[i][j-1]) c[i][j] = c[i-1][j],     f[i][j] =  1;
		else                             c[i][j] = c[i][j-1],     f[i][j] = -1;
	}
	k = c[m][n]-1;
	z[k+1] = 0;
	while (k >= 0) {
		if      (f[m][n] > 0) m--;
		else if (f[m][n] < 0) n--;
		else z[k] = x[m-1], k--, m--, n--;
	}
}

int main()
{
	char *p, *q;

	while (fgets(s, 2005, stdin) != NULL) {
		p = s, q = t+2002;
		while (*p > ' ') *--q = *p++;
		LCS(s, p-s, q, p-s);
		puts(z);
	}
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  if (s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" ||
      s == "hihihihihi") {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
vector<ll> height ;
vector<ll> memo;
int solve(int i){
    if(i<=0)
        return 0;

    if(memo[i]!=-1)
        return memo[i];
    int left_1 = solve(i-1)+abs(height[i]-height[i-1]);
    int left_2 = INT_MAX;
    if(i>=2)
        left_2 = solve(i-2)+abs(height[i]-height[i-2]);
    memo[i]=min(left_1,left_2);
    return memo[i];
}
int main()
{
    ll n ;
    cin >> n ;
    for(int i=0;i<n;i++){
        ll a ;
        cin >> a ;
        height.push_back(a);
        memo.push_back(-1);
    }
    solve(n-1);
    cout << memo.back();
    return 0;
}


Measured memory_bytes: 6764
#include <stdio.h>
long long max(long long x, long long y) {
	long long z;
	z = x;
	if (y > x)z = y;
	return z;
}
long long n, w;
long long a[200000];
long long dp[2][2];
long long e[2][2];
int main() {
	scanf("%lld", &n);
	for (long long i = 0; i < n; i++) {
		scanf("%lld", a + i);
	}
	for (long long i = 0; i < n; i++) {
		e[0][0] = dp[0][0];
		e[0][1] = dp[0][1];
		e[1][0] = dp[1][0];
		e[1][1] = dp[1][1];
		if (i % 2 == 0) {
			dp[0][0] = max(e[0][1], e[1][1]);
			dp[1][1] = e[0][1] + a[i];
			dp[1][0] = e[0][0] + a[i];
			dp[0][1] = -1000000000;
			dp[0][1] *= 1000000;
		}
		else {
			dp[0][0] = max(e[0][0], e[1][0]);
			dp[0][1] = max(e[0][1], e[1][1]);
			dp[1][1] = e[0][0] + a[i];
			dp[1][0] = -1000000000;
			dp[1][0] *= 1000000;
		}
	}
	if (n % 2) {
		printf("%lld\n", max(dp[0][0], dp[1][0]));
	}
	else printf("%lld\n", max(dp[0][1], dp[1][1]));
}


Measured memory_bytes: 3264
#include <iostream>

using namespace std;

int main(void) {
    int n;
    string words[1000]; // since max is 1000
    bool badWord = false;

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> words[i];
        if (!badWord && i > 0 && words[i - 1].back() != words[i].front()) {
            badWord = true; // last word last char is not same as new word first char
        }
        for (int j = i - 1; !badWord && j >= 0; --j) {
            if (words[i] == words[j]) {
                badWord = true;  // word is already said
                break;
            }
        }
    }

    if (badWord) {
        cout << "No";
    } else {
        cout << "Yes";
    }
    return 0;
}


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

void dfs(int n, int b, int rest, vector<int> block)
{
  block.push_back(b);
  if(!rest)
  {
    for(int i = 1; i < block.size() - 1; i++)
      cout << block[i] << " ";
    cout << block[block.size() - 1] << endl;
  }
  int ans = 0;
  for(int i = min(b, rest); i > 0; i--)
  {
    dfs(n + 1, i, rest - i, block);
  }
}

int main()
{
  int n;

loop:
  cin >> n;
  if(!n)
    return 0;
  dfs(0, n, n, vector<int>());
  goto loop;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n;
    cin >> n;
    set<ll> number_of_rows;
    REP(i, n) {
        ll tmp;
        cin >> tmp;
        number_of_rows.insert(tmp);
    }
    cout << number_of_rows.size() << endl;
    return 0;
}

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

using ll = long long;
// #define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
constexpr int MAX = 3*100000 + 5;
int w_from_left[MAX], e_from_right[MAX];
/***** MAIN *****/
signed main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  w_from_left[0] = 0, e_from_right[n-1] = 0;
  REPS(i,1,n) {
    w_from_left[i] = w_from_left[i-1];
    if(s[i-1] == 'W') ++w_from_left[i];
  }
  REPR(i,n-2) {
    e_from_right[i] = e_from_right[i+1];
    if(s[i+1] == 'E') ++e_from_right[i];
  }
  ll ans = MAX * 3;
  REP(i,n) {
    ll tmp = w_from_left[i] + e_from_right[i];
    ans = min(ans, tmp);
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


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

ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n % 2) res = res * a % mod;
    a = a * a % mod;
    n /= 2;
  }
  return res;
}

ll modcomb(ll p, ll q) {
  ll bunshi = 1, bumbo = 1;
  for (ll i = p; i > p-q; i--) bunshi = bunshi * i % mod;
  rep(i,q) bumbo = bumbo * (i+1) % mod;
  
  return bunshi * modpow(bumbo, mod-2) % mod;
}

int main() {
  ll x, y;
  cin >> x >> y;
  
  if ((x+y)%3 != 0) cout << 0 << endl;
  else {
    ll n = (2*y-x)/3;
    ll m = (2*x-y)/3;
    if (n < 0 || m < 0) cout << 0 << endl;
    else cout << modcomb(n+m, min(n,m)) << endl;
  }
}

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

int main(void)
{
    int a,b;
    char op;
    
    while(1)
    {
        cin >> a >> op >> b;
        if(op == '+') cout << a+b << endl;
        else if(op == '-') cout << a-b << endl;
        else if(op == '*') cout << a*b << endl;
        else if(op == '/') cout << a/b << endl;
        else break;
    }
    return 0;
}


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

int main(){
  string N;
  cin>>N;
  int n=N.size();
  int count0=0; int count1=0;
  
  for(int i=0;i<n;i++){
    if(N.at(i)=='0') count0++;
    else if(N.at(i)=='1') count1++;
  }
  int c=max(count0,count1);
  int d=min(count0,count1);
  
  cout<<n-(c-d);
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
const int M=300000;//M=1e6+100;
typedef long long int ll;
using namespace std;
 
ll n,i,j,t,cnt(0),x,y,ans(0),m,k(0);
 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin>>s;
	for(i=0;i<s.size();i++)
	{
		if(s[i]=='R')
		{
			cnt++;
		}else{
			cnt=0;
		}
		ans=max(ans,cnt);
	}
	cout<<ans;
}

Measured memory_bytes: 3668
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        char target = S.charAt(sc.nextInt() - 1);
        char[] array = new char[N];
        for (int i = 0; i < N; i++) {
            char curr = S.charAt(i);
            array[i] = (curr == target) ? target : '*';
        }
        System.out.println(new String(array));
    }
}


Measured memory_bytes: 21716
import numpy as np

n, k = map(int, input().split())
p = map(int, input().split())

e = np.array([(pi+1)/2 for pi in p])
es = np.array([sum(e[:k])] + [0]*(n-k))
for i in range(n-k):
  es[i+1] = es[i] - e[i] + e[i+k]

print(es.max())

Measured memory_bytes: 32396
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>


using namespace std;


using ll = long long;


const ll MAX = 100;


ll adj[MAX][MAX];
ll d[MAX] = {};
bool finished[MAX] = {};
ll n;


void msp()
{
    priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;
    pq.push(make_pair(0, 0));

    while (!pq.empty()) {
        auto p = pq.top(); pq.pop();
        if (finished[p.second])
            continue;

        for (ll j = 0; j < n; j++) {
            if (adj[p.second][j] == -1 || finished[j])
                continue;
            pq.push(make_pair(adj[p.second][j], j));
        }
        // cout << p.second << ": " << p.first << endl;
        d[p.second] = p.first;
        finished[p.second] = true;
    }
}


int main()
{
    cin >> n;
    for (ll i = 0; i < n; i++) {
        for (ll j = 0;j < n; j++) {
            cin >> adj[i][j];
        }
    }

    msp();

    ll acc = 0;
    for (ll i = 0; i < n; i++)
        acc += d[i];
    cout << acc << endl;
}



Measured memory_bytes: 3304
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cout << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int x, y;
  cin >> x >> y;
  cout << x + y / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

struct Edge {
	int to;
	int cost;
	int coin_cost;
	
	Edge(int to, int cost, int coin_cost) : to(to), cost(cost), coin_cost(coin_cost) {}
};

using ppi = pair <ll, pii>;

const int MAX = 55;
vector <Edge> adj[MAX];
int C[MAX], D[MAX];

int main()
{
	boost;
	int n, m, s, i;
	cin >> n >> m >> s;
	
	s = min(s, n * 50);
	fo(i, 0, m) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		adj[a].eb(b, d, c);
		adj[b].eb(a, d, c);
	}
	
	foe(i, 1, n)
	cin >> C[i] >> D[i];
	
	vector <vector <ll> > dp(n + 1, vector <ll> (n * 50, inf64));
	dp[1][s] = 0;
	
	priority_queue <ppi, vector <ppi>, greater <ppi> > pq;
	pq.emplace(0, mk(1, s));
	
	while(!pq.empty()) {
		ll curr_cost = pq.top().f;
		int node, coins;
		tie(node, coins) = pq.top().s;
		pq.pop();
		
		if(dp[node][coins] < curr_cost) continue;
		
		if(coins + C[node] < n * 50 && dp[node][coins + C[node]] > curr_cost + D[node]) {
			dp[node][coins + C[node]] = curr_cost + D[node];
			pq.emplace(curr_cost + D[node], mk(node, coins + C[node]));
		}
		
		for(Edge &e : adj[node]) {
			if(coins < e.coin_cost) continue;
			if(dp[e.to][coins - e.coin_cost] > curr_cost + e.cost) {
				dp[e.to][coins - e.coin_cost] = curr_cost + e.cost;
				pq.emplace(curr_cost + e.cost, mk(e.to, coins - e.coin_cost));
			}
		}
	}
	for(int i = 2; i <= n; i++)
	cout << *min_element(dp[i].begin(), dp[i].end()) << '\n';
}


Measured memory_bytes: 6240
#include <iostream>

int main() {
  int c5 = 0, c7 = 0;
  for (int i = 0; i < 3; ++i) {
    int x;  std::cin>>x;
    if (x == 5)
      c5++;
    else if (x == 7)
      c7++;
  }
  std::cout<<(c5 == 2 and c7 == 1 ? "YES" : "NO")<<"\n";

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define pb push_back
bool isPrime(ll n) 
{ 
   
   if (n <= 1)  return false; 
   if (n <= 3)  return true; 
 
   if (n%2 == 0 || n%3 == 0) return false; 
 
   for (ll i=5; i*i<=n; i=i+6) 
       if (n%i == 0 || n%(i+2) == 0) 
          return false; 
 
   return true; 
} 
ll minthis(ll a, ll b){
if(a < b){
return a;
}
return b;
}
ll maxthis(ll a, ll b){
if(a > b){
return a;
}
return b;
}
int gcd(int a, int b){
   if( a<0 ) a = -a;
   if( b<0 ) b = -b;
   while( b!=0 ){
       a %= b;
       if( a==0 ) return b;
       b %= a;
   }
   return a;
}
 
int findLargestDivisor(int n) 
{ 
int max = 1;
   for (int i = 2; i < n; i++) {        
       if(n %(i) == 0) { 
           max = i;
       } 
    }
   return max;     
} 
 
 
ll power(ll x, ll y)  
{  
   ll temp;  
   if(y == 0)  
       return 1;  
   temp = power(x, y / 2);  
   if (y % 2 == 0)  
       return temp * temp;  
   else
   {  
       if(y > 0)  
           return x * temp * temp;  
       else
           return (temp * temp) / x;  
   }  
} 
bool sortbysec(const pair<int, int>& a, 
               const pair<int, int>& b) 
{ 
   return (a.second < b.second); 
} 



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

	}

}

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




Measured memory_bytes: 4780
/*
 * ID: ITP1_6_C
 * Problem: Official house
 */

#include <stdio.h>

int main(void)
{
    int map[4 + 1][3 + 1][10 + 1] = {};

    int n;
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        int build, floor, room, person;
        scanf("%d %d %d %d", &build, &floor, &room, &person);
        map[build][floor][room] += person;
    }


    for (int i = 1; i <= 4; i++) {
        for (int j = 1; j <= 3; j++) {
            for (int k = 1; k <= 10; k++)
                printf(" %d", map[i][j][k]);
            puts("");
        }
        if (i != 4) {
            for (int j = 0; j < 20; j++)
                putchar('#');
            puts("");
        }
    }

    return 0;
}



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

using namespace std;

using int64 = long long;

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  bool unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k)
  {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k)
  {
    return (-data[find(k)]);
  }
};

int main()
{
  int N, M, K, C[100000];

  cin >> N >> M >> K;
  int id = K;
  for(int i = 0; i < N; i++) {
    cin >> C[i];
    --C[i];
    if(C[i] == -1) C[i] = id++;
  }

  UnionFind uf(N + K);
  vector< tuple< int, int, int > > es;

  for(int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    es.emplace_back(c, C[a], C[b]);
  }

  sort(begin(es), end(es));
  int connect = 0;
  int64 ret = 0;

  for(auto &e : es) {
    int a, b, c;
    tie(c, a, b) = e;
    if(uf.unite(a, b)) {
      ++connect;
      ret += c;
      if(connect == K - 1) {
        break;
      }
    }
  }
  if(connect == K - 1) cout << ret << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
#define spln(i,n) (i==n?'\n':' ')
using namespace std;
int n,m;
int main()
{
	cin>>n>>m;
	if(n==0){
		cout<<abs(m)+(m<0);
		return 0;
	}
	if(m==0){
		cout<<abs(n)+(n>0);
		return 0;
	}
	if(n>=0&&m>=0){
		if(n<=m) cout<<m-n; else cout<<n-m+2;
		return 0; 
	}
	if(n>=0&&m<0){
		cout<<abs(m+n)+1;
		return 0; 
	}
	if(n<0&&m>=0){
		cout<<abs(m+n)+1;
		return 0; 
	}
	if(n<0&&m<0){
		n*=-1;m*=-1;swap(n,m);
		if(n<=m) cout<<m-n; else cout<<n-m+2;
		return 0; 
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long li;
#define ceil(n,a) ((((n)+(a)-1)/(a))*(a))
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  int n; cin >>n;
  vector<li> a(n);
  rep(i,n) cin >> a[i];
  reverse(a.begin(),a.end());
  li mi=2,ma=3;
  rep(i,n){
    mi=ceil(mi,a[i]);
    ma=ceil(ma,a[i]);
  }
  if(mi==ma)print(-1);
  else print(mi,ma-1);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int,int > pp;
typedef long long ll;
 
int const N=1e5+2,oo=1e9;
ll const OO=2e18;
double const eps=1e-8,PI=acos(-1);
int mod=oo+7;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    if(((n+1)/2)>=k)cout<<"YES";
    else cout<<"NO";
    return 0;
}



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

using namespace std;
using LL = long long;

constexpr int N = 1e5 + 5;

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

    LL a, b;
    cin >> a >> b;
    cout << a / __gcd(a, b) * b << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
constexpr lnt INF = 2e18;
struct FIO{FIO(){std::cin.tie(0);std::ios_base::sync_with_stdio(0);}}fIO;
/*-*/

int main() {
	int n,k;
	std::cin >> n >> k;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	rep(i,n) a[i]--;
	int count=0;
	if(a[0]!=0) count++;
	std::vector<std::vector<int> > g(n);
	rep(i,n) {
		if(i==0) continue;
		g[a[i]].emplace_back(i);
	}
	auto dfs = [&](auto f, int i, int par) -> int {
		int max=0;
		for(auto to:g[i]) {
			max=std::max(max,f(f,to,i));
		}
		if(par!=0&&max+1==k) {
			count++;
			return 0;
		}
		return max+1;
	};
	dfs(dfs,0,0);
	print(count);
}


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

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

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

    double ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans += 1.0 / double(A[i]);
    }

    ans = 1.0 / ans;

    cout << fixed << setprecision(10) << ans << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <cctype>
#include <iostream>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
int size(string x){
	string::size_type size=x.size();
	return size;
}
#define fu(l,k) for(int i=l;i<k;i++)
#define fd(l,k) for(int i=l;i>k;i--)
#define sort(ss) sort(ss.begin(), ss.end())
#define rsort(ss) sort(ss.rbegin(), ss.rend())
typedef  vector<string> vs;
typedef  vector<int> vi;
double pi(){
	return M_PI;
}
typedef set<int> set_i;
typedef set<string> set_s;
int INF=1000000;
int main(){
	long long int x[10]={};
	long long int w;
	while(cin>>w){
		for(int i=0;i<10;i++){
			if(i!=0){
				x[i]=w/(1000000000/(pow(10,i)));
				w=w-x[i]*1000000000/(pow(10,i));
			}
			else{
				x[i]=w/1000000000;
				w=w-x[i]*1000000000;
			}
		}
		for(int i=0;i<9;i++){
			for(int e=0;e<9;e++){
				x[e]=(x[e]+x[e+1])%10;
			}
		}
		cout<<x[0]<<endl;
	}
}

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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	int N, K; cin >> N >> K;
	vector<int> h(N);
	REP(i,N) cin >> h[i];
	SORT(h);

	int l = 0, r = K - 1;
	int ans = 1 << 30;
	REP(i,N-K+1){
		
		ans = min(ans, h[r] - h[l]);
		l++;
		r++;

	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>

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

using namespace std;

const int INF=1<<29;

inline int popcount(int x){
	x=((x>>1)&0x55555555)+(x&0x55555555);
	x=((x>>2)&0x33333333)+(x&0x33333333);
	x=((x>>4)+x)&0x0f0f0f0f;
	x+=(x>>8);
	x+=(x>>16);
	return x&0x3f;
}

int main(){
	for(int n,m,n_jiro,s,T;scanf("%d%d%d%d%d",&n,&m,&n_jiro,&s,&T),n;){
		s--;

		static int d[300][300];
		rep(u,n) rep(v,n) d[u][v]=(u==v?0:INF);
		rep(i,m){
			int u,v,cost; scanf("%d%d%d",&u,&v,&cost); u--; v--;
			d[u][v]=d[v][u]=cost;
		}

		int jiro[17],eat[17]; // index 0 is starting point
		jiro[0]=s;
		eat[0]=0;
		rep(i,n_jiro){
			scanf("%d%d",jiro+i+1,eat+i+1);
			jiro[i+1]--;
		}
		n_jiro++;

		// Warshall-Floyd
		rep(w,n) rep(u,n) rep(v,n) d[u][v]=min(d[u][v],d[u][w]+d[w][v]);

		static int dp[17][1<<17]; // dp[last visited jiro][eaten jiro] := minimum time
		rep(i,n_jiro) rep(S,1<<n_jiro) dp[i][S]=INF;
		dp[0][1]=0;
		rep(S,1<<n_jiro) rep(i,n_jiro) if(S&(1<<i)) {
			rep(j,n_jiro) if(!(S&(1<<j))) {
				dp[j][S|(1<<j)]=min(dp[j][S|(1<<j)],dp[i][S]+d[jiro[i]][jiro[j]]+eat[j]);
			}
		}

		int ans=0;
		rep(i,n_jiro) rep(S,1<<n_jiro) if(dp[i][S]+d[jiro[i]][s]<=T) ans=max(ans,popcount(S)-1);
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 10084
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
const ll MAX = 200010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    vector<ll> x(n);
    cins(all(x));
    vector<ll> mod(m,0);
    SORT(x);
    rep(i,n){
        mod[x[i]%m]++;
    }
    ll k = -1,cnt = mod[0]/2;
    if (m%2 == 0) k = m/2;
    rep(i,1,m/2+1){
        if (i == k){
            cnt += mod[i]/2;
        }
        else{
            cnt += min(mod[i],mod[m-i]);
        }
    }
    //array_output(all(mod));
    //PRINT(cnt);
    ll index = 0;
    while(index < n-1){
        if (x[index] == x[index+1]){
            ll s = x[index]%m;
            if (s == k || s == 0){
                index++;
                continue;
            }
            if (mod[s]-mod[m-s] >= 2){
                cnt++;
                mod[s] -= 2;
            }
            index += 2;
        }
        else{
            index++;
        }
    }
    PRINT(cnt);
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
   
 int x,ans=0;
 rep(i,5){
     cin >> x;
     ans ++;
     if(x==0)
     cout << ans << endl;

 }
 return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>

using namespace std;

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

int main(){
  int n,i;
  int a;
  int t=0;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>a;
    t+=a-1;
  }
  cout<<t<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 2000002

void MaxHeapify(int *, int);
void Insert(int *, int);
void Extract(int *);

int h = 0;

int main(){
  int a[N], key;
  int i = 0, j;
  char order[8];

  while( 1 ){
      scanf("%s", order);
      if(order[2] == 'd') break;
      else if(order[0] == 'i'){
	scanf("%d", &key);
	Insert(a, key);
      }
      else Extract(a);
  }


  return 0;
}

void MaxHeapify(int *a, int i){
  int left, right, large, change;

  if(i * 2 <= h) left = i * 2;
  else left = i;
  if(i * 2 + 1 <= h) right = i * 2 + 1;
  else right = i;


  if(left < h + 1 && a[left] > a[i]) large = left;
  else large = i;
  if(right < h + 1 && a[right] > a[large]) large = right;
  
  if(large != i){
    change = a[i];
    a[i] = a[large];
    a[large] = change;
    MaxHeapify(a, large);
  }
}

void Insert(int *a, int key){
  int i, change;

  h++;
  i = h;
  a[i] = key;
  while(i > 1 && a[i / 2] < a[i]){
    change = a[i];
    a[i] = a[i / 2];
    a[i / 2] = change;
    i /= 2;
  }
}

void Extract(int *a){
  int max;

  max = a[1];
  a[1] = a[h];
  h--;
  MaxHeapify(a, 1);

  printf("%d\n", max);
}

Measured memory_bytes: 5148
N = int(input())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))


p = 0

for i in range(N):
  p += B[i]
#  print(i,p)
  
  if i == N-1:
    continue
    
  if A[i+1] == A[i] + 1:
    p += C[A[i]-1]
#  print(i,p)
  
print(p)  
  



Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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




int main(){
    int N; cin >> N;
    cout << (N - 2) * 180 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector <int> A(N+5);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        A.at(i) = a;
    }
    int sigma = 0;
    for (int i = 0; i < N; i++) {
        sigma += A.at(i);
    }
    int x;
    x = sigma / N;
    int cost1 = 0;
    for (int i = 0; i < N; i++) {
         cost1 += (A[i] - x)*(A[i] - x);
    }

    int cost2 = 0;
    for (int i = 0; i < N; i++) {
        if (x >= 0) {
            cost2 += (A[i] - x - 1)*(A[i] - x -1);
        } else if ( x < 0) {
            cost2 += (A[i] -x + 1)*(A[i] - x + 1);
        }
    }

    int cost = min( cost1, cost2);
    
    cout << cost << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	string s;
    cin>>s;
    cout<<s[0]<<s[1]<<s[2];
}


Measured memory_bytes: 3624
n, k = list(map(int, input().split()))
ans = [0] * (n)
for i in range(k):
    di = int(input())
    for ai in list(map(int, input().split())):
        ans[ai-1] += 1
cnt = 0 
for i in range(len(ans)):
    if ans[i] == 0:
        cnt += 1
print(cnt)

    

Measured memory_bytes: 9184