akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		double l = sc.nextDouble();
		double x = l / 3;
		l -= x;
		double y = l / 2;
		l -= y;
		pw.println(x * y * l);
		pw.flush();
	}

	public static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}


Measured memory_bytes: 21332
K=int(input())

dp = [[0]*11 for _ in [0]*11]
dp[1] = [1]*10 + [0]

for i in range(2,11):
    dp[i][0] = dp[i-1][1] + dp[i-1][0]
    for j in range(1,10):
        dp[i][j] = dp[i-1][j-1] + dp[i-1][j] + dp[i-1][j+1]

S = 0
breakFlg = False
for d in range(1,11):
    for n in range(1,10):
        S += dp[d][n]
        if S>=K:
            breakFlg = True
            S -= dp[d][n]
            break
    if breakFlg: break

memo = dict()
def get(d,n):
    if (d,n) in memo:
        return memo[(d,n)]
    if d==1:
        memo[(d,n)] = [n]
        return [n]
    ret = []
    if n>0:
        for a in get(d-1,n-1):
            ret.append(a+n*(10**(d-1)))
    for a in get(d-1,n):
        ret.append(a+n*(10**(d-1)))
    if n<9:
        for a in get(d-1,n+1):
            ret.append(a+n*(10**(d-1)))
    memo[(d,n)] = ret
    return ret

ans = get(d,n)[K-S-1]
print(ans)

Measured memory_bytes: 5340
import sys
input = sys.stdin.readline

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

m = 0
ans = [0]*N
for i in range(N, 0, -1):
    a = A[i-1]
    cnt = 0
    for k in range(i+i, N+1, i):
        cnt += ans[k-1]
    if a != cnt % 2:
        ans[i-1] = 1
        m += 1

print(m)
for i in range(N):
    if ans[i] > 0:
        print(i+1, end=' ')
print()


Measured memory_bytes: 64248
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;

  int change = -2;
  int happy = 0;
  S = 'x' + S + 'x';
  REPS(i, 1, (int)S.length()) {
    if(S[i - 1] != S[i]) {
      change++;
    }
    if(S[i - 1] == 'L' && S[i] == 'L') {
      happy++;
    }
    if(S[i] == 'R' && S[i + 1] == 'R') {
      happy++;
    }
  }
  dump(change, happy);
  if(change > K * 2) {
    happy += 2 * K;
  } else {
    happy = N - 1;
  }

  cout << happy << endl;
}


Measured memory_bytes: 512
a,b=map(int,input().split())
def gcd(x,y):
    if x==y:
        return x
    elif x>y:
        r=-1
        while r!=0:
            r=x%y
            x=y
            y=r
        return x
    else:
        r=-1
        while r!=0:
            r=y%x
            y=x
            x=r
        return y

print(a*b//gcd(a,b))


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
int main()
{
 string s;

    cin>>s;
     int len=s.size();
    int n=0,i=0;
    int j=len-1;
while(i<len/2)
{
      if(s[i]!=s[j])
          n++;
          i++;
          j--;
        }
    cout<<n;
}

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<long long> vecll;
typedef vector<unsigned long long> vecull;

int N;
vector<ll> a;

int main(void) {
    cin >> N;

    set<ll> S;
    rep(i, N) {
        ll n;
        cin >> n;

        if (S.find(n) != S.end()) {
            a.push_back(n);
            S.erase(n);
        }
        else {
            S.insert(n);
        }
        
    }

    sort(ALLOF(a));
    reverse(ALLOF(a));

    if (a.size() < 2) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;
    rep(i, 2) {
        ans *= a[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		List<Long> cityList = new ArrayList();
		for (int i=-1; i<n; i++) {
			cityList.add(scan.nextLong());
		}
		
		List<Long> monsterList = new ArrayList();
		for (int i=0; i<n; i++) {
			monsterList.add(scan.nextLong());
		}
		
		long killedMonster = 0;
		for (int i=0; i<n; i++) {
			long city = cityList.get(i);
			long city2 = cityList.get(i+1);
			long killableMonster = monsterList.get(i);
			long amariMonster = city - killableMonster;
			long amariMonster2 = (city + city2) - killableMonster;
			
			if (amariMonster >= 0) {
				killedMonster += killableMonster;
			} else if (amariMonster2 >= 0) {
				killedMonster += killableMonster;
				cityList.set(i+1, (city2 - (killableMonster - city)));
			} else {
				killedMonster += city + city2;
				cityList.set(i+1, (long) 0);
			}
		}
		
		System.out.println(killedMonster);
	}
}

Measured memory_bytes: 93600
import java.util.*;

public class Main {

    static int MOD = 1000000007;
    public static void main(String[] args) {


        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long ans=0;



        ans = x/11*2;
        if(x%11==0);
        else if(x%11<7)ans++;
        else ans +=2;

        System.out.println(ans);

    }

}


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

#define maxn 200050
int tag[maxn<<2],mx[maxn<<2];

void update(int o)
{
	mx[o]=max(mx[o<<1],mx[o<<1|1]);
}

void make_tag(int o,int f)
{
	tag[o]+=f;
	mx[o]+=f;
}

void pushdown(int o)
{
	if (tag[o]!=0){
		make_tag(o<<1,tag[o]);
		make_tag(o<<1|1,tag[o]);
		tag[o]=0;
	}
}

void modify(int o,int l,int r,int L,int R,int f)
{
//	printf("Modiy %d %d %d %d %d %d\n",o,l,r,L,R,f);
	if (L<=l&&r<=R){
		make_tag(o,f);
		return ;
	}
	int mid=(l+r)>>1; pushdown(o);
	if (R>mid) modify(o<<1|1,mid+1,r,L,R,f);
	if (L<=mid) modify(o<<1,l,mid,L,R,f);
	update(o);
}

void build(int o,int l,int r)
{
	if (l==r){
		mx[o]=l;
		tag[o]=0;
		return;
	}
	int mid=(l+r)>>1;
	build(o<<1,l,mid);
	build(o<<1|1,mid+1,r);
	update(o);
}

int query(int o,int l,int r,int L,int R)
{
	if (L<=l&&r<=R) return mx[o];
	int mid=(l+r)>>1; pushdown(o);
	if (R<=mid) return query(o<<1,l,mid,L,R);
	else if (L>mid) return query(o<<1|1,mid+1,r,L,R);
	else return max(query(o<<1,l,mid,L,R),query(o<<1|1,mid+1,r,L,R));
}

vector <int> v[maxn];

int main()
{
	
	#ifdef WXL
	freopen("in.txt","r",stdin);
	#endif
	
	int n,m,ans;
	scanf("%d%d",&n,&m); ans=max(0,n-m);
	for (int i=1;i<=n;++i){
		int x,y;
		scanf("%d%d",&x,&y);
		v[x].push_back(y);
	}
	build(1,0,m+1);
	for (int i=0;i<=m;++i){
		for (int j=0;j<(int)v[i].size();++j){
//			printf("%d -- %d+1\n",0,v[i][j]);
			modify(1,0,m+1,0,v[i][j],1);
		}
//		printf("Mx on %d %d = %d\n",i+1,m+1,query(1,0,m+1,i+1,m+1));
//		printf("%d %d\n",i,query(1,0,m+1,i+1,m+1));
		ans=max(ans,query(1,0,m+1,i+1,m+1)-i-m-1);
	}
	printf("%d\n",ans);
	
}

Measured memory_bytes: 14080
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>


     
#define INF 1e9
#define LINF 1e19
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
     
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
     
const ll MOD = 1e9 + 7;
const ll ZER = 0;



int main(){
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    rep(i, m)cin >> b[i];
    vector<int> a(m);
    ll res = 0;
    while(n--){
        ll sum = 0;
        rep(i, m){
            cin >> a[i];
            sum += a[i] * b[i];
        }
        if(sum + c > 0)res++;
    }
    cout << res << endl;
}





Measured memory_bytes: 3172
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main() {
	string a = "ACGT";
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	vector<int>ans(n+1),sum(n);
	rep(i, n-1) {
		if (s.substr(i, 2) == "AC") {
			ans[i+1]++;
		}
		if (i > 0) {
			ans[i+1] = ans[i+1] + ans[i];
		}
	}
	ans[n ] = ans[n - 1]; 
	rep(i, q) {
		int l, r; cin >> l >> r;
		l--; r--;
		cout << ans[r]-ans[l] << endl;
	}
	

}


Measured memory_bytes: 1792
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from itertools import combinations # (string,3) 3回
#from collections import deque
#import collections.defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    from fractions import gcd
    n = int(input())
    A = readInts()
    g = 0
    for i in range(n):
        g = gcd(g,A[i])
    print(g)
if __name__ == '__main__':
  main()


Measured memory_bytes: 16244
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    vector<int> hoge(3);
    for(int i=0; i<3; i++){
        cin>>hoge.at(i);
    }
    int ans = 99999999;
    for(int i=0; i<3;i++){
        for(int j=0;j<3;j++){
            if(i==j) continue;
            for(int k=0; k<3; k++){
                if(k==i||k==j) continue;
                ans=min(ans, abs(hoge.at(k)-hoge.at(i))+abs(hoge.at(i)-hoge.at(j)));
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
inputs = list(map(int, (input().split())))

a = inputs[0]
b = inputs[1]
c = inputs[2]
if(a == b and b == c and c == a):
    print("No")
    exit(0)

if(a == b or b == c or c == a):
    print("Yes")
else:
    print("No")
exit(0)


Measured memory_bytes: 3060
N, K = map(int, input().split())
S = str(input())

def run_length_encoding(text:str)->list:
    text += '_'
    c = text[0]
    x = 1
    res = []
    for i in range(1, len(text)):
        if c == text[i]:
            x += 1
        else:
            res.append((c, x))
            c = text[i]
            x = 1
    return res

rle = run_length_encoding(S)
gr = len(rle)
hp = 0
for c, x in rle:
    hp += x - 1

if gr == 1:
    ans = hp
elif gr == 2:
    ans = hp + 1
else:
    if K < gr//2:
        ans = hp + 2 * K
    else:
        ans = hp + 2 * ((gr-1) // 2) + (gr-1) % 2
print(ans)

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

long long dp[51][6000] = {};

int main(){
    int n, a;
    cin >> n >> a;

    int x[n];
    for(int i = 0; i < n; i++){
        cin >> x[i];
        x[i] -= a;
    }  

    dp[0][3000] = 1;

    for(int i = 1; i <= n; i++){
        int now = x[i-1];
        for(int j = 0; j < 6000; j++){
            if(dp[i-1][j] == 0) continue;
            int next = j+now;
            if(0 <= next && next < 6000)    dp[i][next] += dp[i-1][j];
            dp[i][j] += dp[i-1][j];        
        }
    }

    cout << dp[n][3000]-1 << endl;

    return 0;
}

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

#define MAX 1000100

using namespace std;

int gcd(int a, int b) { 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 

int findGCD(vector<int> arr, int n) { 
    int result = arr[0]; 
    for (int i = 1; i < n; i++) { 
        result = gcd(arr[i], result); 
  
        if (result == 1) { 
           return 1; 
        }
    } 
    return result; 
}

vector<int> least_dividing_prime(MAX+1, -1);
void sieve() {
    for (int i = 2; i <= MAX; ++i) {
        // i is prime
        if (least_dividing_prime[i] == -1) {
            least_dividing_prime[i] = i;

            for (long long j = (long long) i * i; j <= MAX; j += i) {
                if (least_dividing_prime[j] == -1) {
                    least_dividing_prime[j] = i;
                }
            }
        }
    }
}

unordered_set<int> prime;
unordered_set<int> factor(int n) {
    int k = n, d;
    unordered_set<int> ret;

    while (k != 1) {
        d = least_dividing_prime[k];
        ret.insert(d);
        k /= d;
    }

    return ret;
}

void solve() {
    int n;
    cin >> n;

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

    sieve();

    bool ok = true;
    for (int i = 0; i < n; ++i) {
        unordered_set<int> s = factor(v[i]);
        for (auto &el : s) {
            if (prime.find(el) != prime.end()) {
                ok = false;
                break;
            }
            prime.insert(el);
        }
    }

    if (ok) {
        cout << "pairwise coprime\n";
    } else {
        if (findGCD(v, n) == 1) {
            cout << "setwise coprime\n";
        } else {
            cout << "not coprime\n";
        }
    }
}

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

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

    int t = 1;
    // cin >> t;

    for (int i = 0; i < t; ++i) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 18324
n,l = map(int,input().split())
taste = [l+i-1 for i in range(1,n+1)]
ideal = sum(taste)
bited = [ideal-taste[i] for i in range(n)]
dif = [abs(ideal-bited[i]) for i in range(n)]
print(bited[dif.index(min(dif))]) 

Measured memory_bytes: 3060
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

N, M, K = map(int,input().split())
uf = UnionFind(N)
F = [set() for k in range(N)]
for k in range(M):
    A, B = map(int,input().split())
    uf.union(A-1,B-1)
    F[A-1].add(B-1)
    F[B-1].add(A-1)

T = [0 for k in range(N)]
for k in range(K):
    C, D = map(int,input().split())
    if uf.same(C-1,D-1) == True:
        T[C-1] -= 1
        T[D-1] -= 1
A = []
for k in range(N):
    A.append(uf.size(k)-len(F[k])+T[k]-1)
print(*A)


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

using namespace std;

int
main(void){
	int n, m, x;
	cin >> n >> m >> x;
	vector<vector<int> > vec(n, vector<int> (m));
	vector<int> cost(n);
	for(int i = 0; i < n; i++){
		cin >> cost[i];
		for(int j = 0; j < m; j++){
			cin >> vec[i][j];
		}
	}
	int ans = INT_MAX; 
	for(int i = 0; i < 1<<n; i++){
		vector<int> algo(m);
		int c = 0;
		for(int j = 0; j < n; j++){
			if(i&(1<<j)){
				c += cost[j];
				for(int k = 0; k < m; k++){
					algo[k] += vec[j][k];
				}
			}
		}
		bool flag = true;
		for(int i = 0; i < m; i++){
			if(algo[i] < x) flag = false;
		}
		if(flag){
			ans = min(ans, c);
		}
	}
	if(ans == INT_MAX) cout << -1;
	else cout << ans;
}

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

int main() {
	bool b[1000001];
	int s;
	cin >> s;
	int count = 1;
	while (!b[s]) {
		b[s] = true;
		if (s % 2 == 0) {
			s /= 2;
		} else {
			s = s * 3 + 1;
		}
		count++;
	}
	cout << count << endl;
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    x, y = LI()

    def gcd(x, y):
        if x<y:
            x, y = y, x
        if x%y==0:
            return y
        else:
            return gcd(y, x%y)

    print(gcd(x, y))

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 5608
#include <stdio.h>
#include <set>
#include<utility>
typedef long long ll;

int main(void) {
  std::set< std::pair<ll, ll> > s;
  ll i, j, k, n, a, now = 0, ans = 0;
  s.insert(std::make_pair(0, 1));
  scanf("%lld", &n);
  for(i = 0; i < n; ++i) {
    scanf("%lld", &a);
    now += a;
    std::set< std::pair<ll, ll> >::iterator it;
    it = s.lower_bound(std::make_pair(now, 0));
    if(it != s.end() && (*it).first == now) {
      ans += (*it).second;
      ll tmp = (*it).second;
      s.erase(it);
      s.insert(std::make_pair(now, tmp + 1));
    } else s.insert(std::make_pair(now, 1));
  }
  printf("%lld", ans);
  return 0;
}

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

int main() {
  int n;
  long long diff = 0,c = 0,d = 0;
  int a[10010],b[10010];
  cin >> n;
  for (int i = 0;i < n;++i) cin >> a[i];
  for (int i = 0;i < n;++i) cin >> b[i];
  for (int i = 0;i < n;++i) {
    diff += b[i]-a[i];
    int temp = max(0,(b[i]-a[i]+1)/2);
    c += temp;
    a[i] += 2*temp;
    d += a[i]-b[i];
  }
  cout <<  ((diff >= c && diff >= d) ? "Yes" : "No") << endl;
  return 0;
}

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

int main() {
	int K;
	int H,W;
	cin >> H >> W >> K;
	vector<vector<char>> c(H, vector<char>(W));

	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin >> c.at(i).at(j);
		}
	}

	int ans=0,count=0;
	vector<vector<char>> tmpc(H, vector<char>(W));

	for(int tmpgyou=0;tmpgyou<(1 << H);tmpgyou++){
		for(int tmpretu =0 ;tmpretu <(1<<W);tmpretu++){
//			bitset<6> bitgyou(tmpgyou);
//			bitset<6> bitretu(tmpretu);

			tmpc = c;
			count = 0;
			for(int i=0;i<H;i++){
				for(int j=0;j<W;j++){
					if(tmpgyou & (1 << i)){
						tmpc.at(i).at(j) = '.';
					}
				}
			}

			for(int j=0;j<W;j++){
				for(int i=0;i<H;i++){
					if(tmpretu & (1 << j)){
						tmpc.at(i).at(j) = '.';
					}
				}
			}

			for(int i=0;i<H;i++){
					for(int j=0;j<W;j++){
						if(tmpc.at(i).at(j) == '#') count++;
					}
				}
			if(count == K) ans++;

		}
	}

	cout << ans << endl;

}


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

using namespace std;

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

    long long ans = 1e12;
    for (long long i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ans = min(ans, i + n / i - 2);
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(a) (a).begin(), (a).end()
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define sz() size()
#define fr first
#define sc second
#define int long long
#define mp make_pair
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
using namespace std;

const int nmax = 10000005;

int n,lp[nmax],divi[nmax];
vector<int>pr;

int32_t main(){
   // ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    srand(chrono::steady_clock::now().time_since_epoch().count());
    for (int i=2; i<nmax; ++i) {
        if (lp[i] == 0) {
            lp[i] = i;
            pr.push_back (i);
        }
        for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<nmax; ++j) lp[i * pr[j]] = pr[j];
    }
    cin >> n;
    int ans = 1;
    divi[1] = 1;
    for(int i=2;i<=n;i++){
        int cnt = 0;
        int num = i;
        while(num % lp[i] == 0){
            cnt++;
            num/=lp[i];
        }
        divi[i] = divi[num]*(cnt+1);
        ans += divi[i]*i;
    }
    rc(ans);
}





Measured memory_bytes: 164972
#include <iostream>
#define llint long long

using namespace std;

llint a, b;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> a >> b;
	if(a >= 13)  cout << b << endl;
	else if(a >= 6) cout << b/2 << endl;
	else cout << 0 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
long long h, w;
cin>>h>>w;
if(h==1)
{
cout<<h;
return 0;
}
if(w==1)
{
cout<<w;
return 0;
}
if(h%2==0 || w%2==0)
{
h=(h*w)/2;
}
else
{
h=(h*w)/2+1;
}
cout<<h;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

// index が条件を満たすかどうか
bool isOK(lint index,lint N,lint K,vector<lint>A) {
	lint ans = 0;
	rep(i, N) {
		ans += (A[i] / index + bool(A[i] % index) -1);
	}
	if (ans <= K) {
		return true;
	}
	else {
		return false;
	}
}

// 汎用的な二分探索のテンプレ
lint binary_search(lint N,lint K,vector<lint>A) {
	lint ng = 0; //「index = 0」が条件を満たすこともあるので、初期値は -1
	lint ok = pow(10,9)+1; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* ok と ng のどちらが大きいかわからないことを考慮 */
	while (abs(ok - ng) > 1) {
		lint mid = (ok + ng) / 2;

		if (isOK(mid, N,K,A)) ok = mid;
		else ng = mid;
	}
	return ok;
}

int main() {
	lint N, K;
	cin >> N >> K;
	vector<lint>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	cout << binary_search(N, K, A) << endl;
}

Measured memory_bytes: 7936
n = int(input())
a = list(map(int, input().split()))

a.sort()
if n % 2 == 0:
    for i in range(0, n, 2):
        if a[i] % 2 == 0:
            print(0)
            exit()
        elif a[i] != a[i+1]:
            print(0)
            exit()

else:
    if a[0] != 0:
        print(0)
        exit()
    for i in range(1, n, 2):
        if a[i] % 2 != 0:
            print(0)
            exit()
        elif a[i] != a[i+1]:
            print(0)
            exit()

num = n // 2
ans = (2 ** num) % 1000000007
print(ans)

Measured memory_bytes: 14008
N,K = map(int,input().split())
At = list(map(int,input().split()))
A = [a-1 for a in At]

visited = [False]*(N)
visited[0] = True

dist = [0]*N
cur = 0
idx = 1
result = [0]
while True:
    nxt = A[cur]
    if visited[nxt]:
        amari = dist[nxt]
        MOD = idx - amari
        break
    else:
        visited[nxt] = True
        dist[nxt] = idx
        cur = nxt
        idx += 1
        result.append(cur)

if K<=amari:
    ans = result[K]+1
else:
    K -= amari
    result = result[amari:]
    ans = result[K%MOD]+1
print(ans)



Measured memory_bytes: 110380
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

struct TWO {
	long long int a, b;
};

bool cmp(TWO x, TWO y) {
	return x.a < y.a;
}

//ユークリッドの互除法　a,bは最大公約数を求めたい２つの数
long long int gcd(long long int a, long long int b) {
	long long int tmp;
	long long int r = 1;
	if (b > a) {
		tmp = a;
		a = b;
		b = tmp;
	}
	r = a % b;
	while (r != 0) {


		a = b;
		b = r;
		r = a % b;

	}
	return b;
}


int main() {
	complex<long double>cmpmp;
	const long long int mod = 1000000007,INF=100000000000000;
	map<long long int, long long int>mp;
	string str,str2;
	cout << fixed << setprecision(10);
	long long int n, m, h, w, res = 0, num[200] = {},p[30];
	TWO two[200001];
	cin >>n;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	for (int i = 1; i < n-1; i++) {
		if (p[i]+p[i-1]+p[i+1]-max(p[i - 1], max(p[i], p[i + 1]))-min(p[i - 1], min(p[i], p[i + 1]))==p[i]) {
			res++;
		}
	}
	cout << res;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= int(b); i++)
#define per(i, a, b) for (int i = (a); i >= int(b); i--)
#define fir first
#define sec second
#define tct template<class type>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int maxn = 2e3, mod = 1e9 + 7;
int n, m, fa[maxn + 5][maxn + 5], mrk[maxn + 5][maxn + 5], p, q, res;
vector<int> G[maxn + 5];
vector<P> vec;

inline void red(int &x) { x += x >> 31 & mod; }
tct inline void cmax(type &x, type y) { x < y ? x = y : 0; }
tct inline void cmin(type &x, type y) { x > y ? x = y : 0; }

void pre(int u, int par = 0) {
	fa[p][u] = par;
	for (int v: G[u]) if (v != par) pre(v, u);
}

void dfs(int u, int par = 0) {
	mrk[p][u] = q;
	for (int v: G[u]) if (v != fa[p][u]) {
		if (mrk[p][v]) assert(mrk[p][v] == v), vec.emplace_back(q, v);
		else dfs(v);
	}
}

void work(int u, int w, int par = 0) {
	if (mrk[w][u] == u) res++, w = u;
	for (int v: G[u]) if (v != par) work(v, w, u);
}

int main() {
	scanf("%d %d", &n, &m);
	for (int i = 1, u, v; i < n; i++) {
		scanf("%d %d", &u, &v);
		G[u].emplace_back(v), G[v].emplace_back(u);
	}
	rep(i, 1, n) pre(p = i);
	for (int x, y; m --> 0; ) {
		scanf("%d %d", &x, &y);
		vec.emplace_back(x, y);
		for (int u, v; !vec.empty(); ) {
			u = vec.back().fir, v = vec.back().sec, vec.pop_back();
			while (u != v && mrk[u][v]) u = mrk[u][v];
			while (v != u && mrk[v][u]) v = mrk[v][u];
			if (u == v) continue;
			p = u, dfs(q = v);
			p = v, dfs(q = u);
		}
	}
	rep(i, 1, n) work(i, i);
	printf("%d\n", res >> 1);
	return 0;
}

Measured memory_bytes: 35428
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;

#define MAX 110

int W, H, N;
int x[MAX], y[MAX], a[MAX];
int map[MAX][MAX] = {};

void X1(int n) {
  for(int i=0; i<H; ++i) {
    for(int j=n-1; j>=0; --j)
      map[i][j] = 1;
  }
}

void X2(int n) {
  for(int i=0; i<H; ++i) {
    for(int j=n; j<W; ++j)
      map[i][j] = 1;
  }
}

void Y1(int n) {
  for(int i=n-1; i>=0; --i) {
    for(int j=0; j<W; ++j)
      map[i][j] = 1;
  }
}

void Y2(int n) {
  for(int i=n; i<H; ++i) {
    for(int j=0; j<W; ++j)
      map[i][j] = 1;
  }
}

int main() {
  int res = 0;

  cin >> W >> H >> N;

  for(int i=0; i<N; ++i)
    cin >> x[i] >> y[i] >> a[i];

  for(int i=0; i<N; ++i) {
    switch(a[i]) {
      case 1: X1(x[i]);
              break;
      case 2: X2(x[i]);
              break;
      case 3: Y1(y[i]);
              break;
      case 4: Y2(y[i]);
              break;
    }
  }

  for(int i=0; i<H; ++i) {
    for(int j=0; j<W; ++j) {
      if(map[i][j]==0) ++res;
    }
  }
  
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<cstdio>
#include <algorithm>
bool cmp(int a,int b){
    return a > b;
}
using namespace std;
int main(){
    int n,i;
    long long int c;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++){
        cin>>a[i];}
    sort(a,a+n,cmp);
        c=a[0];
    if(n==2){
        c=a[0];}

    else if(n==3){
        c=a[0]+a[1];}
    else if(n==4){
        c=a[0]+a[1]+a[2];}
    else if(n==5){
        c=a[0]+a[1]*2+a[2];}
    else if(n==6){
       c=a[0]+a[1]*2+a[2]*2;}
    else{
        for(int i=1;i<=(n-3)/2;i++){
            c=c+2*a[i];
        }
        if(n%2==0){
            c=c+2*a[(n-1)/2];
        }
        else{
            c=c+a[(n-1)/2];
        }
    }
    cout<<c;}


Measured memory_bytes: 4380
N = gets.chomp.to_i
A = gets.chomp.split(" ").map(&:to_i)

search = 1
break_cnt = 0

A.each do |a|
  if a == search then
    search += 1
    next
  end

  break_cnt += 1
end

if search == 1 then
  puts "-1"
else
  puts break_cnt
end

Measured memory_bytes: 16772
n=int(input())
a=[[] for x in range(n)]
for i in range(n):
    ai =int(input())
    for j in range(ai):
        xi,yi=[int(x) for x in input().split()]
        xi-=1
        a[i].append((xi,yi))
ans=0
for i in range(2**n):
    validate=[0]*n
    for j in range(n):
        if (i >> j) & 1:
            validate[j]=1
    flag=True
    for k in range(n):
        if validate[k]==0:
            continue
        for xi,yi in a[k]:
            if validate[xi]!=yi:
                flag=False
                break
        if not flag:
            break
    if flag:
        ans=max(ans,sum(validate))
print(ans)

Measured memory_bytes: 44780
import itertools

n = int(input())

array = [i for i in range(1, n + 1)]
gen_array = itertools.permutations(array, n)

a = list(map(int, input().split()))
b = list(map(int, input().split()))

idx = 1
for lis in gen_array:
    if list(lis) == a:
        num_a = idx
    if list(lis) == b:
        num_b = idx
    idx += 1

print(abs(num_a - num_b))


Measured memory_bytes: 3060
// B - Kleene Inversion
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD 1000000007

int main(){
	ll N,K; cin>>N>>K;
	vector<ll> A(N);
	ll L = 0, M = 0;
	for(int i=0; i<N; i++){
		cin>>A[i];
		for(int j=i-1; j>=0; j--) if(A[i]<A[j]) L++;
	}

	for(int i=0; i<N; i++)
		for(int j=0; j<N; j++) if(i!=j && A[i]>A[j]) M++;

	ll KC2 = K%2? (K-1)/2: K/2;
	KC2 = K%2? KC2 * K % MOD: (K-1) * KC2 % MOD;

	ll a = L * K % MOD;
	ll b = M * KC2 % MOD;
	cout<< (a+b) % MOD << endl;
}

Measured memory_bytes: 256
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ll n, m, x; cin >> n >> m >> x;
	vector<vector<ll>> prices;
	forl(i, 0, n) {
		vector<ll> temp;
		forl(i, 0, m+1) { ll a; cin >> a; temp.push_back(a); }
		prices.push_back(temp);
	}
	ll mincost = INT_MAX;
	forl(i, 0, 1<<n) {
		ll curcost = 0, inst = 1;
		vector<ll> costs(m);
		forl(j, 0, 33) {
			if(i&inst) {
				curcost += prices[j][0];
				forl(k, 1, m+1) costs[k-1] += prices[j][k];
			}
			inst <<= 1;
		}
		bool good = true;
		forl(j, 0, m) if(costs[j] < x) good = false;
		if(good) mincost = min(mincost, curcost);
	}
	if(mincost == INT_MAX) println("-1");
	else println(mincost);
}


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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int gcdd(int a, int b) {
  if(a % b == 0) return b;
  else return gcdd(b, a % b);
}

int lcmm(int a, int b) {
  return a / gcdd(a, b) * b;
}

signed main() {
	ll x, y;
  cin >> x >> y;
  cout << (x + y + 1 - gcdd(x, y)) << endl;
	return 0;
}


Measured memory_bytes: 3236
import math.max
object Main extends App {
    val Array(n, m) = io.StdIn.readLine.split(" ").map(_.toInt)
    val hs = io.StdIn.readLine.split(" ").map(_.toInt)
    val abs = for (_ <- 1 to m) yield io.StdIn.readLine.split(" ").map(_.toInt)

    val ma = Array.fill(n)(0)
    for (ab <- abs) {
        val indexA = ab.head-1
        val indexB = ab.last-1
        ma(indexA) = max(ma(indexA), hs(indexB))
        ma(indexB) = max(ma(indexB), hs(indexA))
    }

    var ans = 0
    for (i <- 0 until n) {
        if (hs(i) > ma(i)) ans+=1
    }
    println(ans)
}

Measured memory_bytes: 66020
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    N, *A = map(int, read().split())
    ans = 0
    for a in A[::2]:
        if a % 2 == 1:
            ans += 1
    print(ans)
    return

if __name__ == '__main__':
    main()


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

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

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

	int sum = 0;

	for (int i = 0; i < n; i+= 2)
	{
		if (a[i] % 2 == 1)
		{
			sum++;
		}
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int x;
	VI cnt(109);
	while (cin >> x) {
		//if (x == 0)break;
		cnt[x]++;
	}
	int max = *max_element(all(cnt));
	FOR(i, 1, 101) {
		if (cnt[i] == max)cout << i << endl;
	}
}


Measured memory_bytes: 3056
<?php

$s = trim(fgets(STDIN));
// var_dump($s);
$length = strlen($s);
$len_top = (($length-1)/2);
$top = [];
for($i=0; $i<$len_top; $i++){
    $top[] = $s[$i];
}
$back = [];
$len_back = ($length+3)/2;
for($i=$len_back-1; $i< $length; $i++){
    $back[] = $s[$i];
}

if($top == $back){
    echo "Yes";
}else{
    echo "No";
}
// var_dump($top);


?>

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

using namespace std;

#define uniq(x)  x.erase(unique(x.begin(),x.end()), x.end()) //Unique value find from vector
#define upper(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Upper value search;
#define lower(arr,n,fixed) lower_bound(arr,arr+n,fixed)-arr  //Lower value search;
#define remvec(vec,val) vec.erase(remove(vec.begin(), vec.end(), val), vec.end())  // remove val from vector
#define FOR(i,a,n) for(int i=a; i<(int)n; i++)
#define FORI(i,a,n) for(int i=a; i>=(int)n; i--)
#define pii pair<int,int>
#define vpii vector<pii>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(a) int((a).size())
#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0)
#define endl "\n"
#define all(a) a.begin(), a.end()
#define MEMSET(p,i) memset(p,i,sizeof(p))

	
// int to string c++
#define SSTR(x) static_cast< std::ostringstream & >( \
		( std::ostringstream() << std::dec << x ) ).str()


int main(void)
{
	
	fastIO();
	string s;

	cin >> s;
	int n = sz(s);
	cout << s[0] << n-2 << s[n-1] << endl;
	
	


	return 0;
}

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

using namespace std;

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

	int n, k;
	cin >> n >> k;

	vector<int> v(n);
	vector<int> dp(n, INT_MAX);

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

	dp[0] = 0;
	for (int i = 0; i < n - 1; i++)
	{
		int j = 1;
		while (j <= k)
		{
			if (i + j < n)
			{
				dp[i + j] = min(dp[i + j], dp[i] + abs(v[i + j] - v[i]));
			}
			else
			{
				break;
			}
			j++;
		}
	}

	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if(a < b) return gcd(b, a);
  int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
  int N, K; cin >> N >> K;
  vector<int> MY(N);
  for(int i=0;i<N;i++){
    cin >> MY[i];
  }
  sort(MY.begin(),MY.end());
  int GCD=MY[0];
  if(MY[N-1]<K){
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  for(int i=0;i<N;i++){
    GCD=gcd(GCD,MY[i]);
  }
  if(K%GCD==0){
    cout << "POSSIBLE" << endl;
  }
  else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
#include<cmath>
#include<iomanip>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
int main() {
	ll A, V;
	cin >> A >> V;
	ll B, W;
	cin >> B >> W;
	ll T;
	cin >> T;
	if (V <= W) {
		cout << "NO" << endl;
	}
	else {
		ll D = abs(A - B);
		if (D <= T*(V - W)) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3572
import java.util.ArrayList;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int K = scanner.nextInt();
		int d,a;
		ArrayList<Integer>array = new ArrayList<Integer>();

		for(int i=0; i<K; i++) {
			d = scanner.nextInt();
			for(int j=0; j<d; j++) {
				a = scanner.nextInt();
				if( !array.contains(a) ) {
					array.add(a);
				}
			}
		}

		System.out.println( N - array.size() );

		scanner.close();


	}

}


Measured memory_bytes: 46228
#include <bits/stdc++.h>
using namespace std;
int main () {
  int W, a, b;
  cin >> W >> a >> b;
  if(a > b) swap(a, b);
  if(a <= b && a + W >= b)cout << 0 << endl;
  else cout << b - a - W << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
static const int MAX = pow(10, 5);
// chokudaiさんのまね
int main()
{
    int N, K;
    std::string S;
    scanf("%d %d", &N, &K);
    std::cin >> S;
    int ans = 0;
    std::vector<int> Nums;
    int now = 1; // 今見ている数 
    int cnt = 0; // nowが幾つ並んでいるか
    for (int i = 0; i < N; ++i)
    {
        if (S[i] == (char)('0' + now)) cnt++;
        else
        {
            Nums.push_back(cnt);
            now = 1 - now; // 見る数を切り替える(0 < -- > 1)
            cnt = 1;
        }
        
    }
    if (cnt != 0) Nums.push_back(cnt); //末尾まで連続していた場合も忘れずに格納する
    
    // 0で終わっていた場合、適当に一つ足す
    if (Nums.size() % 2 == 0) Nums.push_back(0);
    
    int Add = 2 * K + 1;

    int left = 0;
    int right = 0;
    int tmp = 0; // [left, right)のsum

    for (int i = 0; i < Nums.size(); i += 2)
    {
        int nextleft = i;
        int nextright = std::min(i + Add, (int)Nums.size());

        // 左端を移動
        while(nextleft > left)
        {
            tmp -= Nums[left];
            ++left;
        }
        // 右端を移動
        while(nextright > right)
        {
            tmp += Nums[right];
            ++right;
        }
        ans = std::max(tmp, ans);
    }

    printf("%d\n", ans);
    return 0;
}

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

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

    long long n;
    cin >> n;

    if (n & 1) {
        cout << 0 << endl;
        return 0;
    }

    long long ans = 0, cnt = 0, k;
    int P = 30;
    __uint128_t p = 1;
    for (int i = 0; i < P; i++) {
        p *= 5;
    }
    for (int i = P; i > 0; i--) {
        k = n / p / 2;
        ans += i * (k - cnt);
        cnt = k;
        p /= 5;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <unordered_map>
#include <math.h>
#include <bitset>
#include <vector>
using namespace std;
 
int main() {
    int a[3000],n;
    unsigned ans=0;
    cin >>n;
    for(int i=0;i<n;i++){
        cin >>a[i];
        ans+=a[i]-1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	998244353

ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	while (ll r = a % b)
		a = b, b = r;
	return b;
}

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

	ll modinv(ll a)
	{
		ll b = max, u = 1, v = 0;
		while (b)
		{
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= max;
		if (u < 0)
			u += max;
		return u;
	}

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

int main()
{
	double a, b, h, m;
	cin >> a >> b >> h >> m;

	double c = a * a + b * b;
	double rad = m / 720;
	rad -= m / 60;
	rad += h / 12;
	rad *= 2 * M_PI;
	if (rad > M_PI)
		rad = 2 * M_PI - rad;

	c -= 2 * a * b * cos(rad);
	c = sqrt(c);

	printf("%.16f", c);

	return 0;
}

Measured memory_bytes: 3664
import sys

h, w = map(int, sys.stdin.readline().split())
canvas = ['#' * (w + 2)] + ['#' + sys.stdin.readline().rstrip() + '#' for _ in range(h)] + ['#' * (w + 2)]

def main():
    return canvas

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

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

#define MOD 1000000007

long long digit[60];
long long pow2[60];

signed main(){
	pow2[0]=1;
	for(int i=1;i<60;i++){
		pow2[i]=(pow2[i-1]*2)%MOD;
	}
	long long n;	cin>>n;
	vector<long long> a(n);
	for(long long i=0;i<n;i++){
		cin>>a[i];
	}

	for(int i=0;i<n;i++){
		for(int j=0;j<60;j++){
			if((a[i]>>j)&1){
				digit[j]++;
			}
		}
	}

	long long ans=0;
	for(int i=0;i<60;i++){
		long long tmp=( digit[i]*(n-digit[i]) )%MOD;

		ans+=(pow2[i] * tmp)%MOD;
		ans%=MOD;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long int N, A, P[100000] = { 0 }, count = 1;
	bool check = true;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A;
		if (A % 2 == N % 2) check = false;
		if (P[A] == 2) check = false;
		if (A == 0 && P[A] == 1) check = false;
		P[A]++;
	}
	if (check) {
		for (int i = 0; i < N / 2; i++) {
			count *= 2;
			count = count % 1000000007;
		}
	}
	else count--;
	cout << count;
}

Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;


int main(){
    int n,m;cin>>n>>m;
    vector<int>a(m);
    rep(i,m)cin>>a[i];
    int dp[n+1];
  int mod = INF+7;
    rep(i,n+1)dp[i] = 0;
    dp[0] = 1;
    REP(i,1,n){
      if(m>0){if(i == *lower_bound(ALL(a),i))continue;
        else dp[i] += dp[i-1];
      }
      else{
          dp[i]+= dp[i-1];
      }
      
        if(i>1){
            if(a.size()>0){
                if(i == *lower_bound(ALL(a),i)){
                continue;
            }
            else  {
                dp[i] += dp[i-2];
            }
            }
            else {
                dp[i] += dp[i-2];
            }
        }
      dp[i] %= mod;
    }
    cout<<dp[n];
}



Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
using namespace std;
 
int main(void){
    int n;
    cin >> n;
    vector<pair<pair<string,int>,int>> rest(n);
    for(int i = 0;i < n;i++){
        cin >> rest[i].first.first >> rest[i].first.second;
        rest[i].first.second *= -1;
        rest[i].second = i+1;
    }
 
    sort(rest.begin(),rest.end());
 
    for(int i = 0;i < n;i++){
        cout << rest[i].second << endl;
    }
 
    return 0;
}

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

int main(){
    int a,b;
    bool ans = true;
    cin >>a >>b;
    if((a + b) % 2 ==0){
        cout << (a+b)/2 << endl; 
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 888