akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
using namespace std;

const int MAXN=110;
const int MAXM=22000;
const long long INF=101000000000LL;
struct Edge {
	int to;
	long long flow;
	Edge *next, *pair;
}g[MAXM],*head[MAXN];
int eptr=0;
Edge* _addedge(int a, int b, long long f) {
	g[eptr].to = b;
	g[eptr].flow = f;
	g[eptr].next = head[a];
	head[a] = &g[eptr];
	return &g[eptr++];
}
void addEdge (int a, int b, long long f) {
	Edge* t1=_addedge(a,b,f);
	Edge* t2=_addedge(b,a,0);
	t1->pair=t2; t2->pair=t1;
}

int S,T,maxsap;
int h[MAXN],nh[MAXN];
long long sap(int p, long long low) {
	if (p==T)
		return low;
	long long left=low;
	int hmin=maxsap;
	for (Edge *e=head[p]; e; e=e->next) {
		if (e->flow>0 && h[p]==h[e->to]+1) {
			long long tt=sap(e->to, min(e->flow,left));
			e->flow-=tt; e->pair->flow+=tt;
			left-=tt;
			if (!left || h[S]==maxsap)
				return low-left;
		}
		if (e->flow>0 && hmin>h[e->to]+1)
			hmin = h[e->to]+1;
	}
	if (low==left) {
		if (! --nh[h[p]])
			h[S]=maxsap;
		else
			++nh[ h[p]=hmin ];
	}
	return low-left;
}
int main() {
	memset(head, 0, sizeof(head));
	memset(h,0,sizeof(h));
	memset(nh,0,sizeof(nh));
	int n;
	cin>>n;
	S=0; T=n+1; maxsap=T+1; nh[0]=maxsap;
	long long ans1=0;
	for (int i=1; i<=n; i++) {
		int tt; cin>>tt;
		if (tt>0) {
			ans1 += tt;
			addEdge(i, T, tt);
		}
		else
			addEdge(S, i, -tt);
	}
	for (int i=1; i<=n; i++)
		for (int k=2; i*k<=n; k++)
			addEdge(i, i*k, INF);
	long long ans2=0;
	while (h[S]<maxsap)
		ans2 += sap(S,INF);
	cout<<ans1-ans2<<endl;
	return 0;
}


Measured memory_bytes: 256
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       x:usize,
    }

    let mut n = 100;
    for i in 0.. {
        n += (n as f64 * 0.01).floor() as usize;
        //mydbg!(n);
        if n >= x {
            echo!(i + 1);
            return;
        }
    }
}


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

int main(){
  int N ;
  cin >> N ;
  int l[100010] ,r[100010] ;
  for(int i=0;i<N;i ++)
    cin >> l[i] >> r[i] ;
  int ans=0 ;
  for(int i=0;i<N;i ++)
    ans += (r[i] - l[i] + 1 ) ;
  cout << ans << endl ;
}

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

#define MOD 1000000007
typedef unsigned long long ull;

int n;
string s;
int main() {
  cin >> n >> s;
  string res = "";
  char c;
  for (int i = 0; i < (int)s.size(); i++) {
    if (c != s.at(i)) {
      res += {s.at(i)};
      c = s.at(i);
    }
  }

  cout << res.length() << endl;
}


Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String line = sc.nextLine();

      	if(line.equals("ABC")) {
	        System.out.println("ARC");
        } else {
	        System.out.println("ABC");
        }
    }
}

Measured memory_bytes: 26904
#include<iostream>
#include<string>
#include<cmath>
#include<math.h>
//#include<array>
#include<algorithm>
//#include<queue>
#include<deque>
#include<vector>
//#include<utility>
//#include<set>
//#include<map>
//#include<list>
//#include<bitset>
//#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI  r;
//	if (x < y) {
//		swap(x, y);
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x, LLI y) {
//	return x / gcd(x, y) * y;
//}

//long nCr(int n, int r) {
//	long ans = 1;
//	for (int i = n; i > n - r; i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; i++) {
//		ans = ans / i;
//	}
//	return ans;
//}
//long nHr(int n, int r) {
//	n = n + r - 1;
//	return nCr(n, r);
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	LLI MAX = 0, MAX2 = 0;
	cin >> N;
	vector<LLI>vec(N);
	for (int i = 0; i < N; i++) {
		cin >> vec[i];
		if (MAX <= vec[i]) {
			MAX2 = MAX;
			MAX = vec[i];
		}
		else if (MAX2 < vec[i]) {
			MAX2 = vec[i];
		}
	}
	for (int i = 0; i < N;i++) {
		if (vec[i] == MAX) {
			cout << MAX2 << endl;
		}
		else {
			cout << MAX << endl;
		}
	}
}

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

template<class T> inline void chmax(T& a, T b) { if(b > a) a = b; }

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

int m, n;
bool thin[90][90];
int dfs(int y, int x) {
	int res = 0;
	thin[y][x] = 0;
	for(int i = 0; i < 4; ++i) {
		int nx = x + dx[i], ny = y + dy[i];
		if(nx < 0 || nx >= m || ny < 0 || ny >= n)
			continue;

		if(thin[ny][nx])
			chmax(res, dfs(ny, nx));
	}
	thin[y][x] = 1;
	return res + 1;
}

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

	for(; cin >> m >> n, m;) {
		for(int i = 0; i < n; ++i)
			for(int j = 0; j < m; ++j)
				cin >> thin[i][j];

		int ans = 0;
		for(int i = 0; i < n; ++i)
			for(int j = 0; j < m; ++j)
				if(thin[i][j])
					chmax(ans, dfs(i, j));

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

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

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

  char a = S[0];
  if (S[1] == a){
    if ((S[2] == S[3]) && (S[2] != a)){
      cout << "Yes" << endl;
    } else{
      cout << "No" << endl;
    }
  } else if (S[2] == a){
    if ((S[1] == S[3]) && (S[1] != a)){
      cout << "Yes" << endl;
    } else{
      cout << "No" << endl;
    }
  } else if (S[3] == a){
    if ((S[1] == S[2]) && (S[1] != a)){
      cout << "Yes" << endl;
    } else{
      cout << "No" << endl;
    }
  } else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
// Library
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

// TYPEDEFS
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

// CONSTANTS
#define SZA 0
#define SZB 0

// MACRO
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
#define ABS(X) (((X) > 0)? (X) : -(X))
#define YN(X) ((X)? "Yes" : "No")
#define SWAP(T, X, Y) {T t; t = X; X = Y; Y = t;}

#define F1 first
#define S2 second
#define PB push_back
#define MP make_pair


// Global Tables

//ull gPreProcess[SZA][SZB];

// Functions

void Print2DVector(vector<vector<int>>& v)
{
    ull i, j; 
    for(i = 0; i < v.size(); i++)
    {
        for(j = 0; j < v[i].size(); j++)
        {
            cout << v[i][j];
            if(j == v[i].size()-1)
            {
                cout << endl;
            }
            else
            {
                cout << " ";
            }
        }
    }
}

void PrintVector(vi& v)
{
    ull i;
    for(i = 0; i < v.size(); i++)
    {
        cout << v[i];
        if(i == v.size()-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PrintArr(int* a, ull N)
{
    ull i;
    for(i = 0; i < N; i++)
    {
        cout << a[i];
        if(i == N-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PreProcessTables()
{
    ull i, j;
    for(i = 0; i < SZA; i++)
    {
        for(j = 0; j < SZB; j++)
        {
            break;
        }
        break;
    }
}

void TC(int t)
{
    int N, count = 0, D1, D2;
    bool bFlag = false;
    cin >> N;
    for(int i = 0; i < N; i++)
    {
        cin >> D1 >> D2;
        if(D1 == D2)
        {
            count++;
            if(count == 3)
            {
                bFlag = true;
            }
        }
        else
        {   
            count = 0;
        }
    }
    cout << YN(bFlag) << endl;
}

// Main

int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    PreProcessTables();

    int T = 1, t;
    //cin >> T;
    for(t = 1; t <= T; t++)
    {
        TC(t);
    }
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <queue>
#include <vector>
#include <utility>
#include <algorithm>

int main()
{
    int N, M;
    std::cin >> N >> M;
    std::vector<std::pair<int, int> > job(N); // job[i] = (A[i], B[i])
    for(int i=0; i<N; i++) scanf(" %d %d", &(job[i].first), &(job[i].second));

    std::sort(job.begin(), job.end(), std::greater<std::pair<int, int> >());
    std::priority_queue<int> q;
    long long sum = 0;
    for(int i=1; i<=M; i++){
        while(!job.empty() && job.back().first == i){
            q.push(job.back().second);
            job.pop_back();
        }
        if(!q.empty()){
            sum += q.top();
            q.pop();
        }
    }

    std::cout << sum << std::endl;
}

Measured memory_bytes: 1660
n = input()
numbers = [int(x) for x in input().split()]

min_n = min(numbers)
max_n = max(numbers)

squares_sums = []
for y in range(min_n, max_n+1):
    squares_sums.append(sum([((x - y) ** 2) for x in numbers]))
print(min(squares_sums))


Measured memory_bytes: 3060
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int main() {
    int k, x;
    cin >> k >> x;

    string ans = (500*k >= x) ? "Yes" : "No";
    cout << ans << endl;
    
    return 0;
}

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

int main(){

    char num[1000];
    int size,sum,i = 0;
    while(1){
        scanf("%s",num);
        if(num[0] == '0'){
            break;
        }
        size = strlen(num);
        for(i = 0; i < size; i++){
            sum += num[i] - '0';
        }
        printf("%d\n",sum);
        sum = 0;
    }
    return 0;
}



Measured memory_bytes: 2056
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int A, B, C, D;
	
	cin>>A>>B>>C>>D;
	
	while(true){
		C -= B;
		
		if(C <= 0) {
			cout<<"Yes"<<endl;
			return 0;
		}
		
		A -= D;
		if(A <= 0) {
			cout<<"No"<<endl;
			return 0;
		}
		
	}
	
	
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define INF 100000000
using namespace std;
const int mod = 1000000007;

int main() {

  int64_t N,M;
  cin>>N>>M;
  if(N==1||M==1)cout<<1<<endl;
  else if(N%2==0){N/=2; cout<<N*M<<endl;}
  else if(M%2==0){M/=2;cout<<N*M<<endl;}
  else {int64_t k=N*M; k/=2; k++; cout<<k<<endl;}
}


Measured memory_bytes: 256
from itertools import accumulate
n,k = map(int,input().split())
a = list(map(int,input().split()))
suma = sum(a)
devisor = []
for i in range(1,int(suma**0.5)+1):
  if suma%i == 0:
    devisor.extend((i,suma//i))
devisor.sort(reverse=True)
for x in devisor:
  b = [a[i]%x for i in range(n)]
  b.sort()
  sumb = list(accumulate(b))
  for y in range(n-1):
    bf = sumb[y]
    bl = sumb[n-1]-sumb[y]
    if bf%x == (x-(bl%x))%x:
      if k>=max(bf,(n-1-y)*x-bl):
        print(x)
        exit()
      else:
        continue

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

int     main() {
        long W, H, x, y;
        long double SS;
        cin >> W >> H >> x >> y;
        SS=W*H;
        SS /= 2;
        int k=1;
        if (W != x*2) k=0;
        if (H != y*2) k=0;
        cout << SS << " " << k << endl;
        return 0;
}

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

int main()
{
    int n; cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    int ans = 0;
    int mini = 1000000;
    for(int i = 0; i < n; i++) {
        mini = min(mini, p[i]);
        if(p[i] <= mini) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4044
use proconio::{fastout, input};
use std::collections::BTreeMap;

#[fastout]
fn main() {
    input! {
        n: usize,
        k: i64,
        q: usize,
        a: [i64; q]
    };

    let a: Vec<i64> = a.iter().map(|x| x - 1).collect();
    let mut map = BTreeMap::new();

    for i in a.iter() {
        let count = map.entry(i.to_string()).or_insert(0);
        *count += 1;
    }

    for i in 0..n {
        let x = map.get(&i.to_string());
        match x {
            Some(value) => {
                if k - (q as i64 - value) > 0 {
                    println!("Yes")
                } else {
                    println!("No")
                }
            }
            None => {
                if k - q as i64 > 0 {
                    println!("Yes")
                } else {
                    println!("No")
                }
            }
        }
    }
}


Measured memory_bytes: 9380
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main(void){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(a-b)<=d&&abs(b-c)<=d){
        cout<<"Yes"<<endl;
        }else if(abs(a-c)<=d) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    
    
}


Measured memory_bytes: 256
n,y=[int(i) for i in input().split()]
def main():
    for i in range(y//10000+1):
        for j in range(n-i+1):
            sen=(y-i*10000-j*5000)
            if sen%1000==0 and i+j+sen//1000==n:
                print("{} {} {}".format(i,j,sen//1000))
                return True
    return False
if not main():
    print("-1 -1 -1")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
  
int main(){
    string s,t;
    cin>>s>>t;
    int sl=s.length();
    int tl=t.length();
    int dp[3001][3001];
    rep(i,sl+1)dp[i][0]=0;
    rep(i,tl+1)dp[0][i]=0;
    rep2(1,i,sl+1){
        rep2(1,j,tl+1){
            if(s[i-1]==t[j-1]){
                dp[i][j]=dp[i-1][j-1]+1;
            }else{
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    string ans="";
    int x = sl;
	int y = tl;
	while(x > 0 && y > 0){
		if(dp[x][y] == dp[x-1][y]){
			x--;
		}else if(dp[x][y] == dp[x][y-1]){
			y--;
		}else{
			x--;
			y--;
			ans.push_back(s[x]);
		}
	}
    reverse(ans.begin(), ans.end());
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35456
while True:
    n, x = map(int, raw_input().split())
    if n == x == 0:
        break;
    cnt = 0
    for i in range(1, n):
        for j in range(i + 1, n):
            tmp = x - i - j
            if tmp > j and tmp <= n:
                cnt += 1
    print cnt

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

int main() {
    int h, w;
    int i, j;
    while (true) {
        cin >> h >> w;
        if (h == 0 && w == 0) {
            break;
        }
        for (i = 0; i < h; i++) {
            for (j = 0; j < w; j++) {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
}

Measured memory_bytes: 3088
//---Vaidik Patel---//
//-------------------Proud to be Indian--------------------------------//
#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set,multi multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds;
#define int long long int
#define ld long double
#define pii pair<int,int>
typedef tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order()
#define deb1(x) cout<<#x<<" : "<<x<<"\n";
#define deb2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<"\n";
#define deb3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<"\n";
#define deb4(x,y,z,w) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<"\t"<<#w<<" : "<<w<<endl;
#define deb5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define deb6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rFOR(i,a,b) for(int i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vvi vector<vector<int>>
#define M 1000000007
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int powermodm(int x,int n,int m)
{int ans=1;   while(n){if(n&1){ans=(ans*x)%m;}x=(x*x)%m;n=n>>1;}return ans;}

void solve()
{
    int x;
    cin>>x;
    cout<<(x==0)<<"\n";

}
signed main()
{
    
    FIO
    int t;
    t=1;
    //cin>>t;
    FOR(i,0,t)
    {
        solve();
    }
}


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

vector<int> parL,parR; int N,K,L;

void initialize(){
  parL.resize(N); parR.resize(N);
  for(int i = 0; i < N; i++){
    parL[i] = parR[i] = i;
  }
}

int rootL(int x){
  if( x == parL[x]){ return x;}
  else{
    return parL[x] = rootL(parL[x]);
  }
}

int rootR(int x){
  if( x == parR[x]){ return x;}
  else{
    return parR[x] = rootR(parR[x]);
  }
}

void uniteR(int x, int y){
  if( rootR(x) == rootR(y)){ return ;}
  else{
    parR[rootR(x)] = rootR(y);
  }
}

void uniteL(int x, int y){
  if( rootL(x) == rootL(y)){ return ;}
  else{
    parL[rootL(x)] = rootL(y);
  }
}

bool issameL(int x, int y){
  return rootL(x) == rootL(y);
}

bool issameR(int x, int y){
  return rootR(x) == rootR(y);
}

int main(){
  cin >> N >> K >> L;
  initialize();
  for(int i = 0; i < K; i++){
    int p,q; cin >> p >> q; p--; q--;
    uniteR(p,q);
  }
  for(int j = 0; j < L; j++){
    int r,s; cin >> r >> s; r--; s--;
    uniteL(r,s);
  }
  
  map<pair<int,int>,int> mp;
  
  for(int i = 0; i < N; i++){
    mp[{rootR(i),rootL(i)}]++;
  }
  
  for(int i = 0; i < N; i++){
    cout << mp[{rootR(i),rootL(i)}] << " ";
  }
  
  cout << endl;
  
  return 0;
}
  

Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long int x;
    cin >> x;
    if(x%11 ==0){
        cout << x/11*2;
    }else if(x%11 <= 6){
        cout << x/11*2+1;
    }else{
        cout << x/11*2+2;
    }
    return 0;
}

Measured memory_bytes: 256
N, M = [int(x) for x in input().split()]
A = [(int(x) % M) for x in input().split()]
sA = [0]
for i in range(0, N):
    sA.append((sA[i]+A[i]) % M)
dA = {}
ans = 0
for i in range(0, N+1):
    dA.setdefault(sA[i], 0)
    ans += dA[sA[i]]
    dA[sA[i]] += 1
print(ans)


Measured memory_bytes: 16212
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
 
int main() {
  string s;
  cin >> s;
  if (s[s.size()-1] == 's') s += "es";
  else s += "s";
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>

template<typename T> bool chmax(T &a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}

template<typename T> bool chmin(T &a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}

using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N,A,B;
    cin>>N>>A>>B;
    vll X(N);
    for(ll i=0;i<N;i++)cin>>X[i];
    
    ll ans=0;
    for(ll i=1;i<N;i++){
        if((X[i]-X[i-1])*A>B)ans+=B;
        else ans+=(X[i]-X[i-1])*A;
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
#ifndef ONLINE_JUDGE
#define freopen freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#else
#define freopen //comment
#endif
#define io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define pb push_back
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

 main() 
{
   //#define int long long int 
   //freopen
   io
   int h,w,k;
   cin>>h>>w>>k;
   char v[h+1][w+1];
   int tot=0;
   for(int i=0;i<h;i++)for(int j=0;j<w;j++){cin>>v[i][j];if(v[i][j]=='#')tot++;}
   int black=tot,ans=0;
   for(int a=0;a<(1<<h);a++)
   {
    for(int b=0;b<(1<<w);b++)
    {
      bitset<6>x(a);
      bitset<6>y(b);
      map<pair<int,int>,int>chk;
      // cout<<"x"<<endl;
      // for(int i=0;i<6;i++)cout<<x[i]<<" ";
      // cout<<endl;
      // cout<<"y"<<endl;
      // for(int i=0;i<6;i++)cout<<y[i]<<" ";
      // cout<<endl;
      black=tot;

      for(int i=0;i<6;i++)
      {
        if(x[i])
        {
          for(int j=0;j<w;j++)
          {
            if(v[i][j]=='#' && chk[{i,j}]==0){chk[{i,j}]++;black--;}
          }
        }
      }
      for(int i=0;i<6;i++)
      {
        if(y[i])
        {
          for(int j=0;j<h;j++)
          {
            if(v[j][i]=='#' && chk[{j,i}]==0){black--;chk[{j,i}]++;}
          }
        }
      }
      // cout<<"black="<<black<<endl;
      if(black==k){ans++;}


    }
   }
   cout<<ans<<endl;

   
  return 0;

}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
#define rep(i,a,n) for(Int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(Int (i)=(a); (i)<=(n); (i)++)
const int MAX_N = 1000000;
const Int MAX_N_Int = 1000000000000;

template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}


Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}


Int fact_mod(Int n, Int mod) {
    Int f = 1; repq(i,2,n) f = f * (i % MOD) % MOD;
    return f;
}

// 繰り返し二乗法 (modの世界での累乗)
Int mod_pow(Int x, Int n, Int mod) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return res;
}

// 組み合わせ nCr を求める
Int combination_mod(Int n, Int r, Int mod) {
    if(r > n-r) r = n-r;
    if(r == 0) return 1;
    Int a = 1;
    rep(i, 0, r) a = a * ((n-i) % mod) % mod;
    Int b = mod_pow(fact_mod(r, mod), mod-2, mod);
    return (a % mod) * (b % mod) % mod;
}

bool rev(string s){
    string t=s;
    reverse(s.begin(),s.end());
    return s==t;
}
Int w(Int n, Int a){
    return (n+a-1)/a;
}
int main() {
    //COMinit();
    IOS;
    prec;
    Int a=0,b=0,c,d,e,n,m,x,k,y=0,ans=0;
    string str,s,t,u;
    cin>>n>>a>>b>>c>>d>>e;
    ans=w(n,min({a,b,c,d,e}));
    cout<<ans+4;
    //cout<<w(n,a);










    cout<<endl;
    return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
// #define endl "\n"
#define print_array(name,n) for(ll o=0;o<n;o++) cout<<name[o]<<" "
#define fr(i,f,t) for(ll i=(f);i<t;i++)
#define fb(i,f,t) for(ll i=(f);i>=t;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}
template <typename T>
string NumberTostring(T Number )
{
	ostringstream ss;
	ss<<Number;
	return ss.str();
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n;
    string s;
    cin>>n;
    cin>>s;
    // cout<<n<<s<<endl;
    int r[n+1] = {0};
    int g[n+1] = {0};
    int b[n+1] = {0};

    int cntr = 0;
    int cntg = 0;
    int cntb = 0;

    for(int i=n-1;i>=0;i--){
    	r[i] = r[i+1];
    	g[i] = g[i+1];
    	b[i] = b[i+1];
    	if(s[i]=='R'){
    		r[i]++;
    		cntr++;
    	}
    	if(s[i]=='G'){
    		g[i]++;
    		cntg++;
    	}
    	if(s[i]=='B'){
    		b[i]++;
    		cntb++;
    	}
    }
    // cout<<cntr<<endl;
    // cout<<cntg<<endl;
    // cout<<cntb<<endl;
    // print_array(r,n);
    // cout<<endl;
    // print_array(g,n);
    // cout<<endl;
    // print_array(b,n);
    // cout<<endl;
    
    ll count = 0;
    set<char> str;
    for(int i=0;i<n;i++){
    	
    	// str.insert(s[i]);
    	for(int j=i+1;j<n;j++){
    		str.insert(s[i]);
    		if(str.count(s[j])==0){
    			str.insert(s[j]);
    			int k = 2*j - i;
    			if(str.count('R')==0){
    				count+=r[j+1];
    				if(k<n and s[k]=='R'){
    					count--;
    				}
    			}
    			if(str.count('G')==0){
    				count+=g[j+1];
    				if(k<n and s[k]=='G'){
    					count--;
    				}
    			}
    			if(str.count('B')==0){
    				count+=b[j+1];
    				if(k<n and s[k]=='B'){
    					count--;
    				}
    			}
    		}
    		str.clear();
    	}
    }
    cout<<count<<endl;

	return 0;
}

Measured memory_bytes: 3708
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;

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

void solve() {
    int n;
    cin >> n;
    map<int,int> memo;
    int cnt = 1;
    memo[n]++;
    for (;;) {
        if (n % 2) n = 3 * n + 1;
        else n /= 2;
        if (memo.count(n) > 0) {
            cout << ++cnt << endl;
            return;
        }
        memo[n]++;
        ++cnt;
    }
}

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

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	int h, w;
	cin >> H >> W >> h >> w;
	if (H%h == 0 && W%w == 0) {
		cout << "No\n";
		return 0;
	}
	cout << "Yes\n";
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (i%h == 0 && j%w == 0) {
				cout << -(4000 * (h*w - 1))-1 << " ";
			}
			else {
				cout << "4000 ";
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
const static int mod = 1000000007;
 
template<typename T, T M>
struct modint {
  T a;
  constexpr modint(const T x = 0): a((x%M+M)%M){}
  constexpr modint pow(T r) const {
    modint ans(1), aa(a);
    while(r) { if(r & 1) ans *= aa; aa *= aa; r >>= 1; }
    return ans;
  }
  
  constexpr modint& operator+=(const modint r) { a += r.a; if(a >= M) a -= M; return *this; }
  constexpr modint& operator-=(const modint r) { a -= r.a; if(a < 0) a += M; return *this; }
  constexpr modint& operator*=(const modint r) { a = a * r.a % M; return *this; }
  constexpr modint& operator/=(const modint r) { return (*this) *= r.pow(M-2); }
  constexpr modint operator+(const modint r) const { return modint(a) += r; }
  constexpr modint operator-(const modint r) const { return modint(a) -= r; }
  constexpr modint operator*(const modint r) const { return modint(a) *= r; }
  constexpr modint operator/(const modint r) const { return modint(a) /= r; }
  constexpr bool operator!=(const modint r) const { return a != r.a; }
};
 
typedef modint<long long, mod> mi;
 
template<typename T>
struct modfact {
  vector<pair<T, T>> f;
  modfact(int N): f(N + 1) {
  int M = mod;
    assert(N < M);
    f[0].first = T(1);
    for(int i = 1; i < N; i++)
      f[i].first = f[i - 1].first * T(i);
    f[N - 1].second = T(1) / f[N - 1].first;
    for(int i = N - 2; i >= 0; --i)
      f[i].second = f[i + 1].second * T(i + 1);
  }
  T p(int n, int k){
    if (k < 0 || k > n) return T(0);
    return f[n].first * f[k].second;
  }
  T c(int n, int k) {
    if (k < 0 || k > n) return T(0);
    return p(n, k) * f[n-k].second;
  }
};

int main() {
  int k;
  string s;
  cin >> k >> s;
  int n = s.size();
  typedef modint<long long, 1000000007> mint;
  modfact<mint> mf(n+k);
  mint ans(0);
  for (int i = 0; i <= k; ++i) {
    ans += mint(26).pow(k-i) * mint(25).pow(i) * mf.c(i + n - 1, n - 1);
  }
  cout << ans.a << endl;
  return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint n;cin >> n;
    vector<lint> v(n);
    lint ans = 0, x = 0;
    REP(i, n) { cin >> v[i];
        x = max(x, v[i]);
        ans += v[i];
    }

    cout << ans-x/2 <<"\n";

    return 0;
}

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

#define vi vector<int>
#define pb push_back

int mul(int depth);

char s[50][100];
int n;
int g;

int plu(int depth){
    int res = 0;
    while(true){
        g++;
        if(s[g][depth] != '.'){
            g--;
            return res;
        }else if(s[g][depth+1] == '+'){
            res += plu(depth+1);
        }else if(s[g][depth+1] == '*'){
            res += mul(depth+1);
        }else{
            res += (s[g][depth+1]-'0');
        }
        if(g>n) break;
    }
}

int mul(int depth){
    int res = 1;
    while(true){
        g++;

        if(s[g][depth] != '.'){
            g--;
            return res;
        }else if(s[g][depth+1] == '+'){
            res *= plu(depth+1);
        }else if(s[g][depth+1] == '*'){
            res *= mul(depth+1);
        }else{
            res *= (s[g][depth+1]-'0');
        }
        if(g>n) break;
    }
}

int main(){
//    ifstream in("c_in.txt");
//    cin.rdbuf(in.rdbuf());
    while(cin >> n,n){
        rep(i,50)rep(j,100) s[i][j] = ' ';
        g = 0;
        rep(i,n) {
            string ss;
            cin >> ss;
            ss.copy(s[i],ss.size());
        }

        int ans;
        if(s[0][0]=='+'){
            ans = plu(0);
        }else if(s[0][0]=='*'){
            ans = mul(0);
        }else{
            ans = (s[0][0] - '0');
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
#define int         int long long
#define pb          push_back
#define pii         pair<int,int>
#define vi	        vector<int>
#define mii        map<int,int>
#define fs           first
#define sc          second
#define  M        1000000007
#define fr for(int i=0;i<n;i++)
#define f(i,a,b) for(int i=a;i<b;i++)
#define fm(i,a,b) for(int i=a;i>b;i--)
    
using namespace std;

signed main()
{	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int test=1;
    //cin>>test;
    while(test--){
        int n;
        cin>>n;
        int a;
        f(i,0,n){
        	cin>>a;
        	if(a%2==0){
        		if(a%3&&a%5) {
        			cout<<"DENIED";
        			return 0;
        		}
        	}
        }
        cout<<"APPROVED";

    }
    return 0;
}       

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

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

  map<string, int> mp;
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    string str;
    cin >> str;
    sort(str.begin(), str.end());
    mp[str]++;
  }

  for(auto& p : mp){
    int s = p.second;
    ans += (long long)s * (s - 1) / 2;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 11136
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef int ss;
#define int long long

typedef long long ll;
typedef pair<int,int> P;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;

ll N;
ll A[100000];
ll B[100000];
vector<ll> xs;
ll w[200000];
vector<ll> F;
ll mod = 1e+9 + 7;
ll jo[200001];

int extgcd(int a,int b,int& x,int& y){
  int d=a;
  if(b != 0){
    d = extgcd( b , a%b, y, x);
    y -= (a/b)*x;
  } else{
    x=1; y=0;
  }
  return d;
}

int mod_inverse(int a,int m){
  int x,y;
  extgcd(a,m,x,y);
  return (m+x%m) %m;
}

ll comb(ll n,ll r){
  return (((jo[n]*mod_inverse(jo[r],mod)) %mod) *mod_inverse(jo[n-r],mod))%mod;
}

ss main()
{
  cin>>N;
  jo[0]=jo[1]=1LL;
  rep1(i,2*N){
    jo[i]= (jo[i-1]*i) %mod;
  }
  rep(i,N){
    cin>>A[i];
    xs.pb(A[i]);
  }
  rep(i,N){
    cin>>B[i];
    xs.pb(B[i]);
  }
  sort(xs.begin(),xs.end());
  xs.erase( unique(xs.begin(),xs.end()) , xs.end() );
  rep(i,N){
    A[i] = lower_bound(xs.begin(),xs.end(),A[i]) - xs.begin();
    B[i] = lower_bound(xs.begin(),xs.end(),B[i]) - xs.begin();
    w[A[i]]=0;
    w[B[i]]=1;
  }
  ll cnt;
  for(int i = 0; i< 2*N ;i++){
    cnt = 1LL;
    while(i + 1 < 2*N && w[i] == w[i+1] ){
      i++;
      cnt++;
    }
    F.pb(cnt);
  }
  ll ans = 1LL;
  rep(i,F.size()-1){
    if( F[i] <= F[i+1] ){
      ans = (ans * jo[F[i]])%mod;
      F[i+1]-=F[i];
    }
    else{
      ans = (((ans * jo[F[i+1]])%mod)*comb(F[i],F[i+1]))%mod;
      F[i+2] += (F[i]-F[i+1]);
      F[i] = F[i+1] = 0;
    }
  }
  cout<<ans<<endl;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> c(26);
  string s, t;
  cin >> t;
  for(auto k : t) c[k-'a']++;
  rep(i,n-1) {
    cin >> s;
    vector<int> b(26,0);
    for(auto k : s) b[k-'a']++;
    rep(j,26) c[j] = min(c[j],b[j]); 
  }
  string ans = "";
  rep(i,26) {
    rep(j,c[i]) ans += (char)('a'+i);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
input();a,b1,b2,b4=list(map(int,input().split())),0,0,0
for i in a:
  if i%2!=0: b1+=1
  elif i%4==0: b4+=1
  else: b2+=1
print(['NYoe s'[b1<=b4::2],'NYoe s'[b1<=b4+1::2]][not b2])

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    vector<int> backet(1000010, 0);
    vector<bool> ban(1000010, false);
    for (int i = 0; i < N; i++) {
        backet[A[i]]++;
    }
    for (int i = 1; i <= 1e6; i++) {
        if (backet[i] == 0) continue;
        for (int j = i*2; j <= 1e6; j += i) ban[j] = true;
        if (backet[i] >= 2) ban[i] = true;
    }
    
    int ans = 0;
    for (int i = 1; i <= 1e6; i++) {
        if (!ban[i]) ans += backet[i];
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll N;
  IN(N);
  vpll A(N);
  REP(i,N){
    IN(A[i].first);
    A[i].second = i;
  }
  sort(ALL(A));
  REP(i,N){
    printf("%lld ", A[i].second+1);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 2432
//package AtCoder;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		Stack<Character> st=new Stack<>();
		for(int i=0;i<s.length();i++)
		{
			char c=s.charAt(i);
			if(c!='B')
			{
				st.push(c);
		
			}
			else
			{
				if(!st.isEmpty())
					st.pop();
			}
		}
		String ans="";
		while(!st.isEmpty())
			ans=st.pop()+ans;
		
		System.out.println(ans);

	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define l strlen(s)
using namespace std;
int main(){
	char s[100012]={};
    scanf("%s",&s);
    if(l%2==1){
        printf("No");
        return 0;
    }
    for(int i=0;i<l/2;i++){
        int u=abs(s[i]-s[l-i-1]);
        if(u!=1&&u!=2){
            printf("No");
            return 0;
        }
    }
    printf("Yes");
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CHADD(a, b) (a = ADD(a, b))
#define CHMUL(a, b) (a = MUL(a, b))
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b){ if(a<b){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b){ if(a>b){ a=b; return true; } return false; }


int X, Y, Z, K;
int A[1010];
int B[1010];
int C[1010];
VI v, ans;


signed main(){
    cin >> X >> Y >> Z >> K;
    rep(i, 0, X) cin >> A[i];
    rep(i, 0, Y) cin >> B[i];
    rep(i, 0, Z) cin >> C[i];

    rep(i, 0, X)
        rep(j, 0, Y) v.pb(A[i]+B[j]);

    sort(ALL(v), greater<int>());
    sort(RNG(C, 0, Z), greater<int>());

    rep(i, 0, min(SZ(v), K))
        rep(j, 0, min(Z, K)) ans.pb(v[i]+C[j]);

    sort(ALL(ans), greater<int>());

    rep(i, 0, K) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 42852
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>

using namespace std;

typedef long long int64;

int main(void){
    int64 N;
    cin>>N;
    vector<int64> tree(N);
    vector<pair<int64,int64>> branch(N);
    vector<pair<int64,int64>> branch2(N);
    int64 a,b;
    vector<int64> num(N);
    vector<int64> leaf(N);
    int64 ans=0;
    for(int64 i=0;i<N;i++){
        tree[i]=0;
    }
    for(int64 i=0;i<N-1;i++){
        cin>>a>>b;
        tree[a-1]++;
        tree[b-1]++;
        branch[i].first=a-1;
        branch[i].second=b-1;
        branch2[i].first=a-1;
        branch2[i].second=b-1;
    }
    for(int64 i=0;i<N;i++){
        cin>>num[i];
    }

    sort(num.begin(),num.end());

    int64 j=0,k=0;

    for(int64 i=0;i<N-1;i++){
        for(j=0;tree[j]!=1;j++){}
        tree[j]=0;
        for(k=0;branch[k].first!=j&&branch[k].second!=j;k++){}
        if(branch[k].first==j) tree[branch[k].second]--;
        else tree[branch[k].first]--;
        
        leaf[j]=num[i];
        if(i==N-2){
            if(branch[k].first==j) leaf[branch[k].second]=num[i+1];
            else leaf[branch[k].first]=num[i+1];
        }
        branch[k].first=-1;
        branch[k].second=-1;
    }
    for(int64 i=0;i<N-1;i++){
        ans+=min(leaf[branch2[i].first],leaf[branch2[i].second]);
    }

    cout<<ans<<endl;

    for(int64 i=0;i<N;i++){
        cout<<leaf[i];
        if(i==N-1) break;
        cout<<" ";
    }

    cout<<endl;
    

    return 0;
}

Measured memory_bytes: 896