akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N;
string S[212345];
map<string, int> cnt;

int main() {

	cin >> N;
	rep(i, N) cin >> S[i];

	rep(i, N) cnt[S[i]]++;

	int maxim = 0;
	for (auto c : cnt) {
		maxim = max(maxim, c.second);
	}


	for (auto c : cnt) {
		if (c.second == maxim) {
			cout << c.first << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 27136
# https://juppy.hatenablog.com/entry/2019/02/20/ARC64_-E_Cosmic_Rays-_Python_%E7%AB%B6%E6%8A%80%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0_Atcoder
# 写経

import sys

input = sys.stdin.readline

inf = float('inf')


# 単一始点最短路
def dijkstra(s):
    # 始点sから各頂点への最短距離
    d = [inf] * N
    used = [False] * N
    d[s] = 0
    while True:
        v = -1
        # まだ使われていない頂点の中から最小の距離のものを探す
        for i in range(N):
            if (not used[i]) and (v == -1):
                v = i
            elif (not used[i]) and (d[i] < d[v]):
                v = i
        if v == -1:
            break
        used[v] = True
        # 隣接頂点までの距離を更新する
        for j in range(N):
            d[j] = min(d[j], d[v] + cost[v][j])
    return d


xs, ys, xt, yt = map(int, input().split())
N = int(input())

p = list()
p.append((xs, ys, 0))
p.append((xt, yt, 0))
for _ in range(N):
    p.append(tuple(map(int, input().split())))  # (x,y,r)

cost = [[0] * (N + 2) for _ in range(N + 2)]
# cost[u][v] : 辺uvのコスト（存在しないときはinf）


for i in range(N + 2):
    for j in range(i, N + 2):
        cost[i][j] = cost[j][i] = max(
            ((p[i][0] - p[j][0]) ** 2 + (p[i][1] - p[j][1]) ** 2) ** 0.5 - p[i][2] - p[j][2], 0)

cost = tuple(cost)
N += 2

res = dijkstra(0)
print(res[1])


Measured memory_bytes: 83184
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  string s,t;cin>>s>>t;
  int a,b;cin>>a>>b;
  string u;cin>>u;
  if(s==u)a--;
  else b--;
  cout<<a<<" "<<b<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <queue>
#include <tuple>
#include <cmath>
#include <map>
#include <cstring>

template<typename T> bool chmax( T &a, const T &b ) { if ( a <= b ) { a = b; return ( true ); } else { return ( false ); } }
template<typename T> bool chmin( T &a, const T &b ) { if ( a >= b ) { a = b; return ( true ); } else { return ( false ); } }

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pint = pair<int, int>;
using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par.resize( n ); siz.resize( n ); par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


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

	cout << ( 3 * r * r ) << endl;

	return ( 0 );
}


Measured memory_bytes: 888
#include <iostream>
#include <math.h>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cstdlib>
#include <unordered_map>
#include <numeric>
#include <functional>
#include <limits.h>
#include <utility>
#include <stack>

using namespace std;

#define fs first
#define sc second

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

ll p[101000], q[101000];
int main(){
    ll W, H;
    priority_queue<T, vector<T>, greater<T> > que;
    cin >> W >> H;
    for(int i = 0; i < W; i++){
        cin >> p[i];
        que.push(T(p[i], P(i, 0)));
    }
    for(int i = 0; i < H; i++){
        cin >> q[i];
        que.push(T(q[i], P(i, 1)));
    }

    W++; H++;
    ll res = 0;
    ll w = W, h = H;
    ll edgeNum = 0;
    while(!que.empty()){
        T nex = que.top(); que.pop();
        if(nex.sc.sc == 0){
            res += h * nex.fs;
            w--;
            edgeNum += w;
//            cout << "w: " << w << endl;
        }
        else{
            res += w * nex.fs;
            h--;
            edgeNum += w;
//            cout << "h: " << h << endl;
        }
//        cout << nex.fs << " " << res << " " << edgeNum << endl;
    }
//    cout << edgeNum << endl;

    cout << res << endl;




    return 0;
}

Measured memory_bytes: 9456
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::vector<int> a(n);
    std::priority_queue<int> que;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        que.push(a[i]);
    }
    for (int i = 0; i < n; i++) {
        if (que.top() == a[i]) {
            que.pop();
            std::cout << que.top() << std::endl;
            que.push(a[i]);
        }
        else {
            std::cout << que.top() << std::endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3316
import itertools
n = int(input())
li = list(map(int, input().split()))
com_li = list(itertools.combinations(li, 2))
result_li= []

for i in com_li:
  count = i[0] * i[1]
  result_li.append(count)

result = sum(result_li)
print(result)

Measured memory_bytes: 3188
import kotlin.math.min

fun StringBuilder.appendln(s: String): StringBuilder {
    this.append(s)
    this.append("\n")
    return this
}

fun main() {
    val builder = StringBuilder()

    var (n, a, b, c) = readInputLine().split(" ").map { it.toInt() }

    val query = Array(n) { readInputLine() }

    builder.appendln("Yes")

    for (i in 0 until n) {
        when(query[i]) {
            "AB" -> {
                if (a == 0 && b == 0) {
                    println("No")
                    return
                }
                if (a < b || (a == 1 && b == 1 && query[min(i + 1, n - 1)] == "AC")) {
                    builder.appendln("A")
                    a++
                    b--
                } else {
                    builder.appendln("B")
                    a--
                    b++
                }
            }
            "AC" -> {
                if (a == 0 && c == 0) {
                    println("No")
                    return
                }
                if (a < c || (a == 1 && c == 1 && query[min(i + 1, n - 1)] == "AB")) {
                    builder.appendln("A")
                    a++
                    c--
                } else {
                    builder.appendln("C")
                    a--
                    c++
                }
            }
            "BC" -> {
                if (b == 0 && c == 0) {
                    println("No")
                    return
                }
                if (b < c || (b == 1 && c == 1 && query[min(i + 1, n - 1)] == "AB")) {
                    builder.appendln("B")
                    b++
                    c--
                } else {
                    builder.appendln("C")
                    b--
                    c++
                }
            }
        }
    }

    println(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 61176
EXPECTD_RESULT = 7

def make_expressions(ns, expressions)
  return expressions if ns.empty?
  n = ns.shift
  new_expressions = expressions.each.with_object([]) do |expr, o|
    [ '+', '-' ].each { |op| o << expr + op + n }
  end
  make_expressions(ns, new_expressions)
end

def solve(ns)
  init = ns.shift
  make_expressions(ns, [ init ]).find { |expr| eval(expr) == EXPECTD_RESULT } + '=%d' % EXPECTD_RESULT
end

a = gets.chomp.scan(/./)
puts solve(a)


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define vb vector<bool>
#define vvb vector<vb>
#define pb push_back
#define inf 1e18
#define mod 1000000007
#define ps(x,y) fixed<<setpricision(y)<<x
#define w(t) int t; cin>>t; while(t--)
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.14159265358979323846
using namespace std;
const int N = 300 * 1000 + 13;
void init() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int32_t main()
{
	FIO;
	init();
	int n, k; cin >> n >> k;
	vi weight(n + 1);
	for (int i = 1; i <= n; i++) {
		int x; cin >> x; weight[i] = x;
	}
	map<int, set<int>> m;
	while (k--) {
		int x, y; cin >> x >> y;
		m[x].insert(y);
		m[y].insert(x);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int c = 0;
		if (m[i].size() == 0) ans++;
		else {
			for (int x : m[i]) {
				if (weight[i] > weight[x]) c++;
			}
			if (c == m[i].size()) ans++;
		}
	}
	cout << ans << '\n';
}

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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> m(N);

  int s = 0;
  for (int i = 0; i < N; i++) {
    cin >> m.at(i);
    s += m.at(i);
  }
  int min = 10000;
  for (int i = 0; i < N; i++) {
    if (min > m.at(i)) min = m.at(i);
  }

  cout << N + (X - s) / min << endl;


}

Measured memory_bytes: 256
/*
    In the name of Allah

    MohammadErfan Gooneh

*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

#define endl                        '\n'
#define all(a, n)                   for (int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
#define IOS                         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
int main() {
    IOS ;
    int a , b , c ;
    cin >> a >> b >> c;
    cout << (a*b < c)*(a*b) + (a*b >= c)*(c) ;


























return 0 ;
}


Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
int main() {
	int d[3],i;
	int max, min, mid;
	scanf("%d%d%d", &d[0],&d[1], &d[2]);
	max = min = mid = d[0];
	for (i = 1; i < 3; ++i) {
		if (d[i] > max)max = d[i];
		if (min > d[i])min = d[i];
		mid += d[i];
	}
	mid -= (max + min);
	printf("%d %d %d\n", min, mid, max);
	return 0;
}

Measured memory_bytes: 596
n = input()
digit = [int(n[-(i + 1)]) for i in range(len(n))]
digit.append(0)

ans = 0
for i in range(len(digit)):
  if digit[i] > 5 or (digit[i] == 5 and digit[i + 1] >= 5):
    ans += 10 - digit[i]
    digit[i] = 0
    digit[i + 1] += 1
  else:
    ans += digit[i]
    digit[i] = 0

print(ans)

Measured memory_bytes: 13632
import sys

lines = sys.stdin.readlines()

N = int(lines[0].rstrip())
S = lines[1].rstrip()

if N % 2 == 1:
    print('No')
else:
    zenhan = S[:N//2]
    kouhan = S[N//2:]

    if zenhan == kouhan:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3064
"use strict"

function Main(input) {
    const N = parseInt(input[0], 10);
    const V = input.slice(1).map(v => parseInt(v, 10));

    const sortedV = V.sort((a, b) => a - b);
    let result = 0;

    for (let i = 0; i < N - 1; i++) {
        if (i === 0) {
            result = (sortedV[i] + sortedV[i + 1]) / 2;
        } else {
            result = (result + sortedV[i + 1]) / 2;
        }
    }

    console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

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

#define int long long



typedef long long ll;
typedef long double ld;


int a[1001];

int repow(int x){
	return x*x*x*x*x;
}




signed main(){
	ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int X;
    cin>>X;
    for(int i = 1;i < 1001;i++){
    	a[i] = repow(i);
	}
	for(int i = 0;i < 1001;i++){
		int y = abs(a[i]-X);
		int l = 0,r = 1000;
		while(l != r){
			int mid = l + (r-l)/2;
			if(a[mid] >= y) r = mid;
			else l = mid+1;
		}
		if(a[l] == y){
			cout<<i<<" "<<(a[i] >= X ? l : -l)<<endl;
			return 0;
		}
	}
    return 0;
}


Measured memory_bytes: 3656
def g(s, k):
	if s < 0: return 0
	if s == 0: return 1
	if k <=s <= 2*k: 
		return k - (s - k) +1
		return k +1
	if s < k: return s + 1
	if s > 2*k: return 0 

def f(s,k):
	ans = 0
	for c in range(k+1): 
		ans += g(s - c,k)
	return ans
k,s = map(int, raw_input().split())
print f(s,k)

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

int main(void)
{
	int n;
	while(cin >> n)
	{
		int e = 1;
		bool first_output = true;
		for(int i=0; i<=10; i++)
		{
			if( (n & e) == e )
			{
				if(first_output)
				{
					cout << e;
					first_output = false;
				}
				else
					cout << " " << e;
			}
			e *= 2;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
from collections import Counter
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    n = int(input().strip())
    S = input().strip()
    cnts = Counter(S)

    x = 1
    for v in cnts.values():
        x *= (v + 1)
    ans = x - 1

    MOD = 10**9 + 7

    print(ans % MOD)
    return


if __name__ == "__main__":
    main()

Measured memory_bytes: 73824
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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; }
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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(x - a) < abs(x - b))cout << "A" << endl;
	else cout << "B" << endl;
}

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

using namespace std;

int N;
int ans = 0;
bool is;
int main() {
  string s,t;
  cin >> N >> s >> t;
  int k = 0;
  for(int i = 0; i < s.length(); i++) {
    if(s[i] == t[k]) {
      ans++;
      k++;
    }
    else if(ans > 0) {
      ans = 0;
      k = 0;
      i--; 
    }
  }
  cout << N * 2 - ans <<endl;
}



Measured memory_bytes: 256
N, M, C = map(int, input().split())
b = list(map(int, input().split()))
cnt = 0
for _ in range(N):
    a = list(map(int, input().rstrip().split()))
    if sum([ai*bi for ai,bi in zip(a,b)])+C > 0:
        cnt += 1
        
print(cnt)


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

using namespace std;

int main(){
    long long N;
    cin >> N;
    long long SN = 0;
    for(int i = 0; i < to_string(N).size(); i++){
            SN += (int)(to_string(N)[i] - '0');
    }

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

    return 0;
}

Measured memory_bytes: 256
def divisor(num):
  
  count=0
  for i in range(1,num+1):
    if (num%i==0):
      count+=1
  return count
 
n=int(input())
 
if(n<=105):
  if(n==105):
    print(1)
  else:
    print(0)
  exit()

res=1
 
for i in range(106,n+1):
  if(divisor(i)==8 and i%2==1):
    res+=1
print(res)

Measured memory_bytes: 3064
#include<cstdio>
#include<string>
#include<iostream>
using namespace std;
string s;
bool C=0;
int main()
{
	cin>>s;
	int i;
	for(i=0;i<s.length();i++)
		if(s[i]=='C')
		{
			C=1;
			break;
		}
	if(!C||i==s.length()-1)
	{
		printf("No");
		return 0;
	}
	for(;i<s.length();i++)
		if(s[i]=='F')
		{
			printf("Yes");
			return 0;
		}
	printf("No");
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 100005
typedef long long LL;
template<class T>void tomax(T &x,T y){
	if(x<y)x=y;	
}
template<class T>void tomin(T &x,T y){
	if(x>y)x=y;	
}
int main(){
	int n,d;
	cin>>n>>d;
	int mx=d+d+1;
	if(n%mx==0)cout<<n/mx;
	else cout<<n/mx+1;
	return 0;
}

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

using namespace std;

typedef long long ll;

const int mod = 998244353;
const int N = 2e5 + 5;

int n, k;
int l[N], r[N];
ll d[N];
int u[N];

void add(ll& a, ll b) {
    a += b;
    while (a >= mod) {
        a -= mod;
    }
    while (a < 0) {
        a += mod;
    }
}

int main() {
    ios::sync_with_stdio(0); 

    cin >> n >> k;
    
    memset(d, 0, sizeof(d));
    memset(u, 0, sizeof(u));

    for (int i = 0; i < k; ++i) {
        cin >> l[i] >> r[i];
    }

    set<pair<int,int>> s;
    s.emplace(1, 1);

    d[1] = 1;

    int di = 2;

    while (!s.empty()) {
        auto [fr, sc] = *s.begin();

        while (di + 1 <= fr) {
            add(d[di + 1], d[di]);
            di++;
        }

        s.erase(s.begin());
        
        if (fr >= n || u[fr]) {
            continue;
        }

        u[fr] = 1;

        for (int i = 0; i < k; ++i) {
            if (fr + l[i] < N) {
                add(d[fr + l[i]], d[fr]);
            }
            if (fr + r[i] + 1 < N) {
                add(d[fr + r[i] + 1], -d[fr]);
            }
            s.emplace(fr + l[i], fr + r[i]);
        }

        if (fr + 1 < sc) {
            s.emplace(fr + 1, sc);
        }
    }

    cout << d[n] << endl;

    return 0;
}


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

int main() {
    string N;
    cin >> N;
    string ans = "No";
    if (N[0] == '7') ans = "Yes";
    if (N[1] == '7') ans = "Yes";
    if (N[2] == '7') ans = "Yes";
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

#define INF (long long)(10e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
    int n,r,l,s=0;
    cin >> n;
    REP(i, n) {
        cin >> r >> l;
        s += l-r+1;
    }
    cout << s << endl;
}


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

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


	for (i = 0; i < n; i++) {

		if (A[i]%2==1) continue;
		if (A[i]%3*(A[i]%5)!=0)
		{
			cout<<"DENIED"<<endl;
		return 0;}

	}


	cout<<"APPROVED"<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
long long dp[100009],ans;
long long arr[100009];
int solve(int idx)
{
    if(idx==n-1) return 0;
    if(dp[idx]!=-1) return dp[idx];
    ans=solve(idx+1)+(abs(arr[idx+1]-arr[idx]));
    if(idx+2<n)
       {
           ans=min(ans,solve(idx+2)+ abs(arr[idx+2]-arr[idx]));
       }
    return dp[idx]=ans;
}
int main()
{
    memset(dp,-1,sizeof(dp));
    cin>>n;
    for(int i=0;i<n;i++) cin>>arr[i];
    cout<<solve(0)<<endl;
    return 0;
}


Measured memory_bytes: 8276
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

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

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


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

int main()
{
    int i,j,n,len,flag=1;
	char a[101][11],word;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",a[i]);
	}
		len=strlen(a[0]);
		word=a[0][len-1];
    for(i=1;i<n;i++)
	{
		if(word!=a[i][0])flag=0;
		for(j=0;j<i;j++)
		{
			if(strcmp(a[i],a[j])==0)flag=0;
		}
		len=strlen(a[i]);
		word=a[i][len-1];
	}
    if(flag)printf("Yes");
	else printf("No");
}


Measured memory_bytes: 128
import numpy as np
def solve(n, a, b):
    a = np.asarray(a)
    b = np.asarray(b)
    if np.sum(a) < np.sum(b):
        return -1
    d = b - a
    ans = 0
    points = 0
    for i in range(n):
        if d[i] > 0:
            points += d[i]
            d[i] = 0
            ans += 1
    for v in sorted(d):
        if points <= 0:
            return ans
        points += v
        ans += 1
    return ans

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

Measured memory_bytes: 27192
N=int(input());A=list(map(int,input().split()));j=1;fg=0
if N==1:
    if A[0]==1:print(0)
    else: print(-1)
else:
    for i in A:
        if i==j:j+=1
        else:fg+=1
    if j>1:print(fg)
    else: print(-1)

Measured memory_bytes: 32344
#include <iostream>
#include <algorithm>
using namespace std;
int main (){
    int a,b;
    cin >> a >> b;
    if(a>9||b>9||a<1||b<1){
        cout << -1 << endl;
    }
    else{
        cout << a*b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0

_x = -2
for x in a:
    x -= 1
    ans += b[x]
    if x == (_x) + 1:
        ans += c[_x]
    _x = x

print(ans)


Measured memory_bytes: 38256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>
#include<functional>
#include<numeric>
#include <tuple>

using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define mkp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
#define ssp(i,n) (i==n-1?"\n":" ")
#define tpop(p) p.top();p.pop()
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll Inf = 3 * 1e18;
const int inf = 15 * 1e8;
ll read() {
	ll u, k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
/*const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}*/
//---------------------------------------------------
int n, a, b;
signed main() {
	cin >> n >> a >> b;
	if (a > b) swap(a, b);
	if ((b - a) % 2 == 0) {
		cout << (b - a) / 2 << endl;
	}
	else {
		int ans = min(b - 1, n - a);
		int k = a + (n - b + 1);
		ans = min(ans, n - b + 1 + (n - k) / 2);
		k = b - (a);
		ans = min(ans, a + (k - 1) / 2);
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
const int MOD = 1000000007;



int main(){
    int N, X; cin >> N >> X;
    vector<int> L(N);
    rep(i,N) cin >> L[i];

    int ans = 0;
    int count = 0;
    rep(i,N){
        if (ans+L[i] > X) break;
        ans += L[i];
        count++;
    }

    cout << count+1 << endl;
}

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

typedef long long ll;

vector<int>g[55];
int color[55];
int visited[55];

void dfs(int u)
{
	color[u]=1;
	for(int i=0;i<(int)g[u].size();i++) if(color[g[u][i]]==0) dfs(g[u][i]);
}

void make_edge(int u,int v)
{
	g[u].push_back(v);
	g[v].push_back(u);
}

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

    int n,m;
    cin>>n>>m;
    
    for(int i=0;i<m;i++)
    {
    	int a,b;
    	cin>>a>>b;
    	make_edge(a,b);
    }
    
    int edge=0;
    for(int i=1;i<n+1;i++) visited[i]=0;
    
    for(int i=1;i<n+1;i++)
    {
    	visited[i]=1;
    	int sz=g[i].size();
    	int j=sz-1;
    	
    	while(j!=-1)
    	{
    		int temp=g[i][j];
    		
    		if(visited[temp])
    		{
    			j--;
    			continue;
    		}
    		
    		g[i].erase(g[i].begin()+j);
    		for(int k=0;k<(int)g[temp].size();k++)
    		{
    			if(g[temp][k]==i)
    			{
    				g[temp].erase(g[temp].begin()+k);
    			}
    		}
    		
    		int cnt=0;
    		
    		for(int k=1;k<n+1;k++) color[k]=0;
    		
    		for(int k=1;k<n+1;k++) 
    		{
    			if(color[k]==0)
    			{
    				cnt++;
    				dfs(k);
    			}
    		}
    		
    		if(cnt>1) edge++;
    		j--;
    		make_edge(i,temp);
    		
     	}
    }
    
    
    cout<<edge;
  
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
int n;cin>>n;
if(n>=0&&n<1200)
  cout<<"ABC"<<endl;
else if(n>=1200&&n<2800)
  cout<<"ARC"<<endl;
else 
  cout<<"AGC"<<endl;
return 0;}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

/*ll factorial(int r){
  if(r==0) return 1;
  return factorial(r-1)*r;
}

ll nPr(int n,int r){
  if(r==0) return 1;
  return nPr(n-1,r-1)*n;
}

ll nCr(int n,int r){
  return nPr(n,r)/factorial(r);
}

int main(){
  int n,p; cin >> n >> p;
  int even = 0,odd = 0;



  rep(i,n){
    int a; cin >> a;
    if(a%2) odd++;
    else even++;
  }

  ll ans1 = pow(2,even);

  ll ans2 = 0;

  for(int i=p;i<=odd;i+=2){
    ans2 += nCr(odd,i);
  }

  cout << ans1 * ans2 << endl;


}*/
int main(){
  int n,p; cin >> n >> p;
  int m=0;
  rep(i,n){
    int a; cin >> a;
    if(a%2==1) ++m;
  }

  if(m==0) cout << (p==0 ? (1LL<<n):0) << endl;
  else cout << (1LL<<(n-1)) << endl;
}


Measured memory_bytes: 3624
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n, m; cin>>n>>m;
    vector<vector<int>> G(n);
    for(int i=0; i<m; i++){
        int a, b; cin>>a>>b;
        a--, b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    vector<vector<int>> memo(n, vector<int>(11, -1));
    vector<int> ans(n, 0);

    int q; cin>>q;
    vector<int> v(q), d(q), c(q);
    for(int i=0; i<q; i++) cin>>v[i]>>d[i]>>c[i];

    for(int i=q-1; i>=0; i--){
        v[i]--;
        queue<T> que;
        que.emplace(v[i], -1, d[i]);
        while(que.size()){
            int cv, pv, dist;
            tie(cv, pv, dist) = que.front(); que.pop();

            bool valid = true;
            for(int i=dist; i<=10; i++){
                if(memo[cv][i] != -1) valid = false;
            }

            if(!valid) continue;

            memo[cv][dist] = c[i];
            if(ans[cv] == 0) ans[cv] = c[i];

            for(auto nv : G[cv]){
                if(nv == pv) continue;

                que.emplace(nv, cv, dist - 1);
            }
        }
    }

    for(int i=0; i<n; i++) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 17528
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, R; cin >> n >> R;

    int res;
    if(n >= 10){
        res = R;
    }
    else {
        res = R + 100 * (10 - n);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define sd second
#define pi pair<int,int>

using namespace std;

const int maxn = 1<<19;

int n,a[maxn],sum;
pi mx[maxn];

int cmp(int x,int y) {
    return a[x] > a[y];
}

int main() {
  //  freopen("in.txt","r",stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for (int i=0;i<(1<<n);i++) {
        cin>>a[i];
    }
    vector<int> tmp;
    for (int i=0;i<(1<<n);i++) {
        tmp.clear();
        tmp.push_back(i);
        for (int j=0;j<n;j++)
            if ((i>>j)&1) {
                int x = i ^ (1<<j);
                tmp.push_back(mx[x].fi);
                if (mx[x].sd!=-1) tmp.push_back(mx[x].sd);
            }
        sort(tmp.begin(),tmp.end(),cmp);
        tmp.resize(unique(tmp.begin(),tmp.end()) - tmp.begin());
        if (tmp.size()==1) mx[i] = pi(tmp[0],-1);
        else mx[i] = pi(tmp[0],tmp[1]);
    }
    int ans = 0;
    for (int i=1;i<(1<<n);i++) {
        ans = max(ans, a[mx[i].fi] + a[mx[i].sd]);
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 9216
#define taskname ""

#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>

using namespace std;
#define long long long

const int N = 1e5 + 10;

struct S {
    int w, s, v;
    bool operator < (const S& b) {return s + w < b.s + b.w;}
};
vector<S> blocks;
int n;
long dp[N];

int main()
{
//    freopen(taskname".INP", "r", stdin);
//    freopen(taskname".OUT", "w", stdout);

    scanf("%d", &n);
    for (int i = 0, x, y, z; i < n; ++i) {
        scanf("%d%d%d",&x, &y, &z);
        blocks.push_back({x, y, z});
    }
    sort(blocks.begin(), blocks.end());

    for (int i = 0; i < n; ++i)
        for (int sum = blocks[i].s; sum >= 0; --sum)
            dp[sum + blocks[i].w] = max(dp[sum + blocks[i].w], dp[sum] + blocks[i].v);

    long res = 0;
    for (int i = 1; i <= (int) 2e4; ++i) res = max(res, dp[i]);
    cout << res;

    return 0;
}


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

using namespace std;

class Solution {
public:
	void solve() {
		int n;
		cin >> n;
		cout << (1000 - n % 1000) % 1000 << endl;
		return;
	};
};

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

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

	// ??§?¨?
	public class P {
		public double x;
		public double y;

		public P(double x, double y) {
			this.x = x;
			this.y = y;

		}
	}

	void run() {
		Scanner sc = new Scanner(System.in);

		int r, a;
		int angle = 0;

		P p = new P(0, 0);

		while (true) {
			String[] str = sc.next().split(",");
			r = Integer.parseInt(str[0]);
			a = Integer.parseInt(str[1]);

			if (r == 0 && a == 0) {
				break;
			}

			p.x = p.x + r * Math.sin(angle * Math.PI / 180);
			p.y = p.y + r * Math.cos(angle * Math.PI / 180);
			angle += a;
		}

		System.out.println((int) p.x);
		System.out.println((int) p.y);

		sc.close();
	}

	public static void main(String[] args) {
		new Main().run();
	}

}

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

int main() {
  int a,n,m;
  cin >> a >> n >> m; 
  for(int i=n;i<=m;i++){
  if(i%a==0){
    cout << "OK" << endl; 
    return 0;
  }
  }
    cout << "NG" << endl; 
}  

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

int main() {
  int N,M;
  cin>>N>>M;
  vector<pair<long,long>>a;

  for (int i = 0; i < N; i++) {
    int A,B;
    cin >> A>>B;
    a.push_back(pair<int,int>(A,B));
  }
  sort(a.begin(), a.end());
  long ans=0;
  
    for (int i = 0; i < N; i++) {
      if(a.at(i).second<=M){
        long b=a.at(i).first;
        ans+=b*a.at(i).second;
        M-=a.at(i).second;
      }
      else{
        ans+=a.at(i).first*M;
        break;
      }
    }
  
  
    cout<<ans<<endl;
  
}



Measured memory_bytes: 2420
import java.util.Scanner;
import java.util.Arrays;
public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    String input = s.nextLine();
    s.close();
    String[] inputAry = input.split("");
    for (int i = 0; i < inputAry.length; i++) {
      if (Character.isLetter(inputAry[i].charAt(0))) {
        if (Character.isUpperCase(inputAry[i].charAt(0)))
          inputAry[i] = inputAry[i].toLowerCase();
        else
          inputAry[i] = inputAry[i].toUpperCase();
      }
    }
    String result = String.join("", inputAry);
    System.out.println(result);
  }
}



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


int main(){
  int E,Y;
  int y;
  char e;

  cin >> E >> Y;
  
  if(E == 0){
    if( Y >= 1868 && Y <= 1911){
      e = 'M';
      y = Y - 1867;
    }else if( Y >= 1912 && Y <= 1925){
      e = 'T';
      y = Y - 1911;
    }else if( Y >= 1926 && Y <= 1988){
      e = 'S';
      y = Y - 1925;
    }else if( Y >= 1989 && Y <= 2016){
      e = 'H';
      y = Y - 1988;
    }

    cout << e << y << endl;
  }else{
    if(E == 1){
      y = 1867 + Y;
    }else if(E == 2){
      y = 1911 + Y;
    }else if(E == 3){
      y = 1925 + Y;
    }else if(E == 4){
      y = 1988 + Y;
    }

    cout << y << endl;
  }
  
  return 0;
}



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

int main() {
    int cnt=0;
    string s,t;
    cin >> s >> t;
    if(t[0]==s[0]) {
      cnt++;
    }
    if(t[1]==s[1]) {
      cnt++;
    }
    if(t[2]==s[2]) {
      cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
using namespace std;
 
typedef long long ll;
//typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
static const int MOD = 1000000007;
//static const int INF = 21474836470;
//static const long long INF = 9223372000000000000;
static const long long INF = 4000000000;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define ALL(x) (x).begin(),(x).end()
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define int ll

struct edge {int to;double cost;};
typedef pair<double,int> P;

vector<edge> G[1145];
double d[1145];
int V; //dはKを始点とした最短距離を記録

void dijkstra(int s){   //dijkstraをしました
    PQ<P,vector<P>,greater<P> > que;
    fill(d,d+V,INF);
    d[s] = 0;
    que.push(P(0.0,s));

    while(!que.empty()){
        P p=que.top(); que.pop();
        int v = p.second;
        if(d[v]<p.first) continue;
        for(int i=0;i<G[v].size();i++){
            edge e = G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}

double pyth(int a, int b){  //直角三角形の斜辺を求める std::hypotは知らない
    return sqrt(a*a+b*b);
}

signed main(){
    int sx,sy,gx,gy;
    cin >> sx >> sy >> gx >> gy;
    int n;
    cin >> n;
    int a[1145],b[1145],c[1145];
    REP1(i,n) scanf("%lld%lld%lld",&a[i],&b[i],&c[i]);
    a[0] = sx, b[0] = sy, c[0] = 0;
    a[n+1] = gx, b[n+1] = gy, c[n+1] = 0;
    V = n + 2;
    REP(i,V){   //全点対間に辺を張る
        FOR(j,i+1,V){
            double dis = max(0.0,pyth(a[i]-a[j],b[i]-b[j]) - double(c[i]+c[j]));
            edge x,y;
            x.cost = y.cost = dis;
            x.to = j;y.to = i;
            G[i].PB(x);
            G[j].PB(y);
        }
    }

    dijkstra(V-1);

    printf("%.15lf\n",d[0]);

    return 0;
}


Measured memory_bytes: 22804
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
using namespace std;

struct point {
	double x, y;
};
void koch(int d, point p1, point p2) {
	if (d == 0) return;
	point s, t, u;
	double pi = acos(-1);
	s.x = (2 * p1.x + p2.x) / 3;
	s.y = (2 * p1.y + p2.y) / 3;
	t.x = (p1.x + 2 * p2.x) / 3;
	t.y = (p1.y + 2 * p2.y) / 3;
	u.x = s.x + (t.x - s.x) * cos(pi / 3) - (t.y - s.y) * sin(pi / 3);
	u.y = s.y + (t.y - s.y) * cos(pi / 3) + (t.x - s.x) * sin(pi / 3);
	koch(d - 1, p1, s);
	printf("%.4f %.4f\n", s.x, s.y);
	koch(d - 1, s, u);
	printf("%.4f %.4f\n", u.x, u.y);
	koch(d - 1, u, t);
	printf("%.4f %.4f\n", t.x, t.y);
	koch(d - 1, t, p2);
}

int main() {
	int n;
	cin >> n;
	point p1, p2;
	p1.x = 0, p1.y = 0, p2.x = 100, p2.y = 0;
	printf("%.4f %.4f\n", p1.x, p1.y);
	koch(n, p1, p2);
	printf("%.4f %.4f\n", p2.x, p2.y);
}


Measured memory_bytes: 3200
while True:
    n = int(input())
    numbers = []

    if n == 0:
        break

    for i in range(0, n):
        numbers.append(int((input())))

    maxValue = max(numbers)
    minValue = min(numbers)
    totalScore = sum(numbers)

    print(str(int((totalScore - maxValue - minValue) / (len(numbers) - 2))))


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long

void solve(){
	int n;
	cin >> n;
	vector<int> a(n);
	int X = 0;
	for(int i=0; i<n; i++) {
		cin >> a[i];
		X ^= a[i];
	}
	for(int i=0; i<n; i++) {
		cout << (X^a[i]) << " ";
	}
}

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

Measured memory_bytes: 3972
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,i,j,a[200000],max=-1000000000;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    int min=a[0];
    for(i=1;i<n;i++){
        if(a[i]-min>max)max=a[i]-min;
        if(a[i]<min)min=a[i];
    }
    cout<<max<<endl;
}



Measured memory_bytes: 3880
#include <stdio.h>

int main()
{
    long a, b;
    long d, r;
    double f;

    scanf("%ld %ld", &a, &b);
    d = a / b;
    r = a % b;
    f = (double)a / b;
    printf("%ld %ld %.5f\n", d, r, f);

    return 0;
}

Measured memory_bytes: 640
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

ll modpow(ll r,ll n,ll m=MOD){
  ll re=1,d=r%m;
  if(n<0)(n%=m-1)+=m-1;
  for(;n;n/=2){
    if(n&1)(re*=d)%=m;
    (d*=d)%=m;
  }
  return re;
}

ll psum[444][444];
ll pw[444][444];
ll dp[444][444];

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n,c;
  cin>>n>>c;
  vector<ll> a(n),b(n),d(n);
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];
  rep(i,404) pw[i][0]=1;
  rep(i,404) rep(j,404) pw[i][j+1]=pw[i][j]*i%MOD;
  rep(i,n) rep(j,c+1) reps(k,a[i],b[i]+1) (psum[i][j]+=pw[k][j])%=MOD;
  dp[0][0]=1;
  rep(i,n) rep(j,c+1) rep(k,c-j+1){
    (dp[i+1][j+k]+=dp[i][j]*psum[i][k]%MOD)%=MOD;
  }
  //rep(i,n+1){rep(j,c+1)cout<<dp[i][j]<<",";cout<<endl;}
  cout<<dp[n][c]<<endl;
  return 0;
}


/* 悲しみ

  rep(i,n) d[i]=b[i]-a[i];
    cout<<d;
  dp[0]=1;
  rep(i,n){
    fill(sum,sum+161234,0);
    rep(j,160234) sum[j+1]=(sum[j]+dp[j])%MOD;
    rep(j,160234) dp[j]=sum[j+1]-sum[max(0,j-d[i])];
    rep(j,10) cout<<sum[j]<<",";cout<<endl;
    rep(j,10) cout<<dp[j]<<",";cout<<endl;
  }
  rep(j,10) cout<<dp[j]<<",";cout<<endl;
  ll re=0,o=accumulate(all(a),0ll)%MOD;
  cout<<o<<endl;
  rep(i,160234) (re+=dp[i]*modpow(o+i,c)%MOD)%=MOD;
  cout<<re<<endl;


 */


Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
int abs(int a,int b){
  if(a>b)
    return a-b;
  else
    return b-a;
}

int gcd(int a,int b){
  if(a%b==0)
    return b;
  else{
    a%=b;
    swap(a,b);
   // cout << a << b << endl;
    return gcd(a,b);
  }
}

int gg(int a,int b){
  if(a<b)
    swap(a,b);
  return gcd(a,b);
}

int main(){
  int n,x;
  cin >> n >> x;
  vector<int> da(n),ans(n);
  cin >> da[0];
  ans[0]=abs(x,da[0]);
  for(int i=1;i<n;i++){
    cin >> da[i];
    ans[i]=abs(da[i],da[i-1]);
  }
  if(n==1){
    cout << ans[0] << endl;
    return 0;
  }
  int y=gg(ans[0],ans[1]);
  for(int i=2;i<n;i++){
    y=gg(y,ans[i]);
  }
  cout << y << endl;
}

Measured memory_bytes: 1024
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>

using namespace std;

/// 各桁の和
int sumdigit(int x){
   int sum = 0;
    while(x != 0){
        sum += x % 10;
        x /= 10;
    }
    return sum;
}
/// 最小公倍数 
int gcd(int x, int y){
      if(x<y){
          int temp = x;
          x = y;
          y = temp;
      }
      int r = x % y;
       while(r!=0){
           x = y;
           y = r;
           r = x % y;
       }
      return y;
   }
int main(){
  string S;
  cin >> S;
  for(int i = 0; i < S.size(); i++){
      for(int j = 0; j < S.size(); j++){
          string T = S;
          if(T.erase(i,j) == "keyence"){
              cout << "YES" << endl;
              return 0;
          }
      }
  }
  cout << "NO" << endl;
  }

Measured memory_bytes: 256
params0 = list(map(lambda x: int(x), input().split(' ')))
paramN, paramK = params0

data = [True for i in range(paramN)]

for i in range(paramK):
    input()
    sunukes = list(map(lambda x: int(x), input().split(' ')))
    for sunuke in sunukes:
        data[sunuke - 1] = False

print(len(list(filter(lambda x: x, data))))


Measured memory_bytes: 9192