akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;

ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

bool vector_find(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
    if (index != vec.size()) {
        return true;
    }
    else {
        return false;
    }
}

vector<string> split(const string& src, const char* delim = ":") {
    vector<string> vec;
    string::size_type len = src.length();
    
    for (string::size_type i = 0, n; i < len; i = n + 1) {
        n = src.find_first_of(delim, i);
        if (n == string::npos) {
            n = len;
        }
        vec.push_back(src.substr(i, n - i));
    }
    
    return vec;
}

int main(int argc, char *argv[]){
    ll result = 0;
    ll A, B;
    cin >> A >> B;
    if(A >= 13){
        result = B;
    } else if(A <= 5){
        result = 0;
    } else{
        result = B / 2;
    }
    
    cout << result << endl;
}





Measured memory_bytes: 256
X = int(input())

Data = [0]*(X+1)
Data[0] = 1

for c in range(100,106):
    for i in range(X+1):
        if Data[i] == 1:
            n = 1
            while c*n + i <= X:
                Data[c*n+i] = 1
                n+=1
if Data[X] == 1:
    print(1)
else:
    print(0)


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)

int main() {
	int a, b;
	cin >> a >> b;
	int isfalse[4] = {0};
	isfalse[a] = 1;
	isfalse[b] = 1;
	FOR(i, 1, 3) {
		if (!(isfalse[i])) {
			cout << i << endl;
		}
	}
}

Measured memory_bytes: 3600
from fractions import gcd


def primes(N):
    p = [False, False] + [True] * (N - 1)
    for i in range(2, int(N ** 0.5) + 1):
        if p[i]:
            for j in range(i * 2, N + 1, i):
                p[j] = False
    ret = [i for i in range(N + 1) if p[i]]
    return ret


def trial_division(N):
    factors = []
    for p in primes(int(N ** 0.5)):
        while N % p == 0:
            factors.append(p)
            N //= p
    if N > 1:
        factors.append(N)
    return factors


A, B = map(int, input().split())
g = gcd(A, B)
print(len(set(trial_division(g))) + 1)


Measured memory_bytes: 20600
#include<stdio.h>

int numberOfCar(long p, int n, int w[]) {
  long car = p;
  int count = 1;
  for (int i = 0; i < n; i++) {
    if (p < w[i]) return n+1;
    if (car - w[i] < 0) {
      count++;
      car = p;
      i--;
    } else {
      car -= w[i];
    }
  }
  return count++;
}

int main() {
	int n,k;
  scanf("%d %d", &n, &k);
  int w[n];
  for ( int i = 0; i < n; i++ ) scanf("%d", &w[i]);

  long left = 0L;
  long right = 100000*100000L;
  while (left != right) {
    long mid = (left+right)/2;
    if (numberOfCar(mid, n, w) <= k) {
      right = mid;
    } else {
      left = mid+1;
    }
  }

  printf("%lu\n", left);

  return 0;
}



Measured memory_bytes: 3116
import java.util.*;


public class Main{ 
	   public static void main(String args[]) {
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int one=0;
		int two=0;
		int three=0;
		for(int i=1;i<=n;i++) {
			int num=s.nextInt();
			if(num==1)
				one++;
			else if(num==2)
				two++;
			else
				three++;
		}
		
		
		double dp[][][]=new double[n+1][n+1][n+1];
		
		for(int i=0;i<=n;i++) {
			 	for(int j=0;j<=n;j++) {
			 		for(int k=0;k<=n;k++) {
			         dp[i][j][k]=-1;
			        }
		        }
	    }

    double ans=f(dp,one,two,three,n);
		System.out.print(ans);
	   }
	   
   public static double f(double dp[][][],int x,int y,int z,int n) {
	  if(x==0 && y==0 && z==0) {
		  return 0;
	  }
	  if(x<0 || y<0 || z<0) {
		  return 0;
	  }
	  if(dp[x][y][z]>-0.9) {
		  return dp[x][y][z];
	  }
	   
	   double exp=n + x*f(dp,x-1,y,z,n)+ y*f(dp,x+1,y-1,z,n)+z*f(dp,x,y+1,z-1,n);
	   return dp[x][y][z]=exp/(x+y+z);
   }
}

Measured memory_bytes: 279816
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

int A[3][3];
bool check[3][3];

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

    rep(i, 3) rep(j, 3) cin >> A[i][j];

    int N;
    cin >> N;
    rep(k, N) {
        int b;
        cin >> b;
        rep(i, 3) rep(j, 3) {
            if (A[i][j] == b) {
                check[i][j] = true;
            }
        }
    }

    bool bingo = false;
    rep(i, 3) {
        if (check[i][0] && check[i][1] && check[i][2]) 
            bingo = true;
    }
    rep(i, 3) {
        if (check[0][i] && check[1][i] && check[2][i]) 
            bingo = true;
    }
    if (check[0][0] && check[1][1] && check[2][2]) 
        bingo = true;
    if (check[2][0] && check[1][1] && check[0][2]) 
        bingo = true;


    cout << (bingo ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
ll M = 100000000;

ll gap(ll a, ll b, ll c){
  ll m[3] = {a,b,c};
  sort(m,m+3);
  return m[2] - m[0];
}

ll half(ll s, ll h, ll w){
  if((h*w)%2==0){
    return abs(s - h*w/2);
  }else{
    return min(gap(s,h*(w-1)/2,h*(w+1)/2), gap(s,(h-1)*w/2,(h+1)*w/2));
  }
}

int main(){
  ll H, W;
  cin >> H >> W;

  ll ans = M;
  for(ll i=1;i<=H;i++){
    ans = min(ans, half(W*i,H-i,W));
  }
  for(ll i=1;i<=W;i++){
    ans = min(ans, half(H*i,H,W-i));
  }
 
  cout << ans <<endl;

  return 0;
}









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

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NEAL_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif


const int DIRS = 4;
const int DR[DIRS] = {-1,  0, +1,  0};
const int DC[DIRS] = { 0, +1,  0, -1};

int N;
vector<vector<int>> dist;
vector<vector<bool>> remaining;

bool valid(int r, int c) {
    return 0 <= r && r < N && 0 <= c && c < N;
}

void propagate(int row, int col, int new_dist) {
    assert(new_dist < dist[row][col]);
    dist[row][col] = new_dist;

    for (int dir = 0; dir < DIRS; dir++) {
        int nr = row + DR[dir];
        int nc = col + DC[dir];

        if (valid(nr, nc) && new_dist + remaining[nr][nc] < dist[nr][nc])
            propagate(nr, nc, new_dist + remaining[nr][nc]);
    }
}

void propagate_bfs(int row, int col) {
    queue<array<int, 3>> q;

    auto &&bfs_check = [&](int r, int c, int new_dist) {
        if (new_dist < dist[r][c]) {
            dist[r][c] = new_dist;
            q.push({r, c, new_dist});
        }
    };

    bfs_check(row, col, dist[row][col] - 1);

    while (!q.empty()) {
        array<int, 3> top = q.front(); q.pop();

        for (int dir = 0; dir < DIRS; dir++) {
            int nr = top[0] + DR[dir];
            int nc = top[1] + DC[dir];

            if (valid(nr, nc))
                bfs_check(nr, nc, top[2] + remaining[nr][nc]);
        }
    }
}

void decrement(int row, int col) {
    remaining[row][col] = false;
    // propagate(row, col, dist[row][col] - 1);
    propagate_bfs(row, col);
}

int main() {
    ios::sync_with_stdio(false);
#ifndef NEAL_DEBUG
    cin.tie(nullptr);
#endif

    cin >> N;
    dist.assign(N, vector<int>(N));
    remaining.assign(N, vector<bool>(N, true));

    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            dist[i][j] = min({i, N - 1 - i, j, N - 1 - j});

    int total = 0;

    for (int i = 0; i < N * N; i++) {
        int p;
        cin >> p;
        p--;
        int row = p / N, col = p % N;
        total += dist[row][col];

        if (dist[row][col] > 0)
            dbg(row, col, dist[row][col]);

        decrement(row, col);
    }

    cout << total << '\n';
}


Measured memory_bytes: 4720
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef tuple<double,ll,ll> t3;

using namespace std;

set<pii> c[300000];
map<char,vector<int>> table;

void solve()
{
    string s;
    cin >> s;
    ll n = (ll)s.length();
    for(int i = 0;i < n;i++)
    {
        table[s[i]].push_back(i);
    }
    if(n == 1)
    {
        cout << 1 << endl;
        return;
    }
    ll sub = 0;
    for(auto e : table)
    {
        ll nn = (ll)e.second.size();
        sub += nn * (nn-1) / 2;
    }
    ll sum = n * (n-1) / 2 + 1;
    sum -= sub;
    cout << sum << endl;
}

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

Measured memory_bytes: 16252
#include<bits/stdc++.h>
using namespace std;
int main(){
  int dp[100001], n, a[100001];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  dp[0]=0;
  for(int i=1;i<n;i++){
    dp[i]=1e9;
  }
  for(int i=0;i<n-1;i++){
    dp[i+1]=min(dp[i+1],dp[i]+abs(a[i]-a[i+1]));
    dp[i+2]=min(dp[i+2],dp[i]+abs(a[i]-a[i+2]));
  }
  cout<<dp[n-1]<<"\n";
}
  

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

#define ll long long
#define pb push_back
#define fi first
#define se second

/** Dateloper */

using namespace std;

const int mod = 1e9+7;
const int maxn = 1000 * 1000 + 10;

int main()
{
    string s;
    int n;
    cin>>n;
    cin>>s;
    string b="ABC";
    int ans=0;
    for(int i =0;i<=s.size()-3;i++){
        string tmp=s.substr(i,3);
        if(tmp==b)
            ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define mp make_pair
ll mod = 1000000007;
ll mod2 = 998244353;

int main(){
	int n;cin>>n;
    vector<ll> a(n);
    rep(i,0,n) cin>>a[i];
    ll sum = 1;
    sort(a.begin(),a.end());
    if (a[0]==0){
        cout<<0<<endl;
    }else{
        rep(i,0,n){
            if (sum>(1000000000000000000/a[i])){
                sum = -1;
                break;
            }else{
                sum*=a[i];
            }
        }
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 4092
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

long long n, q;
string s;
vector<pair<char, char>> v;

long long solve();

int main() {
  cin >> n >> q;
  cin >> s;
  v.resize(q);
  for(int i = 0; i < q; ++i)
    cin >> v[q - 1 - i].fi >> v[q - 1 - i].se;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long l = 0, r = n - 1;
  for(int i = 0; i < q; ++i) {
    if(l < n && v[i].fi == s[l] && v[i].se == 'L') ++l;
    if(r >= 0 && v[i].fi == s[r] && v[i].se == 'R') --r;
    if(l > 0 && s[l - 1] == v[i].fi && v[i].se == 'R') --l;
    if(r < n - 1 && s[r + 1] == v[i].fi && v[i].se == 'L')
      ++r;
  }
  return max(0LL, r - l + 1);
}

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

 using namespace std;

 int main() {
   vector<int> N(4);

   cin >> N.at(0) >> N.at(1) >> N.at(2) >> N.at(3);

   sort(N.begin(), N.end());

   if (N.at(0) == 1 && N.at(1) == 4 && N.at(2) == 7 && N.at(3) == 9) cout << "YES" << endl;
   else cout << "NO" << endl;
 }


Measured memory_bytes: 768
import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )

readInt :: IO Int
readInt = fst . fromJust . C.readInt <$> C.getLine

main :: IO ()
main = do
  n <- readInt
  print $ g n

g = (2^) . floor . logBase 2 . fromIntegral

f :: Int -> Int
f n = head . filter (<= n) $ [2^i | i<-[6,5 .. 0]]

Measured memory_bytes: 380
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T> *A) {
  for (auto itr = A->begin(); itr < A->end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(vector<T> *A) {
  for (auto itr = A->begin(); itr < A->end(); ++itr) cout << *itr << " ";
  cout << endl;
}

static inline void MainTask() {
  double W, H, x, y;
  cin >> W >> H >> x >> y;
  if (x == (W / 2) && y == (H / 2)) {
    cout << W * H / 2 << " " << 1 << endl;
  } else {
    cout << W * H / 2 << " " << 0 << endl;
  }
}

int main() {
  MainTask();

  return 0;
}


Measured memory_bytes: 256
N, M= [int(i) for i in input().split()]
SCm =[[int(i) for i in input().split()] for _ in range(M)]

results = [-1 for _ in range(N)]
impossible = False
for sc in SCm:
  s, c = sc
  if results[s-1] != -1:
    if results[s-1] != c:
      impossible =True
      break
  else:
    results[s-1] = c
if (N > 1) and (results[0] == 0):
  impossible = True
if impossible:
  print(-1)
else:
  if N > 1:
    results[0] = max(results[0], 1)
  print(int("".join([str(s if s >=0 else 0) for s in results])))



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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  LL n;
  Solver(LL n) : n(n){};

  void solve() {
    LL ans = 0;
    for (LL k = 1; k * k + k < n; ++k) {
      if ((n - k) % k == 0) ans += (n - k) / k;
    }
    cout << ans << endl;
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


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

int main(){
    vector<char> c(6);
    for(int i=0; i<6; i++) cin >> c[i];
    if(c[0] == c[5] && c[1] == c[4] && c[2] == c[3]) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <vector>
#include <map>

using namespace std;

vector<pair<long long, int>> num_list;
map<int, long long> color_count;

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

	int X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;

	for (int i = 0; i < A; i++)
	{
		long long value;
		cin >> value;

		num_list.push_back(make_pair(value, 1));
	}

	for (int i = 0; i < B; i++)
	{
		long long value;
		cin >> value;

		num_list.push_back(make_pair(value, 2));
	}

	for (int i = 0; i < C; i++)
	{
		long long value;
		cin >> value;

		num_list.push_back(make_pair(value, 0));
	}

	sort(num_list.begin(), num_list.end());

	long long result = 0;
	for (auto it = num_list.rbegin(); it != num_list.rend(); it++)
	{
		if (color_count[1] + color_count[2] + color_count[0] == X + Y) break;

		long long curr_value = it->first;
		int curr_color = it->second;

		if (curr_color == 1 && color_count[1] >= X) continue;
		else if (curr_color == 2 && color_count[2] >= Y) continue;

		color_count[curr_color]++;
		result += curr_value;
	}

	cout << result;

	return 0;
}


Measured memory_bytes: 10604
fun MutableList<Int>.swap(index1: Int, index2: Int) {
    val tmp = this[index1] // 'this' corresponds to the list
    this[index1] = this[index2]
    this[index2] = tmp
}

fun main (args:Array<String>) {
    val list = readLine()!!.split(" ").map(String::toInt).toMutableList()

    list.swap(0,1)
    list.swap(0,2)
    var (a,b,c) = list.map(Int::toString)
    print("${a} ${b} ${c}")


}


Measured memory_bytes: 36424
N, Q = map(int, input().split())
s = input()
t, d = zip(*(input().split() for _ in range(Q)))


def f(i):
    i -= 1
    if i < 0:
        return -1
    if i >= N:
        return 1
    for j in range(Q):
        if s[i] == t[j]:
            i += 1 if d[j] == 'R' else -1
        if i < 0:
            return -1
        elif i >= N:
            return 1
    return 0


h, l = N + 1, 1
while h > l:
    i = (h + l) // 2
    r = f(i)
    if r == 1:
        h = i
    else:
        l = i + 1

ans = N - h + 1

h, l = N, 0
while h > l:
    i = (h + l + 1) // 2
    r = f(i)
    if r == -1:
        l = i
    else:
        h = i - 1

ans = N - ans - l

print(ans)


Measured memory_bytes: 120496
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = input()[:-1]

su = 0

for i in range(len(n)):
    su += int(n[i])
if su % 9 == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 68608
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    cin.tie(0);cout.tie(0);
    ios::sync_with_stdio(false);
    ll N;cin>>N;
    ll a=0,b=0,c=0;
    ll ans=1;
    rep(i,N){
        ll A;cin>>A;
        if(A==a and A==b and A==c)ans*=3,a++;
        else if(A==a and A==b)ans*=2,a++;
        else if(A==a)a++;
        else if(A==b and A==c)ans*=2,b++;
        else if(A==b)b++;
        else if(A==c)c++;
        else{
            cout<<0<<endl;
            return 0;;
        }
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n, k = map(int,input().split())
d_l = []
a_l = []
for _ in range(k):
    d_l.append(int(input()))
    a_l.append(list(map(int,input().split())))

sunuke = [1]*n
for i in range(k):
    for j in range(len(a_l[i])):
        num = a_l[i][j]
        sunuke[num-1] = 0

ans = 0
for val in sunuke:
    ans += val
print(ans)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    string s, t;
    cin >> s >> t;
    
    map<char, char> mp1, mp2;
    REP(i, s.size()){
        auto itr = mp1.find(s[i]);
        if(itr == end(mp1)) mp1[s[i]] = t[i];
        else if(mp1[s[i]] != t[i]){
            cout << "No" << endl;
            return 0;
        }

        itr = mp2.find(t[i]);
        if(itr == end(mp2)) mp2[t[i]] = s[i];
        else if(mp2[t[i]] != s[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 916
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int main() {
	//string s[100], res = "";
	int N, M;
	int a[60],b[60], res[60] = { 0 };
	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		cin >> a[i] >> b[i];
		res[a[i]-1] += 1;
		res[b[i]-1] += 1;
	}
	for (int i = 0; i < N; ++i) {
		cout << res[i] << endl;
	}
	return 0;

}


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

int main(){

int n,m;
cin>>n>>m;
char s1[n][n];
char s2[m][m];
for(int i=0;i<n;i++){
	for(int j=0;j<n;j++){
		cin>>s1[i][j];
	}
}
for(int i=0;i<m;i++){
	for(int j=0;j<m;j++){
		cin>>s2[i][j];
	}
}
for(int c1=0;c1<n-m+1;c1++){
	for(int c2=0;c2<n-m+1;c2++){
	bool f=true;
	for(int i=0;i<m;i++){
	for(int j=0;j<m;j++){
		if(s1[i+c1][j+c2]!=s2[i][j]){
			f=false;
			break;
		}
		if(f==false)
		break;
	}
}
if(f){
	cout<<"Yes"<<"\n";
	return 0;
}
	}
}
cout<<"No"<<"\n";

return 0;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define P pair<int,int>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define re(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007;
int n;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n;
    cin>>n;
    int a[n];
    double kai=0.0;
    rep(i,n){
        cin>>a[i];
        kai+=1.0/a[i];
    }
    kai=1.0/kai;
    cout<<kai<<endl;
}

Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.*;
import java.util.Scanner ; 
import java.math.BigInteger;
import java.util.Arrays;
import java.text.DecimalFormat;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int [] a = new int[10];
        int n;
        
        for(int i = 0 ; i<10 ; i++){
            n = sc.nextInt();
            a[i]=n;
        }
        Arrays.sort(a);
        System.out.println(a[9]+"\n"+a[8]+"\n"+a[7]);
    }
}

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

#define W 1000
#define H 1000
#define Q 1000000007

int dp[H+1][W+1];

int main(void){
  int mp[H+2][W+2];
  int h,w;
  
  cin >> h >> w;
  for (int i=0; i<=w; i++) mp[0][i] = 1;
  for (int i=1; i<=h; i++){
    string buf; cin >> buf;
    mp[i][0] = 1;
    for (int j=1; j<=w; j++){
      mp[i][j] = buf[j-1]=='#'?1:0;
    }
  }
  
  dp[1][1] = 1;
  for (int i=1; i<=h; i++){
    for (int j=1; j<=w; j++){
      if (i==1 && j==1) continue;
      dp[i][j] = 0;
      if (mp[i][j]==1) continue;
      if (mp[i][j-1]==0) dp[i][j] += dp[i][j-1];
      if (mp[i-1][j]==0) dp[i][j] += dp[i-1][j];
      dp[i][j] %= Q;
    }
  }
  cout << dp[h][w] << endl;
  return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define LIM 1000007
#define ll long long
using namespace std;
bool v[10];
bool badnum(ll n) {
  int k = n;
  while (k != 0) {
    if (v[k % 10]) {
      return true;
    }
    k /= 10;
  }
  return false;
}
int main() {
  ll n, k;
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    int a;
    cin >> a;
    v[a] = true;
  }
  while (badnum(n)) {
    n++;
  }
  cout << n << endl;
  return 0;
}


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

int main(){
    int n;
    std::cin >> n;
    
    //std::vector<int> v = {0};
    int ans = 0;
    for(int i = 1; i <= n; i += 2){
        int num = 1;
        for(int j = 1; j <= i/2; j++){
            if(i%j == 0) num++;
        }
        if(num == 8) ans++;
    }
    std::cout << ans << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;


int main()
{
    ll n,h;
    cin >> n >> h;
    vector<ll> a(n);
    vector<ll> b(n);
    ll sum=0;
    ll m=-1;
    rep(i,n){
        cin >> a[i] >> b[i];
        m=max(m,a[i]);
    }
    ll cnt=0; //投げ捨てるべきb[i]の数
    rep(i,n){
        if(b[i]>m){
            cnt++;
            sum+=b[i];
        }
    }
    ll ans=0;
    sort(b.rbegin(),b.rend());
    if(h<=sum){
        rep(i,cnt){
            h-=b[i];
            ans++;
            if(h<=0){
                break;
            }
        }
    }
    else{
        h-=sum;
        if(h%m==0){
            ans=h/m+cnt;
        }
        else{
            ans=h/m+1+cnt;
        }
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 1792
#define watch5(a,b,c,d,e) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d << " | "<<#e<<": "<<e<<endl;
#define watch4(a,b,c,d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define watch3(a,b,c) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<endl;
#define printclock cerr<<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<" sec\n";
#define sharingan cerr << "\n-------------------------------------------\n\n";
#define watch2(a,b) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<< endl;
#define Yup ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define watch(a) cerr <<#a<<": "<<a<<endl;
#define __gcd(a, b) __algo_gcd(a, b)
#define PI 3.14159265358979323846

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

#define endl "\n"
#define int long long

int ar[1000000];
int dp[1000000];

int f( int i, int n ){
    if( i == n )return 0;
    if( dp[i] != -1 )return dp[i];
    int cost = abs(ar[i] - ar[i+1]) + f(i+1, n);
    if( i+2 <= n ){
        cost = min(cost, abs(ar[i]-ar[i+2]) + f(i+2, n));
    }
    return dp[i] = cost;
}

int32_t main(){
    int n;
    cin >> n;
    for( int i = 1; i <= n; i++ ){
        cin >> ar[i];
    }
    memset(dp, -1, sizeof(dp));
    cout << f(1, n);
} 


Measured memory_bytes: 15104
#pragma comment(linker, "/STACK:36777216")
#include <bits/stdc++.h>

#define FOR(VAR,ST,END) for(int VAR=ST; VAR<END; ++VAR)
#define FORI(VAR,ST,END) for(int VAR=ST; VAR<=END; ++VAR)
#define ROF(VAR,ST,END) for(int VAR=ST; VAR>END; --VAR)
#define ROFI(VAR,ST,END) for(int VAR=ST; VAR>=END; --VAR)
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define MAXI(a,b) (a=(a>b?a:b))
#define MINI(a,b) (a=(a<b?a:b))
#define ABS(a) (a>0?a:-a)
#define MINI_NZ(a,b) {if(a==0) a = b; else a = a<b?a:b;}
#define SWAP_IF(type,x,y,cond) if(cond) {type tmp=x; x=y; y=tmp;}
#define SWAP(type,x,y) {type tmp=x; x=y; y=tmp;}
#define LL long long
#define ULL unsigned long long
#define INF 0x3f3f3f3f
#define MAX_NP1 (MAX_N+1)

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << MIN(a, b) + MIN(c, d) << endl;
    return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

z = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i + 100*j + 50*k == x:
        z += 1
print(z)  

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

int main(void) {
  int x;
  scanf("%d", &x);

  printf("%d", !x);
  return 0;
}


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

bool comp(int a, int b){
    return (a<b);
}

int main(){
    int k; cin >> k;
    if(k%2==1) cout << (k/2)*(k/2+1);
    else cout << (k/2)*(k/2);
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
    int c;
    if(b<10) c=b+10*a;
    if(10<=b&&b<100) c=b+100*a;
    if(b==100) c=b+1000*a;
    string ans="No";
    for(int i=0; i<400; i++){
        if(c==i*i) ans="Yes";
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 3556
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;





int main() 
{
  ll H,W; cin>>W>>H;
  ll x,y; cin>>x>>y;
  cout<<(double)(H*W)/2<<" ";
  if((W%2==0&&x==W/2)&&(H%2==0&&y==H/2)) {cout<<1<<endl; return 0;}
  cout<<0<<endl;
  return 0;
}


Measured memory_bytes: 256
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input().rstrip()))
def inlt():
    return(list(map(int,input().rstrip().split())))
def insr():
    s = input().rstrip()
    return(s[:len(s) - 1])
def invr():
    return(map(int,input().rstrip().split()))
################################################################
k,n = invr()
nums = inlt()
ans = min(nums[-1] - nums[0],k - (nums[1] - nums[0]))
for i in range(1,n - 1):
    
    result = min(k - (nums[i] - nums[i - 1]), \
             k - abs(nums[i + 1] - nums[i]))
    #print(i,result)
    if result < ans:
        ans = result

ans = min(ans,k - (nums[-1] - nums[-2]))
print(ans)


Measured memory_bytes: 26444
from collections import Counter
import sys
def muri():
    print(-1)
    sys.exit()
N = int(input())
D = [int(sys.stdin.readline()) for _ in range(N)]
#D = list(map(int, input().split()))
Didx = list(range(1, N+1))
Didx.sort(key = lambda x: -D[x-1])
H = {d: i for i, d in enumerate(D, 1)}
H = Counter(H)
D = [0] + D
K = [1]*(N+1)
Ans = []
for vn in Didx[:-1]:
    p = H[D[vn] - (N - 2*K[vn])]
    if not p:
        muri()
    Ans.append((vn, p))
    K[p] += K[vn]
s = set()

Edge = [[] for _ in range(N+1)]
for a in Ans:
    x, y = a
    Edge[x].append(y)
    Edge[y].append(x)

dist = [10**9+7]*(N+1)
dist[0] = 0
dist[1] = 0
stack = [1]
visited = set([1])
while stack:
    vn = stack.pop()
    for vf in Edge[vn]:
        if vf not in visited:
            visited.add(vf)
            dist[vf] = 1 + dist[vn]
            stack.append(vf)
if D[1] != sum(dist[1:]):
    muri()

for a in Ans:
    print(*a)

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

int main()
{
  string ABCD;
  cin >> ABCD;
  int abcd[4];
  for (int i = 0; i < 4; ++i)
    abcd[i] = ABCD[i] - '0';
  int i = 0;
  for (; i < 8; ++i)
  {
    int rhs = abcd[0];
    rhs += (2*(1&(i >> 2)) - 1)*abcd[1];
    rhs += (2*(1&(i >> 1)) - 1)*abcd[2];
    rhs += (2*(1&(i >> 0)) - 1)*abcd[3];
    if (7 == rhs)
      break;
  }
  char op[2] = {'-', '+'};
  cout
    << ABCD[0] << op[1&(i >> 2)]
    << ABCD[1] << op[1&(i >> 1)]
    << ABCD[2] << op[1&(i >> 0)]
    << ABCD[3] << "=7";
  return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
	int N;
	cin>>N;
	vint D(N);rep(i,N)cin>>D[i];
	sort(all(D));
	cout<<D[N/2]-D[N/2-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include "stdio.h"

int main(void){
  int A,B,C,X;
  int N,M,L;
  int count = 0;

  scanf("%d%d%d%d", &A, &B, &C, &X);

  for(int i=0;i<=A;i++){
    if(X != 0){
      N = X - 500*i;
      if(N == 0){
        count++;
      }
    }
    for(int j=0;j<=B;j++){
      if(N != 0){
        M = N - 100*j;
        if(M == 0){
          count++;
        }
      }
      for(int k=0;k<=C;k++){
        if(M != 0){
          L = M - 50*k;
          if(L == 0){
            count++;
          }
        }
      }
    }
  }
  printf("%d", count);

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define fast                          \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);
#define FOR(n) for(int i(0);i<n;++i)
#define ASC(i,a,b) for(int i(a); i <=b; ++i)
#define DESC(i,a,b) for(int i(a);i>=b;i--)
#define WL(t) while(t--)
#define SZ(a) int((a).size())
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define BB begin()
#define EE end()
#define all(c) c.BB, c.EE
#define present(container, element) (container.find(element) != container.end())
// ^^for set,map etc
#define cpresent(container, element) (find(all(container), element) != container.end())
// for vector,array etc
#define tr(container, it) for (auto it = container.begin(); it != container.end(); it++)
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) * (b)) / gcd((a), (b))
typedef long long LL;
typedef long double LD;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef map<char,int> mci;
typedef pair<int, int> pii;
typedef map<int,pii> ipii;
const float INF = numeric_limits<float>::infinity();
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846264338;
const LL big=998244353;

#ifdef _DEBUG
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif


int main(){
	int n;
	cin >> n;
	vector<int> ht;
	FOR(n){
		int x; cin >> x;
		ht.PB(x);
	}
	int ans[n];
	ans[0]=0; ans[1]=abs(ht[1]-ht[0]);
	for(int i(2);i<n;++i){
		ans[i]=min(ans[i-1]+ abs(ht[i-1]-ht[i]) , ans[i-2] + abs(ht[i-2]-ht[i]));
	}
	cout << ans[n-1]<< '\n';

}

Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    LL N,M;cin >> N >> M;
    vector<double> A(N);
    rep(i,N)cin >> A[i];
    sort(rall(A));
    double ans = 0;
    double sum = 0;
    rep(i,N)sum += A[i];

    rep(i,N){
        if(A[i] >= sum/((double)4*M))ans++;
    }
    bool ok = true;
    if(ans < M)ok = false;
    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

const int N = 1e6 + 5, inf = 1e9 + 7;

int dp[N], n, k, val[N];
char s[N], t[N];

int main() {
  scanf("%d %d %s %s", &n, &k, s+1, t+1);
  t[0] = 0;
  // genap, ganjil
  deque<int> d1, d2;
  int val1 = 0, val2 = 0;
  int cnt = 0;
  d1.push_back(0);
  dp[0] = 0;
  for (int i = 1; i <= n; ++i) {
    dp[i] = inf;
    cnt += (t[i] != t[i-1]);
    if (t[i] != t[i-1] && i > 1) {
      if (cnt & 1)
        val2++;
      else
        val1++;
    }
    while (d1.size() > 0 && d1.front() < i-k) d1.pop_front();
    while (d2.size() > 0 && d2.front() < i-k) d2.pop_front();
    if (d1.size() > 0)
      dp[i] = min(dp[i], val[d1.front()]+val1+1);
    // cerr << dp[i] << endl;
    if (d2.size() > 0)
      dp[i] = min(dp[i], val[d2.front()]+val2+1);
    // cerr << dp[i] << endl;
    if (t[i] == s[i])
      dp[i] = min(dp[i], dp[i-1]);
    bool pilih1 = ((cnt & 1) && t[i] == t[i+1]) || (((cnt & 1) == 0) && t[i] != t[i+1]);
    // cerr << i << " " << dp[i] << " " << pilih1 << " " << cnt  << " " << val1 << " " << val2 << endl;
    if (pilih1) {
      val[i] = dp[i] - val1;
      while (d1.size() > 0) {
        if (val[d1.back()] >= val[i])
          d1.pop_back();
        else
          break;
      }
      d1.push_back(i);
    }
    else {
      val[i] = dp[i] - val2;
      while (d2.size() > 0) {
        if (val[d2.back()] >= val[i])
          d2.pop_back();
        else
          break;
      }
      d2.push_back(i);
    }
  }
  printf("%d\n", dp[n]);
  return 0;
}

Measured memory_bytes: 8136
n = int(input())
a = list(map(int, input().split(' ')))
avg = 0
for i in range(n):
    avg += a[i]
avg /= n
delta = 100
ans = -1
for i in range(n):
    d = abs(avg - a[i])
    if d < delta:
        ans = i
        delta = d
print(ans)


Measured memory_bytes: 9116
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 1000000007
int main(){
  lint a,b,c,x,y;llint ans;llint pa,pb;
  cin>>a>>b>>c>>x>>y;
  if(a+b<=c*2){ans=a*x+b*y;}
  else{
  pa=2*c*max(x,y);
  if(x>y){pb=c*y*2+a*(x-y);}else{pb=2*c*x+b*(y-x);}
  ans=min(pa,pb);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<math.h>
#define N 1002
#define Rad(C) C*M_PI/180.0

int main() {
	double a, b, C,S,L;
	scanf("%lf%lf%lf", &a, &b, &C);
	S = 0.5*a*b*sin(Rad(C));
	L = sqrt(a*a+b*b-2*a*b*cos(Rad(C)));
	printf("%.8lf\n%.8lf\n%.8lf\n", S,L+a+b,(S/a)*2.0);
	return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
#define ld long double
using namespace std;
int main() {
    int n;
    cin>>n;
    ld a[n];
    for(int i = 0; i < n; i++)  cin>>a[i];
    ld sum = 0;
    for(int i = 0; i < n; i++) sum += 1/a[i];

    sum = 1/sum;
    cout.precision(15);
    cout<<sum<<"\n";
    return 0;
}


Measured memory_bytes: 256
N=int(input())
A=input().split()
A=list(map(int,A))
def can_divide_by_2():
    for i in range(N):
        a=A[i]
        if a%2==0:
            a=a//2
            A[i]=a
        else:
            return False
for u in range(1000000):
    x=can_divide_by_2()
    if x==False:
        break
print(u)

Measured memory_bytes: 9184
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
from decimal import *

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

A, B, C = map(int, raw_input().split())
if A == B == C:
    print "No"
elif A == B or B == C or C == A:
    print "Yes"
else:
    print "No"

Measured memory_bytes: 4268
#include <bits/stdc++.h>
//#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////


int main(){fastio
    ll n,w;cin>>n>>w;
    ll a[n],b[n];rep(i,0,n-1)cin>>a[i]>>b[i];
    ll dp[n+1][w+1];memset(dp,0,sizeof(dp));
    rep(i,1,n){
        rep(j,0,w){
            dp[i][j]=dp[i-1][j];
            if(j-a[i-1]>=0)Max(dp[i][j],dp[i-1][j-a[i-1]]+b[i-1]);
        }
    }
    ll ans=0;rep(j,0,w)Max(ans,dp[n][j]);
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 79104
n = int(input())
l = []
pa = 0
pb = 0
pc = 0
for i in range(n):
    a,b,c = map(int,input().split())
    na = max((a+pb),(a+pc))
    nb = max((b+pa),(b+pc))
    nc = max((c+pa),(c+pb))
    pa = na
    pb = nb
    pc = nc

print(max(pa,pb,pc))

Measured memory_bytes: 9108
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] a = new int[N];
        int temp = 0;
        int count = 0;

        for (int i = 0; i < N; i++) {
            a[i] = Integer.parseInt(sc.next());
        }

        for (int i = 0; i < N; i++) {

            if (a[i] == 2) {
                count++;
                break;
            } else if (a[i] == 1 || a[i] == -1) {
                count = -1;
                break;
            }

            temp = i;
            i = a[i] - 2;
            a[temp] = -1;
            count++;
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(count);
        sc.close();
        out.flush();
    }
}

Measured memory_bytes: 58428
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

char a[101][101];
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int h, w; 
const int INF = 1000000000;

bool isvalid(int x, int y)
{
	if(x>=0&&x<h&&y>=0&&y<w) return true;
	else return false;
}

template<int MX, ll INF> struct MaxFlow //by yutaka1999, have to define INF and MX (the Max number of vertices)
{
	struct edge
	{
		int to,cap,rev;
		edge(int to=0,int cap=0,int rev=0):to(to),cap(cap),rev(rev){}
	};
	vector <edge> vec[MX];
	int level[MX];
	int iter[MX];
	
	void addedge(int s,int t,int c) //adds an edge of cap c to the flow graph
	{
		int S=vec[s].size(),T=vec[t].size();
		vec[s].push_back(edge(t,c,T));
		vec[t].push_back(edge(s,0,S));
	}
	void bfs(int s)
	{
		memset(level,-1,sizeof(level));
		queue <int> que;
		level[s] = 0;
		que.push(s);
		while (!que.empty())
		{
			int v = que.front();que.pop();
			for(int i=0;i<vec[v].size();i++)
			{
				edge&e=vec[v][i];
				if (e.cap>0&&level[e.to]<0)
				{
					level[e.to]=level[v]+1;
					que.push(e.to);
				}
			}
		}
	}
	ll flow_dfs(int v,int t,ll f)
	{
		if (v==t) return f;
		for(int &i=iter[v];i<vec[v].size();i++)
		{
			edge &e=vec[v][i];
			if (e.cap>0&&level[v]<level[e.to])
			{
				ll d=flow_dfs(e.to,t,min(f,ll(e.cap)));
				if (d>0)
				{
					e.cap-=d;
					vec[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}
	ll maxflow(int s,int t) //finds max flow using dinic from s to t
	{
		ll flow = 0;
		while(1)
		{
			bfs(s);
			if (level[t]<0) return flow;
			memset(iter,0,sizeof(iter));
			while (1)
			{
				ll f=flow_dfs(s,t,1000000007);
				if(f==0) break;
				flow += f;
			}
		}
	}
};

MaxFlow<30021,120001> mf;

int in(int x, int y)
{
	return (w*x + y)*2+1;
}

int out(int x, int y)
{
	return (w*x+y)*2+2;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> h >> w;
	int s = 0; int e = out(h-1,w-1)+1;
	for(int i = 0; i < h; i++)
	{
		for(int j = 0; j < w; j++)
		{
			//cerr<<in(i,j)<<' '<<out(i,j)<<'\n';
			cin >> a[i][j];
			if(a[i][j]=='X')
			{
				mf.addedge(in(i,j),out(i,j),INF);
				mf.addedge(out(i,j),e,INF);
			}
			else
			{
				mf.addedge(in(i,j),out(i,j),1);
			}
			if(i == 0 || i == h - 1 || j == 0 || j == w - 1)
			{
				if(a[i][j] == 'X'){cout << -1 << '\n'; return 0;}
			}
		}
	}
	for(int i = 0; i < h; i++)
	{
		for(int j = 0; j < w; j++)
		{
			for(int k = 0; k < 4; k++)
			{
				int x = i+dx[k]; int y = j+dy[k];
				if(isvalid(x,y))
				{
					mf.addedge(out(i,j),in(x,y),INF);
				}
				else
				{
					mf.addedge(s, in(i,j), INF);
				}
			}
		}
	}
	cout<<mf.maxflow(s,e)<<'\n';
}


Measured memory_bytes: 3328