akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pii pair<int,int>
#define pll pair<long long, long long>
#define rep(i,l,r) for(int i = l;i<r;i++)

#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()

#define fastout  ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
using namespace __gnu_pbds;

typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> order_set;

const int INF = (int)1e9 + 7;
const long long LLINF = (long long)1e18 + 7;

int main() {
    vector<int> cc = {105, 135, 189, 165, 195};
    int n;
    cin >> n;
    int ans = 0;
    for (auto it: cc) {
        if (it <= n) {
            ans++;
        }
    }
    cout << ans;
}


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

using namespace std;
typedef long long ll;

const int mod = 998244353;
const int M = 3e5 + 50;

#define rush() int T;cin>>T;while(T--)


ll fac[M]={1,1},inv[M]={1,1},f[M]={1,1};

ll C(ll a,ll b){
    if(b>a)return 0;
    return fac[a]*inv[b]%mod*inv[a-b]%mod;
}

void init(){//快速计算阶乘的逆元
    for(int i=2;i<M;i++){
        fac[i]=fac[i-1]*i%mod;
        f[i]=(mod-mod/i)*f[mod%i]%mod;
        inv[i]=inv[i-1]*f[i]%mod;
    }
}

int main() {
	
	init();
	ll n,a,b,k;
	scanf("%lld %lld %lld %lld",&n,&a,&b,&k);
	
	ll ans = 0;
	
	for(int i=0;i<=n;i++) { // x
		ll y = (k - a*i) / b;
		if( k < a*i || ((k - a*i) % b) || y > n) continue;
		ans = ( ans + C(n,i) * C(n,y) )% mod;
	}
	
	cout<<ans;
	
}




Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
int a[(int)2e5];
int main()
{
    long long ans=0;
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
   
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    int cnt=a[0];
    for (int i = 1; i < n; i++)
    {
        if(a[i]<cnt) ans+=cnt-a[i];
        cnt=max(a[i],cnt);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4400
#include <iostream>
#include <cmath>
#include <cstring>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cassert>
#include <unordered_map>

#define DEBUG false
#define OJ_DEBUG

#define $(x) {if (DEBUG) {cout << __LINE__ << ": "; {x} cout << endl;}}
#define _(x) {cout << #x << " = " << x << " "; }
const double E = 1e-8;
const double PI = acos(-1);

using namespace std;

typedef long long ll;
typedef std::pair<int, int> pii;
typedef unsigned long ul;

int main() {
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n, k, ans = 0;
    cin >> n >> k;

    while (n > 0) {
        int aux = n % k;
        n /= k;
        ans++;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,n,c;
    cin>>n>>a>>b;
    c=n*a;
    if(c>b)
    {
        cout<<b<<endl;
    }
    else
    {
        cout<<c<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;
typedef tuple<int,int,int> TP;
int main() {
  int a, b;
  char c;
  cin >> a >> c >> b;
  cout << (c == '+' ? a + b : a - b) << endl;
  return 0;
} 

Measured memory_bytes: 3624
<?php
fscanf(STDIN, "%d %d %d %d", $A, $B, $C, $D);
$result = 'Yes';
$count = 0;

while ($A > 0 && $C > 0){
  if ($count % 2 === 0) {
    $C -= $B;
  } else {
    $A -= $D;
  }
  $count++;
}

if ($A <= 0) {
  $result = 'No';
}

echo $result;

Measured memory_bytes: 16200
#include <iostream>
#include <climits>
#include <algorithm>
#include <string>
using namespace std;

int main(void){
	int n[] = {4,1,4,1,2,1,2,1};

	while(1){
		int c[8];
		for(int i=0;i<8;i++) if(!(cin>>c[i])) return 0;

		string minS = "";
		int min = INT_MAX;

		for(int i=0;i<8;i++){
			int sum = 0;
			string s = "";

			for(int j=0;j<8;j++){
				s += (char)(n[(i+j)%8] + '0');
				int rem = c[j] - n[(i+j)%8];
				if(rem > 0) sum += rem;
			}

			if(min >= sum){
				if((min > sum) || (min == sum && s.compare(minS) < 0)){
					minS = s;
				}
				min = sum;
			}
		}

		for(int i=0;i<7;i++){
			cout<<minS.at(i)<<" ";
		}
		cout<<minS.at(7)<<endl;
	}
}

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

int main(void)
{
    char W[10],T[1000];
    int i,sum = 0;
    
    scanf("%s",W);
    while(1){
        scanf("%s",T);
        if(strcmp(T,"END_OF_TEXT")==0){
            break;
        }
        for(i=0; T[i] != '\0'; i++){
            if('A' <= T[i] && T[i] <= 'Z'){
			T[i]+=32;
		    }
        }
        if(strcmp(T,W)==0){
            sum++;
        }
    }
    printf("%d\n",sum);
    return 0;
}


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

int main(){
    // Your code here!
    int a,b;
    int answer;
    cin >> a >> b;
    answer = a*b;
    
    if(answer %2 == 0){
        cout << "Even" << endl;
    }
    else{
        cout << "Odd" << endl;
    }
    
}


Measured memory_bytes: 3624
before = 0
cur = 0

N = int(input())

for h in map(int, input().split()):
    if (cur - 1 > h):
        print("No")
        exit()
    elif (cur - 1 == h):
        if (before > h):
            print("No")
            exit()
        else:
            cur = h
            before = h
    else:
        cur = h

print("Yes")

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

int main(){
  int D,G; cin >> D >> G;
  int p[10],c[10];
  for(int i=0; i<D; i++) cin >> p[i] >> c[i];
  int minprob=10000;
  for(int i=0; i<(1<<D); i++){
    int used[10]={};
    int scoresum=0;
    int probsum=0;
    for(int j=0; j<D; j++){
      if((i&(1<<j))>0){
        used[j]=1;
        probsum+=p[j];
        scoresum+=(100*(j+1)*p[j]+c[j]);
      }
    }
    if(scoresum<G){
      for(int j=0; j<D; j++){
        if(used[D-1-j]==0){
          if(scoresum+100*(D-j)*p[D-1-j]>G){
            int k=(G-scoresum+100*(D-j)-1)/(100*(D-j));
            scoresum+=100*(D-j)*k;
            probsum+=k;
          }else{
            scoresum+=(100*(D-j)*p[D-1-j]);
            probsum+=p[D-1-j];
          }
        }
        if(scoresum>=G) break;
      }
    }
    if(scoresum>=G) minprob=min(minprob,probsum);
  }
  cout << minprob << endl;
}

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

int n, t;
long long k;
vector<int> c, f;

bool check(long long m)
{
	long long ret = 0;
	for (int i=0; i<n; ++i)
		ret += max(0LL, c[i] - m/f[i]);
	return ret <= k;
}

int main()
{

	cin >> n >> k;
	for (int i=0; i<n; ++i) {
		cin >> t;
		c.push_back(t);
	}

	for (int i=0; i<n; ++i) {
		cin >> t;
		f.push_back(t);
	}

	sort(c.rbegin(), c.rend());
	sort(f.begin(), f.end());

	long long l = 0, r = 1e18;
	while (l <= r) {
		long long mid = (l+r)/2;
		if (check(mid))
			r = mid-1;
		else
			l = mid+1;
	}
	cout << l << '\n';

	return 0;
}


Measured memory_bytes: 2548
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void calc(int[] a) {
    auto b = a.dup;
    b.sort!"a > b";

    int x = b[0];
    int y = b[1];
    foreach (e; a) {
        writeln(e == x ? y : x);
    }
}

void main() {
    int n; scan(n);
    int[] a;
    foreach (_; 0..n) a ~= readint;
    calc(a);
}


Measured memory_bytes: 5756
let () =
  let s = read_line () in
  let t = read_line () in
  Array.init (String.length s) (fun i -> i)
  |> Array.to_list
  |> List.exists (fun i ->
      Array.init (String.length s) (fun j -> j)
      |> Array.to_list
      |> List.for_all (fun j ->
          s.[(i + j) mod String.length s] = t.[j]))
  |> (function true -> "Yes" | false -> "No")
  |> print_endline


Measured memory_bytes: 2432
N, K = map(int, input().split())
X = list(map(int, input().split()))

answer = 10 ** 9
for i in range(N-K+1):
    b, c = X[i], X[i+K-1]
    if b * c >= 0:
        answer = min(answer, max(abs(b), abs(c)))
    else:
        d, e = min(abs(b), abs(c)), max(abs(b), abs(c))
        answer = min(answer, d*2+e)
print(answer)


Measured memory_bytes: 14224
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 21 16:49:00 2020

@author: matsui
"""

def cost(i,j):
    return abs(int(h[i])-int(h[j]))

N=int(input())
h=input().split()

dp=[0]*N
dp[1]=cost(0,1)
   
for i in range(2,N):
    dp[i]=min(cost(i,i-1)+dp[i-1],cost(i,i-2)+dp[i-2])
    
print(dp[N-1])

Measured memory_bytes: 13752
// ConsoleApplication77.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<string>
using namespace std;
int a[105];
int main()
{
	int n;
	bool lala = 1;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int aa = 0; aa < n; aa++)
	{
		if (a[aa] % 2 == 0)
		{
			if (a[aa] % 3 == 0 || a[aa] % 5 == 0)
			{
		
			}
			else
			{
				lala = 0;
				break;
			}
		}
	}
	if (lala == 1)
	{
		cout << "APPROVED\n";
	}
	else
	{
		cout << "DENIED\n";
	}
}



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

int main(){
	int a, n, i, j, z, s[78498];
	while(scanf("%d", &n) != EOF){
		if(n < 2){
			printf("0\n");
			continue;
		}
		s[0] = 2;
		a = 1;
		for(i = 3; i <= n; i += 2){
			z = 0;
			for(j = 0; s[j] * s[j] <= i; j++){
				if(i % s[j] == 0){
					z = 1;
					break;
				}
			}
			if(z == 0){
				s[a] = i;
				a++;
			}
		}
		printf("%d\n", a);
	}
	return 0;
}

Measured memory_bytes: 912
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<typeinfo>
#include<complex>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a;i < b; i++)
const long double PI = (acos(-1));

int main() {

	int n;
	cin >> n;

	vector<int> l(n);
	rep(i, 0, n) cin >> l[i];

	sort(l.begin(), l.end());
	int sum = 0;

	rep(i, 0, n - 1) sum += l[i];

	if (sum > l[n - 1]) cout << "Yes" << endl;
	else cout << "No" << endl;
 
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
		int a,b,t,ans=0;
		cin>>a>>b>>t;
		if(a>t) cout<<0<<"\n";
		else if(a == t) cout<<1<<"\n";
		else{
			while(t+0.5>a){
				t = t-a;
				ans =ans +b;
			}
					cout<<ans<<"\n";
		}

		return 0;
}

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

const int N = 1e4+5, M = 105, MOD = (int)1e9+7;
string k;
int d, dp[N][M][2];

int solve(int idx, int rem, int less){
    int &res = dp[idx][rem][less];
    if(idx == k.size())
        return rem == 0;
    if(res != -1)
        return res;
    res = 0;
    for(int i = 0; i <= ((less)? 9 : (int)(k[idx] - '0')); ++i){
        res += solve(idx + 1, (rem + i) % d, less | (k[idx] - '0') > i);
        res %= MOD;
    }
    return res;
}

int main(){
    cin >> k >> d;
    int n = k.size();
    memset(dp, -1, sizeof(dp));
    cout << (solve(0, 0, 0) - 1 + MOD) % MOD;
}


Measured memory_bytes: 9216
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

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

struct State
{
public:
	int y;
	int x;
	vector< pair< int, int > > path;
};

struct Widget
{
	int y;
	int x;
	int ny;
	int nx;
};

int main()
{
	int H, W;
	cin >> H >> W;
	int a[ H ][ W ];
	REP( i, H ) REP( j, W ) cin >> a[ i ][ j ];

	vector<Widget> V;
	REP( i, H ) REP( j, W )
	{
		int y = i;
		int x = ( i % 2 == 0 ) ? j : ( W - 1 - j );
		int ny = ( j == W - 1 ) ? y + 1 : y;
		int nx = ( j == W - 1 ) ? x : ( i % 2 == 0 ) ? x + 1 : x - 1;

		if( ny >= H ) break;

		if( a[ y ][ x ] % 2 == 1 )
		{
			--a[ y ][ x ];
			++a[ ny ][ nx ];
			Widget w;
			w.y = y;
			w.x = x;
			w.ny = ny;
			w.nx = nx;
			V.push_back( w );
		}
	}
	cout << V.size() << endl;
	for( const auto& w : V )
	{
		cout << w.y + 1 << " " << w.x + 1 << " " << w.ny + 1 << " " << w.nx + 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 5232
from sys import stdin
N = int(stdin.readline().rstrip())
nums = [int(_) for _ in stdin.readline().rstrip().split()]

def select_sort(a, n):
    count = 0
    for i in range(n):
        mini = i
        for j in range(i, n):
            if a[j] < a[mini]:
                mini = j
        if mini != i:
            count += 1
        a[i], a[mini] = a[mini], a[i]
    return a, count

ret, count = select_sort(nums, N)
print(*ret)
print(count)


Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x,long long int y) 
{ 
    long long int res = 1;     // Initialize result 
  // x=x;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x); 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x);  // Change x to x^2 
    } 
    return res; 
}
long long int power(long long int x,long long int y,long long int m) 
{ 
    long long int res = 1;     // Initialize result 
   x=x%m;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x)%m; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x)%m;  // Change x to x^2 
    } 
    return res; 
}
void primeFactors(int n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        cout << 2 << " ";  
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            cout << i << " ";  
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        cout << n << " ";  
}

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 long long int lcm(long long int a, long long int b)  
 { 
     long long int temp;
    
    return (a*b)/gcd(a, b);  
 }
 
int main() {
   
    long long int n1,m1,t;
   //cin>>t;
 t=1;
    while(t--)
    {
   long long int i,j;
 //long long int b[1000000];
 //set<long long int >s;
       long long int f=0,p=0,o=0;
       double pie=3.141592653589793238;
    long long int c=0,n,m=0,l=0,r=0,k=0,min1=10000000000000,max2=0,ans=0;
      map<long long int,long long int>mp,mp1;
 cin>>n;
 if(n<=599)
 cout<<8;
 else if(n<=799)
 cout<<7;
 else if(n<=999)
 cout<<6;
 else if(n<=1199)
 cout<<5;
 else if(n<=1399)
 cout<<4;
 else if(n<=1599)
 cout<<3;
 
 else if(n<=1799)
 cout<<2;
 else if(n<=1999)
 cout<<1;
 /*long long int a[n];
 for(i=0;i<n;i++)
 cin>>a[i];
 */
 
    }
 return 0;
}


Measured memory_bytes: 3620
n = int(input())

last = [0,0,0]
for i in range(n):
    new = list(map(int, input().split()))
    newDp = [0,0,0]
    for j in range(3):
        for k in range(3):
            if j!=k:
                newDp[j] = max(newDp[j], last[k]+new[k])
    last = newDp
print(max(last))





Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "NO" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N,K;
    int p[214514];
    int M=-INF,now=0;
    cin >> N >> K;
    REP(i,N){
        cin >> p[i];
    }
    REP(i,K){
        now+=p[i];
    }
    M=max(M,now);
    for(int i=0;i+K<N;i++){
        now-=p[i];
        now+=p[i+K];
        M=max(M,now);
    }
    double Ans=((double)M+K)/2.0;
    printf("%.8f\n",Ans);
    return 0;
}



Measured memory_bytes: 1792
# coding: utf-8
# Your code here!

il = list(input().split())

X = int(il[0])
Y = int(il[1])

count = len(il)


ans = 0
for i in range(count):
    
    
    if X < Y:
        ans += Y
        if 0 < Y:
            Y -= 1
    else:
        ans += X
        if 0 < X:
            X -= 1
        
    
    
print(ans)

Measured memory_bytes: 3060
/**
 * B - Battle
 * https://atcoder.jp/contests/abc164/tasks/abc164_b
 */
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    // 高橋君と青木君がモンスターを闘わせます。
    // 高橋君のモンスターは体力が A で攻撃力が B です。
    // 青木君のモンスターは体力が C で攻撃力が D です
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    
    // 高橋君→青木君→高橋君→青木君→... の順に攻撃を行います。
    for (int i = 0; i < 100; i++) {
        // 高橋くんの攻撃
        C -= B;
        // 高橋君が勝つなら Yes、負けるなら No を出力せよ。
        if (C <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        // 青木くんの攻撃
        A -= D;
        if (A <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }
}
 

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

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];
    ll ans = 0;
    for(ll l = 0; l < k + 1; l++){
        for(ll r = 0; r < k - l + 1; r++){
            if(l + r > n) continue;
            vector<ll> s = {};
            ll memo = 0;
            rep(i, l){
                memo += v[i];
                s.push_back(v[i]);
            }
            rep(i,r){
                memo += v[n - i - 1];
                s.push_back(v[n - i - 1]);
            }
            sort(s.begin(), s.end());
            rep(i, k - l - r){
                if(i >= s.size()) break;
                if(s[i] > 0) break;
                memo -= s[i];
            }
            ans = max(ans, memo);
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<int>;
using P = pair<int,int>;


int main()
{
    int n,h,sum=0;cin >>h>>n;
    rep(i,n){
        int a;cin >>a;
        sum+=a;
    }
    if(sum>=h)puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
import math

def culcD(a,b):
  x1,y1,r1=a
  x2,y2,r2=b
  return max(0,math.sqrt((x1-x2)**2+(y1-y2)**2)-(r1+r2))

A=[]

xs,ys,xg,yg=map(int,input().split())
A.append((xs,ys,0))
A.append((xg,yg,0))

V=defaultdict(int)
V[(0,1)]=(culcD(A[0],A[1]))
V[(1,0)]=(culcD(A[0],A[1]))

N=int(input())
for i in range(N):
  x,y,r=map(int,input().split())
  A.append((x,y,r))
  for j in range(len(A)-1):
    dist = culcD(A[j],A[-1])
    V[(i+2,j)]=dist
    V[(j,i+2)]=dist

def dijkstra(n):
  d=[float('inf')]*(n+2)
  d[0]=0
  used=[False]*(n+2)
  
  while True:
    v=-1
    for i in range(n+2):
      if used[i]==False and (v==-1 or d[i] < d[v]):
        v=i
    if v==-1:
      break
    used[v]=True
    for j in range(n+2):
      d[j]=min(d[j],d[v]+V[(j,v)])

  return d[1]

print(dijkstra(N))


Measured memory_bytes: 147444
(N, Y) = STDIN.gets.split(' ').map(&:to_i)

def search(n, yen)
    n.downto(0) do |x|
        yn = n - x
        yn.downto(0) do |y|
            z = yn - y
            if 10000*x + 5000*y + 1000*z == yen then
                return [x, y, z]
            end
        end
    end

    [-1, -1, -1]
end

puts search(N, Y).join(' ')


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

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int n;
	cin >> n;
	int maxi = INT_MIN;
	int svi;
	for(int i=1; i<=n; i++) {
		int tmp = 0, a = i;
		while(a % 2 == 0) {
			tmp++;
			a/=2;
		}
		if (tmp > maxi) maxi = tmp, svi = i;
	}
	cout << svi << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }

        for (int j = 0; j < N - K; j++) {
            int before = A[j];
            int after = A[j + K];
            if (before < after) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}


Measured memory_bytes: 52180
def count(l):
    res = {}
    for d in l:
        if d in res:
            res[d] += 1
        else:
            res[d] = 1
    return res

n = int(input())
string = input()
cnt = count(string)
mod = 10**9 + 7
ans = 1
for v in cnt.values():
    ans *= v + 1
    ans %= mod 
print(ans - 1)


Measured memory_bytes: 9116
n = gets.to_i
s = gets.chomp
i = 0
j = s.length-1
ans = 0
while i <= j
  if s[i] == "W" && s[j] == "R"
    s[i],s[j] = s[j],s[i]
    ans += 1
    i += 1
    j -= 1
  elsif s[i] == "R"
    i += 1
  elsif s[j] == "W"
    j -= 1
  end
end
puts ans

Measured memory_bytes: 14544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    unsigned long long a, b, k;
    cin >> a >> b >> k;
    if ((a+b) < k){
        cout << 0 << " " << 0 << endl;
    }else{
        if(a<k){
            cout << 0 << " " << (b-(k-a)) << endl;
        }else{
            cout << a-k << " " << b << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<cstring>

using namespace std;

#ifdef LDEBUG
#define debug(x) cout << #x << ":" << x << endl
#else
#define debug(...)
#endif

#define REP(i,n) for(int i=0; i<n; ++i)

typedef unsigned long long u64;
typedef long long i64;

int a,b,c,d,e;

int r(int k){
        debug(k);
        if (k%10 == 0)
                return k;

        return k + (10 - (k%10));
}

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

        cin >> a >> b >> c >> d >> e;

        int m = 1000;
        if (a%10 != 0 && (m == 1000 ? 1 : a%10 < m%10)) {
                debug(a);
                m = a;
        }
        if (b%10 != 0 && (m == 1000 ? 1 : b%10 < m%10)) {
                debug(b);
                m = b;
        }
        if (c%10 != 0 && (m == 1000 ? 1 : c%10 < m%10)) {
                debug(c);
                m = c;
        }
        if (d%10 != 0 && (m == 1000 ? 1 : d%10 < m%10)) {
                debug(d);
                m = d;
        }
        if (e%10 != 0 && (m == 1000 ? 1 : e%10 < m%10)) {
                debug(e);
                m = e;
        }


        if (m == 1000) {
                cout << a + b + c + d + e << endl;
        } else {
                int p = r(a) + r(b) + r(c) + r(d) + r(e);
                p -= r(m);
                p += m;
                cout << p << endl;
        }


        return 0;
}


Measured memory_bytes: 256
using System;
using static System.Console;
using System.Linq;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
          long N = long.Parse(ReadLine());
          string stone = ReadLine();
          var Rtotal = stone.Count(x => x == 'R');
          var Stone = stone.Substring(0, Rtotal);
          var cnt = Stone.Count(x => x == 'W');
          WriteLine(cnt);
      }
   }
}

Measured memory_bytes: 28656
(v=>{
    const gcd = (arr) =>{
        const f = (a,b) => b ? f(b, a % b): a 
        let ans = arr[0]
        for(let i = 1;i<arr.length;i++){
            ans = f(ans, arr[i])
        }
        return ans
    }
    const k = ~~v
    let s = 0
    for(let i = 1;i<=k;i++){
        for(let j = 1;j<=k;j++){
            for(let jj = 1;jj<=k;jj++){
                s += gcd([i, j, jj])
            }
        }
    }
    console.log(s)
})(require("fs").readFileSync("/dev/stdin", "utf8"))

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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;

int arr[maxn];
bool v[maxn];

pair < int , int > get(int m, int d){

    int tot=m+1;
    int val=m;
    int i=0;
    while(i<=val){
        if(abs(val-i)==d){
            return {i,val};
        }
        i++;
        val--;
    }
    return {-1, -1};
}

int main() {
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin>> n;

    f0(i,n){
        cin >> arr[i];
    }

    int m=n-1;
    int start=1;
    bool ok=1;
    f0(i,n){
        pair < int , int > a;
        a= get(m,arr[i]);

        int f=a.ff;
        int e=a.ss;

        if(f==-1 && e==-1){
            ok=0;
            break;
        }
        if(!v[f]){
            v[f]=start;
        }else if(!v[e]) {
            v[e]=start;
        }else {
            ok =0;
            break;
        }
    }

    if(!ok){
        cout <<"0"<< endl;
    }else {
        int cnt=0;
        int a[n+1]={0};
        f0(i,n){
            a[arr[i]]++;
        }

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

        ll ans = 1LL;
        for(int i=1 ; i<=cnt ; i++){
            ans = ((ans % MOD)*2)%MOD;
        }
        cout << ans << endl;

    }

    return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int a[200005];
int main()
{
	int n;
	cin>>n;
	int u;
	for(int i=1;i<n;i++)
	{
		cin>>u;
		a[u]++;
	}
	for(int i=1;i<=n;i++)
		cout<<a[i]<<"\n";
	return 0;
}

Measured memory_bytes: 4308
#include <bits/stdc++.h>
#include <cstdlib>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
    long long n, a, b;
    long long ans = 0;
    cin >> n >> a >> b;
    if (a == 0) {
        cout << ans << endl;
        return 0;
    }
    long long p = n / (a + b);
    long long r = n % (a + b);
    ans += a * p;
    if (a <= r) {
        ans += a;
    } else {
        ans += r;
    }
    cout << ans << 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);
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    if (a * b % 2 == 0) {
      System.out.println("Even");
    } else {
      System.out.println("Odd");
    }
  }
}

Measured memory_bytes: 21716
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var nm = ReadIntArray();
            var n = nm[0];
            var m = nm[1];
            var routes = new bool[n, n];
            for (int i = 0; i < m; i++)
            {
                var ab = ReadIntArray();
                var a = ab[0] - 1;
                var b = ab[1] - 1;
                routes[a, b] = true;
                routes[b, a] = true;
            }
            var isPassed = Enumerable.Repeat(false, n).ToArray();
            isPassed[0] = true;
            Console.WriteLine(CountRoute(isPassed, 0, routes));
        }

        private static int CountRoute(bool[] isPassed, int current, bool[,] routes)
        {
            var count = 0;
            for (int i = 0; i < isPassed.Length; i++)
            {
                if (!isPassed[i] && routes[current, i])
                {
                    isPassed[i] = true;
                    if (isPassed.All(v => v))
                    {
                        isPassed[i] = false;
                        return 1;
                    }
                    else
                    {
                        count += CountRoute(isPassed, i, routes);
                        isPassed[i] = false;
                    }

                }
            }
            return count;
        }
    }

    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }
}


Measured memory_bytes: 13396
def divisor(n):
  ass=[]
  for i in range(1,int(n**0.5)+1):
    if n%i==0:
      ass.append(i)
      if i!=n//i:ass.append(n//i)
  return ass
n,m=map(int,input().split())
d=divisor(m)
d.sort(reverse=1)
for i in d:
  if m//i>=n:print(i);exit()

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

double eps = 1e-10;

class Point {
public:
	double x, y;
	
	Point(double x = 0, double y = 0) : x(x), y(y) {}
	
	Point operator + (const Point& p) {
		return Point(x + p.x, y + p.y);
	}
	Point operator - (const Point& p) {
		return Point(x - p.x, y - p.y);
	}
	Point operator * (const double& a) {
		return Point(x * a, y * a);
	}
	Point operator / (const double& a) {
		return Point(x / a, y / a);
	}
	
	bool operator < (const Point& p) const {
		return x != p.x ? x < p.x : y < p.y;
	}
	bool operator == (const Point &p) const {
		return fabs(x - p.x) < eps && fabs(y - p.y) < eps;
	}
	
	double abs() {
		return sqrt(norm());
	}
	double norm() {
		return x * x + y * y;
	}
	
};

typedef Point Vector;

bool equals(const double& a, const double& b) {
	return fabs(a - b) < eps;
}

double dot(const Vector& a, const Vector& b){
	return a.x * b.x + a.y * b.y;	
}

double cross(const Vector& a, const Vector& b){
	return a.x * b.y - a.y * b.x;
}

int main() {
	double x1, x2, x3, y1, y2, y3, px, py;
	while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> px >> py){
		Vector va = Vector(x2 - x1, y2 - y1);
		Vector vb = Vector(x3 - x2, y3 - y2);
		Vector vc = Vector(x1 - x3, y1 - y3);
		Vector v1 = Vector(px - x1, py - y1);
		Vector v2 = Vector(px - x2, py - y2);
		Vector v3 = Vector(px - x3, py - y3);
		double c1 = cross(va, v2);
		double c2 = cross(vb, v3);
		double c3 = cross(vc, v1);
		if((c1 > eps && c2 > eps && c3 > eps) || (c1 < eps && c2 < eps && c3 < eps))
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
		
	}
	return 0;
}

Measured memory_bytes: 1224
#template
def inputlist(): return [int(j) for j in input().split()]
#template

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

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

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

        if x == y:
            return

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

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

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

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

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

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

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}


N,M = inputlist()
uf = UnionFind(N+1)
for i in range(M):
    A,B = inputlist()
    uf.union(A,B)

ans = 0
for i in range(N+1):
    ans = max(ans,uf.size(i))
print(ans)

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

int main()
{
    ll n,T=1,A=1,t,a,ans,x,y,r;
    cin>>n;
    while(n--)
    {
        cin>>t>>a;
        x=(T+t-1)/t;
        y=(A+a-1)/a;
        r=max(x,y);
        T=t*r;
        A=a*r;
    }
    ans=A+T;
    cout<<ans;
    return 0;
}



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

using namespace std;

typedef long long ll;

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

	int a, b;
	cin >> a >> b;

	if(a % 3 == 0){
		cout << "Possible" << endl;
	}else if(b % 3 == 0){
		cout << "Possible" << endl;
	}else if((a + b) % 3 == 0){
		cout << "Possible" << endl;
	}else{
		cout << "Impossible" << endl;
	}
}


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

#define FOR(i,N) for(int i=0;i<N;i++)

int main(){
    long long N,K,X,T,X1,X2,ans=0,keep1,keep2;
    cin >> N;
    vector<long>A(N);
    FOR(i,N)cin >> A[i];
    for(int i=1;i<N;i++){
        if(A[i-1]-A[i]>0){
            ans += A[i-1]-A[i];
            A[i] += A[i-1]-A[i];
        }
    }
    cout << ans;
}

Measured memory_bytes: 4836
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define dump(x)  cout << #x << " = " << (x) << endl;

#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
//             0123456789 - digits. check the limits, int vs long
const int MX = 100001;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(0);
    cout << std::fixed;
    // freopen("ex.in","r",stdin);
    // freopen("ex.out","w",stdout);
    int n, m;
    cin >> n >> m;
    vpi a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].second >> a[i].first;
    }
    sort(a.begin(), a.end());

    int ans = 0;
    set<int> days;
    for (int i = 0; i < m; i++) {
        days.insert(i);
    }
    for (int i = n - 1; i > -1; i--) {
        if (days.empty()) break;
        int latestDay = m - a[i].second;
        // dump(latestDay);
        auto itLow = days.lower_bound(latestDay);
        if (*itLow != latestDay) {
            if (itLow == days.begin())
                continue;
            itLow--;
        } 
        // cout << "Current : " <<a[i].second << " - " << a[i].first << " set loc: " << *itLow << "\n";
        ans += a[i].first;
        days.erase(itLow);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 5760
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int W = sc.nextInt();
        int v[] = new int[n];
        int w[] = new int[n];
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
        }
        long dp[][] = new long[n + 1][W + 1];
        for (long i[] : dp) {
            Arrays.fill(i, -1);
        }
    
        long ans = knapsack(n, v, w, W,dp);
    
        System.out.println(ans);
    }

    private static long knapsack(int n, int[] v, int[] w, int w2, long[][] dp) {
        if (w2 == 0 || n==0)
            return 0;
        if(dp[n][w2] != -1)
            return dp[n][w2];    
        if (w[n-1] <= w2)
            return dp[n][w2] = Math.max(v[n-1] + knapsack(n-1, v, w, w2-w[n-1], dp), knapsack(n-1, v, w, w2, dp));

        return dp[n][w2] = knapsack(n-1, v, w, w2,dp);
    }

    private static long knapsack_brute(int i, long sum, int[] v, int[] w, int w2) {
        if (w2 < 0)
            return 0;
        if (i == v.length || w2 == 0)
            return sum;

        return Math.max(knapsack_brute(i + 1, sum + v[i], v, w, w2 - w[i]), knapsack_brute(i + 1, sum, v, w, w2));
    }

    static final Random random = new Random();

    static void sort(int[] a) {
        int n = a.length;
        for (int i = 0; i < n; i++) {
            int val = random.nextInt(n);
            int cur = a[i];
            a[i] = a[val];
            a[val] = cur;
        }
        Arrays.sort(a);
    }

    static void sortl(long[] a) {
        int n = a.length;
        for (int i = 0; i < n; i++) {
            int val = random.nextInt(n);
            long cur = a[i];
            a[i] = a[val];
            a[val] = cur;
        }
        Arrays.sort(a);
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

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

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

}


Measured memory_bytes: 139216
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a;cin>>a;a++;
  cout<<a%2<<endl;
  return 0;
}


Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
int main(){
  char a[200010];
  cin >> a;
  int n=strlen(a);
  int sum=0;
  for(int i=0;i<n;++i){
    sum+=a[i]-'0';
  }
  if(sum%9==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

    
  


Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int main() {
    int N, K, d; cin >> N >> K;
    map<int, int> m;
    int a;
    rep(i, K) {
        cin >> d;
        rep(j, d) {
            cin >> a;
            m[a - 1] = 1;
        }
    }
    int ans = 0;
    rep(i, N) {
        if (m[i] == 0) ans++;
    }
    cout << ans << endl;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> prime;
    vector<bool> is_prime(55556,true);
    is_prime[0]=is_prime[1]=false;
    int p=0;
    for (int i=2;i<=55555;i++){
        if (is_prime[i]){
            if (i%5==2){
                p++;
                prime.push_back(i);
                if (p==N){
                    break;
                }
            }
            for (int j=i;j<=55556;j+=i){
                is_prime[j]=false;
            }
        }
    }
    rep(i,p){
        cout << prime[i];
        if (i!=p-1){
            cout << ' ';
        }
        else {
            cout << endl;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1<<28
#define MAX 200005
#define PI 2*acos(0.0)
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d\n", a)
#define pfl(a) printf("%lld\n", a)
#define Case(t) printf("Case %d: ", t)
#define pii pair<int, int>
#define MOD 1000000007

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    string s;
    cin>>s;
    int pin = 0;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i]=='x')
        {
            pin++;
        }
    }
    if(pin>7)
        cout<<"NO"<<endl;
    else
        cout<<"YES"<<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);
      int w = sc.nextInt();
      int h = sc.nextInt();
      int x = sc.nextInt();
      int y = sc.nextInt();
      System.out.println((double)w*h/2);
      if(x*2==w&&y*2==h)System.out.println(1);
      else System.out.println(0);
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
using namespace std;
int n, a[200000], b[200000], bit[262145];
void add(int i, int x) {
	while (i <= n) bit[i] += x, i += i & -i;
}
int sum(int i) {
	int ret = 0;
	while (i > 0) ret += bit[i], i -= i & -i;
	return ret;
}
int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]), b[i] = a[i];
	sort(b, b + n);
	long long ret = 0;
	for(int i = 0; i < n; i++) {
		int ptr = lower_bound(b, b + n, a[i]) - b; add(ptr + 1, 1);
 		ret += sum(n) - sum(ptr + 1);
	}
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 5612
s = input().split()
kane = int()
if int(s[0]) == 1:
  kane = kane + 300000
elif int(s[0]) == 2:
  kane = kane + 200000
elif int(s[0]) == 3:
  kane = kane + 100000
else:
  pass

if int(s[1]) == 1:
  kane = kane + 300000
elif int(s[1]) == 2:
  kane = kane + 200000
elif int(s[1]) == 3:
  kane = kane + 100000
else:
  pass
  
if int(s[0]) + int(s[1]) == 2:
  kane = 1000000

print(kane)

Measured memory_bytes: 9028
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int primes[60] = {
        11 ,31 ,41 ,61 ,71 ,101 ,131 ,151 ,181 ,191 ,211 ,241 ,251 ,271 ,281 ,311 ,331 ,401 ,421 ,431 ,461 ,491 ,521 ,541 ,571 ,601 ,631 ,641 ,661 ,691 ,701 ,751 ,761 ,811 ,821 ,881 ,911 ,941 ,971 ,991 ,1021 ,1031 ,1051 ,1061 ,1091 ,1151 ,1171 ,1181 ,1201 ,1231 ,1291 ,1301 ,1321 ,1361 ,1381 ,1451 ,1471 ,1481 ,1511 ,1531
    };
    int n; cin>>n;
    for(int i=0;i<n;i++){
        cout<<primes[i]<<' ';
    }
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt(), K = sc.nextInt();
        Susi[] susi = new Susi[N];
        for (int n = 0; n < N; n++) susi[n] = new Susi(sc.nextInt(), sc.nextLong());
        Arrays.sort(susi, Comparator.reverseOrder());
        PriorityQueue<Susi> used = new PriorityQueue<>();
        PriorityQueue<Susi> rem = new PriorityQueue<>((s1, s2) -> -Long.compare(s1.priority, s2.priority));
        Map<Integer, Integer> map = new HashMap<>();
        long max = 0;
        long[] f = new long[N];
        for (int i = 0; i < K; i++) {
            used.add(susi[i]);
            if (map.containsKey(susi[i].t)) {
                int x = map.get(susi[i].t);
                map.put(susi[i].t, x + 1);
            } else {
                map.put(susi[i].t, 1);
            }
            max += susi[i].d;
            f[i] = max + (long)map.size() * (long)map.size();
        }
        for (int i = K; i < N; i++) rem.add(susi[i]);
        int c = 0;
    outside:
        while (used.size() > 0) {
            Susi s = used.poll();
            if (map.get(s.t) > 1) {
                while (rem.size() > 0) {
                    Susi u = rem.poll();
                    if (!map.containsKey(u.t)) {
                        max += u.d - s.d;
                        map.put(u.t, 1);
                        f[K + c] = max + (long)map.size() * (long)map.size();
                        c++;
                        continue outside;
                    }
                }
            }
        }
        max = f[K - 1];
        for (int i = K; i < N; i++) {
            max = f[i] > max ? f[i] : max;
        }
        System.out.println(max);
        sc.close();
    }
}
class Susi implements Comparable<Susi> {
    int t;
    long d;
    long priority;
    Susi(int t, long d) {
        this.t = t;
        this.d = d;
        priority = d;
    }
    @Override
    public int compareTo(Susi other) {
        return Long.compare(priority, other.priority);
    }
    @Override
    public int hashCode() {
        int prime = 31;
        int result = 1;
        result = prime * result + t;
        result = prime * result + (int)(d ^ (d >>> 32));
        return result;
    }
    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Susi other = (Susi)obj;
        return t == other.t && d == other.d;
    }
}


Measured memory_bytes: 97196