akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <unordered_map>
#include <iterator>
#include <functional>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;

int n, m;

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin >> n >> m;
	vi d(2*n);
	REP(i, m){
		int l, w;
		cin >> l >> w;
		REP(j, w) d[l+j] = 1;
	}
	REP(i, 2*n) d[i] |= d[(i+n)%(2*n)];
	int sum = accumulate(d.begin(), d.begin()+n, 0);
	if(sum == n){
		printf("%d 1\n", sum);
		return 0;
	}
	int s = 0;
	REP(i, n){
		if(d[i] == 0 && d[i+1] == 1) s = (i+1) % n;
	}
	map<int, int> ans;
	int c = 0;
	REP(i, n){
		if(!d[s+i]){
			if(c) ans[c] ++;
			c = 0;
		}else c ++;
	}
	vector<pii> ans2;
	RFOR(it, ans) printf("%d %d\n", it->first, it->second);
	return 0;
}


Measured memory_bytes: 1196
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 100000007)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(Scanner())
	ans := make([]int, n)
	for i := 0; i < n; i++ {
		ans[i], _ = strconv.Atoi(Scanner())
	}
	dp := make([][]map[int]int, n)
	for i := range dp {
		dp[i] = make([]map[int]int, 2)
		for j := range dp[i] {
			dp[i][j] = make(map[int]int)
		}
	}

	m := int(n / 2)

	dp[0][0][m] = 0
	dp[0][1][m-1] = ans[0]
	for i := 1; i < n; i++ {
		n := int((n - i) / 2)
		for j := range dp[i-1][0] {
			if j >= 0 {
				if j >= 1 {
					dp[i][1][j-1] = dp[i-1][0][j] + ans[i]
				}
				if j <= n {
					if m, ok := dp[i-1][1][j]; ok {
						dp[i][0][j] = max(dp[i-1][0][j], m)
					} else {
						dp[i][0][j] = dp[i-1][0][j]
					}
				}
			}
		}
		for k := range dp[i-1][1] {
			if k-1 <= n {
				m2 := dp[i-1][1][k]
				if m, ok := dp[i-1][0][k]; ok {
					m2 = max(m2, m)
				}
				if m, ok := dp[i][0][k]; ok {
					dp[i][0][k] = max(m, m2)
				} else {
					dp[i][0][k] = m2
				}
			}
		}
	}

	fmt.Println(max(dp[n-1][0][0], dp[n-1][1][0]))
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 118632
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    const double wa = (2*M_PI) / (12*60), wb = (2*M_PI) / 60;
    double TH = wa*(60*h + m) - wb*m;
    double D2 = a*a + b*b - 2*a*b*cos(TH);
    double D = abs(sqrt(D2));
    cout << setprecision(10) << D << endl;
    return 0;
}

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


typedef long long LL;


int main() {
	int N;
	cin >> N;
	vector<LL> A(N);
	for (int i = 0; i < N; ++i)
		cin >> A[i];

	LL amt = 1000LL;
	for (int i = 0; i < N - 1; ++i)
		if (A[i] < A[i + 1])
			amt += (A[i + 1] - A[i]) * (amt / A[i]);

	cout << amt << endl;

	return 0;
}


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

int main(){
    int n , k , x , y;
    cin >> n >> k >> x >> y;
    int fee=0;
    if(n<=k) k=n;
    for(int i=1;i<=k;++i) fee+=x;
    for(int i=k+1;i<=n;++i) fee+=y;
    cout << fee << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

  string N;
  cin >> N;
  rep(i,N.size()-1){
    if(N[i]=='A' && N[i+1]=='C'){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14 100兆
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  ll H, W;
  cin >> H >> W;
  vector<vector<ll>> c(10, vector<ll>(10));
  rep(i, 10){
    rep(j, 10){
      cin >> c.at(i).at(j);
    }
  }
  vector<vector<ll>> A(H, vector<ll>(W));
  rep(i, H){
    rep(j, W){
      cin >> A.at(i).at(j);
    }
  }
  rep(k, 10){
    rep(i, 10){
      rep(j, 10){
        chmin(c.at(i).at(j), c.at(i).at(k)+c.at(k).at(j));
      }
    }
  }
  ll ans = 0;
  rep(i, H){
    rep(j, W){
      if(A.at(i).at(j) == -1){
        continue;
      }
      ans += c.at(A.at(i).at(j)).at(1);
    }
  }
  cout << ans << endl;
}

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

#define pb push_back
#define fi first
#define se second
#define eb emplace_back

using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
const int N = 1000007, inf = 0x3f3f3f3f;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int k; cin >> k;
	string s; cin >> s;
	if(s.size() <= k) {
		cout << s << '\n';
	}else {
		s = s.substr(0, k);
		cout << s << "...\n";
	}
}

Measured memory_bytes: 3656
#include <iostream>
#define ll long long
using namespace std;

int x[100010];
ll mod=1000000007;

int main() {
	int N;
	cin >> N;
	for(int i=0; i<N; ++i) cin >> x[i];
	int now=0;
	ll ans=1;
	for(int i=0; i<N; ++i){
		while(now<N-1){
			if((x[now]+1)/2<now+1-i) break;
			++now;
		}
		ans=(ans*(now+1-i))%mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m, q;
    cin >> n >> m >> q;
    
    vector<int> A(q), B(q), C(q), D(q);
    for (int i = 0; i < q; ++i) {
        cin >> A[i] >> B[i] >> C[i] >> D[i];
        --A[i], --B[i];
    }

    vector<int> nums(n, 0);
    int res = 0;
    function<void(int, int)> dfs = [&](int i, int x) {
        if (i == n) {
            int ans = 0;
            for (int j = 0; j < q; ++j) {
                if (nums[B[j]] - nums[A[j]] == C[j]) {
                    ans += D[j];
                }
            }
            res = max(res, ans);
            return;
        }

        for (int j = x; j <= m; ++j) {
            nums[i] = j;
            dfs(i + 1, j);
        }
    }; 

    dfs(0, 1);

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 3644
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;



void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    vector<ll> c(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());

    ll ans = 0;

    rep(i,n){

        vector<ll>::iterator j,k;
        // auto j,k;

        j = lower_bound(a.begin(),a.end(),b[i]);
        k = upper_bound(c.begin(),c.end(),b[i]);

        ll dis1,dis2;

        dis1 = distance(a.begin(),j);
        dis2 = distance(k,c.end());

        ans += (dis1)*(dis2);

    }

    cout << ans << endl;

    return 0;
}

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

struct UnionFind {
	vector<int> par;
	UnionFind(int N) : par(N) {
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int root(int x) {
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}
	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry) return;
		par[rx] = ry;
	}

	bool same(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main() {
	int N, M; cin >> N >> M;
	vector<int> p(N); for (auto&& x : p)cin >> x;

	int x, y;
	UnionFind UF(N);
	for (int i = 0; i < M; ++i) {
		cin >> x >> y;
		UF.unite(x - 1, y - 1);
	}

	int sum = 0;
	for (int i = 0; i < N; ++i) {
		if (UF.same(i, p.at(i) - 1)) {
			++sum;
		}
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
const int N = 1e5 + 7;
char s[N],t[N];
int lens,lent;

using ll = long long;
ll ans = 0,last = 0;
std::vector<int> ref[200];

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

	std::cin >> (s + 1) >> (t + 1);
	lens = strlen(s + 1),lent = strlen(t + 1);

	for(int i = 1;i <= lens;i++) ref[s[i]].push_back(i);

	ans = lens;


	for(int i = 1;i <= lent;i++) {
		if(ref[t[i]].empty()) {
			std::cout << -1;
			exit(0);
		}

		auto pos = std::upper_bound(ref[t[i]].begin(),ref[t[i]].end(),
				last);
		if(pos == ref[t[i]].end()) {
			ans += lens;
			i--;
			last = 0;
		} else last = *pos;
	}
	std::cout << ans - (lens - last);
	exit(0);
}


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

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> ds(k);
	vector<vector<int>> ass(k);
	for (int i = 0; i < k; i++)
	{
		cin >> ds[i];
		ass[i].resize(ds[i]);
		for (auto &&a : ass[i])
		{
			cin >> a;
			a--;
		}
	}

	vector<int> cnt(n, 0);
	for (auto &&as : ass)
	{
		for (auto &&a : as)
		{
			cnt[a]++;
		}
	}

	cout << count(cnt.begin(), cnt.end(), 0) << endl;

	return 0;
}

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

signed main(){
	int N,M,Q;
	cin >> N >> M >> Q;
	string s[N];
	REP(i,N)cin >> s[i];
	vector<vector<int>>sum(N+1,vector<int>(M+1,0));
	vector<vector<int>>tate(N+1,vector<int>(M+1,0));
	vector<vector<int>>yoko(N+1,vector<int>(M+1,0));
	REP(i,N)REP(j,M)sum[i+1][j+1] += s[i][j]=='1';
	REP(i,N)REP(j,M-1)if(s[i][j]=='1'&&s[i][j+1]=='1')yoko[i+1][j+1]++;
	REP(i,N-1)REP(j,M)if(s[i][j]=='1'&&s[i+1][j]=='1')tate[i+1][j+1]++;
	REP(i,N)REP(j,M){
		sum[i+1][j+1] += sum[i][j+1] + sum[i+1][j] - sum[i][j];
		tate[i+1][j+1] += tate[i][j+1] + tate[i+1][j] - tate[i][j];
		yoko[i+1][j+1] += yoko[i][j+1] + yoko[i+1][j] - yoko[i][j];
	}
	vector<int>ans;
	while(Q--){
		int x1,y1,x2,y2;
		cin >> x1 >> y1 >> x2 >> y2;
		int blue = sum[x2][y2] - sum[x1-1][y2] - sum[x2][y1-1] + sum[x1-1][y1-1];
		int tateren = tate[x2-1][y2] - tate[x1-1][y2] - tate[x2-1][y1-1] + tate[x1-1][y1-1];
		int yokoren = yoko[x2][y2-1] - yoko[x1-1][y2-1] - yoko[x2][y1-1] + yoko[x1-1][y1-1];
		//cout<<tate[x2-1][y2]<<" "<<tate[x1-1][y2]<<" "<<tate[x2][y1-1]<<" "<<tate[x1-1][y1-1]<<endl;
		//cout << blue << " " << tateren << " " << yokoren << endl;
		ans.push_back(blue-tateren-yokoren);
	}
	for(auto e:ans)cout<<e<<endl;
}

Measured memory_bytes: 101616
def main():
  ab=[1]*100000
  bc=[1]*100000
  ac=[1]*100000
  a=input()
  b=input()
  c=input()
  A,B,C=len(a),len(b),len(c)
  match=lambda x,y:x=="?" or y=="?" or x==y
  for i in range(A):
    for j in range(B):
      if not match(a[i],b[j]):ab[i-j+50000]=0
  for i in range(A):
    for j in range(C):
      if not match(a[i],c[j]):ac[i-j+50000]=0
  for i in range(B):
    for j in range(C):
      if not match(b[i],c[j]):bc[i-j+50000]=0
  ans=10**20
  for i in range(-4000,4001):
    for j in range(-4000,4001):
      if ab[i+50000]+ac[j+50000]+bc[j-i+50000]==3:
        ans=min(ans,max(A,B+i,C+j)-min(0,i,j))
  print(ans)
if __name__ == "__main__":
  main()

Measured memory_bytes: 54224
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
  int N; cin >> N;
  ll ans = 0;
  vector<ll> L(N+1), v(N);
  for(int i = 1; i <= N; ++i) {
    cin >> L[i];
  }
  for(int i = 0; i < N; i++) v[i] = L[i+1];
  sort(v.begin(), v.end());
  for(ll mid = N-1; mid >= 0; mid--) {
    for(ll low = mid - 1; low >= 0; low--) {
      auto itr = lower_bound(v.begin(), v.end(), v[mid]+v[low]);
      ll ng = distance(itr, v.end());
      ans += (N-1-mid) - ng;
    }
  }
  cout << ans << endl;
  return 0;
}


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

struct Node{
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

Node * find(Node *u, int k) {
    while(u != NIL && k != u->key) {
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x != NIL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }

    z->parent = y;
    if(y == NIL){
        root = z;
    }else{
        if(z->key < y->key){
            y->left = z;
        }else{
            y->right = z;
        }
    }
}

Node * treeMinimum(Node *x){
    while(x->left != NIL) x = x->left;
    return x;
}

Node * treeSuccessor(Node *x){
    if(x->right != NIL) return treeMinimum(x->right);
    Node *y = x->parent;
    while(y != NIL && x == y->right){
        x = y;
        y = y->parent;
    }
    return y;
}

void treeDelete(Node *z){
    Node *y;
    Node *x;

    if(z->left == NIL || z->right == NIL) y = z;
    else y = treeSuccessor(z);

    if(y->left != NIL){
        x = y->left;
    }else{
        x = y->right;
    }

    if(x != NIL){
        x->parent = y->parent;
    }

    if(y->parent == NIL){
        root = x;
    }else{
        if(y == y->parent->left){
            y->parent->left = x;
        }else{
            y->parent->right = x;
        }
    }

    if(y != z){
        z->key = y->key;
    }

    free(y);
}

void inorder(Node *u){
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u){
    if(u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n, i, x;
    string com;
    scanf("%d", &n);

    for(i = 0; i < n; i++){
        cin >> com;
        if(com == "find"){
            scanf("%d", &x);
            Node *t = find(root, x);
            if(t != NIL) printf("yes\n");
            else printf("no\n");
        }else if(com == "insert"){
            scanf("%d", &x);
            insert(x);
        }else if(com == "print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }else if(com == "delete"){
            scanf("%d", &x);
            treeDelete(find(root, x));
        }
    }

    return 0;
}


Measured memory_bytes: 21952
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        //Compute c1 = new Compute();//calc
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();
        //input
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int d[] = new int[n];
        for (int i=0;i<n;++i) d[i]=sc.nextInt();

        int ans = 0;
        for (int i=0;i<n;++i)
        {
            for (int j =0;j<n;++j)
            {
                if (j==i)continue;
                ans +=d[i]*d[j];
            }
        }
        ans /=2;

        System.out.println(ans);
        sc.close();
    }
}

Measured memory_bytes: 23764
// Author by Md. Jashim Uddin_RMSTU

#include<bits/stdc++.h>
using namespace std;
#define     sf(a)           scanf("%d",&a)
#define     sff(a,b)        scanf("%d %d",&a,&b)
#define     sfff(a,b,c)     scanf("%d %d %d",&a,&b, &c)
#define     pb              push_back
#define     ll              long  long int
#define     fast            ios_base :: sync_with_stdio(false);cin.tie(0)
#define     pi              2*acos(0)
#define     sp              fixed<<setprecision
#define     lcm(a,b)        (a*b)/gcd(a,b)
#define     gcd(a,b)        _gcd(a,b)

#define     forn(i,n)       for(int i=1;i<=n;i++)
#define     min3(a,b,c)     min(a,min(b,c)
#define     M             32000

int main()
{
    ll a=0,b=0;
    string s;
    cin>>s;
    int i=0;
    while(s[i]!='\0')
    {
        if(s[i]=='A') a++;
        else if(s[i]=='B') b++;

        i++;
    }
    if(a>0 && b>0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

return 0;

}


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



int main(void){
    int M, D;
    scanf("%d%d", &M, &D);
    int ans=0;
    for(int i=2;i<10;i++)for(int j=2;j<10;j++){
        if(i*10+j<=D){
            if(i*j<=M)ans++;
        }
    }
    printf("%d", ans);
    
    
    return 0;
}


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

using namespace std;
int main()
{
    string s, t;
    cin >> s;
    t=s;
    int l=s.size();
    reverse(s.begin(), s.end());
    if(s!=t || l%2==0)
        cout<< "No\n";
    else
    {
        string s1, s2, t1, t2;
        s1=s.substr((l/2)+1);
        s2=t.substr((l/2)+1);
        t1=s1;
        reverse(s1.begin(), s1.end());
        t2=s2;
        reverse(s2.begin(), s2.end());
        //cout<< s1<< endl<< t1<< endl<< s2<< endl<< t2<< endl;
        if(s1==t1 && s2==t2)
            cout<< "Yes\n";

        else
            cout<< "No\n";

    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll mod=1e9+7;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vector<ll>v(n);
    for(ll i=0;i<n;i++)cin>>v[i];
    vector<ll>sum(n);
    sum[n-1]=v[n-1];
    for(ll i=n-2;i>=0;i--){
        sum[i]=(sum[i+1]%mod)+v[i]%mod;
        sum[i]%=mod;
    }
    ll ans=0;
    for(ll i=0;i<n-1;i++){
        ans+=(v[i]%mod)*(sum[i+1]%mod);
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}



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

int MOD = 998244353;
int n;
string s;
long long ans;
long long cnt[1 << 3];

int main()
{
	cin >> n, ans = 1, cnt[0] = n;
	cin >> s;
	for (int i = 0; i < s.size(); i++)
	{
		int k = 0;
		if (s[i] == 'R') k = 1;
		if (s[i] == 'B') k = 2;
		int res = 0;
		for (int m = 0; m < 8; m++)
		{
			if (cnt[m] && __builtin_popcount(m) > __builtin_popcount(res) && (m & (1 << k)) == 0) res = m;
		}
		ans = ans * cnt[res] % MOD;
		cnt[res]--;
		res += (1 << k);
		cnt[res]++;
	}
	cout << ans;
}

Measured memory_bytes: 900
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
const ll INF=100000000000000LL;

int main() {
	string s;
	cin>>s;
	cout<<s[0]<<s.size()-2<<s[s.size()-1]<<endl;
		return 0;
}


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

int main(void){
  int n,p[25],count,i;
  char str[100],*q;
  
  fgets(str,sizeof(str),stdin);
  n=atoi(str);
  
  fgets(str,sizeof(str),stdin);
  q=strtok(str," \n");
  p[0]=atoi(q);
  
  for(i=1;i<n;i++){
    q=strtok(NULL," \n");
    p[i]=atoi(q);
  }
  
  for(i=1,count=0;i<n-1;i++){
    if((p[i]>p[i-1] && p[i]<p[i+1]) || (p[i]<p[i-1] && p[i]>p[i+1])){
      count++;
    }
  }
  
  printf("%d\n",count);
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <regex>

#define FOR(i,x,y) for(int i=(x);i<(y);i++)
#define RFOR(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define REP(i,x) for(int i=0;i<(x);i++)
#define RREP(i,x) for(int i=(x)-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define int long long

using namespace std;

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

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

using namespace std;

const int MAX_N = 100000;
ll Q,H,S,D;
ll N;

ll solve() {
    pair<int, int> ar[] = {pair<int, int>(Q * 8, 0), pair<int, int>(H * 4, 1), pair<int, int>(S * 2, 2), pair<int, int>(D, 3)};

    sort(ar, ar+4);
//    REP(i,4) cout << ar[i].first << "\n";
//    REP(i,4) cout << ar[i].second << "\n";
    if(ar[0].second == 3){
        return (N % 2) * ar[1].first / 2 + (N - N % 2) / 2 * ar[0].first;
    }else{
        return ar[0].first / 2 * N ;
    }
}

signed main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> Q >> H >> S >> D >> N;
    cout << solve() << "\n";
}


Measured memory_bytes: 256
H, W, K = map(int, input().split())
# store graph
graph = []
for h in range(H):
  graph.append(list(input()))

answer = 0
# check all possibilities
for choices in range(2 ** (W+H)):
  #copy graph
  graph_copy = [ [0]*W for i in range(H)]
  for r in range(H):
    for c in range(W):
      graph_copy[r][c] = graph[r][c] 
  #one possiblity
  selected_rows = []
  selected_cols = []
  for i in range(W+H):
    if ((choices >> i) & 1):
      #row chosen
      if (i < H):
        row = i
        selected_rows.append(row)
      #col chosen
      else:
        col = i - H
        selected_cols.append(col)
  #check if that possibility is right
  #1)paint red
  for row in selected_rows:
    for col in range(W):
      graph_copy[row][col] = "."
  for col in selected_cols:
    for row in range(H):
      graph_copy[row][col] = "."
  #2)count blacks
  count = 0
  for r in range(H):
    for c in range(W):
      if (graph_copy[r][c] == "#"):
        count += 1
  if (count == K):
    answer += 1
    
    
print(answer)

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

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

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
int N, M;
map<int, vector<int>> mp;
int D[105000];
int ans[205000];
bool ok[105000];
vector<i_i> paths[105000];
struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<ll> Size;
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n + 1); rank.resize(n + 1); Size.resize(n + 1);
        for (int i = 0; i <= n; ++i) par[i] = i, rank[i] = 0, Size[i] = 1;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        //if (rank[x] < rank[y]) swap(x, y);
        if((x - 1) % N > (y - 1) % N) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        Size[x] += Size[y];
        return true;
    }

    ll size(int x){
        return Size[root(x)];
    }
};


int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    for(int i = 1; i <= M; i++) {
        ans[i] = 1e9;
    }
    for(int i = 1; i <= N; i++) {
        cin >> D[i];
        mp[D[i]].push_back(i);
    }
    for(int i = 1; i <= M; i++) {
        int u, v;
        cin >> u >> v;
        paths[u].emplace_back(v, i);
        paths[v].emplace_back(u, i);
    }
    UnionFind uni(2 * (N + 1));
    for(auto tmp : mp) {
        int val = tmp.first;
        for(auto now : tmp.second) {
            if(ok[now]) continue;
            for(auto e : paths[now]) {
                int to = e.first;
                int edge = e.second;
                if(D[to] == D[now]) {
                    ans[edge] = D[now];
                    ok[now] = true;
                    ok[to] = true;
                    uni.merge(now, to + N);
                    uni.merge(now + N, to);
                    break;
                }
                if(D[to] < D[now]) {
                    ans[edge] = D[now] - D[to];
                    ok[now] = true;
                    uni.merge(now, to);
                    uni.merge(now + N, to + N);
                    break;
                }
            }
            if(!ok[now]) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    for(int i = 1; i <= N; i++) {
        if(uni.root(i) <= N) cout << "B";
        else cout << "W";
    }
    cout << endl;
    for(int i = 1; i <= M; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 24960
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = a + b;
        ans = Math.max(ans, a - b);
        ans = Math.max(ans, a * b);
        System.out.println(ans);
	}
}

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

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int n;
  cin >> n;
  int maxsum = 100000000;
  for(int i=1;i <= n-1;i++){
    int a = i;
    int b = n-i;
    int sum = 0;
    string sa = to_string(a);
    string sb = to_string(b);
    rep(i,sa.size()){
      sum += sa.at(i) - '0';
    }
    rep(i,sb.size()){
      sum += sb.at(i) - '0';
    }
    maxsum = min(maxsum,sum);
  }
  cout << maxsum << endl;
}

Measured memory_bytes: 256
// Problem : C - Vacation
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define ll long long 
#define ull unsigned long long
const int INF = 1e9 + 5;
#define pb push_back
#define eb emplace_back
#define vll vector<long long int>
#define vi vector<int>
#define loop(i, a, b) for(long long int i = a; i < b; i++)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pii pair<ll, ll>
#define vpair vector<pii>
#define vbool vector<bool>
#define mkp make_pair
#define scan(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) {cout<<a[i]<<' ';}cout<<'\n'
#define sec second
#define fir first
#define br '\n'
#define permute next_permutation
#define pqua priority_queue<ll>
#define pqud priority_queue<ll, vector<ll>, greater<ll> >
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define maxi *max_element
#define pi acos(-1)
#define PRECISION std::cout.unsetf ( std::ios::fixed );std::cout.precision(10)

vector<long long int> sieve(long long int n){
 	vector<long long int> primes;
 	bool isPrime[n+1] = {false};
 	isPrime[1] = isPrime[0] = false;
 	for(long long int i = 2;i<=n;i++)
 	{
 		isPrime[i] = true;
 	}
 	for(long long int i = 2;i*i<=n;i++)
 	{
 		if(isPrime[i])
 		{
 			for(long long int j = i*i;j<=n;j+=i)
 			{
 				isPrime[j] = false;
 			}
 		}
 	}
 	for(long long int i = 2;i<=n;i++)
 	{
 		if(isPrime[i])
 		{
 			primes.push_back(i);
 		}
 	}
 	return primes;
}

void print_vector2(vector<vector<ll> >v) {
    for(ll i=0;i<v.size();i++){
        for(ll j=0;j< v[i].size();j++){
            cout<<v[i][j]<<" ";
        }cout<<"\n";
    }
}

void print_vector1(vector<ll> v) {
    for(ll i=0; i<v.size();i++){
        cout<<v[i]<<" ";
    }cout<<"\n";
}

ll gcd(ll a, ll b) {
    return __gcd(a, b);
}

// v.back()
// v.erase(v.begin(), v.brgin + k)
// v.insert(at which place v.bigin() + 1 implines at i = 1, no. of times, value)
// v.insert(position, copy.begin(), copy.end())
// v1.swap(v2)
// v.clear() to clear v.empty() to check empty
// map assending order and set descending order 
// stringstream ss(str) Used for breaking words

int main(){
    FastIO;
    PRECISION;
	ll n;
	cin>>n;
	vll dp(3, 0);
    loop(i, 0, n){
    	vll temp(3);
    	scan(temp, 3);
    	loop(j, 0, 3){
    		temp[j] = temp[j] + max(dp[(j + 1) % 3], dp[(j + 2) % 3]);
    	}
    	dp = temp;
    }
    cout<<max(dp[0], max(dp[1], dp[2]));
    
    return 0;
}

Measured memory_bytes: 3604
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input())


print(a[k-1])


Measured memory_bytes: 2940
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,i,j;
            cin>>n;
            ll ar[n+2],ar2[n+1];
            ar[0]=0;
            ll ans=0,mini;
            for(i=1;i<=n+1;++i)
                cin>>ar[i];
            for(i=1;i<=n;++i)
                cin>>ar2[i];
            for(i=1;i<=n;++i)
            {
                mini=min(ar2[i],ar[i]);
                ans=ans+mini;
                ar2[i]=ar2[i]-mini;
                ar[i]=ar[i]-mini;
                mini=min(ar2[i],ar[i+1]);
                ans=ans+mini;
                ar[i+1]=ar[i+1]-mini;
            }
            cout<<ans<<endl;
        }
        return 0;
    }


Measured memory_bytes: 1792
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
q=gi
max=0

require 'prime'
lr=q.times.map{
  i=gsmi
  max=i[1] if max<i[1]
  i
}
rui=[0]
1.upto(max) do |i|
  if i.even?
    rui<<rui[-1]
  else
    if i.prime? && ((i+1)/2).prime?
      rui<<rui[-1]+1
    else
      rui<<rui[-1]
    end
  end
end

q.times do |i|
  l,r=lr[i]
  puts rui[r]-rui[l-1]
end

Measured memory_bytes: 12540
from collections import defaultdict
from itertools import product, groupby
from math import pi
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10


def main():
    N = input()
    print("Yes" if "9" in N else "No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
IDENTIFICATION DIVISION.
       PROGRAM-ID. test1.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 INP PIC 99.
       01 A PIC 9.
       PROCEDURE DIVISION.
       MAIN.
       	ACCEPT INP.
      	COMPUTE A=INP/10.
      	COMPUTE INP=INP - A*10.
      	IF A=9 OR INP=9 THEN
      		DISPLAY "Yes"
      	ELSE
      		DISPLAY "No"
      	END-IF.
        STOP RUN.


Measured memory_bytes: 504
#include<iostream>
#include<string>
#include<algorithm>
#define SIZE 80
int main()
{
	int N, n, s;
	std::string d1, d2, sum;

	std::cin >> N;
	std::getline(std::cin, d1);
	for (n = 0; n < N; n ++) {
		std::getline(std::cin, d1);
		std::getline(std::cin, d2);
		if (d1.size() > SIZE || d2.size() > SIZE) {
			std::cout << "overflow" << std::endl;
		} else {
			std::reverse(d1.begin(), d1.end());
			std::reverse(d2.begin(), d2.end());
			s = 0;
			sum.clear();
			for (size_t i = 0; i < d1.size() || i < d2.size(); i ++) {
				s += (i < d1.size()) ? (d1[i] - '0') : 0;
				s += (i < d2.size()) ? (d2[i] - '0') : 0;
				sum += '0' + (s%10);
				s /= 10;
			}
			if (s)
				sum += '0' + s;
			if (sum.size() > SIZE) {
				std::cout << "overflow" << std::endl;
			} else {
				std::reverse(sum.begin(), sum.end());
				std::cout << sum << std::endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
// 2020-07-30 20:29:20
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

const int lim = 80*160*2+10;
using bs = bitset<lim>;
void answer() {
  int h, w;
  cin >> h >> w;
  vector<vector<int> > c(h+1, vector<int>(w+1, 0));
  rep(i, h) rep(j, w) cin >> c[i][j];
  rep(i, h) rep(j, w) {
    int b;
    cin >> b;
    c[i][j] = abs(b-c[i][j]);
  }
  vector<bs> dp(w+1, bs());
  dp[0][lim/2+c[0][0]] = 1;
  dp[0][lim/2-c[0][0]] = 1;
  rep(i, h) {
    vector<bs> p(w+1, bs());
    swap(p, dp);
    rep(j, w) {
      p[j+1] |= p[j] << c[i][j+1];
      p[j+1] |= p[j] >> c[i][j+1];
      dp[j] |= p[j] << c[i+1][j];
      dp[j] |= p[j] >> c[i+1][j];
    }
  }
  int ans = lim;
  rep(x, lim) if(dp[w-1][x]) chmin(ans, abs(lim/2-x));
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = 2e9+1;

int main(){
  int n, l, q;
  cin >> n;
  vector<int> x(n);
  rep(i,n) cin >> x[i];
  cin >> l >> q;
  vector<vector<int>> to(23, vector<int>(n));
  x.push_back(INF);
  for (int i = 0; i < n; i++) {
    auto itr = lower_bound(x.begin(), x.end(), x[i] + l);
    if (*itr > x[i] + l) itr--;
    to[0][i] = itr - x.begin();
  }
  for (int i = 0; i < 22; i++) {
    for (int j = 0; j < n; j++) to[i + 1][j] = to[i][to[i][j]];
  }

  while (q--) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    int res = 0;
    if (a > b) swap(a, b);
    for (int i = 22; i >= 0; i--) {
      if (to[i][a] < b) {
        a = to[i][a];
        res += 1 << i;
      }
    }
    cout << res + 1 << endl;
  }
  return 0;
} 

Measured memory_bytes: 10224
#include<iostream>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n;
	while(cin>>n){
		long long cnt=0;
		for(int i=max(0,n-3000);i<=min(1000,n);i++){
			for(int j=max(0,n-i-2000);j<=min(1000,n-i);j++){
				cnt+=(min(1000,n-i-j)-max(0,n-i-j-1000)+1);
			}
		}
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7


a,b,c = map(int,input().split())
d = []
for i in range(1,b+1):
    e = (a*i)%b
    if e == c:
        print("YES")
        sys.exit()
print("NO")


Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {

	public static double dist(int[] xs, int[]ys, int p) {
		double ret = 0.0;
		for(int i=0;i<xs.length;i++) {
			ret += Math.pow(Math.abs(xs[i] - ys[i]), p);
		}
		return Math.pow(ret, 1.0/p);
	}
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		int xs[] = new int[n];
		int ys[] = new int[n];
		for (int i = 0; i < n; i++) {
			xs[i] = in.nextInt();
		}
		for (int i = 0; i < n; i++) {
			ys[i] = in.nextInt();
		}

		System.out.println(dist(xs, ys, 1));
		System.out.println(dist(xs, ys, 2));
		System.out.println(dist(xs, ys, 3));

		double ret = 0.0;
		for(int i=0;i<n;i++) {
			ret = Math.max(ret, Math.abs(xs[i] - ys[i]));
		}
		System.out.println(ret);
	}
}

Measured memory_bytes: 26500
#include <bits/stdc++.h>
#include <regex>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef complex<double> Point;
typedef long long ll;
const int INF = 1145141919;
const int MOD = 100000007;
const double EPS = 1e-10;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int main()
{
	int q;
	cin >> q;
	ll cnt = 0;
	while (q--)
	{
		int p, n;
		char c;
		cin >> p >> c >> n;
		if (c == '(') cnt += n;
		else cnt -= n;
		puts(cnt ? "No" : "Yes");
	}
	return 0;
}

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

int main()
{
  int n;
  cin >> n;
  vector<double> v(n);
  for(int i = 0; i < n; ++i) cin >> v[i];
  
  sort(v.begin(), v.end());
  
  double ans = v[0];
  for(int i = 1; i < n; ++i)
  {
    ans = (ans + v[i]) / 2;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3792
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(std::vector<T>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}

bool check (string S, string T, int k)
{
   corner(T.size() + k > S.size(),"Out of Size");
   bool check = 1;
   for (int i = 0; i < T.size(); i++)
   {
    if((S[k+i] == T[i] || S[k+i] == '?')^(true)) check = 0;
   }

   return check;
}

string fill(string S,string T,int k)
{
  string filled = S;
  for (int i = 0; i < T.size(); i++)
  {
    filled[k+i] = T[i];
  }
  for (int i = 0; i < S.size(); i++)
  {
    if(filled[i] == '?')filled[i] = 'a';
  }
  
  return filled;
}
void solve(void)
{

  string S,T;
  cin>>S;
  cin>>T;
  reverse(T.begin(),T.end());
  
  if(S == T)
  {
    cout<<"YES"<<endl;
  }
  else
  {
    cout<<"NO"<<endl;
  }
   
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
var
	N,i,j:Longint;
	ans:int64;
begin
	read(N);
	j:=round(sqrt(N));
	if j*j>N then dec(j);
	for i:=1 to j do inc(ans,(N div i)*(N div i+1)*i-i*i*i);
	writeln(ans);
end.

Measured memory_bytes: 1380
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const int MOD = 1000000007;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


ll abc(ll x,ll y){
    ll now=1;
    for(ll i=x;i>0;i--){
        if(i!=y){
            now=now*i;
            now=now%MOD;
        }
    }
    return now;
}


int main(){
    ll n;
    cin >> n;
    vector<ll> vec(n);
    rep(i,n){
        cin >> vec[i];
    }
    
    ll total=vec[n-1]-vec[0];
    
    vector<ll> vec2(n);
    
    vec2[0]=total;
    
    for(ll i=1;i<n;i++){
        total=total-(vec[i]-vec[i-1]);
        vec2[i]=total;
    }
    
    ll ans=0;
    
    ll aiai=1;
    for(ll i=n-1;i>0;i--){
        aiai=aiai*i;
        aiai=aiai%MOD;
    }
    
    for(ll i=0;i<n-1;i++){
        ll auau=aiai*modinv(i+1,MOD)%MOD;
        auau=auau*vec2[i]%MOD;
        ans+=auau;
        ans=ans%MOD;
    }
    
    
    cout << ans << endl;

    return 0;
}







Measured memory_bytes: 1792
S = input()
tmp = ['']*len(S)
sum = 0
for i in range(len(S)):
    tmp[i] = S[i]
if len(S) < 2:
    print(int(S))
else:
    for j in range(pow(2,len(S)-1)):
        work = format(j,'b').zfill(len(S)-1)
        storeNUM = tmp[0]
        for k in range(len(work)):
            if work[k] == '1':
                sum += int(storeNUM)
                storeNUM = str(tmp[k+1])
            else:
                storeNUM = storeNUM + str(tmp[k+1])
        sum += int(storeNUM)
    print(sum)

Measured memory_bytes: 3064