akhauriyash/Code-Regression huggingface dataset:
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
#define pb     push_back
#define inf     2e18
#define low     -2e18
#define PI        acos(-1.0)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
const int sz = 2e5+9;
ll vis[sz];
vector<ll> v[sz];
ll cnt = 0;
void dfs(ll node)
{
    vis[node]   =1;
    cnt++;
    for(ll i=0;i<v[node].size();i++)
    {
        if(vis[v[node][i]]==0)
        {
            dfs(v[node][i]);
        }
    }
}
int main()
{
    ll i,n,t,k,j,x=0,y=0,m;
    FAST
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    ll ans = 0;
    for(i=1;i<=n;i++)
    {
        cnt = 0;
        if(vis[i]==0)
        {
            dfs(i);
            ans =max(ans,cnt);
        }
    }
    cout<<ans<<endl;
    return 0;
}



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

int main() {
	int a[5];
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
	}
	int k;
	cin >> k;
	int count = 0;
	for (int i = 0; i < 5; i++) {
		for (int j = 0; j < 5; j++) {
			if (a[i] - a[j] > k) {
				count++;
			}
		}
	}
	if (count == 0) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

int main(){

    ll k; cin >> k;

    queue<ll> q;
    rep2(i, 1, 10) q.push(i);

    ll x;
    rep(i, k){
        x = q.front(); q.pop();
        if(x%10 != 0){
            q.push(10*x+(x%10)-1);
        } 
        q.push(10*x+(x%10));
        if(x%10 != 9){
            q.push(10*x+(x%10)+1);
        }
    }

    cout << x << endl;

    return 0;
}

Measured memory_bytes: 5092
#include <iostream>
using namespace std;
 
int main() {
	unsigned long long int N , M ,a;
	cin >> N >> M;
	a = N;
	long long int Mmax = M / 2;
	if (M >= 2 * N) {
		N = N + (M - 2 * N) / 4;
		M = M - 2 * ((M - 2 * a) / 4);
	}
	for (int x = 0;x < 100;x++) {
		if (N >= M / 2) {
			N = M / 2;
			break;
		}
		else if (N * 2 < M && M - 2 * N < 4) {
			break;
		}
		else {
			N = N + 1;
			M = M - 2;
		}
	}
	cout << N << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>
#include <set>
#include <bitset>
#include <limits>

using namespace std;

#define ll long long

int main(void){
    char a;
    cin >> a;

    if(isupper(a))  cout << "A" << endl;
    else            cout << "a" << endl; 

    return 0;
}

Measured memory_bytes: 3524
a, b, c, d, e = list(map(int, input().split()))
if a == 0:
  my_result = 1
elif b == 0:
  my_result = 2
elif c == 0:
  my_result = 3
elif d == 0:
  my_result = 4
elif e == 0:
  my_result = 5
print(my_result)

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

int main (){
    ll X, Y, Z, K;
    cin>>X>>Y>>Z>>K;
    vector<ll> A(X), B(Y), C(Z);
  	for(int i=0; i<X; i++){
      	cin>>A.at(i);
    }
  	for(int i=0; i<Y; i++){
      	cin>>B.at(i);
    }
  	for(int i=0; i<Z; i++){
      	cin>>C.at(i);
    }
  	int XYZ=X*Y*Z;
    int limit=K;
  	//cout<<limit<<endl;
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    sort(B.begin(), B.end());
    reverse(B.begin(), B.end());
    sort(C.begin(), C.end());
    reverse(C.begin(), C.end());
    vector<ll> ABC(0);
    for(ll i=0; i<X; i++){
        for(ll j=0; j<Y; j++){
            if((i+1)*(j+1)>limit){
              	//cout<<'!'<<endl;
                break;
            }
            for(ll k=0; k<Z; k++){
                if((i+1)*(j+1)*(k+1)>limit){
                  	//cout<<'%'<<endl;
                    break;
                }
                ABC.push_back(A[i]+B[j]+C[k]);
            }
        }
    }
    sort(ABC.begin(), ABC.end());
    reverse(ABC.begin(), ABC.end());
    for(ll i=0; i<limit; i++){
        cout<<ABC[i]<<endl;
    }
}





Measured memory_bytes: 1404
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int num;
	scanf("%d", &num);
	num *= 2;
	vector<int>v;
	for (int i = 0; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		v.push_back(z);
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	int ans = 0;
	for (int i = 1; i < num; i += 2)
	{
		ans += v[i];
	}
	printf("%d\n", ans);
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


int main(){
  int n, m;
  cin >> n >> m;
  UnionFind tree(n);
  
  for(int i=0; i<m; i++){
    int x, y, z;
    cin >> x >> y >> z;
    tree.unite(x-1, y-1);
  }
  
  set<int> se;
  for (int i = 0; i < n; ++i) se.insert(tree.root(i));
  cout << (int)se.size() << endl;
  
  return 0;
}

Measured memory_bytes: 8292
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    dp = [0 for j in range(N+1)]
    dp[0] = 1000
    for i in range(1, N+1):
        for j in range(i):
            dp[i] = max(dp[i], dp[j])
        for j in range(1, i):
            dp[i] = max(dp[i], dp[j] % A[j-1]+A[i-1]*(dp[j]//A[j-1]))
    ans = dp[N]
    print(ans)


if __name__ == "__main__":
    solve()

Measured memory_bytes: 67628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    private static FastReader fr = new FastReader();
    private static PrintWriter out=new PrintWriter(System.out);

    private static long MOD = 1000000007;

    private static long[][] dp;

    private static int[][] arr;

    private static long calculate(int men, int women, int n){
        if(men == n) return 1;
        if(dp[men][women] != -1) return dp[men][women];
        long ans = 0;
        for(int i = 0; i < n; i++){
            int bit = getBit(women, i);
            if(bit == 0 && arr[men][i] == 1){
                ans += calculate(men + 1, setBit(women, i), n);
                ans %= MOD;
            }
        }
        dp[men][women] = ans;
        return ans;
    }

    private static int getBit(int value, int position){
        return (value >> position) & 1;
    }

    private static int setBit(int value, int position){
        int filter = 1 << position;
        return value | filter;
    }

    public static void main(String[] args) throws IOException {
        long time = System.currentTimeMillis();
        StringBuilder sb = new StringBuilder();
        // code goes here
        int n = fr.nextInt();
        arr = new int[n][n];
        for(int i = 0; i < n; i++){
            arr[i] = fr.nextIntArray(n);
        }
        dp = new long[n][1 << (n + 1)];
        for(int i = 0; i < n; i++){
            Arrays.fill(dp[i], -1);
        }
        sb.append(calculate(0, 0, n));
        System.out.print(sb.toString());
    }

    static class FastReader{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");

        public String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

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

        public int[] nextIntArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long[] nextLongArray(int n) {
            long[] a=new long[n];
            for (int i=0; i<n; i++) a[i]=nextLong();
            return a;
        }
    }

    static class Pair<A, B>{
        A first;
        B second;
        public Pair(A first, B second){
            this.first = first;
            this.second = second;
        }
    }
}


Measured memory_bytes: 791288
X,K,D= map(int,input().split())
X = abs(X)
X2 = X
I = 0
K2 = X//D
if X == 0:
    if K%2 ==0:
        print(0)
    else:
        print(D)
elif K <= K2:
    print(X - K*D)
else:
    X = X - K2*D
    for i in range(K2,K+1):
        X -= D
        X2 = X
        if X <= 0:
            X += D
            I = i
            break
    if (K-I)%2 == 0:
        print(abs(X))
    else:
        print(abs(X2))

Measured memory_bytes: 9200
H, W, K = map(int, input().split())
G = [list(input()) for _ in range(H)]
ans = 0
for rows in range(2**H):
    for cols in range(2**W):
        black = 0
        for i in range(H):
            if rows >> i & 1:
                continue
            for j in range(W):
                if cols >> j & 1:
                    continue
                if G[i][j] == '#':
                    black += 1
        if black == K:
            ans += 1
print(ans)

Measured memory_bytes: 9204
#include <iostream>
#include <queue>

int main()
{
	std::queue<int> x;
	int n;

	while (1)
	{
		std::cin >> n;

		if (n == 0)
		{
			break;
		}

		x.push(n);
	}

	n = 0;

	while (!x.empty())
	{
		std::cout << "Case " << ++n << ": " << x.front() << std::endl;
		x.pop();
	}

	return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int m, n;
        cin >> m >> n;
        if(m == 0)
            return 0;

        list<int> rest;
        for(int i=1; i<=m; ++i)
            rest.push_back(i);

        list<int>::iterator it = rest.begin();
        for(int i=1; i<=n; ++i){
            string s;
            cin >> s;
            bool ng = false;
            if(i % 3 == 0 && i % 5 == 0){
                if(s != "FizzBuzz")
                    ng = true;
            }else if(i % 3 == 0){
                if(s != "Fizz")
                    ng = true;
            }else if(i % 5 == 0){
                if(s != "Buzz")
                    ng = true;
            }else{
                ostringstream oss;
                oss << i;
                if(s != oss.str())
                    ng = true;
            }

            if(ng && rest.size() > 1)
                it = rest.erase(it);
            else
                ++ it;
            if(it == rest.end())
                it = rest.begin();
        }

        cout << (*rest.begin());
        for(it=++rest.begin(); it!=rest.end(); ++it)
            cout << ' ' << (*it);
        cout << endl;
    }
}

Measured memory_bytes: 0
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		long ans;
		if(K % 2 == 1)
			ans = (long)Math.pow(N/K, 3);
		else if(2*N/K % 2 == 1)
			ans = (long)(Math.pow(N/K, 3) + Math.pow(N/K+1, 3));
		else
			ans = (long)Math.pow(N/K, 3) * 2;
		System.out.println(ans);
	}

}

Measured memory_bytes: 22868
n, m, x = map(int, input().split())
l = []
for i in range(n):
    a = list(map(int, input().split()))
    l.append(a)
ans = []
for i in range(2**len(l)):
    l2 = []
    for j in range(len(l)):
        if (i >> j) & 1 == 1:
            l2.append(l[j])
    #print(l2)
    s = [0] * (m + 1)
    for j in range(len(l2)):
        for k in range(m + 1):
            s[k] += l2[j][k]
    ans.append(s)
min = float("INF")
for i in range(2 ** len(l)):
    c = 0
    for j in range(1, m + 1):
        if ans[i][j] >= x:
            c += 1
    if c == m and min > ans[i][0]:
        min = ans[i][0]
print(-1 if min == float("INF") else min)

Measured memory_bytes: 11100
#include <bits/stdc++.h>
using namespace std;
//素因数分解
vector<pair<long,long>> factorization(long n){
    vector<pair<long,long>> res;
    for(long p=2;p*p<=n;p++){
        if(n%p != 0) continue;
        int num=0;
        while(n%p==0){
            num++;
            n /= p;
        }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main(){
    long n;cin>>n;
    auto factlist = factorization(n);
    long res=0;
    for (auto p : factlist) {
        long e = p.second;
        long tmp = 0, cur = 1;
        while (e >= cur){
            e-=cur;
            cur++;
            tmp++;
        }
        res += tmp;
    }
    cout << res << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision


#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

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

struct ModInt {
	ModInt(ll n) : mInt(n) {};
	//~ModInt(){};
	ll mInt;
	static ll mMod;
	//todo
	ModInt& operator=(const ModInt& a) { mInt = a.mInt; return *this; }
	ModInt& operator+=(const ModInt& a) { mInt += a.mInt; mInt %= mMod; return *this; }
	ModInt& operator-=(const ModInt& a) { mInt -= a.mInt; if (mInt < 0) mInt += mMod; return *this; }
	ModInt& operator*=(const ModInt& a) { mInt *= a.mInt; mInt %= mMod; return *this; }
	ModInt operator+(const ModInt a) { return ModInt(mInt + a.mInt % mMod); }
	ModInt operator-(const ModInt a) { return ModInt(mInt - a.mInt < 0 ? mInt - a.mInt + mMod : mInt - a.mInt); }
	ModInt operator*(const ModInt a) { return ModInt(mInt * a.mInt % mMod); }
  friend ostream& operator<<(ostream& os, const ModInt& n) {
		os << n.mInt;
		return os;
	}
	void setMod(ll mod) {
		ModInt::mMod = mod;
	}
};



ll ModInt::mMod = MOD;

ModInt pow(ModInt a, int b) {
	ModInt pow = 1;
	while (b > 0) {
		if (b & 1) pow = pow * a;
		a = a * a;
		b >>= 1;
	}
	return pow;
}

ModInt inv(ModInt n) {
	return pow(n, n.mMod - 2);
}

ModInt fact(int n) {
	ModInt fac = 1;
	for (int i = n; i > 0; --i) fac *= i;
	return fac;
}

ModInt comb(ll n, ll r) {
	ModInt com = 1;
	if (n / 2 < r) return comb(n, n - r);
	else {
		for (int i = 0; i < r; ++i)
			com *= n - i;
		return com * inv(fact(r));
	}
}

map<ll, ll> primeFactor(ll n) {
	map<ll, ll> ret;

  for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			n /= i;
			ret[i]++;
		}
	}

	if (n != 1) ret.insert({ n,1 });

	return ret;
}

int main() {
	int n, m;
	cin >> n >> m;
  
	map<ll,ll> mp;
	mp = primeFactor(m);

	ModInt ans(1);
	for (auto pe : mp) {
		ans *= comb(n-1+pe.second, pe.second);
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin>>a>>b>>c;
  int count=0;
  while(true){
    if(count>500000000){
      count=-1;
      break;
    }
    if(a%2!=0 || b%2!=0 || c%2!=0){
      break;
    }
    count++;
    int x=a,y=b,z=c;
    a=(y/2)+(z/2);
    b=(x/2)+(z/2);
    c=(x/2)+(y/2);
  }
  cout<<count<<'\n';
  return(0);
}

Measured memory_bytes: 256
package main

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

const mod = 1000000007

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func dfs(k,pre,now int, fac,facp []int, g [][]int) int {
	num := k-2
	par := len(g[now])-1
	if now == 0 {
		num = k-1
		par++
	}

	if num < par {
		return 0
	}

	val := perm(num,par,fac,facp)
	
	for _, e := range g[now] {
		if pre == e {
			par--
			continue
		}

		val = val*dfs(k,now,e, fac,facp,g)%mod
	}

	return val
}

func mpow(x,n int) int {
	a := 1
	for ;; {
		if n&1 == 1 {
			a = a*x %mod
		}
		x = x*x %mod
		n = n >> 1
		if n == 0 {
			break
		}
	}
	return a
}

func perm(a,b int, fac,facp []int) int {
	if a == 0 && b == 0 {
		return 1
	}
	return fac[a]*facp[a-b]%mod
}



func main() {
	sc.Split(bufio.ScanWords)
	n := scanInt()
	k := scanInt()

	g := make([][]int,n)

	for i := 0; i < n-1; i++ {
		a,b := scanInt()-1,scanInt()-1
		g[a] = append(g[a],b)
		g[b] = append(g[b],a)
	}

	fac := make([]int,k+1)
	facp := make([]int,k+1)
	fac[0] = 1
	facp[0] = 1
	for i := 0; i < k; i++ {
		fac[i+1] = fac[i]*(i+1)%mod
		facp[i+1] = facp[i]*mpow(i+1,mod-2) %mod
	}

	fmt.Println(k*dfs(k,0,0,fac,facp,g)%mod)
	
}


Measured memory_bytes: 57856
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std;

int a1,a2,a3,b1,b2,b3,d[10];

int main(){
	scanf("%d%d%d%d%d%d",&a1,&b1,&a2,&b2,&a3,&b3);
	d[a1]++; d[a2]++; d[a3]++;
	d[b1]++; d[b2]++; d[b3]++;
	int s=0;
	rep(i,1,4) if (d[i]==1) s++;
	int s2=0;
	rep(i,1,4) if (d[i]==2) s2++;
	if (s==2 && s2==2) puts("YES"); else puts("NO");
	return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)
typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;


int main() {

    int x;
    cin >> x;

    if (x == 7 || x == 5 || x == 3) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }


}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll N, a[212345];

int main() {

	cin >> N;
	rep(i, N) cin >> a[i];

	ll xored = 0;
	rep(i, N) xored ^= a[i];

	rep(i, N) cout << (xored ^ a[i]) << " ";
	cout << endl;

	return 0;
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    string o,e;cin >> o >> e;
    int n = o.size();
    int m = e.size();
    rep(i,n+m){
        if(i%2 == 0)cout<<o[i/2];
        else cout <<e[i/2];
    }
    cout << endl;
}

Measured memory_bytes: 256
/// Thank you tanakh!!!
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::cmp;

fn main() {
    input!(a: usize, b: usize, c: usize);

    let mut v = vec![a, b, c];
    v.sort();
    let ans = v[2] * 10 + v[1] + v[0];
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    cout << k * (ll)pow(k-1, n-1) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
    int L,N;
    cin>>N>>L;
    int p=(N*(L-1))+(N*(N+1))/2;
    int k;
    if(L>=1){
        k=p-(L);
    }
    if((L<1)&&(abs(L)<N)){
        k=p;
        
    }
    if((L<1)&&(abs(L)>=N)){
        k=p-(L+N-1);
    }
    cout<<k;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))

sort_a = sorted(a, reverse=True)

cnt = 0
Alice = 0
Bob = 0
for i in sort_a:
    if cnt % 2 == 0:
        Alice += i
    else:
        Bob += i
    cnt += 1

print(Alice - Bob)

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

int main()
{
	int N;
	char s[101];
	int i, a = 0, b = 0;
	scanf("%d", &N);
	scanf("%s", s);
	for (i = 0;i < N;i++)
	{
		if (s[i] == 'R')a++;
		else b++;
	}
	if (a > b)printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    from collections import Counter
    c = Counter(A)
    even = len([v for v in c.values() if v % 2 == 0])
    ans = len(c.keys())
    if even % 2 == 1:
        ans -= 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62124
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define ff first
#define ss second
#define p pair<ll,ll>
#define pb push_back
#define endl '\n'
#define w(t) ll test;cin>>test;while(test--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define iof  freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define pi acos(-1)
int fx[]={0,0,1,-1,1,1,-1,-1};
int fy[]={1,-1,0,0,-1,1,-1,1};
const int mxn=1e5+7;

int main()
{
    fast;
    int x;
    cin>>x;
    cout<<(x?0:1)<<endl;
}



Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N, P; cin >> N >> P;
	vector<int>vec(N);
	rep(i, 0, N)cin >> vec[i];
	int cnt = 0;
	rep(i, 0, N) {
		if (vec[i] % 2 == 1)++cnt;
	}
	if (P == 0) {
		if (cnt == 0)cout << (ll)pow(2LL, N);
		else cout << (ll)pow(2LL, N - 1);
	}
	else {
		if (cnt == 0)cout << 0 << "\n";
		else cout << (ll)pow(2LL, N - 1);
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstring>
#include <string>
#define rep(i,n) for(int i = 0;i< (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

//struct Point {
//	int x,y;
//};
//long long ccw(const Point& A, const Point& B, const Point& C) { // 시계방향이면 음수 
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}

int main() { // 골드 1, 플레 1
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	string s; cin >> s;
	rep(i, (int)s.size()) {
		if (i & 1) {
			if (s[i] == 'R') {
				cout << "No" << '\n'; return 0;
			}
		}
		else {
			if (s[i] == 'L') {
				cout << "No" << '\n'; return 0;
			}

		}
	}
	cout << "Yes" << '\n';






}

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

int main(){
    long long n, i, sum = 0;
    cin >> n;
    for(i = 0; i <= n; i++){
        if((i % 3 != 0) && (i % 5 != 0)){
            sum += i;
            //cout << i << endl;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3676
from collections import Counter

n = int(input())
k_list = [int(w) for w in input().split()]
c = Counter(k_list)


max_pat = 0
for n in c.values():
    max_pat += (n * (n - 1)) // 2

for i in k_list:
    cnt = c[i]
    tmp = max_pat

    if cnt >= 2:
        tmp -= (cnt * (cnt - 1)) // 2
        tmp += ((cnt - 1) * (cnt - 2)) // 2

    print(tmp)


Measured memory_bytes: 26772
#include<stdio.h>

int main(){
  int i, j, n, a[128], ans=0, min, t;

  scanf("%d", &n);

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

  for(i=0; i<n-1; i++){
    min=i;
    for(j=i+1; j<n; j++){
      if(a[min]>a[j]){
	min=j;
      }
    }
    if(min!=i){
      t=a[min];
      a[min]=a[i];
      a[i]=t;
      ans++;
    }   
  }

  for(i=0; i<n; i++){
    if(i==n-1){
      printf("%d\n", a[i]);
    }else{
      printf("%d ", a[i]);
    }
  }
  printf("%d\n", ans);
  
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,ans;
signed main()
{
	cin>>n;
	for(int i=1;i*i<=n;i++)
	{
		if(n%i!=0) continue;
		int b=i-1,c=n/i;
		if(b>c)
			ans+=b;
		b=n/i-1;
		c=i;
		if(b>c)
			ans+=b;
	}
	cout<<ans<<endl;
	return 0;
}


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

#define loop(v, f, l) for(int v = (f), v##_ = (l); v < v##_; ++v)

using namespace std;

typedef long long int lint;
static inline int in(){ int x; scanf("%d", &x); return (x); }
static inline lint inl(){ lint x; scanf("%lld", &x); return (x); }

int matrix[11][11];

int main()
{
	int n;

	while( (n = in()) != 0 )
	{
		loop(i, 0, 11)
		{
			loop(j, 0, 11)
			{
				matrix[i][j] = 0;
			}
		}

		loop(i, 0, n)
		{
			loop(j, 0, n)
			{
				matrix[i][j] = in();
			}
		}
		
		loop(i, 0, n)
		{
			loop(j, 0, n)
			{
				matrix[i][n] += matrix[i][j];
				matrix[n][i] += matrix[j][i];
			}
			matrix[n][n] += matrix[i][n];
		}
		
		loop(i, 0, n + 1)
		{
			loop(j, 0, n + 1)
			{
				printf("%5d", matrix[i][j]);
			}
			printf("\n");
		}
		
	}

	return (0);
}

Measured memory_bytes: 1204
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		int sum = 0;
		//???????????????
		int c = sc.nextInt();
		//?¨?????????????
		int r = sc.nextInt();
		//???????????£?¨? ?¨???????????¨? ??¨??????????¨? ??????????????????????????????1??????
		int [][] list = new  int [c+1][r+1];
		//?????????????´? ??????
		for(int i = 0; i < c; i++){
			//?????????????´? ?¨????
			for(int j = 0; j< r; j++){
				list[i][j] = sc.nextInt();
			}
		}
		//
		for(int i = 0; i< c; i++){
			for(int j =0; j< r;j++){
				list[i][r]  += list[i][j]; //??? ????¨????
				list[c][j] += list[i][j]; //??? ????¨????
				list[c][r] += list[i][j]; //???????? ????¨????
			}
		}
		//??¨?????????
		for(int i = 0;i<=c;i++){
			//System.out.print(list[i][0] + " ");
			for(int j =0; j<=r;j++){
				if(j == r){
					System.out.print(list[i][j]);
				}else{
					System.out.print(list[i][j] + " ");
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 42256
from functools import lru_cache

digits = list(map(lambda x: str(x),range(1,10)))

@lru_cache(maxsize=None) 
def check(s,n):  
    return ' '.join([s]*n)

def down(x):
    x = list(x[::-1])   
    while '0' in x:
        x.remove('0')
        x.append('#')
    return x

def main(n):
    data = '\n'.join(map(lambda x: input(), range(n)))  
    score = 0
    while True:
        removed = False
        for d in digits:
            if check(d, 3) in data:
                for i in range(5, 2, -1):
                    if check(d, i) in data:
                        score += int(d) * (data.count(check(d, i))*i)
                        data = data.replace(check(d, i), check('0', i))
                        removed = True
        if removed == False:
            break
        data = zip(*map(lambda x: x.split(), data.split('\n')))
        data = map(lambda x: down(x), data)
        data = list(map(lambda x: ' '.join(x),zip(*data)))
        data = '\n'.join(data[::-1])
    print(score) 


while True:
    n = int(input())
    if n == 0: break
    main(n)



Measured memory_bytes: 6448
from sys import stdin

n,h,w = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]
point = 0
for i in li:
    if i[0] >= h and i[1] >= w:
        point += 1
print(point)

Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.function.LongSupplier;

public class Main{ // 

	static class ConsoleScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			try {
				while (!st.hasMoreElements())
					st = new StringTokenizer(br.readLine());
				return st.nextToken();
			} catch (IOException e) {
				throw new AssertionError(e);
			}
		}

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

		long nextLong() {
			return Long.parseLong(next());
		}
	}

	static LongSupplier now = new LongSupplier() {
		private long t = System.currentTimeMillis();

		@Override
		public long getAsLong() {
			long a = t;
			t = System.currentTimeMillis();
			long ans = t - a;
			return ans;
		}
	};

	public static void main(String args[]) {
		ConsoleScanner cin = new ConsoleScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	static int tr(Object... objects) {
		System.out.println("tr:" + Arrays.deepToString(objects));
		return 0;
	}

	private static void solve(ConsoleScanner cin, PrintWriter cout) {
		// assert solve(1) == 1;

		int a = cin.nextInt();
		int b = cin.nextInt();
		int c = cin.nextInt();
		int d = cin.nextInt();
		int e = cin.nextInt();
		int f = cin.nextInt();

		now.getAsLong();

		String ans = solve(a, b, c, d, e, f);
		cout.println(ans);

		assert 0 == tr("elapsed", now.getAsLong());
	}

	private static String solve(int a, int b, int c, int d, int e, int f) {
		int[] ans = { 100 * a, 0 };
		double max = 0;
		for (int i = 0; 100 * i * b <= f; i++)
			for (int j = 0; 100 * (i * b + j * a) <= f; j++) {
				if (i + j == 0)
					continue;

				int w100 = i * b + j * a;

				for (int s = 0; 100 * w100 + s * d <= f; s++)
					for (int t = 0; 100 * w100 + s * d + t * c <= f; t++) {
						int sug = s * d + t * c;
						if (w100 * e < sug)
							break;
						double dens = sug / (100.0 * w100 + sug);
						if (max < dens) {
							max = dens;
							ans = new int[] { 100 * w100 + sug, sug };
						}
					}
			}

		return ans[0] + " " + ans[1];
	}

}


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

using namespace std;

int main()
{
  int N, M;
  while(cin >> N >> M, N || M){
    int D[10001] = {0}, P[10001] = {0};
    long long sum = 0;
    for(int i = 0; i < N; i++) cin >> D[i] >> P[i], sum += D[i]*P[i];
    while(M > 0){
      int idx = max_element(P, P + N)  - P;
      if(P[idx] == -1) break;
      sum -= min(M, D[idx])*P[idx];
      M -= D[idx];
      P[idx] = -1;
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 1240
import numpy as np
N = int(input())
A = list(map(int, input().split()))
A.sort()
A = np.array(A)
B = list(map(int, input().split()))
B.sort()
B = np.array(B)
C = list(map(int, input().split()))
C.sort()
C = np.array(C)

ans = 0
for i in range(N):
	b = B[i]
	a_ind = np.searchsorted(A,b,side='left')
	c_ind = np.searchsorted(C,b,side='right')
	ans += a_ind * (N-c_ind)

print(ans)

Measured memory_bytes: 24836
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<map>
using namespace std;
#define ll long long
int main(){
	int R;
	cin >> R;
    if(R<1200){
    	cout << "ABC";
    }else if (R<2800){
    	cout << "ARC";
    }else {
    	cout << "AGC";
    }
    return 0;
}


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

int main(){
    int N, M;
    cin >> N >> M;
    int a[100];

    for (int i = 0; i < N; i++){ cin >> a[i]; }

    for (int k = 1; k <= M; k++){
        for (int i = 0; i < N-1; i++){
            if (a[i]%k > a[i+1]%k) {
                swap(a[i], a[i+1]);
            }
        }
    }
    
    for (int i = 0; i < N; i++){ cout << a[i] << endl; }
}


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

int main() {
    long long int  N;
    long long int RED,BLUE;
    long long int count;

    scanf("%lld %lld %lld",&N,&RED,&BLUE);
    count = N /(RED+BLUE) ;
    if(N % (RED +BLUE) >=RED){
        printf("%lld",count*RED +RED);
    }
    else{
        printf("%lld",count*RED + (N%(RED +BLUE)) );
    }
    return 0;
}

int A(){
    char S[3];
    scanf("%s",&S);
    if(S[0] != S[1] || S[0] != S[2] || S[1] != S[2]){
        printf("Yes");
    }
    else{
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 128
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


int main(void){
    string s;
    cin >> s;

    int ans = 1e9;
    for(int i = 0; i < s.size() - 2; i++){
        int tmp = atoi(s.substr(i, 3).c_str());
        ans = min(ans, abs(753 - tmp));
   }

   cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
static const int N = 1000;

int lcs(string X, string Y)
{
  int c[N + 1][N + 1];
  int m = X.size();
  int n = Y.size();
  int maxl = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  for (int i = 0; i <= m; i++)
    c[i][0] = 0;
  for (int j = 1; j <= n; j++)
    c[0][j] = 0;

  for (int i = 1; i <= m; i++)
  {
    for (int j = 1; j <= n; j++)
    {
      if (X[i] == Y[j])
      {
        c[i][j] = c[i - 1][j - 1] + 1;
      }
      else
      {
        c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      }
      maxl = max(maxl, c[i][j]);
    }
  }
  return maxl;
}

int main()
{
  string s1, s2;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> s1 >> s2;
    cout << lcs(s1, s2) << endl;
  }
  return 0;
}


Measured memory_bytes: 7100
#include<iostream>
#include<algorithm>
#include<math.h>
#include<stack>
#include<map>
#include<vector>
#include<utility>
#include<string>
#define inf (1<<30)
#define MAX 1000000007
using namespace std;
typedef long long ll;

int N;
ll T;
ll mina=inf;
int main(void)
{
  cin >> N >> T;
  vector<ll> A(N,0);
  for(int i=0;i<N;i++)
    {
      cin >> A[i];
    }
  vector<ll> B(N,0);
  vector<ll> tmp(1,inf);
  for(int i=0;i<N;i++)
    {
      if(A[i]<mina) mina=A[i];
      B[i]=A[i]-mina;
      tmp.push_back(A[i]);
    }
  sort(B.begin(),B.end());
  reverse(B.begin(),B.end());
  int ans=count(B.begin(),B.end(),*std::max_element(B.begin(),B.end()));
  cout << ans << endl;
  return 0;
  
}


Measured memory_bytes: 2936
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();

        long factorialCount = 0;
        boolean isDividable = true;
        while (isDividable) {
            h = h / 2;
            factorialCount += 1;
            if (h == 0) isDividable = false;
        }

        long ans = 1;
        int count = 0;
        while (count < factorialCount) {
            ans *= 2;
            count++;
        }

        System.out.println(ans - 1);
    }
}

Measured memory_bytes: 22100
from collections import defaultdict
inf = 10**10
A = list(map(lambda x:ord(x)-ord('a'), list(input())))
N = len(A)
abc = 'abcdefghijklmbopqrstuvwxyz'
s_to_i = [[N]*26 for _ in range(N+1)]
for i in range(N)[::-1]:
    for x in range(26):
        s_to_i[i][x] = s_to_i[i+1][x]
    s_to_i[i][A[i]] = i
dp = [0]*(N+2)
dp[-2] = 1
for i in range(N)[::-1]:
    now = max(s_to_i[i])+1
    dp[i] = dp[now]+1
n = dp[0]
now = 0
ans = []
for i in range(n):
    for x in range(26):
        tmp = s_to_i[now][x]+1
        if dp[tmp] <= n-i-1:
            ans.append(chr(x+ord('a')))
            now = tmp
            break
print(*ans, sep = '')



    
        





Measured memory_bytes: 78456
N,K,Q = map(int,input().split())
B = [0 for i in range(N)]

for i in range(Q):
  a = int(input())-1
  B[a] += 1
  
for b in B:
  if K-Q+b <= 0:
    print("No")
  else:
    print("Yes")
    

Measured memory_bytes: 4644
N=int(input())
A=[0]+list(map(int,input().split()))
A.append(0)

S=[0]*(N+2)
for i in range(N+1):
    S[i+1]=abs(A[i+1]-A[i])+S[i]

for i in range(N):
    ans=S[-1]-abs(A[i+1]-A[i])-abs(A[i+2]-A[i+1])+abs(A[i+2]-A[i])
    print(ans)





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

int main()
{
    unordered_map<string, int> mp;
    int n;
    cin >> n;
    string s;
    rep(i, n) {
        cin >> s;
        mp[s]++;
    }
    int m;
    cin >> m;
    string t;
    rep(i, m) {
        cin >> t;
        mp[t]--;
    }
    int ans = 0;
    for (auto p : mp) {
        ans = max(ans, p.second);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define hell 1000000007
#define int long long int

using namespace std;

void solve(){
    int n;
    cin>>n;
    vector <int> a(1000000,0);
    int sum=0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        sum+=x;
        a[x]++;
    }
    int q;
    cin>>q;
    while(q--){
        int b,c;
        cin>>b>>c;
        sum=sum-b*a[b]+a[b]*c;
        a[c]+=a[b];
        a[b]=0;
        cout<<sum<<"\n";
    }
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 11116
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define rep(i,a,b) for(i=a;i<b;i++)
#define tr(container,it)   for(auto it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mod 998244353
#define fs first
#define sc second
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
void solve()
{
  int n,i,j;
  cin>>n;
  map<string,int>m;
  for(i=0;i<n;i++)
  {
    string s;
    cin>>s;
    m[s]++;
  }
  cout<<"AC x "<<m["AC"]<<"\n";
  cout<<"WA x "<<m["WA"]<<"\n";
  cout<<"TLE x "<<m["TLE"]<<"\n";
  cout<<"RE x "<<m["RE"]<<"\n";
}
signed main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t;
  t=1;
  //cin>>t;
  while(t--)
  solve();
  TIME
  return 0;
}

Measured memory_bytes: 3816
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		int n[]=new int[10];
		boolean m[]=new boolean[10];
		int i,j,x,k=2,tmp;
		
		n[0]=1;
		for(i=1;i<10;i++){
			n[i]=k;
			k=2*k;
		}
		
		while(s.hasNext()){
			Arrays.fill(m, false);
			x=s.nextInt();
			tmp=x;
			for(i=i-1;i>=0;i--){
				if(tmp>=n[i]){
					m[i]=true;
					tmp-=n[i];
				}
			}
			boolean f=true;
			for(i=0;i<10;i++){
				if(m[i]){
					if(!f){
						System.out.print(" ");
					}
					f=false;
					System.out.print(n[i]);
				}
			}
			System.out.println();
		}
	}

}

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

// clang-format on
void answer() {
  ll a, b;
  cin >> a >> b;
  if (a == b) {
    cout << 2 * (a - 1) << '\n';
    return;
  }
  if (a > b) swap(a, b);
  ll l = 0, r = b - a + 1;
  while (l + 1 < r) {
    ll x = (l + r) / 2;
    if ((a + x / 2) * (a + (x + 1) / 2) < a * b)
      l = x;
    else
      r = x;
  }
  cout << 2 * (a - 1) + l << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int q;
  cin >> q;
  rep(_, q) answer();
  return 0;
}

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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int n,a,b,c;
vector<int> v;

main() {
    cin >> n;
    rep(i,n) {
        cin >> c;
        v.pb(c);
    }
    sort(rall(v));
    rep(i,v.size()) {
        if(i%2) b+=v[i];
        else a+=v[i];
    }
    ct(a-b)
}

Measured memory_bytes: 256