akhauriyash/Code-Regression huggingface dataset:
n=int(input())
x=[0 for i in range(2,1001)]
def soinsu(a):
    for i in range(2,a+1):
        t=0
        while(a%i==0):
            a/=i
            t+=1
        x[i-2]+=t
for i in range(2,n+1):
    soinsu(i)
a=1
for i in x:
    a*=i+1
    a%=10**9+7
print(a)

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <math.h>

using namespace std;
int N;

double Minkowski(int *xvec, int *yvec, int p)
{
    double rval = 0.0;
    
    if(p == -1)
    {
        for(int i = 0; i < N; ++i)
        { rval = fabs(xvec[i] - yvec[i]) > rval ? fabs(xvec[i] - yvec[i]) : rval; }
    }
    else if(p > 0)
    {
        for(int i = 0; i < N; ++i)
        { rval += pow(fabs(xvec[i] - yvec[i]), p); }
        rval = pow(rval, 1.0 / p);
    }
    
    return rval;
}

int main()
{
 
    cin >> N;
    int xvec[N], yvec[N];
    
    for(int i = 0; i < N; ++i)
    {
        int a; cin >> a;
        xvec[i] = a;
    }
    for(int i = 0; i < N; ++i)
    {
        int a; cin >> a;
        yvec[i] = a;
    }
    
    printf("%f\n",Minkowski(xvec, yvec, 1));
    printf("%f\n",Minkowski(xvec, yvec, 2));
    printf("%f\n",Minkowski(xvec, yvec, 3));
    printf("%f\n",Minkowski(xvec, yvec, -1));
    
    
    return 0;
}


Measured memory_bytes: 3344
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << ele << endl
#define print10(ele) cout << fixed << setprecision(10) << ele << endl

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  int n;
  cin >> n;
  print((n + 1) / 2);
  return 0;
}

Measured memory_bytes: 256
import java.util.PriorityQueue;
import java.util.Scanner;

//Missing Numbers
public class Main{

	class R implements Comparable<R>{
		boolean row;
		int p, c;
		public R(boolean row, int p, int c) {
			this.row = row;
			this.p = p;
			this.c = c;
		}
		public int compareTo(R o) {
			return c-o.c;
		}
	}

	void run(){
		Scanner sc = new Scanner(System.in);
		int NOT = 1<<29;
		for(boolean head=true;;head=false){
			int h = sc.nextInt();
			if(h==0)break;
			int w = sc.nextInt();
			if(!head)System.out.println();
			int[][] a = new int[h+1][w+1];
			boolean[][] m = new boolean[h+1][w+1];
			for(int i=0;i<=h;i++)for(int j=0;j<=w;j++){
				String s = sc.next();
				m[i][j] = "?".equals(s);
				if(m[i][j])a[i][j]=NOT;
				else a[i][j]=Integer.parseInt(s);
			}
			boolean ok = false;
			for(;;){
				PriorityQueue<R> q = new PriorityQueue<R>();
				int[] rc = new int[h], cc = new int[w];
				for(int i=0;i<h;i++)for(int j=0;j<w;j++){
					if(a[i][j]==NOT){
						rc[i]++; cc[j]++;
					}
				}
				for(int i=0;i<h;i++)if(0<rc[i])q.add(new R(true, i, rc[i]));
				for(int j=0;j<w;j++)if(0<cc[j])q.add(new R(false, j, cc[j]));
				if(q.isEmpty()){
					ok = true; break;
				}
				R r = q.poll();
				if(2<=r.c)break;
				if(r.row){
					int pj = -1, v = a[r.p][w];
					for(int j=0;j<w;j++){
						if(a[r.p][j]==NOT)pj = j;
						else v-=a[r.p][j];
					}
					a[r.p][pj] = v;
				}
				else{
					int pi = -1, v = a[h][r.p];
					for(int i=0;i<h;i++){
						if(a[i][r.p]==NOT)pi = i;
						else v-=a[i][r.p];
					}
					a[pi][r.p] = v;
				}
			}
			if(ok){
				for(int i=0;i<h;i++)for(int j=0;j<w;j++)if(m[i][j])System.out.println(a[i][j]);
			}
			else System.out.println("NO");
		}
	}

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

Measured memory_bytes: 0
import java.util.*;
import java.math.*;
import java.io.*;

public class Main{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int tt = in.nextInt();
		int sum = 0;
		for(int qq=1; qq<=tt; qq++){
			sum += in.nextInt();
		}
		if(sum<=n){
			System.out.println(n-sum);
		}else{
			System.out.println("-1");
		}
	}
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
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;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    int s;
    cin >> s;
    map<int,int> mp;
    mp[s]++;
    int i=1;

    while(mp.size()==i){
        if(s%2==0){
            s/=2;
        }else{
            s=3*s+1;
        }
        i++;
        mp[s]++;
    }

    cout << i << endl;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc131/tasks/abc131_d
# 最適なのは締切が速い順から取り掛かること
import sys
from operator import itemgetter
read = sys.stdin.readline


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


N = read_a_int()
AB = read_tuple(N)
AB.sort(key=itemgetter(1))
jikoku = 0
for a, b in AB:
    jikoku += a
    if jikoku > b:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 76508
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let r: usize = s.next().unwrap().parse().unwrap();
	let c: usize = s.next().unwrap().parse().unwrap();
	let k: usize = s.next().unwrap().parse().unwrap();

	let mut item = vec![vec![-1; c]; r];
	for _ in 0..k {
		let r: usize = s.next().unwrap().parse().unwrap();
		let c: usize = s.next().unwrap().parse().unwrap();
		let v: i64 = s.next().unwrap().parse().unwrap();
		item[r - 1][c - 1] = v;
	}

	let mut dp = vec![vec![std::i64::MIN; 4]; c];
	dp[0][0] = 0;

	for i in 0..r {
		let mut next = vec![vec![std::i64::MIN; 4]; c];
		for j in 0..c {
			let mut max = std::i64::MIN;
			for n in 0..4 {
				max.max_assign(dp[j][n]);
			}
			next[j][0] = max;
		}
		for j in 0..c {
			for n in 0..4 {
				if j > 0 {
					let a = next[j - 1][n];
					next[j][n].max_assign(a);
				}
			}
			for n in (0..4).rev() {
				if item[i][j] > 0 && n > 0 {
					let a = next[j][n - 1];
					next[j][n].max_assign(a + item[i][j]);
				}
			}
		}
		dp = next;
	}
	println!("{}", dp[c - 1].iter().max().unwrap());
}

pub trait UpdateAssign
where
	Self: PartialOrd,
{
	fn min_assign(&mut self, value: Self) -> bool;
	fn max_assign(&mut self, value: Self) -> bool;
}

impl<T> UpdateAssign for T
where
	T: PartialOrd,
{
	fn min_assign(&mut self, value: Self) -> bool {
		*self > value && {
			*self = value;
			true
		}
	}

	fn max_assign(&mut self, value: Self) -> bool {
		*self < value && {
			*self = value;
			true
		}
	}
}


Measured memory_bytes: 76448
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  int Count = 0;
  for (int i = 0; i < N; i++) {
    if (A.at(i) % 2 == 0) {
      if (A.at(i) % 3 == 0) {
        continue;
      }
      if (A.at(i) % 5 == 0) {
      continue;
      }
      Count++;
    }
  }
  if (Count == 0) {
    cout << "APPROVED" << endl;
  }
  if (Count != 0) {
    cout << "DENIED" << endl;
  }
}

Measured memory_bytes: 256
//In the name of Allah
#include <bits/stdc++.h>
using namespace std;

#define set SET
const int maxN = 100 * 1000 + 10; 
typedef long long ll; 
const int mod = 1e9 + 7; 

inline int mul( int a , int b ) { 
    return a * 1ll * b  % mod; 
}
inline int sum( int a , int b ) { 
    int c = a + b; 
    if( c >= mod ) c -= mod;
    return c;
}
int n;

ll s[maxN];
int dp[2][maxN];

int main() { 
    cin >> n;
    ll a[2]; cin >> a[0] >> a[1]; 


    n++;
    s[0] = 1e9;
    s[0] = -(s[0] * s[0] + 1000 );
    cin >> s[1]; 
    dp[0][0] = dp[1][0] = 1; 

    int st[2] = { 0 , 0 }; 

    for( int i = 2 ; i < n ; i++ ) { 
        cin >> s[i]; 
        for( int t = 0 ; t < 2 ; t++ ) { 
            int v = upper_bound( s , s + i - 1 , s[i] - a[t] ) - s;
            dp[t][i-1] = sum(dp[t][i-2] , dp[t^1][v-1]);
        }
        for( int t = 0 ; t < 2 ; t++ ) 
            if( s[i] - s[i-1] < a[t] ) { 
                dp[t][i-1] = sum( dp[t][i-1] , mod - dp[t][i-2] ); 
                for( ;st[t] < i - 1 ; st[t]++ ) 
                    dp[t][st[t]] = 0; 
            }
    }
    cout << sum(dp[0][n-2],dp[1][n-2]) << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstring>
#include<cstdio>
#define MAIN 200010
using namespace std;
const long long p=1000000007;
long long fact[MAIN]= {1},inv[MAIN]= {1};
long long Lucas(long long a,long long m)
{
    long long ans=fact[a];
    ans=(ans*inv[a-m]%p)*inv[m]%p;
    return ans;
}
long long power(long long a,long long b)
{
    long long ans=1;
    while(b)
    {
        if (b&1) ans=(ans*a)%p;
        b=b>>1;
        a=(a*a)%p;
    }
    return ans;
}
int main()
{
    long long h,w,a,b;
    scanf("%lld%lld%lld%lld",&h,&w,&a,&b);
    for (int i=1; i<=200000; i++)
    {
        fact[i]=(fact[i-1]*i)%p;
        inv[i]=power(fact[i],p-2);
    }
    long long ans=0;
    for (long long i=1; i<=w-b; i++)
        ans=(ans+Lucas(a+i-2,i-1)*Lucas(h-a+w-i-1,w-i))%p;
    printf("%lld\n",ans);
    return 0;
}

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

int main(){
    int h, n, i, a;
    cin >> h >> n;
    for(i=0; i<n; i++){
        cin >> a;
        h -= a;
    }
    h <= 0 ? printf("Yes\n") : printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
using namespace std;

int main()
{
    int K, A[3];
    cin >> A[0] >> A[1] >> A[2] >> K;
    for (int i = 1; i <= K; i++)
    {
        auto tmp = max_element(A, A + 3);
        *tmp *= 2;
    }
    cout << accumulate(A, A + 3, 0) << endl;
    return 0;
}

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

int match[809], c; bool p[10000009], used[809]; vector<int> g[809];

bool augment(int pos) {
	used[pos] = true;
	for (int i : g[pos]) {
		if (match[i] < 0 || !used[match[i]] && augment(match[i])) {
			match[pos] = i;
			match[i] = pos;
			return true;
		}
	}
	return false;
}
int bipartite_matching() {
	int res = 0;
	fill(match, match + c, -1);
	for (int i = 0; i < c; i++) {
		if (match[i] < 0) {
			fill(used, used + c, false);
			if (augment(i)) res++;
		}
	}
	return res;
}

int N, A, B, a[810], b[810], cnt; vector<int>X, Y;

int main() {
	cin >> N >> A >> B;
	for (int i = 1; i <= N; i++) {
		cin >> a[i] >> b[i];
		if (abs(a[i] - b[i]) <= A || (B <= abs(a[i] - b[i]) && abs(a[i] - b[i]) <= 2 * A)) {
			cnt++;
			continue;
		}
		if (a[i] - b[i] >= 0) X.push_back(a[i] - b[i]);
		else Y.push_back(a[i] - b[i]);
	}
	sort(X.begin(), X.end());
	sort(Y.begin(), Y.end());
	for (int i = 0; i < X.size(); i++) {
		for (int j = 0; j < Y.size(); j++) {
			if (abs(X[i] + Y[j]) <= A || (B <= abs(X[i] + Y[j]) && abs(X[i] + Y[j]) <= 2 * A)) {
				g[i].push_back(j + X.size());
				g[j + X.size()].push_back(i);
			}
		}
	}
	c = X.size() + Y.size();

	int cnt2 = bipartite_matching();

	cout << cnt + cnt2 << endl;
	return 0;
}



Measured memory_bytes: 3412
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n,k; cin>>n>>k;
	ll ans=1;
	rep(i,0,n){
		if(!i) ans*=k;
		else ans*=(k-1);
	}
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int a,b;
  scanf("%d %d",&a,&b);
  a--;
  int c=0;
  for (; a != -1; a--) {
    c=c+a;
  }
  int d=0;
  for (b--; b != -1; b--) {
    d=d+b;
  }
  printf("%d",d+c);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    int N, K;
    string S;
    cin >> N >> K >> S;

    int c[N + 2];
    REP(i, N + 2) c[i] = 0;
    int itr = 0;
    bool f = (S[0] == '0')? true : false;
    if (f) {
        c[0] = 0;
        itr++;
    }
    c[itr]++;
    FOR(i, 1, N) {
        if (S[i] == S[i - 1]) {
            c[itr]++;
        }
        else {
            itr++;
            c[itr]++;
        }
    }
    itr++;
    if (S[N - 1] == '0') {
        c[itr] = 0;
        itr++;
    }

    int sum = c[0];
    for (int i = 0; i < K; ++i) {
        if (i * 2 + 1 < itr) sum += c[i * 2 + 1];
        if (i * 2 + 2 < itr) sum += c[i * 2 + 2];
    }
    int maxSum = sum;

    int start = 2 * K + 1;
    int rstart = 0;
    for (int i = start; i < itr; i += 2, rstart += 2) {
        sum -= c[rstart];
        sum -= c[rstart + 1];
        sum += c[i];
        sum += c[i + 1];
        if (sum > maxSum) maxSum = sum;
    }

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


Measured memory_bytes: 896
import sys
import numpy as np
input = sys.stdin.readline

def main():
    N, M, Q = map(int, input().split())

    check = np.zeros((N+1, N+1))

    for i in range(M):
        l, r = map(int, input().split())
        check[r][l] += 1

    # print(check)
    for i in range(1, N+1):
        check[i] += check[i-1]
    for i in range(1, N+1):
        check[:,i] += check[:,i-1]
    # print(check)

    for i in range(Q):
        p, q = map(int, input().split())
        print(int(check[q][q] - check[q][p-1] - check[p-1][q] + check[p-1][p-1]))

if __name__ == "__main__":
    main()

Measured memory_bytes: 15256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <numeric>
#include <cassert>
#include <sstream>

using namespace std;

class apc001_c {
public:
    void solve(istream& in, ostream& out) {
        int N;
        cin >> N;
        string s;
        cout << 0 << endl;
        cin >> s;
        if (s == "Vacant") {
            return;
        }
        int male = (s == "Female");
        int low = 1, high = N - 1, ans = low;
        while (low <= high) {
            int mid = (low + high) / 2;
            cout << mid << endl;
            cin >> s;
            if (s == "Vacant") {
                return;
            } else if (s == "Female") {
                if (mid % 2 == male) {
                    high = mid - 1;
                } else {
                    ans = low;
                    low = mid + 1;
                }
            } else {
                if (mid % 2 == male) {
                    ans = low;
                    low = mid + 1;
                } else {
                    high = mid - 1;
                }
            }
        }
        cout << ans << endl;
        cin >> s;
        assert(s == "Vacant");
    }
};


int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	apc001_c solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 852
//#define _GLIBCXX_DEB // Iterator safety; out-of-bounds access for Containers, etc.
//#pragma GCC optimize "trapv" // abort() on (signed) integer overflow.
#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;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define ll long long int
#define mod 1000000007
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.1415926535897932384626
#define INF 1000000000
#define bits(n) __builtin_popcount(n)

int vis[100001];
vector<int> adj[100001];        
void dfs( int node) 
{
    vis[node] = 1;

    for (auto i : adj[node])
    {
        if (vis[i] == 0) 
            dfs( i);
    }
}

void solve()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    int c=0;
    for(int i=1;i<=n;i++)
    {
        if(vis[i]==0)
        {
            dfs(i);
            c++;
        }
    }
    cout<<c-1;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

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


Measured memory_bytes: 9964
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;
 
#define Pr(f,...) //printf(f,##__VA_ARGS__),fflush(stdout)
 
typedef long long ll;
 
const int N=3e5+50,P=1e9+7;

void upd(int &a,int b) { a+=b; if(a>=P)a-=P; }
 
int n,f[N][2][3][3],ans;
string s;
int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("dat.in","r",stdin);
	freopen("my.out","w",stdout);
#endif
	cin>>s;
	s+='1';
	n=s.length();
	f[0][0][0][0]=1;
	rep(i,0,n-1)rep(p,0,1)rep(len,0,2)rep(st,0,2){
		rep(c,0,1)if(s[i]=='0'+c||s[i]=='?'){
			int x=f[i][p][len][st];
			if(c==0){
				int ni=i+1,np=p,nlen,nst=st;
				if(len==0)nlen=len+1;
				else nlen=(len-1+1)%2+1;
				upd(f[ni][np][nlen][nst],x);
			}else{
				int ni=i+1,np,nlen=0,nst;
				if(len&1){
					np=p,nst=st;
					upd(f[ni][np][nlen][nst],x);
				}else{
					np=(p+1)&1,nst=st;
					if(len==0){
						if((np%2==1)&&st==0)nst=1;
						else if((np%2==0)&&st==1)nst=2;
					}
					upd(f[ni][np][nlen][nst],x);
				}
			}
		}
	}
	rep(p,0,1)rep(len,0,2)upd(ans,f[n][p][len][2]);
	printf("%d\n",ans);
	return 0 ;
}

Measured memory_bytes: 21764
N = int(input())
S = input()

white = [0] * (N + 1)
black = [0] * (N + 1)
for i, si in enumerate(S):
    black[i + 1] = black[i]
    white[i + 1] = white[i]
    if si == "#":
        black[i + 1] += 1
    if si == ".":
        white[i + 1] += 1

mi = 10 ** 10
for i in range(N + 1):
    b = black[i]
    w = white[N] - white[i]
    mi = min(w + b, mi)
print(mi)


Measured memory_bytes: 12776
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  long long a[10001];
  int n;
  long long sum=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n-1;i++){
    for(int j=0;j<n-1-i;j++){
      if(a[j]>a[j+1]){
	int temp=a[j];
	a[j]=a[j+1];
	a[j+1]=temp;
      }
    }
  }
  for(int i=0;i<n;i++){
    sum+=a[i];
  }
  cout << a[0] << ' ' << a[n-1] << ' ' << sum << endl;
  return(0);
}
  



Measured memory_bytes: 3160
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = read_func().strip().split()
    A = []
    for i in range(N):
        A.append(int(input_raw[i]))
    input_raw = read_func().strip().split()
    B = []
    for i in range(N):
        B.append(int(input_raw[i]))
    input_raw = read_func().strip().split()
    C = []
    for i in range(N):
        C.append(int(input_raw[i]))
    A.sort()
    B.sort()
    C.sort()

    A_backet = {}
    C_backet = {}
    A_ptr = 0L
    C_ptr = 0L
    count = 0L
    for i in range(N):
        while A_ptr < N and A[A_ptr] < B[i]:
            A_ptr += 1L
        while C_ptr < N and C[C_ptr] <= B[i]:
            C_ptr += 1L
        count += A_ptr * (N - C_ptr)
    print count




if __name__ == '__main__':
    main()


Measured memory_bytes: 65128
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#define mod 1000000007
#define ten5 100005
#define PI 3.1415926
using namespace std;

int num[26];

int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,n1=0,n2=0,n3;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=1,now=1;
    long long int a,a1;
    //float f,g,h;
    //char now,pre;
    string s,s1;
    cin>>s;
    a=s.size();
    for(i=0;i<a;i++)
    {
        a1=s[i]-'a';
        num[a1]++;
        if(num[a1]>1)
        {
            cout<<"no";
            return 0;
        }
    }
    cout<<"yes";
    return 0;
}



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

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Problem solver = new Problem();
        solver.solve(0, in, out);
        out.close();
    }

    static class Problem {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt(), K = in.nextInt();
            int[] arr = new int[N];
            for (int i = 0; i < N; i++)
                arr[i] = in.nextInt();

            Arrays.sort(arr);
            long sum = 0;
            for (int i = 0; i < N - K; i++) {
                sum += arr[i];
            }

            out.println(sum);
        }

    }

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

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

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

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

    }
}



Measured memory_bytes: 55864
import sys
n=int(input())
c=0
for i in range(n):
    d1,d2=map(int,input().split())
    if d1==d2:
        c+=1
    else:
        if c>=3:
            print('Yes')
            sys.exit()
        c=0

if c>=3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 62356
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N;
map<string, int> a;
signed main(){
	cin >> N;
	rep(i, N){
		string s;
		cin >> s;
		if(a.count(s) == 0) a[s] = 1;
		else a[s]++;
	}
	int M = 0;
	for(auto itr=a.begin(); itr!=a.end(); itr++){
		M = max(M, itr->second);
	}
	vector<string> ans;
	for(auto itr=a.begin(); itr!=a.end(); itr++){
		if(M == itr->second) ans.pb(itr->first);
	}
	ans.erase(unique(all(ans)), ans.end());
	rep(i, ans.size()){
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 26868
let security s =
  let a, b, c, d = (s / 1000, (s / 100)  mod 10, (s / 10)  mod 10, s mod 10)
  in
    if a <> b && b <> c && c <> d then "Good" else "Bad"

let () = Printf.printf "%s\n" (security (read_int()))


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

int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    int n = N % 1000;
    int ans = 0;
    if (n > 0) {
       ans = 1000 - n;
    }
    
    std::cout << ans;
    return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <stdio.h>
#include <math.h>

using namespace std;

int n;
double r[505];
double p[505];

int main(void)
{
  cin >> n;
  for(int i = 1; i <= n; i++) cin >> r[i];

  p[1] = r[1];
  for(int i = 2; i <= n; i++){
    p[i] = r[i];
    for(int j = 1; j < i; j++){
      double r1 = r[i], r2 = r[j];
      if(r1 > r2) swap(r1, r2);
      double l = sqrt( (r1+r2)*(r1+r2)-(r2-r1)*(r2-r1) );
      p[i] = max(p[i], p[j]+l);
    }
  }
  double ans = 0;
  for(int i = 1; i <= n; i++) ans = max(ans, p[i]+r[i]);
  printf("%.11f\n", ans);

  return 0;
}



Measured memory_bytes: 3300
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807/2;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

string s;
int main(){
	cin>>s;
	if(s=="SAT"){
		cout<<1<<endl;
	}else if(s=="SUN"){
		cout<<7<<endl;
	}else if(s=="MON"){
		cout<<6<<endl;
	}else if(s=="TUE"){
		cout<<5<<endl;
	}else if(s=="WED"){
		cout<<4<<endl;
	}else if(s=="THU"){
		cout<<3<<endl;
	}else if(s=="FRI"){
		cout<<2<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
##入力
N, M = list(map(int,input().split()))
sc = [list(map(int,input().split())) for _ in range(M)]
##最小の値(0)を先にいれておく(00...0)
numl = [0 for _ in range(N)]
##2桁以上と分かっている場合1桁目は1以上でなくてはならない
if N >= 2:
  numl[0] = 1
flag = 0
s = [sc[i][0] for i in range(M)]
c = [sc[i][1] for i in range(M)]
##数字を桁ごとにリストに入れる
for i in range(M):
  numl[s[i]-1] = c[i]
##最初の桁が0で2桁以上ならだめ
if numl[0] == 0 and N >= 2:
  flag += 1
##同じ桁で違う数字を指定されたらだめ
for i in range(0, M-1):
  for j in range(i+1, M):
    if s[i] == s[j] and c[i] != c[j]:
      flag += 1
 
#結果
if flag != 0:
  print(-1)
else:
  ##join使いたいので一度str型にした
  Numl = [str(a) for a in numl]
  num=''.join(Numl)
  print(num)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<v> vv;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<set<ll>> vsll;
typedef set<pair<ll, ll>> spll;
typedef vector<spll> vspll;
typedef vector<pll> vpll;
const ll MOD = 1e9 + 7;
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define yesno(f) \
    if (f)       \
        yes else no;
#define noo \
    { no return; }
#define round(x, y) ((2 * x + y) / (2 * y))
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define sz(x) (ll) x.size()
#define sq(x) ((x) * (x))

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

template <typename T = ll>
vector<T> ga(ll n, bool oneIndexed = false) {
    vector<T> a = vector<T>(n + oneIndexed);

    for (ll i = 0; i < n; i++) {
        T p;
        cin >> p;
        a[i + oneIndexed] = p;
    }

    return move(a);
}

template <typename T, typename A>
void pa(vector<T, A> const &a, ll begin = 0, ll end = -1) {
    if (end == -1)
        end = sz(a) - 1;
    for (ll i = begin; i <= end; i++) {
        cout << a[i] << " ";
    }
    cout << endl;
}

void solve() {
    ll h, a;
    cin >> h >> a;
    cout << ce(h, a) << endl;
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // freopen("file", "r", stdin);
    // freopen("file", "w", stdout);
    // ll t;cin >> t;while(t--)
    solve();
    return 0;
}

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

int main(){
	int n, m,data[10000]; int ans=0;
	cin >> n  >> m;
	for(int i=0;i<n;i++){
		cin >> data[i];
		if(m >= data[i]){
			ans++;
			m-= data[i];
		}
	}
	int mn = *min_element(data, data+n);
	 ans += m/mn;
	cout << ans << "\n";
}

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

using namespace std;
using ll = long long;
ll mo=1e9+7;
int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    for(auto & b : a) cin>>b;
    ll ret = 0;
    ll cur = 0;
    ll length = 1;
    for(int i=0;i<n;++i){
        if(length ==1) cur = a[i];
        else cur ^= a[i-1],length--;
        while(i+length<n&&cur+a[i+length] == (cur ^ a[i+length] ))cur ^= a[i+length],length++;
        ret += length;
    }
    cout << ret <<endl;
    return 0;
}



Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		String s = in.next();
		String t = in.next();
		int ans;

		String s_sub, t_sub;
		for (int i = 0; i < N; i++) {
			//sのi文字目からN-1文字目まで==tの0文字目からN-i-1文字目までが一致？
			s_sub = s.substring(i, N);
			t_sub = t.substring(0, N-i);
			if(s_sub.equals(t_sub)) {
				ans = 2*N - (N-i);
				System.out.println(ans);
				return;
			}
		}
		System.out.println(2*N);
	}
}

Measured memory_bytes: 9804
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

long long gcd(long long a, long long b) {
    if(a%b == 0) {
        return b;
    } else {
        return gcd(b, a%b);
    }
}

long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b;
}
 
int main() {
    int n; std::cin >> n;
    std::vector<long long> t(n);
    for(int i = 0; i < n; i++) {
        std::cin >> t[i];
    }

    long long ans;
    if(n != 1) {
    ans = lcm(t[0], t[1]);
    for(int i = 2;i < n; i++) {
        ans = lcm(ans, t[i]);
    }
    } else {
        ans = t[0];
    }

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

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

int main(){
	int n;
	cin >> n;
	vector<int> v(n);
	vector<int> c(n);
	rep(i,n) cin >> v[i];
	rep(i,n) cin >> c[i];
	int ans = 0;
	rep(i,n){
		if(v[i] - c[i] > 0) ans += v[i] - c[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
A = [int(x) for x in input().split()]
B = [a for a in A]
for i in range(N - 2, -1, -1):
  B[i] += B[i + 1]
C = [a for a in A]
for i in range(2, N):
  C[i] += C[i - 2]
D = [0 for i in range(N)]
for i in range(1, N + 1):
  if N - 1 - 2 * i < 0:
    break
  D[N - i] = (A[N - 1 - i] + A[N - 1 - 2 * i]) // 2 + 1
E = [b for b in B]
for i in range(1, N + 1):
  if N - 2 * i - 1 < 0:
    break
  E[N - i] += C[N - 2 * i - 1]
def binsearch(upper, lower, x):
  if x >= D[upper]:
    return upper
  if upper - lower == 1:
    return lower
  else:
    mid = (upper + lower) // 2
    if D[mid] <= x:
      return binsearch(upper, mid, x)
    else:
      return binsearch(mid, lower, x)
for q in range(Q):
  x = int(input())
  print(E[binsearch(N - 1, 0, x)])

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

int main(){
  string s;
  int n,k;
  
  cin>>n;
  
  pair<pair<string,int>,int> p[n];
  for(int i=0;i<n;i++){
    cin>>s>>k;
    p[i] = make_pair(make_pair(s,-k), i+1);
  }
  
  sort(p,p+n);
  
  for(int i=0;i<n;i++)
    cout<<p[i].second<<endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(3)
#include <bits/stdc++.h>
#include<unordered_set>
using namespace std;

namespace _ {
	bool rEOF = 1;//为0表示文件结尾
	inline char nc() {
		static char buf[100000], *p1 = buf, *p2 = buf;
		return p1 == p2 && rEOF && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? (rEOF = 0, EOF) : *p1++;
	}
	template<class _T>
	inline bool read(_T &num) {
		char c = nc(), f = 1; num = 0;
		while (c<'0' || c>'9')c == '-' && (f = -1), c = nc();
		while (c >= '0'&&c <= '9')num = num * 10 + c - '0', c = nc();
		return (bool)(num *= f);
	}
	inline bool need(char &c) { return c >= 'a'&&c <= 'z' || c >= '0'&&c <= '9' || c >= 'A'&&c <= 'Z'; }//读入的字符范围
	inline bool read_str(char *a) {
		while ((*a = nc()) && need(*a) && rEOF)++a;
		*a = '\0'; return rEOF;
	}
}using namespace _;

void file(bool opt)
{
	if (opt&&fopen("in.txt", "r"))
	{
		freopen("in.txt", "r", stdin);
		//freopen("out.txt", "w", stdout);
	}
}

map<string,long long>p;
string str;
int main()
{
	int n;
	cin >> n;
	long long ans = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> str;
		sort(str.begin(), str.end());
		ans += p[str];
		p[str]++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11136
// Problem : D - XOR World
// Contest : AtCoder - AtCoder Beginner Contest 121
// URL : https://atcoder.jp/contests/abc121/tasks/abc121_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e6 + 1;

ll a, b;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> a >> b;
	if (b - a <= 10) {
		ll ans = 0;
		for (ll i = a; i <= b; i++) {
			ans ^= i;
		}
		cout << ans;
		return 0;
	}
	ll ans = 0;
	while (a % 4 != 0) {
		ans ^= a;
		a++;
	}
	while (b % 4 != 3) {
		ans ^= b;
		b--;
	}
	cout << ans;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e4;
bool cmp(int s,int f){
    if(s>f)
    return true;

    return false;

}
int arr[N];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",arr+i);
    int sum=0;
    sort(arr,arr+n,cmp);
    for(int i=0;i<n;i++){
        if(i%2==0)
        sum+=arr[i];
        else
        sum-=arr[i];
    }
    printf("%d\n",sum);

}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n,m,k,x[SZ],y[SZ]; Edgc
const ll MOD=1e9+7;
ll ca=1,cc[555][555],aa[555];
ll qp(ll a,ll b)
{
    ll ans=1;
    while(b)
    {
        if(b&1) ans=ans*a%MOD;
        a=a*a%MOD; b>>=1;
    }
    return ans;
}
void proc(vector<int> edg)
{
	if(!edg.size()) return;
	if(edg.size()<=1) {ca=ca*k%MOD; return;}
	map<int,int> d;
	for(auto e:edg) ++d[x[e]],++d[y[e]];
	bool cyc=1;
	for(auto g:d) if(g.se!=2) cyc=0;
	if(cyc) ca=ca*aa[edg.size()]%MOD;
	else ca=ca*cc[edg.size()+k-1][k-1]%MOD;
}
stack<int> q;
int dfn[SZ],low[SZ],C=0;
void tj(int x,int fe)
{
	low[x]=dfn[x]=++C;
	for esb(x,e,b)
	{
		if(!dfn[b])
		{
			q.push(vc[e]);
			tj(b,vc[e]);
			low[x]=min(low[x],low[b]);
			if(low[b]<dfn[x]) continue;
			vector<int> v;
			while(!q.empty())
			{
				int t=q.top(); q.pop();
				v.pb(t); if(t==vc[e]) break;
			}
			proc(v);
		}
		else if(vc[e]!=fe)
		{
			low[x]=min(low[x],dfn[b]);
			if(dfn[x]>dfn[b]) q.push(vc[e]);
		}
	}
}
int main()
{
	for(int i=0;i<555;++i)
	{
		cc[i][0]=1;
		for(int j=1;j<=i;++j)
			cc[i][j]=(cc[i-1][j-1]+cc[i-1][j])%MOD;
	}
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<555;++i)
	{
		aa[i]=0;
		for(int j=1;j<=i;++j)
			aa[i]+=qp(k,__gcd(j,i)),aa[i]%=MOD;
		aa[i]=aa[i]%MOD*qp(i,MOD-2)%MOD;
	}
	for(int i=1;i<=m;++i)
		scanf("%d%d",x+i,y+i),adde(x[i],y[i],i);
	for(int i=1;i<=n;++i)
		if(!dfn[i])
		{
			tj(i,0); vector<int> v;
			while(!q.empty())
				v.pb(q.top()),q.pop();
			proc(v);
		}
	ca=(ca%MOD+MOD)%MOD;
	printf("%lld\n",ca);
}


Measured memory_bytes: 16768
fn main() {
    let mut line = String::new();
    let stdin = std::io::stdin();
    let _ = stdin.read_line(&mut line);
    let n = line.split_whitespace().nth(0).unwrap().parse::<usize>().unwrap();
    line.clear();
    let mut towers = vec![true; n];
    let _ = stdin.read_line(&mut line);
    let hs: Vec<_> = line.split_whitespace().map(|x| x.parse::<usize>().unwrap()).collect();
    line.clear();
    while let Ok(l) = stdin.read_line(&mut line) {
        if l <= 0 { break; }
        let ab: Vec<_> = line.split_whitespace().map(|x| x.parse::<usize>().unwrap()-1).collect();
        line.clear();
        if hs[ab[0]] <= hs[ab[1]] { towers[ab[0]] = false; }
        if hs[ab[0]] >= hs[ab[1]] { towers[ab[1]] = false; }
    }
    println!("{}", towers.iter().filter(|&x| *x).count());
}


Measured memory_bytes: 4076
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
    s.find_by_order(k) ---> returns iterator to the element at index(from 0) k
    s.order_of_key(val) ---> number of elements that are strictly smaller than the given value
*/
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int tc; cin >> tc; cin.ignore(); while(tc--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}

ll n;
vll a;
set <pll> l, r;

int main() {
	fast();

    /*NA – JEONG – MO – SA – JI – MI – DA – CHAE – TZU*/
    
    cin >> n;
    a.resize(n);
    set <ll> x;
    for(int i=0; i<n; i++){
        cin >> a[i].ff >> a[i].ss;
        l.ins({a[i].ff-a[i].ss, i});
        r.ins({a[i].ff+a[i].ss, i});
        x.ins(i);
    }
    ll ind = 0;
    ll ans = 0;
    auto z = r.begin();
    while(z!=r.end()&&ind<n){
        pll xx = *z;
        ll i = xx.ss;
        ll right = xx.ff;
        z++;
        if(x.find(i)==x.end()){
            continue;
        }
        ans++;
        while(l.size()&&l.begin()->ff<right){
            pll y = *l.begin();
            x.er(y.ss);
            l.er(l.begin());
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 19072
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>

using namespace std;

#define x first
#define y second
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define all(x) x.begin(),x.end()
#define SZ(x) int(x.size())
#define rep(i, a, b) for(int i = a; i < b; i++)
#define per(i, a, b) for(int i = b-1; i >= a; i--)
#define DBG(x) cerr << (#x) << "=" << x << "\n";
#define ll long long
#define inf 1000000007
#define mod 1000000007
#define N 1005

template<typename U, typename V> void Min(U &a, const V & b){if(a > b)a = b;}
template<typename U, typename V> void Max(U &a, const V & b){if(a < b)a = b;}
template<typename U, typename V> void add(U &a, const V & b){a = (a + b) % mod;}
template<typename U> U gcd(U a, U b){
    if(a == 0)return b;
    if(b == 0)return a;
    if(a >= b)return gcd(a % b, b);
    else return gcd(a, b % a);
}
int pow(int a, int b){
    int ans = 1;
    while(b){
        if(b & 1)ans = 1LL * ans * a % mod;
        a = 1LL * a * a % mod;
        b >>= 1;
    }
    return ans;
}

int ans, s, t, vis[N], d[N], p[N];
vi g[N];
void dfs(int u){
    vis[u] = 1;
    for(auto &v : g[u]){
        if(vis[v] == 2)continue;
        else if(vis[v]){
            int K = d[u] - d[v] + 1;
            if(K < ans){
                ans = K, 
                s = v, t = u;
            }
        }
        else{
            d[v] = d[u] + 1;
            p[v] = u;
            dfs(v);
        }
    }
    vis[u] = 2;
}
int main(){
    int T, m, n, i, j, k, K;
    scanf("%d%d", &n, &m);
    rep(i, 0, m){
        scanf("%d%d", &j, &k);
        j--, k--;
        g[j].pb(k);
    }
    ans = n + 1;
    rep(i, 0, n)if(!vis[i]){
        dfs(i);
    }
    if(ans > n){
        puts("-1");
        return 0;
    }
    int x = t;
    while(x != s){
        vis[x] = 3;
        x = p[x];
    }
    vis[s] = 3;
    vi q;
    while(s != t){
        q.pb(s);
        int mx = -1, y;
        for(auto &x : g[s])if(vis[x] == 3 && d[x] > mx){
            mx = d[x];
            y = x;
        }
        s = y;
    }
    q.pb(t);
    printf("%d\n", SZ(q));
    for(auto &x : q)
    printf("%d\n", x + 1);
}


Measured memory_bytes: 384
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#define ll long long
using namespace std;



int main(){
  ll A,B,maxs;
  cin>>A>>B;
  maxs=max(A+B,A-B);
  maxs=max(maxs,A*B);
  cout<<maxs<<endl;
  return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var N = GetInt();
            var L = new long[N+1];
            L[0] = 2;
            L[1] = 1;
            for(int i = 2; i < N+1; i++)
            {
                L[i] = L[i - 2] + L[i - 1];
            }
            var ans = L[N];
            Console.WriteLine(ans);
        }


        static public string GetStr() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

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

int main(){
  string s;
  cin >> s;
  int d[26] = {};
  int a = 0;
  
  for(int i = 0;i < s.size();i++) d[s.at(i) - 'a']++;
  
  for(int i = 0;i < 26;i++){
  if(d[i] % 2 == 1){
    a = 1;
    break;
  }
  }
  
  if(a) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256