akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <sstream>
using namespace std;

set<string>s;
set<string>visit;
map<string,vector<string> >m;

void solve(string &key){
	int i;
	vector<string> &z=m[key];
	for(i=0;i<z.size();i++)
		if(m.find(z[i])==m.end())s.insert(z[i]);
		else if(visit.find(z[i])==visit.end()) /////
			visit.insert(z[i]),solve(z[i]); ///// avoid recursive lol
}

main(){
	string str,group,g1,arg;
	int n,i,j;
	for(;cin>>n,n;cout<<s.size()<<endl){
		m.clear();
		s.clear();
		visit.clear();
		for(i=0;i<n;i++){
			cin>>str;
			for(j=0;j<str.length();j++)if(str[j]==':'||str[j]==','||str[j]=='.')str[j]=' ';
			istringstream is(str);
			vector<string>v;
			is>>group;
			if(!i)g1=group;
			for(;is>>arg;)v.push_back(arg);
			m[group]=v;
		}
		visit.insert(g1),solve(g1);
	}
}

Measured memory_bytes: 1372
import sys
#import time
from collections import deque, Counter, defaultdict
#from fractions import gcd
import bisect
#import heapq
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n = ri()
l = rl()

l.sort()
ans=0
for i in range(n):
    for j in range(i):
        ans+=bisect.bisect_left(l, l[i]+l[j])-(i+1)
print(ans)

Measured memory_bytes: 83496
import java.util.*;

public class Main {
    public static void main(String[] args){
        
        Scanner scanner = new Scanner(System.in);
        long A = scanner.nextLong();
        long B = scanner.nextLong();
        long K = scanner.nextLong();
        
        if(A>=K){
            System.out.println(A-K);
            System.out.println(B);
        }else if(A<K && A+B>K){
            System.out.println(0);
            System.out.println(B-(K-A));
        }else{
            System.out.println(0);
            System.out.println(0);
        }
        
    }
}


Measured memory_bytes: 22996
def read_input():
    n = int(input())
    alist = list(map(int, input().split()))

    return n, alist

def submit():
    n, alist = read_input()

    four_multiple = sum([1 for a in alist if a % 4 == 0])
    two_multiple = sum([1 for a in alist if a % 4 != 0 and a % 2 == 0])

    if n // 2 <= four_multiple:
        print('Yes')
        return

    n -= 2 * four_multiple
    if n <= two_multiple:
        print('Yes')
        return

    print('No')




if __name__ == '__main__':
    submit()

Measured memory_bytes: 63640
#include <stdio.h>
	int main()
	{
		int S,h,m,s;
		scanf("%d",&S);
		h=S/3600;
		m=(S-3600*h)/60;
		s=S-3600*h-60*m;
		printf("%d:%d:%d\n",h,m,s);
		return 0;
}



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

int main(){
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    vector<int>X(n+1);
    vector<int>Y(m+1);

    for(int i=0; i<n; i++){
        cin >> X[i];
    }
    X[n]=x;

    for(int i=0; i<m; i++){
        cin >> Y[i];
    }
    Y[m]=y;

    sort(X.begin(),X.end());
    sort(Y.begin(),Y.end());

    if(abs(X[n]-Y[0])<1){
        cout << "War" << endl;
        return 0;
    }

    if(X[n]>Y[0]){
        cout << "War" << endl;
        return 0;
    }

    cout << "No War" << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){
  int n, a, b;
  string str;
  cin >> str;
  if(str> "2019/04/30")cout << "TBD\n";
  else cout <<"Heisei\n";
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const long long MOD = 1000000007;

void func(int n, long long m, vi oks) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);

    vll dp(n + 1);
    dp[0] = 1;                           //０段目は確実に１通り
    for (int now = 0; now < n; now++) {  //０段から見ていく
        for (int next = now + 1; next <= min(now + 2, n); next++) {
            // 次の段か次の次の段をみる、もしくは最大値まで
            if (oks[next]) {          //次に進めるのならば
                dp[next] += dp[now];  //今までの累積を次に渡す。
                dp[next] %= mod;  //巨大になりすぎる前にmodしておく。
            }
        }
    }
    cout << dp[n] << endl;
}

int main() {
    int N;
    scanf("%d", &N);
    long long M;
    scanf("%lld", &M);
    vi oks(N + 1, true);  // ok step ＝壊れていない段
    for (int i = 0; i < M; i++) {
        int a;
        cin >> a;
        oks[a] = false;  // 壊れている段を入力
    }
    func(N, M, std::move(oks));
    return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int N, T;

vector<pair<int, int>> AB;
int dp[3000 + 10][3000 + 10];

int main() {
	cin >> N >> T;
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		AB.push_back(make_pair(a, b));
	}
	
	sort(AB.begin(), AB.end());
	
	int ans = 0;
	dp[0][0] = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= T - 1; j++) {
			dp[i][j] = dp[i - 1][j];
			ans = max(ans, dp[i][j] + AB[i - 1].second);
			if (j - AB[i - 1].first >= 0)
				dp[i][j] = max(dp[i][j], dp[i - 1][j - AB[i - 1].first] + AB[i - 1].second);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for (int i=0; i<(n); ++i)
#define rrep(i,n) for (int i=1; i<=(n); ++i)
#define drep(i,n) for (int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for (int i=s; i<t; ++i)
#define pi (acos(-1))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int, int> P;
const int INF = 1001001001;
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 gcd (ll a, ll b) {
  return b ? gcd(b, a%b) : a;
}
ll lcm (ll a, ll b) {
  return a/gcd(a,b)*b;
}
int main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int x;
	cin >> x;
	if(x>=400 && x<=599) cout << 8 << endl;
	else 	if(x>=600 && x<=799) cout << 7 << endl;
	else 	if(x>=800 && x<=999) cout << 6 << endl;
	else 	if(x>=1000 && x<=1199) cout << 5 << endl;
	else 	if(x>=1200 && x<=1399) cout << 4 << endl;
	else 	if(x>=1400 && x<=1599) cout << 3 << endl;
	else 	if(x>=1600 && x<=1799) cout << 2 << endl;
	else 	if(x>=1800 && x<=1999) cout << 1 << endl;
	return 0;
}










	


Measured memory_bytes: 3608
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String s = scan.nextLine();
    char a = s.charAt(0);
    for(int i = 1; i < 4; i++) {
      if (a == (s.charAt(i))) {
        System.out.println("Bad");
        return;
      }
      a = s.charAt(i);
    }
    System.out.println("Good");
    return;
  }
}
  


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define per(i, n) for(int i = (n)-1; i >= 0; --i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 
#define cop(a) for(auto x:(a)){cout << x << endl;}

using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

constexpr char sp = ' ';
constexpr char cmm = ',';
constexpr int MOD = 1e9+7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s<<'[';for(size_t i=0;i<v.size();++i){s << v[i];if(i < v.size()-1) s << ", ";}s<<']';return s;
}
struct __f{
    __f(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    }
};


vector<vector<int>> G;
vector<int> ans;
vector<int> e;

void dfs(int i){
    int m = 0;
    for(auto c : G[i]){
        if(ans[i] == ++m) ++m;
        ans[c] = m;
        dfs(c);
    }
}

int main(){

    int n;
    scanf("%d", &n);
    G.resize(n);
    ans.resize(n, 0);
    e.resize(n-1);

    rep(i, n-1){
        int a, b;
        scanf("%d%d", &a, &b);  
        --a; --b;
        G[a].emplace_back(b);
        e[i] = b;
    }
    
    dfs(0);

    ppp(*max_element(ans.begin(), ans.end()));
    for(int edge : e)
        ppp(ans[edge]);
    

    return 0;
}


Measured memory_bytes: 6784
package main

import (
	"fmt"
)

func minInt(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)

	cumSum := make([]int, n+1)
	cumSum[0] = 0
	for i := 0; i < n; i++ {
		if s[i:i+1] == "#" {
			cumSum[i+1] = cumSum[i] + 1
		} else {
			cumSum[i+1] = cumSum[i]
		}
	}

	minAns := n
	for i := 0; i <= n; i++ {
		ans := cumSum[i] + ((n - i) - (cumSum[n] - cumSum[i]))
		minAns = minInt(minAns, ans)
	}
	fmt.Println(minAns)
}


Measured memory_bytes: 3584
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#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 pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  int n = (int)s.length();
  for (char c = 'a'; ; c += 1) {
    vi ind;
    rep (i, n) {
      if (s[i] == c) {
        ind.push_back(i);
      }
    }
    int m = (int)ind.size();
    set<string> q;
    FOR (i, 1, 6) {
      rep (j, m) {
        if (ind[j] + i > n) {
          break;
        }
        q.insert(s.substr(ind[j], i));
      }
    }
    if ((int)q.size() < k) {
      k -= (int)q.size();
      continue;
    }
    string ans;
    rep (i, k) {
      ans = *begin(q);
      q.erase(begin(q));
    }
    cout << ans << "\n";
    return 0;
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
rlist = []
for i in range(n):
    r = int(input())
    rlist.append(r)
mlist = [rlist[1] - rlist[0]]
mini = rlist[0]
for i in range(1,n):
    if(rlist[i-1] < mini):
        mini = rlist[i-1]
    m = rlist[i] - mini
    if(m>mlist[-1]):
        mlist.append(m)
print(mlist[-1])
    
    


Measured memory_bytes: 13668
import java.util.ArrayList;
import java.util.Scanner;
import java.lang.Math.*;

public class Main {

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

		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			val[i] = a;
			if (i == 0) {
				cost[0] = 0;
			} else if (i == 1) {
				cost[1] = Math.abs(val[1] - val[0]);
			} else {
				cost[i] = Math.min(cost[i - 1] + Math.abs(val[i] - val[i - 1]),
						cost[i - 2] + Math.abs(val[i] - val[i - 2]));
			}
		}

		System.out.println(cost[n - 1]);
	}

}


Measured memory_bytes: 60100
def main():
    S = input()
    w1 = 'dream'[::-1]
    w2 = 'dreamer'[::-1]
    w3 = 'erase'[::-1]
    w4 = 'eraser'[::-1]
    # print(w1,w2,w3,w4)
    S = S[::-1]
    # print(S)

    # words = ['dream', 'dreamer', 'erase', 'eraser']
    words = [w1, w2, w3, w4]
    T = ''
    while S != T:
        cand = []
        for w in words:
            new_t = T + w
            cand.append(new_t) 
        # print('cand', cand)
        ans = False
        for c in cand:
            if c == S[:len(c)]:
                T = c
                ans = True

        if not ans:
            break

    if S == T:
        print('YES')
    else:
        print("NO")

if __name__ == "__main__":
    main()

Measured memory_bytes: 3936
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
using namespace std;
typedef int64_t ll;
typedef vector<ll> vll;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll N;
        in >> N;
        vll p(N);
        rep(i, N) {
            in >> p[i];
        }
        ll ans = 0;
        rep(i, N-1) {
            if (i+1 == p[i]) {
                ans++;
                swap(p[i], p[i+1]);
            }
        }
        if (N == p[N - 1]) {
            ans++;
        }
        out << ans << '\n';
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


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

int n;
vector<pair<int, int> > v;

bool use[202];
long long int p2[202];
#define MOD 998244353
int main(){
	p2[0] = 1;
	for (int i = 1; i < 202; i++){
		p2[i] = p2[i - 1];
		p2[i] *= 2;
		if (p2[i] >= MOD){
			p2[i] %= MOD;
		}
	}
	cin >> n;
	for (int i = 0; i < n; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		v.push_back(make_pair(a, b));
	}
	long long int ng = 0;
	for (int i = 0; i < n; i++){
		ng++;
		memset(use, false, sizeof(use));
		for (int j = i + 1; j < n; j++){
			int cnt = 1;
			if (use[j])continue;
			use[j] = true;
			pair<long long int, long long int> vec = make_pair(v[j].first - v[i].first, v[j].second - v[i].second);
			for (int k = j+1; k < n; k++){
				pair<long long int, long long int> vec2 = make_pair(v[k].first - v[i].first, v[k].second - v[i].second);
				if (vec.first*vec2.second == vec.second*vec2.first){
					use[k] = true;
					cnt++;
				}
			}
			long long int way = p2[cnt];
			way += MOD - 1;
			if (way >= MOD)way %= MOD;
			ng += way;
			if (ng >= MOD)ng %= MOD;
		}
	}
	long long int ALL = p2[n] + MOD - 1 + MOD - ng;
	ALL %= MOD;
	printf("%lld\n", ALL);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c,d,e,k,ans;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&d);
  scanf("%d",&e);
  scanf("%d",&k);
  
  ans = e - a;
               	
  if(ans <= k){
    printf("Yay!");
  }else{
    printf(":(");
  }
  return 0;
  
}



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

int main(){
	int N;
	string s;
	int A,B,C,D;
	cin >>N>>A>>B>>C>>D>>s;
	bool aa=false;
	bool bb=false;
	string s1=s.substr(B-2,D-B+3);
	string s2=s.substr(A-1,max(C,D)-A+2);
	for(int i=1;i<s1.length();i++){
		if(s1[i-1]=='.'&&s1[i]=='.'&&s1[i+1]=='.')
			bb=true;
	}
	
	for(int i=0;i<s2.length();i++){
		if(s2[i]=='#'&&s2[i+1]=='#')
			aa=true;
	}
	
	if(aa)cout << "No"<<endl;
	else if(C<D)cout << "Yes"<<endl;
	else if(C>D && bb)cout << "Yes"<<endl;
	else cout << "No"<<endl;
}


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

int main(){
    int a,b,c,d,k;
    cin >> a >> b >> c >> d >> k;
    int x = a*60+b;
    int y = c*60+d;
    cout << y - x - k;
}

Measured memory_bytes: 3600
n, m = list(map(int, input().split()))
p, s = [], []
for i in range(m):
    ps = list(input().split())
    p.append(int(ps[0]))
    s.append(ps[1])
ac_list = [0 for i in range(n)]
wa_list = [0 for i in range(n)]
for i in range(m):
    if s[i] == "AC":
        ac_list[p[i] - 1] = 1
    else:
        if ac_list[p[i] - 1] == 0:
            wa_list[p[i] - 1] += 1
for i in range(n):
    if ac_list[i] == 0:
        wa_list[i] = 0
print(*[sum(ac_list), sum(wa_list)])


Measured memory_bytes: 14920
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n;
double d,x,ans;
int main(){
    scanf("%d%lf%lf",&n,&d,&x);
    while(n){
        ans+=d+x*(n-0.5);
        d=((n*2.0+2.0)*d+5.0*x)/(n*2.0);
        x=(n+2.0)*x/(n*1.0);
        --n;
    }
    printf("%.15lf\n",ans);
    //system("pause");
    return 0;
}


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

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

using namespace std;

void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	long long int x, t=0;
	vector<long long int> v;

	cin>> x;

	while (t*t*t*t*t / t / t / t / t / t == 1) {
		v.push_back(t*t*t*t*t);
		//cout << t * t*t*t*t << endl;
		auto itr = lower_bound(v.begin(), v.end(), x - t * t*t*t*t);
		if (*itr == x - t * t*t*t*t) {
			cout << t SP << -1*(itr - v.begin()) <<endl;
			return 0;
		}
		auto itr2 = lower_bound(v.begin(), v.end(), t * t*t*t*t-x);
		if (*itr2 == t * t*t*t*t-x) {
			cout << t SP << itr2 - v.begin() << endl;
			return 0;
		}
		t++;
	}

	return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#include <atcoder/all>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int N, M;
	cin >> N >> M;
	mcf_graph<int, ll> g(N * M + 2);
	int s = N * M, t = N * M + 1;
	vector<string> S(N);
	ll ans = 0;
	rep(i, N) {
		cin >> S[i];
		rep(j, M) {
			if (S[i][j] == 'o') {
				g.add_edge(s, i * M + j, 1, 0);
				ans += (InfL - i - j);
			}
		}
	}
	rep(i, N) {
		rep(j, M) {
			if (i != N - 1) {
				if (S[i][j] != '#' && S[i + 1][j] != '#')
					g.add_edge(i * M + j, (i + 1) * M + j, InfL, 0);
			}
			if (j != M - 1) {
				if (S[i][j] != '#' && S[i][j + 1] != '#')
					g.add_edge(i * M + j, i * M + (j + 1), InfL, 0);
			}
		}
	}
	rep(i, N) {
		rep(j, M) {
			if (S[i][j] != '#')
				g.add_edge(i * M + j, t, 1, InfL - i - j);
		}
	}
	auto cc = g.flow(s, t);
	ans -= cc.second;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4248
#include<iostream>
using namespace std;
int main(){
  int a[31]={},i,b;
    for(i=0;i<28;i++){
      cin>>b;
      a[b]=1;
    }
    for(i=1;i<=30;i++)
      if(a[i]!=1)
	cout<<i<<endl;
    return 0;
  }

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
const ll MOD = (1e+9)+7;
typedef pair<ll, ll> LP;
 
ll POW(ll m,ll n)
{
  if(n<0) return 0;
  if(n==0) return 1;
  return m*POW(m,n-1)%MOD;
}
 
int main()
{
  ll n,k,g,l;
  cin >> n >> k;
  if(k%2==1){g=n/k;
             printf("%lld",g*g*g);
            }
  else {g=n/k;
        k/=2;
        l=n/k;
         printf("%lld",g*g*g+(l-g)*(l-g)*(l-g)); 
            }
}

Measured memory_bytes: 256
s = input().strip()

a = ""
a_cnt = 0
b = ""
b_cnt = 0
flg = True

for e in s:
    if (a == ""):
        a = e
        a_cnt += 1
    elif (a == e):
        a_cnt += 1
    elif (b == ""):
        b = e
        b_cnt += 1
    elif (b == e):
        b_cnt += 1

if (a_cnt == 2 and b_cnt == 2):
    print("Yes")
else:
    print("No")


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

constexpr ll INF = ll(1e+18) + 1;

ll dist(ll a, ll b, ll c, ll d) {
    return abs(a-c) + abs(b-d);
}

int main() {
    int N, M;
    vector<pair<ll, ll>> stu, point;
    ll buf1, buf2;

    cin >> N >> M;

    rep (i, N) {
        cin >> buf1 >> buf2;
        stu.push_back(make_pair(buf1, buf2));
    }

    rep (i, M) {
        cin >> buf1 >> buf2;
        point.push_back(make_pair(buf1, buf2));
    }

    ll ans, count, near_dist;
    for (pair<ll, ll> s: stu) {
        ans = 0;
        count = 0;
        near_dist = INF;
        for (pair<ll, ll> p : point) {
            ll tmp = dist(s.first, s.second, p.first, p.second);
            if (near_dist > tmp) {
                ans = count+1;
                near_dist = tmp;
            }
            count++;
        }
        cout << ans << endl;
    }

}


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

int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a+b==3) printf("3\n");
	if(a+b==5) printf("1\n");
	if(a+b==4) printf("2\n");
	return 0;
} 

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const int MAXN=200000+5;
int a[MAXN+5];
int n,x;
int main()
{
	scanf("%d%d",&n,&x);
	if(x==1||x==2*n-1)
	{
		printf("No\n");
	}
	else
	{
		a[n-2]=x-1;
		a[n-1]=x;
		a[n]=x+1;
		int now=1;
		for(int i=0;i<2*n-1;i++)
		{
			if(!a[i])
			{
				while(abs(now-x)<=1)
					now++;
				a[i]=now++;
			}
		}
		printf("Yes\n");
		for(int i=0;i<2*n-1;i++)
			printf("%d\n",a[i]);
	}
	return 0;
}


Measured memory_bytes: 2304
#include<stdio.h>
#include<stdlib.h>
int cmp(const int *a,const int *b){
  return *a-*b;
}
int main(){
  int a[5],ans;
  scanf("%d%d%d",&a[0],&a[1],&a[2]);
  qsort(a,3,4,cmp);
  if(a[0]%2==a[1]%2){
    ans=(a[1]-a[0])/2+a[2]-a[1];
  }
  else {
    ans=(a[2]-a[0])/2+(a[2]-a[1])/2+2;
  }
  printf("%d",ans);
}

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


const int MAX=80*80*80+1;
bool dp[81][81][6401];
int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<int>> ma, m;
  for (int i = 0; i < h; ++i) {
    vector<int> tmp;
    for (int j = 0; j < w; ++j) {
      int a;
      cin >> a;
      tmp.push_back(a);
    }
    ma.push_back(tmp);
  }
  for (int i = 0; i < h; ++i) {
    vector<int> tmp;
    for (int j = 0; j < w; ++j) {
      int b;
      cin >> b;
      tmp.push_back(abs(ma[i][j]-b));
      // cerr << i << " " << j << " " << tmp[j] << endl;
    }
    m.push_back(tmp);
  }
  dp[0][0][0] = true;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      for (int k = 0; k <= 6400; ++k) { 
        if (!dp[i][j][k]) continue;
        int nex = k+m[i][j];
        // cerr << i << " " << j << " " << k << " " << nex << endl;
        if (nex <= 6400) {
          dp[i+1][j][nex] = true;
          dp[i][j+1][nex] = true;
        }
        int nex2 = abs(k-m[i][j]);
        dp[i+1][j][nex2] = true;
        dp[i][j+1][nex2] = true;
      }
    }
  }
  int ans = 6400;
  for (int k = 0; k < 6400; ++k) { 
    if (dp[h-1][w][k]) {
      cout << k << endl;
      return 0;
    }
    if (dp[h][w-1][k]) {
      cout << k << endl;
      return 0;
    }
  }
}



Measured memory_bytes: 41216
#include <iostream>
#include <queue>
#define maxn 1003
#define mp make_pair
#define fi first
#define se second
using namespace std;
string a[maxn];
bool vis[maxn][maxn];
int d[maxn][maxn];
int w[4][2] = {{-1, 0}, {0, -1}, {0, 1}, {1, 0}};
queue < pair <int, int> > q;
int main(){
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; ++ i){
		cin >> a[i];
		for (int j = 0; j < m; ++ j)
			if (a[i][j] == '#'){
				vis[i][j] = true;
				q.push(mp(i, j));
			}
	}
	while (q.size()){
		pair <int, int> p = q.front();
		q.pop();
		for (int i = 0; i < 4; ++ i){
			int x = p.fi + w[i][0], y = p.se + w[i][1];
			if (1 <= x && x <= n && 0 <= y && y < m && ! vis[x][y]){
				vis[x][y] = true;
				d[x][y] = d[p.fi][p.se] + 1;
				q.push(mp(x, y));
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; ++ i)
		for (int j = 0; j < m; ++ j)
			ans = max(ans, d[i][j]);
	cout << ans << endl;
}


Measured memory_bytes: 12432
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

int n, m, ans;
int k[110], p[110], sta[110];
int s[110][110];

void check()
{
    int flag = 1;
    for (int i = 1; i <= m; ++i)
    {
        int f = 0;
        for (int j = 1; j <= k[i]; ++j)
        {
            f += sta[s[i][j]];
        }
        if (f % 2 != p[i])
        {
            flag = 0;
            break;
        }
    }
    ans += flag;
}

void dfs(int dep)
{
    if (dep > n)
    {
        check();
        return;
    }
    sta[dep] = 1;
    dfs(dep + 1);
    sta[dep] = 0;
    dfs(dep + 1);
}

int main()
{
    std::ios::sync_with_stdio(0), std::cin.tie(0), std::cout.tie(0);
    std::cin >> n >> m;
    for (int i = 1; i <= m; ++i)
    {
        std::cin >> k[i];
        for (int j = 1; j <= k[i]; ++j)
            std::cin >> s[i][j];
    }
    for (int i = 1; i <= m; ++i)
        std::cin >> p[i];
    dfs(1);
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

bool is_prime[1000002];

void Sieve() {
  fill(is_prime, is_prime+1000001, true);
  is_prime[0] = is_prime[1] = false;
  
  for(long long i=2; i<=1000000; i++) {
    if(is_prime[i]) {
      for(long long j=i*i; j<=1000000; j+=i)
	is_prime[j] = false;
    }
  }
}

int main() {
  int a, d, n;
  
  Sieve();
  
  while(cin >> a >> d >> n && (a|d|n)) {
    int cnt = 0;
    for(int i=a; i<=1000000; i+=d) {
      if(is_prime[i]) cnt ++;
      if(cnt == n) {
	cout << i << endl;
	break;
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 2136
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


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

int h,m,H,M,k;
cin >> h >> m >> H >> M >> k;

m += h*60;
M += H*60;

cout << M - m - k << endl;

return 0;
}

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

int chair(string s_){
	if(s_ == "Vacant"){
		return 0;
	}
	if(s_ == "Male"){
		return 1;
	}
	return 2;
}

int main(void){
	int n;
	cin >> n;
	int q, l, r;
	string s[3];


	cout << 0 << endl << flush;
	cin >> s[0];
	if(!chair(s[0])){
		return 0;
	}
	cout << n/2 << endl << flush;
	cin >> s[1];
	if(!chair(s[1])){
		return 0;
	}
	cout << n-1 << endl << flush;
	cin >> s[2];
	if(!chair(s[2])){
		return 0;
	}

	if((s[0] == s[1] && (n/2)%2==1) || (s[0] != s[1] && (n/2)%2 == 0)){
		//左
		l = 0; r = n/2;
		s[2] = s[1];
	}else{
		//右
		l = n/2; r = n-1;
		s[0] = s[1];
	}

	while(true){
		q = (l + r) / 2;
		cout << q << endl << flush;
		cin >> s[1];
		if(!chair(s[1])){
			break;
		}
		if((s[0] != s[1] && (q-l)%2==0) || (s[0] == s[1] && (q-l)%2==1) ){
			//左
			r = q;
			s[2] = s[1];
		}else{
			//右
			l = q;
			s[0] = s[1];
		}
		//if(r-l <= 1) break;
	}
	if(!chair(s[1])){
		return 0;
	}
	if(r != n){
		cout << r << endl << flush;
		cin >> s[1];
		if(!chair(s[1])){
			return 0;
		}
	}
	cout << l << endl << flush;
	cin >> s[1];
	if(!chair(s[1])){
		return 0;
	}
	return 0;
}

Measured memory_bytes: 976
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define vec vector
#define psb push_back
#define ppb pop_back
#define mkp make_pair
#define fst first
#define scd second
#define ins insert
#define psf push_front
#define ppf pop_front
using namespace std;
ll modExp(ll a, ll b, ll c) {
	a %= c;
	ll ans = 1;
	for(; b; b >>= 1) {
		if(b & 1){
			ans *= a;
			ans %= c;
		}
		a *= a;
		a %= c;
	}
	return ans;
}
int main() {
	ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll n, i, x, j, ans = 0, modv = 1e9+7;
	cin >> n;
	ll bit[64] = {0};
	for(i = 0; i < n; i++) {
		cin >> x;
		j = 0;
		while(x) {
			bit[j] += (x & 1);
			x >>= 1;
			j++;
		}
	}
	for(i = 0; i < 64; i++) {
		ans += (((ll)1) << i) % modv * bit[i] % modv * (n - bit[i]) %modv;
		ans %= modv;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <math.h>
#include <iostream>
#include <set>

using namespace std;

int main(){

  set<string> items;
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    string a;
    cin >> a;
    items.insert(a);
  }

  cout << items.size() << endl;
  
  return 0;
}


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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  int N;

  string A,B,C;

  cin>>N;

  cin>>A>>B>>C;

  int cnt=0;
  
  for(int i=0;i<N;i++){
    if(!(A[i]==B[i]&&B[i]==C[i])){
      if(A[i]==B[i]){
	cnt++;
      }else if(B[i]==C[i]){
	cnt++;
      }else if(A[i]==C[i]){
	cnt++;
      }else{
	cnt+=2;
      }
    }
  }
       
  cout<<cnt<<endl;
    
  return 0;

}


Measured memory_bytes: 256
#include <stdio.h>


int main(void){
	int n;
	scanf("%d",&n);
	char s1[n],s2[n];
	scanf("%s", s1);
	scanf("%s", s2);

	long long exp=1;
	int leftis2=0;//横
	int leftis1=0;//縦
	for(int i=0;i<n;i++){
		if(s1[i]==s2[i]){//縦　leftis1=1なら2通り　leftis2=1なら1通り
			if(leftis1==1){exp*=2;}
			else if(leftis2==1){exp*=1;}
			else{exp*=3;}
			leftis1=1;
			leftis2=0;
		}
		else{//横　leftis1=1なら2通り　leftis2=1なら3通り
			if(leftis1==1){exp*=2;}
			else if(leftis2==1){exp*=3;}
			else{exp*=6;}
			leftis1=0;
			leftis2=1;
			i++;
		}
		if(exp>1000000008) exp=exp%1000000007;
	}
	printf("%lld",exp);
	return 0;
} 

Measured memory_bytes: 128
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <chrono>
#include <queue>
#include <string>
#include <cassert>
#include <bitset>
#include <stack> 
#include <unordered_set>

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define BASE 77747
#define PI acos(-1.0)
#define MAXLEN 29

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef vector <ll> vll;

int n, m;
pair <ll, ll> t[800000];
pii arr[200000];

void add(int v, int l, int r, int wl, int wr, ll val) {
	if (wl > wr) return;
	if (wl == l && wr == r) {
		t[v].second += val;
		t[v].first += val;
		return;
	}
	int mid = (l + r) / 2;
	add(2 * v, l, mid, wl, min(mid, wr), val);
	add(2 * v + 1, mid + 1, r, max(mid + 1, wl), wr, val);
	t[v].first = max(t[2 * v].first, t[2 * v + 1].first) + t[v].second;
}

void setValue(int v, int l, int r, int index, ll val) {
	if (l == r) {
		t[v].first = val + t[v].second;
		return;
	}
	int mid = (l + r) / 2;
	if (index <= mid) setValue(2 * v, l, mid, index, val);
	else setValue(2 * v + 1, mid + 1, r, index, val);
	t[v].first = max(t[2 * v].first, t[2 * v + 1].first) + t[v].second;
}
ll getMax(int v, int l, int r, int wl, int wr) {
	if (wl > wr) return -INFLL;
	if (wl == l && wr == r) return t[v].first;
	int mid = (l + r) / 2;
	ll le = getMax(2 * v, l, mid, wl, min(mid, wr));
	ll ri = getMax(2 * v + 1, mid + 1, r, max(wl, mid + 1), wr);
	return max(le, ri) + t[v].second;
}

struct Point {
	int val;
	ll pp;
	bool isEnd;
	int ind;
};

Point all[400000];

bool cmp(Point a, Point b) {
	if (a.val != b.val) return a.val < b.val;
	if (a.isEnd != b.isEnd) return !a.isEnd;
	return false;
}

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++) {
		ll pp;
		scanf("%d %d %lld", &arr[i].first, &arr[i].second, &pp);
		arr[i].first--;
		arr[i].second--;

		all[2 * i].val = arr[i].first;
		all[2 * i].isEnd = false;
		all[2 * i].ind = i;
		all[2 * i].pp = pp;
		all[2 * i + 1].val = arr[i].second;
		all[2 * i + 1].isEnd = true;
		all[2 * i + 1].ind = i;
		all[2 * i + 1].pp = pp;
	}
	sort(all, all + 2 * m, cmp);
	// for (int i = 0; i < 2 * m; i++) {
	// 	cout << all[i].val << " " << all[i].ind << " " << all[i].pp;
	// 	cout << " " << all[i].isEnd << endl;
	// }
	int index = 0;
	ll cur = 0;
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		while (index < 2 * m  && i == all[index].val && !all[index].isEnd) {
			cur += all[index].pp;
			add(1, 0, n - 1, arr[all[index].ind].first, arr[all[index].ind].second, -all[index].pp);
			index++;
		}
		ll cc = max(0LL, getMax(1, 0, n - 1, 0, i - 1)) + cur;
		setValue(1, 0, n - 1, i, cc);
		ans = max(ans, cc);
		while (index < 2 * m  && i == all[index].val) {
			cur -= all[index].pp;
			add(1, 0, n - 1, arr[all[index].ind].first, arr[all[index].ind].second, all[index].pp);
			index++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 20736
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[364364]={};
    long long int ans=0;
    for(int i=0;i<3*n;i++){
        cin>>a[i];
    }
    sort(a,a+(3*n),greater<int>());
    for(int i=1;i<=2*n-1;i+=2){
        ans+=a[i];
    }
    cout<<ans<<endl;
}   




Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long 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 {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= 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 {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////
int main() {
	ll N;
	cin >> N;
	ll ans = 0;
	repn(i, N) {
		ll a;
		cin >> a;
		if (a % 2 == 1 && i % 2 == 1) { ans++; }
	}
	cout << ans << endl;
}

Measured memory_bytes: 3584
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }




// ***************************************


int main(){

    int N, K;
    cin >> N >> K;

    vector<int> A(N+1);

    REP(i, K){
        int d;
        cin >> d;
        REP(j, d){
            int x;
            cin >> x;
            A[x]++;
        }
    }

    int ans = 0;
    FOR(i, 1, N + 1){
        if (A[i] == 0) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a;
	cin>>a;
	int b[a+1];

	for(int i=1;i<=a;i++)
	{
		cin>>b[i];
	}
for(int j=1;j<=a;j++)
{
	for(int i=2;i<=a;i++)
	{
		if(b[i]<b[i-1])
		swap(b[i],b[i-1]);
	}
}
	

	cout<<b[a]-b[1];

	return 0;
}

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

void Main() {
    // input
    u_int32_t N;
    u_int64_t K;
    cin >> N >> K;
    u_int32_t A[N+1];
    u_int32_t B[N+1];
    for (u_int32_t i = 1; i <= N; i++) {
        cin >> A[i];
        B[i] = -1;
    }


    // translate

    // どこかに必ず閉路は存在する
    u_int32_t now_city = 1;
    B[1] = 0; // 訪れた
    u_int32_t count = 1;
    for (u_int32_t k = 1; k <= K; k++) {
        now_city = A[now_city];
        // cout << "now:" << now_city << endl;
        if (B[now_city] == -1) {
            B[now_city] = count;
        } else {
            u_int32_t loop_size = count - B[now_city];
            // cout << "loop_size: " << loop_size << endl;
            u_int32_t loop_num = (K - k) % loop_size;
            for (u_int32_t l = 0; l < loop_num; l++) {
                now_city = A[now_city];
            }
            break;
        }
        count++;

    }


    // output
    cout << now_city << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 5184
from collections import Counter

n,k=map(int,input().split())
l=list(map(int,input().split()))

l=Counter(l)

if len(l) <= k:
  ans=0
else:
  sl=sorted(list(l.values()))
  num=len(l)-k
  ans=sum(sl[:num])
  
print(ans)

Measured memory_bytes: 35136
#include <bits/stdc++.h>
using namespace std;
#define intMax 2147483647
#define longMax 9223372036854775807
#define ll long long
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>
#define vii vector<pair<int,int>>
#define ii pair<int, int>
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repp(i, a, b) for (int i = a; i >= b; i--)
#define be(x) x.begin(), x.end()
#define rbe(x) x.rbegin(), x.rend()
#define pb push_back
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    ll x=n*n;
    x-=n;
    x/=2;
    cout<<x;   
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int flag=0;
    for (int i=0;i<4;i++)
    {
        if(s[i] == s[i+1]){
            flag = 1;
        }
    }
    cout << (flag == 1 ? "Bad":"Good") << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/rope>
#define VALHALLA cin.tie(0);ios_base::sync_with_stdio(false);cout<<fixed<<setprecision(13);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) (int)x.size()
#define fast(map_name) map_name.reserve(1024);map_name.max_load_factor(0.25);
using namespace std;
using namespace __gnu_cxx;
typedef long long int ll;
typedef pair<int,int> ii;
typedef complex<double> point;
const double epsilon=1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mod=1e9+7;
/* VARIABLE DECLARATION START */
/*  FUCNTION TEMPLATE STARTS  HERE */

double dot(point a,point b){ return (conj(a)*b).real() ; }
double cross(point a,point b){ return (conj(a)*b).imag() ; }
double dist(point a, point b){ return abs(a-b); }
struct neal {
static uint64_t splitmix64(uint64_t x)
 {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const
 {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
}
};
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
bool isprime(ll n) {
    if (n == 2 || n == 3) return true;
    if (n < 2 || n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 6; (i - 1) * (i - 1) <= n; i += 6) {
        if (n % (i - 1) == 0 || n % (i + 1) == 0) {
            return false;
        }
    }
    return true;
}
inline ll exp(ll a, ll b, ll mod) {
    ll n = 1;
    ll p = a;
    while (b > 0) {
        if (b % 2 == 1) {
            n *= p;
            n %= mod;
        }
        p *= p;
        p %= mod;
        b /= 2;
    }
    return n;
}

inline bool comp(double a,double b)
{
  return (fabs(a-b)<epsilon);
}
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}


/*  FUCNTION TEMPLATE ENDS HERE */
int main()
{
   VALHALLA
   int a,b,h;
   cin>>a>>b>>h;
   h/=2;
   cout<<(a+b)*h<<endl;


}


Measured memory_bytes: 256