akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <queue>
#include <map>
using namespace std;

constexpr int n = 4;
const int n2 = n*n;

int MDT[n2][n2];

struct Puzzle{
public:
  int f[n2], space, MD;
  int cost;

  bool operator < (const Puzzle& p) const{
    for(int i=0; i<n2; i++){
      if(f[i] == p.f[i]) continue;
      return f[i] < p.f[i];
    }

    return false;
  }

  int getAllMD(){
    int sum = 0;
    for(int i=0; i<n2; i++){
      if(f[i] == n2) continue;
      sum += MDT[f[i]-1][i];
    }
    return sum;
  }
};

struct State{
public:
  vector<State> solve;
  Puzzle puzzle;
  int estimated;

  void print(){
    for(int i=0; i<n2; i++){
      cout << ((puzzle.f[i] == n2)? 0: puzzle.f[i]) << " ";
      if(i%n == n-1) cout << endl;
    }
  }

  bool operator < (const State& s) const{
    return estimated < s.estimated;
  }

  bool operator > (const State& s) const{
    return estimated > s.estimated;
  }
};

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

int dfs(int limit, int cnt, State s, int before){
  if(cnt == 0){
    if(s.puzzle.MD == 0) return s.puzzle.cost;
    else return -1;
  }

  int sx = s.puzzle.space / n, sy = s.puzzle.space % n;

  for(int i=0; i<4; i++){
    int nx = sx + dx[i], ny = sy + dy[i];
    if(nx < 0 || nx >= n || ny < 0 || ny >= n || before+i == 3) continue;

    Puzzle np = s.puzzle;
    np.MD -= MDT[nx * n + ny][np.f[nx * n + ny] -1];
    np.MD += MDT[sx * n + sy][np.f[nx * n + ny] -1];

    swap(np.f[nx * n + ny], np.f[sx * n + sy]);
    np.cost++;
    np.space = nx * n + ny;

    State next;
    next.puzzle = np;
    next.estimated = np.MD + np.cost;

    /*
    cout << "---------------" << endl;
    cout << "limit = " << limit << " ";
    cout << "cnt = " << cnt << " ";
    cout << "f(x) = " << next.estimated << endl;
    next.print();
    */

    if(next.estimated > limit) continue;

    int tmp = dfs(limit, cnt-1, next, i);
    if(tmp != -1) return tmp;
  }
  return -1;
}

int IDA(Puzzle in){
  constexpr int MAX = 100;

  State s;
  s.puzzle = in;
  s.puzzle.cost = 0;
  s.puzzle.MD = s.estimated = in.getAllMD();

  for(int i=s.estimated; i<=MAX; i++){
    int ans = dfs(i, i, s, -10);
    if(ans != -1){
      return ans;
    }
  }
  return -1;
}

int main(){
  for(int i=0; i<n2; i++){
    for(int j=0; j<n2; j++){
      MDT[i][j] = abs(i/n - j/n) + abs(i%n - j%n);
    }
  }

  Puzzle in;
  for(int i=0; i<n2; i++){
    cin >> in.f[i];
    if(in.f[i] == 0){
      in.space = i;
      in.f[i] = n2;
    }
  }

  cout << IDA(in) << endl;

  return 0;
}



Measured memory_bytes: 3116
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            long N = sc.nextLong();

            if (N % 2 == 1) {
                System.out.println(0);
                return;
            }

            long[] x = new long[26];
            x[0] = 10;
            for (int i = 1; i < 26; i++) {
                x[i] = x[i - 1] * 5;
            }

            long c = 0;
            for (int i = 0; i < 26; i++) {
                c += N / x[i];
            }

            System.out.println(c);
        }
    }

}


Measured memory_bytes: 21844
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	a := readInt()
	b := readInt()
	c := readInt()
	fmt.Println(minList([]int{a + b, b + c, c + a}))
}

func minList(l []int) int {
	var min = math.MaxInt64
	for _, n := range l {
		if min > n {
			min = n
		}
	}
	return min
}

func read() string {
	sc.Scan()
	return sc.Text()
}

func readInt() int {
	i, e := strconv.Atoi(read())
	if e != nil {
		panic(e)
	}
	return i
}


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

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  if(a.at(a.size()-1)==b.at(0) && b.at(b.size()-1)==c.at(0)){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << (H - h) * (W - w) << endl;
}

Measured memory_bytes: 256
import sys
n=int(input())
a=input()
a0=a.split()
l=list()
b=1
q= "0" in a0
if q==True:
    print(0)
    sys.exit()
for i in range (n):
    a1=int(a0[i])
    b=b*a1
    if b>10**18:
        print(-1)
        sys.exit()
print(b)

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

using namespace std;

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

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

int main(void) {
  int i,j;
  string s;
  cin>>s;
  int n=0,m=0,l=0;
  rep(i,s.size())
    if('0'<=s[i]&&s[i]<='9')n++;
    else if('a'<=s[i]&&s[i]<='z')m++;
    else if('A'<=s[i]&&s[i]<='Z')l++;
  if(s.size()>=6&&n&&m&&l)cout<<"VALID"<<endl;
  else cout<<"INVALID"<<endl;
}

Measured memory_bytes: 3228
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<math.h>
#define INFINI 100000001
int gcd(int a,int b)
{
    if(b==0)return a;
    else return (b,a%b);

}
int  compareint(const void *a,const void *b)
{

    return *(int*)(a)-*(int*)(b);

}



int main(){

int x,a,b;
scanf("%d %d %d",&x,&a,&b);


printf("%c",(abs(x-a)<abs(x-b))?'A':'B');


}


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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int N, M; cin >> N >> M;
	vector<string> A(N), B(M);
	string ans = "No";
	for(int i = 0; i < N; i++) cin >> A[i];
	for(int i = 0; i < M; i++) cin >> B[i];
	if(A == B) ans = "Yes";
	else {
		for(int i = 0; i <= N - M; i++) {
			for(int j = 0; j <= N - M; j++) {
			vector<string> Apart(M);
			for(int k = 0; k < M; k++) Apart[k] = A[i + k].substr(j, M);
			if(Apart == B) ans = "Yes";
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3608
n = gets.to_i

m = 0
cnt = 0
n.times do
  a, b = gets.chomp.split.map(&:to_i)
  if a == b
    cnt += 1
  else
    cnt = 0
  end
  m = [m, cnt].max
end

if m >= 3
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 14384
#include <stdio.h>

int main(void) {
  int A, B, C;
  scanf("%d%d%d",&A,&B,&C);

  if(A==B){
   printf("%d",C);
  }
  else if(B==C){
   printf("%d",A);
  }
  else if(A==C){
   printf("%d",B);
  }
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<stack>
#include<string.h>
#include<string>
using namespace std;
typedef long long LL;

#define _CRT_SECURE_NO_WARNINGS
int N; 
vector<int> l[100010];
template <class T> class Node {
public:
	Node()
		:parent(0), child(0)
	{};
	Node* parent;
	vector<Node*> child;
	T para;
};
Node<int> nodes[100010];
int main() {
	scanf("%d",&N);
	for (int i = 0; i < N-1; i++) {
		int a, b;
		scanf("%d %d",&a,&b);
		l[a].push_back(b);
		l[b].push_back(a);
	}

	nodes[1].para = 0;
	stack<int> s; s.push(1);
	while (!s.empty()) {
		int n = s.top();
		s.pop();
		for (int i = 0; i < l[n].size();i++) {
			if (nodes[n].parent != &nodes[l[n][i]]) {
				nodes[n].child.push_back(&nodes[l[n][i]]);
				nodes[l[n][i]].parent = &nodes[n];
				nodes[l[n][i]].para = nodes[n].para+1;
				s.push(l[n][i]);
			}
		}
	}

	Node<int>* a = &nodes[N];
	for (int i = 0; i < (nodes[N].para - 1) / 2;i++) {
		a = a->parent;
	}
	int c = 1;
	stack<Node<int>*> ss; ss.push(a);
	while (!ss.empty()) {
		Node<int>* n = ss.top(); ss.pop();
		if (n->child.size() != 0) {
			for (int i = 0; i < n->child.size(); i++) {
				c++;
				ss.push(n->child[i]);
			}
		}
	}

	if (c>=N-c) {
		printf("Snuke\n");
	}
	else {
		printf("Fennec\n");
	}
	return 0;
}

Measured memory_bytes: 12800
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int h, w;
    int i, j;
    while(1){
        scanf("%d %d", &h, &w);
        if(h == 0 && w == 0) break;
        for(i=0; i<h; i++){
            for(j=0; j<w; j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 572
/*..............................................*\
Author:Kishor Kumar Paroi
Dept:CSE-1703053
email.kishor.josephite@gmail.com
RUET,BANGLADESH
\*---------------------------*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <sstream>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include<bits/stdc++.h>
#include<iostream>
#include<iterator>

#define max(a,b) ((a>b)?a:b)                        //finding max
#define min(a,b) ((a<b)?a:b)                        //finding min
#define Max(a,b,c) max(a,max(b,c))                  //finding max between 3 numbers
#define Min(a,b,c) min(a,min(b,c))                  //finding min between 3 numbers
#define Pi acos(-1.0)                               //defining Pi for mathematical uses
#define Clear(a) memset(a,0,sizeof(a))              //clearing memory of an array
#define setfalse(a) memset(a,false,sizeof(a))       //setting the array into false
#define settrue(a) memset(a,true,sizeof(a))         //setting the array into true
#define clrstr(a) memset(a,'\0',sizeof(a))          //setting string array to null
#define open freopen("input.txt","r",stdin)         //opening input file
#define close freopen ("output.txt","w",stdout)     //opening output file
#define Case(a) printf("Case %d: ",a)               //printing case number
#define caseh(a) printf("Case #%d: ",a)             //printing case number having '#'
#define getcase(a) scanf("%d",&a)                   //scanning case number
#define caseloop(a,b) for(a=1;a<=b;a++)             //making case loop
#define EPS 1e-9                                    //small value for avoiding preccesion error
#define LL long long                                //long long short form
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vi vector<int>v
//const int N=100*1000;
//const int mod=1e9+7;

//# define int min3(int a,int b,int c){return min(a,min(b,c));}
//#define int max3(int a,int b,int c){return max(a,max(b,c));}
//#define int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
//#define int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
     int n;
     cin>>n;
     vi;
     while(n--)
     {
         int num;
         cin>>num;
         v.push_back(num);
     }
     sort(v.begin(),v.end());
     int s=0;
     for(vector<int>::iterator it=v.begin();it!=v.end();it++)
     {
         //cout<<*it<< " ";
         if(it==v.end()-1)
         s+=*it/2;
         else
            s+=*it;
     }
    // cout<<endl;
     cout<<s<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int x,n; cin>>x>>n;
	set<int> s;
	rep(i,0,n){
		int a; cin>>a;
		s.insert(a);
	}
	int ans=MOD;
	rep(i,0,200){
		int a=x+i;
		int b=x-i;
		if(!s.count(b)){
			ans=b;
			break;
		}
		if(!s.count(a)){
			ans=a;
			break;
		}
	}
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 3636
/**
 *    author:  tourist
 *    created: 26.11.2019 03:28:43       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long h, w;
  cin >> h >> w;
  cout << abs((h - 2) * (w - 2)) << '\n';
  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())

ans = [-1] * n

for _ in range(m):
    s, c = map(int, input().split())
    if ans[s - 1] == -1:
        ans[s - 1] = c
    elif ans[s - 1] != -1 and ans[s - 1] != c:
        print(-1)
        exit()

if n != 1 and ans[0] == 0:
    print(-1)
    exit()

if n != 1 and ans[0] == -1:
    ans[0] = 1

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

print(''.join(map(str, ans)))


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

int tmp[] = {6000,4000,3000,2000};

int main(){
  int a,b;
  for(int i = 0;i < 4;i++){
    cin >> a >> b;
    cout << tmp[a-1] * b << endl;
  }

  return 0;
}





Measured memory_bytes: 3108
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
#define srep(i, j, k) for (int i = j; i < k; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using ull = unsigned long long;

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

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

const int INF = 1001001001;

//mint�p�̒萔 (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h[i];

    vector<int> dp(n, INF);
    dp[0] = 0;
    srep(i, 1, n) {
        srep(j, 1, k + 1) 
            if (i >= j) chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
    }

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

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

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

int main(){
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  double t;
  t = H*60 + M;
  double wt = 11*t*3.1415926535897932384626433832795028841971 /360;
  double coswt = cos(wt);
  double cc = - coswt*2*A*B + A*A + B*B;
  
  cout << fixed << setprecision(20);
  cout << sqrt(cc) << endl;
  
 return 0;
  
}

Measured memory_bytes: 4188
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	cout << 800 * n - 200 * (n / 15) << endl;
	return 0;
}

Measured memory_bytes: 256
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def ris(): return list(input())
def pli(a): return "".join(list(map(str, a)))

n,k = rli()
A = rli()

def gcd(a,b):
    while b:
        a, b = b, a%b
    return a

b = 0
for a in A:
    b  = gcd(a, b)

if k%b or k > max(A):
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// ここに処理を記述

    #define int ll

    int N;
    cin >> N;

    vector<ll> A, B, C;
    int temp = 0;
    for(int i=0; i<N; i++){
        cin >> temp;
        A.emplace_back(temp);
    }
    REP(i, N){
        cin >> temp;
        B.eb(temp);
    }
    REP(i, N){
        cin >> temp;
        C.eb(temp);
    }
    sort(A.begin(), A.end());   // 必須
    sort(B.begin(), B.end());   // 必須ではない
    sort(C.begin(), C.end());   // 必須

    int ans = 0;
    // ポイント : Aで探索すると O(N^2 logN) しかできないので
    // Bで探索し O(NlogN)で処理
    REP(i,B.size()){
        auto ok_a = lower_bound(A.begin(), A.end(), B[i]);
        // Bより小さいものはlower_boundのひとつ前
        int num_a = (int)(ok_a - A.begin());
        
        // upper_boundは a > bを調べる(lower_boundはa >= b)
        auto ok_c = upper_bound(C.begin(), C.end(), B[i]);
        int num_c = (int)(C.end() - ok_c);

        ans += num_a * num_c;
    }

    cout << ans << "\n";

return 0;
}

Measured memory_bytes: 3316
using System;
using System.Collections.Generic;
using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] AB = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            Console.WriteLine(AB[0]*AB[1]-(AB[0]+AB[1]-1));
        }   
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 11092
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w;
        while (true){
          int x = sc.nextInt();
          int y = sc.nextInt();
          if ( (x == 0) && (y == 0)) break;
          if ( x > y ){
            w = x;
            x = y;
            y = w;
          }
          System.out.println( x + " " + y );
        }
      }
    }


Measured memory_bytes: 35428
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long w,h,x,y;
	cin>>w>>h>>x>>y;
	cout<<(w*h/2.0);
	if(w==2*x && h==2*y)
	cout<<" "<<1;
	else
	cout<<" "<<0;
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
int main(void){
  int a[36]={0};
  char s[27];
  scanf("%s",s);
  for(int i=0;i<strlen(s);i++)a[s[i]-97]++;
  for(int i=0;i<36;i++){
    if(a[i]>1){
      puts("no");
      exit(0);
    }
  }
  puts("yes");
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int C = scan.nextInt();

		if((A == B && B == C)||(A!=B && A!=C && B!=C) ) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
	}

}


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

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> maze (h, vector<int>(w, -1));
    rep(i, h) {
        rep(j, w) {
            char c;
            cin >> c;
            if (c == '#') maze.at(i).at(j) = 1001001001;
        }
    }

    int ans = 0;
    vector<P> step = {{0, 1}, {-1, 0}, {0, -1}, {1, 0}};
    rep(i, h) {
        rep(j, w) {
            if (maze.at(i).at(j) == -1) {
                queue<P> q;
                vector<vector<int>> m = maze;
                m.at(i).at(j) = 0;
                int d = 0;
                q.push({i, j});
                while (!q.empty()) {
                    P now = q.front(); q.pop();
                    d = max(d, m.at(now.first).at(now.second));
                    for (auto s : step) {
                        int x = now.first + s.first;
                        int y = now.second + s.second;
                        if (0 <= x && x < h && 0 <= y && y < w && m.at(x).at(y) == -1) {
                            m.at(x).at(y) = m.at(now.first).at(now.second) + 1;
                            q.push({x, y});
                        }
                    }
                }
                ans = max(ans, d);
            }
        }
    }

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

Measured memory_bytes: 3612
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
def main():
    a=I()
    b=I()
    c=I()
    d=I()
    e=I()
    k=I()
    yn= 'Yay!' if e-a<=k else ':('
    print(yn)
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 9060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        int count= 0;
        int max = 0;
        for (int i = 0; i < N; i++) {
            int h = sc.nextInt();
            if(h>=max) count++;
            max = Math.max(h,max);
        }
            System.out.println(count);

    }
}


Measured memory_bytes: 21972
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int sigma = 26; // species of characters
int main() {
	string s;
	cin >> s; s = "a" + s; // <-- sentinel
	int n = s.size();
	vector<int> seq(n);
	for (int i = 0; i < n; ++i) {
		seq[i] = s[i] - 'a';
	}
	vector<vector<int> > nxt(n, vector<int>(sigma, n)), pre(n, vector<int>(sigma, -1));
	for (int i = 1; i < n; ++i) {
		pre[i] = pre[i - 1];
		pre[i][seq[i - 1]] = i - 1;
	}
	for (int i = n - 2; i >= 0; --i) {
		nxt[i] = nxt[i + 1];
		nxt[i][seq[i + 1]] = i + 1;
	}
	vector<int> dp(n + 1);
	for (int i = n - 1; i >= 0; --i) {
		dp[i] = n + 1;
		for (int j = 0; j < 26; ++j) {
			dp[i] = min(dp[i], dp[nxt[i][j]] + 1);
		}
	}
	string ans; int cur = 0;
	for (int i = dp[0] - 1; i >= 0; --i) {
		for (int j = 0; j < sigma; ++j) {
			if (dp[nxt[cur][j]] == i) {
				ans = ans + (char)('a' + j);
				cur = nxt[cur][j];
				break;
			}
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 55224
#include<bits/stdc++.h>
using namespace std;
int N, temp;
vector<int> origin, sorted;

int main(){
 cin >> N;
 for(int i = 0; i < N; i++){
  scanf("%d", &temp);
  origin.push_back(temp);
	sorted.push_back(temp);
 }
 sort(sorted.begin(), sorted.end());

 for(int i = 0; i < N; i++){
  if(sorted[N / 2] <= origin[i]) printf("%d\n", sorted[N / 2 - 1]);
	else printf("%d\n", sorted[N / 2]);
 }
 return 0; 
};


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

vector<ll> a;

void dfs(ll cntup, ll x, ll s, ll f, ll t){
    if(cntup == 11) return;
    if(s >0 && f >0 && t >0){
        a.push_back(x);
    }

    dfs(cntup+1, 10*x+3, s, f, t+1);
    dfs(cntup+1, 10*x+5, s, f+1, t);
    dfs(cntup+1, 10*x+7, s+1, f, t);

}

int main(){
    ll n; cin >> n;
    ll ans = 0;

    dfs(1, 3, 0, 0, 1);
    dfs(1, 5, 0, 1, 0);
    dfs(1, 7, 1, 0, 0);

    sort(all(a));

    rep(i,a.size()){
        if(a[i] > n) break;
        ans++;
    }

    cout << ans << endl;

}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % 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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int dp[3][100100] = {0};

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

  int N;
  cin >> N;

  int a, b, c;
  cin >> a >> b >> c;
  dp[0][0] = a;
  dp[1][0] = b;
  dp[2][0] = c;

  rep(i, 1, N){
    cin >> a >> b >> c;
    vector<int> vec;
    vec.push_back(a);
    vec.push_back(b);
    vec.push_back(c);

    rep(j, 3){
      rep(k, 3){
        if(j != k){
          chmax(dp[j][i], dp[k][i-1]+vec[j]);
        }
      }
    }
  }

  cout << max(max(dp[0][N-1], dp[1][N-1]), dp[2][N-1]) << endl;

  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
//setprecision(12)
#include <cassert>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
const long long MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
#define pint pair<int,int>
#define pll pair<ll,ll>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

vector<pair<ll,int>> factorize(ll n) {
    vector<pair<ll,int>> res;
    for(ll i = 2; i*i <= n; ++i) {
        if(n%i) continue;
        res.emplace_back(i,0);
        while(n%i == 0) {
            n/=i;
            res.back().second++;
        }
    }
    if(n!=1) res.emplace_back(n,1);
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n; cin >> n;
    vector<pair<ll,int>> v = factorize(n);
    int ans = 0;
    rep(i,v.size()) {
        int now = 1;
        while(v[i].second-now>=0) {
            ans++;
            v[i].second-=now;
            now++;
        }
    }
    cout << ans << endl;


    return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}


int main(){
  int n,d,x; cin >> n >> d >> x;
  
  for(int i = 0; i < n; ++i){
    int a; cin >> a;
    int now = 1;    
    while(now <= d){
      x++;
      now += a;
    }
  }
  cout << x << endl;
}


Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;

#define FOR(i,a,b) for(long long int i=(a);i<(b);i++)
#define REP(i,n) for(long long int i=0;i<(n);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI 3.14159265358479

typedef long long int ll;
typedef vector<long long int> vi;

int main(){
	ll n, c = 0;
	while (cin >> n){
		REP(i, 10){
			REP(j, 10){
				REP(k, 10){
					REP(l, 10){
						if (i + j + k + l == n)c++;
					}
				}
			}
		}
		cout << c << "\n";
		c = 0;
	}
}

Measured memory_bytes: 1156
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
k = 0
ans = 0
for i in range(len(A)):
  if i == 0:
    ans += B[A[i]-1]
    k = A[i]
  else:
    if A[i]-k == 1:
      ans += B[A[i]-1]
      ans += C[A[i]-2]
      k = A[i]
    else:
      ans += B[A[i]-1]
      k = A[i]
print(ans)

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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x, y) make_pair(x, y)

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll n; cin >> n;
    vector<ll> a(n), b(n);
    ll num = 0;
    rep(i, n) {
        cin >> a[i];
        num -= a[i];
    }
    rep(i, n) {
        cin >> b[i];
        num += b[i];
    }

    if(num < 0) cout << "No" << endl;
    else {
        ll c = 0;
        rep(i, n) {
            if(b[i] > a[i]) {
                c += (b[i]-a[i]+1)/2;
            }
        }
        if(c <= num) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 3760
# -*- coding: utf-8 -*-

def readInts():
  return [int(s) for s in input().split(" ")]

def solve():
  N = readInts()[0]
  tasks = [tuple(readInts()) for _ in range(N)]
  tasks.sort(key=lambda x: x[1], reverse=True)

  t = tasks[0][1] - tasks[0][0]
  if t < 0:
    return False

  for i in range(1, N):
    if t > tasks[i][1]:
      t = tasks[i][1]
    t -= tasks[i][0]
    if t < 0:
      return False

  return True

def main():
  ans = solve()
  if ans:
    print("Yes")
  else:
    print("No")

if __name__ == "__main__":
  main()


Measured memory_bytes: 32084
N = int(input())
p = list(map(float,input().split()))

DP = [[0]*(N+1) for i in range(N+1)]
DP[0][0] = 1
for i in range(1,N+1):
    DP[i][0] = DP[i-1][0]*(1-p[i-1])


for i in range(1,N+1):
    for j in range(1,i+1):
        DP[i][j] = DP[i-1][j-1]*p[i-1]+DP[i-1][j]*(1-p[i-1])

print(sum(DP[N][(N+1)//2::]))

Measured memory_bytes: 311048
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<utility>
#include<bitset>
#include<complex>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>

using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=a; i<=b; ++i)
#define FOR(i,a,b) for(int i=a; i<b; ++i)
#define MP make_pair
#define PB push_back
#define fi first
#define se second
typedef long long LL;
typedef pair<int,int> pii;

const int maxn = 1e5, maxk = 2000;

int n, kk;
int B[maxk+5][maxk+5], W[maxk+5][maxk+5];

int S(int x, int y, int c) {
    int x1 = max(x-kk+1,1), y1 = max(y,1);
    int x2 = min(x,kk*2), y2 = min(y+kk-1, kk*2);
    if(x1 > x2 || y1 > y2) return 0;
    if(c == 0) return B[x2][y2] - B[x1-1][y2] - B[x2][y1-1] + B[x1-1][y1-1];
    return W[x2][y2] - W[x1-1][y2] - W[x2][y1-1] + W[x1-1][y1-1];
}

int main() {
    scanf("%d%d", &n, &kk);
    char str[5];
    for(int i = 1, x, y; i <= n; ++i) {
        scanf("%d%d%s", &x, &y, str);
        ++x, ++y;
        x %= kk*2, y %= kk*2;
        if(x == 0) x += kk*2;
        if(y == 0) y += kk*2;
        if(str[0] == 'B') ++B[x][y];
        else ++W[x][y];
    }
    for(int i = 1; i <= kk*2; ++i)
        for(int k = 1; k <= kk*2; ++k) {
            W[i][k] += W[i-1][k] + W[i][k-1] - W[i-1][k-1];
            B[i][k] += B[i-1][k] + B[i][k-1] - B[i-1][k-1];
        }
    int ans = 0;
    for(int i = 1; i <= kk+1; ++i) {
        for(int k = 1; k <= kk+1; ++k) {
            int tmp1 = 0, tmp2 = 0;
            int ti = i-kk, tj = k-kk*2;
            for(int ii = 0; ii < 4; ++ii)
                for(int jj = 0; jj < 4; ++jj) {
                    tmp1 += S(ti + kk * ii, tj + kk * jj, (ii+jj)&1);
                    tmp2 += S(ti + kk * ii, tj + kk * jj, ((ii+jj)&1) ^ 1);
                }
            ans = max(ans, max(tmp1, tmp2));
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

double memo[101][101];
double data[101][101];
int n;

void initData(){
  for(int i=0;i<101;i++)
    for(int j=0;j<101;j++)
      data[i][j] = 1;
}

void inputData(){
  for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
      cin >> data[i][j];
}

double solve(int m, int p){ //回数,直前の肥料
  
  if(!m) return 1;
  if(memo[m][p]) return memo[m][p];

  double ans = 0;
  for(int i=n;i>0;i--) ans = max(ans, solve(m-1, i)*data[p][i]);
  
  return memo[m][p] = ans;
}

int main(){
  
  int  m;
  
  while(true){
    cin >> n >> m;
    if(!n && !m) break;
    
    memset(memo, 0, sizeof(memo));
    initData();
    inputData();

    printf("%.2f\n", solve(m, 0));
  }
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//for(int i = 0; i<n; i++)
 
 
int main()
{
    int n;cin>>n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin>>a[i];
    int b = 100000000;
    for(int i = -100; i <= 100; i++){
        int sum = 0;
       for(int j = 0; j < n; j++){
           sum += (a[j] - i)*(a[j] - i);
       }    
       b = min(b, sum) ;
    }
    cout << b << endl;
    return 0;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <functional>
#include <utility>
#include <tuple>
#include <numeric>
#include <queue>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <regex>
#include <stack>
#include <limits>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	long long res = max(a * c, a * d);
	res = max(res, max(b * c, b * d));
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 3192
#define ll long long
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    int ans=0;
    if(a==d)
    {
        ans++;
    }
    if(b==e)
    {
        ans++;
    }
    if(c==f)ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int N,K,d[101],A[101][101];
	bool ok[101]={};
	scan(N>>K);
	rep(i,K){
		scan(d[i]);
		rep(j,d[i]){
			scan(A[i][j]);
			A[i][j]--;
			ok[A[i][j]]=1;
		}
	}
	int ans=0;
	rep(i,N) if(ok[i]==0) ans++;
	prin(ans);
	return 0;
}


Measured memory_bytes: 3676
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello{
    public static void Main()
    {
        // Your code here!
        string S = Console.ReadLine();
        string[] divide = new string[]{"dream", "dreamer", "erase", "eraser"};
        bool can = false;
        dfs(0, ref can, S, divide);
        if(can) Console.WriteLine("YES");
        else Console.WriteLine("NO");
        
    }
    
    public static void dfs(int now, ref bool can, string S, string[] divide)
    {
        if(now == S.Length)
        {
            can = true;
            return;
        }
        
        for(int i = 0; i < divide.Length; i++)
        {
            string d = divide[i];
            int next = now + d.Length;
            if(S.Length - now < d.Length)
            {
                continue;
            }
            else if(S.Substring(now, d.Length) == d)
            {
                dfs(next, ref can, S, divide);
            }
            
        }
        
    　  //どうやっても切れなかったらreturn
        return;
    }
    
    
}


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

int main()
{
    int a, b, count = 0;
    char str[100];

    scanf("%d %d", &a, &b);
    scanf("%s", str);

    int len = strlen(str);

    for(int i = 0; i < len; i++){
        if(str[i] == '-'){
            count++;
        }
    }

    if(count == 1 && str[a] == '-'){
        printf("Yes\n");
    }
    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 256
N = int(input())

q, mod = divmod(N, 26)
if mod == 0:
    ans = "z"
    q -= 1
else:
    ans = chr(mod+96)

while q > 0:
    q, mod = divmod(q, 26)
    if mod == 0:
        ans = "z" + ans
        q -= 1
    else:
        ans = chr(mod+96) + ans
    
print(ans)




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

int main() {
  string N;
  cin >> N;
  if(N == "Sunny") cout << "Cloudy" << endl;
  else if(N == "Cloudy") cout << "Rainy" << endl;
  else cout << "Sunny" << endl;
}


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

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

class Team{
	int id;
	int af;
	int solved;
	int pena;
	Team(int nid,int naf,int ns,int np){
		this.id=nid;
		this.af=naf;
		this.solved=ns;
		this.pena=np;
	}
}

public class Main {
	
	Team[] sort(Team t[],int n){
		int max;
		for(int i=0;i<n;i++){
			max=i;
			for(int j=i;j<n;j++){
				if(t[max].solved<t[j].solved){
					max=j;
				}
				else if(t[max].solved==t[j].solved){
					if(t[j].pena<t[max].pena){
						max=j;
					}
					else if(t[j].pena==t[max].pena){
						if(t[j].id<t[max].id)
							max=j;
					}
				}
			}
			Team temp=t[i];
			t[i]=t[max];
			t[max]=temp;
		}
		return t;
	}
	void select(Team[] t,int n){
		int count=0;
		int p[]=new int[1001];
		Arrays.fill(p, 0);
		Team s[]=new Team[26];
		for(int i=0;i<n;i++){
			if(count<10){
				if(p[t[i].af]<3){
					s[count]=t[i];
					count++;
					p[t[i].af]++;
				}
			}
			else if(count<20){
				if(p[t[i].af]<2){
					s[count]=t[i];
					count++;
					p[t[i].af]++;
				}
			}
			else if(count<26){
				if(p[t[i].af]<1){
					s[count]=t[i];
					count++;
					p[t[i].af]++;
				}
			}
		}
		for(int i=0;i<count;i++){
			System.out.println(s[i].id);
		}
	}
	void run(){
		Scanner sc=new Scanner(System.in);
		int n;
		while(true){
			n=sc.nextInt();
			if(n==0) break;
			Team t[]=new Team[n];
			for(int i=0;i<n;i++){
				t[i]=new Team(sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt());
			}
			t=sort(t,n);
			select(t,n);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

void add(ll& a, ll b){a = (a+b) % MOD;}

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

const int MAX_DIGIT=50;
ll dp[100][2];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    ll K;
    cin>>N>>K;
    vector<ll> A(N);
    REP(i,N) cin>>A[i];

    memset(dp,-1,sizeof(dp));
    dp[0][0]=0;
    REP(d,MAX_DIGIT){
        ll mask=1LL<<(MAX_DIGIT-d-1);
        int num=0;
        REP(i,N) if(A[i]&mask)++num;

        ll cost0 = mask*num;
        ll cost1 = mask*(N-num);

        if(dp[d][1]!=-1){
            chmax(dp[d+1][1],dp[d][1]+max(cost0,cost1));
        }
        if(dp[d][0]!=-1){
            if(K&mask){
                chmax(dp[d+1][1],dp[d][0]+cost0);
            }
        }
        if(dp[d][0]!=-1){
            if(K&mask) chmax(dp[d+1][0],dp[d][0]+cost1);
            else chmax(dp[d+1][0],dp[d][0]+cost0);
        }
    }
    cout<<max(dp[MAX_DIGIT][0],dp[MAX_DIGIT][1])<<endl;
}

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

using namespace std;

bool cmp(const pair <string, int> &a, pair <string, int> &b) {
  if(a.first == b.first) return a.second > b.second;
  return a.first < b.first;
}
 
int main() {
  int n;
  cin >> n;
  map<pair<string, int>, int> mp;
  vector<pair <string, int>> a;
  for(int i = 0; i < n; i++) {
    string s; int m;
    cin >> s >> m;
    a.push_back({s, m});
    mp.insert({{s,m}, i});
  }
  sort(a.begin(), a.end(), cmp);
  for(int i = 0; i < n; i++) {
    cout << mp[{a[i].first, a[i].second}] + 1<< '\n'; 
  }
}


Measured memory_bytes: 256