akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

template <int MOD = 1000000007>
struct Mint {
    int x;

    Mint() : x(0) {}
    Mint(long long t) {
        x = t % MOD;
        if (x < 0) x += MOD;
    }

    Mint pow(int n) {
        Mint res(1), t(x);
        while (n > 0) {
            if (n & 1) res *= t;
            t *= t;
            n >>= 1;
        }
        return res;
    }

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

    Mint &operator+=(Mint a) {
        x += a.x;
        if (x >= MOD) x -= MOD;
        return *this;
    }

    Mint &operator-=(Mint a) {
        x += MOD - a.x;
        if (x >= MOD) x -= MOD;
        return *this;
    }

    Mint &operator*=(Mint a) {
        x = int(1LL * x * a.x % MOD);
        return *this;
    }

    Mint &operator/=(Mint a) {
        return (*this) *= a.inv();
    }

    Mint operator+(Mint a) const {
        return Mint(x) += a;
    }
    Mint operator-(Mint a) const {
        return Mint(x) -= a;
    }
    Mint operator*(Mint a) const {
        return Mint(x) *= a;
    }
    Mint operator/(Mint a) const {
        return Mint(x) /= a;
    }

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

    bool operator==(const Mint a) {
        return x == a.x;
    }
    bool operator!=(const Mint a) {
        return x != a.x;
    }
    bool operator<(const Mint a) {
        return x < a.x;
    }

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

    friend istream &operator>>(istream &is, Mint &a) {
        int t;
        is >> t;
        a = Mint<MOD>(t);
        return (is);
    }
};

signed main() {
    int n;
    cin >> n;
    ll a, b;
    int zero = 0, azero = 0, bzero = 0;
    using P = pair<ll, ll>;
    map<P, P> mp;
    rep(i, n) {
        cin >> a >> b;
        if (a == 0 && b == 0) {
            zero++;
            continue;
        } else if (a == 0) {
            azero++;
            continue;
        } else if (b == 0) {
            bzero++;
            continue;
        }
        if (a < 0) {
            a = -a;
            b = -b;
        }
        ll g = gcd(a, abs(b));
        a /= g;
        b /= g;
        if (b > 0)
            mp[{a, b}].second++;
        else
            mp[{-b, a}].first++;
    }
    Mint<> ans = 1;
    for (auto p : mp) {
        ans *=
            Mint<>(2).pow(p.second.first) + Mint<>(2).pow(p.second.second) - 1;
    }
    ans *= Mint<>(2).pow(azero) + Mint<>(2).pow(bzero) - 1;
    ans += zero;
    cout << ans - 1 << endl;
    return 0;
}

Measured memory_bytes: 19156
twon = [0,0,0,0];
for i in 1..3 do
  input = gets
  a,b = input.split.map { |e| e.to_i }
  twon[a - 1] += 1
  twon[b - 1] += 1
end

even = twon.count {|i| i % 2 == 0}
odd = twon.count {|i| i % 2 == 1}
no_way = twon.count {|i| i == 0}
if no_way >= 1
  puts 'NO'
elsif even == 4
  puts 'YES'
elsif odd == 2 && even == 2
  puts 'YES'
else
  puts 'NO'
end

Measured memory_bytes: 1788
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    int l = s.length();
    int cnt[26];
    REP(i, 26){
        cnt[i] = 0;
    }
    REP(i, l){
        cnt[s[i] - 'a']++;
    }
    bool flag = true;
    REP(i, 26){
        if(cnt[i] >= 2){
            flag = false;
        }
    }
    if(flag){
        cout << "yes" << endl;
    }
    else {
        cout << "no" << endl;
    }
    return 0;
}

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

int main()
{
    int n,a;
    scanf("%d",&n);
    a=n%10;
    if(a==2||a==4||a==5||a==7||a==9)
        printf("hon");
    if(a==0||a==1||a==6||a==8)
        printf("pon");
    if(a==3)
        printf("bon");
}

Measured memory_bytes: 1732
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#define rep(i,n) for (int i = 0; i < (n); ++i)


using namespace std;

typedef pair<int,int> pii;
typedef vector<int> vi;

int main () {
    int n;
    cin >> n;
    set<string> gacha;
    string s;
    rep(i,n) {
        cin >> s;
        gacha.insert(s);
    }
    cout << gacha.size() << endl; 
    return 0;
}

Measured memory_bytes: 15724
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  ll a,b;
  cin >> a >> b;
  if(__gcd(a,b)==b) {
    cout << -1 << endl;
    return 0;
  }
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 3608
import fractions
A,B,C,D=map(int,input().split())
E=C*D//fractions.gcd(C,D)
X=0
Y=0
X=A-1-(A-1)//C-(A-1)//D+(A-1)//E
Y=B-B//C-B//D+B//E
print(Y-X)

Measured memory_bytes: 5176
#include<bits/stdc++.h>
using namespace std;
vector<vector<long>>adj;
vector<long> dp;
int dfs(int i){
    if(dp[i]!=0) return dp[i];
    else{
        long ans=0;
        for(long j=0;j<adj[i].size();j++){
            dp[adj[i][j]]=dfs(adj[i][j]);
            ans=max(ans,1+dp[adj[i][j]]);
        }
        // cout<<ans;
        return ans;
    }
}
int main(){
    long long n,edges;
    cin>>n>>edges;
    adj.resize(n+1);
    dp.resize(n+1);
    for(int i=0;i<edges;i++){
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
    }
    long ans=0;
    for(long i=1;i<=n;i++){
        dp[i]=dfs(i);
        ans=max(ans,dp[i]);
    }
    cout<<ans;
    return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    set<int> s;

    rep(i, k) {
        int d;
        cin >> d;
        rep(j, d) {
            int a;
            cin >> a;
            s.insert(a);
        }
    }

    cout << n - s.size() << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define M_PI 3.14159265358979323846

void main()
{
    int a, b, h, m;
    double theta;

    scanf("%d %d %d %d", &a, &b, &h, &m);
    theta = fabs((double)m / 60.0 - ((double)h / 12.0 + (double)m / 60.0 / 12.0)) * 2.0 * M_PI;
    printf("%.20lf", sqrt(pow(a, 2.0) + pow(b, 2.0) - 2 * a * b * cos(theta)));
}

Measured memory_bytes: 2580
#include <bits/stdc++.h>
using namespace std;
const int N = 188;
int dpr[N][N][N];
int dpd[N][N][N];
int new_dpr[N][N][N];
int new_dpd[N][N][N];
int main() {
	cin.tie(0); cin.sync_with_stdio(false);
	int h, w;
	cin >> h >> w;
	vector<string> grd(h);
	for (int i = 0; i < h; i++) cin >> grd[i];
	vector<vector<int>> cum(h + 1, vector<int>(w + 1, 0));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cum[i + 1][j + 1]
				= cum[i + 1][j] + cum[i][j + 1] - cum[i][j]
				+ (int)(grd[i][j] == '.');
		}
	}
	auto get_sum = [&] (int i1, int j1, int i2, int j2) {
		return cum[i2 + 1][j2 + 1]
			- cum[i2 + 1][j1] - cum[i1][j2 + 1] + cum[i1][j1];
	};
	auto is_mono = [&] (int i1, int j1, int i2, int j2) {
		int sum = get_sum(i1, j1, i2, j2);
		int area = (i2 - i1 + 1) * (j2 - j1 + 1);
		return (sum == 0 || sum == area);
	};
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			for (int i1 = i; i1 < h; i1++) {
				int low = j - 1, hgh = w - 1;
				while (low < hgh) {
					int mid = (low + hgh + 1) >> 1;
					if (is_mono(i, j, i1, mid)) low = mid;
					else hgh = mid - 1;
				}
				dpr[i][j][i1] = low;
			}
			for (int j1 = j; j1 < w; j1++) {
				int low = i - 1, hgh = h - 1;
				while (low < hgh) {
					int mid = (low + hgh + 1) >> 1;
					if (is_mono(i, j, mid, j1)) low = mid;
					else hgh = mid - 1;
				}
				dpd[i][j][j1] = low;
			}
		}
	}
	for (int it = 0; ; it++) {
		if (dpr[0][0][h - 1] == w - 1) {
			cout << it << endl;
			return 0;
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				for (int i1 = i; i1 < h; i1++) {
					int j1 = dpr[i][j][i1];
					if (j1 < w - 1) j1 = dpr[i][j1 + 1][i1];
					new_dpr[i][j][i1] = j1;
				}
				for (int j1 = j; j1 < w; j1++) {
					int i1 = dpd[i][j][j1];
					if (i1 < h - 1) i1 = dpd[i1 + 1][j][j1];
					new_dpd[i][j][j1] = i1;
				}
			}
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				for (int i1 = i; i1 < h; i1++) {
					int j1 = new_dpr[i][j][i1];
					while (j1 < w - 1 && new_dpd[i][j][j1 + 1] >= i1) ++j1;
					dpr[i][j][i1] = j1;
				}
				for (int j1 = j; j1 < w; j1++) {
					int i1 = new_dpd[i][j][j1];
					while (i1 < h - 1 && new_dpr[i][j][i1 + 1] >= j1) ++i1;
					dpd[i][j][j1] = i1;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 103808
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N,K = LI()
    P = LI()
    C = LI()

    x = [False] * (N+1)

    ans = -INF
    for i in range(1,N+1):
        #if x[i]: continue
        z = [0] * (N+1)
        y = [0] * (N+1)
        cnt = 0
        cnt_max = -INF
        z[i] = 1
        q = collections.deque()
        q.append(i)
        j = 1
        while q:
            u = q.popleft()
            x[u] = True

            v = P[u-1]
            cnt += C[v-1]
            y[u] = cnt
            cnt_max = max(cnt,cnt_max)
            if j >= K:
                break
            j += 1
            if z[v] > 0:
                r = j - z[v]
                cnt += ((K - j) // r) * (cnt+C[P[v-1]-1]-y[v])
                j += r * ((K - j) // r)
                z = [0] * (N+1)
                cnt_max = max(cnt,cnt_max)
                q.append((v))
            else:
                z[v] = j
                q.append(v)
        ans = max(ans,cnt_max)
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 99836
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

vector<LL> v;
int n,k,a[200111],bit[200111];
void add(int x)
{
	for(;x<200111;x+=x&-x)bit[x]++;
}
int query(int x)
{
	int ret=0;
	for(;x>0;x-=x&-x)ret+=bit[x];
	return ret;
}
int getid(LL x)
{
	return lower_bound(v.begin(),v.end(),x)-v.begin()+1;
}
int main()
{
	get2(n,k);
	for(int i=1;i<=n;i++){get1(a[i]);a[i]-=k;}
	LL sum=0;
	v.pb(sum);
	for(int i=1;i<=n;i++)
	{
		sum+=a[i];
		v.pb(sum);
	}
	sort(v.begin(),v.end());
	sum=0;
	add(getid(0));
	LL ans=0;
	for(int i=1;i<=n;i++)
	{
		sum+=a[i];
		ans+=query(getid(sum));
		add(getid(sum));
	}
	printendl(ans);
	return 0;
}

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

#define ll long long

int main(void){
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.rbegin(),a.rend());
    cout << a[0] - a[a.size()-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef vector <int> VI;
typedef vector <VI> VVI;

#define NONE -1
#define MAX 120

int main( void )
{
	VVI G( MAX, VI( MAX, NONE ) );

	// üÍ
	int cnt = 0;
	while ( cin.eof() == false )
	{
		string input;
		getline( cin, input );

		replace( input.begin(), input.end(), ',', ' ' );
		istringstream is( input );

		int n;
		int m = 0;
		while ( is >> n )
		{
			G[cnt][m] = n;
			m++;
		}

		if ( m > 0 )
			cnt++;
		if ( cin.eof() ) break;
	}

	int middle = cnt/2;
	for ( int i = 1; i <= middle; i++ )
	{
		for ( int j = 0; j < i; j++ )
		{
			for ( int k = middle; k > 0; k-- )
			{
				swap( G[middle+i][k], G[middle+i][k-1] );
			}
		}
	}

	VVI dp = VVI( MAX, VI( MAX, -1 ) );
	dp[0][0] = G[0][0];
	for ( int i = 0; i < MAX; i++ )
	{
		for ( int j = 0; j < MAX; j++ )
		{
			if ( G[i][j] != NONE )
			{
				if ( G[i+1][j] != NONE )
					dp[i+1][j] = max( dp[i+1][j], G[i+1][j] + dp[i][j] );
				if ( G[i+1][j+1] != NONE )
					dp[i+1][j+1] = max( dp[i+1][j+1], G[i+1][j+1] + dp[i][j] );
			}
		}
	}

	int answer = -1;
	for ( int i = 0; i < MAX; i++ )
	{
		for ( int j = 0; j < MAX; j++ )
			answer = max( answer, dp[i][j] );
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 0
n = int(input())
a = list(map(int, input().split()))

count = 0
flag = 0

while flag == 0 :
	
	for i in range(n):
		flag += 0 if a[i] % 2 == 0 else + 1
		a[i] = a[i] / 2


	count += 1 if flag == 0 else +0

print(count)

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>

int search(int *S, int num, int key){
  int l = 0, m = num/2, r = num;
// printf("Enter function search\n");
  while(num > 0){
    // printf("l:S[%d]=%d, m:S[%d]=%d, r:S[%d]=%d\n",l,S[l],m,S[m],r,S[r]);
    if(S[m] > key){
      r = m;
      m = l + (r-l)/2;
    }
    else if(S[m] <key){
      l = m + 1;
      m = l + (r-l)/2;
    }
    else if(S[m] == key){
      return 1;
    }
    if(l > m){
      break;
    }
    num /= 2;
  }

  return 0;
}

int main(){
  int n, *S, q;
  int i, j, in, count=0;
  int num=0;

  // input data
  scanf("%d",&n);
  S = (int *)malloc(sizeof(int) * n);
  for(i=0; i<n; i++){
    scanf("%d",&S[num++]);
  }
  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&in);
    // search
    count += search(S, num, in);
    // printf("q_input:%d (search fin)\n",in);
  }

  printf("%d\n",count);

  return 0;
}



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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll a, b;
  cin >> a >> b;
  map<ll, int> amp, bmp;
  ll aa = a, bb = b;
  for (ll i = 2; i * i <= aa; i++) {
    while (aa % i == 0) {
      amp[i]++;
      aa /= i;
    }
  }
  for (ll i = 2; i * i <= bb; i++) {
    while (bb % i == 0) {
      bmp[i]++;
      bb /= i;
    }
  }
  if (aa > 1) amp[aa]++;
  if (bb > 1) bmp[bb]++;
  map<ll, int> mp;
  for (auto &it : amp) {
    if (bmp.find(it.first) != bmp.end()) {
      mp[it.first] = min(it.second, bmp[it.first]);
    }
  }

  cout << mp.size() + 1 << endl;

  return 0;
}


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

int main(){

    string N;
    cin >> N;

    ll len=N.length();
    ll sum=0;
    for(char d : N){
    sum+=(d-'0');
   }

    if(sum%9==0){
        cout << "Yes" << endl;        
    }
    else{
        cout << "No" << endl; 
    }


    return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vi vector<ll>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define el printf("\n")
#define pb push_back
#define f first
#define s second
#define arrondi(a) (long long)floor(a+0.5);
#define NIL -1
ll N=500005;
ll MAX=9223372036854775807;
ll MOD=1000000007;
long double PI =4*atan(1);

int main()
{
	IOS;
    cout.precision(30);
    ll n,m,k,b,c,x,y; long double a;
    cin >> n; multiset<long double> s;
    for (int i=0;i<n;i++) {cin >> a; s.insert(a);}
    while(s.size()>1)
    {
        multiset<long double> :: iterator it=s.begin(),itt=s.begin();
        itt++;
        long double val=(*it)+(*itt);
        s.erase(s.begin());
        s.erase(s.begin());
        s.insert(val/2);
    }
    cout << *(s.begin());

    return 0;
}


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

using namespace std;
using ll = long long;

const int INFTY = 2e9;

int main(){
    int N; cin >> N;
    vector<vector<ll> > cost(N, vector<ll>(N,INFTY));
    vector<vector<bool> > need(N, vector<bool>(N,true));
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            cin >> cost[i][j];
        }
    }

    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                if(cost[i][j] > cost[i][k] + cost[k][j]){
                    cout << -1 << endl;
                    return 0;
                }

                if(cost[i][k] + cost[k][j] == cost[i][j] && cost[i][k] > 0 && cost[k][j] > 0){
                    need[i][j] = false;
                }
            }
        }
    }

    ll ans = 0ll;
    for(int i=0;i<N;i++){
        for(int j=i;j<N;j++){
            if(need[i][j]) ans += cost[i][j];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

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

Node *root, *NIL;

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

    z = (Node*)malloc(sizeof(Node));
    z->key = key;
    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 *find(int key, Node* node){
    while(node!=NIL && key != node->key){
        if(key < node->key) node = node->left;
        else node = node->right;
    }
    return node;
}
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 del(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, x;
    string com;
    Node *u;

    cin >> n;
    for(int i=0;i<n;i++){
        cin >> com;
        if(com == "insert"){
            cin >> x;
            insert(x);
        }
        else if(com == "print"){
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
        else if(com == "find"){
            cin >> x;
            u = find(x, root);
            if(u != NIL) cout << "yes" << endl;
            else cout << "no" << endl;
        }
        else if(com == "delete"){
            cin >> x;
            del(find(x, root));
        }

    }
    return 0;
}




Measured memory_bytes: 21932
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
 
int main (void)
{
  int n,m;
  cin>>n>>m;
  if(n>m){cout<<0<<endl;return 0;}
  int i,j,x[100000],dp[100000],ans=0;//dp草
  for(i=0;i<m;i++)
  {
    cin>>x[i];
  }
  sort(x,x+m);
  for(i=0;i<m-1;i++)
  {
    dp[i]=x[i+1]-x[i];
  }
 
  
  sort(dp,dp+m-1);
  
 
  
  for(i=0;i<m-n;i++)
  {
    ans+=dp[i];
 
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4268
# -*- coding: utf-8 -*-
# dwacon6th-prelims/dwacon6th_prelims_b
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

MAX = 10**5 + 100
MOD = 10**9 + 7

fac = [0] * MAX
finv = [0] * MAX
inv = [0] * MAX
coef = [0] * MAX

fac[0:2] = (1, 1)
finv[0:2] = (1, 1)
inv[1] = 1
coef[0:2] = (1, 1)

for i in range(2, MAX):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * int(MOD / i) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD
    coef[i] = (coef[i - 1] * i) % MOD + fac[i - 1] % MOD

def main():
    N = i2n()
    n = N - 1
    x = i2nn()
    total = 0
    for i in range(1, N):
        d = x[i] - x[i - 1]
        total = (total + (((coef[i] * fac[n]) % MOD * finv[i]) % MOD) * d % MOD) % MOD
    print(total % MOD)
    return

main()


Measured memory_bytes: 30912
N, K = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
from operator import itemgetter
ab.sort(key=itemgetter(0))
s = [0] * (N + 1)
for i in range(N):
    s[i + 1] = s[i] + ab[i][1]
    if s[i + 1] >= K:
        print(ab[i][0])
        break

Measured memory_bytes: 32084
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))

int main(){
    int N;
    cin >> N;
    int A[N + 1], B[N], C[N + 1];
    A[0] = 0;
    for(int i = 1; i <= N; i++){
        cin >> A[i];
    }
    for(int i = 0; i < N; i++){
        cin >> B[i];
    }
    C[0] = 1e9 + 2;
    for(int i = 1; i <= N; i++){
        cin >> C[i];
    }
    sort(A, A + N + 1);
    sort(C, C + N + 1, greater<>());
    long ans = 0;
    for(int i = 0; i < N; i++){
        ans += (upper_bound(A, A + N + 1, B[i] - 1) - A - 1) * (upper_bound(C, C + N + 1, B[i] + 1, greater<>()) - C - 1);
    }
    cout << ans << endl;
}


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

typedef long long ll;
static const ll MOD=998244353;

ll mod_pow(ll x, ll n){ //べき乗
    ll ans=1;
    x%=MOD;
    while(n!=0){
        if(n&1) ans=ans*x%MOD;
        x=x*x%MOD;
        n=n>>1;
    }
    return ans%MOD;
}


int main(){
    int N,S; cin >> N >> S;
    ll a[N];
    for(int i=0;i<N;i++) cin >> a[i];
    ll dp[N+1][S+1];
    memset(dp,0,sizeof(dp));
    dp[0][0]=mod_pow(2,N);
    for(int i=0;i<N;i++){
        for(int j=0;j<=S;j++){
            dp[i+1][j]+=dp[i][j];
            dp[i+1][j]%=MOD;
            if(j+a[i]>S) continue;
            dp[i+1][j+a[i]]+=(dp[i][j]*mod_pow(2,MOD-2))%MOD;
            dp[i+1][j+a[i]]%=MOD;
        }
    }
    cout << dp[N][S]%MOD << endl;
}

Measured memory_bytes: 73904
while True:
    n, k = map(int, raw_input().split())
    if (n,k) == (0,0):
        break
    a = [int(raw_input()) for _ in range(n)]
    sum, r = 0, 0
    for i in range(n):
        if i < k:
            sum += a[i]
        else:
            sum -= a[i-k]
            sum += a[i]
            r = max((r, sum))
    print r

Measured memory_bytes: 10480
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val k = Integer.parseInt(scanner.next()!!)
    var sum = 0
    (1..k).forEach {a ->
        (1..k).forEach {b ->
            (1..k).forEach { c ->
                sum += gcd3(a,b,c)
            }
        }
    }
    println(sum)
}
tailrec fun gcd2(a: Int, b: Int): Int {
    if (b == 0) {
        return a
    }
    return gcd2(b, a % b)
}
fun gcd3(a: Int, b: Int, c: Int): Int {
    var ans = a
    listOf(b,c).forEach {
        ans = gcd2(ans, it)
    }
    return ans
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  double res = 0;
  for (int i = 0;i < n; i++) {
    double x;
    cin >> x;
    res += 1 / x;
  }
  cout << fixed << setprecision(10) << 1 / res << endl;
}

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

int main(){
    ll n,k;
    cin >>n>>k;
    ll a[n];
    rep(i,n) cin >>a[i];
    sort(a,a+n);
    ll ans=0;
    rep(i,n-k) ans+=a[i];
    cout << ans <<endl; 
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int B = 0; int A = 0;
		for(int i = 0; i < n; i++) {
			int a = sc.nextInt();
			A += a;
			B += a*a;
		}
		float y = A;
		y = y/n;
		int Y = Math.round(y);
		System.out.println(B-2*Y*A+n*Y*Y);
		sc.close();

	}

}

Measured memory_bytes: 23124
import sys

def floyd(v_count, matrix):
  for i in range(v_count):
    for j, c2 in enumerate(matrix[j][i] for j in range(v_count)):
      for k, (c1, c3) in enumerate(zip(matrix[j], matrix[i])):
        if c1 > c2+c3:
          matrix[j][k] = c2+c3
  return matrix

def has_negative_cycle(a):
  return any(row[i] < 0 for i, row in enumerate(a))

V, E = map(int,input().split())
inf = float("inf")
matrix = [[inf]*V for _ in [0]*V]
for i in range(V):
  matrix[i][i] =0
for s,t,d in (map(int, l.split()) for l in sys.stdin):
  matrix[s][t] = d
floyd(V, matrix)
if has_negative_cycle(matrix):
  print('NEGATIVE CYCLE')
else:
  for row in matrix:
    print(' '.join(map(lambda n:str(n) if n!=inf else "INF", row)))



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

int main(){
  int L, R; cin >> L >> R;
  int ans=2019;
  for(int i=L;i<min(L+2018, R);i++){
    for(int j=L+1;j<=min(L+2018,R);j++){
      int k=((i%2019)*(j%2019))%2019;
      if(ans>k){
        ans=k;
      }
    }
  }
  cout << ans << endl;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll s, n;
	cin >> s >> n;

	while (n--) {
		ll x; cin >> x;
		s -= x;
	}

	cout << (s <= 0 ? "Yes" : "No") << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define eb emplace_back
#define precision(n) cout << fixed << setprecision(n);
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
int main()
{
    fast;
   string s;
   long long int sum=0;
   cin>>s;
   for(int i=0;i<s.size();i++)
   {
       sum+=s[i]-'0';

   }
   if(sum%9==0)
   {
       cout<<"Yes"<<endl;
   }
   else
   {
       cout<<"No"<<endl;
   }
   //cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3740
package main

import "fmt"
import "strings"

func isOK(s string) bool {
	if s == "" {
		return true
	} else {
		a := strings.HasPrefix(s, "dreamer") && isOK(s[7:])
		b := strings.HasPrefix(s, "dream") && isOK(s[5:])
		c := strings.HasPrefix(s, "eraser") && isOK(s[6:])
		d := strings.HasPrefix(s, "erase") && isOK(s[5:])
		return a || b || c || d
	}
}

func main() {
	var s string
	fmt.Scan(&s)
	if isOK(s) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}


Measured memory_bytes: 8832
from fractions import gcd

N, M = map(int, input().split()) # 横に2個
S = input()
T = input()
Gcd = gcd(N, M)
Np = N // Gcd
Mp = M // Gcd

ans = Gcd * Mp * Np
for g in range(Gcd):
    if S[g*Np] != T[g*Mp]:
        ans = -1
        break

print(ans)

Measured memory_bytes: 5348
#include<stdio.h>

#define N 10000
int main(){
  int n, q;
  int i, j, key;
  int S[N], T[N];
  int count = 0;
  
  scanf("%d", &n);
 
  for(i = 0; i < n; i++){
    scanf("%d", &S[i]);
  }
  

  scanf("%d", &q);

  for(i = 0; i < q; i++){
    scanf("%d", &T[i]);
  }

  for(i = 0; i < q; i++){
    key = T[i];

    j = 0;

    S[n] = key;

    while(S[j] != key)
      j++;

    if(j != n) count++;
  }
  
  printf("%d\n", count);
  
  return 0;
}

Measured memory_bytes: 644
n, m = gets.split.map(&:to_i)
a = gets.split.map { |x| x.to_i / 2}

def func x
  count = 0
  while (x % 2 == 0)
    x = x / 2
    count += 1
  end
  count
end

t = func a[0]
for i in 0..n-1
  if t != func(a[i])
    puts 0
    exit
  end
  a[i] = a[i] / (2 ** t)
end
m = m / (2 ** t)
l = 1
for i in 0..n-1
  l = l.lcm(a[i])
  if l > m
    puts 0
    exit
  end
end
m /= l
puts ((m + 1)/ 2)


Measured memory_bytes: 8588
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int N, M;
	cin >> N >> M;
	vector<LL> XX(N), YY(M);
	IN(XX); IN(YY);
	vector<LL> X(N-1), Y(M-1);
	for (int i = 0; i < N - 1; ++i) {
		X[i] = XX[i + 1] - XX[i];
	}
	for (int i = 0; i < M - 1; ++i) {
		Y[i] = YY[i + 1] - YY[i];
	}

	LL Xsum = 0;
	N--; M--;
	for (int i = 0; i < N; ++i) {
		LL ter = X[i];
		ter = ter * (i + 1);
		ter %= MOD;
		ter = ter * (N - 1 - i + 1);
		ter %= MOD;
		Xsum += ter;
		Xsum %= MOD;
	}
	LL Ysum = 0;
	for (int i = 0; i < M; ++i) {
		LL ter = Y[i];
		ter = ter * (i + 1);
		ter %= MOD;
		ter = ter * (M - 1 - i + 1);
		ter %= MOD;
		Ysum += ter;
		Ysum %= MOD;
	}
	LL ans = (Xsum*Ysum)%MOD;
	cout << ans << endl;
	
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int N,M;
vector<pair<int,int> >E;
int parent[1<<17],s[1<<17];
vector<long long >ret;
long long ans;
int find(int p){return p==parent[p]?p:(parent[p]=find(parent[p]));}
int main()
{
    cin>>N>>M;
    ans=1LL*N*(N-1)/2;
    ret.push_back(ans);
    for(int i=0;i<M;i++)
    {
        int a,b;cin>>a>>b;
        E.push_back(make_pair(a-1,b-1));
    }
    for(int i=0;i<N;i++)parent[i]=i,s[i]=1;
    for(int i=M;i--;)
    {
        int a=E[i].first,b=E[i].second;
        a=find(a),b=find(b);
        if(a!=b)
        {
            if(s[a]<s[b])
            {
                ans-=s[a]*s[b];
                s[b]+=s[a];
                parent[a]=b;
            }
            else
            {
                ans-=s[a]*s[b];
                s[a]+=s[b];
                parent[b]=a;
            }
        }
        ret.push_back(ans);
    }
    for(int i=M;i--;)cout<<ret[i]<<endl;
}

Measured memory_bytes: 3828
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  ll i=1;
  while(n!=0){
    while(i*(i+1)/2<n){
      i++;
    }
    cout<<i<<endl;
    n-=i;
    i=1;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007LL

const int N = 100005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int k; cin>>k;
    int cur = 0;
    int dp[11][10];
    dp[1][0]=1;
    int tot = 0;
    For(i, 1, 10){
        dp[1][i]=1;
        tot++;
        if(tot==k){
            cout<<i;
            return 0;
        }
    }
    string ans = "";
    int len;
    bool fl = false;
    int prev = 9;
    int cp;
    For(i, 2, 11){
        For(j, 0, 10){
            dp[i][j]=0;
            if(j>0){
                dp[i][j] = dp[i-1][j-1];
            }
            dp[i][j]+=dp[i-1][j];
            if(j<9){
                dp[i][j] += dp[i-1][j+1];
            }
            if(j>0){
                tot+=dp[i][j];
            }
            if(tot >= k){
                ans+=to_string(j);
                k-=prev;
                fl = true;
                len = i-1;
                cp = j;
                break;
            }
            if(j>0){
                prev = tot;
            }
        }
        if(fl)
            break;
    }
    while(len != 0){
        int cur = 0;
        int prev = 0;
        For(i, 0, 10){
            if(abs(cp-i)>1)
                continue;
            cur+=dp[len][i];
            if(cur>=k){
                cp=i;
                ans+=to_string(i);
                if(i > 0){
                    k-=prev;
                }
                break;
            }
            prev = cur;
        }
        len--;
    }
    cout<<ans;
    return 0;
}





Measured memory_bytes: 256
#include <stdio.h>


int main() {
	int n,m,f,r,v;
	int A[100][100] = { { } };
	int b[100] = {};
	int c[100] = {};
	scanf("%d%d", &n,&m);
	for (int i = 0; i < n; i++) 
	{
		for (int j = 0; j < m; j++)
		{
			scanf("%d",&A[i][j]);
		}
	}
	for (int j = 0; j < m; j++)
	{
		scanf("%d", &b[j]);
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			c[i] += b[j] * A[i][j];
		}
	}
	
	for (int i = 0; i < n; i++) {
		printf("%d\n", c[i]);
	}

	return 0;
}

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

int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<int>> T(H,vector<int>(W,-1));
  for(int i = 0; i < H; ++i){
    string s;
    cin >> s;
    for(int j = 0; j < W; ++j){
      if(s[j] == 'c')
        T[i][j] = 0;
    }
    for(int j = 1; j < W; ++j){
      if(T[i][j-1] >= 0 and T[i][j] < 0)
        T[i][j] = T[i][j-1]+1;
    }
  }
  for(int i = 0; i < H; ++i){
    for(int j = 0; j < W; ++j){
      cout << T[i][j] << (j+1 < W ? " " : "\n");
    }
  }
}



Measured memory_bytes: 3244
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e18;
const ll N = 3e5+100;
const ll bits = 20;
const ld pi = 3.14159265358979323846;
const ll mod = 1e9+9;
const ll p = 29;



int main(){
    FASTIO;
    PRECISION; 

    int x,y,z;
    cin>>x>>y>>z;

    swap(x,y);
    swap(x,z);
    cout<<x<<" "<<y<<" "<<z<<"\n";
 
}

Measured memory_bytes: 256
import sys
N = int(input())
A = list(map(int,input().split()))
B = []
tmp = 1
for i in range(N+1):
    B.append(tmp)
    tmp -= A[i]
    if tmp < 0:
        print(-1)
        sys.exit()
    tmp *= 2

for i in range(N, 0, -1):
    A[i-1] += A[i]

ans = 0

for i in range(N+1):
    ans += min(B[i], A[i])

print(ans)

Measured memory_bytes: 676016
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << "\n"; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// debug() << imie(x) imie(y)
//debugging ends


int solve(){
    string s,t;
    cin>>s>>t;
    
    //atcoder
    //codeforces
    int res=10000000;
    for (int i = 0; i < t.length(); i++)
    {
      for (int j = 0; j < s.length(); j++)
      {
           int cnt=0,bk=0;
           if(s[j]==t[i]){
            //  debug()<< imie(t[i]) imie(s[j]);
             int ii=i,jj=j;
             while(ii<t.length() && jj<s.length()){
               if(s[jj]!=t[ii]) cnt++;
               ii++;jj++;
               if(jj>=s.length() && ii<t.length()) {cnt=0;bk=1;break;}
              //  debug()<< imie(t[ii]) imie(s[jj]) imie(cnt);
             }
             if(bk){continue;}
             ii=i;jj=j; 
             while(ii>=0 && jj>=0){
               if(s[jj]!=t[ii]) cnt++;
               ii--;jj--;
               if(ii>=0 && jj<0) {cnt=0;bk=1;break;}
              //  debug()<< imie(t[ii]) imie(s[jj]) imie(cnt);
             }
             if(bk){continue;}
            //  debug()<< imie(cnt);
             res=min(res,cnt);
          }        
      }
      
    }

    if(res==10000000) res=t.length();
    cout<<res;

    return 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cerr<<fixed<<setprecision(10);
  auto start = chrono::high_resolution_clock::now();
  int t=1;
  //cin>>t;
  while(t--)
    solve(),cout<<"\n";

  auto stop = chrono::high_resolution_clock::now(); 
  auto duration = chrono::duration_cast<chrono::nanoseconds>(stop - start); 
  cerr << "Time taken : " << ((long double)duration.count())/((long double) 1e9) <<"s \n";      
  
  return 0;
}


Measured memory_bytes: 3856
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef pair<Int, Int> P;


int main(){
    Int N, Q; cin >> N >> Q;

    // white_X[i] = v: (1,i)までは最も近い白石がv
    map<Int,Int> white_X, white_Y;
    set<Int> id_X, id_Y;
    white_X[N-1] = N-1; id_X.insert(N-1);
    white_Y[N-1] = N-1; id_Y.insert(N-1);

    Int black = (N-2)*(N-2);
    rep(query,Q){
        Int q, x; cin >> q >> x;
        x--;

        if(q == 1){
            int key = *id_X.lower_bound(x);
            Int p = white_X[key];

            black -= p-1;
            if (white_Y.find(p) != white_Y.end()){
                white_Y[p] = min(white_Y[p],x);
            }else{
                white_Y[p] = x;
            }
            id_Y.insert(p);
        } else {
            int key = *id_Y.lower_bound(x);
            Int p = white_Y[key];

            black -= p-1;
            if (white_X.find(p) != white_X.end()){
                white_X[p] = min(white_X[p],x);
            }else{
                white_X[p] = x;
            }
            id_X.insert(p);
        }
    }

    cout << black << endl;

}


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

typedef long long int ll;

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

    set<string> s;
    for(int i=0;i<n;i++)
    {
        string a;
        cin>>a;
        s.insert(a);
    }

    cout<<s.size();
    
    return 0;
}

Measured memory_bytes: 19220