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

using ll = long long;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

class Combination {
    vector<ll> factorial;
    vector<ll> fact_inverse;
    vector<ll> inverse;
    int mod;

    void init(int size) {
        factorial[0] = 1;
        factorial[1] = 1;
        fact_inverse[0] = 1;
        fact_inverse[1] = 1;
        inverse[1] = 1;

        for (int i = 2; i < size; i++) {
            factorial[i] = factorial[i - 1] * i % mod;
            inverse[i] = mod - inverse[mod % i] * (mod / i) % mod;
            fact_inverse[i] = fact_inverse[i - 1] * inverse[i] % mod;
        }
    }

    public:
        Combination(int size, int m) {
           factorial = vector<ll>(size);
           fact_inverse = vector<ll>(size);
           inverse = vector<ll>(size);
           mod = m;
           init(size);
        }
    
        ll calc(int n, int k) {
            if (n < k) {
                return 0;
            }
            if (n < 0 || k < 0) {
                return 0;
            }
            return factorial[n] * (fact_inverse[k] * fact_inverse[n - k] % mod) % mod;
        }

        ll with_repetition(int n, int k) {
            return calc(n + k - 1, k);
        }
};

void solve() {
    int x, y;
    cin >> x >> y;
    if ((x + y) % 3 != 0) {
        cout << 0 << EOL;
        return;
    }

    Combination c(1000000, MOD);
    cout << c.calc((x + y) / 3, x - ((x + y) / 3)) << EOL;
}


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

int main(){
    int n, k;
    cin >> n >> k;
    vector<long long int> v;
    long long int sum = 0;
    for(int i=0;i<n;++i){
        long long int a;
        cin >> a;
        v.push_back(a);
        sum += max(a, 0ll);
    }

    if(k == 1)cout << sum << endl;
    else{
        long long int plus = 0, minus = 0;
        int left = 0, right = k - 1;
        for(int i=0;i<k;++i){
            plus += max(v[i], 0ll);
            minus += min(v[i], 0ll);
        }
        long long int ans = 0;
        while(right < n){
            ans = max(ans, sum + minus);
            ans = max(ans, sum - plus);
            if(v[left] < 0)minus -= v[left];
            else plus -= v[left];
            left++;
            right++;
            if(right >= n)break;
            if(v[right] < 0)minus += v[right];
            else plus += v[right];
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 1400
S = input()
ans = 0
for i in range(2**(len(S)-1)):  # 総当たり
    tmp = S[0]  # 先頭だけ格納
    for j in range(len(S)-1):   # mask
        if i & (1<<j):  # iと1をjbitシフトしたものを比較
            tmp += "+"
        tmp += S[j+1]
    ans += eval(tmp)
print(ans)


Measured memory_bytes: 2940
if __FILE__ == $0
	while line = gets
		args = line.split(" ").map{|e|e.to_f}
		a = args[0]
		b = args[1]
		c = args[2]
		d = args[3]
		e = args[4]
		f = args[5]

		y = (a * f - d * c) / (a * e - d * b)
		x = (c - b * y) / a
		
		puts "#{sprintf("%.03f", x)} #{sprintf("%.03f", y)}"
	end
end

Measured memory_bytes: 8648
from bisect import bisect_left
a,b,q = map(int,input().split())
inf = float('inf')
S = [-inf]+[int(input()) for i in range(a)]+[inf]
T = [-inf]+[int(input()) for i in range(b)]+[inf]

def f(S,T):
    res = 10**30 
    s = bisect_left(S,x)

    ans = 0
    t = bisect_left(T,S[s-1])
    ans += abs(x-S[s-1])+min(abs(S[s-1]-T[t-1]),abs(S[s-1]-T[t]))
    if ans <= res:
        res = ans
    
    ans = 0
    t = bisect_left(T,S[s])
    ans += abs(x-S[s])+min(abs(S[s]-T[t-1]),abs(S[s]-T[t]))
    if ans <= res:
        res = ans

    return res


for i in range(q):
    x = int(input())
    print(min(f(S,T),f(T,S)))


Measured memory_bytes: 12800
divisor = 10 ** 9 + 7
h, w = map(int, input().split())
a = [input() for _ in range(h)]
dp = [[0] * w for _ in range(h)]
dp[0][0] = 1
for i in range(h):
  for j in range(w):
    if i + 1 < h and a[i + 1][j] != '#':
      dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % divisor
    if j + 1 < w and a[i][j + 1] != '#':
      dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % divisor
print(dp[h - 1][w - 1])


Measured memory_bytes: 43712
N, T = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(N)]

import sys
from operator import itemgetter

data.sort(key=itemgetter(0))

for d in data:
	if d[1] <= T:
		print(d[0])
		sys.exit()

print('TLE')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define per(i,a,n) for(int i=(n)-1;i>=(a);i--)
#define MP make_pair

typedef double db;

const db EPS = 1e-8;

inline int sign(db a) {
	return a < -EPS ? -1 : a > EPS;
}

inline int cmp(db a, db b){
	return sign(a-b);
}

struct P {
	db x, y;
	P() {
	}
	P(db _x, db _y) :
			x(_x), y(_y) {
	}
	P operator+(P p) {
		return P(x + p.x, y + p.y);
	}
	P operator-(P p)  {
		return P(x - p.x, y - p.y);
	}
	P operator*(db d) {
		return P(x * d, y * d);
	}
	P operator/(db d) {
		return P(x / d, y / d);
	}
	bool operator<(P p) const {
		int c = sign(x - p.x);
		if (c)
			return c == -1;
		return sign(y - p.y) == -1;
	}
	db dot(P p) {
		return x * p.x + y * p.y;
	}
	db det(P p) {
		return x * p.y - y * p.x;
	}
	db distTo(P p) { return (*this-p).abs(); }

	db alpha() {
		return atan2(y, x);
	}
	void read() {
		cin>>x>>y;
	}
	db abs() {
		return sqrt(abs2());
	}
	db abs2() {
		return x * x + y * y;
	}
	P rot90(){
		return P(-y,x);
	}
};

#define cross(p1,p2,p3) ((p2.x-p1.x)*(p3.y-p1.y)-(p3.x-p1.x)*(p2.y-p1.y))
#define crossOp(p1,p2,p3) sign(cross(p1,p2,p3))

P isLL(P p1, P p2, P q1, P q2) {
	db a1 = cross(q1, q2, p1), a2 = -cross(q1, q2, p2);
	return (p1 * a2 + p2 * a1) / (a1 + a2);
}

bool intersect(db l1,db r1,db l2,db r2){
	if(l1>r1) swap(l1,r1); if(l2>r2) swap(l2,r2); 
	return !( cmp(r1,l2) == -1 || cmp(r2,l1) == -1 );
}

bool isSS(P p1, P p2, P q1, P q2){
    return intersect(p1.x,p2.x,q1.x,q2.x) && intersect(p1.y,p2.y,q1.y,q2.y) && 
    crossOp(p1,p2,q1) * crossOp(p1,p2,q2) <= 0 && crossOp(q1,q2,p1)
            * crossOp(q1,q2,p2) <= 0;
}

bool isMiddle(db a, db m, db b) {
    return sign(a - m) == 0 || sign(b - m) == 0 || (a < m != b < m);
}
 
bool isMiddle(P a, P m, P b) {
    return isMiddle(a.x, m.x, b.x) && isMiddle(a.y, m.y, b.y);
}

bool onSegment(P p1, P p2, P q){
	return crossOp(p1,p2,q) == 0 && isMiddle(p1, q, p2);
}

P proj(P p1, P p2, P q) {
    P dir = p2 - p1;
    return p1 + dir * (dir.dot(q - p1) / dir.abs2());
}

P reflect(P p1, P p2, P q){
	return proj(p1,p2,q) * 2 - q;
}

db nearest(P p1,P p2,P q){
	P h = proj(p1,p2,q);
	if(isMiddle(p1,h,p2))
		return q.distTo(h);
	return min(p1.distTo(q),p2.distTo(q));
}

db disSS(P p1, P p2, P q1, P q2){
	if(isSS(p1,p2,q1,q2)) return 0;
	return min(min(nearest(p1,p2,q1),nearest(p1,p2,q2)), min(nearest(q1,q2,p1),nearest(q1,q2,p2)) );
}

db getrad(P p1,P p2){
	return atan2l(p1.det(p2),p1.dot(p2));
}

db incircle(P p1, P p2, P p3){
	db A = p1.distTo(p2);
	db B = p2.distTo(p3);
	db C = p3.distTo(p1);
	return sqrtl(A*B*C/(A+B+C));
}

db area(vector<P> ps){
	db ret = 0; rep(i,0,ps.size()) ret += ps[i].det(ps[(i+1)%ps.size()]); 
	return abs(ret/2);
}

int main(){
	int n;cin>>n;
	vector<P> ps(n);
	rep(i,0,n) ps[i].read();
	printf("%0.1f\n",area(ps));
	return 0;
}

Measured memory_bytes: 3200
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iostream>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

int N;

int main(int argc, char const *argv[]) {
	cin >> N;
	int a;
	int cnt = 0;
	map<int, int> mp;

	for (int i = 0; i < N; i++) {
		cin >> a;
		a--;
		if (!mp.count(a)) {
			mp[a] = 0;
			cnt++;
		}
		else mp[a]++;
	}

	if ((N - cnt) % 2 == 0) cout << cnt << endl;
	else cout << cnt - 1 << endl;

	return 0;
}

Measured memory_bytes: 4864
n,x=map(int,input().split())

l=[int(x) for x in input().split()]
d=0
cnt=1
for i in l:
    d+=i
    cnt+=1
    if d > x:
        print(cnt-1)
        break
    elif d==x:
        print(cnt)
        break
if d<x:
    print(cnt)    


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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int a[10][10];

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

	int n, d;
	cin >> n >> d;

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

	auto dist = [&] (int i, int j) {
		int ans = 0;
		for (int k = 0; k < d; k++) {
			ans += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);
		}
		return ans;
	};

	auto sqr = [&] (int x) {
		int r = sqrt((LD) x) + 1e-9;
		return r * r == x;
	};

	int cnt = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int x = dist(i, j);
			if (sqr(x)) {
				cnt++;
			}
		}
	}

	cout << cnt << "\n";
    return 0;
}


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

using namespace std;

typedef long long ll;

#define eps 1e-9
#define all(a)   a.begin(),a.end()
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define sz size()
#define rd(inp) scanf("%lld",&inp)
#define rd2(inp1, inp2) scanf("%lld %lld",&inp1, &inp2)
#define rl(inp) scanf("%d",&inp)
#define pf(out) printf("%lld\n", out);

const long long linf = 1e18+5;
const int mod = (int) 1e9 + 7;
const int inf = 1e9;

ll read(){
	bool minus = false;
	ll result = 0;
	char ch;
	ch = getchar();
	while (true) {
		if (ch == '-') break;
		if (ch >= '0' && ch <= '9') break;
		ch = getchar();
	}
	if (ch == '-') minus = true; else result = ch-'0';
	while (true) {
		ch = getchar();
		if (ch < '0' || ch > '9') break;
		result = result*10 + (ch - '0');
	}
	if (minus){
		return -result;
	}
	else{
		return result;
	}
}

ll fpow(ll base,ll power){
	ll result = 1;
	while (power > 0){
		if (power%2 == 1) result=(result*base);
  		base = (base*base);
  		power /= 2;
  	}
	return result;
}

vector<ll> v;

void calc(){
	ll i, j;
	bool f = false;
	for ( i = 2 ; i <= 1000 ; i ++ ){
		f = 0;
		for ( j = 2 ; j <= sqrt(i) ; j ++ ){
			if ( i%j == 0 ){
				f = 1;
			}
		}
		if ( !f ){
			v.pb(i);
		}
	}
}

ll go(ll n, ll d){
	ll p = 1;
	ll res = 0;
	ll in = d;
	while ( n / d > 0 ){
		res += n / d;
		p ++;
		d = fpow(in, p);
	}
	return res;
}

int main(){
	ll n, i;
	cin >> n;
	calc();
	ll ans = 1;
	for ( i = 0 ; i < v.sz ; i ++ ){
		if ( v[i] <= n ){
			ans = (ans%mod * (1 + go(n, v[i])) % mod) % mod;
		}
	}
	pf(ans);
	return 0;	
}

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


int main(){
	
	int n,m;
	cin>>n>>m;
	vector<int> arr;
	int x;
	for(int i=0;i<m;i++){
		cin>>x;
		arr.push_back(x);
	}
	int sum =0;
	for(auto i : arr){
		sum += i;
	}
	if(sum>n){
		cout<<-1;
		return 0;
	}
	cout<<n-sum;
	
	
}

Measured memory_bytes: 3676
N = int(input())
matrix = []

T = list(map(int, input().split()))

M = int(input())

for i in range(M):
  p,x = map(int, input().split())
  # matrix.append(list(map(int, input().split())))
  # p = matrix[0][0]
  # x = matrix[0][1]
  # print(T[p])
  print(sum(T) - (T[p-1] - x))
  # a = sum(T) - (T[p-1] - x)


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;

class Program {
    static void Main(string[] args) {
        int N = int.Parse(Console.ReadLine());
        string[] a = Console.ReadLine().Split(' ');

        long result=0;

        int now = 1;

        for(int s = 0; s < N; s++) {
            int As= int.Parse(a[s]);
            if (now != As) {
                result++;
            } else {
                now++;
            }

        }

        if (result == N) result = -1;

        Console.WriteLine(result);
    }
}

Measured memory_bytes: 30684
#include<bits/stdc++.h>
#define mod 998244353
using namespace std;
map<string, int>mp1, mp2;
string s;
int solve(string s);
int check(string s)
{
	if (mp2.find(s) != mp2.end())
		return mp2[s];
	int& res = mp2[s], l = s.size();
	if (l == 1)return res = s[0] - '0' + 1;
	for (int i = 1; i < l; i++)
		if (l % i == 0)
		{
			string ss(i, '1');
			for (int j = 0; j < l; j++)
				if (s[j] == '0')
					ss[j % i] = '0';
			res = (res + solve(ss)) % mod;
		}
	return res;
}
int solve(string s)
{
	if (mp1.find(s) != mp1.end())
		return mp1[s];
	int& res = mp1[s], l = s.size();
	for (int i = 1; i <= l; i++)
		res = (res + 1LL * check(s.substr(0, i)) * solve(s.substr(i)) % mod) % mod;
	return res;
}
int main()
{
	cin >> s;
	mp1[string()] = mp2[string()] = 1;
	cout << solve(s) << endl;
	return 0;
}

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

using namespace std;

int main() {

	int n;
	cin >> n;

	vector<int> x(n, 0);
	vector<int> y(n, 0);
	vector<long long> h(n, 0);

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

	bool finflg = true;
	for (int cx = 0; cx < 101; cx++) {
		for (int cy = 0; cy < 101; cy++) {

			finflg = true;
			long long karih = 0;
			int counter = 0;
			for (int i = 0; i < n; i++) {
				if (h[i] != 0 && counter == 0) {
					karih = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
					counter = 1;
				}
				else if (h[i] != 0) {
					if (karih != h[i] + abs(x[i] - cx) + abs(y[i] - cy)) {
						finflg = false;
						break;
					}
				}
			}
			for (int i = 0; i < n; i++) {

				if (h[i] == 0 ) {
					if (karih - abs(x[i] - cx) - abs(y[i] - cy)>0) {
						finflg = false;
						break;
					}
				}

			}
			if (finflg==true) {
				cout << cx << " " << cy << " " << karih << endl;
				return 0;
			}

		}
	}

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int maxn=3e5+5, INF=1e9;
int n, l, numW, numE, ans=INF; char s[maxn];

int main(){
    scanf("%d%s", &n, s); l=strlen(s);
    for (int i=0; i<l; ++i) if (s[i]=='E') ++numE;
    if (s[0]=='E') --numE; ans=min(ans, numW+numE);
    for (int i=1; i<l; ++i){
        if (s[i-1]=='W') ++numW;
        if (s[i]=='E') --numE;
        ans=min(ans, numW+numE);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 512
N,A,B,C,D=map(int,raw_input().split());Z=[1]+[0]*N;M=10**9+7;I=[1,1];F=I+[];R=I+[]
for i in range(2,N+1):I+=[(M-M/i)*I[M%i]%M];F+=[i*F[-1]%M];R+=[I[i]*R[-1]%M]
for i in range(A,B+1):Z=[(Z[j]+sum(Z[j-i*k]*F[N-j+i*k]*R[N-j]*pow(R[i],k,M)*R[k]for k in range(C,min(D,j/i)+1)))%M for j in range(N+1)]
print Z[N]

Measured memory_bytes: 53532
/// wa ^3^

#pragma GCC optimize("O3")

#include<bits/stdc++.h>
                           
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

void stndrtn() {
#ifdef accepted
    freopen(".in", "r", stdin);
#endif        
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), stndrtn();
    int n;
    cin >> n;
    ll res = 0;
    vector<int> a(n), cnt(n*2);
    for (int& x : a) {
        cin >> x;
        res += cnt[x]++;
    }    
    for (int x : a) {
        res -= --cnt[x];
        cout << res << "\n";
        res += cnt[x]++;
    }
    return 0;
}



Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <stack>
#include <queue>

typedef long long ll;

using namespace std;

int main(void){
	int a, b, t; cin >> a >> b >> t;
	cout << (t/a)*b << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))
#define INF INT_MAX

using namespace std;
using LL=long long;

const int M=1046527;
const int NIL=-1;
const int L=14;

char H[M][L];

int getChar(char ch){
    if(ch=='A') return 1;
    else if(ch=='C') return 2;
    else if(ch=='G') return 3;
    else if(ch=='T') return 4;
    else return 0;
}

long long getKey(char str[]){
    long long sum=0,p=1,i;
    for(i=0;i<strlen(str);i++){
        sum +=p*(getChar(str[i]));
        p*=5;
    }
    return sum;
}

int h1(int key){return key%M;}
int h2(int key){return 1+(key%(M-1));}

int find(char str[]){
    long long key,i,h;
    key=getKey(str);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0) return 1;
        else if(strlen(H[h])==0) return 0;
    }
    return 0;
}

int insert(char str[]){
    long long key,i,h;
    key=getKey(str);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0) return 1;
        else if(strlen(H[h])==0){
            strcpy(H[h],str);
            return 0;
        }
    }
    return 0;
}

int main(){
    int i,n,h;
    char str[L],com[9];
    for(i=0;i<M;i++) H[i][0]='\0';
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s %s",com,str);
        if(com[0]=='i'){
            insert(str);
        }
        else{
            if(find(str)){
                printf("yes\n");
            }
            else{
                printf("no\n");
            }
        }
    }
    return 0;
}



Measured memory_bytes: 17432
import sys

letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
table = [0 for i in range(26)]
#input_str = input()
input_str = sys.stdin.read()

for i in input_str:
    index = 0
    for j in letters:
        #print(i, j)
        if i == j:
            table[index % 26] += 1
        index += 1

for i in range(26):
    print(f"{letters[i]} : {table[i]}")


Measured memory_bytes: 5580
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) ((x).begin()),((x).end())
#define int ll
using pii = pair <int, int>;
#define INF 0x7f7f7f7f7f7f7f7f
const bool debug = 0;
const int mod = 1000000007;

vector <int> snuke[105];
int32_t main()
{
    int n, k; cin >> n >> k;
    for (int i = 1; i<=k; i++)
    {
        int d; cin >> d;
        for (int j = 1; j<=d; j++)
        {
            int x; cin >> x;
            snuke[x].push_back(i);
        }
    }
    int ct = 0;
    for (int i = 1; i<=n; i++)
    {
        ct += snuke[i].empty();
    }
    cout << ct << '\n';
}

Measured memory_bytes: 3672
#include <cstdio>
#include <vector>
#include <string>
#include <memory.h>
using namespace std;

const int N = 500500;

const int AL = 26;

struct node {
    int to[AL];
    node() {
        memset(to, -1, sizeof(to));
    }
};

int bpt = 1;

node B[N];

string S[N];

char buf[N];

int term[N];
int sz[N];
int ver[N];

string Q[N];
int ans[N];

vector<int> queries[N];

void add(const string& s, int id) {
    int cur = 0;
    for (char c : s) {
        sz[cur]++;
        if (B[cur].to[c - 'a'] == -1)
            B[cur].to[c - 'a'] = bpt++;
        cur = B[cur].to[c - 'a'];
    }
    sz[cur]++;
    term[cur]++;
    ver[id] = cur;
}

int cnt[AL][AL];

int pos[AL];
void to_pos(const string& q) {
    for (int i = 0; i < (int)q.size(); i++) {
        pos[q[i] - 'a'] = i;
    }
}

void DFS(int x, int shorter) {
    for (int q : queries[x]) {
        to_pos(Q[q]);
        ans[q] = shorter;
        for (int i = 0; i < AL; i++) {
            for (int j = 0; j < AL; j++) {
                if (pos[j] < pos[i]) {
                    ans[q] += cnt[i][j];
                }
            }
        }
    }
    for (int i = 0; i < AL; i++) {
        int y = B[x].to[i];
        if (y == -1)
            continue;
        for (int j = 0; j < AL; j++) {
            if (B[x].to[j] != -1) {
                cnt[i][j] += sz[B[x].to[j]];
            }
        }
        DFS(y, shorter + term[x]);
        for (int j = 0; j < AL; j++) {
            if (B[x].to[j] != -1) {
                cnt[i][j] -= sz[B[x].to[j]];
            }
        }
    }
}

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%s", buf);
        S[i] = buf;
        add(S[i], i);
    }
    int q;
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        int k;
        scanf("%d", &k);
        --k;
        scanf("%s", buf);
        Q[i] = buf;
        queries[ver[k]].emplace_back(i);
    }
    DFS(0, 0);
    for (int i = 0; i < q; i++) {
        printf("%d\n", ans[i] + 1);
    }
}


Measured memory_bytes: 99064
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		int ans = keta(N);
		for(long i = 1;i <= N / i;i++){
			if(N % i == 0){
				ans = Math.min(ans,keta(Math.max(N / i,i)));
			}
		}
		System.out.println(ans);
	}
	public static int keta(long a){
		int count = 1;
		long buf = a;
		while(buf / 10 != 0){
			count++;
			buf = buf / 10;
		}
		return count;
	}
}

Measured memory_bytes: 23764
#include <stdio.h>

int main(void){
	int n, k,i,j,con,ab,count=0;
	scanf("%d %d", &n, &k);
	int have[n];
	for (i = 0; i < n; i++) {
		have[i] = 0;
	}

	for (i = 0; i < k; i++) {
		scanf("%d", &con);
		for (j = 0; j < con; j++) {
			scanf("%d", &ab);
			have[ab-1] = 1;
		}
	}

	for (i = 0; i < n; i++) {
		if (have[i] == 0)count++;
	}
	printf("%d", count);

	
	return 0;
}

Measured memory_bytes: 1732
#include <iostream>

using namespace std;

bool initComb(bool* b, int n)
{
	if (n>10) return false;
	for (int i=0; i<n; i++) b[i] = true;
	return true;
}

bool nextComb(bool* b)
{
	int pos;
	int last_true_pos;
	for (pos=9; pos>=0; pos--) {
		if (!b[pos]) {
			last_true_pos = pos + 1;
			break;
		}
	}
	for (pos--; pos>=0; pos--) {
		if (b[pos]) {
			b[pos]   = false;
			b[pos+1] = true;
			if (last_true_pos < 10) {
				for (int i=last_true_pos; i<10; i++) b[i] = false;
				for (int i=0; i<10-last_true_pos; i++) b[i+pos+2] = true;
			}
			return true;
		}
	}
	return false;
}

int main()
{
	int n, s;
	
	while (true) {
		cin >> n >> s;
		if (n==0 && s==0) break;
		
		bool isMember[10] = {false};
		if ( !initComb(isMember, n) ) {
			cout << 0 << endl;
			continue;
		}
		
		int count = 0;
		
		do {
			int sum = 0;
			for (int i=0; i<10; i++) sum += isMember[i] ? i : 0;
			if (sum == s) { 
				//for (int i=0; i<10; i++) {
				//	if (isMember[i]) cout << i << " ";
				//}
				//cout << endl;
				count++;
			}
		} while ( nextComb(isMember) );
		
		cout << count << endl;
	}
	
	return 0;
}

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

int main(){
  int k;
  vector<int>a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cin >> k;
  cout << a[k-1];
  return 0;
} 

Measured memory_bytes: 256
from collections import Counter
H,W = map(int,input().split())

d = [list(map(int,input().split())) for i in range(10)]
for i in range(10):
    d[i][i] = 10**9 #inf
src = [list(map(int,input().split())) for i in range(H)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

ctr = Counter()
for row in src:
    ctr.update(row)
ans = 0
for i in range(10):
    if i == 1: continue
    ans += ctr[i] * d[i][1]
print(ans)


Measured memory_bytes: 3700
/* --- author: dxm --- */
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define INF 2147483647
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
inline void Fail(){
	printf("0");
	exit(0);
}

const int maxn=100005;
int n,e,t;
ll dp[maxn];
int x[maxn],y[maxn];
class segtree{
public:
	ll tree[maxn*4];
	int leaf[maxn];
	void build(int l,int r,int node){
		if(l==r){
			leaf[l]=node;
			tree[node]=Inf;
			return;
		}
		int mid=(l+r)>>1;
		build(l,mid,node*2);
		build(mid+1,r,node*2+1); 
		tree[node]=min(tree[node*2],tree[node*2+1]);
	}
	void upd(int node,ll val){
		node=leaf[node];
		tree[node]=val;
		node>>=1;
		while(node){
			tree[node]=min(tree[node*2],tree[node*2+1]);
			node>>=1;
		}
	}
	ll query(int l,int r,int vl,int vr,int node){
		if(r<l||vr<vl)return Inf;
		if(l>vr||r<vl)return Inf;
		if(l>=vl&&r<=vr)return tree[node];
		int mid=(l+r)>>1;
		return min(query(l,mid,vl,vr,node*2),query(mid+1,r,vl,vr,node*2+1));
	}
}t1,t2;

int main(){
	scanf("%d%d%d",&n,&e,&t);
	rep(i,n)scanf("%d",&x[i]),y[i]=2*x[i];
	t1.build(0,n-1,1);
	t2.build(0,n-1,1);
	rep(i,n){
		dp[i]=max((x[i]-x[0])*2LL,1LL*t);
		int pos=lower_bound(y,y+n,2*x[i]-t)-y;
		dp[i]=min(dp[i],min(t1.query(0,n-1,0,pos-2,1)+2LL*x[i],t2.query(0,n-1,max(pos-1,0),n-1,1)+t));
		t1.upd(i,dp[i]-2LL*x[i+1]);
		t2.upd(i,dp[i]);
	}
	printf("%lld",e+dp[n-1]);
	return 0;
}

/*
Input:
-----------------
Output:
*/

Measured memory_bytes: 8960
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  cin>>n;
  vi a(n);
  rep(i,n)cin>>a[i];
  sort(all(a));
  int ans=0;
  rep(i,n){
    j=i+1;
    while(a[i]==a[j]&&j<n)j++;
    if((j-i)%2)ans++;
    i=j-1;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 640
import java.util.Scanner;


public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        while(true) {
            String s = sc.next();
            if(s.equals("0")) break;
            int sum = 0;
            for(int i = 0; i < s.length(); i++)
            {
                sum =(int)sum+s.charAt(i)-48;
            }
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 26220
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, X;
  while (cin >> N >> X) {
    vector<int> L(N);
    for (int& x : L) cin >> x;
    int sum = 0, res = 1;
    for (int x : L) {
      sum += x;
      if (sum <= X) {
        ++res;
      } else {
        break;
      }
    }
    cout << res << endl;
  }
  return 0;
}


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

const int MAXN = 2 * 100 * 1000 + 10;
int n, q, a, b, sumx, val[MAXN], jav[MAXN], x;
vector <int> adj[MAXN];
bool mark[MAXN];

void dfs(int v) {
    x += val[v];
    mark[v] = 1;
    jav[v] = x;
    for (int i : adj[v])
        if (!mark[i])
            dfs(i);
    x -= val[v];
}
void input(){
    cin >> n >> q;
    for (int i = 1; i < n; i ++){
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    for (int i = 0; i < q; i ++) {
        cin >> a >> b;
        val[a] += b;
    }
}
void output() {
    for (int i = 1; i <= n ; i ++)
        cout << jav[i] << " ";
    cout << endl;
}
void solve() {
    input();
    dfs(1);
    output();
}

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


Measured memory_bytes: 21120
#include <iostream>
using namespace std;
int main(void){
  int X;	cin >> X;
  int howMany500 = X / 500;
  X = X % 500;
  int howMany5 = X / 5;
  int happiness = howMany500*1000 + howMany5*5;
  cout << happiness << endl;
  return 0;
}


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

int main()
{
    vector<int> haiku;
    int a, b, c;
    cin >> a >> b >> c;
    haiku.push_back(a);
    haiku.push_back(b);
    haiku.push_back(c);
    sort (haiku.begin(), haiku.end());

    if (haiku[0] == 5 && haiku[1] == 5 && haiku[2] == 7) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)

class modint {
  public:
    using ll = long long;
    ll num;
    static const ll MOD = 1e9+7;
    static vector<modint> factorial;

    modint(): num(0) {};
    modint(ll n_): num((n_ + MOD) % MOD) {}
    modint(const modint &r): num(r.num) {}
    operator ll() const { return (num+MOD)%MOD; }
    friend istream& operator>>(istream& is, modint &r){
        ll num_;
        is >> num_;
        r = num_;
        return is;
    }
    modint operator+(const modint &r) const { return modint(num + r.num); }
    modint operator-(const modint &r) const { return modint(num - r.num); }
    modint operator*(const modint &r) const { return modint(num * r.num); }

    template<typename T>
    modint operator^(const T &r) const {
        if(r == 0) return 1;
        return (((*this)*(*this)) ^ (r/2)) * modint(r&1 ? num : 1);
    }
    modint operator/(const modint &r) const { return num * (r^(MOD-2)); }

    modint operator+=(const modint &r) { return *this = *this + r; }
    modint operator-=(const modint &r) { return *this = *this - r; }
    modint operator*=(const modint &r) { return *this = *this * r; }
    modint operator/=(const modint &r) { return *this = *this / r; }

    template<typename T>
    modint operator^=(const T &r) { return *this = *this ^ r; }

    static modint pow(const modint x, ll r) {
        return x^r;
    }

    static modint fact(int n){
        if((int)factorial.size() <= n) factorial.resize(n+1);
        if(factorial[n]) return factorial[n];
        if(n == 0) return 1;
        return factorial[n] = modint(n) * fact(n-1);
    }

    static modint C(ll n,ll r){
        return n >= r ? fact(n)/(fact(n-r)*fact(r)) : modint(0);
    }
};
vector<modint> modint::factorial;
#define fact(n) modint::fact(n)
#define C(n,r) modint::C(n,r)
#define H(a,b) C(a+b, a)


int main(void){
    ll n,k;
    cin >> n >> k;
    rep1(i,k){
        if ((n-k)-(i-1) < 0) {
            cout << 0 << endl;
        } else {
            cout << modint::C(k-1, i-1) * modint::H((n-k)-(i-1), i) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 384
S = input()
N = len(S)-1
res = 0

for i in range(2 ** N):
  pw = 0
  for j in range(N):
    if ((i >> j) & 1):
      res += int(S[pw:j+1])
      pw = j+1
  res += int(S[pw:])
  
print(res)

Measured memory_bytes: 9044
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<iostream>
#define rep(i,x,y) for(int i=x;i<y;i++)

using namespace std;
int main(){
  string s;
  cin>>s;
  s.erase(5,1);
  s.erase(12,1);
  s.insert(5," ");
  s.insert(13," ");
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>
#include <functional>


using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a,0,sizeof(a))
#define minus(a) memset(a,0xff,sizeof(a))
#define chmax(a,b) a=min((a),(b))
#define chmin(a,b) a=max((a),(b))


#define MOD 1000000007


typedef pair<int,int> P;														// pairは小文字


class uf {
public:
	int par[200005];
	int level[200005];

	void init(int n) {
		rep(i, n) {
			par[i] = i;
			level[i] = 0;
		}

	}

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

	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return;

		if (level[x] < level[y])
			par[x] = y;
		else {
			par[y] = x;
		}
		if (level[x] == level[y])level[x]++;

	}

	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

int n, k, l;

int main(){
	int a, b;
	scanf("%d %d %d ", &n, &k, &l);
	uf uf1, uf2;
	uf1.init(n); uf2.init(n);
	rep(i, k) {
		scanf("%d %d ", &a, &b);
		a--; b--;//
		uf1.unite(a, b);
	}
	rep(i, l) {
		scanf("%d %d ", &a, &b);
		a--; b--;
		uf2.unite(a, b);
	}
	map<P, int> m;
	rep(i, n) {
		a = uf1.find(i);
		b = uf2.find(i);
		m[P(a, b)]++;
	}
	rep(i, n) {
		a = uf1.find(i);
		b = uf2.find(i);
		cout << m[P(a, b)] << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 15104
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n;
  cin >> n;
  int tmp = n;
  int h = 0;
  
  while(tmp != 0){
    h += tmp%10;
    tmp /= 10;
  }
  
  
  if(n%h == 0){
    puts("Yes");
  }else{
    puts("No");
  }
  
  return 0;
}

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

int main(void){
  int h, w;
  int flg = 1;
  cin >> h >> w;
  
  string board[50];
  
  for (int i=0; i<h; i++) {
    cin >> board[i];
  }
  
  int dx[4] = {1, -1, 0, 0};
  int dy[4] = {0, 0, 1, -1};
  
  
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      int flg2 = 0;
      if (board[i][j] == '.') continue;
      
      for (int d=0; d<4; d++) {
        const int ni = i + dx[d];
        const int nj = j + dy[d];
        
        if (ni < 0 or ni >= h) continue;
        if (nj < 0 or nj >= w) continue;
        
        if (board[ni][nj] == '#') flg2 = 1;
      }
      if (flg2 == 0) flg = 0;
    }
  }
  
  if (flg == 0) cout << "No" << endl;
  else cout << "Yes" << endl;
  
  return 0;
}

Measured memory_bytes: 256
import sys

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    N = II()
    if N >= 30:
        print("Yes")
    else:
        print("No")
    
    

if __name__ == "__main__":
	main()

Measured memory_bytes: 9180
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        for (int i = 1; i <= 1100; i++) {
            if (Math.floor(i * 0.08) == a && Math.floor(i * 0.1) == b) {
                System.out.println(i);
                return;
            }
        }
        System.out.println(-1);
    }

}


Measured memory_bytes: 23740
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
#define fi   first
#define se   second
#define pi   3.1415926535897932384626433832795
using namespace std;
int n,m,x[3],y[3],a[200005],b[200005],k,s;
bool B;
pair<int,int> p[200005];
int main(){
    scanf("%d%d%d%d",x+1,y+1,x+2,y+2);
    if(x[1]>x[2]){
        swap(x[1],x[2]);
        swap(y[1],y[2]);
    }
    if(y[1]>y[2]){
        y[1]=100000001-y[1];
        y[2]=100000001-y[2];
        B=1;
    }
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        int x,y;
        scanf("%d%d",&x,&y);
        if(B)y=100000001-y;
        p[i]=mp(x,y);
    }
    sort(p+1,p+n+1);
    for(int i=1;i<=n;++i)if(p[i].fi>=x[1]&&p[i].fi<=x[2]&&p[i].se>=y[1]&&p[i].se<=y[2])a[++m]=p[i].se;
    for(int i=1;i<=m;++i){
        int o=0;
        for(int j=18;j>=0;--j){
            int O=o+(1<<j);
            if(O>k) continue;
            if(b[O]<a[i])o=O;
        }
        if(o==k)++k;
        b[o+1]=a[i];
    }
    s=x[2]+y[2]-x[1]-y[1];
    if(k<min(x[2]-x[1],y[2]-y[1])+1)printf("%.10lf\n",100.0*s+(5.0*pi-20.0)*k);
    else printf("%.10lf\n",100.0*s+(5.0*pi-20.0)*k+pi*5.0);
    //system("pause");
    return 0;
}


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

int main() {
  
  vector<int> vec(3);
  
  for (int i = 0; i < 3; i++) {
    int a; cin >> a;
    vec.at(i) = a;
  }
  
  sort(vec.begin(), vec.end());
  
  cout << vec.at(0) << " " << vec.at(1) << " " << vec.at(2) << endl;
  
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e11;

ll H, W;

ll f1(ll h, ll w) {
  if (w % 3 == 0) {
    return 0;
  }
  else {
    return h;
  }
}

ll f2(ll h, ll w) {
  ll res = INF;
  for (int i = 1; i <= h - 1; i++) {
    ll s1 = w * i, s2 = (w / 2) * (h - i), s3 = ((w + 1) / 2) * (h - i);
    ll smax = max(s1, max(s2, s3)), smin = min(s1, min(s2, s3));
    res = min(res, smax - smin);
  }
  return res;
}

void abc062c() {
  ll min1 = min(f1(H, W), f1(W, H)), min2 = min(f2(H, W), f2(W, H));
  ll res = min(min1, min2);
  cout << res << "\n";
  return;
}

int main() {
  cin >> H >> W;
  abc062c();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
  string S;
  cin >> S;
  size_t N = S.size();
  size_t end1 = (N - 1) / 2 - 1;
  string first = S.substr(0, end1 + 1);

  size_t start = (N + 3) / 2 - 1;
  string second = S.substr(start);
  if (first != second) {
    cout << "No" << endl;
    return 0;
  }
  size_t mid = end1 / 2;
  for (size_t i = 0; i <= mid; ++i) {
    if (S[i] != S[end1 - i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
int main() {
	ll a, b, c;
	ll n;
	while (cin >> a >> b >> n) {
		a -= (a / b) * b;
		ll o = 0;
		ll i, j, k;
		for (i = 0; i < n; i++) {
			a *= 10;
			//cout << a/b << ":";
			o += a / b;
			a -= (a / b) * b;
			if (a == 0) break;
		}
		cout << o << endl;
	}
	return 0;
}


Measured memory_bytes: 3012
def main
    h, w = gets.chomp.split.map &:to_i
    m = []
    h.times do
        m << gets.chomp.gsub('.', '0')
    end

    h.times do |i|
        w.times do |j|
            if m[i][j] == '#'
                around(i, j, h, w).each do |y, x|
                    m[y][x] = m[y][x].succ if m[y][x] != '#'
                end
            end
        end
    end

    puts m
end

def around(i, j, h, w)
    s = []
    [i - 1, 0].max.upto([i + 1, h - 1].min) do |y|
        [j - 1, 0].max.upto([j + 1, w - 1].min) do |x|
            if x != j or y != i
                s << [y, x]
            end
        end
    end

    return s
end

main


Measured memory_bytes: 1788
n, m = map(int, input().split())
py = [list(map(int, input().split()))+[i+1] for i in range(m)]
py = sorted(py, key = lambda x: x[1])

ans = [0]*m
prefecs = [1]*(n+1)
for i, (p, y, j) in enumerate(py):
    top = p
    under = prefecs[p]
    ans[i] = (str(top).zfill(6)+str(under).zfill(6), j)
    prefecs[p] += 1

ans = sorted(ans, key = lambda x: x[1])
for i in range(m):
    print(ans[i][0])


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}


void solve(std::vector<long long> T, std::vector<long long> A, std::vector<long long> B){
    if(T[0]*(A[0]-B[0])+T[1]*(A[1]-B[1])<0){
        A.swap(B);
    }
    int d1=T[0]*(A[0]-B[0])+T[1]*(A[1]-B[1]);
    int dmax=T[0]*B[0]-T[0]*A[0];

    if(d1==0){
        cout<<"infinity"<<endl;
        return;
    }
    if(dmax<0){
        cout<<0<<endl;
        return;
    }
    
    if(dmax%d1==0) cout<<dmax/d1*2<<endl;
    else cout<<2*RUP(dmax,d1)-1<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    std::vector<long long> T(2);
    for(int i = 0 ; i < 2 ; i++){
        scanf("%lld",&T[i]);
    }
    std::vector<long long> A(2);
    for(int i = 0 ; i < 2 ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(2);
    for(int i = 0 ; i < 2 ; i++){
        scanf("%lld",&B[i]);
    }
    solve(std::move(T), std::move(A), std::move(B));
    return 0;
}


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

int main() {
  long long N,D;
  cin >> N>>D;
  vector<long>X(N);
  vector<long>Y(N);
  int ans=0;
  for(int i=0;i<N;i++){
    cin>>X[i]>>Y[i];
    if(X[i]*X[i]+Y[i]*Y[i]<=D*D){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 6420
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, p: "List[int]"):
    print(sum(p)-max(p)//2)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, p)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int h1 = sc.nextInt();
		int m1 = sc.nextInt();
		int h2 = sc.nextInt();
		int m2 = sc.nextInt();
		int k = sc.nextInt();
		sc.close();

		LocalDateTime date1 = LocalDateTime.of(2020,5,30,h1,m1,00);
		LocalDateTime date2 = LocalDateTime.of(2020,5,30,h2,m2,00);

		LocalDateTime date1_1 = date1.plusMinutes(k);

		DateTimeFormatter dtFormat = DateTimeFormatter.ofPattern("HH:mm");
		String sDate1_1 = date1_1.format(dtFormat);
		String sDate2 = date2.format(dtFormat);

		String[] array1 = sDate1_1.split(":");
		String[] array2 = sDate2.split(":");

		int ans = (Integer.parseInt(array2[0])-Integer.parseInt(array1[0]))*60;
		ans = ans + Integer.parseInt(array2[1])-Integer.parseInt(array1[1]);
		System.out.println(ans);

	}
}


Measured memory_bytes: 33268
#include <iostream>

using namespace std;

int main() {
    int n;

    cin >> n;

    int a, count[100010] = {0};

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

    if (n%2 == 1) {
        count[0]++;
    }

    for (int i = (n+1)%2; i < n; i += 2) {
        if (count[i] != 2) {
            cout << 0 << endl;
            return 0;
        }
    }

    long long ans = 1;

    for (int i = 0; i < n/2; i++) {
        ans *= 2;
        ans %= 1000000007;
    }

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


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,p[11],i,sum=0;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>p[i];
		sum+=p[i];
	}
	sort(p+1,p+n+1);
	sum-=p[n]/2;
	cout<<sum<<endl;
	return 0;
} 

Measured memory_bytes: 256