akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    using namespace std;
    #define ll  long long
    #define rep(i,n) for(ll i=0;i<n;i++)
    #define pb push_back
    #define in insert
    #define test   ll t;cin>>t;while(t--)
    #define bs  binary_search
    #define rep1(x,n) for(ll x=n-1;x>=0;x--) 
    
    #define SORT(x) sort(x.begin(),x.end())
    #define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
    #define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
    #define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
    #define All(x) (x).begin(),(x).end()
    #define rAll(x) (x).rbegin(),(x).rend()
    #define db  double
    #define sc scanf
    #define pf printf
    const ll MAX=1e8;
    //ll d[MAX],h[MAX];
    const double pi=3.14159265358979323846;
    const ll M=2e18 +7;
    ll gcd(ll x,ll y){
    	if(x==0)return y;
    	else return gcd(y%x,x);
    }
    ll lcm(ll x,ll y){
    	return (x*y)/gcd(x,y);
    }
   
      bool isPrime(ll n) 
{  
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6){ 
        if (n % i == 0 || n % (i + 2) == 0){ 
            return false; 
        }
    }
    return true; 
} 
bool pdrome(string s){
    ll n = s.length();
    for(ll i=0;i<n/2;i++){
        if(s[i]!=s[n-i-1]){
            return false;
        }
    }
    return true;
}
ll mindig(ll x){
    ll ans = 9;
    ll t = x;
    while(x){
        ans = min(ans,x%10);
        x/=10;
    }
    x = t;
    return ans;
}
ll maxdig(ll x){
    ll ans = 0;
    ll t = x;
    while(x){
        ans = max(ans,x%10);
        x/=10;
    }
    x = t;
    return ans;
}
ll modpow(ll x,ll n,ll M){
	if(n==0)return 1%M;
	ll u=modpow(x,n/2,M);
	u=(u*u)%M;
	if(n%2==1)u=(u*x)%M;
	return u;

}
ll sum(ll a) {
    ll result = 0;
    while (a > 0) {
        result += a % 10;
        a /= 10;
    }
    return result;
}
ll digits(long long n) 
{ 
    return floor(log10(n) + 1); 
}                                  

    int main() {
    	ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    	int n;
    	cin>>n;
    	int k=(n+999)/1000;
    	cout<<k*1000-n;
    return 0;
}
    


Measured memory_bytes: 3688
#include <iostream>
#include <algorithm>
#include <cstring>

#define MAX 1500001

using namespace std;

int tate[MAX], yoko[MAX];

int main( void )
{
	int n, m;
	int h[1500], w[1500];
	while(cin >> n >> m, n | m) {
		int sum_all_h, sum_all_w;
		sum_all_h = sum_all_w = 0;
		for(int i=0; i < n; ++i) { cin >> h[i]; sum_all_h += h[i]; }
		for(int i=0; i < m; ++i) { cin >> w[i]; sum_all_w += w[i]; }
		memset(tate, 0, sizeof(tate));
		memset(yoko, 0, sizeof(yoko));
		int size = max(sum_all_h+1, sum_all_w+1);
		for(int i=0; i < n; ++i) {
			if(i) sum_all_h -= h[i-1];
			int sum_h = sum_all_h;
			++tate[sum_h];
			for(int j=n-1; j > i; --j) {
				sum_h -= h[j];
				++tate[sum_h];
			}
		}
		for(int i=0; i < m; ++i) {
			if(i) sum_all_w -= w[i-1];
			int sum_w = sum_all_w;
			++yoko[sum_w];
			for(int j=m-1; j > i; --j) {
				sum_w -= w[j];
				++yoko[sum_w];
			}
		}
		int answer = 0;
		for(int i=1; i < size; ++i) {
			answer += tate[i] * yoko[i];
		}
		cout << answer << endl;
	}

	return 0;
}

Measured memory_bytes: 12000
#include<stdio.h>
int main()
{
    int n,i=0,s=0,a;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a);
        s=s+a;
    }
    s=s-n;
    printf("%d\n",s);
    return 0;
}


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

using namespace std;

typedef long long ll;


const int N=2e5+10;
int n,k,a[N];
ll psum[N],coor[N];


struct BIT{
    int b[N];
    void add(int x,int v){
        while (x<N){
            b[x]+=v;
            x+=x&-x;
        }
    }
    int get(int x){
        int ans=0;
        while (x){
            ans+=b[x];
            x-=x&-x;
        }
        return ans;
    }
}mbit;
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++) scanf("%d",a+i);
    for(int i=1;i<=n;i++) a[i]-=k;
//    for(int i=1;i<=n;i++) cout<<a[i]<<" \n"[i==n];
    for(int i=1;i<=n;i++) psum[i]=psum[i-1]+a[i];
//    for(int i=1;i<=n;i++) cout<<psum[i]<<" \n"[i==n];
    for(int i=1;i<=n+1;i++) coor[i]=psum[i-1];
    sort(coor+1,coor+n+2);
//    for(int i=1;i<=n+1;i++) cout<<coor[i]<<" \n"[i==n+1];
    ll ans=0;
    mbit.add(upper_bound(coor+1,coor+n+2,0)-coor-1,1);
    for(int i=1;i<=n;i++){
        ans+=mbit.get(upper_bound(coor+1,coor+n+2,psum[i])-coor-1);
        mbit.add(upper_bound(coor+1,coor+n+2,psum[i])-coor-1,1);
//        cout<<upper_bound(coor+1,coor+n+2,psum[i])-coor-1<<" "<<upper_bound(coor+1,coor+n+2,-psum[i])-coor-1<<'\n';
    }
    cout<<ans;
}


Measured memory_bytes: 4992
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using Graph = vector<vector<int>>;
using Wgraph = vector<vector<pair<int, long long int>>>;
constexpr long long int INF = 1001001001001001LL;
constexpr long long int MOD = 1000000007LL;
constexpr double PI = 3.1415926535897932;
constexpr long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
constexpr long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

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;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = 1; i <= (n); i++)
#define DREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define SREP(i,s,t) for(int i = s; i < t; i++)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define PB push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

int main(){
  
  int n; cin >> n;
  vector<int> l(n);
  for(int i = 0; i < n; i++) cin >> l[i];
  sort(ALL(l));
  int ans = 0;
  for(int i = 0; i < n; i++) {
    for(int j = i + 1; j < n; j++) {
      int lb = j;
      int ub = n;
      int val = l[i] + l[j];
      while(ub - lb > 1) {
        int mid = (ub + lb) / 2;
        if(val > l[mid]) lb = mid;
        else ub = mid;
      }

      ans += lb - j;
    }
  } 

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


Measured memory_bytes: 384
## coding: UTF-8
#最後の方のテストケースでREになってしまう。時間切れ。
from decimal import *
from itertools import permutations, combinations,combinations_with_replacement,product

s = input().split()
t = [int(p) for p in s]


sA = input().split()
p = [int(w) for w in sA]
p.sort(reverse=True) #大きい順に並べ替える


sB = input().split()
q = [int(p) for p in sB]
q.sort(reverse=True)

sC = input().split()
r = [int(p) for p in sC]
r.sort(reverse=True)

X = t[0]
Y = t[1]
A = t[2]
B = t[3]
C = t[4]
p = p[:X] #下の方はいらない子
q = q[:Y] #下の方はいらない子
r = r[:X+Y] #下の方はいらない子だけど、全部無色の可能性もある。
#print('{} {} {} {} {}'.format(X,Y,A,B,C))
#print(p)
#print(q)
#print(r)

def delete_min(p, q, r):
    if(len(p) == 0 and len(q) == 0):
        del r[-1]
    elif(len(p) == 0):
        if(q[-1] <= r[-1]):
            del q[-1]
        else:
            del r[-1]
    elif(len(q) == 0):
        if(p[-1] <= r[-1]):
            del p[-1]
        else:
            del r[-1]
    elif(len(r) == 0):
        if(p[-1] <= q[-1]):
            del p[-1]
        else:
            del q[-1]
    else:
        if(p[-1] <= q[-1] and p[-1] <= r[-1]):
            del p[-1]
        elif(q[-1] <= r[-1]):
            del q[-1]
        else:
            del r[-1]
    #要素数が0になることもありうるので、その回避処理が必要だった

while len(p) + len(q) + len(r) > X + Y:
    delete_min(p, q, r)
    #print('p:{}, q:{}, r:{}'.format(p,q,r))

answer = sum(p) + sum(q) + sum(r)
print(answer)




Measured memory_bytes: 39964
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    

S=input()
cnt=0
ct=0
while len(S)>0 and cnt==0:
	S=S[:-2]
	ct=0
	for i in range(len(S)//2):
		if S[i]==S[i+len(S)//2]:
			ct+=1
	if ct==len(S)//2:
		cnt+=1
		print(len(S))
		
	

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
#define PI 3.14159265358979
//#define rep(i,init,n) for(ll i=init;i<=n;++i)
using P = pair<ll , ll>;
using map = map<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main(){
    ll a,b;
    cin >> a>>b;
    cout << a*b << endl;

    return 0;
}

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

int n, m, a[300005];
int main()
{
	int i, j;
	cin >> n >> m;
	if (n % 2 == 0) {
		printf("%d ", n / 2);
		for (i =1; i < m; i++) printf("%d ", n);
		return 0;
	}
	for (i = 0; i < m; i++) a[i] = (n + 1) / 2;
	i = m - 1;
	for (j = 0; j < m / 2; j++) {
		a[i]--;
		if (a[i] == 0) a[i--] = n;
		else i = m - 1;
	}
	for (j = 0; j <= i; j++) printf("%d ", a[j]);
    return 0;
}


Measured memory_bytes: 3456
using System;
using static System.Console;
using static System.Math;
using System.IO;
using System.Collections.Generic;
namespace I_am_the_green_coder{
    class Inonoa{
        static void Main(){
            long n = ILongs()[0];
            long[] a = ILongs();
            long[] b = ILongs();

            long ans = 0;

            if(a[0]<=b[0]){
                    ans += a[0];
                    b[0] -= a[0];
                a[0] = 0;
                }else{
                    ans += b[0];
                    a[0] -= b[0];
                    b[0] = 0;
                }

            for(int i=1;i<n;i++){
                if(a[i]<=b[i-1]){
                    ans += a[i];
                    b[i-1] -= a[i];
                    a[i] = 0;
                    
                }else{
                    ans += b[i-1];
                    a[i] -= b[i-1];
                    b[i-1] = 0;
                }
                if(a[i]<=b[i]){
                    ans += a[i];
                    b[i] -= a[i];
                    a[i] = 0;
                }else{
                    ans += b[i];
                    a[i] -= b[i];
                    b[i] = 0;
                }
            }
            if(a[n]<=b[n-1]){
                    ans += a[n];
                    a[n] = 0;
                    b[n-1] -= a[n];
                }else{
                    ans += b[n-1];
                    a[n] -= b[n-1];
                    b[n-1] = 0;
                }
                Console.WriteLine(ans);
        }

        static readonly long MOD = 1000000007;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        ///<summary>n行の文字列を取ったり</summary>
        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = ReadLine().ToCharArray();
            }
            return re;
        }
    }
}

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

#define pb push_back
#define mp make_pair
#define sqr(a) ((a) * (a)) 
#define io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

typedef long long int li;
typedef long double ld;


int main()
{
    io();
    li n,k;
    cin>>n>>k;
    li a[1000]={0},i;
    while(k--)
    {
        li d;
        cin>>d;
        while(d--)
        {
            li x;
            cin>>x;
            a[x]++;
        }
    }
    li ans=0;
    for(i=1;i<=n;i++)
    if(a[i]==0)
    ans++;
    cout<<ans;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL n;
int s[100000];
int main(){
    scanf("%lld", &n);
    LL x = 0, y = 1, z = 0;
    while(x <= n){
        y *= 26LL;
        x += y;
        ++z;
    }
    x -= y;
    if(n == x){
        for(int i = 1; i < z; i++) cout<<'z';
        cout<<endl;
    }
    else{
        
        int u = 0;
        LL a = n - x - 1LL;
        while(a > 0){
            s[++u] = a % 26LL;
            a /= 26LL;
        }
        for(int i = z; i >= 1; i--) printf("%c", s[i] + 'a');
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3676
import java.util. ArrayList;
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> a = new ArrayList<>();
        while(sc.hasNext()== true ){
            a.add(sc.nextInt());
        }
        int sumo = 0;
        for (int i =0; i<a.size(); i++){
            sumo += a.get(i);
        }
        sumo -= a.get(0);
        sumo -= a.get(1);
        int ans = a.get(0) - sumo;
        if( a.get(0)< sumo){
            System.out.println(-1);
        }else{
            System.out.println(ans);
        }
    }
}


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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

const int MAX = 510000;

void	ComInit(vector<ll> &fac, vector<ll> &finv, vector<ll> &inv) {
	fac.at(0) = 1;
	fac.at(1) = 1;
	finv.at(0) = 1;
	finv.at(1) = 1;
	inv.at(1) = 1;
	for (int i=2; i<MAX; i++) {
		fac.at(i) = (fac.at(i-1)*i) %MOD;
		inv.at(i) = MOD - (inv.at(MOD%i)*(MOD/i)) %MOD;
		finv.at(i) = (finv.at(i-1)*inv.at(i)) %MOD; 
	}
}

ll	COM(int N, int K, vector<ll> &fac, vector<ll> &finv) {
	if (N<K)
		return 0;
	if ((N<0)||(K<0))
		return 0;
	return (fac.at(N) * ((finv.at(K)*finv.at(N-K)) %MOD)) %MOD;
}

int	main() {
	// Array
	vector<ll> fac(MAX);
	vector<ll> finv(MAX);
	vector<ll> inv(MAX);
	// Initialize
	ComInit(fac, finv, inv);
	ll n, k;
	cin >>n >>k;
	if (k>=n-1) {
		cout <<COM(n+n-1, n-1, fac, finv) <<endl;
		return 0;
	}
	/*
	cout <<COM(n+n-1, k, fac, finv) <<endl;
	cout <<COM(n, k, fac, finv) <<endl;
	cout <<COM(n+n-1, k, fac, finv)*COM(n, k, fac, finv)%MOD <<endl;
	*/
	ll S=0;
	for (int i=0; i<=min(n-1, k); i++) {
		ll s=COM(n, i, fac, finv);
			// empty cells
		s *=COM(n-1, i, fac, finv);
			// n delivered to n-i cells
		s %=MOD;
		S +=s;
		S %=MOD;
	}
	cout <<S <<endl;
	return 0;
}



Measured memory_bytes: 12288
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <typename Monoid>
class SegmentTree {
  int sz;
  vector<Monoid> node;
  const Monoid identity;

 public:
  SegmentTree(int n) : identity(Monoid::identity()) {
    sz = 1;
    while (sz < n) sz <<= 1;
    node.resize(2 * sz, identity);
  }

  void update(int k, const Monoid &x) {
    k += sz;
    node[k] = x;
    while (k >>= 1) {
      node[k] = node[2 * k + 0] + node[2 * k + 1];
    }
  }

  void add(int k, const Monoid &x) { return update(k, node[k + sz] + x); }
  Monoid query(int l, int r) {
    Monoid L = identity, R = identity;
    for (l += sz, r += sz; l < r; l >>= 1, r >>= 1) {
      if (l & 1) L += node[l++];
      if (r & 1) R += node[--r];
    }
    return L + R;
  }
};

struct Monoid {
  int v;
  bool operator==(const Monoid& that) const { return v == that.v; }
  bool operator!=(const Monoid& that) const { return !(*(this) == that); }

  static Monoid identity() { return Monoid(0); }

  Monoid(int v = 0) : v(v) {}
  Monoid& operator+=(const Monoid& that) {
    v += that.v;
    return *this;
  }
  Monoid operator+(const Monoid& that) const { return Monoid(*this) += that; }
};

int main() {
  int n, q;
  cin >> n >> q;

  SegmentTree<Monoid> seg(n);
  for (int i = 0; i < (int)(q); ++i) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com) {
      --x, --y;
      cout << seg.query(x, y + 1).v << endl;
    } else {
      --x;
      seg.add(x, y);
    }
  }

  return 0;
}



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


int main() {
    string n;
    int k;
    cin >> n >> k;
    int m=n.size();
    vector<int> d(m);
    for (int i=0;i<m;i++) d[i]=n[i]-'0';
    vector<vector<int>> p;
    vector<vector<int>> dp0(m+1,vector<int>(k+1)),dp1(m+1,vector<int>(k+1));
    for (int i=0;i<m+1;i++) {
        for (int j=0;j<k+1;j++) {
            dp0[i][j]=0;
            dp1[i][j]=0;
        }
    }
    dp0[1][0]=1;
    dp0[1][1]=d[0]-1;
    dp1[1][1]=1;
    for (int i=2;i<=m;i++) {
        dp0[i][0]=1;
        for (int j=1;j<=min(i,k);j++) {
            if (d[i-1]>0) {
                dp0[i][j]=dp0[i-1][j]+9*dp0[i-1][j-1]+dp1[i-1][j]+(d[i-1]-1)*dp1[i-1][j-1];
                dp1[i][j]=dp1[i-1][j-1];
            } else {
                dp0[i][j]=dp0[i-1][j]+9*dp0[i-1][j-1];
                dp1[i][j]=dp1[i-1][j];
            }
        }
    }
    cout << dp0[m][k]+dp1[m][k] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

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

    for(ll a=1; a*a+a<N; a++) if((N-a)%a == 0) ans += (N-a)/a;
   
    cout << ans << endl;
}

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

typedef long long ll;
typedef long double ld;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN

#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)

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


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}


void subsetsUtil(vector<int>& A, vector<vector<int> >& res, 
                 vector<int>& subset, int index) 
{ 
    res.push_back(subset); 
    for (int i = index; i < A.size(); i++) { 
  
        subset.push_back(A[i]); 
  
        subsetsUtil(A, res, subset, i + 1); 
  
        subset.pop_back(); 
    } 
  
    return; 
} 
  
vector<vector<int> > subsets(vector<int>& A) 
{ 
    vector<int> subset; 
    vector<vector<int> > res; 
 
    int index = 0; 
    subsetsUtil(A, res, subset, index); 
  
    return res; 
} 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, m, x;
	cin>>n>>m>>x;
	vector<int> array(n);
	for(int i = 0; i < n; i++)
	{
		array[i]=i;
	}

	vector<vector<int> > res = subsets(array); 
  
  	int minim = imx;
  	vector<vector<int> > mat(n, vector<int> (m+1));
  	for(int i = 0; i < n; i++)
  	{
  		for(int j = 0; j < m+1; j++)
  		{
  			cin>>mat[i][j];
  		}
  	}

    for (int i = 0; i < res.size(); i++)
    { 
    	int sum = 0;
    	vector<int> tem(m+1);
        for (int j = 0; j < res[i].size(); j++) 
        {
        	for(int k = 0; k < m+1; k++)
        	{
        		tem[k]+=mat[res[i][j]][k];
        	}
            // cout << res[i][j] << " "; 
        }
        int f = 0;
        for(int k = 1; k<=m; k++)
        {
        	if(tem[k]<x)
        	{
        		f = 1;
        		break;
        	}
        }
        if(f)
        {	
        	;
        }
        else
        {
        	minim = min(tem[0], minim);
        }
        // cout << endl; 
    } 
    if(minim==imx) cout<<-1<<endl;
    else
    cout<<minim<<endl;
	// vector<vector<int> > mat(a(n))
}

Measured memory_bytes: 3900
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 10000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
typedef pair<P, int> PI;
typedef pair<int, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

#define N 803

vector<P> g[N];
int p[N], d[N];
int dist[N];
int n;

int search(int s) {
  rep(i, n) {
    if(g[i].size() == 1) {
      dist[i] = -1;
    } else {
      dist[i] = INF;
    }
  }

  queue<int> que;
  dist[s] = 0;
  que.push(s);
  while(!que.empty()) {
    int v = que.front(); que.pop();
    rep(i, g[v].size()) {
      P &e = g[v][i];
      int to = e.first, cost = e.second;
      if(dist[v] + cost < dist[to]) {
        dist[to] = dist[v] + cost;
        que.push(to);
      }
    }
  }

  int res = -1, ma = -1;
  rep(i, n) {
    if(ma < dist[i]) {
      ma = dist[i];
      res = i;
    }
  }
  return res;
}

int main() {
  while(cin >> n && n) {
    rep(i, n) g[i].clear();
    int su = 0;
    p[0] = 0;
    repl(i, 1, n-1) cin >> p[i];
    repl(i, 1, n-1) cin >> d[i];
    repl(i, 1, n-1) {
      --p[i];
      g[i].push_back(P(p[i], d[i]));
      g[p[i]].push_back(P(i, d[i]));
      su += d[i];
    }

    int s = 0;
    rep(i, n) {
      if(g[i].size() != 1) {
        s = i;
        break;
      }
    }

    int u = search(s);
    int v = search(u);

    int om = 0;
    rep(i, n) {
      if(g[i].size() == 1) {
        P &e = g[i][0];
        om += e.second;
      }
    }
    cout << su + 2*(su - om) - dist[v] << endl;

  }
  return 0;
}

Measured memory_bytes: 1316
#include <bits/stdc++.h>
using namespace std;
int main() {
  //入力
  int h, w;
  cin >> h >> w;
  //一つの文字列に
  string s;
  for(int i = 0; i < h; i++) {
    string f;
    cin >> f;
    s += f;
  }
  //＃を数える s.at(i*w+j)が基本
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      int count = 0;
      if(i!=0 && j!=0 && s.at((i-1)*w+j-1)=='#') count++;
      if(i!=0 && s.at((i-1)*w+j)=='#') count++;
      if(i!=0 && j!=w-1 && s.at((i-1)*w+j+1)=='#') count++;
      if(j!=0 && s.at(i*w+j-1)=='#') count++;
      if(j!=w-1 && s.at(i*w+j+1)=='#') count++;
      if(i!=h-1 && j!=0 && s.at((i+1)*w+j-1)=='#') count++;
      if(i!=h-1 && s.at((i+1)*w+j)=='#') count++;
      if(i!=h-1 && j!=w-1 && s.at((i+1)*w+j+1)=='#') count++;
      //入れ替え
      if(s.at(i*w+j) == '#') continue;
      else if(count == 1) s.at(i*w+j) = '1';
      else if(count == 2) s.at(i*w+j) = '2';
      else if(count == 3) s.at(i*w+j) = '3';
      else if(count == 4) s.at(i*w+j) = '4';
      else if(count == 5) s.at(i*w+j) = '5';
      else if(count == 6) s.at(i*w+j) = '6';
      else if(count == 7) s.at(i*w+j) = '7';
      else if(count == 8) s.at(i*w+j) = '8';
      else if(count == 0) s.at(i*w+j) = '0';
    }
  }
  //改行して出力
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      cout << s.at(i*w+j);
      if(j == w - 1) cout << endl;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
   string s;
   cin>>s;
   int cnt=0;
   for (int i = 0; i < s.size(); i++)
   {
       /* code */
       if (s[i]=='x')
       {
           /* code */
           cnt++;
       }
       
   }
   if (cnt>7)
   {
       /* code */
       cout<<"NO"<<endl;
   }
   else
   {
       cout<<"YES"<<endl;
   }
   
   
   
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

int N; 
void dfs(string s, char last){
  if(s.size() == N){
    cout << s << "\n";
    return;
  }

  for(char c = 'a'; c <= last; c++){
    dfs(s+c, ((c == last)? char(last+1): last));
  }
}

signed main() {
  cin >> N;

  dfs("", 'a');

  return 0;
}

Measured memory_bytes: 1536
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#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)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	vector<int> a(n);

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

	for (int i = 0; i < n-1; i++) {

		if (a[i + 1] > a[i]){
			a[i + 1]--;
		}
		

		if (a[i] - a[i+1] > 0) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}

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

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n), b(n), c(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	rep(i, n) cin >> c[i];
	sort(all(a));
	sort(all(b));
	sort(all(c));
	vector<ll> ab(n), bc(n);
	ll ans = 0;
	rep(i, n) {
		ll now_a = lower_bound(all(a), b[i]) - a.begin();
		ll now_c = n - (upper_bound(all(c), b[i]) - c.begin());
		// cout << now_a << " " << now_c << endl;
		ans += now_a * now_c;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4224
N,A,B = map(int,input().split())
S = input()

a_cnt = b_cnt = 0

for s in S:
  if s == "c":
    print("No")
  elif s == "a":
    if a_cnt+b_cnt < A+B:
      a_cnt += 1
      print("Yes")
    else:
      print("No")
  else:
    if a_cnt+b_cnt < A+B and b_cnt+1 <= B:
      b_cnt += 1
      print("Yes")
    else:
      print("No")

Measured memory_bytes: 4016
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
string s, d, f;
int main(){
    int n;
    while(cin>>n){
        cin>>s>>d>>f;
        ll ans=0;
        for(int i=0; i<n; ++i){
            if(d[i]!=f[i])
                ans+=(s[i]!=d[i]) + (s[i]!=f[i]);
            else
                ans+=(s[i]!=d[i])||(s[i]!=f[i]);
        }
        cout<<ans<<endl;
    }
  return 0;
}




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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

typedef long long ll;

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  
  int d, t, s;  cin >> d >> t >> s;
  if(s*t>=d)  cout << "Yes" << endl;
  else  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  int n,m;
  cin>>n>>m;
  int mx = 1;
  if(n>=1000){
    rep(i,1,1000001){
      if(m%i==0){
        ll c = m/i;
        if(c>=n){
          mx = max(mx,i);
        }
      }
    }
    cout << mx << endl;
    return 0;
  }
  for(int i = 1; i*i <= 1000000000; i++){
    if(m%i==0){
      int a = i;
      int b = m/i;
      if(a>=n){
        mx = max(mx,b);
      }
    }
  }
  cout << mx << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }

        int cnt = 0;
        int cur = A[0];
        for (int i = 1, sign = 0; i < A.length; i++) {
            int diff = (A[i] - cur);
            if (diff * sign < 0) {
                cnt++;
                sign = 0;
            } else if (diff > 0) {
                sign = 1;
            } else if (diff < 0) {
                sign = -1;
            }
            cur = A[i];
        }

        System.out.println(cnt + 1);

        
        return;
    }

}

Measured memory_bytes: 50140
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

int visited[1000001];

int main(){
  int dividend;
  int divisor;
  while(~scanf("%d %d",&dividend,&divisor)){
    if(divisor == 0) break;
    
    memset(visited,-1,sizeof(visited));

    int pos = 0;
    int len = 0;
    for(int i = 0; i < 1000000; i++){
      if(dividend % divisor == 0){
        pos = i;
        len = 0;
        break;
      }
      if(visited[dividend % divisor] != -1){
        pos = visited[dividend % divisor];
        len = i - visited[dividend % divisor];
        break;
      }
      visited[dividend % divisor] = i;
      dividend %= divisor;
      dividend *= 10;
    }

    printf("%d %d\n",pos,len);
  }
}

Measured memory_bytes: 5100
#include<queue>
#include<algorithm>
#include<cstdio>
#include<vector>
#include <iomanip>
#include<cstring>
#include<iostream>
#include<cmath>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
vector<P>v;

bool cmp(P a,P b)
{
    return atan2(a.second,a.first)<atan2(b.second,b.first);
}

int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
         P m;
         cin>>m.first;
         cin>>m.second;
         v.push_back(m);
    }
    sort(v.begin(),v.end(),cmp);
    for(int i = 0; i < n; i++)
        v.push_back(v[i]);
    long double maxN=0;
    for(int start = 0; start < n; start++)
    {
        long long x = 0LL, y = 0LL;

        for(int l = 1; l <= n; l++)
        {
            x += 1LL * v[start + l - 1].first;
            y += 1LL * v[start + l - 1].second;

            maxN = max(maxN, sqrtl(1LL * x * x + y * y));
        }
    }
    cout << fixed << setprecision(60) << maxN << '\n';
    return 0;
}
///*
//
//4 6 0
//0 1 2
//1 2 2
//1 3 1
//0 2 5
//1 3 3
//0 3 4
//
//
//
//*/


Measured memory_bytes: 512
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>

using namespace std;

/// 各桁の和
int sumdigit(int x){
   int sum = 0;
    while(x != 0){
        sum += x % 10;
        x /= 10;    
    }
    return sum;
}
/// 最小公倍数 
int gcd(int x, int y){
      if(x<y){
          int temp = x;
          x = y;
          y = temp;
      }
      int r = x % y;
       while(r!=0){
           x = y;
           y = r;
           r = x % y;
       }
      return y;
   }



int main(){
int A,B,C;
cin >> A >> B >> C;
if(B/A >= C){
    cout << C << endl;
    return 0;
}
else{
    cout << B/A << endl;
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> pii;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
const ll MOD = 998244353ll;

int n,m;
int a[52525], b[52525], c[52525];
gp_hash_table<int, int> M[125252];
int dp[252521];

ll modpow(ll a, ll b){
  ll r = 1;
  while(b){
    if(b&1)r=r*a%MOD;
    a=a*a%MOD;
    b>>=1;
  }
  return r;
}

bool ppcnt[16];

bool ex(int a, int b){
  return M[a].find(b)!=M[a].end();
}

int main(){
  scanf("%d%d",&n,&m);
  REP(i,m)scanf("%d%d%d",a+i,b+i,c+i),a[i]--,b[i]--;
  REP(i,16)ppcnt[i] = __builtin_popcount(i)%2==0;
  REP(i,m)M[a[i]][b[i]] = c[i];
  REP(j,16){
    if(!ppcnt[j])continue;
    bool ok = true;
    REP(i,4)if(ex(i>>1, i&1) && M[i>>1][i&1] != (j>>i&1)){
      ok = false;
    }
    if(ok)dp[j>>3&1] += 1;
  }
  REP(i,n-2)REP(r2,2)if(dp[i*2+r2]){
    int ci = i+1;
    REP(ld,2){
      int ru = r2 ^ ld;
      if(ex(ci-1,ci+1) && M[ci-1][ci+1] != ld)continue;
      if(ex(ci+1,ci-1) && M[ci+1][ci-1] != ru)continue;
      REP(to,8){
        int nj = to*2+r2;
        if(!ppcnt[nj])continue;
        if(ex(ci+1,ci+0) && M[ci+1][ci+0] != (nj>>1&1))continue;
        if(ex(ci+0,ci+1) && M[ci+0][ci+1] != (nj>>2&1))continue;
        if(ex(ci+1,ci+1) && M[ci+1][ci+1] != (nj>>3&1))continue;
        (dp[(i+1)*2+(nj>>3)] += dp[i*2+r2]) %= MOD;
      }
    }
  }
  ll base = (dp[(n-2)*2] + dp[(n-2)*2+1]) % MOD;
  ll fr = n<=3 ? 0ll : ((ll)n*n - 7ll*2 - 5ll*(n-4))/2;
  REP(i,m){
    int x = a[i], y = b[i], z = c[i];
    if(abs(x-y)<=2)continue;
    if(ex(y,x)){
      if(M[y][x] != z){
        base = 0;
      }else if(x<y){
        fr--;
      }
    }else{
      fr--;
    }
  }
  ll ans = base * modpow(2ll, fr) % MOD;
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 29312
//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ll,ii>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
//change less to less_equal for non distinct pbds, but erase will bug

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int n;
vector<int> al[200005];

vector<ii> edges;

int p[400005];
int pa[400005][20];
int ppp[400005]; //actual parent in dfs tree
int w[400005];
int cnt[400005];

int find(int x){
	if (x==p[x]) return x;
	else return p[x]=find(p[x]);
}

int count(int i,int weight){
	if (i>weight){
		int res=1;
		
		for (auto &it:al[i]){
			if (it==ppp[i] || it>weight) continue;
			res+=count(it,weight);
		}
		
		return res;
	}

	rep(x,20,0){
		if (pa[i][x]!=-1 && w[pa[i][x]]<=weight) i=pa[i][x];
	}
	return cnt[i];
}

int mx[200005]; //max on path until parent
int ans[200005];

void dfs(int i,int p){
	for (auto &it:al[i]){
		if (it==p) continue;
		
		ppp[it]=i;
		mx[it]=max(mx[i],i);
		
		if (it>mx[i]){ //never visit this before
			ans[it]=ans[i]+count(it,mx[it]-1);
		}
		else if (mx[i]<i){ //only visit if between parent and parent's parent
			ans[it]=ans[i]+count(it,i-1)-count(it,mx[i]);
		}
		else{
			ans[it]=ans[i];
		}
		
		dfs(it,i);
	}
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	rep(x,0,400005) p[x]=x;
	memset(pa,-1,sizeof(pa));
	
	cin>>n;
	
	int a,b;
	rep(x,1,n){
		cin>>a>>b;
		if (a<b) swap(a,b);
		
		al[a].push_back(b);
		al[b].push_back(a);
		
		edges.push_back(ii(a,b)); //ordered by larger node
	}
	
	sort(all(edges));
	
	rep(x,1,n+1) cnt[x]=1;
	
	int IDX=n+1;
	for (auto &it:edges){ //tree so they are all nice
		int u=find(it.fi),v=find(it.se);
		
		p[u]=p[v]=IDX;
		pa[u][0]=pa[v][0]=IDX;
		cnt[IDX]=cnt[u]+cnt[v];
		w[IDX]=it.fi; //weight of larger node is the weight of edge
		
		IDX++;
	}
	
	rep(x,IDX,1){
		int curr=pa[x][0];
		
		rep(y,0,20){
			if (curr==-1) break;
			curr=pa[x][y+1]=pa[curr][y];
		}
	}
	
	dfs(1,-1);
	
	rep(x,2,n+1) cout<<ans[x]<<" ";
}


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

const int MAX_N = 1300000;

int prime[MAX_N];
bool is_prime[MAX_N + 1];

void eratos(int n) {
    int p = 0;
    for (int i = 0; i <= n; ++i) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= n; ++i) {
        if (is_prime[i]) {
            prime[p++] = i;
            for (int j = 2*i; j <= n; j += i) is_prime[j] = false;
        }
    }
}

int main() {
    eratos(MAX_N);

    int n;
    while (cin >> n, n) {

        int r = n, l = n;
        for (int i=n; !is_prime[i]; --i) l=i-1;
        for (int i=n; !is_prime[i]; ++i) r=i+1;

        cout << r-l << endl;

    }
}

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

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

	int n;
	cin >> n;
	map<int, int> mp;
	int a[n+1];
	for(int i=0; i<n-1; i++){
		cin >> a[i];
		mp[a[i]]++;
	}
	for(int i=1; i<=n; i++){
		cout << mp[i] << endl;
	}

	return 0;
}


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

int main(){
  int n, k;
  string s;
  cin >> n >> k;
  cin >> s;
  vector<int> ser;
  char prev = 'X';
  rep(i, n){
    if (prev == s[i]) ser.back()++;
    else ser.push_back(1);
    prev = s[i];
  }
  int x = ser.size();
  int ans;
  if (k - x/2 >= 0) ans = n - 1;
  else ans = n - x + 2 * k;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3988
#include <stdio.h>
#include <map>
using namespace std;

int main(){

    map<int, int> mmap;

    int n, temp, con = 0;
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i){
        scanf("%d", &temp);
        mmap[i] = temp;
    }
    for(int j = 1; j <= n; ++j){
        if(mmap[mmap[j]] == j){
            con++;
            mmap[mmap[j]] = 0;
        }
    }
    printf("%d\n", con);

return 0;
}


Measured memory_bytes: 4864
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import Data.List

solve :: [Int] -> Int
solve = getMaxArea

getMaxArea :: [Int] -> Int
getMaxArea s
    | a1 > 0 && a2 > 0 = a1 * a2
    | otherwise = 0
    where
        a = getMaxLength 0 s
        a1 = fst a
        a2 = snd a

getMaxLength :: Int -> [Int] -> (Int, Int)
getMaxLength _ [] = (-1, -1)
getMaxLength y (x1:x2:xs)
    | x1 == x2 && y > 0 = (y, x1)
    | x1 == x2 = getMaxLength x1 xs
    | otherwise = getMaxLength y (x2 : xs)
getMaxLength _ _ = (-1, -1)


main :: IO ()
main = do
    n <- getLine
    a <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine :: IO [Int]
    let s = sortBy (flip compare) a
    print $ solve s

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

int main(){
    string S;cin>>S;
    int cnt1 = 0;
    int cnt2 = 0;
    for(int i = 0; i < S.length(); i++){
        if(i%2==0){
            if(S[i] == '0'){
                cnt1++;
                if(S[i+1] == '1' && (i+1) < S.length()){
                    cnt1++;
                }
            }else{
                if(S[i+1] == '1' && (i+1) < S.length()){
                    cnt1++;
                }
            }
        }else{
            if(S[i] == '0'){
                cnt2++;
                if(S[i-1] == '1'){
                    cnt2++;
                }
                if((S.length()-1) == i+1 && S[i+1] == '1'){
                    cnt2++;
                }

            }else{
                if(S[i-1] == '1'){
                    cnt2++;
                }
                if((S.length()-1) == i+1 && S[i+1] == '1'){
                    cnt2++;
                }
            }
        }
    }
    if(cnt1 < cnt2){
        cout << cnt1 << endl;
    }else{
        cout << cnt2 << endl;
    }

    return 0;
}

Measured memory_bytes: 512
"""
author : halo2halo
date : 2, Feb, 2020
"""

import sys
import itertools

import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = readline().decode('utf8').split()

print(S[0][0]+S[1][0]+S[2][0])


Measured memory_bytes: 12488
N = gets.to_i

GRAPH = Hash.new { |h, k| h[k] = {} }
edges = (N - 1).times.map { gets.split.map(&:to_i) }

edges.each do |from, to, len|
  GRAPH[from][to] = len
  GRAPH[to][from] = len
end

queue = [[1, 0]]
visited = {}
ans = Array.new(N)

until queue.empty?
  v, dist = queue.shift

  if dist.even?
    ans[v - 1] = 0
  else
    ans[v - 1] = 1
  end

  next if visited[v]
  visited[v] = true

  GRAPH[v].each do |n, len|
    queue << [n, dist + len]
  end
end

puts ans


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

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;

void solve() {
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif
	int a, b;
	cin >> a >> b;

	if (a == b) cout << "Draw" << endl;
	else if (a == 1 || a > b && b != 1)  cout << "Alice" << endl;
	else  cout << "Bob" << endl;

}




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


	solve();
#ifdef _WIN32
	system("PAUSE");
#endif
	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = []
march = ['M', 'A', 'R', 'C', 'H']
S_sub = []
for i in range(N):
    S.append(input())
    if S[i][0] in march:
        S_sub.append(S[i][0])
m_cnt = S_sub.count('M')
a_cnt = S_sub.count('A')
r_cnt = S_sub.count('R')
c_cnt = S_sub.count('C')
h_cnt = S_sub.count('H')
mar_cnt = m_cnt*a_cnt*r_cnt
mac_cnt = m_cnt*a_cnt*c_cnt
mah_cnt = m_cnt*a_cnt*h_cnt
mrc_cnt = m_cnt*r_cnt*c_cnt
mrh_cnt = m_cnt*r_cnt*h_cnt
mch_cnt = m_cnt*c_cnt*h_cnt
arc_cnt = a_cnt*r_cnt*c_cnt
arh_cnt = a_cnt*r_cnt*h_cnt
ach_cnt = a_cnt*c_cnt*h_cnt
rch_cnt = r_cnt*c_cnt*h_cnt
print(mar_cnt+mac_cnt+mah_cnt+mrc_cnt+mrh_cnt+mch_cnt+arc_cnt+arh_cnt+
      ach_cnt+rch_cnt)

Measured memory_bytes: 10596