akhauriyash/Code-Regression huggingface dataset:
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline void reverse(Type& arr) { reverse(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ll BIGP = 1e9 + 7;
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
using P = pair<ll, ll>;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //
    ll N;
    cin >> N;
    map<ll, ll> counts;
    ll baseCount = 0;
    rep(i, N)
    {
        ll a;
        cin >> a;
        ++counts[a];
        baseCount += a;
    }
    ll Q;
    cin >> Q;
    rep(i, Q)
    {
        ll B, C;
        cin >> B >> C;
        baseCount += counts[B] * (C - B);
        counts[C] += counts[B];
        counts[B] = 0;
        cout << baseCount << endl;
    }
    //
    return 0;
}

Measured memory_bytes: 8948
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools

import queue
from collections import deque



def main():
    node_num, edge_num, max_tank = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(edge_num)]
    q_num = int(input())
    query = [list(map(int, input().split())) for i in range(q_num)]

    graph_data = defaultdict(set)
    dist_data = defaultdict(int)

    distance = [[10 ** 12 for i in range(node_num + 1)] for j in range(node_num + 1)]
    for i in range(1, node_num + 1):
        distance[i][i] = 0

    for i in range(edge_num):
        a, b, c = data[i]
        graph_data[a].add(b)
        graph_data[b].add(a)
        dist_data[(a, b)] = c
        dist_data[(b, a)] = c
        distance[a][b] = c
        distance[b][a] = c


    for k in range(1, node_num + 1):
        for i in range(1, node_num + 1):
            for j in range(1, node_num + 1):
                distance[i][j] = min(distance[i][k] + distance[k][j], distance[i][j])


    distance2 = [[10 ** 5 for i in range(node_num + 1)] for j in range(node_num + 1)]
    for i in range(1, node_num + 1):
        distance2[i][i] = 0

    for i in range(1, node_num + 1):
        for j in range(1, node_num + 1):
            if distance[i][j] <= max_tank:
                distance2[i][j] = 1


    for k in range(1, node_num + 1):
        for i in range(1, node_num + 1):
            for j in range(1, node_num + 1):
                distance2[i][j] = min(distance2[i][k] + distance2[k][j], distance2[i][j])

    for i in range(q_num):
        s, t = query[i]
        ans = distance2[s][t]
        if ans == 10 ** 5:
            print(-1)
        else:
            print(ans - 1)



if __name__ == '__main__':
    main()


Measured memory_bytes: 85204
n = int(input())
rx = []
bx = []

for i in range(n):
    r = tuple(map(int, input().split()))
    rx.append([r, 0])

for j in range(n):
    b = tuple(map(int, input().split()))
    bx.append([b, 0])

rx.sort(key=lambda x: x[0][1], reverse=True)
bx.sort(key=lambda x: x[0][0])

ans = 0

for i in range(n):
    for j in range(n):
        if rx[j][0][0] < bx[i][0][0] and rx[j][0][1] < bx[i][0][1]:
            if rx[j][1] == 0:
                ans += 1
                rx[j][1] = 1
                break

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define show(x) cerr << #x << " = " << x << endl
#define VARNAME(x) #x
#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;
using ld = long double;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

constexpr ll MOD = 1000000007LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 10;

ll power(const ll p, const ll n)
{
    if (n == 0) {
        return 1;
    }
    if (n % 2 == 1) {
        return power(p, n - 1) * p % MOD;
    } else {
        const ll pp = power(p, n / 2);
        return pp * pp % MOD;
    }
}

ll inv(const ll p)
{
    return power(p, p - 2);
}

int main()
{
    ll N, C;
    cin >> N >> C;
    vector<ll> A(N);
    vector<ll> B(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }
    vector<vector<ll>> sum(401, vector<ll>(401, 1));
    for (int i = 0; i <= 400; i++) {
        for (int j = 1; j <= 400; j++) {
            sum[i][j] = sum[i][j - 1] + power(j, i);
            sum[i][j] %= MOD;
        }
    }
    vector<vector<ll>> x(N, vector<ll>(401));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= 400; j++) {
            x[i][j] = (sum[j][B[i]] - sum[j][A[i] - 1] + MOD) % MOD;
        }
    }
    vector<ll> dp(C + 1, 0);
    dp[0] = 1;
    for (int i = 0; i < N; i++) {
        vector<ll> tmp(C + 1, 0);
        for (int j = 0; j <= C; j++) {
            if (dp[j] > 0) {
                for (int k = 0; j + k <= C; k++) {
                    (tmp[j + k] += dp[j] * x[i][k]) %= MOD;
                }
            }
        }
        dp = tmp;
    }
    cout << dp[C] << endl;

    return 0;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
  using namespace std;
  typedef long long ll;

  vector<ll>v;
  int main()
  {
    ll n, m, ans=0, dif, i, x;
    cin>>n>>m;

    for(i=0; i<m; i++)
    {
      cin>>x;
      v.push_back(x);
    }
    ans=v[m-1]-v[0];
    for(i=1; i<m; i++)
    {
      ans=min(ans,v[i-1]+n-v[i]);
    }

    cout<<ans<<endl;


  }

Measured memory_bytes: 2420
s = input()
q = int(input())

for _ in range(q):
    n = input().split()
    a, b = map(int, n[1:3])
    if n[0] == 'print':
        print(s[a:b+1])
    elif n[0] == 'reverse':
        s = s[:a] + s[a:b+1][::-1] + s[b+1:]
    elif n[0] == 'replace':
        s = s[:a] + n[3] + s[b+1:]


Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void){
    int n;
    cin>>n;
    vector<ll>a(n);
    int zero =0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i] == 0)zero++;
    }
    if(zero >0){
        cout<<0<<endl;
        return 0;
    }
    ll ans = 1;
    for(int i=0;i<n;i++){
        if(a[i]<= 1000000000000000000/ans){
            ans*=a[i];
        }else{
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3968
from collections import defaultdict
N, M = map(int, input().split())
sc = defaultdict(list)

for i in range(M):
    s, c = map(int, input().split())
    sc[s].append(c)

ans = [-1] * N
res = True
for s, c in sc.items():
    if len(set(c)) != 1:
        res = False
        break
    else:
        ans[s - 1] = c[0]

if N == 1 and ans[0] == -1:
    ans[0] = 0
elif N > 1 and ans[0] == 0:
    res = False
else:
    if ans[0] == -1:
        ans[0] = 1

    for i in range(1, N):
        if ans[i] == -1:
            ans[i] = 0

print("".join(list(map(str, ans))) if res else "-1")


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    int t;
    t=1;
    while(t--)
    {
        ll d,t,s;
        cin>>d>>t>>s;
        if(s*t>=d)
            cout<<"Yes";
        else
            cout<<"No";
        cout<<"\n";
    }
}

Measured memory_bytes: 3612
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan_ = new Scanner(System.in);
        int h_ = scan_.nextInt();
        int w_ = scan_.nextInt();
        
        System.out.println( h_ * w_ + " "  + ((h_ + w_) * 2) );
    }
}


Measured memory_bytes: 26332
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
 
n = int(input())
edge = [[] for _ in range(n)]
edge_dict = dict()
 
for i in range(n - 1):
    a, b = [int(item) - 1 for item in input().split()]
    edge[a].append(b)
    edge[b].append(a)
    if a > b:
        edge_dict[(b, a)] = i
    else:
        edge_dict[(a, b)] = i
 
m = int(input())
uv = []
for _ in range(m):
    uv.append([int(item) - 1 for item in input().split()])
 
def dfs(p, v, dest):
    if v == dest:
        return [v]
    if p != -1 and len(edge[v]) == 1:
        return False
    for nv in edge[v]:
        if nv == p:
            continue
        ret = dfs(v, nv, dest)
        if ret:
            return ret + [v]
    return False
 
target_edge = [0] * m
for i, (u, v) in enumerate(uv):
    ret = dfs(-1, u, v)
    for uu, vv in zip(ret, ret[1:]):
        if uu > vv:
            uu, vv = vv, uu
        if (uu, vv) in edge_dict:
            target_edge[i] |= (1 << edge_dict[(uu, vv)])

edge_of_state = [0] * 2**m
for i in range(1, 2**m):
    lsb = i & (-i)
    edge_of_state[i] = edge_of_state[i ^ lsb] | target_edge[lsb.bit_length() - 1]
 
# dp[fills uv as st]
dp = [0] * 2**m
dp[0] = pow(2, n-1) 
ans = dp[0]
for i in range(1, 2**m):
    lsb = i & (-i)
    n_edgest = edge_of_state[i]
    p_edgest = edge_of_state[i ^ lsb]
    limit_num = bin(n_edgest ^ p_edgest).count("1")
    dp[i] = dp[i ^ lsb] // pow(2, limit_num)
    if bin(i).count("1") % 2 == 0:
        ans += dp[i]
    else:
        ans -= dp[i]
print(ans)

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

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define f first
#define s second
#define uint unsigned int

using namespace std;

int a[500];

int main() {
#define FILE_INPUT 0
#define FILE ""
#ifndef DEBUG
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#if FILE_INPUT == 1
#warning "FREOPEN is on"
    freopen(FILE".in", "r", stdin);
    freopen(FILE".out", "w", stdout);
#endif
#endif	
	int n, x;
	cin >> n >> x;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	int i = 0;
	while (x >= 0 && i <= n) {
		x -= a[i];
		i++;
	}
	if (x + a[i] != 0)
		i--;
	cout << i - 1;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toLong() }

    val map = mutableMapOf<Long, Long>()

    a.forEach {
        if (map.containsKey(it)) map[it] = map[it]!! + 1
        else map[it] = 1
    }
    val cMap = map.filterValues { it >= 2 }
    if (cMap.size < 2) {
        println(0)
        return
    }
    val (x, y) = cMap.keys.toList().sortedDescending().subList(0, 2)
    if (cMap[x]!! >= 4) {
        println(x*x)
    } else {
        println(x*y)
    }
}

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

using namespace std;

typedef long long	ll;

const int N = int(2e5) + 10;
const ll mod = ll(1e9) + 7LL;

ll fat[N];

ll fast_expo(ll base, ll x, ll mod){
	ll r = 1LL;

	while(x){
		if(x & 1LL){
			r = (r * base) % mod;
		}

		base = (base * base) % mod;
		x >>= 1LL;
	}

	return r;
}

ll comb(ll n, ll k){
	ll inv1 = fast_expo((fat[k] * fat[n - k]) % mod, mod - 2, mod);

	return (fat[n] * inv1) % mod;
}

int main(){
	ll n, k;

	scanf("%lld %lld", &n, &k);

	fat[0] = 1LL;

	for(ll i = 1 ; i < N ; i++){
		fat[i] = (i * fat[i - 1]) % mod;
	}

	ll sum = 0LL;

	k = min(k, n - 1);

	for(int d = 0 ; d <= k ; d++){
		sum += (comb(n - 1, n - d - 1) * comb(n, d)) % mod;
		// printf("%lld\n", sum);

		if(sum >= mod){
			sum -= mod;
		}
	}

	printf("%lld\n", sum);

	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n,sum=10000000000,sumtemp=0,ans;
    cin >> n;//>> b;
    ll a[n];
    for( ll i=0;i<n;i++)
    {
        cin >> a[i];
    }
    sort(a,a+n);
    for(ll i=a[0];i<=a[n-1];i++)
    {
        for(ll j=0;j<n;j++)
        {
            sumtemp = sumtemp + (a[j]-i)*(a[j]-i);
        }
        if(sumtemp<sum)
        {
            sum = sumtemp;
            ans = i;
        }
        sumtemp=0;
    }
    cout << sum << endl;
}


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

int main(void){
    int S;
     cin >> S;
     int N[4];
     N[0]= S/1000;
     N[1]= S/100%10;
     N[2]= S/10%10;
     N[3]= S%10;
   for(int i = 0;i<3;i++){
     if(N[i]==N[i+1]){
         cout << "Bad" << endl;
         return 0;
     }
   }
   cout << "Good" << endl;
   return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] moji = s.toCharArray();
        Arrays.sort(moji);
        int cnt  = 0;

        for(int i = 0;i<moji.length-1;i++){
            if(moji[i]==moji[i+1]){
                cnt++;
            }
        }
        if(cnt==0){
            System.out.println("yes");
        }else{
            System.out.println("no");
        }

    }
}




Measured memory_bytes: 21844
program abc166e
  use iso_fortran_env
  implicit none
  integer(int64) :: n, i, t
  integer(int64),allocatable :: a(:), x(:), y(:)
  read *, n
  allocate(a(n),x(n),y(n))
  read *, a
  x = 0
  y = 0
  do i = 1,n
     t = min(i+a(i),n)
     x(t) = x(t) + 1
     t = max(i-a(i),0)
     y(t) = y(t) + 1
  end do
  print *, sum(x*y)
end program abc166e


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

bool isPrime(int n) {
  if (n==2) {
    return true;
  } else if (n<2 || n%2==0) {
    return false;
  }

  for (int i=3; i<=sqrt(n); i+=2) {
    if (n%i==0) {
      return false;
    }
  }
  return true;
}

int main() {
  int n, sum=0;
  cin >> n;

  for (int i=0; i<n; i++) {
    int t;
    cin >> t;
    sum+=isPrime(t);
  }

  cout << sum << endl;
}


Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    string s;
    cin >> s;
    int n = s.length();
    int ans = 0;
    bool flag = true;
    for(int i = 0; i < n; ++i){
        if(s[i] == 'W'){
            if(!flag){
                ans += 2;
                flag = true;
            }
        }
        else    flag = false;
    }
    if(!flag)   ++ans;
    int cnt = 0;
    flag = true;
    for(int i = 0; i < n; ++i){
        if(s[i] == 'B'){
            if(!flag){
                cnt += 2;
                flag = true;
            }
        }
        else    flag = false;
    }
    if(!flag)   ++cnt;
    chmin(ans, cnt);
    cout << ans << endl;
}

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

int main() {
  cin.tie(0); 
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int ary[N];

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

  int c = 0;
  for (int i = 0; i < N; i++) {
    if (ary[i] == c+1) {
      c++;
    }
  }
  if (c == 0) {
    cout << -1 << '\n';
  } else {
    cout << N - c << '\n';
  }

  return 0;
}


Measured memory_bytes: 1024
/* Simplicity and Goodness */

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B)
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;


void solve()
{
    int n, k;
    scn(n); scn(k);

    string s;
    cin >> s;

    s += "#";

    int cnt = 0;
    char prv = '1';

    vi util;

    rep(i, 0, s.size()) {
        if(s[i] != prv) {
            util.pb(cnt);
            cnt = 1;
        } else {
            cnt ++;
        }
        prv = s[i];
    }

    if(s[n-2] == '0')
        util.pb(0);

    int ans = 0, sum = 0;

    rep(i, 0, util.size()) {
        sum += util[i];

        if(i - (k * 2 + 1) >= 0) 
            sum -= util[i - (k * 2 + 1)];

        if(i % 2 == 0)
            ans = max(ans, sum);
    }

    prin(ans);
}

int main()
{
    int t = 1;
    // scn(t);
    
    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4132
import heapq
h, w = map(int, input().split())
cs = [[] for _ in range(10)]
g = [[] for _ in range(10)]
for i in range(10):
    lis = list(map(int, input().split()))
    for j in range(10):
        if i == j:
            continue
        g[j].append((i,lis[j]))
ds = [-1]*10
hq = [(0,1)]
while hq:
    c,idx = heapq.heappop(hq)
    if ds[idx] != -1:
        continue
    ds[idx] = c
    for i in g[idx]:
        if ds[i[0]] == -1:
            heapq.heappush(hq,(c+i[1],i[0]))
res = 0
for i in range(h):
    lis = list(map(int, input().split()))
    for j in lis:
        if j != 1 and j != -1:
            res += ds[j]
print(res)

Measured memory_bytes: 73888
#include <iostream>

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

  int l, i = 0, v[n],c[n];
  int x[n];
  while (std::cin >> l) {
    v[i] = l;
    i++;
    if (i >= n) {
        break;
    }
  }

  i = 0;
  while (std::cin >> l) {
    c[i] = l;
    i++;
    if (i >= n) {
      break;
    }
  }
  
  int sum = 0;
  for(i = 0;i < n;i++){
    x[i] = v[i] - c[i];
    if(x[i] >=0) sum += x[i];
  }
  
  std::cout << sum << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for (int (i)=0; (i) < (n); (i)++)

int main()
{
    ll N; cin >> N;
    vector<ll> a(N, 0);
    map<ll,ll> m;
    rep(i,N) {
        cin >> a[i];
        m[a[i]]++;
    }
    vector<ll> T;
    for (auto i : m) {
        T.push_back(i.first);
    }
    ll maxv = 0;
    rep(i,T.size()) {
        ll index = T[i];
        if (maxv < m[index] + m[index-1] + m[index+1]) {
            maxv = m[index] + m[index-1] + m[index+1];
        }
    }
    cout << maxv << endl;

}


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

struct UnionFind{
  vector<int> data;
  UnionFind(int n) : data(n, -1) {}
  bool unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return false;
    if(data[y] < data[x]) swap(x,y);
    data[x] += data[y];
    data[y] = x;
    return x != y;
  }
  bool same(int x, int y){ return find(x) == find(y); }
  int find(int x){
    if(data[x] < 0) return x;
    return data[x] = find(data[x]);
  }
  int size(int x){ return -data[find(x)]; }
};

int main(){
  int N, M;
  cin >> N >> M;
  UnionFind uf(N);
  for(int i = 0; i < M; ++i){
    int x, y, z;
    cin >> x >> y >> z;
    uf.unite(x-1,y-1);
  }
  set<int> S;
  for(int i = 0; i < N; ++i) S.insert(uf.find(i));
  cout << S.size() << endl;
}


Measured memory_bytes: 5376
from fractions import gcd
from math import factorial, ceil, sqrt, atan2, log
from itertools import *
import string
import copy
import random
import bisect
from decimal import *
def id_generator(size=20, chars=string.digits):
    return ''.join(random.choice(chars) for _ in range(size))
 
def mp():
    return map(int,str(raw_input()).split())
a=input()
b=input()
c=input()
x=input()
a+=1
b+=1
c+=1
ans=0
for i in range(a):
	for j in range(b):
		for k in range(c):
			if (i*500+j*100+k*50)==x:
				#print i,j,k
				ans+=1
print ans

Measured memory_bytes: 6032
import math
from collections import Counter
n=int(input())



def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)

    return a
ans=0
for i in range(1,n+1):
  if i%2==0:
    continue
  s=Counter(prime_factorize(i))
  cnt=1
  for j in s.values():
    cnt*=j+1
    
    
  if cnt==8:
    ans+=1
    #print(s)
  else:
    continue
    
print(ans)

Measured memory_bytes: 9476
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N, A, B,j=0,f=0;
	string S;
	cin >> N >> A >> B >> S;
	rep(i, N) {
		if (S.at(i) == 'a'&&j+f<A+B) {
			cout << "Yes" << endl;
			j++;
		}
		else if (S.at(i) == 'b' && j + f < A + B && f < B) {
			cout << "Yes" << endl;
			f++;
		}
		else {
			cout << "No" << endl;
		}
	}

}

Measured memory_bytes: 1024
n,d,e = map(int,input().split())

mod = 10**9+7
x = pow(2,n,mod)

a = 1
b = 1
for i in range(n-d+1,n+1):
    a = a*i%mod
for i in range(n-e+1,n+1):
    b = b*i%mod

def f(hiki):
    fac = 1
    for i in range(1,1+hiki):
        fac = fac*i%mod
    return fac

a2 = pow(f(d),mod-2,mod)
b2 = pow(f(e),mod-2,mod)

a_mod = a*a2%mod
b_mod = b*b2%mod
print((x-a_mod-b_mod-1)%mod)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long long a[110],w[110],dp[100010],n,k,ans=-1;
/*void dq(int i,long long cost,long long weight){
    cout<<i<<" "<<cost<<" "<<weight<<endl;
    if(weight>k)return ;
    ans=max(ans,cost);
    for(;i<n;i++)
        dq(i+1,cost+w[i+1],weight+a[i+1]);
}*/
void solve(){
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>a[i]>>w[i];
    for(int i=1;i<=n;i++)
        for(int j=k;j>=0;j--)
            if(j-a[i]>=0){dp[j]=max(dp[j-a[i]]+w[i],dp[j]);}
    for(int i=1;i<=k;i++)dp[i]=max(dp[i],dp[i-1]);
    //dq(0,0,0);
    cout<<dp[k];
}
main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    //freopen("FORM MAU.inp","r",stdin);
    //freopen("FORM MAU.out","w",stdout);

    //srand(time(0));

    //int t;cin>>t;while(t--)
    //cout << setprecision(2) <<fixed;
    solve();
}



Measured memory_bytes: 1152
#include <iostream>
using namespace std;
int main(){
  int H, W;
  for (int i = 0; ; i++){
    cin >> H >> W;
    if (H==0 && W==0) break;
    for (int h=0; h<H; h++){
      for (int w=0; w<W; w++){
        if ((h+w)&1) cout << '.';
        else cout << '#';
      }
      cout << endl;
    }
  cout << endl;
  }
}

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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 105;

int n, m, a[N][N], b[N][N];
std::vector<int> E[N][N];

int mat[N], vis[N];

bool dfs(int u, int tag) {
	if (vis[u] == tag) {
		return false;
	}
	vis[u] = tag;
	for (int v = 0; v < n; ++v) {
		if (!E[u][v].empty() && (mat[v] == -1 || dfs(mat[v], tag))) {
			mat[v] = u;
			return true;
		}
	}
	return false;
}

int main() {
	read(n), read(m);
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			read(a[i][j]);
			--a[i][j];
			E[i][a[i][j] / m].push_back(a[i][j]);
		}
	}
	for (int j = 0; j < m; ++j) {
		for (int i = 0; i < n; ++i) {
			mat[i] = vis[i] = -1;
		}
		for (int i = 0; i < n; ++i) {
			dfs(i, i);
		}
		for (int i = 0; i < n; ++i) {
			b[mat[i]][j] = E[mat[i]][i].back();
			E[mat[i]][i].pop_back();
		}
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			print(b[i][j] + 1, ' ');
		}
		putchar('\n');
	}
	for (int j = 0; j < m; ++j) {
		std::vector<int> res(n);
		for (int i = 0; i < n; ++i) {
			res[i] = b[i][j];
		}
		std::sort(res.begin(), res.end());
		for (int i = 0; i < n; ++i) {
			b[i][j] = res[i];
		}
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			print(b[i][j] + 1, ' ');
		}
		putchar('\n');
	}
}


Measured memory_bytes: 4396
#include <iostream>                                                                                                       
#include <cmath>

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

   if(N<6){
      std::cout << N << std::endl;
      return 0;
   }   

   int n = N;
   int n1 = n%3;
   n -= n1; 
   n /= 3;
   int ans = N;
   for(int i=0; i<=n/2; ++i){
      if((n - 2*i)%3!=0) continue;
      int count = 0;
      int j = i;
      int m = 0;
      while(j/6>0){
         int n6 = 1;
         while(j-n6*6>=0){
            n6 *= 6;
         }
         j -= n6; 
         ++m;
      }   
      count += j + m;
           j = (n - 2*i)/3;
      m = 0;
      while(j/9>0){
         int n9 = 1;
         while(j-n9*9>=0){
            n9 *= 9;
         }
         j -= n9;
         ++m;
      }
      count += j + m;
      if(ans>count) ans = count;
   }
   ans += n1;
   std::cout << ans << std::endl;
   return 0;

}

Measured memory_bytes: 256
my $N = <>;
chomp $N;
my @array = ();
my $n_tmp = $N;
while ( $n_tmp > 0 ) {
    my $input = <>;
    my ($A,$B) = split(' ', $input);
    my $sum = $A + $B;
    #$hash->{$n_tmp} = \@input;
    push @array, [$sum,$A,$B];
    $n_tmp--;
}

my @sorted = sort {$b->[0] <=> $a->[0]} @array;
#print Dumper @sorted;

my $taka = 0;
my $aoki = 0;
my $taka_turn = 1;
for my $row ( @sorted ) {
    if ( $taka_turn ) {
        $taka += $row->[1];
        $taka_turn = 0;
    }
    else {
        $aoki += $row->[2];
        $taka_turn = 1;
    }
};

print $taka - $aoki;

Measured memory_bytes: 35184
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    unsigned long long n, a=2, b=1, i = 0, c;
    cin>>n;
    if(n == 1)
    {
        cout<<b;
        return 0;
    }
    for(int i = 2; i <= n; i++)
    {
        c = a+b;
        int t = a;
        a = b;
        b = c;
    }
    cout<<c;
    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(x) (x).begin(), (x).end()
#define INF 1e9
typedef long long ll;

ll N;
vector<ll> d;

void solve(){
  ll m = N/2 - 1;
  ll ans = d[m+1] - d[m];
  cout << ans << endl;
}

int main(){
  cin >> N;
  rep(i, N){
    ll a;
    cin >> a;
    d.push_back(a);
  }

  sort(all(d));
  // rep(i, N){
  //   cout << d[i] << " ";
  // }
  // cout << endl;
  solve();
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
typedef pair<ll, ll> P;
const ll INF = 1LL << 60;
//const int MOD = 1000000007;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

int main(){
  ll n;
  cin>>n;
  ll ans=0;
  for(ll i=1;i<=n;i++){
    for(ll j=1;j<=n;j++){
      ll c=n-i*j;
      if(c<=0)break;
      //if(i>j)break;
      //cout<<i<<" "<<j<<" "<<c<<endl;
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3632
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#include <cstdint>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

long n;
long a[200005];

int main(){
    scanf("%ld", &n);
    std::map<long, long> cnt;
    for(int i = 0; i < n; i++){
        scanf("%ld", a+i);
        cnt[a[i]]++;
    }
    long sum = 0;
    for(auto it = cnt.begin(); it != cnt.end(); it++){
        long c = it->second;
        sum += c * (c-1) / 2;
    }
    for(int i = 0; i < n; i++){
        printf("%ld\n", sum - cnt[a[i]] + 1);
    }
}


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

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define pii pair<int,int>

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

int main(){

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

  vector<int> v;
  REP(i,n){
    int t;
    scanf("%d", &t);
    if(i == 0 || (i != 0 && t != v.back())){
      v.pb(t);
    }
  }

  int res = 0;
  REP(i,v.size()){
    res++;
    if(i == n - 1) break;
    if(v[i] > v[i + 1]){
      FOR(j,i,v.size()){
        i = j;
        if(j == n - 1 || v[j] < v[j + 1]){
          break;
        }
      }
    }else{
      FOR(j,i,v.size()){
        i = j;
        if(j == n - 1 || v[j] > v[j + 1]){
          break;
        }
      }
    }
  }

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



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

int main(){
  int N,K;
  string s;
  cin >> N;
  cin >> s;
  string s1 = s.substr(0, N/2);
  string s2 = s.substr(N/2, N/2);
  if(s1 == s2 && s == s1 + s2){
    cout << "Yes" << endl;
   } else {
     cout << "No" << endl;
   }

  return 0;
}

Measured memory_bytes: 256
from collections import deque
n=int(input())
a=list(map(int,input().split()))

even=deque()
odd=deque()

for i in range(n):
    if i%2==0:
        even.append(a[i])
    else:
        odd.append(a[i])

ans=[]
while(len(odd)>0):
    ans.append(odd.pop())

while(len(even)>0):
    ans.append(even.popleft())

if n%2==1:ans.reverse()

print(*ans)

Measured memory_bytes: 32432
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;


int main()
{
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n+1);
    for(ll j=1;j<=n;j++)
    {
        cin>>a[j];
    }
    ll dp[n+1];
    memset(dp,-1,sizeof(dp));
    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(a[2]-a[1]);
    for(ll j=3;j<=n;j++)
    {
        dp[j]=INT_MAX;
        dp[j]=min(dp[j-1]+abs(a[j]-a[j-1]),dp[j]);
        ll h=2;
        while(j-h>=1 && h<=k)
        {
            dp[j]=min(dp[j],dp[j-h]+abs(a[j]-a[j-h]));
            h++;
        }
    }
    //for(ll j=1;j<=n;j++)cout<<dp[j]<<" ";
    //cout<<endl;
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

struct open {
  int a, b, c;
  open(int a, int b, int c) : a(a), b(b), c(c) {}
};

struct cmp {
  bool operator()(const open &a, const open &b) const {
    if (a.a != b.a) {
      return a.a > b.a;
    }
    return 0;
  }
};

priority_queue <open, vector <open>, cmp> pq;

const int N = 100005;
const int inf = (int) 1e9 + 7;

int n, m;
vector < vector <int> > adj;
//vector <int> adj[N];
int dist[N][3];

int main() {
  cin >> n >> m;
  adj.resize(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    adj[x].push_back(y);
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      dist[i][j] = inf;
    }
  }
  int s, t;
  cin >> s >> t; s--; t--;
  dist[s][0] = 0;
  pq.push(open(0, s, 0));
  while (!pq.empty()) {
    auto here = pq.top(); pq.pop();
    int d = here.a, u = here.b, div = here.c;
    if (d > dist[u][div]) continue;
    int nd = d + (div == 2), ndiv = (div + 1) % 3;
    for (int v : adj[u]) {
      if (nd < dist[v][ndiv]) {
        dist[v][ndiv] = nd;
        pq.push(open(nd, v, ndiv));
      }
    }
  }
  int ans = dist[t][0];
  if (ans == inf) ans = -1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6912
#include<stdio.h>

int main(void){
  int N,T[105],M,P[105],X[105],i,total=0;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&T[i]);
    total+=T[i];
  }
  scanf("%d",&M);
  for(i=0;i<M;i++){
    scanf("%d %d",&P[i],&X[i]);
  }
  for(i=0;i<M;i++){
    printf("%d\n",total-T[P[i]-1]+X[i]);
  }
  return 0;
}


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

int main(){
string n;
int sum=0;
cin >> n;

int len = n.size();

for(int i = 0;i < len;i++){
  sum += n[i]-'0';

}

if(sum%9 == 0){
  cout << "Yes" << endl;
}else{
  cout << "No" << endl;

}

  return 0;
}

Measured memory_bytes: 3752
function Main(input){
    input = input.split(" ")
    var a_1=parseInt(input[0],10);
    var b_0=parseInt(input[1],10);
    var c_m1=parseInt(input[2],10);
    var k=input[3];
    var n1=0;
    var n0=0;
    var nm1=0;
   
  if(a_1>=k){
    n1=k;
  }
  else if((a_1+b_0)>=k){
    n1=a_1;
    n0=k-(n1)
  }
  else if((a_1+b_0+c_m1)>=k){
    n1=a_1;
    n0=b_0
    nm1=k-(n1+n0); 
  }
  console.log(1*n1+ 0*n0 - nm1)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 29888
#[test]
fn check_solve() {
    println!(
        "input:\n5\n1 2\n2 3\n3 4\n4 5\n1 2 3 4 5\n\noutput:\n{}",
        solve("5\n1 2\n2 3\n3 4\n4 5\n1 2 3 4 5\n")
    );
    println!(
        "input:\n5\n1 2\n1 3\n1 4\n1 5\n3141 59 26 53 59\n\noutput:\n{}",
        solve("5\n1 2\n1 3\n1 4\n1 5\n3141 59 26 53 59\n")
    );
}
fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let n: usize = sc.read();
    let mut ngb = vec![Vec::new(); n];
    for _ in 0..n - 1 {
        let a: usize = sc.read();
        let b: usize = sc.read();
        ngb[a - 1].push(b - 1);
        ngb[b - 1].push(a - 1);
    }
    let mut c: Vec<usize> = (0..n).map(|_| sc.read()).collect();
    c.sort();
    let mut val = vec![None; n];
    val[0] = c.pop();
    let mut can = ngb[0].clone();
    let scr = c.iter().sum::<usize>();

    while let Some(v) = can.pop() {
        val[v] = c.pop();
        for &w in &ngb[v] {
            if val[w].is_none() {
                can.push(w);
            }
        }
    }

    let mut ret = String::new();
    use std::fmt::Write;

    writeln!(&mut ret, "{}", scr).unwrap();

    for &val in &val {
        write!(&mut ret, "{} ", val.unwrap()).unwrap()
    }
    ret.pop();
    ret.push('\n');
    ret
}
fn main() {
    let mut buf = String::new();
    use std::io::{Read, Write};
    std::io::stdin().read_to_string(&mut buf).unwrap();
    std::io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}
struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}


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

using namespace std;

template <typename T=int>
struct Fenwick {
    int n;
    vector<T> v;
    
    Fenwick(int size = 100005) : n(size), v(n+1, 0) {}
    inline void add(int p, T val) {
        for (; p <= n; p += (p&-p)) { v[p] += val; }
    }
    inline T query(int p) {
        T tmp = 0;
        for (; p > 0; p -= (p&-p)) { tmp += v[p]; }
        return tmp;
    }
    inline T query(int l, int r) {
        return query(r) - query(l-1);
    }
};

void solve() {
    int n; cin >> n;
    Fenwick<int> f(n);
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        if (f.query(x, n) == i) cnt++;
        f.add(x, 1);
    }
    cout << cnt;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 1024
def solve(list)
  odd_num = 0
  even_num = 0
  list.each do |e|
    if e.even?
      even_num += 1
    else
      odd_num += 1
    end
  end
  if odd_num.even?
    "YES"
  else
    "NO"
  end
end

def main
  n = gets.to_i
  list = gets.split.map {|e| e.to_i}
  puts solve(list)
end

main

Measured memory_bytes: 8452
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>

using namespace std;
int h,w,k[55][55];
char c[55][55];
int main()
{
	cin>>h>>w;
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			cin>>c[i][j];
			if(c[i][j]=='#')k[i][j]=1;
		}
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			if(c[i][j]=='#')cout<<"#";
			else
			{
				cout<<k[i-1][j-1]+k[i-1][j]+k[i-1][j+1]+k[i][j-1]+k[i][j+1]+k[i+1][j-1]+k[i+1][j]+k[i+1][j+1];
			}
		}
		cout<<"\n";
	}
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        int a=cin.nextInt();
        int b=cin.nextInt();
        int c=cin.nextInt();
        string ans = "No";
        if(a==b||b==c||c==a)ans="Yes";
        if(a==b&&a==c)ans="No";
        Console.WriteLine(ans);
        
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
    public void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}

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

int main(void){

  char S[10];
  scanf("%s",S);                //文字列入力
  char keep[3];
  int calc;
  int min = 10000;

  for(int i = 0 ; i < 8 ; i++){
    
    keep[0] = S[i];
    keep[1] = S[i + 1];
    keep[2] = S[i + 2];

    calc = 753 - atoi(keep);    //文字列を数値に変換したのを引く
    if(calc < 0) calc *= -1;    //絶対値に変換

    if(calc < min) min = calc;  //最小判定

  }

  printf("%d", min);
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
  //O(n)
    int n;
    scanf("%d",&n);
    if(n==1){
        printf("Yes\n");
        return 0;
    }
    int factors = 0;
    for(int i = 9; i >= 2; i--){
        while(n % i == 0){
            factors++;
            n = n / i;
        }
    }
    if(n > 1) printf("No\n");
    else{
        cout<<(1 <= factors  && factors <=2 ? "Yes" : "No") << "\n";
    }
    return 0;
}
/*
int main()
//Complexity O(n^2)
{
   int n;
   scanf("%d",&n);
   for(int i = 1; i <= 9; i++){
    for(int j = 1; j<= 9; j++){
        if(i * j == n){
           printf("Yes\n");
           return 0;
        }
    }
   }
   printf("No\n");
   return 0;
}
*/


Measured memory_bytes: 3736
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<string>
#include<functional>
#include<queue>
#include<math.h>
#define INF 999999

using namespace std;


int main()
{
	
	double a, b, c;
	double d, e, f;

	
	while (cin >> a >> b >> c >> d >> e >> f) {

		double x = (e*c - b*f) / (e*a - b*d);
		double y = (d*c - a*f) / (d*b - a*e);
		if (x == 0)x = 0;
		if (y == 0)y = 0;
		
		printf("%.3f %.3f\n", x,y);
	}

	return 0;
}

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

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

  if (N%10 == N%100/10 && N%100/10 == N%1000/100){
    cout << "Yes" << endl;
  }
  else if(N%100/10 == N%1000/100  && N%1000/100 == N/1000) {
    cout << "Yes" << endl;
    }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

vector<vector<pair<ll, ll>>> g;
vector<int> color;

void dfs(int v, int c=0){

    if(0<=color[v]) return;
    color[v]=c;
    for(auto x: g[v]){
        if(x.second&1) dfs(x.first, 1-c);
        else dfs(x.first, c);
    }
}

int main(){
    int n;  cin >> n;
    g.resize(n); color.resize(n, -1);
    REP(i, n-1){
        int a, b, x;   cin >> a >> b >> x;
        a--;    b--;
        g[a].emplace_back(b, x);
        g[b].emplace_back(a, x);
    }
    dfs(0);
    for(auto x: color) cout << x << endl;
    
}

Measured memory_bytes: 9600
n, k = list(map(lambda x: int(x),input().split(' ')))

has_cookie = []
for i in range(k):
  cookie_num = int(input())
  has_cookie.extend(list(map(lambda x: int(x), input().split(' '))))

has_cookie = list(set(has_cookie))

print(n - len(has_cookie))

Measured memory_bytes: 9228
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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


	ll N;
	cin >> N;

	co(N * (N - 1) / 2);

	Would you please return 0;
}

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

using namespace std;
typedef long long lint;

#define RPT(i, b, e) for (int i = (b); i <= (e); i++)
#define RPT0(i, n) RPT(i, 0, n - 1)
#define RPT1(i, n) RPT(i, 1, n)
#define EACH(it, v) for (const auto& it : v)
#define ALL(v) v.begin(), v.end()

lint gcd_table[201][201][201];

lint GCD(lint a, lint b) { return b ? GCD(b, a % b) : a; }
lint GCD2(lint a, lint b, lint c)
{
    if (gcd_table[a][b][c] == 0) gcd_table[a][b][c] = GCD(a, GCD(b, c));
    return gcd_table[a][b][c];
}

void resolve()
{
    int N;
    cin >> N;

    RPT1(i, N) RPT1(j, N) RPT1(k, N) gcd_table[i][j][k] = 0;
    lint ans = 0;
    RPT1(i, N) RPT1(j, N) RPT1(k, N) ans += GCD2(i, j, k);

    cout << ans << endl;
}

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


Measured memory_bytes: 66668