akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

static const int INF = 1e9 + 7;

struct Union_Find {
  int par[100001], root[100001];

  Union_Find()
  {
    for (int i = 0; i < 100001; i++) {
      par[i] = 0;
      root[i] = i;
    }
  }
  int find(int x)
  {
    if (root[x] == x) return x;
    return root[x] = find(root[x]);
  }

  int same(int x, int y)
  {
    return find(x) == find(y);
  }

  void unite(int x, int y)
  {
    if (same(x, y)) return;
    x = find(x);
    y = find(y);
    if (par[x] < par[y]) {
      root[y] = root[x];
    } else {
      root[x] = root[y];
      if (par[x] == par[y]) {
        par[x]++;
      }
    }
  }
};

void hawawa()
{
  int n, m;
  cin >> n >> m;
  vector<vector<int> > l(n);
  Union_Find uf;
  for (int i = 0; i < n; i++) {
    int num;
    cin >> num;
    int lang1;
    cin >> lang1;
    l[i].push_back(lang1);
    for (int j = 1; j < num; j++) {
      int lang2;
      cin >> lang2;
      l[i].push_back(lang2);
      uf.unite(lang1, lang2);
    }
  }
  for (int i = 1; i < n; i++) {
    if (!uf.same(l[0][0], l[i][0])) {
      cout << "NO\n";
      return;
    }
  }
  cout << "YES\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  hawawa();
}

Measured memory_bytes: 6528
S = input()
if S == "MON":
	print(6)
elif S == "TUE":
	print(5)
elif S == "WED":
	print(4)
elif S == "THU":
	print(3)
elif S == "FRI":
	print(2)
elif S == "SAT":
	print(1)
else:
	print(7)


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

using namespace std;

int h;
int w;
int k;
char grid[10][10];

int get(int m1 , int m2){
    int Black = 0;
    for(int i = 0; i < h; i++){
        // 1010
        //&0010

        if(m1 & (1 << i))
            continue;
        for(int j = 0; j < w; j++){
            if(m2 & (1 << j))
                continue;
            Black += grid[i][j] == '#';
        }
    }
    return Black;
}

int main(){
    cin >> h >> w >> k;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> grid[i][j];
        }
    }
    int cnt = 0;
    for(int maskR = 0; maskR < (1 << h); maskR++)
        for(int maskC = 0; maskC < (1 << w); maskC++){
            if(get(maskR , maskC) == k)
                cnt++;
        }
    cout << cnt << "\n";
}
/*
3

    1    2    3
   1 0  1 0  1 0
1 -> 2(N) - 1

0 :   0 0 0 0
1 :   0 0 1 0
2 :   0 1 0
3 :   0 1 1
4 :   1 0 0
5 :   1 0 1
mask = 5
idx = 210
      101
ar[idx]

6 :   1 1 0
7 :   1 1 1
8 : 1 0 0 0


1 0 1 0 1 0 1 0 10111 00 1
3
25 30 40
1 - >2^20
*/




/*


2 3 2

RRR
#R#

mask_Row =  10 0->2^Row-1
mask_Col = 001 0->2^Col-1


0->2^row-1
   0->2^col-1
      if(get(maskR , maskC) == k)
            cnt++;

            maskR & (1 << idx)
             grid


*/



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n; cin >> n;
    ll a = 1, b = 1;
    REP(i, n) {
        ll A, B; cin >> A >> B;
        ll x = (a+A-1)/A;
        ll y = (b+B-1)/B;
        ll z = max(x, y);
        a = A * z, b = B * z;
        // cout << a << " " << b << endl;
    }
    cout << a + b << endl;
}


Measured memory_bytes: 256
import math
[L,R] = list(map(int,input().split()))
#[L,R] = [2020,2040]
if R >= L+2019:
    print(0)
else:
    ans = 2020
    for i in range(L,R):
        for j in range(i+1,R+1):
            if (i*j)%2019 <= ans:
                ans = (i*j)%2019
    print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse -> greater<long long>()
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back

int main(){
   int x,y,z,k;
   cin>>x>>y>>z>>k;
   VI A(x),B(y),C(z);
   rep(i,x)cin>>A[i];
   rep(i,y)cin>>B[i];
   rep(i,z)cin>>C[i];
   sort(rALL(C));
   VI AB;
   rep(i,x)rep(j,y){
      AB.push_back(A[i]+B[j]);
   }
   sort(rALL(AB));
   AB.resize(k);
   VI ans;
   rep(i,sz(AB))rep(j,sz(C)){
      ans.emplace_back(AB[i]+C[j]);
   }
   sort(rALL(ans));
   rep(i,k)cout<<ans[i]<<endl;
}

Measured memory_bytes: 44108
#include <iostream>
#include <algorithm>
#include <set>

using namespace std;

int main(){
  int N,M;
  int K,like;
  cin >> N>>M;
  set<int> foods,food,food_tmp;
  cin >> K;
  for (int i=0;i<K;i++) {
    cin >> like;
    foods.insert(like);
  }
  for(int i=1;i<N;i++){
    cin >> K;
    food.clear();
    for (int j=0;j<K;j++){
      cin >> like;
      food.insert(like);
    }
    food_tmp.clear();
    set_intersection(foods.begin(),foods.end(),
                     food.begin(),food.end(),
                     inserter(food_tmp,food_tmp.end()));
    foods=food_tmp;
  }

  cout << foods.size();
}

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

int A[100], B[100];

int main() {
  int N, result;
  int i;
  scanf ("%d", &N);
  
  for (i=0;i<N-1;i++) {
      scanf("%d", &B[i]);
  }
  B[N-1] = B[N-2];
  
  A[0] = B[0];
  result = A[0];
  for (i=1;i<N;i++) {
  	if (B[i]>B[i-1]) A[i] = B[i-1];
  	else             A[i] = B[i];
  	result += A[i];
  }
  
  
  printf("%d", result);
  return 0;
}




Measured memory_bytes: 128
/*-----------------------------------------atcoder------------------------------------------*/
/*------------------------------------------turtle----------------------------------------*/
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long int

int main() {
	int x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	priority_queue<int,vector<int>,greater<int>>pq;
	vector<int>v;
	for(int i=0;i<a;i++){
		int s;
		cin>>s;
		v.push_back(s);
	}
	sort(v.begin(),v.end(),greater<int>());
	for(auto u:v){
		if(pq.size()<x){
			pq.push(u);
		}
		else break;
	}
	
	v.clear();
	for(int i=0;i<b;i++){
		int s;
		cin>>s;
		v.push_back(s);
		
	}
	sort(v.begin(),v.end(),greater<int>());
	for(auto u:v){
		if(pq.size()<x+y){
			pq.push(u);
		}
		else break;
	}
	v.clear();
	for(int i=0;i<c;i++){
		int s;
		cin>>s;
		pq.push(s);
	}
	while(pq.size()>x+y){
		pq.pop();
	}
	long long int ans=0;
	while(!pq.empty()){
		ans+=pq.top();
		pq.pop();
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2804
#include <bits/stdc++.h>
#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
using namespace std;

inline bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
inline bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
    int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
    return x * fh;
}

struct node {
	int a, b, c, dis;
};

node S;
queue<node> Q;

struct App { int a, b, c; 
	bool operator < (const App &rhs) const { 
		if (a ^ rhs.a) return a < rhs.a;
		if (b ^ rhs.b) return b < rhs.b;
		return c < rhs.c;
	}
};
map<App, bool> M;

inline void Insert(int a, int b, int c, int dis) {
	App now = (App){a, b, c};
	if (M[now]) return ; M[now] = true;
	Q.push(node{a, b, c, dis});
}

int main () {
#ifdef zjp_shadow
	freopen ("c.in", "r", stdin);
	freopen ("c.out", "w", stdout);
#endif
	int a, b, c;
	cin >> a >> b >> c;
	Insert(a, b, c, 0);
	while (!Q.empty()) {
		node u = Q.front(); Q.pop();
		if (u.a == u.b && u.b == u.c) return printf ("%d\n", u.dis), 0;
		Insert(u.a + 1, u.b + 1, u.c, u.dis + 1);
		Insert(u.a, u.b + 1, u.c + 1, u.dis + 1);
		Insert(u.a + 1, u.b, u.c + 1, u.dis + 1);
		Insert(u.a + 2, u.b, u.c, u.dis + 1);
		Insert(u.a, u.b + 2, u.c, u.dis + 1);
		Insert(u.a, u.b, u.c + 2, u.dis + 1);
	}
    return 0;
}


Measured memory_bytes: 6016
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int ans = 0;

    if (n >= 105 && n < 135) {
      ans = 1;
    } else if (n >= 135 && n < 165) {
      ans = 2;
    } else if (n >= 165 && n < 189) {
      ans = 3;
    } else if (n >= 189 && n < 195) {
      ans = 4;
    } else if (n >= 195) {
      ans = 5;
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 22996
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(){
    double x1,x2,y1,y2,x,y;
    cin>>x1>>y1>>x2>>y2;
    x=pow(x2-x1,2);
    y=pow(y2-y1,2);
    cout<<fixed<<setprecision(15)<<sqrt(x+y)<<endl;
    return 0;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int x;
    cin >> x;
    for(ll a = -200; a <= 200; a++){
        for(ll b = -200; b <= 200; b++){
            ll a5 = a * a * a * a * a;
            ll b5 = b * b * b * b * b;
            if (a5 - b5 == x){
                printf("%lld %lld\n", a, b);
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3772
import sys
input = sys.stdin.readline
W, H, N = map(int, input().split())
vs = set()
for _ in range(N):
    a, b = map(int, input().split())
    vs.add((a-1,b-1))

R = [0] * 10
vvs = set()
for a, b in vs:
    for i in range(3):
        for j in range(3):
            x, y = a+i-2, b+j-2
            if x < 0 or W-3 < x or y < 0 or H-3 < y:
                continue
            if (x, y) in vvs:
#                print(x, y, a, b)
                continue
            c = 0
#            print(x, y, a, b)
            for k in range(3):
                for l in range(3):
#                    print(x+k, y+l)
                    if (x+k, y+l) in vs:
                        c += 1
#            print(c, x, y)
            R[c] += 1
            vvs.add((x, y))

R[0] = (H-2)*(W-2)-sum(R)
for i in range(10):
    print(R[i])


Measured memory_bytes: 117492
#include<bits/stdc++.h>
using namespace std;
map<int,int>ma;
struct X{
   int l,r;
};
int main()
{
    X a[100001];
    int n,m,mx,mn;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a[i].l>>a[i].r;
    }
    mx=a[0].l;
    mn=a[0].r;
    for(int i=1;i<m;i++){
        mx=max(mx,a[i].l);
        mn=min(mn,a[i].r);
    }
    if(mn<mx) cout<<0<<endl;
    else
    cout<<mn-mx+1<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MOD = 1e9+7;


int main(){
    string S; cin >> S;
    int ans = 0;

    int l = 0, r = S.size()-1;
    while(l < r){
        if(S[l] == S[r]) {
            l++;
            r--;
        }
        else{
            if(S[l] == 'x'){
                ans++;
                l++;
            }
            else if(S[r] == 'x'){
                ans++;
                r--;
            }
            else {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine().ToInt();
            var a = new int[N];

            for (var i = 0; i < N; i++)
            {
                a[i] = Console.ReadLine().ToInt();
            }

            var count = 0;
            var nextButton = 0;
            var visitedFlgs = new bool[N];
            visitedFlgs[nextButton] = true;
            while(true)
            {
                count++;
                nextButton = a[nextButton] - 1;

                if(nextButton == 1)
                    break;

                if(visitedFlgs[nextButton])
                    break;

                visitedFlgs[nextButton] = true;

                if(count >= N)
                    break;
            }

            Console.WriteLine(nextButton == 1 ? count.ToString() : "-1");
        }
    }
    
    static class StringExtention
    {
        static public int ToInt(this string input)
        {
            return int.Parse(input);
        }

        static public int[] ToIntArray(this string input)
        {
            return input.Split(' ').Select(int.Parse).ToArray();
        }

        static public long ToLong(this string input)
        {
            return long.Parse(input);
        }

        static public long[] ToLongArray(this string input)
        {
            return input.Split(' ').Select(long.Parse).ToArray();
        }
    }
}


Measured memory_bytes: 15200
import java.util.Scanner;

class Main {
    final Scanner sc = new Scanner(System.in);

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

    private void run() {
        int n = sc.nextInt();
        int[] a = new int[n + 1];
        for (int i = 0; i <= n; i++) {
            a[i] = sc.nextInt();
        }

        // 葉ではない頂点の最大数
        long[] max = new long[n + 1];
        max[0] = 1 - a[0];
        if (max[0] < 0) {
            System.out.println(-1);
            return;
        }

        long ln = 100000000000000L;
        for (int i = 1; i <= n; i++) {
            max[i] = Math.min(max[i - 1] * 2 - a[i], ln);
            if (max[i] < 0) {
                System.out.println(-1);
                return;
            }
        }

        long ans = a[n];
        long[] b = new long[n + 1];
        b[n] = a[n];
        for (int i = n - 1; i >= 0; i--) {
            b[i] = Math.min(max[i], b[i + 1]) + a[i];
            ans += b[i];
        }

        System.out.println(ans);
    }
}



Measured memory_bytes: 58936
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define st first
#define nd second
#define rep(i,n) for (long long (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for(long long (i)=(a);(i)<(b);++(i))
#define pb push_back
#define mp make_pair
#define endl '\n'
const int mx=1e5+5;
int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	string s,t;cin >> s >> t;ll a=0;
	if(s[0]==t[0])++a;
	if(s[1]==t[1])++a;
	if(s[2]==t[2])++a;
	cout << a << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;

struct SegTree {

	vector<int> data;
	int size;

	void init(vector<int>& init_data) {
		size = 1;
		while(size < (int)init_data.size()) {
			size = size * 2;
		}
		data.resize(size * 2);
		for(int i = 0; i < (int)init_data.size(); i++) {
			data[size + i] = init_data[i];
		}
		for(int i = (int)init_data.size(); i < size; i++) {
			data[size + i] = -1;
		}
		for(int i = size - 1; i > 0; i--) {
			data[i] = max(data[i * 2 + 0], data[i * 2 + 1]);
		}
	}

	void update(int pos, int val) {
		pos = pos + size;
		data[pos] = val;
		pos = pos / 2;
		while(pos > 0) {
			data[pos] = max(data[pos * 2 + 0], data[pos * 2 + 1]);
			pos = pos / 2;
		}
	}

	int maxi(int a, int b, int l, int r, int k) {

		if(b <= l || r <= a) {
			return -1;
		}
		if(a <= l && r <= b) {
			return data[k];
		}

		int mid = (l + r) / 2;
		int lv = maxi(a, b, l, mid, k * 2 + 0);
		int rv = maxi(a, b, mid, r, k * 2 + 1);
		return max(lv, rv);
	}

	int maxi(int a, int b) {
		return maxi(a, b, 0, size, 1);
	}
};

int main()
{
	int n;
	vector<int> as, bs;

	scanf("%d", &n);
	as.resize(n);
	bs.resize(n);
	for(int i = 0; i < n; i++) {
		scanf("%d", &as[i]);
	}
	for(int i = 0; i < n; i++) {
		scanf("%d", &bs[i]);
	}

	vector<pair<int, int>> cells;

	for(int i = 0; i < n; i++) {
		cells.push_back({bs[i], as[i]});
	}
	sort(cells.begin(), cells.end());

	vector<pair<int, int>> as_list;
	for(int i = 0; i < n; i++) {
		as_list.push_back({cells[i].second, i});
	}
	sort(as_list.begin(), as_list.end());

	vector<int> a_ord(n);
	for(int i = 0; i < n; i++) {
		a_ord[as_list[i].second] = i;
	}

	vector<int> pos_list_data(n);
	for(int i = 0; i < n; i++) {
		pos_list_data[a_ord[i]] = i;
	}

	SegTree pos_list;
	pos_list.init(pos_list_data);
	int step = 0;

	for(int i = 0; i < n; i++) {
		//printf("pos[%d] = %d\n", i, pos_list_data[i]);
	}

	for(int pos = 0; pos < n; pos++) {

		int b = cells[pos].first, a = cells[pos].second;

		//printf("%d -> %d %d\n", pos, a, b);

		if(a <= b) {
			continue;
		}

		pair<int,int> l = {b, inf};
		int o = upper_bound(as_list.begin(), as_list.end(), l) - as_list.begin();
		int target = pos_list.maxi(0, o);
		//printf("o = %d, target = %d\n", o, target);

		if(o == 0 || target <= pos) {
			step = inf;
			break;
		} else {
			swap(cells[pos].second, cells[target].second);
			swap(a_ord[pos], a_ord[target]);
			pos_list.update(a_ord[pos], pos);
			pos_list.update(a_ord[target], target);
			step += 1;
			//printf("    swap: %d -> %d\n", target, cells[pos].second);
		}
	}

	//fprintf(stderr, "step: %d\n", step);

	printf("%s\n", step <= n - 2 ? "Yes" : "No");

	return 0;
}

/* waffle */


Measured memory_bytes: 4340
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define inf 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}

/*--------Library Zone!--------*/

int n, ans;
P red[105], blue[105];
bool re[105], bl[105];
signed main() {
	cin >> n;
	rep(i, n)cin >> red[i].second >> red[i].first;
	rep(i, n)cin >> blue[i].first >> blue[i].second;
	sort(red, red + n);
	reverse(red, red + n);
	sort(blue, blue + n);
	rep(j, n) {
		rep(i, n) {
			if (!re[i] && !bl[j] && red[i].second < blue[j].first&&red[i].first < blue[j].second) {
				ans++;
				re[i] = true;
				bl[j] = true;
			}
		}
	}
	cout << ans << endl;
	endre;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
//#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define all1(i) begin(i),end(i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false

int main(void){
    
    ll R,C,K;
    vector<pair<ll,ll>> CV[3000];
    ll r,c,v;
    
    cin >> R >> C >> K;
    REP(i,K){
        cin >> r >> c >> v;
        r--;c--;
        CV[r].push_back({c,v});
    }
    
    ll dp[2][3000][4]={};
    
    REP(j,R){
        vector<ll> P(C,0);
        REP(i,CV[j].size()){
            P[CV[j][i].first]+=CV[j][i].second;
        }
        
        
        REP(i,C){
            REP(k,4){
                //横・とる
                if(i!=C-1 && k!=3){
                    dp[0][i+1][k+1]=max(dp[0][i+1][k+1],P[i]+dp[0][i][k]);
                }
                //横・とらない
                if(i!=C-1){
                    dp[0][i+1][k]=max(dp[0][i+1][k],dp[0][i][k]);
                }
                //縦・とる
                if(k!=3){
                    dp[1][i][0]=max(dp[1][i][0],P[i]+dp[0][i][k]);
                }
                //縦・とらない
                dp[1][i][0]=max(dp[1][i][0],dp[0][i][k]);
                
            }
        }
        REP(i,C){
            REP(k,4){
                dp[0][i][k]=dp[1][i][k];
                dp[1][i][k]=0;
            }
        }
        
        /*
        REP(i,C){
            ll d=0;
            REP(k,4){
                d=max(d,dp[0][i][k]);
            }
            cout << d << " ";
        }cout << endl;*/
        
    }
    
    ll Ans=0;
    REP(i,C){
        REP(k,4){
            Ans = max(Ans,dp[0][i][k]);
        }
    }
    cout << Ans << endl;
    
    return 0;
}



Measured memory_bytes: 9416
#include<stdio.h>
int main(){
    int a;
    scanf("%d",&a);
    for(;a--;){
        int b[10];
        for(int i=0;i<10;i++)scanf("%d",b+i);
        bool ans=false;
        for(int i=0;i<1024;i++){
            int maxa=0;
            int maxb=0;
            bool val=true;
            for(int j=0;j<10;j++){
                if(i&1<<j){
                    if(maxa<b[j])maxa=b[j];
                    else val=false;
                }else{
                    if(maxb<b[j])maxb=b[j];
                    else val=false;
                }
            }
            if(val)ans=true;
        }
        printf(ans?"YES\n":"NO\n");
    }
}


Measured memory_bytes: 2576
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int n, w[220][220], res = -1;
char p[220][220];
int main() {
	int i, j, k;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		scanf("%s", p[i] + 1);
		for (j = 1; j <= n; j++) {
			if (i == j)w[i][j] = 0;
			else if (p[i][j] == '1')w[i][j] = 1;
			else w[i][j] = 1e9;
		}
	}
	for (k = 1; k <= n; k++) {
		for (i = 1; i <= n; i++) {
			for (j = 1; j <= n; j++) {
				w[i][j] = min(w[i][j], w[i][k] + w[k][j]);
			}
		}
	}
	for (i = 1; i <= n; i++) {
		int Mx = 0, chk = 0;
		for (j = 1; j <= n; j++) {
			if (Mx < w[i][j])Mx = w[i][j];
		}
		for (j = 1; j <= n; j++) {
			for (k = 1; k <= n; k++) {
				if (w[i][j] == w[i][k] && p[j][k] == '1')chk = 1;
			}
		}
		if (!chk) {
			res = max(res, Mx + 1);
		}
	}
	printf("%d\n", res);
}

Measured memory_bytes: 512
data = input().split()
s = input()
end_max = int(max(data[3:5]))
s = s[int(data[1])-1:end_max]

if '##' in s:
    print('No')
else:
    if int(data[3]) < int(data[4]):
        print('Yes')
    else:
        s = s[int(data[2])-2:int(data[4])+1]
        if '...' in s:
            print('Yes')
        else:
            print('No')


Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>
#include <tuple>
#include <iostream>
#include <deque>
#include <array>
#include <set>
#include <functional>

int main() {
	int n; std::cin >> n;
	std::vector<long long int> values(n);
	for (auto& v : values) std::cin >> v;
	std::sort(values.begin(), values.end());
	std::vector<std::pair<long long int, long long int>> operation;
	int minus{ 0 }, zero{ 0 }, positive{ 0 };
	int min_abs_index = 0;
	for (auto i = 0; i < n; ++i) {
		auto v = values[i];
		if (v == 0) {
			++zero;
		}
		else if (v < 0) {
			++minus;
		}
		else {
			++positive;
		}
		if (std::abs(values[min_abs_index]) > std::abs(v)) {
			min_abs_index = i;
		}
	}
	if (minus == 0) {
		long long int current = values[0];
		for (auto i = 1; i < n - 1; ++i) {
			operation.push_back(std::make_pair(current, values[i]));
			current -= values[i];
		}
		operation.push_back(std::make_pair(values.back(), current));
	}
	else if (positive == 0) {
		long long int current = values.back();
		for (int i = n - 2; i >= 0; --i) {
			operation.push_back(std::make_pair(current, values[i]));
			current -= values[i];
		}
	}
	else if (zero > 0) {
		long long int current = values[minus];
		for (auto i = minus + 1; i < n - 1; ++i) {
			operation.push_back(std::make_pair(current, values[i]));
			current -= values[i];
		}
		operation.push_back(std::make_pair(values.back(), current));
		current = values.back() - current;
		for (auto i = 0; i < minus; ++i) {
			operation.push_back(std::make_pair(current, values[i]));
			current -= values[i];
		}
	}
	else {
		long long int current = values[0];
		for (auto i = minus; i < n - 1; ++i) {
			operation.push_back(std::make_pair(current, values[i]));
			current -= values[i];
		}
		operation.push_back(std::make_pair(values.back(), current));
		current = values.back() - current;
		for (auto i = 1; i < minus; ++i) {
			operation.push_back(std::make_pair(current, values[i]));
			current -= values[i];
		}
	}

	std::cout << operation.back().first - operation.back().second << std::endl;
	for (const auto& p : operation) {
		std::cout << p.first << " " << p.second << std::endl;
	}
}



Measured memory_bytes: 4336
import sys
sys.setrecursionlimit(10**9)

N, M = map(int, input().split())

cond = N == M or N+1 == M or N == M+1
if cond == False:
	print(0)
	sys.exit()

def factorial(a):
	ans = 1
	for i in range(1,a+1):
		ans *= i
		ans %= 1000000007
	return ans

if N == M:
	h = factorial(N)
	print((((h*h)%1000000007)*2)%1000000007)
else:
	h_1 = factorial(N)
	h_2 = factorial(M)
	print((h_1*h_2) % 1000000007)




Measured memory_bytes: 3064
N, *XY = map(int, open(0).read().split())
X = XY[::2]
Y = XY[1::2]
ans = N
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        p = X[i] - X[j]
        q = Y[i] - Y[j]
        cnt = 0
        for k in range(N):
            for l in range(N):
                if k == l:
                    continue
                if X[k] - X[l] == p and Y[k] - Y[l] == q:
                    cnt += 1
        ans = min(ans, N - cnt)
print(ans)


Measured memory_bytes: 9116
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long int
using namespace std;
int mod = 1e9 + 7;

int32_t main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio;

	int n;
	cin >> n;
	if (n >= 30)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15); 
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j) {
            ans = max(ans, abs(a[i] - a[j])); 
        }
    cout << ans << endl; 
    return 0; 
}

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

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {

            var imp = Console.ReadLine().Split(' ');
            Array.Sort(imp);
            if (imp[0] == "1" && imp[1] == "4" && imp[2] == "7" && imp[3] == "9")
            {
                Console.Write("YES");
            }
            else
            {
                Console.Write("NO");
            }
            
            //System.Threading.Thread.Sleep(1000);
        }
    }
    
}


Measured memory_bytes: 13404
#include<iostream>
#include<cstdio>
#include<algorithm> 
#include<string>
using namespace std;
string s;
int main()
{
 	cin >> s;
    if (s[s.size() - 1] == 's') cout << s << "es" << endl;
    else cout << s << "s" << endl;
    return 0;
} 

Measured memory_bytes: 3636
#include<iostream>
#include<math.h>
using namespace std;


int main() {
	long long a, b;
	long long v, w, t;
	cin >> a >> v >> b >> w >> t;


	if (a < b) {
		if (a + v * t >= b + w * t) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	else {
		if (a - v * t <= b - w * t) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3640
/*
A fallen time that's bygone
A crude elite that's from a distant zone
You turn a blind eye on what's "brave"
You don't know if it's the truth you told

Anger looks on the quiet dreaming
Seals the sense incandescent ones

Hold back desire for danger
A bet you lose, you'll have no way to turn
I see the man who lives and breathes corruption
Into a circle that you call your own

Don't run away, from the pain. A claim that you deal with
A power game, from within. Impossible for you to see this

Laid down the laws of deceit
The ones who cherish are the ones who'll go
Into the ashes of a tortured world
Only in mind's eye can you see a light

Harmony breaks, dark awakes, in old eyes - the trouble, feel it
Here to stay, mark the way, improvise the judgement hearing

Don't run away, from the pain. A claim that you deal with
A power game, from within. Impossible for you to see this

Anger looks on the quiet dreaming
Seals the sense incandescent ones

All remains of the glowing embers
Is a bleak cold irrelevance
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery

#define eps 1e-9
#define M_PI 3.141592653589793
#define bsize 300

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 610031;

int r,g,b,n,ans;

int main(){
//    freopen("apache.in","r",stdin);
//    freopen("apache.out","w",stdout);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    //cin.tie(0);

    cin>>r>>g>>b>>n;
    for (int i=0;i<=n;i++){
    	for (int j=0;j<=n;j++){
    		int taken=r*i+j*g;
    		if (taken>n)
    			continue;
    		int need=n-taken;
    		if (need%b==0)
    			++ans;
    	}
    }
    cout<<ans<<endl;

//    cin.get(); cin.get();
    return 0;
}


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

int main()
{
    int a[3],k;
    cin>>a[0]>>a[1]>>a[2];
    cin>>k;
    while(a[1]<=a[0])
    {
        a[1]*=2;
        k--;
    }
    while(a[2]<=a[1])
    {
        a[2]*=2;
        k--;
    }
    if(k>=0) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

void fin(ll x,ll y){
  cout<<x<<" "<<y<<endl;
}

int main(){
  ll N,A,B;
  cin>>N>>A>>B;

  N%=12;
  if(N==0) fin(A,B);
  else if(N==1) fin(A-B,B);
  else if(N==2) fin(A-B,A);
  else if(N==3) fin(-B,A);
  else if(N==4) fin(-B,A-B);
  else if(N==5) fin(-A,A-B);
  else if(N==6) fin(-A,-B);
  else if(N==7) fin(B-A,-B);
  else if(N==8) fin(B-A,-A);
  else if(N==9) fin(B,-A);
  else if(N==10) fin(B,B-A);
  else if(N==11) fin(A,B-A);
  

  return 0;
}



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

const long long mod =1e9+7 ;
const int N = 1e6+5;


#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define fr(i,l,m) for(int i=l;i<m;i++)
# define vii vector<int>
#define vpr vector<pair<int,int>
#define debug(x) cout << #x << " is " << x << endl;
#define speak(x) cout<<x<<endl;
ll pwr(ll x,ll y);

////
////
////
int a[N];
bool dp[N];

////
////
///
int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);

int n,k;
cin>>n>>k;
fr(i,1,n+1)
{
    cin>>a[i];
}


fr(i,1,k+1)
{
    fr(j,1,n+1)
    {
        if(i>=a[j] && dp[i-a[j]]==0)
        {
            dp[i]=1;
            break;
        }
    }
}
if(dp[k]==1){cout<<"First\n";}
else{cout<<"Second\n";}

/////
////
////

return 0;
}
ll pwr(ll x,ll y)
{
    ll ans=1;
    x=x%mod;
    while(y>0){
    if(y&1)ans=(x*(ans%mod))%mod;
    x=(x*x)%mod;
    y=y/2;

    }
    return ans%mod;
}



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

int main() {
  string s,t; cin>>s>>t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  if(s<t) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

int main() {
    ll n, k;
    cin >> n >> k;
    ll r, s, p;
    cin >> r >> s >> p;
    string t;
    cin >> t;
    const ll RR = 0, SS = 1, PP = 2;

    ll ans = 0;
    for (ll i = 0; i < k; ++i) {
        vector<vector<ll>> dp(n / k + 10, vector<ll>(3));
        ll tmp = 0;
        for (ll j = i; j < n; j += k) {
            ll idx = j / k;
            rep(now, 3) {
                rep(prev, 3) {
                    if (idx > 0 && now == prev) continue;
                    dp[idx + 1][now] = max(dp[idx + 1][now], dp[idx][prev]);

                    if (t[j] == 'r' && now == PP) {
                        dp[idx + 1][now] = max(dp[idx + 1][now], dp[idx][prev] + p);
                    }
                    if (t[j] == 's' && now == RR) {
                        dp[idx + 1][now] = max(dp[idx + 1][now], dp[idx][prev] + r);
                    }
                    if (t[j] == 'p' && now == SS) {
                        dp[idx + 1][now] = max(dp[idx + 1][now], dp[idx][prev] + s);
                    }
                }
                tmp = max(tmp, dp[idx + 1][now]);
            }
        }
        ans += tmp;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <string.h>
#include <cstdio>
#include <string>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
//#include <unordered_map>
#define Fbo friend bool operator < (node a, node b)
#define mem(a, b) memset(a, b, sizeof(a))
#define FOR(a, b, c) for (int a = b; a <= c; a++)
#define RFOR(a, b, c) for (int a = b; a >= c; a--)
#define off ios::sync_with_stdio(0)
#define sc(a) scanf("%d",&a)
#define pr(a) printf("%d\n",a);
#define SC(n,m) scanf("%d%d",&n,&m)
bool check1(int a) { return (a & (a - 1)) == 0 ? true : false; }

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int INF = 0x3f3f3f3f;//1e10
const int mod = 1e4;
const int Maxn = 1e5+9;
const int M = Maxn * 20;
const double pi = acos(-1.0);
const double eps = 1e-8;

int n, k;
int a[Maxn];

int solve(int l,int r) {
    if (l < 0 && r < 0)return -l;
    if (l > 0 && r > 0)return r;
    return r - l + min(-l, r);
}

int main() {
    cin >> n >> k;
    k--;
    FOR(i, 1, n)cin >> a[i];
    int ans = INF;
    for (int i = 1; i <= n-k ; i++) {
        ans = min(ans, solve(a[i],a[i+k]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
from bisect import bisect_left
import sys
input = sys.stdin.readline
def LIS():
    N = int(input())
    INF = 10000000000
    dp = [INF] * (N+1)
    for _ in range(N):
        x = int(input())
        dp[bisect_left(dp, x)] = x
    print(bisect_left(dp, INF - 1))

LIS()


Measured memory_bytes: 9484
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main(){

	int n;
	string s;

	cin >> n;
	cin >> s;

	if (n % 2 == 1) {
		cout << "No" << endl;
		return 0;
	}

	for (int i = 0;i < n / 2;i++) {
		if (s[i] != s[i + n / 2]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout<< "Yes" << endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <queue>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pl=pair<ll,ll>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vs=vector<string>;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

void solve() {
    ll D,T,S;
    cin >> D >> T >> S;

    bool ok = (D <= T*S);
    print(ok?"Yes":"No");
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;

bool check(int a, int b) {
	return a > b;
}

int main() {
	vector<int>a(4);
	rep(i, 4) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	bool ans = false;
	if (a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9) {
		ans = true;
	}
	YES(ans);
	return 0;
}


Measured memory_bytes: 256
import math
N, K = map(int, input().split())
right=N
left=K
ans=0
cnt=0
while left > N:
    left = math.ceil(left/2)
    cnt+=1
while True:
    ans += (1/N)*(right-left+1)*(1/2)**cnt
    right = left-1
    left = math.ceil((right+1)/2)
    cnt+=1
    if left==1:
        break
ans += (1/N)*(right-left+1)*(1/2)**cnt
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
int const M=2e5+10,inf=1e9+10,mod=1e9+7;
int a[M],n;
bool mark[M];
main()
{
	string x;
	cin>>x;
	for(int i=0;i<x.size();i++)
	{
		mark[x[i]-'a']=1;
	}
	for(int i=0;i<26;i++)
	{
		if(!mark[i])return cout<<x<<char(i+'a'),0;
	}
	char tmp=x[(int)x.size()-1];
	for(int i=(int)x.size()-2;i>=0;i--)
	{
		int tmp=1000;
		for(int k=i+1;k<x.size();k++)
		{
			int hlp=x[k]-'a';
			if(x[i]<x[k])tmp=min(tmp,hlp);
		}
		if(tmp==1000)continue;
		for(int j=0;j<i;j++)cout<<x[j];
		cout<<char(tmp+'a');
		return 0;
	}
	cout<<-1;
}

Measured memory_bytes: 256
N=input()
slen=len(N)-1
if(slen==0):
    print(N)
    exit()
ans=0
for i in range(2<<(slen-1)):
    k=N
    ins=0
    for j in range(slen): 
        if((i>>j)&1):
            k=k[:j+1+ins]+"+"+k[j+1+ins:]
            ins+=1
    ans+=eval(k)
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#define size 100001

int N,M;
int*dist[size];
int city[size];
int qu[size];
int dist_s[size];

void set(){
  int a,b;
  for(int i=0;i<N;i++){
    city[i]=-1;
    dist_s[i]=0;
  };
  city[0]=0;
  for(int i=0;i<M;i++){
    scanf("%d %d",&a,&b);
    a--;b--;
    dist[a]=realloc(dist[a],sizeof(int)*(dist_s[a]+1));
     dist[a][dist_s[a]]=b;
      dist_s[a]++;
    dist[b]=realloc(dist[b],sizeof(int)*(dist_s[b]+1));
     dist[b][dist_s[b]]=a;
      dist_s[b]++;
  };
};

void sys(){
  int tar=0,nm=0,ji=0;
  while(1){
    for(int i=0;i<dist_s[tar];i++){
      if(city[dist[tar][i]]!=-1)continue;
      city[dist[tar][i]]=tar+1;
      qu[nm]=dist[tar][i];
      nm++;
    };
    if(nm==ji)break;
    tar=qu[ji];
    ji++;
  };
};
    
int main(void){
   scanf("%d%d",&N,&M);
   set();
   sys();
   printf("Yes\n");
   for(int i=1;i<N;i++){
     printf("%d\n",city[i]);
   };
  
  return 0;
}

Measured memory_bytes: 8452
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)

const int INF = 100000000;

using namespace std;


int main() {
	char a, b;
	cin >> a >> b;
	if (a == 'H') {
		if (b == 'H')cout << "H" << endl;
		else cout << "D" << endl;
	}
	else {
		if (b == 'H')cout << "D" << endl;
		else cout << "H" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
import java.util.StringJoiner;
import java.util.stream.Collectors;

@SuppressWarnings("ALL")
public class Main {

    public static void main(String[] args) {
        List<Integer> values = IO.readLineAsIntList();
        int n = values.get(0);
        int m = values.get(1);

        int x = calc(n, m);

        IO.writeLine("" + x);
    }

    private static int calc(int n, int m) {
        int r = n - m;
        int p = bai(2, m);
        return p * (m * 1900 + r * 100);
    }

    private static int bai(int n, int p) {
        if( p == 0 ) return 0;
        if( p == 1 ) return n;

        int time = p - 1;
        for (int i = 0; i < time; i++) {
            n = n * 2;
        }
        return n;
    }

    public static class IO {

        private static BufferedReader br;

        private static BufferedReader br() {
            if( br == null ) {
                br = new BufferedReader( new InputStreamReader(new BufferedInputStream(System.in), StandardCharsets.UTF_8) );
            }
            return br;
        }

        public static String readLine() {
            try {
                return br().readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        public static int readLineAsInt() {
            return Integer.parseInt(readLine());
        }

        public static List<String> readLineAsList() {
            return Arrays.asList( readLine().split(" "));
        }

        public static List<Integer> readLineAsIntList() {
            return readLineAsList().stream()
                    .map( Integer::parseInt )
                    .collect(Collectors.toList());
        }

        public static void writeLine(String line) {
            System.out.println( line );
        }

        public static void writeLine(List<Integer> values) {
            StringJoiner j = new StringJoiner(" ");
            values.forEach(i -> j.add(String.valueOf(i)) );
            writeLine(j.toString());
        }

        public static void writeLines(List<String> lines) {
            lines.forEach(System.out::println);
        }
    }
}


Measured memory_bytes: 28500
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
using namespace std;

typedef long long ll;


int main() {
	ll n, k; cin >> n >> k;
	ll b = n/k;
	ll ans = b*b*b;
	for (ll i = 1; i < k; i++) {
		if ((2 * i) % k != 0) continue;
		if (i <= n%k) b = n / k + 1;
		else b = n / k;
		ans += b*b*b;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256