akhauriyash/Code-Regression huggingface dataset:
import sys
import math
from collections import defaultdict, deque
from copy import deepcopy
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    H, W = MI()
    sx, sy = MI()
    gx, gy = MI()
    sx-=1
    sy-=1
    gx-=1
    gy-=1
    
    mylist = [input().rstrip() for i in range(H)]
    dist = Init(H, W, float('inf'))
    #dist2 = Init(H, W, float('inf'))
    dq = deque()
    dq2 = deque()
    dq.append((sx, sy))
    move1 = [[1,0],[0,1],[-1,0],[0,-1]]
    move2 = [[i,j] for i in range(-2,3) for j in range(-2,3) if not [i, j ] in move1 and [i, j] != [0, 0]]
    dist[sx][sy] = 0
    while dq:
        x, y = dq.popleft()
        if x == gx and y == gy:
            print(dist[gx][gy])
            sys.exit()


        #コスト1の移動
        for x2, y2 in move2:
            x2 += x
            y2 += y
            if x2 >= 0 and x2 < H and y2 >= 0 and y2 < W and mylist[x2][y2] == "." and dist[x2][y2] > dist[x][y]+1:
                dist[x2][y2] = dist[x][y]+1
                dq2.append((x2,y2))

        #コスト0の移動
        for x2, y2 in move1:
            x2 += x
            y2 += y
            if x2 >= 0 and x2 < H and y2 >= 0 and y2 < W and mylist[x2][y2] == "." and dist[x2][y2] > dist[x][y]:
                dist[x2][y2] = dist[x][y]
                dq.append((x2,y2))

        if not dq:
            dq = deque(set(dq2))
            dq2 = deque()
        
    
    if dist[gx][gy] == float('inf'):
        print(-1)
    else:
        print(dist[gx][gy])
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 109252
import Data.List (sort)
import Data.Maybe (maybeToList)

splitBy :: (a -> Bool) -> [a] -> [[a]]
splitBy _ [] = []
splitBy p xs = us : splitBy p (dropWhile p vs)
  where (us,vs) = break p xs

elemAt :: Int -> [a] -> Maybe a
elemAt _ []     = Nothing
elemAt 0 (x:_)  = Just x
elemAt k (_:xs) = elemAt (k-1) xs

solve :: Int -> Int -> [Int] -> Int
solve k q xs = minimum $ concatMap (\x -> solve1 k q x xs) xs
  where solve1 k q x = maybeToList . fmap (subtract x) . elemAt (q-1) . sort . concatMap ((\xs -> take (length xs - k + 1) xs) . sort) . filter ((>= k) . length) . splitBy (< x)

main :: IO ()
main = do
  [_n, k, q] <- map read . words <$> getLine :: IO [Int]
  xs <- map read . words <$> getLine :: IO [Int]
  print $ solve k q xs


Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N,M;
  cin >> N>>M;
  vector<int> A(M);
  for(int i = 0; i<M; i++) cin >> A[i];
 
  int wd = 0;
  for(int i = 0; i<M; i++) {
    wd += A[i];
  }
  if(N >= wd) cout << N - wd << endl;
  else cout << "-1" << endl;
}

Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int n, t;
	cin >> n >> t;
	vector<int> C(n), T(n);
	rep(i, n) cin >> C[i] >> T[i];
	int ans = 114514;
	rep(i, n) {
		if (T[i] <= t) {
			ans = min(ans, C[i]);
		}
	}
	if (ans == 114514) cout << "TLE" << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<algorithm>
#include<string>
#include<cstdio>
using namespace std;
int main(){
    stack<double> st;
    double a, b;
    char s[105];
    char w;
    while(~scanf("%s%c", s, &w)){
	switch(s[0]){
	case '+':
	    a = st.top();st.pop();
	    b = st.top();st.pop();
	    st.push(b+a);
	    break;
	case '-':
	    if(s[1] != '\0')goto a;
	    a = st.top();st.pop();
	    b = st.top();st.pop();
	    st.push(b-a);
	    break;
	case '*':
	    a = st.top();st.pop();
	    b = st.top();st.pop();
	    st.push(b*a);
	    break;
	case '/':
	    a = st.top();st.pop();
	    b = st.top();st.pop();
	    st.push(b/a);
	    break;
	default:
	a:
	    sscanf(s, "%lf", &a);
	    st.push(a);
	}
	if(w == '\n'){
	    printf("%.5lf\n",st.top());
	    while(!st.empty())
		st.pop();
	}
    }
    return 0;
}

Measured memory_bytes: 1252
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int sum = 0;
  rep(i, n) sum += a[i];
  int cnt = 0;
  rep(i, n) {
    if (4 * m * a[i] >= sum) cnt++;
  }
  cout << (cnt >= m ? "Yes" : "No") << endl;


  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) cout << ", "; else first = false;
    cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i];
}
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

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


Measured memory_bytes: 256
class Stack():
    def __init__(self):
        self.stack = [0 for _ in range(200)]
        self.top = 0

    def isEmpty(self):
        return self.top == 0

    def isFull(self):
        return self.top >= len(self.stack) - 1

    def push(self, x):
        if self.isFull():
            print "error"
            return exit()
        self.top += 1
        self.stack[self.top] = x

    def pop(self):
        if self.isEmpty():
            print "error"
            return exit()
        a = self.stack[self.top]
        del self.stack[self.top]
        self.top -= 1
        return a

    def lol(self):
        return self.stack[self.top]

def main():
    st = Stack()
    data = raw_input().split()
    for i in data:
        if i == '+':
            b = int(st.pop())
            a = int(st.pop())
            st.push(a + b)
        elif i == '-':
            b = int(st.pop())
            a = int(st.pop())
            st.push(a - b)
        elif i == '*':
            b = int(st.pop())
            a = int(st.pop())
            st.push(a * b)
        else:
            st.push(i)
    print st.lol()

if __name__ == '__main__':
    main()

Measured memory_bytes: 6376
N, Y = map(int, input().split())


def main():
    for x in range(N + 1):
        for y in range(N + 1):
            if N < x + y:
                break

            z = N - x - y

            if 10000 * x + 5000 * y + 1000 * z == Y:
                print(x, y, z)
                return

    print(-1, -1, -1)
    return


main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

long long dp[55],p[55];
long long search(long long n,long long x){
    // cout<<n<<" "<<x<<endl;
    if(x==dp[n]) return p[n];
    if(x==(dp[n]+1)/2) return p[n-1]+1;
    if(x==1) return 0;
    if(x>(dp[n]+1)/2) return p[n]-search(n,dp[n]-x);
    return search(n-1,x-1);
}
int main(){
    long long n,x; cin>>n>>x;
    dp[0]=p[0]=1;
    for(int i=1;i<55;i++){
        dp[i]=dp[i-1]*2+3;
        p[i]=p[i-1]*2+1;
    }
    // cout<<dp[2]<<endl;
    cout<<search(n,x)<<endl;
    return 0;
}


Measured memory_bytes: 256
import math

N = int(input())
Xs = input().split(' ')
X = []
for i in range(N):
  X.append(int(Xs[i]))
  
 
minimizeP = sum(X)/N
P_floor = math.floor(minimizeP)
P_ceil = math.ceil(minimizeP)
minP1 = 0
minP2 = 0
X.sort()
for i in X:
  minP1 = minP1 + (i - P_floor) ** 2
  minP2 = minP2 + (i - P_ceil) ** 2
  
print(min(minP1,minP2))


Measured memory_bytes: 3188
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iostream>
#include<cstring>
#define ll long long
#define maxn 200005
#define p 1000000007
#define re(i,a,b) for(int i=a;i<=b;i++)
#define for_edge(x) for(int i=head[x];i;i=e[i].nxt)
using namespace std;
inline int read(){char c=getchar();int f=1;int ans = 0;while(c>'9'||c<'0'){if(c=='-')f=-f;c=getchar();}while(c<='9'&&c>='0'){ans =ans*10+c-'0';c=getchar();}return ans*f;}
//_____________________________________________________________________________________________________
struct edge
{
	int nxt,to;ll v;
	edge(int nxt=0,int to=0,ll v=0)
	:nxt(nxt),to(to),v(v){};
}e[maxn*2];
int head[maxn],TOT;
inline void add(int x,int y,ll v)
{
	e[++TOT] = edge( head[x],y,v );
	head[x] = TOT;
}
int n,tot;
struct node
{
	int x,y;ll v;
	node(int x=0,int y=0,ll v=0)
	:x(x),y(y),v(v){};
	inline bool operator < (node x) const
	{ return v<x.v; };
}E[maxn*20];
int size[maxn],sz_root,root,vis[maxn];
void find_root(int x,int fa,int SZ)
{
	size[x] = 1;
	int sz_x = 0;
	for_edge(x)
	{
		int y = e[i].to ;
		if(y==fa||vis[y]) 
			continue;
		find_root(y,x,SZ);
		size[x] += size[y];
		sz_x = max(sz_x,size[y]);
	}
	sz_x = max( sz_x,SZ-size[x] );
	if(sz_x<sz_root)
	{
		sz_root = sz_x;
		root = x;
	}
}
int RT;ll sum_RT,v[maxn];
void dfs1(int x,int fa,ll dis)
{
	if(v[x]+dis<sum_RT)
	{
		sum_RT = v[x] + dis;
		RT = x;
	}
	for_edge(x)
	{
		int y = e[i].to ;
		if(y==fa||vis[y])
			continue;
		dfs1( y,x,dis+e[i].v );
	}
}
void dfs2(int x,int fa,ll dis)
{
	E[++tot] = node(x,RT,v[x]+dis+sum_RT);
	for_edge(x)
	{
		int y = e[i].to ;
		if(y==fa||vis[y])
			continue;
		dfs2( y,x,dis+e[i].v );
	}
}
void solve(int x,int SZ)
{
	sz_root = SZ;
	find_root(x,0,SZ);
	x = root;
	find_root(x,0,SZ);
	sum_RT = 1e18;
	dfs1(x,0,0);
	dfs2(x,0,0);
	vis[x] = 1;
	for_edge(x)
	{
		int y = e[i].to ;
		if(vis[y])
			continue;
		solve(y,size[y]);
	}
}
//_____________________________________________
int fa[maxn];
inline int find(int x)
{return fa[x]==x ? x : fa[x] = find(fa[x]);}
inline void mst()
{
	re(i,1,n)
		fa[i] = i;
	ll ans = 0;
	sort(E+1,E+tot+1);
	re(i,1,tot)
	{
	//	printf("%d %d %lld\n",E[i].x ,E[i].y ,E[i].v);
		int x = find(E[i].x ) , y = find(E[i].y );
		if(x==y)
			continue;
		ans += E[i].v ;
		fa[x] = y;
	}
	printf("%lld\n",ans);
}
int main()
{
//	freopen("0.in","r",stdin);
	n = read();
	re(i,1,n)
		v[i] = read();
	re(i,1,n-1)
	{
		int x = read(),y=read(),v=read();
		add(x,y,v);
		add(y,x,v);
	}
	solve(1,n);
	mst();
	return 0;
}


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

int main(){
    int w, h;
    while(1){
        cin >> h >> w;
        if ( w == 0 && h == 0) break;
        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3136
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main(void) {
	int a;
	cin >> a;
	cout << a + a * a + a * a * a << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  string S;
  cin >> S;
  int N;
  cin >> N;
  vector<string> cand;
  for(int s = 0; s < S.size(); s++){
    for(int e = s;e < S.size() && e-s+1 <= N; e++){
      cand.push_back(S.substr(s,e-s+1));
    }
  }
  sort(cand.begin(), cand.end());
  unique(cand.begin(), cand.end());
  cout << cand[N-1];
}


Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k;
  string s;
  cin >>k;
  cin >>s;
  int tmp=s.size();
  if(tmp<=k)
    cout <<s<<endl;
  else{
    string tmp=s.substr(0,k)+"...";
    cout <<tmp<<endl;}
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void){

	int a = 0 ;
	int b = 0 ;
	int c = 0 ;		//??????????????±???????´????????????°

	int i = 0;			//???????????°
	int divcnt = 0 ;	//?´???°??????????????????????????°

	scanf("%d" , &a);
	scanf("%d" , &b);
	scanf("%d" , &c);

	for( i = a ; i <= b ; i++){	//i???a??????b?????§????????????????????????????´???°????????????

		if(c%i == 0){			//c???i??§?????£????????????0???????´???°
			divcnt++;
		}

	}

	/*????????¨???*/
	printf("%d\n", divcnt);

	return 0;
}

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

using namespace std;

const int N = 2e6 + 5;

int a[N];

int n, k;

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> k >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    a[n + 1] = a[1] + k;
    int res = N;
    for (int i = 1; i <= n; i++)
        res = min(res, k - (a[i + 1] - a[i]));
    cout << res << endl;
    return 0;
}


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

#define _USE_MATH_DEFINES

#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <bitset>
#include <complex>
#include <limits>
#include <random>


using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

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

	int X, K, D;
	cin >> X >> K >> D;

	if (X == 0)
	{
		if (K % 2 == 0)
		{
			cout << 0 << endl;
		}
		else
		{
			cout << D << endl;
		}
	}
	else if (0 < X)
	{
		int p = X;
		int t = (X + D - 1) / D;
		p -= min(t, K)*D;
		K = max(0LL, K - t);
		if (K > 0)
		{
			if (K % 2 == 0)
			{
				cout << abs(p) << endl;
			}
			else
			{
				cout << abs(p + D) << endl;
			}
		}
		else
		{
			cout << abs(p) << endl;
		}
	}
	else
	{
		int p = X;
		int t = (-X + D - 1) / D;
		p += min(t, K)*D;
		K = max(0LL, K - t);
		if (K > 0)
		{
			if (K % 2 == 0)
			{
				cout << abs(p) << endl;
			}
			else
			{
				cout << abs(p - D) << endl;
			}
		}
		else
		{
			cout << abs(p) << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3648
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, k = MAP()
n += 1
a = [0] + LIST()
# b[1]: 町iに到達する最小回数
b = [-1]*n

now = 1
count = 0
for i in range(n):
    if b[now] == -1:
        b[now] = count
        count += 1
        now = a[now]
    else:
        offset = b[now]
        loop = count - b[now]
        break
if k <= offset:
    targ = k
else:
    targ = (k-offset) % loop + offset

for i in range(1, n):
    if b[i] == targ:
        print(i)
        exit()

Measured memory_bytes: 34212
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
using in = int64_t;
const int INF =(1<<30);

bool chmin(int &a,int b){
  if(a>b){a=b; return 1;}
  return 0;
}

int main(){
   int n,k;
  cin>>n>>k;
  vector<int> h(n);
  rep(i,n) cin>>h.at(i);
  vector<int> dp(n);
  rep(i,n) dp.at(i)=INF;
  dp.at(0)=0;
  
  for(int i=1;i<n;i++){
    for(int j=1;j<=k;j++){
     if(i>=j) chmin(dp.at(i), dp.at(i-j)+abs(h.at(i)-h.at(i-j)));
    }
  }
  cout<<dp.at(n-1);
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    rep(i, N - 2) {
        if (S.substr(i, 3) == "ABC") ans++;
    }
    write(ans);
}

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

long long int wa(long long int u){
    return u*(u+1)/2;
}


int main(){
    
    int N,M;cin>>N>>M;
    vector<long long int> S(N+1);
    for(int i=1;i<=N;i++){
        long long int a;cin>>a;
        S[i]=(S[i-1]+a)%M;
    }
    long long int ans=0;
    sort(S.begin(),S.end());
    long long int cnt=0;
    for(int i=1;i<=N;i++){
        cnt=0;
        for(int j=i;j<=N;j++){
            if(S[i]==S[j]) cnt++;
                else{
                    if(S[j-1]==0) ans+=wa(cnt);
                    else ans+=wa(cnt-1);
                    i=j-1;
                    break;
                }
            if(j==N){
                if(S[j]==0) ans+=wa(cnt);
                else ans+=wa(cnt-1);
                i=N+1;
            }
        }
    }
    cout<<ans<<endl;
}


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

int main() {
  int N,K,d,A;
  cin>>N>>K;
  vector<int>sunuke(N);
  for(int i=0;i<K;i++){
    cin>>d;
    for(int j=0;j<d;j++){
      cin>>A;
      sunuke.at(A-1)++;
    }
  }
  int cou=0; 
  for(int l=0;l<N;l++){
    if(sunuke.at(l)==0){
      cou++;
    }
  }
  cout<<cou<<endl;
}

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

using namespace std;

bool dp[100001];
int a[101];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(12);
    int n, k;
    cin >> n >> k;
    vector<int> cnt(4);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= k; ++i) {
        dp[i] = false;
        for (int j = 0; j < n; ++j) {
            if (i - a[j] >= 0) {
                if (!dp[i - a[j]]) {
                    dp[i] = true;
                    break;
                }
            }
        }
    }
    if (dp[k]) cout << "First" << "\n";
    else cout << "Second" << "\n";
    return 0;
}

Measured memory_bytes: 384
//Code by : Abhishek Tiwari
//codechef.com/users/devil_within || hackerearth.com/@devil_within
#include<bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int 
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define repr(i,a,b) for(int i=(a);i>(b);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pii pair<int,int> 
#define ff first
#define ss second 
#define mod 1000000007
#define inf 1000000000
#define gcd __gcd
#define lcm(a,b) ((a)*(b))/gcd(a,b)
using namespace std;

/*******************************************************************************************/
/*******************************************************************************************/
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { 
    os<<"["; for(int i=0;i<v.size()-1; ++i)os<<v[i]<<", ";os<<v[v.size()-1]<<"]\n"; return os; 
} 
template <typename T> ostream& operator<<(ostream& os, const set<T>& v) { 
    os<<"{"; for(auto it : v) { os<<it; if(it!=*v.rbegin()) os<<", "; } os<<"}\n"; 
    return os; 
}
template <typename T, typename S> ostream& operator<<(ostream& os, const map<T, S>& v) { 
    os<<"{"; for(auto it:v){ os<<"("<<it.first<<" : "<<it.second<<")"; if(it!=*v.rbegin()) os<<", "; } os<<"}\n"; 
    return os; 
}
template <typename T, typename S> ostream& operator<<(ostream& os, const pair<T, S>& v) { 
    os<<"("; os<<v.first<<", "<< v.second<<")"; 
    return os; 
} 
template<typename T> T maxi(T a,T b){return a>b ? a:b;}
template<typename T> T mini(T a,T b){return a<b ? a:b;}
/*******************************************************************************************/
/*******************************************************************************************/
int fpow(int x, int y, int p); 


int32_t main()  
{
#ifndef ONLINE_JUDGE
//freopen("input.txt" , "r" , stdin);freopen("output.txt" , "w" , stdout);freopen("error.txt" , "w" , stderr);
#endif
fio;
int tcases = 1;
//cin>>tcases;
for(int tcase = 1 ; tcase <= tcases ; ++tcase)
{
    int n, k ;
    cin>>n>>k;
    vector<int> a(n) , dp(k+1, 0);
    rep(i, 0 , n) cin>>a[i];
    rep(i , 0 , k+1)
    {
        if(dp[i] == 0 )
        {
            rep(j , 0 , n)
            {
                if(i + a[j] <= k)
                {
                    dp[i + a[j] ] =  1;
                }
            }
        }
    }
    dp[k]==1 ? cout<<"First" : cout<<"Second";
    //cout<<"Case #"<<tcase<<": ";
}
return 0;
}



//Functions 

int fpow(int x, int y, int p) { 
    int res = 1; 
   x = x % p;  
   while (y > 0) { 
     if (y & 1) 
        res = (res * x) % p; 
     y = y >> 1; 
        x = (x * x) % p; 
    } 
    return res; 
} 


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoderApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var K = int.Parse(Console.ReadLine());
            var input = Console.ReadLine().Split(' ');

            var A = int.Parse(input[0]);
            var B = int.Parse(input[1]);

            for (int i = A; i <= B; i++)
            {
                if (i % K == 0)
                {
                    Console.WriteLine("OK");
                    return;
                }
            }
            Console.WriteLine("NG");
        }
    }
}

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

int main() {
  int n;
  std::cin >> n;
  std::string s;
  std::cin >> s;
  int red = 0, blue = 0;

  for (const auto i : s) {
    if (i == 'R') {
      red++;
    } else {
      blue++;
    }
  }

  if (blue < red) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
module Enumerable
  def balance(n)
    Array.new(n) { [] }.tap { |ary| zip(ary.cycle) { |e, a| a << e } }
  end
end

n, k = gets.split.map(&:to_i)
r, s, p = gets.split.map(&:to_i)
$points = { r: p, s: r, p: s }
ts = gets.chomp.each_char.map(&:to_sym).balance(k)

def f(t)
  t.chunk(&:itself).inject(0) do |sum, (sym, ary)|
    sum + (ary.size + 1) / 2 * $points[sym]
  end
end

puts ts.inject(0) { |sum, t| sum + f(t) }


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

typedef struct{
    int value;
    char suit;
}card;

void BubbleSort(card c[],int n){
    for(int i=0;i<n;i++){
        for(int j=n-1;j>i;j--){
            if(c[j-1].value>c[j].value){
                card v=c[j-1];
                c[j-1]=c[j];
                c[j]=v;
            }
        }
    }
}

void SelectionSort(card c[],int n){
    for(int i=0;i<n-1;i++){
        int minj=i;
        for(int j=i+1;j<n;j++)if(c[minj].value>c[j].value)minj=j;
        if(i!=minj){
            card v=c[i];
            c[i]=c[minj];
            c[minj]=v;
        }
    }
}

void printcard(card c[],int n){
    for(int i=0;i<n;i++){
        if(i)cout<<" ";
        cout<<c[i].suit<<c[i].value;
    }cout<<endl;
}

int main(){
    int n; cin>>n;
    card b[n],s[n];
    for(int i=0;i<n;i++){
        cin>>b[i].suit>>b[i].value;
        s[i]=b[i];
    }
    BubbleSort(b,n);
    printcard(b,n);
    cout<<"Stable"<<endl;
    SelectionSort(s,n);
    printcard(s,n);
    int flag=1;
    for(int i=0;i<n;i++){
        if(b[i].suit!=s[i].suit){
            flag=0;
            break;
        }
    }
    if(flag)cout<<"Stable"<<endl;
    else cout<<"Not stable"<<endl;
    return 0;
}


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

using namespace std;

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

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

typedef long long LL;

const int oo = 0x3f3f3f3f;

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	scanf("%d", &n);
	int tmp = 0;
	REP(i, 0, n)
	{
		int x;
		scanf("%d", &x);
		tmp |= (x & 1) << i;
	}
	int ans = 0;
	REP(i, 0, (1 << n) - 1)
	{
		int cnt = 1;
		REP(j, 0, n) if (((i >> j) & 1) != ((tmp >> j) & 1)) cnt <<= 1;
		ans += cnt;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        char[] ch = sc.nextLine().toCharArray();
        
        int count = 0;
        
        for(int i=0;i<ch.length-1;i++){
            if(ch[i]==ch[i+1]){
                ch[i+1] = (ch[i]=='0')?'1':'0';
                count++;
            }
        }
        
        System.out.println(count);
    }
}


Measured memory_bytes: 27724
#include <stdio.h>

void swap(int *n1, int *n2)
{
	int temp = *n1;
	*n1 = *n2;
	*n2 = temp;
}

int main(void)
{
	int i;
	int num;		/* データセット数 */
	int x, y, z;	/* ３辺の長さ */
	scanf("%d", &num);
	
	for(i = 0; i < num; i++) {
		scanf("%d %d %d", &x, &y, &z);
		
		/* x <= y <= z にソート */
		if (x > y)	swap(&x, &y);
		if (y > z)	swap(&y, &z);
		if (x > y)	swap(&x, &y);
		
		if(x*x + y*y == z*z)
			puts("YES");
		else
			puts("NO");
	}
	
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int a,b; cin >> a>>b;
  if(a>9 or b>9){
    cout << -1 << endl;
    return 0;
  }
  cout << a*b << endl;
  return 0;
}


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


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

int main() {
  int n;
  cin >> n;
  cout << n / 3 << endl;
  return 0;
}

Measured memory_bytes: 256
def solve():
    A, B, K = map(int, input().split())
    ans = []
    if A + B <= K:
        ans = [0, 0]
    elif K <= A:
        ans = [A-K, B]
    elif K <= A + B:
        ans = [0, B+A-K]
    print(*ans)
solve()


Measured memory_bytes: 3060
import java.util.*;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();
        int k = sc.nextInt();

        int max = Math.max(a, Math.max(b, Math.max(c, Math.max(d, e))));
        int min = Math.min(a, Math.min(b, Math.min(c, Math.min(d, e))));

        if (max - min <= k) {
            System.out.println("Yay!");
        } else {
            System.out.println(":(");
        }
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
using Graph=vector<vector<int>>;
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; }

int main(){
    long long n;
    cin>>n;
    vector<long long> dp(n+1,1);
    for(long long i=2;i<=n;++i){
        for(long long j=1;i*j<=n;++j){
            ++dp[i*j];
        }
    }

    long long ans=0;
    for(long long i=1;i<=n;++i){
        ans+=dp[i]*i;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 81340
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  string s, t; cin >> s >> t;
  if (s[0] == t[2] && s[1] == t[1] && s[2] == t[0])
    cout << "YES";
  else 
    cout << "NO";
  cout << '\n';

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define rep(i, n) for (int i = 0; i < (n); i ++)
using namespace std;

int main()
{
  string s;
  cin >> s;
  
  vector<int> a(26);
  int n = s.size();
  rep(i, n)
  {
    a.at((int)(s.at(i)) - 97) ++;
  }
  auto it = find(a.begin(), a.end(), 0);
  if (it == a.end()) cout << "None";
  else cout << (char)(distance(a.begin(), it) + 97);
  
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    int a;
    cin>>a;
    char b[a];
    for(int i=0;i<a;i++){
        cin>>b[i];
        if(b[i]=='Y'){
            cout<<"Four"<<endl;
            return 0;
        }
    }
    cout<<"Three"<<endl;
    
}


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

const int N = 10005;

int n, c[N], a[N], cc, s;
vector<int> e[N];

void f(int x, int y){
	for(int i : e[x]){
		if(i != y) f(i, x);
	}
	a[x] = c[cc++];
	s += a[x];
}

int main(){
	scanf("%d", &n);
	for(int i = 0, x, y; i < n - 1; i++){
		scanf("%d%d", &x, &y);
		e[x].push_back(y);
		e[y].push_back(x);
	}
	for(int i = 0; i < n; i++) scanf("%d", c + i);
	sort(c, c + n);
	f(1, 0);
	printf("%d\n", s - a[1]);
	for(int i = 1; i <= n; i++) printf("%d ", a[i]);
	puts("");
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main(void) {
	int n;
	cin >> n;
	vector<bool> color(8,false);
	int overred = 0;
	rep(i, 0, n) {
		int a;
		cin >> a;
		if (1 <= a && a <= 399)color[0] = true;
		else if (400 <= a && a <= 799)color[1] = true;
		else if (800 <= a && a <= 1199)color[2] = true;
		else if (1200 <= a && a <= 1599)color[3] = true;
		else if (1600 <= a && a <= 1999)color[4] = true;
		else if (2000 <= a && a <= 2399)color[5] = true;
		else if (2400 <= a && a <= 2799)color[6] = true;
		else if (2800 <= a && a <= 3199)color[7] = true;
		else overred++;
	}
	int minv, maxv;minv = maxv = 0;
	rep(i, 0, color.size()) {
		if (color[i]) {
			minv++;maxv++;
		}
	}
	maxv = maxv + overred;
	minv = max(1, minv);
	
	cout << minv << " " << maxv << endl;
	return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    rep1(i, n) {
        if (i%3!=0 && i%5!=0) ans += i;
    }
    cout << ans << endl;
    return 0;
}


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

int main(void) {
  string st, tt; cin >> st >> tt;
  int n = st.length();
  vector<char> s(n);
  vector<char> t(n);
  for (int i=0; i<n; i++) {
    s[i] = st[i];
    t[i] = tt[i];
  }
  
  bool flag = false;
  for (int i=0; i<n; i++) {
    if (s == t) {
      flag = true; break;
    }
    s.push_back(s[0]); s.erase(s.begin());
  }
  
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3576
#include<stdio.h>
int main(void){
  int a,b,c,d,kai=1;
  
  scanf("%d\n %d\n %d\n %d\n",&a,&b,&c,&d);
  while(a>0&&c>0){
    if(kai%2==0){
      a=a-d;
    }
    else
      c=c-b;
    
    kai++;
  }
  if(a<=0)
    printf("No");
  else
    printf("Yes");
  
  return 0;
}

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

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

    int counter = 0;

    for(int i=a; i<=b; i++)
    {
        if(c%i==0) counter++;
    }
    cout << counter << endl;
    
    return 0;
}


Measured memory_bytes: 3092
"累積和を使う問題"

N = gets.to_i
S = gets.chomp

arr = []
arr.fill(0, 0..N)

N.times do |i|
  s = 0
  t = N-1
  if S[i]=='W' ? t = i : s = i
    arr[s] = arr[s] + 1
    arr[t+1] = arr[t+1] - 1
  end
end

#累積和を求める
sum = 0
(N+1).times do |i|
  arr[i] = arr[i] + sum
  sum = arr[i]
end

puts N-arr.max

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

#define IOS cin.tie(0);ios_base::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vs      vector<string>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>
using Graph  =  vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define SRepS(i,n,m)    for(int i=(int)(n);i*i<=(int)(m);i++)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template<class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define VCIN(x) for(auto &item:x) cin>>item

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?" ":"\n"); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);} //最小公倍数
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(b<a){a=b;return true;}return false;}
template<class T>bool comp(T a,T b){return abs(a)<abs(b);} //比較関数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int NMAX = 200;
const int INF = 1e9;
const int MOD = 1e9+7;
bool flag;

//----------------------Global-------------------------//

signed main(){
    SCIN(s);
    int x=count(all(s),'0');
    int y=count(all(s),'1');
    printf("%d\n",min(x,y)*2);

    return 0;
}

Measured memory_bytes: 512
import sys
import numpy as np 

n = int(sys.stdin.readline().rstrip())
a = np.array(sys.stdin.readline().split(), dtype=np.int64)

def main():
    tmp = np.absolute(a)
    if np.count_nonzero(a) != n:
        return tmp.sum()
    else:
        if np.count_nonzero(a < 0) & 1:
            return tmp.sum() - np.amin(tmp) * 2
        else:
            return tmp.sum()

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 24844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string str;
            int result = 0;
            string cnt = Console.ReadLine();
            str = Console.ReadLine();
            string[] s = str.Split(' ');
            for (int i = 0; i < s.Length - 2; i++)
            {
                int[] val = new int[3];

                val[0] = int.Parse(s[i]);
                val[1] = int.Parse(s[i+1]);
                val[2] = int.Parse(s[i+2]);

                if ((val[0] < val[1]) && (val[1] < val[2]))
                {
                    result++;
                }
                else if ((val[0] > val[1]) && (val[1] > val[2]))
                {
                    result++;
                }

            }
            Console.WriteLine(result);
        }
    }
}



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

int main(){
    string s;cin>>s;
    int a=1;int b=1;
    if(s[0]==s[1]){
      if(s[1]==s[2]){
        cout<<"No"<<endl;
        return 0;
      }else{
        if(s[2]==s[3]){
          cout<<"Yes"<<endl;
          return 0;
        }else{
          cout<<"No"<<endl;
        }
      }
    }else{
      for(int i=2;i<4;i++){
        if(s[i]==s[0]){
          ++a;
        }else if(s[i]==s[1]){
            ++b;
        }else{
          cout<<"No"<<endl;
          return 0;
        }
      }
    }
    if(a==2&&b==2){
      cout<<"Yes"<<endl;
    }
    
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<stdlib.h>

#define MAX 2000001
#define INF 2147483647
int A[MAX];
int h=0;

void heapIncreaseKey(int i, int k);

int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}
void maxHeapify(int i){
  int l,r,largest,temp;
  
  l = left(i);
  r = right(i);
  
  // choose max node among left child, me, and right child
  
  if(l <= h && A[l] > A[i])
    largest = l;
  else 
    largest = i;
  
  if(r <= h && A[r] > A[largest])
    largest = r;
  
  if(largest != i){ // A[i] > A[l],A[r]
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    maxHeapify(largest);
  }
}
void buildMaxHeap(){
  int i;
  for(i=h/2;i>0;i--)
    maxHeapify(i);
}

void maxHeapInsert(int k){
  h++;
  A[h] = -INF;
  heapIncreaseKey(h,k);
}

void heapIncreaseKey(int i, int k){

  int temp;

  /*  // 例外処理
  if(k < A[i]){
    printf("new key is smaller than current key\n");
    exit(0);
    }*/
  
  A[i] = k;
  while(i>1 && A[parent(i)] < A[i]){
    temp = A[i];
    A[i] = A[parent(i)];
    A[parent(i)] = temp;
    i = parent(i);
  }
  
  
  
}
int extract(){
  
  /*  // 例外処理
  if(h<1){
    printf("heap underflow\n");
    exit(0);
    }*/
  
  int max = A[1];
  A[1] = A[h];
  h--;
  maxHeapify(1);
  
  return max;
}
int main(){
  
  int i,k;
  char cmd[10];
  
  // 入力
  while(1){
    scanf("%s",cmd);
    
    if(strcmp(cmd,"insert") == 0){
      scanf("%d",&k);
      maxHeapInsert(k);
    }
    else if(strcmp(cmd,"extract") == 0){
      printf("%d\n",extract());
    }
    else if(strcmp(cmd,"end") == 0){
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 4696
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define pob pop_back
#define mp make_pair
#define ff first
#define ss second
#define pi 3.14159265
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <ll, ll> pll;
const ll M=1e9+7;
ll inf=1e18;
int main()
{
    int t;
    cin>>t;
    string s;
    int a=0,b=0,c=0,d=0;
    while(t--){
        cin>>s;
        if(s[0]=='A')
            a++;
        else if(s[0]=='W')
            b++;
        else if(s[0]=='T')
            c++;
        else
            d++;
    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<b<<endl;
    cout<<"TLE x "<<c<<endl;
    cout<<"RE x "<<d<<endl;
}


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

using namespace std;
int main()
{
    long int x,y,k,z,ans;
    cin >> x;
    y = x/500;k = x % 500;
    z = k/5;
    ans = (y * 1000) + (z * 5);
    cout << ans << endl;
}


Measured memory_bytes: 256
def main(*args, **kwargs):
    """Write Codes for contest here."""
    grid = []
    for i in range(3):
        grid.append(list(map(int, input().split())))

    #for b_sum in range(1, 301):
    #    a1 = Fraction(Fraction(sum(grid[0]), b_sum), 3)
    #    a2 = Fraction(Fraction(sum(grid[1]), b_sum), 3)
    #    a3 = Fraction(Fraction(sum(grid[2]), b_sum), 3)
    #    if is_integer(a1) and is_integer(a2) and is_integer(a3) and 0 <= a1 <= 100 and 0 <= a2 <= 100 and 0 <= a3 <= 100:
    #        print('Yes')

    for a1 in range(0, 101):
        b1_1 = grid[0][0] - a1
        b2_1 = grid[0][1] - a1
        b3_1 = grid[0][2] - a1
        for a2 in range(0, 101):
            b1_2 = grid[1][0] - a2
            b2_2 = grid[1][1] - a2
            b3_2 = grid[1][2] - a2
            for a3 in range(0, 101):
                b1_3 = grid[2][0] - a3
                b2_3 = grid[2][1] - a3
                b3_3 = grid[2][2] - a3

                # Check the condition
                if b1_1 == b1_2 == b1_3 and b2_1 == b2_2 == b2_3 and b3_1 == b3_2 == b3_3:
                    print('Yes')
                    return
    print('No')
    return
main()

Measured memory_bytes: 3064