akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

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

int main() {
    ll n, k;
    cin >> n >> k;
    vector<int> g(k+1);
    REP(i, k){
        ll now = k/i;
        g[i] = modpow(now, n, mod);
    }
    for(int i = k; i > 0; i--){
        vector<int> ret;
        for(int j = 1; j * j <= i; j++){
            if(i % j == 0){
                ret.push_back(j);
                if(j * j != i)ret.push_back(i/j);
            }
        }
        rep(j, ret.size()){
            if(ret[j] != i)g[ret[j]] = (g[ret[j]] - g[i] + mod) % mod;
        }
    }
    ll ans = 0;
    REP(i, k)ans = (ans + ((i % mod)* (g[i] % mod)) % mod) % mod;
    cout << ans << endl;
}   

Measured memory_bytes: 3700
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstdlib>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	cout<<(a+b)*c/2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n, k, c=0;
  cin>>n>>k;
  int h[n];
  for(int i=0; i<n; i++)
  {
    cin>>h[i];
  } 
  for(int i=0; i<n; i++)
  {
    if(h[i]>=k)
    {
        c++;
    }
  }
  cout<<c;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int P = sc.nextInt();
        int Q = sc.nextInt();
        int R = sc.nextInt();

        System.out.println(solve(P, Q, R));

        sc.close();
    }

    static int solve(int P, int Q, int R) {
        return P + Q + R - Math.max(Math.max(P, Q), R);
    }
}

Measured memory_bytes: 35192
n = int(input())
if n == 1:
    print(0)
    exit()

def primes_factraizar(n):
    rn = int(n**0.5)
    is_prime = [True]*(rn+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2,rn+1):
        if not is_prime[i]:
            continue
        for j in range(i*2,rn+1,i):
            is_prime[j] = False
        return [i for i in range(rn+1) if is_prime[i]]
primes = primes_factraizar(n)

divisors = []
for i in primes:
    if n % i == 0:
        divisors.append(i)

divisors.sort()

if divisors == []:
    print(1)
    exit()
ans = 0

for i in divisors:
    if i == 1:
        continue

    c = 0

    while n%i == 0:
        n = n // i
        c += 1
    
    d=0

    for count in range(1,1000):
        if c >= d+count:
            ans += 1
            d+=count
        else:
            break
if not n == 1:
    ans += 1

print(ans)

Measured memory_bytes: 36824
from sys import stdin

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
B = [int(x) for x in stdin.readline().rstrip().split()]
cnt = 0

for i in range(N):
    kill = min(A[i], B[i])
    A[i] -= kill
    cnt += kill
    B[i] -= kill
    kill2 = min(A[i + 1], B[i])
    A[i + 1] -= kill2
    cnt += kill2

print(cnt)


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

int main() {
  string S;
  cin >> S;
  if(S=="abc"||S=="acb"||S=="bac"||S=="bca"||S=="cab"||S=="cba"){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

map<int64_t, int> prime_factor(int64_t n) {
  map<int64_t, int> ret;
  for (int64_t i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}

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

  cin >> n;
  for (auto p : prime_factor(n)) {
    sum = 0;
    cnt = 1;
    while (1) {
      if (sum + cnt > p.se) break;
      sum += cnt;
      ans++;
      cnt++;
    }
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
int W,H,m[52][52],i,j,r;
void f(int h,int w)
{
	int x[3]={-1,0,1},p;
	if(m[h][w])
		for(p=m[h][w]=0;p<=9;p++)
			f(h+x[p/3%3],w+x[p%3]);
}
int main()
{
	
	for(;scanf("%d%d",&W,&H),W;)
	{
		for(i=1;i<=H;i++)
			for(j=1;j<=W;j++)
				scanf("%d",&m[i][j]);
		for(i=1,r=0;i<=H;i++)
			for(j=1;j<=W;j++)
				if(m[i][j])
				{
					r++;
					f(i,j);
				}
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 748
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
 
int main() {
	int N, M;
	cin >> N >> M;
 
	int ans = 1;
	for (int A = 1; A * A <= M; A++)
	{
		//約数の判定をする！！！
		if (M % A != 0) continue;
 
		int B = M / A;
 
		if ((long)A * N <= M) ans = max(ans, A);
		if ((long)B * N <= M) ans = max(ans, B);
	}
	cout << ans << endl;
}

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

int main() {
  int a[20][20] = {-1};
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      a[i][j] = 0;
    }
  }
  
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < W; ++j) {
      a[i][j] = 1;
    }
  }
  
  for (int j = 0; j < w; ++j) {
    for (int i = 0; i < H; ++i) {
      a[i][j] = 1;
    }
  }
  
  int count = 0;
  
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (a[i][j] == 0) {
        count++;
      }
    }
  }
  
  cout << count << endl;
  
  return 0;
}

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

struct card{
	char suit;
	int val;
	
	bool isEqu(card &h){
		if(suit==h.suit && val==h.val){
			return true;
		}else{
			return false;
		}
	}
};

void print(card* d,int ds){
	int i=0;
	while(true){
		cout<<d[i].suit<<d[i].val;
		i++;
		if(i<ds){
			cout<<" ";
		}else{
			break;
		}
	}
	cout<<endl;
}

int main(){
	int n;
	cin>>n;
	card in[n];
	for(int i=0;i<n;i++){
		char ain[3]="";
		cin>>ain;
		in[i].suit=ain[0];
		in[i].val=(int)(ain[1]-'0');
	}
	
	card bs[n];
	memcpy(bs,in,sizeof(bs));
	for(int i=0;i<n;i++){
		for(int j=n-1;j>i;j--){
			if(bs[j].val<bs[j-1].val){
				swap<card>(bs[j],bs[j-1]);
			}
		}
	}
	print(bs,n);
	cout<<"Stable"<<endl;
	
	card ss[n];
	memcpy(ss,in,sizeof(ss));
	for(int i=0;i<n;i++){
		int minj=i;
		for(int j=i;j<n;j++){
			if(ss[j].val<ss[minj].val){
				minj=j;
			}
		}
		swap<card>(ss[i],ss[minj]);
	}
	print(ss,n);
	for(int i=0;i<n;i++){
		if(!ss[i].isEqu(bs[i])){
			cout<<"Not stable"<<endl;
			return 0;
		}
	}
	cout<<"Stable"<<endl;
	return 0;
}


Measured memory_bytes: 3164
fun main(array: Array<String>)  {
    val a = readLine()!!
    val b = readLine()!!

    when {
        a.length > b.length -> print("GREATER")
        a.length < b.length -> print("LESS")
        a > b -> print("GREATER")
        a < b -> print("LESS")
        else -> print("EQUAL")
    }

}

Measured memory_bytes: 31816
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int4(n, k, x, y);
    if(n <= k)pri(n * x);
    else pri(k * x + (n - k) * y);


/*/

//*/ break;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 1e5 + 10;
const ll mod = 1e9 + 7;

ll qpow(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

int n, k;

int vis[MAX], prime[MAX], num;
ll phi[MAX];
void makePhi(int siz) {
    phi[1] = 1;
    for (int i = 2; i <= siz; i++) {
        if (!vis[i]) prime[++num] = i, phi[i] = i - 1;
        for (int j = 1; j <= num && i * prime[j] <= siz; j++) {
            vis[i * prime[j]] = 1;
            if (i % prime[j] == 0) {
                phi[i * prime[j]] = phi[i] * prime[j];
                break;
            }
            else phi[i * prime[j]] = phi[i] * phi[prime[j]];
        }
    }
    for (int i = 1; i <= siz; i++) phi[i] = (phi[i] + phi[i - 1]) % mod;
}

int main() {
#ifdef ACM_LOCAL
    freopen("input.in", "r", stdin);
    freopen("output.out", "w", stdout);
#endif
    scanf("%d%d", &k, &n);
    makePhi(n);
    ll ans = 0;
    for (int l = 1, r = 0; l <= n; l = r + 1) {
        r = n / (n / l);
        ans = (ans + 1ll * (phi[r] - phi[l - 1] + mod) % mod * qpow(n / l, k) % mod) % mod;
    }
    printf("%lld\n", ans);


    return 0;
}

Measured memory_bytes: 5024
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
A=get_i
kind=array(9,0)
A.each do|a|
  a=3200 if a>3200
  kind[a/400]+=1
end
min=0
8.times do|i|
  min+=1 if kind[i]>0
end
max=min
max+=kind[8]
min=1 if min.zero?
puts [min,max].join(" ")

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

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

int K,T;
vector<P> A;

int main(){
    cin >> K >> T;
    for(int i=0;i<T;i++){
        int a;
        cin >> a;
        A.push_back({a,i});
    }
    int before = -1;
    int ans = 0;
    for(int i=0;i<K;i++){
        sort(A.rbegin(),A.rend());
        if(before != A[0].second){
            (A[0].first)--;
            before = A[0].second;
            continue;
        }
        if(A[1].first > 0){
            (A[1].first)--;
            before = A[1].second;
            continue;
        }
        ans = A[0].first;
        break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = gets.to_i
A = (2 ** N).times.map { gets.to_i }

while A.size > 1
  x, y = A.shift(2)

  if x > y
    A.push(x - y)
  elsif x < y
    A.push(y - x)
  else
    A.push(x)
  end
end

puts A.first


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    string s;
    cin >> s;
    sort(all(s));
    if(s == "abc") cout << "Yes";
    else cout << "No";
    cout << endl;

    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

int main() {
  string s;
  cin >> s;
  string srev = s;
  reverse(all(srev));
  map<char, char> mp;
  mp['b'] = 'd';
  mp['d'] = 'b';
  mp['p'] = 'q';
  mp['q'] = 'p';
  int len = s.length();
  rep (i, len) {
    if (mp[s[i]] != srev[i]) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
int main(void){
    int n,ans=0;
    cin>>n;
    map<int,int> mp;
    for(;n--;){
        int p;
        cin>>p;
        if(mp.find(p)==mp.end()){
            mp[p]=1;
        }else{
            mp[p]++;
        }
        if(mp[p]%2==1){
            ans++;
        }else{
            ans--;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 4992
#include<stdio.h>
#include<math.h>
int main(void){
    double a,b,C;
    double S=0.0,L=0.0,h=0.0;

    scanf("%lf %lf %lf",&a,&b,&C);
    S=0.5*a*b*sin(C*3.14159265359/180);
    L=a+b+sqrt((a*a)+(b*b)-(2*a*b*cos(C*3.14159265359/180)));
    h=b*sin(C*3.14159265359/180);
    printf("%f\n",S);
    printf("%f\n",L);
    printf("%f\n",h);

    return 0;
}


Measured memory_bytes: 2044
s = list(input())
k = int(input())

for i, c in enumerate(s):
    t = (ord("z") - ord(c) + 1) % 26
    if k >= t:
        s[i] = "a"
        k -= t

t = k % 26
s[-1] = chr(ord(s[-1]) + t)

print("".join(s))

Measured memory_bytes: 76836
#include <bits/stdc++.h>
using namespace std;
bool cmp(char a,char b)
{
  return a>b;
}
int main()
{
	string s,t;
	cin>>s>>t;
	sort(s.begin(),s.end());
		sort(t.begin(),t.end(),cmp);
		if(s<t)
		    cout<<"Yes";
		else
		    cout<<"No";
		return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
      int w,h,x,y,r;
      
      scanf("%d",&w);
      scanf("%d",&h);
      scanf("%d",&x);
      scanf("%d",&y);
      scanf("%d",&r);

if(x+r<=w&&0<=x-r&&y+r<=h&&y-r>=0)
printf("Yes\n");

else
printf("No\n");

return(0);
    
}


Measured memory_bytes: 2112
#include<stdio.h>
#include<math.h>
int main()
{
    long long int a,b,c,k,i,j,m,n,p,cnt,fla;
    scanf("%lld %lld %lld %lld",&a,&b,&c,&k);

    if(k<=a) printf("%lld\n",k);
    else
    {
        m=k-a;
        if(m<=b) printf("%lld\n",a);
        else
        {
            n=m-b;
            printf("%lld\n",a-n);
        }
    }

    return 0;
}


Measured memory_bytes: 1732
#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 n;
    cin >> n;
    vector <int> d(n);
    priority_queue <int> q;
    rep(i,n){
        cin >> d[i];
        q.push(d[i]);
    }

    rep(i,n/2-1){
        q.pop();
    }

    int a,b;
    b=q.top();
    q.pop();
    a=q.top();

    cout << b-a << endl;

    return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	int a[3]; cin >> a[0] >> a[1] >> a[2];
	sort(a, a+3);
	cout << a[0]+a[1];
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;
int main()
{
	int N;
	int K;
	int d[200];
	int A;
	int B[200] = { 0 };

	cin >> N;
	cin >> K;

	for (int i = 0; i < K; i++)
	{
		cin >> d[i];
		for (int j = 0; j < d[i]; j++)
		{
			cin >> A;
			B[A - 1] = 1;
		}
	}

	int count = 0;
	for (int i = 0; i < N; i++)
	{
		if (B[i] == 0)
		{
			count++;
		}
	}

	cout << count << endl;
}

Measured memory_bytes: 3636
n, k = map(int, input().split())
d = [0]*k
a = [0]*k
for i in range(k):
  d[i] = int(input())
  a[i] = list(map(int, input().split()))
  
lis = [0]*n
for i in range(n):
  lis[i] = i + 1

alis = sum(a, [])

alis = list(set(alis))

for i in range(len(alis)):
  lis.remove(alis[i])
print(len(lis))

Measured memory_bytes: 9340
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
#define ll long long

int main(int argc, const char * argv[]) {
    // insert code here...
    
    int n;
    cin >> n;
    
    vector<int> a(n);
    
    for (auto i=0; i<n; i++) {
        cin >> a[i];
    }
    
    if (n%2==0) {
        for (int i=0; i<n/2; i++) {
            cout << a[n-1-(2*i)] << " ";
        }
        cout << a[0] << " ";
        
        for (int i=0; i < n/2 -1; i++) {
            cout << a[2 + 2*i] << " ";
        }
        cout << endl;
    }
    else if(n%2==1){
        for (int i=0; i<(n-1)/2; i++) {
            cout << a[n-1-(2*i)] << " ";
        }
        cout << a[0] << " ";
        for (int i=0; i < n/2; i++) {
            cout << a[1 + 2*i] << " ";
        }
        cout << endl;
    }
    
    
    
    return 0;
}



Measured memory_bytes: 2944
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M=1000000007;
const ll MM=998244353;
ll begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";

 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}



const ll N=1e6+5;

ll dp[N][2];

int main()
{ 

IOS;

ll n;cin>>n;
 map<string,ll>m;

ll mx=0;

 FOR(i,n){
  string s;cin>>s;
  m[s]++;
  chmax(mx,m[s]);
 }

 for(auto p:m){
  if(p.ss==mx)d1(p.ff);
 }

//end_routine();

return 0;
 
 }

Measured memory_bytes: 19244
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define emp emplace

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int N = 100010;
int pd[N];
int h[N];

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", h+i);
	pd[n] = 0x3f3f3f3f;
	pd[n-1] = 0;

	for (int i = n-2; i >= 0; i--)
		pd[i] = min(pd[i+1] + abs(h[i] - h[i+1]), pd[i+2] + abs(h[i+2] - h[i]));
	printf("%d\n", pd[0]);
	return 0;
}



Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
	ll n,ans=INF; cin>>n;
    vector<ll> a(n,0),sum(n+1,0);
    rep(i,n){
        cin>>a[i];
        a[i]*=2;
        sum[i+1]=sum[i]+a[i];
    }
    rep(i,n-3){
        ll ls=sum[i+2],rs=sum[n]-sum[i+2];
        ll P,Q,R,S;
        ll l=1,r=i+2,c;
        while(l!=r){
            c=(l+r)/2;
            if(sum[c]>=ls/2) r=c;
            else l=c+1;
        }
        if(l==i+2){
            P=sum[i+1]; Q=ls-P;
        }
        else if(l==1){
            P=a[0]; Q=ls-P;
        }
        else{
            if(abs(ls/2-sum[l])>abs(ls/2-sum[l-1])) P=sum[l-1];
            else P=sum[l];
            Q=ls-P;
        }
        l=i+3; r=n;
        while(l!=r){
            c=(l+r)/2;
            if(sum[c]-sum[i+2]>=rs/2) r=c;
            else l=c+1;
        }
        if(l==n){
            R=sum[n-1]-sum[i+2]; S=rs-R;
        }
        else if(l==i+3){
            R=a[i+2]; S=rs-R;
        }
        else{
            if(abs(rs/2-(sum[l]-sum[i+2]))>abs(rs/2-(sum[l-1]-sum[i+2])))
            R=sum[l-1]-sum[i+2];
            else R=sum[l]-sum[i+2];
            S=rs-R;
        }
        ll D=max(max(P,Q),max(R,S))-min(min(P,Q),min(R,S));
        ans=min(ans,D);
    }
    cout<<ans/2<<endl;
}

Measured memory_bytes: 3328
#include<iostream>

using namespace std;

int main(){
    int a,b,k;
    cin >> a >> b >>k;
    if((b-a)<2*k){
        for(int i=a;i<=b;i++){
            cout << i << endl;
        }
    }
    else{
    for(int i=0;i<k;i++){
        cout << a+i << endl;
    }
    for(int i=k-1;i>=0;i--){
        cout << b-i << endl;
    }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
void Cut(int);
void solve();
int t,len,flag,flag2,ans,ansc[6],anss;
string num;
bool cut[6];

int main(){
  while(1){
    cin>>t>>num;
    if(!t&&num=="0") break;
    for(int i=0;i<6;i++) cut[i]=false;
    len=num.size();
    flag=flag2=0;
    ans=-1;
    Cut(0);
    if(!flag) cout<<"error"<<endl;
    else{
      if(flag2) cout<<"rejected"<<endl;
      else{
	cout<<ans<<' ';
	for(int i=0;i<anss;i++) cout<<ansc[i],i==anss-1?:cout<<' ';

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

void Cut(int x){
  if(x==len-1){
    solve();
    return;
  }
  for(int i=0;i<2;i++) cut[x]=i,Cut(x+1);
}

void solve(){
  int sum=0,value=0,ind=0,v[6],f=0;
  for(int i=0;i<len;i++){
    value=value*10+(num[i]-'0');
    if(cut[i]) sum+=value,value=0;
  }
  sum+=value;
  if(sum<=t&&sum>=ans){
    value=0;
    flag=1;
    if(ans==sum) flag2=1;
    else flag2=0;
    ans=sum;
    for(int i=0;i<len;i++){
      value=value*10+(num[i]-'0');
      if(cut[i]) v[ind]=value,value=0,ind++;
    }
    v[ind]=value;
    ind++;
    anss=ind;
    for(int i=0;i<ind;i++) ansc[i]=v[i];
  }
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	
	ll m,d; cin>>m>>d;
	ll sum = 0;
	for(int i = 1; i <= m; i++){
		for(int j = 10; j <= min(d,99ll); j++){
			int c = j;
			vector<int> ans;
			ll co = 1;
			while(c){
				ans.push_back(c%10);
				c /= 10;
			}
			for(auto xx : ans) co *= xx;
			if(co == i && ans.size() == 2 && ans[0]>=2 && ans[1]>=2) {sum++; } 
			
		}
	}
	cout<<sum<<"\n";
	
	
	
	
	
	
	
	
}

Measured memory_bytes: 256
using System;

class Program
{
    static int[,,] Table = new int[100000, 27, 27];
    class Trie
    {
        public int Leaves = 0;
        public Trie[] Son = new Trie[27];
        public Trie()
        {
            for (int ii = 0; ii <= 26; ii++) Son[ii] = null;
        }
        public void AddWord(string _w)
        {
            Trie Point = this;
            for (int ii = 0; ii < _w.Length; ii++)
            {
                Point.Leaves++;
                if (Point.Son[_w[ii] - 'a' + 1] == null) Point.Son[_w[ii] - 'a' + 1] = new Trie();
                Point = Point.Son[_w[ii] - 'a' + 1];
            }
            Point.Leaves++;
            Point.Son[0] = new Trie();
            Point.Son[0].Leaves++;
        }
        public void Count(string _w, int _p)
        {
            Trie Point = this;
            for (int ii = 0; ii < _w.Length; ii++)
            {
                for (int jj = 0; jj <= 26; jj++)
                    if (jj != _w[ii] - 'a' + 1)
                        if (Point.Son[jj] != null)
                            Table[_p, jj, _w[ii] - 'a' + 1] = Table[_p, jj, _w[ii] - 'a' + 1] + Point.Son[jj].Leaves;
                Point = Point.Son[_w[ii] - 'a' + 1];
            }
        }
    }
    static void Main()
    {
        Trie Root = new Trie();
        string[] s = new string[100000];
        int n = int.Parse(Console.ReadLine());
        for (int i = 0; i < n; i++)
        {
            s[i] = Console.ReadLine();
            Root.AddWord(s[i]);
        }
        for (int i = 0; i < n; i++) Root.Count(s[i], i);
        int q = int.Parse(Console.ReadLine());
        for (int i = 0; i < q; i++)
        {
            string[] ip = Console.ReadLine().Split(' ');
            int m = int.Parse(ip[0]);
            int ans = 1;
            for (int j = 0; j < 26; j++)
            {
                ans = ans + Table[m - 1, 0, ip[1][j] - 'a' + 1];
                for (int k = j + 1; k < 26; k++)
                    ans = ans + Table[m - 1, ip[1][j] - 'a' + 1, ip[1][k] - 'a' + 1];
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 359740
#include <iostream>
#include <stdio.h>

int main(){
    double const PI = 3.141592653589;

    double r = 0.0f;
    std::cin >> r;

    double size = r * r * PI;
    double cir  = (r + r) * PI;

    printf( "%f %f\n", size, cir );

    return 0;
}

Measured memory_bytes: 1232
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<iostream>
using namespace std;
int n,A[55];
long long ans,pj;
long long dp[55][55][50*50+5];
int main()
{
	scanf("%d%lld",&n,&pj);
	for(int i=1;i<=n;i++)
		scanf("%d",&A[i]);
	dp[0][0][0]=1;
	for(int i=1;i<=n;i++)
		for(int k=0;k<=i;k++)
			for(int j=0;j<=pj*n;j++)
			{
				if(i-1>=k)
					dp[i][k][j]+=dp[i-1][k][j];
				if(j>=A[i] && k-1>=0)
					dp[i][k][j]+=dp[i-1][k-1][j-A[i]];
			}
	for(int k=1;k<=n;k++)
		for(int j=0;j<=pj*n;j++)
			if(j==k*pj)
				ans+=dp[n][k][j];
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 53504
#include <stdio.h>
#include <string.h>
int main(void){
    // Here your code !
    int a,i,j;
    int x = 0;
    char s[27];
    scanf("%s",s);
    a = strlen(s);
    for(i=0;i<a;i++){
        for(j=0;j<a;j++){
            if(s[i] == s[j]){
                x++;
            }
        }
        if(x>=a+1){
            printf("no\n");
            break;
        }
        else if(i==a-1){
            printf("yes\n");
            break;
        }
    }
    
    return 0;
}


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

#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
using psi = pair<string, int>;
using pss = pair<string, string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() {
  int N = in();
  typedef multimap<int, int> MII;
  multimap<string, MII> mp;

  string s;
  int p;

  REP(i, N) {
    cin >> s >> p;
    auto itr = mp.find(s);
    if (itr != mp.end()) {
      itr->second.emplace(p,i+1);
    } else {
      MII tmp { {p, i+1} };
      mp.emplace(s, tmp);
    }
  }
  for (auto e: mp) {
    auto m = e.second;
    for (auto ee = m.rbegin(); ee != m.rend(); ++ee) {
      print(ee->second);
    }
  }
  return 0;
}

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

void solve(ll X) {
    for ( ll a = 0; a*a*a*a <= X; a++ ) {
        for ( ll b = 0; a*a*a*a*a+b*b*b*b*b <= X; b++ ) {
            if ( a*a*a*a*a+b*b*b*b*b == X) {
                cout << a << " " << -b << "\n";
                return;
            }
        }
    }
    for ( ll b = 0; b*b*b*b <= X; b++ ) {
        for ( ll a = 0; a*a*a*a*a-b*b*b*b*b <= X ; a++ ) {
            if ( a*a*a*a*a-b*b*b*b*b == X) {
                cout << a << " " << b << "\n";
                return;
            }
        }
    }
    return;
}

int main() {
    // ll a, b;
    // cin >> a >> b;
    // ll X = a*a*a*a*a-b*b*b*b*b;
    ll X;
    cin >> X;
    solve(X);
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n)  FOR(i,0,n)

int main() {
	int n, a[200], flag = 0, sum = 0;
	scanf("%d",&n);
	REP(i,n) scanf("%d",&a[i]);
	while(1) {
		REP(i,n) if(a[i] % 2 == 1) flag = 1;
		if(flag) break;
		REP(i,n) a[i] /= 2;
		sum++;
	}
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define stop exit(0)
#define pb push_back
#define skip continue
#define ll long long
ll a,b,c,d=0,e=0,i,f=0,g=0,j,k=0,l=0,r,m,h,p,df[51];
string t,x,q,s;
double w;
vector<ll>dv[101],v,z;
vector<string>u;
map<string,ll>n;
set<ll>y;
void dfs(ll x){
    df[x]=1;
    for(ll i=0;i<dv[x].size();i++){
        if(dv[x][i]==0){
            dfs(dv[x][i]);
            df[dv[x][i]]=1;
        }
    }
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin>>a>>b>>c;
    a+=(b-1);
    cout<<(a/b)*c;
}

Measured memory_bytes: 3616
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-19 21:04:10
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

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

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for (int i = 0; i < m; i++)
        cin >> a[i];

    int sum = 0;
    for (int i = 0; i < m; i++)
        sum += a[i];

    cout << max(-1, n-sum) << endl;

    return 0;
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
#define  ll  long long
ll M=1e9+7;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll i,l,n,m,s=1,p=1;
    cin>>n>>m;
    l=abs(n-m);
    if(l>1)
    {
        cout<<"0\n";
    }
    else
    {
        for(i=2;i<=n;i++)
        {
            s=(s*i)%M;
        }
        for(i=2;i<=m;i++)
        {
            p=(p*i)%M;
        }
        s=(s*p)%M;
        if(l==0)
        {
            s=(2*s)%M;
        }
        cout<<s<<"\n";
    }
    return 0;
}

Measured memory_bytes: 256
//s.empty() //emptyなら1を出力 入っていれば0を出力
/*//ABC018-B 部分的にreverseをかける解法
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  rep(i,n) cin>>a.at(i)>>b.at(i);
  rep(i,n)a.at(i)--;
  rep(i,n)b.at(i)--;
  string t;
  rep(i,n){
    t = s;
    for(int k=0;k<=b.at(i)-a.at(i);k++){
      t.at(a.at(i)+k) = s.at(b.at(i)-k);
    }
    s = t;
  }
  cout << s << endl;
}
*///ABC018-B
//  string s;
//  cin >> s;
//  cout << s.at(0) <<endl;
//  cout << s.at(0)-'0' <<endl;
//  Aが16？
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n;
  cin >> n;
  string s,t;
  cin >> s >> t;
  int flag = 0;
  for(int i=0;i<s.size();i++){
    if(t.at(0)==s.at(i)){
      int count = 0;
      for(int j=i;j<s.size();j++){
        if(t.at(j-i) == s.at(j) ) count++;
      }
      if(count == s.size()-i){
        flag = 1;
        cout << n * 2 - count << endl;
        break;
      }
    }
    if(flag==1)break;
  }
  if(flag!=1)cout<<n*2<<endl;
}    

Measured memory_bytes: 3596
// ITP1_5_A:   Print a Rectangle
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int H, W;
	int h, w;

	while (1) {
		scanf("%d%d", &H, &W);
		if (H == 0 && W == 0) break;
		for (h = 0; h < H; h++) {
			for (w = 0; w < W; w++) putchar('#');
			putchar('\n');
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 572
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();

		if (a <= 5) {
			System.out.println(0);
		} else if (a <= 12) {
			System.out.println(b / 2);
		} else {
			System.out.println(b);
		}
	}
}


Measured memory_bytes: 21844
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y = sc.nextInt();
        if(Y%2==0 && Y/2-X>=0 && 2*X-Y/2>=0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    
        }
    }

Measured memory_bytes: 35836
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author dyominov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ARatingGoal solver = new ARatingGoal();
        solver.solve(1, in, out);
        out.close();
    }

    static class ARatingGoal {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int r = in.nextInt();
            int g = in.nextInt();
            out.print(g * 2 - r);
        }

    }

    static class InputReader implements AutoCloseable {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

        public void close() {
        }

    }
}



Measured memory_bytes: 20308
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define gridif(a,x,b) if((a)<=(x)&&(x)<(b))
using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;

int digitsum(int n,int b){
	if(b<2) return -1;
	if(n<b) return n;
	return digitsum(n/b,b)+n%b;
}
int mpow(int a,int x);
int m_inv(int n){return mpow(n,mod-2);}

int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}

signed main(){
    int H,W,N;
    cin>>H>>W>>N;
    map<P,int> mp;
    rep(i,N){
    	int a,b;
    	cin>>a>>b;
    	a--;b--;
    	rep(j,3) rep(k,3){
    		gridif(0,a-j,H-2) gridif(0,b-k,W-2){
    			mp[P(a-j,b-k)]++;
    		}
    	}
    }
    int ans[10];
    rep(i,10) ans[i]=0;
    ans[0]=(H-2)*(W-2);
    itr(i,mp) ans[i->second]++;
    rep(i,1,10) ans[0]-=ans[i];
    rep(i,10) cout<<ans[i]<<endl;
}

int mpow(int a,int x){
	int ans=1;
	while(x>0){
		if(x%2==1) (ans*=a)%=mod;
		(a*=a)%=mod;
		x>>=1;
	}
	return ans;
}

Measured memory_bytes: 56448
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

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;
}

void trace(int A[], int N) {
    for (int i = 0; i < N; ++i) {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

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

const unsigned long long INF = 1LL << 60;

////////////////////////////////////////////////////////////

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

    for (int i = 1; i <= N; i++) {
        if (i % 3 == 0) continue;
        if (i % 5 == 0) continue;
        ans += i;
    }

    cout << ans << endl;
}


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

int min(int a, int b) { return a < b ? a : b; }

int ans = 2147483647;
std::string s, t;

int main() {
	std::cin >> s >> t;
	int len1 = s.length(), len2 = t.length();
	for (int i = 0; i < len1; ++i) {
		if (i + len2 - 1 >= len1) break;
		int p = i, sum = 0;
		for (int j = 0; j < len2; ++j, ++p) {
			if (s[p] == t[j]) ++sum;
		}
		ans = min(ans, len2 - sum);
	}
	std::cout << ans << '\n';
	return 0;
}

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


int main(void){
    // Your code here!
    long long n;
    vector<long long> x;
    
    cin >> n;
    for(long long i = 0; i < n; i++){
        long long temp;
        cin >> temp;
        x.push_back(temp);
    }
    
    long long output_count = 0;
    vector<long long> output(n, 0);
    for(long long i = n; 1 <= i; i--){
        long long temp = 2;
        vector<long long> r;
        while(i * temp <= n){
            r.push_back(i * temp);
            temp++;
        }
        
        long long count = 0;
        for(auto j:r)
            count += output[j - 1];
        output[i-1] = x[i-1] ^ (count % 2);
        output_count += output[i-1];
    }
    
    cout << output_count << endl;
    for(long long i = 0; i < n; i++)
        if(output[i] == 1)
            cout << i + 1 << ' ';
    
    return 0;
    
}


Measured memory_bytes: 6484
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String a = sc.nextLine();
        String s = sc.nextLine();
        
        int n = Integer.parseInt(a);
        
        if (n < 3200) {
            System.out.println("red");
        } else {
            System.out.println(s);
        }
    }
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, m);
    vvi data(m);
    rep(i, m) {
        Int(tmp);
        rep(j, tmp) {
            Int(tp);
            data[i].pb(tp);
        }
    }

    vi state(m);
    rep(i, m) {
        cin >> state[i];
    }

    int ans = 0;
    rep(i, 1ll << n) {
        bool ok = true;
        rep(j, m) {
            int cnt = 0;
            rep(k, data[j].size()) {
                if (1 << (data[j][k]-1) & i) {
                    cnt++;
                }
            }
            if (cnt % 2 != state[j]) {
                ok = false;
            }
        }
        if (ok) {
            ans++;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, core.bitop;

void main()
{
    auto nk = readln.split.to!(int[]);
    auto K = nk[1];
    int[int] as;
    foreach (a; readln.split.to!(int[])) ++as[a];
    int[] bs;
    foreach (a; as.values) bs ~= a;
    sort!"a < b"(bs);
    int r;
    foreach (i; 0..max(0, bs.length.to!int - K)) r += bs[i];
    writeln(r);
}

Measured memory_bytes: 24848