akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#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<bits/stdc++.h>

#define lli long long int
#define mp make_pair
#define pb push_back
using namespace std;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<lli> vli;

//static bool comp(){
//	if(){
//		return true;
//	}
//	return false;
//}


void solve(){
	
	int n;
	cin >> n;
	lli t;
	map<lli, lli>mp;
	for(int i = 0;i<n;i++){
		cin>>t;
		mp[t]++;
	}
	int ans = 0;
	for(auto x:mp){
		if(x.first < x.second){
			ans += (x.second - x.first);
		}
		else if(x.first > x.second){
			ans += x.second;
		}
		else{

		}
	}
	cout<<ans;

}




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


	int t = 1;
	while(t--){
		solve();
		cout<<endl;
	}

}

Measured memory_bytes: 6272
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

bool sort_drinks(const pair<long, long> a, const pair<long, long> b) {
    return a.first < b.first;
}

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

    vector<pair<long, long>> drinks(N);
    for (int i = 0; i < N; ++i) {
        int a, b;
        cin >> a >> b;
        drinks[i] = make_pair(a, b);
    }

    sort(drinks.begin(), drinks.end(), sort_drinks);

    long min_price = 0;
    int number_of_bought = 0;
    for (int i = 0; i < N; ++i) {
        if (number_of_bought >= M)
            break;

        int lack = M - number_of_bought;
        if (lack >= drinks[i].second) {  // should buy maximum num
            min_price += drinks[i].first * drinks[i].second;
            number_of_bought += drinks[i].second;
        } else {
            min_price += lack * drinks[i].first;
            number_of_bought += lack;
        }
    }
    cout << min_price << '\n';
}


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

int main() {
    int N, K; cin >> N >> K;
    int h[N];
    for (int i = 0; i < N; i++) cin >> h[i];
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (h[i] >= K) ans++;
    } 
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
                Scanner scan = new Scanner(System.in);
                for(int i=1; i>0; i++){
                        int iNum1 = scan.nextInt();
                        int iNum2 = scan.nextInt();
                        if(iNum1 == 0 && iNum2 == 0)
                                break;
                        if(iNum1 > iNum2){
                        	int temp = iNum1;
                        	iNum1 = iNum2;
                        	iNum2 = temp;
                        }
                        System.out.println(iNum1 + " " + iNum2);
                }
	}
}

Measured memory_bytes: 27152
#include<iostream>

using namespace std;

int main()
{
	int num,i,j;
	
	for(;;)
	{
		int n[55]={0},p[4];
		cin >> num >> p[0] ;
		if(num==0 && p[0]==0)
			break;
		
		p[1]=p[0];
		for(i=0;;i++)
		{
			if(i==num)
				i-=num;
			if(p[1]!=0)
			{
				n[i]++;
				p[1]--;
			}
			else
			{
				p[1]=n[i];
				n[i]=0;
			}
			if(n[i]==p[0])
				break;
		}
		cout << i << endl;
	}
}

Measured memory_bytes: 864
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 998244353;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

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

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

using modint = ModInt< mod >;


bool solve(){
	ll n;cin>>n;
	vector<ll>a(n);
	rep(i,n)cin>>a[i];
	ll sum=0;
	rep(i,n)sum^=a[i];
	rep(i,n)cout<<(sum^a[i])<<endl;
  	return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(15);
  solve();
}


Measured memory_bytes: 4664
import java.util.*;
public class Main{
	public static void main(String[]args){
      Scanner scan=new Scanner(System.in);
    	String str=scan.nextLine();
      	if(str.charAt(str.length()-1)=='s'){
        	System.out.println(str+"es");
        }else{
        	System.out.println(str+"s");
        }
    }	
  
}

Measured memory_bytes: 38524
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():
    N, L = map(int, readline().split())
    
    full = N * L + N * (N-1) // 2
    min_error = INF
    for i in range(N):
        tmp = (N-1) * L + sum(j for j in range(N) if j != i)
        if min_error > abs(full-tmp):
            min_error = abs(full-tmp)
            ans = tmp
            
    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9168
N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]
INF = 10**9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return(min(ret0, ret1, ret2, ret3))
    
print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
a = int(input())

List = []
for i in range(a):
	b, c = input().split()
	c = int(c)
	List.append([b, c, i])
List = sorted(List, key = lambda x:(x[0],-x[1]))

List2 = []
for i in range(a):
  List2.append(List[i][2]+1)
  
print(*List2)

Measured memory_bytes: 3064
/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) ((lli)(x).size())
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;


const auto start_time = std::chrono::high_resolution_clock::now();
void aryanc403()
{
#ifdef ARYANC403
auto end_time = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/aryan/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{
    // n=4000;
    // s.resize(n);
    // for(auto &x:s)
    //     x='0'+rnd(1,3);
    cin>>n;cin>>s;

    lli ans=1;
    map<char,lli> mm;
    
    for(auto x:s)
        mm[x]++;
    for(auto x:mm)
        ans*=x.Y;
    if(sz(mm)<3)
    {
        cout<<0<<endl;
        return 0;
    }
    fo(i,n)
    {
        for(lli l=1;i-l>=0&&i+l<n;++l)
            ans-=(s[i]!=s[i-l]&&s[i+l]!=s[i]&&s[i+l]!=s[i-l]);
    }
    cout<<ans<<endl;

}   aryanc403();
    return 0;
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n, k;
    string s;
    cin >> n >> k >> s;

    vector<int> v(n, 0);

    REP(i, n-1){
        v[i+1] = v[i];
        if(s[i] != s[i+1]) v[i+1]++;
    }

    int ans = 0;

    REP(i, v.back() + 1){
        int l = lower_bound(all(v), i) - v.begin();
        int r;
        if(s[l] == '1') r = lower_bound(all(v), i + 2*k + 1) - v.begin();
        else r = lower_bound(all(v), i + 2*k) - v.begin();
        chmax(ans, r - l);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>

using namespace std;

int main() {

	int n;
	cin >> n;
	long long int m;
	cin >> m;
	long long int q;
	cin >> q;

	vector< vector<long long int> > mp(n, vector<long long int>(n, 0));

	int l, r;
	for (long long int i = 0; i < m; i++) {
		cin >> l >> r;
		l--;
		r--;
		mp[l][r]++;
	}
	for (long long int i = 1; i < n; i++) {
		mp[0][i] += mp[0][i - 1];
	}
	for (long long int i = 1; i < n; i++) {
		mp[i][0] += mp[i - 1][0];
		for (long long int j = 1; j < n; j++) {
			mp[i][j] += mp[i - 1][j] + mp[i][j - 1] - mp[i - 1][j - 1];
		}
	}
	int a, b;
	for (long long int i = 0; i < q; i++) {
		cin >> a >> b;
		a--;
		b--;
		if (a > 0) {
			cout << mp[b][b] - mp[a - 1][b] - mp[b][a - 1] + mp[a - 1][a - 1] << endl;
		}
		else {
			cout << mp[b][b] << endl;
		}
	}
	return 0;
}

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

string G;
int ans;

void solve(string const& s, int d, vector<string> const& a, vector<string> const& b) {
    if(d > ans || s.size() > G.size()) {
        return;
    }
    if(s == G) {
        ans = d;
    }
    int n = a.size();
    for(int i=0; i<n; ++i) {
        string next;
        int l = a[i].size();
        for(int j=0; j<s.size(); ++j) {
            if(j + l - 1 < s.size() && s.substr(j, l) == a[i]) {
                next += b[i];
                j += l-1;
            } else {
                next += s[j];
            }
        }
        if(next == s) continue;
        solve(next, d+1, a, b);
    }
}

int main() {
    int n;
    while(cin >> n, n) {
        string S;
        ans = 1e9;
        vector<string> a(n), b(n);
        for(int i=0; i<n; ++i) {
            cin >> a[i] >> b[i];
        }
        cin >> S >> G;
        solve(S, 0, a, b);
        cout << (ans == 1e9 ? -1 : ans) << endl;
    }
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}
signed main(signed argc, char* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int MOD = 1000000007;
	int n;
	cin>>n;
	set<string> st;
	rep(i,n){
		string s;
		cin>>s;
		st.insert(s);
	}
	cout<<st.size()<<endl;
}


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

int main()
{
	string s;
	cin >> s;

	for (int i = 0; i < s.length(); i++) {
		if ((i + 1) % 2 == 1) {
			cout << s[i];
		}
	}
	cout << endl;
}






Measured memory_bytes: 3676
import math

X=int(input())
count=0
# count=float(count)
atcor=100
atcor=int(atcor)


while True:
    
    if atcor>=X:
        print(count)
        break
    else:
        p=atcor/100
        atcor=atcor+p
        atcor=math.floor(atcor)
        count+=1





Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll n, k;
    cin >> n >> k;
    if((n-1)%(k-1) == 0){
        cout << (n-1)/(k-1) << endl;
    }else{
        ll ans = (ll)((n-1)/(k-1));
        cout << ans+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <numeric>

using namespace std;

#define MAX_M 30

int main() {
    int N, M, K, A;
    scanf("%d %d",&N,&M);
    int loved[MAX_M+1] = {0}, byall[MAX_M+1] = {0};
    for (int i=1; i<=M; i++) byall[i] = 1;
    for (int i=0; i<N; i++) {
        scanf("%d",&K);
        for (int j=0; j<K; j++) {
            scanf("%d",&A);
            loved[A] = 1;
        }
        for (int j=0; j<=M; j++) {
            if (loved[j]) loved[j] = 0;
            else byall[j] = 0;
        }
    }
    printf("%d\n", accumulate(byall+1, byall+M+1, 0));
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Test | diff Test.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Test.cpp && ./a.out

/*

 6/19/2020

 21:02-

 */

string S;
int N;
int X,Y;

bool f(VI ms, int G) {
  //dumpc(ms);
  int L=accumulate(ALL(ms),0);
  int M=SZ(ms);
  int hb=2*L+10;
  VV<int> dp(M+1,VI(hb,0));
  dp[0][L+5]=1,G+=L+5;
  REP(i,M) REP(j,hb) if(dp[i][j]) {
    dp[i+1][j+ms[i]]=true,dp[i+1][j-ms[i]]=true;
  }
  return dp[M][G];
}
bool solve() {
  VV<int> ms(2);
  N=SZ(S);
  int i=0;
  while(i<N&&S[i]=='F') --X,i+=1;
  int dir=0;
  //dump(i,X,Y);
  FOR(j,i,N) {
    if(S[j]=='T') {
      dir^=1;
      ms[dir].push_back(0);
    } else {
      ms[dir].back()++;
      //dump(j,ms[dir].back());
    }
  }
  bool xok=f(ms[0],X),yok=f(ms[1],Y);
  return xok&&yok;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>S>>X>>Y;
  cout<<(solve()?"Yes":"No")<<endl;

  return 0;
}


Measured memory_bytes: 66008
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

typedef vector<P> G;

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}


struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

bool judge(G g, P p) {
  REP(i,4)
    if (ccw(g[i], g[(i+1)%4], p) == 1) return 0;
  return 1;
}
bool judge2(G g1, G g2) {
  REP(i,4) if (judge(g1, g2[i])) return 1;
  REP(i,4) if (judge(g2, g1[i])) return 1;
  REP(i,4) REP(j,4) {
    if (intersectSS(L(g1[i], g1[(i+1)%4]), L(g2[j], g2[(j+1)%4]))) return 1;
  }
  return 0;
}

int main() {
  int N;
  while(cin>>N,N) {
    while(N--) {
      int n;
      cin >> n;
      G g[n];
      REP(i,n) {
        REP(j,4) {
          int x,y;
          cin >> x >> y;
          g[i].push_back(P(x,y));
        }
      }
      UnionFind uf(n);
      REP(i,n) {
        REP(j,i) {
          if (judge2(g[i], g[j]))
            uf.unionSet(i,j);
        }
      }
      set<int> se;
      REP(i,n)
        se.insert(uf.root(i));
      cout << se.size() << endl;
    }
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> A(N-1),B(N);
    for (int i=0; i<N-1; i++) {
        cin >> A.at(i);
        B.at(A.at(i)-1)++;
    }
    for (int i=0; i<N; i++) {
        cout << B.at(i) << endl;
    } 
} 

Measured memory_bytes: 4464
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Dynamic;
using System.Globalization;
using System.IO.Compression;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 0; i < 9; i++)
            {
                var nameab = Reads();
                Write(nameab[0] + " ");
                Write(int.Parse(nameab[1]) + int.Parse(nameab[2]) + " ");
                WriteLine(int.Parse(nameab[1]) * 200 + int.Parse(nameab[2]) * 300);
            }
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 15740
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define all(x) (x).begin(), (x).end()

using namespace __gnu_pbds;
using namespace std;

using ull = unsigned long long;
using ll = long long;
using ld = long double;
template <typename T> using ordered_set = tree<T, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;

const int mod = 1e9 + 7;
const int inf = INT_MAX;

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

    int n, m, k;
    cin >> n >> m >> k;

    vector<string> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];

    int c = 0;

    for (int mask1 = 0; mask1 < (1 << n); mask1++) {
        for (int mask2 = 0; mask2 < (1 << m); mask2++) {
            vector<string> temp = a;
            for (int i = 0; i < n; i++) {
                if (mask1 & (1 << i)) {
                    for (int j = 0; j < m; j++)
                        temp[i][j] = '.';
                }
            }
            for (int i = 0; i < m; i++) {
                if (mask2 & (1 << i)) {
                    for (int j = 0; j < n; j++)
                        temp[j][i] = '.';
                }
            }

            int cnt = 0;
            for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cnt += (temp[i][j] == '#');
            c += (cnt == k);
        }
    }

    cout << c << "\n";
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;

int main(void)
{
    ll a, b, c, k;
    ll sum = 0;
    cin >> a >> b >> c >> k;

    sum += min(a, k);
    if (k > a)
    {
        k -= a;
    }
    else
    {
        k = 0;
        cout << sum << endl;
        return 0;
    }

    if (k > b)
    {
        k -= b;
    }
    else
    {
        k = 0;
        cout << sum << endl;
        return 0;
    }

    sum -= k;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3192
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}

bool graph[50][50];
int n,m;
bool vis[50];
int visNum;
bool dfs(int current){

  if(visNum == n) return true;
  bool flag = false;
  for(int i = 0; i < n; i++){
    
    if(vis[i] == false && graph[current][i]){
      vis[i] = true;
      visNum ++;
      if(dfs(i)) flag = true;
    }
  }
  return flag;
}
int main(){

  cin >> n >> m;

  int a[m], b[m];
  for(int  i = 0; i < m; i++){
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    graph[a[i]][b[i]] = true;
    graph[b[i]][a[i]] = true;
  }
  int cnt;

  for(int  i = 0; i < m; i++){
    graph[a[i]][b[i]] = false;
    graph[b[i]][a[i]] = false;
    for(int j = 0; j < n; j++) vis[j] = false;
    vis[0] = true;
    visNum = 1;
    if( dfs(0) ) cnt++;
    graph[a[i]][b[i]] = true;
    graph[b[i]][a[i]] = true;
  }
  cout << m - cnt << endl;
  return 0;
}


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

int main(){
    map<char, int> dec;
    dec['I'] = 1;
    dec['V'] = 5;
    dec['X'] = 10;
    dec['L'] = 50;
    dec['C'] = 100;
    dec['D'] = 500;
    dec['M'] = 1000;
    string in;
    while( cin >> in ){
        int res=0;
        for( int i=0; i<in.length()-1; i++ ){
            if( dec[in[i]] >= dec[in[i+1]] ){
                res += dec[in[i]];
            }else{
                res -= dec[in[i]];
            }
        }
        res += dec[in[in.length()-1]];
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1184
#include <stdio.h>

int main(void) {
	int a,b,c,MIN=30000;
	scanf("%d %d %d",&a,&b,&c);
	if(MIN>a+b) MIN=a+b;
	if(MIN>a+c) MIN=a+c;
	if(MIN>c+b) MIN=c+b;
	printf("%d\n",MIN);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int n;
vector<ll> a(3010);
vector<vector<ll>> dp(3010,vector<ll>(3010,-1));

ll dfs(ll l,ll r){
  if(dp[l][r]!=-1) return dp[l][r];
  if((l+r)%2!=n%2){
    if(r-l==1) return dp[l][r]=-a[l];
    return dp[l][r]=min(dfs(l+1,r)-a[l],dfs(l,r-1)-a[r-1]);
  }else{
    if(r-l==1) return dp[l][r]=a[l];
    return dp[l][r]=max(dfs(l+1,r)+a[l],dfs(l,r-1)+a[r-1]);
  }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    rep(i,n) cin>>a[i];
    cout<<dfs(0,n)<<endl;
}

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

int main() {
  bool north=false, south=false, west=false, east=false;
  string s;
  cin >> s;
  int n = s.size();
  for (int i = 0; i < n; i++) {
    if (s.at(i) == 'N') north=true;
    else if (s.at(i)=='S') south=true;
    else if (s.at(i) == 'W') west=true;
    else if (s.at(i) == 'E') east=true;
  }
  if (north==south && west==east) cout << "Yes" << endl;
  else cout<<"No" << endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1005;
int x,y,z,k;
long long a[maxn],b[maxn],c[maxn];
priority_queue<long long> q;
int main(){
	cin>>x>>y>>z>>k;
	for(int i=0;i<x;i++) cin>>a[i];
	for(int i=0;i<y;i++) cin>>b[i];
	for(int i=0;i<z;i++) cin>>c[i];
	sort(a,a+x,greater<ll>());
	sort(b,b+y,greater<ll>());
	sort(c,c+y,greater<ll>());
	
	for(int i=0;i<x;i++)
		for(int j=0;j<y;j++){
		
			if((i+1)*(j+1)-1>=k) break;
			for(int l=0;l<z;l++){
				if((i+1)*(j+1)*(l+1)-1>=k) break;
				long long tmp=a[i]+b[j]+c[l];
				q.push(tmp);
			}
		}
	for(int i=0;i<k;i++){
		cout<<q.top()<<endl;
		q.pop();
	}
	return 0;
}

Measured memory_bytes: 1400
import java.io.*;
import java.util.*;
import java.math.*;
 
class Main {
    public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public static PrintWriter pw = new PrintWriter(System.out);
    public static String line;
    public static StringTokenizer st, st2;
    public static ArrayList<ArrayList<Integer>> adjList;
    public static int[] dx = {-1, 0, 1, 0, -1, 1, 1, -1, 0};
    public static int[] dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
    public static int INF = 0x3f3f3f3f;
    public static int MOD = 1000000007;
    public static long LINF = 0x3f3f3f3f3f3f3f3fL;

    public static void main(String[] args) throws Exception {
        st = new StringTokenizer(br.readLine());
        String s = st.nextToken();
        String t = st.nextToken();
        pw.println(t + s);

        pw.close();
        br.close();
    }
}

class Pair implements Comparable<Pair>{
    public int a, b;

    Pair(int _a, int _b){
        a = _a;
        b = _b;
    }
 
    public String toString(){
        return a + " " + b;
    }

    public int compareTo(Pair p){
        if (b != p.b) return b < p.b ? -1 : 1;
        if (a != p.a) return a < p.a ? -1 : 1;
        return 0;
    }
}

Measured memory_bytes: 22356
#include<bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef pair<lo,lo> ll;//pair
typedef vector<lo> vl;  //vector of long
typedef vector<ll > vll;   //vector of pair
typedef priority_queue<lo>p_q;
#define mp(a,b) make_pair((a),(b))
#define REP(a,b) for(lo i=(a);i<(b);i++)//no need to declare variable i
 
#define REP2(a,b) for(lo j=(a);j<(b);j++)
#define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(d);j++)//no need to declare vaiables i,j
#define REPV(a,b,c) for((a)=b;(a)<(c);(a)++)//a is the variable
#define IREP(a,b) for(lo i=(a);i>=(b);i--)
#define IREPV(a,b,c) for((a)=b;(a)>=(c);(a)--)
#define all(v) (v).begin(),(v).end()
#define TRvl(c) for (vl::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvll(c) for (vll::iterator it = (c).begin(); it != (c).end(); it++
#define INF INT_MAX
#define gc getchar_unlocked
#define pc putchar_unlocked3
#define pb(a) push_back((a))
 
 
 
lo cel(lo x,lo y){
	if(x%y<=1)return x/y;
	else return x/y +1;
}
 

void solve(){
	string s;
	lo x,y;
	lo n;
	cin>>s;
	n=s.size();
	x=0;
	REP(0,n/2){
		if(s[i]!=s[n-1-i]){
			x++;
		}
	}
	cout<<x;
}

 
 
int main(){

 
	// lo n;
	// cin>>n;
	// while(n--)
		solve();
	
	return 0;
}

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

int main()
{
    pair<pair<string, int>, int> S[110];
    int N;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        string s;
        int P;
        cin >> s >> P;
        S[i] = make_pair(make_pair(s, -P), i);
    }

    sort(S, S + N);
    for (int i = 0; i < N; i++)
        cout << S[i].second + 1 << endl;

    return 0;
}

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

typedef long long int ll;
const ll MOD = 1000000007;

int bit[300010][61];

void binary(ll num, ll i){
    // ll ans = 0;
    for (ll j = 0; num>0 ; j++)
    {
        // ans = ans+(bina%2)*pow(10,i);
        bit[i][j] = num % 2;
        num = num/2;
    }
    // return ans;
}

ll bitmod(ll i){
    if(i==0){
        return 1;
    }
    ll a=1;
    for(ll j=0; j<i; j++){
        a = (a*2) % MOD;
    }
    return a;
}

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

    vector<ll> A(N);

    for(ll i=0; i<N; i++){
        cin >> A[i];
    }
    for(ll i=0; i<N; i++){
        for(ll j=0; j<61; j++){
            bit[i][j] = 0;
        }
    }
    for(ll i=0; i<N; i++){
        for(ll j=0; j<61; j++){
            binary(A[i], i);
        }
    }

    ll C[61];
    for(ll i=0; i<61; i++){
        C[i] = 0;
    }

    for(ll i=0; i<N; i++){
        for(ll j=0; j<61; j++){
            if(bit[i][j] == 1){
                C[j]++;
            }
        }
    }
    ll ans=0;
    for(ll i=0; i<61; i++){
        // ans += ((((C[i]) * ((N-C[i])) %MOD) * bitmod(i))) % MOD;
        ans += (((C[i]%MOD) * (N-C[i])) % MOD) * bitmod(i);
        // cout << i << ":" << C[i] << ":" << bitmod(i) << endl;
        // cout << ans << endl;
        ans = ans % MOD;
    }
    cout << ans % MOD << endl;
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n; cin>>n;
  vector<pair<ll,ll>> a;
  rep(i,n){
    ll x,l; cin>>x>>l;
    ll s=x-l, g=x+l;
    a.emplace_back(g,s);
  }
  vsort(a);
  
  ll b=-LINF;
  int cnt=0;
  rep(i,n){
    auto now=a[i];
    // cout<<now.second<<endl;
    if(b<=now.second){
      cnt++;
      b=now.first;
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 2420
n,a,b = [int(x) for x in input().split()]
mod = 10**9 + 7
def comb(x,y):
    child = 1
    mother = 1
    for i in range(y):
        child = child * (x-i)%mod
        mother = mother * (i+1)%mod
    return child * pow(mother,mod-2,mod) % mod
ans = pow(2,n,mod) - 1 - comb(n,a) - comb(n,b)
print(ans%mod)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Pii = pair<int, int>;

//AC by deitorial
int main(){
  int h, n;
  cin>>h>>n;
  int INF = 1<<29;

  vector<int> dp(h+10010, INF);
  dp[0] = 0;

  int a, b;
  for(int rp=0; rp<n; rp++){
    cin>>a>>b;
    for(int i=0; i<=h; i++){
      dp[i+a] = min(dp[i+a], dp[i]+b);
    }
  }

  int ans = *min_element(dp.begin()+h, dp.end());
  cout<<ans<<endl;
}

Measured memory_bytes: 384
n, m = map(int, input().split())
sc = []
for _ in range(m):
    sc.append(list(map(int, input().split())))

# print(sc)
for i in range(10**3):
    if len(str(i)) == n:
        cnt = 0
        for s, c in sc:
            if int(str(i)[s-1]) == c:
                cnt += 1
        if cnt == m:
            print(i)
            exit()

print(-1)

Measured memory_bytes: 9052
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) (int)x.size()
#define sz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

int N, K, h[100010], d[100010];

int main() {
	scanf("%d%d", &N, &K);
	for(int i=1;i<=N;i++)scanf("%d", h + i);
	for(int i=2;i<=N;i++) {
		d[i] = d[i-1] + abs(h[i] - h[i-1]);
		for(int j=2;j<=K;j++) if(i > j) d[i] = min(d[i], d[i-j] + abs(h[i] - h[i-j]));
	}
	printf("%d\n", d[N]);
	return 0;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
N, M = map(int, input().split())
INF = 10**12
AB = []
C = []
for i in range(M):
    AB.append(tuple(int(x) for x in input().split()))
    C.append(sum(1<<(int(x)-1) for x in input().split()))

dp = [INF]*(1<<N)
dp[0] = 0
for i in range(1<<N):
    for (a, b), c in zip(AB, C):
        m = i | c
        dp[m] = min(dp[m], dp[i]+a)
        
if dp[-1] == INF:
    print(-1)
else:
    print(dp[-1])
        

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

public class Main implements Runnable {
	public static void main (String[] args) {new Thread(null, new Main(), "_cf", 1 << 28).start();}

	int n, k;
	ArrayList<Integer>[] adj;
	long res = 1, MOD = (long)1e9+7;
	
	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		n = fs.nextInt();
		k = fs.nextInt();
		adj = new ArrayList[n];
		for(int i = 0; i < n; i++) adj[i] = new ArrayList<>();
		for(int i = 0; i < n-1; i++) {
			int u = fs.nextInt()-1, v = fs.nextInt()-1;
			adj[u].add(v);
			adj[v].add(u);
		}
		
		dfs(0, 0, -1);
		out.println(res);
		
		out.close();
	}
	
	void dfs(int u, int d, int p) {
		if(u == 0) res = k;
		long curM = k-1;
		if(d > 0) curM = k-2;
		for(int v : adj[u]) if(v != p) {
			res = res*curM % MOD;
			curM--;
		}
		for(int v : adj[u]) if(v != p) {
			dfs(v, d+1, u);
		}
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}                
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
		
		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}
		
	}

}

Measured memory_bytes: 68856
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

void printresult(vector<vector<int>>& dp, int xlen, int ylen) {
    for (int i = 0; i < xlen + 1; i++) {
        for (int j = 0; j < ylen + 1; j++) {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
}

int solve(string x, string y, int xlen, int ylen) {
    vector<vector<int>> dp(xlen + 1, vector<int>(ylen + 1, 0));
    for (int i = 0; i < xlen + 1; i++) {
        dp[i][0] = i;
    }
    for (int j = 0; j < ylen + 1; j++) {
        dp[0][j] = j;
    }
    for (int i = 1; i < xlen + 1; i++) {
        for (int j = 1; j < ylen + 1; j++) {
            if (x[i - 1] == y[j - 1]) {
                dp[i][j] = min(dp[i][j - 1] + 1, min(dp[i - 1][j] + 1, dp[i - 1][j - 1]));
            }
            else {
                dp[i][j] = min(dp[i][j - 1] + 1, min(dp[i - 1][j] + 1, dp[i - 1][j - 1] + 1));
            }
        }
    }
    //printresult(dp, xlen, ylen);
    return dp[xlen][ylen];
}

int main() {

    string x, y;

    cin >> x >> y;

    cout << solve(x, y, x.length(), y.length()) << endl;

    
    return 0;
}


Measured memory_bytes: 6908
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <complex>
#include <tuple>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#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 repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++i)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define LF "\n"

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;

int main(){
	FAST;

	int N; 
	cin >> N;

	double ans;
	ans = (N-(N/2))/(double)N;
	cout << ans << LF;

	return 0;
}

Measured memory_bytes: 256
/*
 Sarthak Jain
*/
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
int mod=1e9+7;
int min(int a,int b){
    return (a<b)?a:b;
}
int max(int a,int b){
    return (a>b)?a:b;
}
int fp(int a,int b){
    if(b==0) return 1;
    int x=fp(a,b/2);
    x=(x*x)%mod;
    if(b&1) x=(x*a)%mod;
    return x;
}


signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
 int n;
 cin>>n;
 int a[n+1];
 int m=1000;
 for(int i=1;i<=n;i++)
 {
    cin>>a[i];
 }

 for(int i=1;i+1<=n;i++)
 {
    int x=m/a[i];
    m+=x*max(0,a[i+1]-a[i]);
 }
 cout<<m;


}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int n;
    cin>>n;
    string s[n];
    int ans = 0;
    int c1 = 0, c2 = 0, c3 = 0;
    f(i, n){
        cin>>s[i];
        f(j, s[i].length() - 1){
            if(s[i][j] == 'A' && s[i][j + 1] == 'B') ans++;
        }
        if(s[i][0] == 'B' && s[i][s[i].length() - 1] == 'A') {
            c3++;
            continue;
        }
        if(s[i][0] == 'B') c1++;
        if(s[i][s[i].length() - 1] == 'A') c2++;
    }
    if(c3 > 0){
        ans += c3 - 1;
        if(c2 > 0){
            ans++;
            c2--;
        }
        if(c1 > 0) {
            ans++;
            c1--;
        }
        ans += min(c1, c2);
    }
    else{
        ans += min(c1, c2);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
using namespace std;

template<typename T_n> // typename は class と書いてもよい
T_n myGcd(T_n tnA, T_n tnB){
  T_n tnR = tnA % tnB;
  while(tnR > 0){
    tnA = tnB;
    tnB = tnR;
    tnR = tnA % tnB;
  }

  return tnB;
}

int main()
{
  long long N,M;
  cin >> N >> M;

  string S,T;
  cin >> S >> T;

  if(S[0] != T[0]){
    cout << -1 << "\n";
    return 0;
  }else{
    long long G = myGcd(N,M);

    if(G == 1){
      cout << N*M << "\n";
      return 0;
    }else{
      long long L = N/G*M;
      long long perS = N/G;
      long long perT = M/G;
      for(int i=1;i<G;i++){
        if(S[i*perS] != T[i*perT]){
          cout << -1 << "\n";
          return 0;
        }
      }
      cout << L << "\n";
    }

  }

	return 0;
}


Measured memory_bytes: 512
M=int(input()) 
N=list(input().split()) 
check=[0]*M           
for i in range(M):    
    check[int(N[i])-1]+=1   
num=0
for i in range(M):
    num+=check[i]*(check[i]-1)//2
for i in range(M):
    if check[int(N[i])-1]!=2:
        print(num-(check[int(N[i])-1]-1))
    else:
        print(num-1)


Measured memory_bytes: 20576
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7


def main():
    N = int(input())
    print(int(N == 0))


if __name__ == "__main__":
    main()

Measured memory_bytes: 9404