akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	int n, ans = 0;
	ll d;
	cin >> n >> d;
	for(int i = 0; i < n; i++) {
		ll u, v;
		cin >> u >> v;
		if(u * u + v * v <= d * d) ans++;
	}
	cout << ans << '\n';

}



Measured memory_bytes: 3620
N,M=map(int,input().split())
x=[-1]*N
for i in range(M):
    s,c=map(int,input().split())
    if x[s-1]==-1:
        x[s-1]=c
    elif x[s-1]!=c:
        print(-1)
        exit()
if N>=2:
    if x[0]==0:
        print(-1)
        exit()
    if x[0]==-1:
        x[0]=1
else:
    if x[0]==-1:
        x[0]=0
for a in range(N):
    if x[a]==-1:
        x[a]=0

print(*x,sep="")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;

#ifdef DEBUG
     #define debug(args...)            {dbg,args; cerr<<endl;}
#else
    #define debug(args...)              // Just strip off all debug tokens
#endif

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;
const ll mn=1e5+4;
ll a[mn];
ll sell[mn];
int main() 
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll n,t; scanf("%lld %lld",&n,&t);
	for (ll i=0;i<n;i++) scanf("%lld",a+i);
	sell[n-1]=0;
	for (ll i=n-2;i>=0;i--) {
		sell[i]=max(sell[i+1],a[i+1]);
	}
	ll best=0;
	for (ll i=0;i<n;i++) {
		chkmax(best,sell[i]-a[i]);
	}
	ll ans=0;
	for (ll i=0;i<n;i++) {
		//printf("sell:%lld a:%lld best:%lld\n",sell[i],a[i],best);
		if (sell[i]-a[i]==best) ans++;
	}
	printf("%lld\n",ans);
}



Measured memory_bytes: 1792
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()
    A = ['Sunny', 'Cloudy', 'Rainy']

    print(A[(A.index(S) + 1) % 3])
    return


if __name__ == '__main__':
    main()


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

#define REP(i, s, e) for(int i = (int)s; i < (int) e; i++)
#define rep(i, n) REP(i, 0 ,n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define fi first
#define se second
#define pb push_back
#define mp nake_pair

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

string s;
int perseInt(const string& s){
    int ret = 0;
    rep(i, s.size()) ret = ret *10 + (s[i]-'0');
    return ret;
}

struct P{
    int x, y;
    P(){};
    P(int x, int y) : x(x), y(y){};
    int dist(const P& p){
        return abs(x-p.x)+abs(y-p.y);
    }
};
vector<P> ps[2600];

int main(){
    int w, h;
    while(cin>>w>>h && w && h){
        int m = 0;
        P g;
        rep(i, 2600) ps[i].clear();
        rep(i, h) rep(j, w){
            cin>>s;
            if(s == ".") continue;
            else if(s == "S") ps[0].pb({i, j});
            else if(s == "G") g = {i, j};
            else {
                int k = perseInt(s);
                ps[k].pb({i, j});
                m = max(m, k);
            }
        }
        ps[++m].pb(g);
        vector<vi> d(2600, vi(2600, 1e9));
        d[0][0] = 0;
        rep(i, m){
            rep(j, ps[i].size()){
                rep(k, ps[i+1].size()){
                    d[i+1][k] = min(d[i+1][k], d[i][j]+ps[i][j].dist(ps[i+1][k]));
                }
            }
        }
        cout<<d[m][0]<<endl;
    }
}

Measured memory_bytes: 29612
#include <bits/stdc++.h>
#define REP(i, a, b) for (long long i = a; i <= b; ++i)
#define ll long long
using namespace std;

ll a, b;

inline ll read(){
	ll s = 0, w = 1;
	char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

inline void work(){
	a = read(), b = read();
	if (b % 2 == 1 || b > a * 4){
		puts("No");
		exit(0);
	}
	REP(i, 0, a)
		if (i * 2 + (a - i) * 4 == b){
			puts("Yes");
			exit(0);
		}
	puts("No");
}

int main(){
	work();
	return 0;
}

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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c;
	if(a > b){ d = a; a = b; b = d; }
	if(b > c){ d = b; b = c; c = d; }
	if(a > b){ d = a; a = b; b = d; }
	cout << a << " " << b << " " << c << endl;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main() {
  ll x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  ll x3, y3, x4, y4;
  ll dx = x2 - x1;
  ll dy = y2 - y1;
  x3 = x2 - dy;
  y3 = y2 + dx;
  x4 = x1 - dy;
  y4 = y1 + dx;

  printf("%lld %lld %lld %lld\n", x3, y3, x4, y4);
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

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

	vector<int> p(N);
	for (int i = 0; i < N; i++) {
		cin >> p.at(i);
	}

	int count = 0;
	vector<int> q(N);
	for (int i = 0; i < N; i++) {
		q.at(i) = p.at(i);
	}
	sort(q.begin(), q.end());

	for (int i = 0; i < N; i++) {
		if (p.at(i) != q.at(i)) {
			count++;
		}
	}
	if (count == 2 || count == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

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

#define INF (INT_MAX/2)
#define PI (2*acos(0.0))
#define EPS (1e-8)

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int Cost;
struct Edge {
  int src, dst; Cost cost;
  Edge(int s, int d, Cost c) : src(s), dst(d), cost(c) {}
};
typedef vector<Edge>  Edges;
typedef vector<Edges> Graph;
typedef vector<Cost>  Array;
typedef vector<Array> Matrix;

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

pair<vector<Cost>, bool> bellmanFord(const Graph &g, int s) {
  int n = g.size(); const Cost inf = numeric_limits<Cost>::max() / 2;
  Edges es;
  for (int i = 0; i < n; i++) for (auto & e : g[i]) es.emplace_back(e);
  vector<Cost> dist(n, inf); dist[s] = 0;
  bool neg_cycle = false;
  for (int i = 0; ; i++) {
    bool update = false;
    for (auto & e : es) {
      if (dist[e.src] != inf && dist[e.dst] > dist[e.src] + e.cost) {
        dist[e.dst] = dist[e.src] + e.cost;
        update = true;
      }
    }
    if (!update) break;
    if (i > n) { neg_cycle = true; break; }
  }
  return make_pair(dist, neg_cycle);
}

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int v, e, r;
  int s, t, d;
  
  cin >> v >> e >> r;
  
  Graph g(v);
  for (int i = 0; i < e; i++) {
    cin >> s >> t >> d;
    g[s].push_back(Edge(s, t, d));
  }

  vector<Cost> c;
  bool neg_cycle;

  tie(c, neg_cycle) = bellmanFord(g, r);
  
  if (neg_cycle) { cout << "NEGATIVE CYCLE" << endl; return 0; }
  for (int i = 0; i < (int)c.size(); i++) {
    if (c[i] == numeric_limits<Cost>::max() / 2) cout << "INF" << endl;
    else cout << c[i] << endl;
  }
  return 0; 
}

Measured memory_bytes: 3252
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();

        if (s.equals(t.substring(0, t.length() - 1))) {
            System.out.println("Yes");
        } else {
            System.out.println("No");

        }
        sc.close();
    }

}


Measured memory_bytes: 35600
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

int main() {
    int N, M, p, A = 0, W = 0;
    string J;
    cin >> N >> M;
    vector<int> AC(N), WA(N);
    rep(i, N) AC[i] = WA[i] = 0;
    rep(i, M) {
        cin >> p >> J;
        p--;
        if(J == "AC") {
            AC[p] = 1;
        } else if(!AC[p]) {
            WA[p]++;
        }
    }
    rep(i, N) {
        A += AC[i];
        if(AC[i]) W += WA[i];
    }
    cout << A << " " << W << endl;
}

Measured memory_bytes: 4052
def is_guumoji?(str)
  str[0...str.length/2] == str[str.length/2...str.length]
end

# main
str = gets
(1...str.length/2).each{ |i|
  target_str = str[0...-i*2-1]
  if is_guumoji?(target_str)
    puts target_str.length
    break
  end
}

Measured memory_bytes: 1788
#include<iostream>
#include<string>
using namespace std;
int main(){
	string a,b,c;
	cin>>a>>b>>c;
	if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0])cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	double a, b;
	cin >> a >> b;
	cout << (int)(a / b) << "\n";
	cout << (int)((int)a % (int)b) << "\n";
	cout << fixed << setprecision(10)<< (a / b) << "\n";
	return 0;
}

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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> cnt(10);
    cnt[a]++;
    cnt[b]++;
    cnt[c]++;

    for(int i = 1; i <= 9; i++)
    {
        if(cnt[i] == 2)
        {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";

    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))


def z_algorithm(s):
    n = len(s)
    z = [0]*n
    z[0] = n
    i = 1
    j = 0
    while i<n:
        while i+j<n and s[j]==s[i+j]:
            j+=1
        z[i] = j

        if j==0:
            i+=1
            continue

        k = 1
        while k+z[k]<j:
            z[i+k] = z[k]
            k+=1
        
        i+=k
        j-=k
    
    return z

n = readint()
s = readstr()

ans = 0
for i in range(n):
    z = z_algorithm(s[i:])
    for j in range(n-i):
        if z[j]<=j:
            ans = max(ans,z[j])
print(ans)






Measured memory_bytes: 79312
s=input()
import sys
while len(s)>0:
    if s[-5:]=='dream':
        s=s[:-5]
    elif s[-7:]=='dreamer':
        s=s[:-7]
    elif s[-5:]=='erase':
        s=s[:-5]
    elif s[-6:]=='eraser':
        s=s[:-6]
    else:
        print('NO')
        sys.exit()
print('YES')

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


map<int,int> ans;
map<int,int> tmp;
bool finished = false;
vector<bool> is_able_to_use(10,false);


void print_answer(const map<int,int> &mp){
    if(is_able_to_use[9]){
        for(int i = 0; i < ans[6]; i++){
            cout << 9;
        }
        ans[6] = 0;
    }
    if(is_able_to_use[8]){
        for(int i = 0; i < ans[7]; i++){
            cout << 8;
        }
        ans[7] = 0;
    }
    if(is_able_to_use[7]){
        for(int i = 0; i < ans[3]; i++){
            cout << 7;
        }
        ans[3] = 0;
    }
    if(is_able_to_use[6]){
        for(int i = 0; i < ans[6]; i++){
            cout << 6;
        }
        ans[6] = 0;
    }
    if(is_able_to_use[5]){
        for(int i = 0; i < ans[5]; i++){
            cout << 5;
        }
        ans[5] = 0;
    }
    if(is_able_to_use[4]){
        for(int i = 0; i < ans[4]; i++){
            cout << 4;
        }
        ans[4] = 0;
    }
    if(is_able_to_use[3]){
        for(int i = 0; i < ans[5]; i++){
            cout << 3;
        }
        ans[5] = 0;
    }
    if(is_able_to_use[2]){
        for(int i = 0; i < ans[5]; i++){
            cout << 2;
        }
        ans[5] = 0;
    }
    if(is_able_to_use[1]){
        for(int i = 0; i < ans[2]; i++){
            cout << 1;
        }
        ans[2] = 0;
    }
    cout << endl;
}


void dfs(int n, vector<int> &elem){
    if(n==0){
        ans = tmp;
        finished = true;
        return;
    }
    for(int i = 0; i < elem.size(); i++){
        if(n-elem[i]>=0){
            tmp[elem[i]]++;
            if(!finished){
                dfs(n-elem[i], elem);
            }
            tmp[elem[i]]--;

        }
    }
    return;
}

int main(){
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int a;
        cin >> a;
        is_able_to_use[a] = true;
    }
    vector<int> elem;
    if(is_able_to_use[1]){elem.push_back(2);}
    if(is_able_to_use[7]){elem.push_back(3);}
    if(is_able_to_use[4]){elem.push_back(4);}
    if(is_able_to_use[2] || is_able_to_use[3] || is_able_to_use[5]){elem.push_back(5);}
    if(is_able_to_use[6] || is_able_to_use[9]){elem.push_back(6);}
    if(is_able_to_use[8]){elem.push_back(7);}


    dfs(n, elem);
    while(is_able_to_use[9] && ans[5]>=1 && ans[7]>=1){
        ans[5]--; ans[7]--;
        ans[6] += 2;
    }
    while(is_able_to_use[9] && ans[4]>=1 && ans[7]>=1){
        ans[4]--; ans[7]--;
        ans[5]++; ans[6]++;
    }
    print_answer(ans);


    return 0;

}


Measured memory_bytes: 768
#include <stdio.h>
void Search(int);
int S[10000],count=0;
int main(){
	int Slength,Tlength,key;
	int i;


//input S
scanf("%d",&Slength);
for(i=0;i<Slength;i++){
	scanf("%d",&S[i]);
}

//input T
scanf("%d",&Tlength);
for(i=0;i<Tlength;i++){
	scanf("%d",&key);
	Search(key);
}



//output C
printf("%d\n",count);

	return 0;
}


void Search(int key){
int i;
	for(i=0;i<10000;i++){
		if(S[i]==key){
			count++;
			break;
		}
	}

}



Measured memory_bytes: 2108
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const int MAX_N = 100000;
int n, u, v;
vi g[MAX_N];
vi ttoa;

bool dfs1(int x, int p) {
    if (x == u) {
        ttoa.push_back(x);
        return true;
    }

    for (int y : g[x]) {
        if (p == y) continue;
        if (dfs1(y, x)) {
            ttoa.push_back(x);
            return true;
        }
    }

    return false;
}

int depth[MAX_N];
int dfs2(int x, int p) {
    int& res = depth[x];

    for (int y : g[x]) {
        if (p == y) continue;
        chmax(res, dfs2(y, x));
    }
    res++;

    return res;
}

int main() {
    fastio();

    cin >> n >> u >> v;
    u--, v--;
    forn(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    dfs1(v, -1);

    int t = ttoa[ttoa.size() / 2 - 1];
    int a = ttoa[ttoa.size() / 2];
    //cout << t << " " << a << endl;

    for (int x : g[t]) {
        if (x != a)
            dfs2(x, t);
    }

    /*
    forn(i, n)
        printf("depth[%d]=%d\n", i, depth[i]);
*/
    int maxd = 0;
    for (int x : g[t]) {
        if (x == a) continue;
        if (maxd < depth[x]) {
            maxd = depth[x];
        }
    }

    maxd += ttoa.size() / 2 - 1 + ttoa.size() % 2;

    cout << maxd << endl;

    return 0;
}

Measured memory_bytes: 9728
import Foundation
 
let N = Int(readLine()!)!
var array =  readLine()!.componentsSeparatedByString(" ").map { Int($0)! }
var answer = "YES"
array = array.sort()
for i in 0 ..< N - 1 {
  	let diff = array[i] - array[i + 1]
    if  diff == 0 {
        answer = "NO"
    }
}
print(answer)

Measured memory_bytes: 14012
#include <bits/stdc++.h>
#define rep(i, s, e) for(int i = s; i < e; i++)
#define rrep(i, s, e) for(int i = s; i > (s)-(e); i--)
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;



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


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

  if (abs(x-a) < abs(x-b)) pr("A");
  else pr("B");


  return 0;
}


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

int main()
{
	vector<string> x = { "SUN","MON","TUE","WED","THU","FRI","SAT" };
	string s;
	cin >> s;
	for (int i = 0; i < 7; i++) {
		if (s == x[i]) {
			cout << 7 - i << endl;
			break;
		}
	}
}


Measured memory_bytes: 3604
n = int(input())
h = input().split()
h_list = [int(s) for s in h]
cost = [0 for i in range(n)]
for i in range(n):
    if i == 0:
        cost[i] = 0
        continue
    if i == 1:
        cost[i] = abs(h_list[i] - h_list[i - 1])
        continue
    cost[i] = min(cost[i - 1] + abs(h_list[i] - h_list[i - 1]), cost[i - 2] + abs(h_list[i] - h_list[i - 2]))
print(cost[n - 1])

Measured memory_bytes: 17872
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;

int main() {
  int N;
  cin >> N;
  string res[N];
  cout << 0 << endl;
  string s;
  cin >> s;
  int left = -1;
  int right = -1;
  if (s == "Vacant") return 0;
  cout << N - 1 << endl;
  string t;
  cin >> t;
  if (t == "Vacant") return 0;
  res[0] = s;
  res[N - 1] = t;
  left = 0;
  right = N - 1;
  int cnt = 2;
  while (0 == 0) {
    cnt++;
    int mid = (left + right) / 2;
    cout << mid << endl;
    string str;
    cin >> str;
    res[mid] = str;
    if (str == "Vacant") return 0;
    int lr = mid - left + 1;
    int rr = right - mid + 1;
    if ((lr % 2 == 1 && res[mid] != res[left]) || lr % 2 == 0 && res[mid] == res[left]) {
      right = mid;
    } else {
      left = mid;
    }
    if (cnt == 20) {
      return 0;
    }
  }
  return 0;
}

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

int main() {
  int64_t N, K;
  cin >> N >> K;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  vector<int> all(N);
  vector<int> after(N);
  
  for(int i=0; i<N; i++){
    int all_x = 0;
    int after_x = 0;
    for(int j=0; j<N; j++){
      if(vec.at(i) > vec.at(j)){
        all_x++;
        if(i < j){
          after_x++;
        }
      }
    }
    all.at(i) = all_x;
    after.at(i) = after_x;
  }
  int64_t sum_af = 0;
  int64_t sum_all = 0;
  for(int i=0; i<N; i++){
    sum_af += after.at(i);
    sum_all += all.at(i);
  }
  int64_t ans = K*(K-1)/2 %1000000007;
  ans *= sum_all %1000000007;
  ans += sum_af*K;
  ans %= 1000000007;

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef unsigned long long ll;
typedef unsigned int ui;
const ll mod = (ll)(1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
ll bit[1 << 17][2]; int n;
void add(int id,int a, ll w) {
	for (int i = a; i <= n + 1; i += i & -i)bit[i][id] += w;
}
ll sum(int id,int a) {
	ll ret = 0;
	for (int i = a; i > 0; i -= i & -i)ret += bit[i][id];
	return ret;
}
int a[1 << 17][3];
P b[1 << 17];
int main() {
	cin >> n;
	rep(i, 3) {
		rep(j, n) {
			cin >> a[j][i]; a[j][i]--;
		}
	}
	bool f = true;
	rep(i, n) {
		int key = a[i][0]/3;
		rep1(j, 2) {
			if (key != a[i][j] / 3)f = false;
		}
		if (a[i][1] == a[i][0] + 1 && a[i][2] == a[i][0] + 2) {
			b[key] = { i+1,0 };
		}
		else if (a[i][1] == a[i][0] - 1 && a[i][2] == a[i][0] - 2) {
			b[key] = { i+1,1 };
		}
		else f = false;
		if (i % 2 != key % 2)f = false;
		//cout << key << endl;
	}
	if (!f) {
		cout << "No" << endl;
	}
	else {
		ll cnt[2] = {};
		rep(i, n) {
			int k = i % 2;
			cnt[k ^ 1] += b[i].second;
			cnt[k] += (b[i].first-1)/2 - sum(k,b[i].first);
			add(k,b[i].first,1);
			//cout << cnt << endl;
		}
		//cout << cnt[0] << " " << cnt[1] << endl;
		if (cnt[0]% 2==0&&cnt[1]%2==0)cout << "Yes" << endl;
		else cout << "No" << endl;
		//cout << cnt << endl;
	}
	return 0;
}


Measured memory_bytes: 4096
nums = input().split(' ')
# values = []
# for i in range(int(nums[0])):
#     values.append(1)
# for i in range(int(nums[1])):
#     values.append(0)
# for i in range(int(nums[2])):
#     values.append(-1)

one_counts = int(nums[0])
zero_counts = int(nums[1])
mone_counts = int(nums[2])
top = int(nums[3])


if one_counts >= top:
    print(top)
else:
    if one_counts + zero_counts >= top:
        print(one_counts)
    else:
        print(one_counts - (top - (one_counts + zero_counts)))


Measured memory_bytes: 9068
#include <stdio.h>
#define MAX 100000

int binarySearch(int,int);
int S[MAX];

int main(){

  int i,n,q,T,kosu=0;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++) {
    scanf("%d",&T);
    if(binarySearch(T,n)==1) kosu++;
     }
  printf("%d\n",kosu);

  return 0;
}

int binarySearch(int key,int n){

  int i=0,left=0,right=n,mid;

  while(left < right){
    mid = (left + right) / 2;
    if (S[mid] == key)
      return 1;
	    else if (key < S[mid])
	      right = mid;
        else
	  left = mid + 1;
  }
  return 0;
}



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

int N, C, S, A[10009];

int main() {
	cin >> N >> C;
	for (int i = 0; i < C; i++) {
		cin >> A[i]; S += A[i];
	}
	cout << (S + N) / (N + 1) << endl;
	return 0;
}


Measured memory_bytes: 3124
fun main(args: Array<String>) {
    val (n, a, b) = readLine()!!.split(' ').map { it.toLong() }
    val xs = readLine()!!.split(' ').map { it.toLong() }
    (1 until n.toInt())
            .map { i ->
                Math.min(a * (xs[i] - xs[i - 1]), b)
            }
            .sum()
            .let { println(it) }
}


Measured memory_bytes: 57700
#include <iostream>
#include <cmath>
#include <iomanip> 

using namespace std;

int main(){
  double N, K;
  cin >> N >> K;
  
  double answer = 0;
  for(int i = 0; i < N; i++){
    int double_num = 0;
    int init = i+1;
    while(K > init) {
      init *= 2;
      double_num++;	
    }
    double temp = N * pow(2, double_num);
    answer += 1. / temp;
  }
  cout << setprecision(15) << answer;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;

int main(void)
{
	int n,i,e,h[65000];
	unsigned int x,z,a,w;
	while(1){
	  w=0;
		scanf("%d",&n);
		if(n==0) break;
		for(i=0;i<n;i++){
			scanf("%d",&e);
			w+=e;
		}
		for(i=0;i<n-1;i++){
			scanf("%d",&h[i]);
		}
		sort(h,h+n-1,greater<int>());
		x=n*w;
		z=w;
			for(i=0;i<n-1;i++){
				z=z+h[i];
				a=(n-(i+1))*z;
				if(a>x){
					x=a;
				}
			}
		printf("%u\n",x);
	}
	return 0;
}

Measured memory_bytes: 1300
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)998244353
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
const ll N=100005, inf=1e18;
ll pwr(ll base,ll expo){
	ll ans=1;
	rep(i,0,expo)ans*=base;
	return ans;
}
ll f(ll x){
	ll lo = -3000, hi=3000, mid;
	while(hi-lo>1){
		mid=(hi+lo)/2;
		if(pwr(mid,5)<=x)lo=mid;
		else
			hi=mid;
	}
	return lo;
}
void solve(){
	ll x;
	cin>>x;
	rep(i,0,3001){
		ll cur=pwr(i,5)-x;
		if(pwr(f(cur),5)==cur){
			//cout<<"hola\n";
			cout<<i<<" "<<f(cur);
			return;
		}
	}
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0 ;
}


Measured memory_bytes: 3624
#include <stdio.h>

int up[100001], n;

int fd(int u) {
	if (up[u] == 0) return u;
	return up[u] = fd(up[u]);
}

void un(int u, int v) {
	int ru = fd(u), rv = fd(v);
	up[rv] = ru;
}

int a[100001], m;

int main() {
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	while (m--) {
		int u, v;
		scanf("%d %d", &u, &v);
		if (fd(u) != fd(v)) un(u, v);
	}
	int res = 0;
	for (int i = 1; i <= n; i++) {
		if (fd(i) == fd(a[i])) res++;
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 896
import scala.io.StdIn._

object Main extends App {
  val nums: Array[Int] = readLine().split(" ").map(_.toInt)
  val sum: Int = nums(0) + nums(1)
  if (sum % 2 == 0) {
    println(sum / 2)
  } else {
    println(sum / 2 + 1)
  }
}


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

#define pb push_back

#define ll long long

#define ft first

#define sd second

using namespace std;

const int N = 5050 ;

bool used[N];

ll z , r , w ;

ll p = -1 ;

int main(){

    int n ;
    cin >> n ;
    for(int i = 1 ; i <= 9 ; i ++ ){
        for(int j = 1 ; j <= 9 ; j ++ ){
            if(i*j==n){
                cout<<"Yes"<<endl;
                return 0 ;
            }
        }
    }
    cout<<"No"<<endl;
    return 0 ;

}


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

int main(){
  int a,b,c; cin>>a>>b>>c;
  cout<<abs(b-a)+abs(c-a)+abs(b-c)-max(abs(b-a),max(abs(a-c),abs(c-b)))<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define el '\n'
typedef long long ll;
const int MAXH = 1e3+2, MOD = 1e9+7;
int H, W,dp[MAXH][MAXH];
char grid[MAXH][MAXH];
int main(){
	cin.tie(0);
	cin.sync_with_stdio(0);
	cin >> H >> W;
	for(int i = 0;i<H;i++){
		string s; cin >> s;
		for(int j = 0;j<W;j++){
			grid[i+1][j+1] = s[j];
		}
	}
	dp[1][1] = 1;
	for(int i = 1;i<=H;i++){
		for(int j=1;j<=W;j++){
			if(i+1<=H&&grid[i+1][j]!='#')dp[i+1][j] = (dp[i][j]+dp[i+1][j])%MOD;
			if(j+1<=W&&grid[i][j+1]!='#')dp[i][j+1] = (dp[i][j]+dp[i][j+1])%MOD;
		}
	}
	cout << dp[H][W] << el;
	return 0;
}

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

const int mod = 1e9 + 7;
const int N = 900010;
int n, m, k;
ll fac[N], inv[N], p[N];

inline ll read() {
	ll s = 0, f = 1;
	char ch;
	for(; ch < '0' || ch > '9'; ch = getchar())	if(ch == '-')	f = -1;
	for(; ch >= '0' && ch <= '9'; ch = getchar())	s = (s << 1) + (s << 3) + ch - '0';
	return s * f;
}

inline ll quickpow(ll a, ll b) {
    ll re = 1;
    while(b) {
        if(b & 1) re *= a;
        re %= mod;
		b >>= 1;
        a *= a;
        a %= mod;
    }
    return re;
}

inline void init() {
	n = read(), m = read(), k = read();
    fac[0] = 1;
    p[0] = 1;
    for(int i = 1 ; i < N; ++i) {
        fac[i] = fac[i - 1] * i % mod;
        p[i] = p[i - 1] * 3LL % mod;
    }
    for(int i = 0; i < N; ++i) { inv[i] = quickpow(fac[i], mod - 2) % mod; }
}

inline ll C(ll x, ll y) { return (fac[x] * inv[y] % mod * inv[x - y] % mod) % mod; }

inline void work() {
	ll ans = 0, x = 1LL;
    --n;
    if(m < k)	swap(m, k);
    for(int i = 0; i <= m + k; ++i) {
        ans = (ans + C(n + i, n) * p[m + k - i] % mod * x) % mod;
        if(i < k) x = (x * 2LL) % mod;
        else if(i < m) x = (x * 2LL - C(i, k)) % mod ;
        else  x = (x * 2LL - C(i, k) - C(i, m)) % mod ;
    }
    printf("%lld\n", (ans + mod) % mod);
}

int main() {
	init();
    work();
    return 0;
}

Measured memory_bytes: 21376
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
////////////////////////////////////////////////////////////

int main(){
  while(1){
    int N;
    
    C(N);

    if(N == 0)
      break;
    
    int ans = 0;
    
    for(int i = 1 ; i <= N/2 + 1 ; i++ ){
      int sum = i;
      for(int j = i+1 ; j <= N/2 + 5 ; j++){
        sum += j;
        //P(sum);
        if(sum > N)
          break;
        else if(sum == N){
          ans++;
          break;
        }
        else
          continue;
      }
    }
    P(ans);
  }
  ret 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const int MN=2e5+5;
char S[MN],T[MN];
int n,f[MN][2],g[MN][2];
int main(){
	scanf("%s",S+1);n=strlen(S+1);
	memset(f,~0x3f,sizeof(f));
	if(S[1]!='D')f[1][0]=0;
	if(S[1]!='P')f[1][1]=1;
	for(reg int i=2;i<=n;i++){
		if(S[i]!='D'){
			if(f[i-1][0]>f[i-1][1])f[i][0]=f[i-1][0],g[i][0]=0;
			else f[i][0]=f[i-1][1],g[i][0]=1;
		}
		if(S[i]!='P'){
			if(f[i-1][0]+1>f[i-1][1])f[i][1]=f[i-1][0]+2,g[i][1]=0;
			else f[i][1]=f[i-1][1]+1,g[i][1]=1;
		} 
	}
	reg int pre=0;
	if(f[n][1]>f[n][0])pre=1;
	T[n]=(pre?'D':'P');
	for(reg int i=n;i;i--)T[i]=(pre?'D':'P'),pre=g[i][pre];
	puts(T+1);
	return 0;
}

Measured memory_bytes: 7176
N,W=map(int,input().split())
w=[]
v=[]
for i in range(0,N):
    a,b=map(int,input().split())
    w.append(a)
    v.append(b)

dp=[[[-1 for i in range(0,3*N+1)] for j in range(0,N+1)] for k in range(0,N+1)]

for j in range(0,N+1):
    for k in range(0,3*N+1):
        weight=w[0]*j+k
        if weight>W:
            dp[0][j][k]=-1
        else:
            dp[0][j][k]=0
#i:何番までか　j:今までに何個選んだか　k:今までの重さ
for i in range(1,N+1):
    for j in range(0,N):
        for k in range(0,3*N+1):
            if 3*N>=k+w[i-1]-w[0]:
                if dp[i-1][j][k]==-1:
                    dp[i][j][k]=-1
                elif dp[i-1][j+1][k+w[i-1]-w[0]]==-1:
                    dp[i][j][k]=dp[i-1][j][k]
                else:
                    dp[i][j][k]=max(dp[i-1][j][k],dp[i-1][j+1][k+w[i-1]-w[0]]+v[i-1])
            else:
                dp[i][j][k]=dp[i-1][j][k]

if dp[N][0][0]==-1:
    print(0)
else:
    print(dp[N][0][0])

Measured memory_bytes: 68956
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
typedef pair<int, int> P;
const int mod = 1e9 + 7, inf = 1e16;
const string ye = "Yay!", no = ":(";

int modpow(int x, int n) {
	if (n == 0) return 1;
	if (n % 2) return x * modpow(x * x % mod, n / 2) % mod;
	return  modpow(x * x % mod, n / 2) % mod;
}
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
signed main() {
	int n, k;
	cin >> n >> k;
	cout << n % k << endl;
}

Measured memory_bytes: 896
import java.util.Scanner;

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

                int K = scan.nextInt();
                String S = scan.next();

                if (K >= S.length()) {
                	System.out.println(S);
                } else {
                	System.out.println(S.substring(0, K) + "...");
                }
        }
}

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

int main(){
  int N ,K;
  string S;
  cin >> N >> K >> S;
  K -= 1;
  if(S[K] == 'A'){
    S[K] = 'a';
    cout << S;
  }
  if(S[K] == 'B'){
    S[K] = 'b';
    cout << S;
  }
  if(S[K] == 'C'){
    S[K] = 'c';
    cout << S;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int ha,hb,ka,kb,a,b,c,d,ht,kt;
    scanf("%d %d",&ha,&hb);
    scanf("%d %d",&ka,&kb);
    scanf("%d %d %d %d",&a,&b,&c,&d);
    ht=ha*a+hb*b;
    if(ha>=10)
      ht+=(ha/10)*c;
    if(hb>=20)
      ht+=(hb/20)*d;
    kt=ka*a+kb*b;
    if(ka>=10)
      kt+=(ka/10)*c;
    if(kb>=20)
      kt+=(kb/20)*d;
    if(ht>kt)
    printf("hiroshi\n");
    if(kt>ht)
    printf("kenjiro\n");
    if(kt==ht)
    printf("even\n");
    }






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

void bottomup(){
	int n; cin >> n;	
	vector<int> dp(3);
	
	for(int day=0; day<n; day++){
		vector<int> a(3);
		vector<int> new_dp(3, 0);
		
		for(int i=0; i<3; i++)
			cin >> a[i];
		
		for(int i=0; i<3; i++){
			for(int j=0; j<3; j++) {
				if(i!=j) {
					new_dp[j]=max(new_dp[j], dp[i]+a[j]);
				}
			}
		}
		dp = new_dp;	
	}
	cout << max({dp[0], dp[1], dp[2]}) << "\n";
}

int main(){
	bottomup();
}

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

#define WIDTH 3001
#define HEIGHT 51

int dp[HEIGHT * WIDTH];

int main(void)
{
	int i, j, k;
	int n, m, s;
	while(scanf("%d%d%d", &n, &m, &s), n){
		n *= n;
		memset(dp, 0, sizeof(dp));
		dp[0] = 1;

		for(i=1; i<=m; ++i){
			for(j=n; j>=0; --j){
				for(k=s; k>=0; --k){
					if(j && i <= k){
						dp[j*WIDTH + k] = (dp[j*WIDTH + k] + dp[(j-1)*WIDTH + k-i]) % 100000;
					}
				}
			}
		}

		printf("%d\n", dp[n*WIDTH + s]);
	}

	return 0;
}

Measured memory_bytes: 1360
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pi;
typedef pair<lli,lli> plli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<pi> vpi;
typedef vector<plli> vplli;
const lli M=1000000007ll;
#define debug(x) cout<<"debugg:: "<<(x)<<'\n';


int main(){
	fast_io
	string s;
	cin>>s;
	int n=s.size(),val=0,m=2019,g;
	
	vi pre(m,0),pot(n+1);
	pre[0]=1; pot[0]=1;
	
	for(int i=1; i<=n; ++i ) pot[i]=(pot[i-1]*10)%m;
	
	lli ans=0;
	for(int i=0; i<n; ++i){
		val=(val*10 + s[i]-'0')%m;
		g=(val*(pot[n-i]%m))%m;
		ans+=pre[g];
		pre[g]++;
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 4424
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
    string s,act,w;
    int num,k1,k2;
    cin>>s;
    cin>>num;
    for(int i=0;i<num;i++){
        cin>>act>>k1>>k2;
        if(act=="print"){
            for(int j=k1;j<=k2;j++)cout<<s[j];
            cout<<"\n";
        }
        else if(act=="reverse"){
            reverse(s.begin()+k1,s.begin()+k2+1);
        }
        else if(act=="replace"){
            cin>>w;
            s=s.replace(k1,k2-k1+1,w);
        }
    }

    return 0;
}


Measured memory_bytes: 3204
import java.util.*;

public class Main {

    public static void main(String[] args) {
        int[] count = new int[5];
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 6; i++) {
            int j = sc.nextInt();
            count[j]++;
            if (count[j] > 2) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
}

Measured memory_bytes: 25300
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s;cin>>s;
  int n=s.size();
  string ans="";
  for(int i=0;i<n;i++){
    if(i%2==0)ans+=s.at(i);
  }
  cout << ans << endl;
}

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

namespace ABC166B
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = ReadInt();
            int N = NK[0];
            int K = NK[1];

            int[] have = new int[N];
            for (int i = 0; i < K; i++)
            {
                Console.ReadLine();
                var A = ReadInt();
                foreach (var a in A)
                {
                    have[a - 1]++;
                }
            }

            int ans = have.Where(x => x == 0).Count();

            Console.WriteLine(ans);
            Console.ReadKey();
        }


        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }


    }
}


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

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

  ll a,b,c;
  cin >> a >> b >> c;
  ll d = c - a - b;
  if(d > 0 && d * d > 4 * a * b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
N,M = map(int,input().split())
D = [[]for i in range(N)]
AC = 0
WA = 0
for i in range(M):
  plobNum,res = input().split()
  D[int(plobNum)-1].append(res)

for prob in D:
  wa_ = 0
  for submit in prob:
    if submit == "WA" :
      wa_+=1
    elif submit == "AC":
      AC+=1
      WA +=wa_
      break

print("{} {}".format(AC,WA))

Measured memory_bytes: 58016
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main()
{
    long long int n,sum=0;
    cin>>n;
    long long int a[3*n+5];
    for(long long int i=0;i<3*n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+3*n,greater<int>());
    for(long long int i=1;i<=2*n;i+=2) sum=sum+a[i];
    cout<<sum;
    return 0;
}


Measured memory_bytes: 5920
#include <stdio.h>
#include <stdlib.h>


int main()
{
	int n, k;
	int w, bk_w;;
	int *nimotu;
	int count, sum;
	int P;
	int max;
	int i, j;


	scanf("%d %d", &n, &k);
	if(k > n)
		k = n;

	nimotu = (int *)malloc(sizeof(int) * n);

	sum = max = 0;
	for(i = 0; i < n; i++){
		scanf("%d", &w);
		sum += nimotu[i] = w;
		if(w > max)
			max = w;
	}

	// 積載重量を求める
	P = sum / k;
	if(max > P)
		P = max;
	count = 0;
	for(i = P; ;i++){
		//printf("<%d>\n", i);
		count = bk_w = 0;
		for(j = 0; j < n; j++){
			if(i >= bk_w + nimotu[j]){
				bk_w += nimotu[j];
				//printf("%d ", bk_w);
			}else{
				bk_w = nimotu[j];
				//printf("\n%d ", bk_w);
				count++;
			}
			if(j == n - 1 && i >= bk_w)
				count++;
			if(count > k)
				break;
		}
		if(j == n && count <= k)
			break;
	}

	printf("%d\n", i);

	return 0;
}


Measured memory_bytes: 2192
#include <iostream>

#define MAX 400000
int main(){
    long deque[MAX];
    int s = MAX-1;
    int t = 0;
    
    int q;
    std::cin >> q;
    while(q--){
        int com;
        std::cin >> com;
        if (com == 0){
            int d, k;
            std::cin >> d >> k;
            if (d == 0){
                deque[s] = k;
                s = (s + MAX - 1) % MAX;
            }
            else{
                deque[t] = k;
                t = (t + MAX + 1) % MAX;
            }
        }
        if (com == 1){
            int p;
            std::cin >> p;
            std::cout << deque[(s + p + 1) % MAX] << std::endl;
        }
        if (com == 2){
            int d;
            std::cin >> d;
            if (d == 0){
                s = (s + MAX + 1) % MAX;
            }
            else {
                t = (t + MAX - 1) % MAX;
            }
        }
    }
}


Measured memory_bytes: 6188
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int H, W, K;
vector<vector<int>> G;

void update (vector<vector<int>> &G) {
    for (auto &g : G) {
        vector<int> updated;
        for (auto elm : g) if (elm != 0) updated.push_back(elm);
        g = updated;
    }
}

int count (vector<vector<int>> &G) {
    int sum = 0;
    for (int i = H - 1; i >= 0; i--) {
        // REP(j, 0, W) {
        //     if (G[j].size() > i) cout << " " << G[j][i] << " ";
        //     else cout << " NA ";
        // }
        // cout << endl;
        int j = 0;
        while (j < W - K + 1) {
            if (!(G[j].size() > i)) {
                j++;
                continue;
            }
            int len = 1, k = j + 1;
            while (k < W && G[k].size() > i) {
                if (G[j][i] == G[k][i]) {
                    len++;
                    k++;
                }
                else break;
            }
            // cout << "# i : " << i << " , found " << G[j][i] << " * " << len << endl;
            if (len >= K) {
                sum += G[j][i] * len;
                REP(l, j, k) G[l][i] = 0;
            }
            j = k;
        }
    }
    return sum;
}

int calculate(vector<vector<int>> &G) {
    int s = 0, n = 1; vector<vector<int>> tmp = G;
    while (1) {
        update(tmp);
        // for (auto t : tmp) cout << t.size() << " ";
        // cout << endl;
        int score = count(tmp) * n;
        if (score == 0) break;
        s += score;
        n *= 2;
    }
    return s;
}

int main() {
    cin >> H >> W >> K;
    vector<string> C(H);
    REP(i, 0, H) cin >> C[i];

    G.resize(W, vector<int>(H));
    REP(i, 0, H) REP(j, 0, W) G[j][H - 1 - i] = C[i][j] - '0';

    int ans = 0;
    REP(i, 0, H) {
        REP(j, 0, W) {
            int tmp = G[j][i];
            G[j][i] = 0;
            ans = max(ans, calculate(G));
            G[j][i] = tmp;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import numpy as np
INF = 10 ** 12

N, W = map(int, input().split(" "))
wv = np.array([[int(i) for i in input().split(" ")] for _ in range(N)])

sumv = np.sum(wv[:,1])

dp = np.zeros((N + 1, sumv + 1), dtype=np.int64)
dp[0][1:] = INF

for i in range(N):
    dp[i+1][:wv[i][1]] = dp[i][:wv[i][1]]
    dp[i+1][wv[i][1]:] = np.minimum(dp[i][wv[i][1]:], dp[i][:-wv[i][1]]+wv[i][0])

ans = 0
for v, w in enumerate(dp[N]):
    if w <= W:
        ans = max(v, ans)

print(ans)

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

int cc(long long i)
{
    int ans=0;
    while(i)
    {
        if(i%2)
        ans++;
        i/=2;
    }
    return ans;
}
int main() {
	// your code goes here
int d,n;
cin>>d>>n;
if(d==0) { if(n%100!=0) cout<<n<<endl; else cout<<n+1<<endl;}
else
{
    if(d==1)
    {
        if(n%100!=0) cout<<n*100<<endl; else {cout<<n*100+100<<endl; }
    }
    else
    {
        if(n%100!=0) cout<<n*10000<<endl; else{cout<<n*10000+10000<<endl; }
    }
}
return 0;
}


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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using namespace std;

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

    int n, m; cin >> n >> m;
    int a[n], b[n], minimum[n], ans[n], x[m], y[m];
    REPI(i, n){
        cin >> a[i] >> b[i];
        minimum[i] = 1e9;
    }
    REPI(i, m){
        cin >> x[i] >> y[i];
    }

    REPI(i, n){
        REPJ(j, m){
            int man_dis = abs(a[i] - x[j]) + abs(b[i] - y[j]);
            //cout << man_dis << endl;
            if(minimum[i] > man_dis){
                //cout << "value j: " << j << endl;
                ans[i] = j + 1;
                minimum[i] = man_dis;
            }
        }
    }
    REPI(i, n) cout << ans[i] << '\n';
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc119/tasks/abc119_c
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
#define ip(arr, n) for(int i=0; i<n; i++) cin>>arr[i];
#define ip1(arr, n) for(int i=1; i<=n; i++) cin>>arr[i];
#define op(arr, n) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
#define fstIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define debug(x) cout<<x<<"\n";
#define inf 1e9
#define INF 1e16
#define MOD 1000000007

int n,a,b,c;
int *arr;

ll findMinCost(int i, ll sum_a, ll sum_b, ll sum_c){
    if(i==n){
        if(!sum_a or !sum_b or !sum_c)return inf;
        return abs(a-sum_a) + abs(b-sum_b) + abs(c-sum_c);
    }

    ll ans = inf;
    ans = min(ans, findMinCost(i+1, sum_a, sum_b, sum_c));
    ans = min(ans, findMinCost(i+1, sum_a+arr[i], sum_b, sum_c)+(sum_a?10:0));
    ans = min(ans, findMinCost(i+1, sum_a, sum_b+arr[i], sum_c)+(sum_b?10:0));
    ans = min(ans, findMinCost(i+1, sum_a, sum_b, sum_c+arr[i])+(sum_c?10:0));

    return ans;
}

void solve(){
    cin>>n>>a>>b>>c;
    arr = new int[n];
    ip(arr, n);
    ll ans = findMinCost(0,0,0,0);
    cout<<ans<<endl;
}

int main(){

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

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

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

void solve(long long N){
    int ans = 0;
    double s = sqrt(1000000000);
    REP(i, (int)s + 2) {
        if (i * i == N) {
            ans = N;
            break ;
        }
        else if (i * i > N) {
            ans = pow(i - 1, 2);
            break ;
        }
    }
    cout << ans << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256