akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		for(int j = 0; j < n; j++) {
			double[] x = new double[4];
			double[] y = new double[4];
			for(int i = 0; i < 4; i++) {
				x[i] = sc.nextDouble() * 10000;
				y[i] = sc.nextDouble() * 10000;
			}
			Vec AB = new Vec(x[1] - x[0], y[1] - y[0]);
			Vec CD = new Vec(x[3] - x[2], y[3] - y[2]);
			if(AB.x * CD.y - AB.y * CD.x == 0.0) {
				sb.append("YES").append("\n");
			}else {
				sb.append("NO").append("\n");
			}
		}
		sc.close();
		System.out.print(sb.toString());
	}
	static class Vec{
		double x, y;
		Vec(double x, double y) {
			this.x = x;
			this.y = y;
		}
	}
}


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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

const ll mod = 1000000007;
int dist[1009][1009];

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int N, X, Y;
    cin >> N >> X >> Y;
   	VI cnt(N + 3, 0);
    FOR(i, 1, N - 1) {
    	FOR(j, i + 1, N) {
    		int d = INT_MAX;
    		// int dd = abs(X - i) + min(abs(j - X), abs(Y - j) + 1); 
    		int dd = abs(X - i) + abs(Y - j) + 1; 
    		d = min(dd, d);
    		d = min(j - i, d);
    		cnt[d]++;
    	}
    }
    FOR(i, 1, N - 1) {
    	cout << cnt[i] << "\n";
    }
    // FOR(dist, 1, N - 1) {
    // 	int ans = 0;
    // 	FOR(i, 1, N - 1) {
    // 		if (i + dist <= N) {
	   //  		if (i <= X) {
	   //  			if (i + dist < Y) {
	   //  				ans++;
	   //  			}
	   //  			if (i + dist > X && i + dist + Y - X - 1 >= Y && i + dist + Y - X - 1 <= N) {
	   //  				ans++;
	   //  			}
	   //  		} else {
	   //  			ans++;
	   //  		}
    // 		}
    // 	}
    // 	cout << ans << "\n";
    // }

}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;
using namespace std;


int main() {
    string s = "";
    cin >> s;
    vector<bool> check(26, false);
    for (char c : s) {
        check.at(c-'a') = true;
    }
    for (int i=0; i<26; i++) {
        if (!check.at(i)) {
            cout << s + (char)('a'+i) << endl;
            return 0;
        }
    }
    string ret = "";
    for (int i=24; i>=0; i--) {
        if (s.at(i) > s.at(i+1)) {
            continue;
        }
        else {
            for (int j=0; j<i; j++) {
                ret += s.at(j);
            }
            int now = 25;
            while (true) {
                if (s.at(now) > s.at(i)) {
                    ret += s.at(now);
                    cout << ret << endl;
                    return 0;
                }
                now--;
            }
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(int i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(int i=(a);i<(n);i++)cout<<(arr)[i]<<' ';

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}

int main(){
	fast;
	ll n;
	cin>>n;
	ll a[n], ans = 0;
	cin>>a[0];
	ans = a[0];
	forn(i, 1, n){
		cin>>a[i];
		ans = __gcd(ans, a[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4428
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>


int main() {
    const int nn = 100000;
    int n;
    std::cin >> n;
    std::vector<std::pair<int, int>> a0(nn+1), a1(nn+1);
    for (int i = 0; i <= nn; i++) {
        a0[i] = {0, i};
        a1[i] = {0, i};
    }
    for (int i = 0; i*2 < n; i++) {
        int a, b;
        std::cin >> a >> b;
        a0[a].first++;
        a1[b].first++;
    }

    std::sort(a0.begin(), a0.end(), std::greater<std::pair<int, int>>());
    std::sort(a1.begin(), a1.end(), std::greater<std::pair<int, int>>());

    int ans = n;
    if (a0[0].second != a1[0].second) {
        ans -= (a0[0].first + a1[0].first);
    } else {
        int x0 = a0[0].first + a1[1].first;
        int x1 = a1[0].first + a0[1].first;
        ans -= x0 > x1 ? x0 : x1;
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <map>

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    long long N; cin >> N;
    map<long long, int> map;

    rrep (i, 2, N) {
        int x = i;
        rrep (j, 2, x) {
            while (x % j == 0) {
                x /= j;
                map[j]++;
            }
        }
    }

    long long ans = 1;
    for (auto mp : map) {
        ans = ((ans % MOD) * (mp.second+1)%MOD) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
K = int(input())

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

gcd_table = [[0] * (K+1) for i in range(K+1)]
for i in range(1, K+1):
    for j in range(i, K+1):
        g = gcd(i, j)
        gcd_table[i][j] = gcd_table[j][i] = g


ans = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            g1 = gcd_table[a][b]
            g2 = gcd_table[g1][c]
            ans += g2

print(ans)

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

typedef vector <int> vi;

#define trav(a, A) for (auto & a : A)

const int INF = 1e9;

int main ()
{
    ios_base::sync_with_stdio (0);
    cin.tie (0);
    int i, j, n;
    cin >> n;
    vi dp (n, INF), cost (n);
    trav (a, cost)
        cin >> a;
    dp[0] = 0;
    for (i = 1; i < n; ++i)
        for (j = 1; j <= 2 && i - j >= 0; ++j)
            dp[i] = min (dp[i], dp[i - j] + abs (cost[i - j] - cost[i]));
    cout << dp[n - 1] << '\n';

    return 0;
}


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int w = tx - sx, h = ty - sy;

    // Path 1
    cout << string(w, 'R') << string(h, 'U');

    // Path 2
    cout << string(w, 'L') << string(h, 'D');

    // Path 3
    cout << 'D' << string(w+1, 'R') << string(h+1, 'U') << 'L';

    // Path 4
    cout << 'U' << string(w+1, 'L') << string(h+1, 'D') << 'R';

    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main()
{
	string s;

	cin >> s;

	for (size_t i = 0; i < s.length(); i++)
	{
		if (i % 2 == 0)
		{
			cout << s[i];
		}
	}
	
	cout << endl;

	return 0; 
}

Measured memory_bytes: 576
import java.util.*;
import java.io.*;
import java.util.function.*;

class Main {
    static Scanner scanner = new Scanner();
    static int mod = 1000000007;
    static int inf = 0x7ffffff;

    void solve() {
        int n = scanner.nextInt();
        int t = scanner.nextInt();
        int[][] ab = new int[n][2];
        for (int i = 0; i < n; i++) {
            ab[i][0] = scanner.nextInt();
            ab[i][1] = scanner.nextInt();
        }
        Arrays.sort(ab, Comparator.comparingInt(array -> array[0]));
        int[][] dp1 = new int[6006][n + 1];
        int[][] dp2 = new int[6006][n + 1];
        for (int i = 1; i < 6006; i++) {
            for (int j = 0; j < n; j++) {
                if (0 <= i - ab[j][0]) {
                    dp1[i][j + 1] = dp2[i][j + 1] = dp2[i - ab[j][0]][j] + ab[j][1];
                }
            }
            for (int j = 1; j <= n; j++) {
                dp2[i][j] = Math.max(dp2[i][j - 1], dp2[i][j]);
            }
        }
        int max = 0;
        for (int i = 0; i < 6006; i++) {
            for (int j = 0; j < n; j++) {
                if (i - ab[j][0] < t) {
                    max = Math.max(max, dp1[i][j + 1]);
                }
            }
        }
        System.out.println(max);
    }

    public static void main(String[]$) throws Exception {
        new Main().solve();
        System.out.flush();
    }
}

class System {
    static PrintWriter out = new PrintWriter(java.lang.System.out);

    static void exit() {
        java.lang.System.exit(0);
    }
}

class Scanner {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(java.lang.System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

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

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

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

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

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

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

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}


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

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
constexpr int loose = 0;
constexpr int tight = 1;


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;
}

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
	ll n,z,w;
	cin>>n>>z>>w;
	Array a(n);
	REP(i,n) cin>>a[i];
	if(n>2) cout<<max(abs(w-a[n-1]),abs(a[n-2]-a[n-1]))<<en;
	if(n==1) cout<<abs(a[0]-w)<<en;
}

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

    solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 256
a,b,c=map(int,input().split())
p = max(a,b,c)
q = min(a,b,c)
r = a+b+c-(p+q)
x =(p-q)//2+(p-r)//2
q +=((p-q)//2)*2
r +=((p-r)//2)*2
if p == q and p == r:
        print(x)
elif p != q and p != r:
        print(x+1)
else:
        print(x+2)

Measured memory_bytes: 8968
#define _CRT_SECURE_NO_WARNINGS

#include <vector>
#include <iostream>
#include <string>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <ctime>
#include <queue>
#include <deque>
#include <math.h>
#include <cmath>
#include <stack>
#include <algorithm>
#include <list>
#include <array>
#include <valarray>
#include <unordered_map>
#include <cassert>
#include <random>
#include <cstring>

using namespace std;

typedef long long li;
typedef pair<int, int> pii;

#define X first
#define Y second
#define all(a) a.begin(), a.end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)

double eps = 1e-5;
const int INF = 1e9 + 7;
const li LINF = 9e18 + 7;


int main() {
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif

	int k;
	cin >> k;

	vector<li> a(k);
	forn(i, k)
		cin >> a[i];

	li low = 2, high = 2;
	for (int i = k - 1; i >= 0; --i) {
		low = (low + a[i] - 1) / a[i] * a[i];
		high = high / a[i] * a[i] + a[i] - 1;

		if (low > high) {
			cout << -1 << endl;
			return 0;
		}
	}

	li x = low;
	forn(i, k) {	
		x -= x % a[i];

		if (x < 2) {
			cout << -1 << endl;
			return 0;
		}
	}

	if (x != 2) {
		cout << -1 << endl;
		return 0;
	}

	cout << low << ' ' << high << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<queue>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<bitset>
#include<set>
#include<vector>
using namespace std;
const int maxn=501;
struct Edge
{
	int u,v,f,next;
}edge[maxn];
int head[maxn],ednum;
void add(int u,int v,int f)
{
	edge[ednum].u=u;
	edge[ednum].v=v;
	edge[ednum].f=f;
	edge[ednum].next=head[u];
	head[u]=ednum++;
}
int n,m,mp[maxn][maxn];
struct Bitset
{
	bitset<100> state;
	bool operator ==(const Bitset &p)const
	{
		for(int i=99;i>=0;--i)
			if(state[i]!=p.state[i])return false;
		return true;
	}
	bool operator <(const Bitset &p)const
	{
		for(int i=99;i>=0;--i)
			if(state[i]!=p.state[i])return state[i]<p.state[i];
	}
}tmp;
set<Bitset> vis;
queue<Bitset> q;
bool check(int u,Bitset a)
{
	for(int j=0;j<99;++j)if(a.state[j]&&!mp[u][j+1])return false;
	return true;
}
int ans;
int match(Bitset a)
{
	int j,k,res=0,tp;
	for(j=0;j<100;++j)
	{
		if(!a.state[j])continue;
		tp=1e9+100;
		for(k=0;k<100;++k)
		{
			if(j==k)continue;
			if(!a.state[k])continue;
			tp=min(tp,mp[j+1][k+1]);
		}
		if(tp!=1e9+100)res+=tp;
	}
	return res;
}
void bfs(int u)
{
	int i;
	Bitset now,tmp;
	now.state.reset();
	q.push(now);
	vis.insert(now);
	while(!q.empty())
	{
		now=q.front();
		q.pop();
		for(i=1;i<=100;++i)
		{
			if(now.state[i-1])continue;
			if(!check(i,now))continue;
			tmp=now;
			tmp.state[i-1]=1;
			if(vis.find(tmp)==vis.end())
			{
				vis.insert(tmp);
				ans=max(ans,match(tmp));
				q.push(tmp);
			}
		}
	}
}
int main()
{
	int i,j,u,v,f;
	scanf("%d%d",&n,&m);
	//n=100,m=0;
	memset(head,-1,sizeof(head));
	ednum=0;
	for(i=0;i<m;++i)
	{
		scanf("%d%d%d",&u,&v,&f);
		add(u,v,f);add(v,u,f);
		mp[u][v]=mp[v][u]=f;
	}
	ans=0;
	bfs(0);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3356
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<PII,PII> st;
const int maxn=100010;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
int n,a[maxn];
vector<ll> dp[20][20];
ll DP(int l,int r,int x,int y,int t){
	if(l+1==r) return 1ll*a[l]*x+1ll*a[r]*y;
	ll &d=dp[l][r][t];
	if(d) return d;
	ll s=1e18;
	FOR(i,l+1,r-1) s=min(s,DP(l,i,x,x+y,t<<1)+DP(i,r,x+y,y,t<<1|1)-1ll*a[i]*(x+y));
	return d=s;
}
int main(){
	n=read();
	FOR(i,1,n) a[i]=read();
	FOR(i,1,n) FOR(j,i+1,n) dp[i][j].resize(1<<(n-j+i));
	printf("%lld\n",DP(1,n,1,1,1));
}

Measured memory_bytes: 33280
#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;
typedef vector<string> vstring;
#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);
  string s;
  cin>>s;
  int count=0,fg=0,max=0;
  rep(i,(int)s.size()){
    if(s[i]=='R'){
      count++;
    }
    else{
      chmax(max,count);
      count=0;
    }
  }
  chmax(max,count);
  cout<<max<<'\n';
  return(0);
}


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

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

	rep(i,A-1){
	 if(S[i] != S[i+1])ans++;
 }
	cout << ans + 1 << endl;
}


Measured memory_bytes: 512
using System;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(null);
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            int add = A + B;
            int sub = A - B;
            int mul = A * B;
            int higher;

            if (add >= sub)
            {
                higher = add;
            }else
            {
                higher = sub;
            }

            if (mul > higher)
            {
                higher = mul;
            }

            Console.WriteLine(higher);
        }    
    }
}

Measured memory_bytes: 13140
import sys
import math
input = sys.stdin.readline

def multiples(n):
    for i in range(3,100003):
        yield i*n
        if i*n > 100003:
            break

def sosuu(x):
    if x == 2 : return 2
    d = set()
    end = math.ceil(math.sqrt(x))
    d = d.union(multiples(2))
    for i in range(3,end,2):
        if i not in d:
            d = d.union(set(multiples(i)))
    
    i = x if x % 2 != 0 else x+1
    while True:
        if i not in d:
            return i
        i += 2

def main():
    x = int(input())
    print(sosuu(x))

if __name__ == "__main__":
    main()

Measured memory_bytes: 14764
#define DEBUG
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
 
#define F first
#define S second 
#define pb push_back
#define endl "\n"

#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }

#ifdef DEBUG
    #define dbg(s) {s;}
#endif

#ifndef DEBUG
    #define dbg(s)
#endif

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int grand(int x) { // from [0, x-1]
    return uniform_int_distribution<int>(0, x - 1)(rng);
}

#define int ll
#define i32 int32_t

#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 

#define all(v) (v).begin(),(v).end()

typedef long long ll;
typedef long double ld;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;

int getInt () {
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}


ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
} 

const ll mod = 1e9 + 7;

ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % mod;
        ex >>= 1ll;
        x = (x * x) % mod;
    }
    return ans;
}

const int maxn = 1e6 + 7;

const ll inf = 1e9 + 7;

vector<int> nums[10];

i32 main() {
    //freopen("<file>.in", "r", stdin);
    //freopen("<file>.out", "w", stdout);

    IOS;
    int n;
    cin>>n;

    string s;
    cin>>s;

    for(int i=0;i<n;i++)
    {
        nums[s[i]-'0'].pb(i+1);
    }
    
    int ans = 0;
    int d1,d2,d3;
    
    int x;
    int fir,las,val;
    
    vector<int>::iterator ca;
    
    for(int i=0;i<1000;i++)
    {
        x = i;
        d1 = x%10;
        x/=10;
        d2 = x%10;
        x/=10;
        d3 = x%10;
        if(nums[d1].size()==0 || nums[d2].size()==0 || nums[d3].size()==0)
            continue;

        fir = nums[d3][0];
        las = nums[d1][nums[d1].size()-1];
        
        ca = upper_bound(all(nums[d2]),fir);
        if(ca==nums[d2].end() || *ca>=las)
            continue;
        ans++;
    }
    
    cout<<ans<<endl;
    
}





Measured memory_bytes: 768
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, X):
    if N % 2 == 0 and X == N//2:
        return 3*X
    ans = 0
    if X > N//2:
        X = N-X

    ans = X

    def f(n, x):
        # print(n, x)
        ans = 0
        ans += n
        n_x = n // x
        ans += 2*n_x*x - x
        if n % x != 0:
            ans += f(x, n - n_x*x)

        # print(n, x, n_x, 2*n_x*x - x, ans)
        return ans

    return ans + f(N-X, X)


def main():
    N, X = read_int_n()
    print(slv(N, X))

  

if __name__ == '__main__':
    main()


Measured memory_bytes: 59756
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
typedef long long ll;
ll n,c,x[N],w[N],val[N],rval[N],shun[N],ni[N];
int main()
{
    cin>>n>>c;
    for(int i=1;i<=n;i++)
    {
        cin>>x[i]>>w[i];
        val[i]=val[i-1]+w[i];//顺着到i的价值总和
        shun[i]=max(shun[i-1],val[i]-x[i]);//顺着到i取最大
    }
    for(int i=n;i>=1;i--)
    {
        rval[i]=rval[i+1]+w[i];//逆着到i的价值总和
        ni[i]=max(ni[i+1],rval[i]-c+x[i]);//逆着到i取最大
    }
    ll maxx=0;
    for(int i=n;i>=1;i--)
    {
        maxx=max(maxx,rval[i]-2*(c-x[i])+shun[i-1]);//先逆着到i，再顺着到i-1
        maxx=max(maxx,ni[i]);//只有逆
    }
    for(int i=1;i<=n;i++)
    {
        maxx=max(maxx,val[i]-2*x[i]+ni[i+1]);//先顺着到i，再逆着到i+1
        maxx=max(maxx,shun[i]);//只有顺
    }
    cout<<maxx;
    return 0;
}

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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  int L = A+B, R = C+D;
  if (L > R){
    cout << "Left" << endl; 
  }
  
  if (L == R){
    cout << "Balanced" << endl;
  }

  if (L < R){
    cout << "Right" << endl;
  }

}

Measured memory_bytes: 256
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
using namespace std;
ll read()
{
	char c=getchar(); ll s=0;
	while(c<'0'|| c>'9')	c=getchar();
	while(c>='0'&&c<='9')	s=s*10+c-'0',c=getchar();
	return s;
}
int main()
{
	ll a=read(),b=read(),c=read(),k=read();
	if(k%2==0)	printf("%lld\n",a-b);
	else	printf("%lld\n",b-a);
	return 0;
}


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

int main() {
  	int N;
  	cin >> N;
  	int h[N];
  	for (int i = 0; i < N; i++){
      	cin >> h[i];
    }
	int res = 0, count = 0;
  	int previous = 0;
  	for (int i = 0; i < N; i++){
      	if (previous < h[i]){
          	if (res < count - 1) res = count - 1;
          	count = 0;
        }
      	previous = h[i];
      	count++;
    }
  	if (res < count - 1) res = count - 1;
  	cout << res << endl;
}  


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, q, S[N], T[N], X[N], R[N], P[N], D[N];
bool CMP(int i, int j)
{
    return (X[i] < X[j]);
}
int main()
{
    scanf("%d%d", &n, &q);
    for (int i = 0; i < n; i++)
        scanf("%d%d%d", &S[i], &T[i], &X[i]), P[i] = i;
    set < pair < int , int > > ST;
    for (int i = 0; i < q; i++)
    {
        scanf("%d", &D[i]);
        ST.insert({D[i], i});
        R[i] = -1;
    }
    sort(P, P + n, CMP);
    for (int j = 0; j < n; j++)
    {
        int i = P[j];
        auto it = ST.lower_bound(pair < int , int > {S[i] - X[i], -1});
        while (it != ST.end() && it->first + X[i] < T[i])
            R[it->second] = X[i], it = ST.erase(it);
    }
    for (int i = 0; i < q; i++)
        printf("%d\n", R[i]);
    return 0;
}


Measured memory_bytes: 16000
#include<bits/stdc++.h>
using namespace std;
int n, k, v[55], vf[55], vb[55], ans;

int main(){
    scanf("%d%d", &n, &k);
    for(int i = 0; i < n; i++){
        scanf("%d", v+i);
        vf[i] = v[i] + (i ? vf[i-1] : 0);
    }
    for(int i = n-1; i >= 0; i--) vb[i] = v[i] + vb[i+1];
    if(n*2 < k){
        sort(v, v+n, greater<int>());
        for(int i = 0;v[i] > 0; i++) ans += v[i];
        return 0*printf("%d\n", ans);
    }
    for(int i = (k+1)/2; i <= min(n,k); i++){
        for(int j = 0; j <= i; j++){
            int mn[55], t = 0, sm = (j ? vf[j-1] : 0) + (i-j ? vb[n-i+j] : 0);
            for(int l = 0; l < j; l++) if(v[l] <= 0) mn[t++] = v[l];
            for(int l = n-1; l >= n-i+j; l--) if(v[l] <= 0) mn[t++] = v[l];
            sort(mn, mn+t);
            for(int l = 0; l < min(t, k-i); l++) sm -= mn[l];
            ans = max(ans, sm);
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
N, K = map(int,input().split())
A = [int(i)-1 for i in input().split()]

visited = [0]
visited_flg = [0 for _ in range(N)]
visited_flg[0] = 1
now_city = 0

next_city = A[0]
# visited.append(A[0])

if K <= N:
    p = 0
    for _ in range(K):
        p = A[p]
    print(p + 1)
    exit()


while True:
    next_city = A[now_city] 
    if visited_flg[next_city]:
        break
    
    now_city = next_city
    visited.append(now_city)
    visited_flg[now_city] = 1
    

loop_start = next_city
loop_city =  visited[visited.index(loop_start):]
k =  (K- len(visited)) % len(loop_city)
print(loop_city[k]+1)

Measured memory_bytes: 104120
#include<iostream>

using namespace std;

struct BSTNode {
	int data;
	BSTNode *left;
	BSTNode *right;
};

BSTNode* getnode(int data);
BSTNode* Insert(BSTNode *root, int data);
void PreOrder(BSTNode *root);
void InOrder(BSTNode *root);
void Visit(BSTNode *root);


int main() {
	
	BSTNode *root = NULL;
	
	int n;
	string s;
	int data;
	
	while(cin >> n) {
		
		for(int i=0;i<n;i++) {
			
			cin >> s;
			
			if(s[0] == 'i') {
				
				cin >> data;
				root = Insert(root, data);
			
		}
			else {
				
				InOrder(root);
				cout << "\n";
				PreOrder(root);	
				cout << "\n";
				
				
			}
				
			
		}
		
		
		
	}
	
	return 0;
}

BSTNode* getnode(int data) {
	
	BSTNode *newnode = new BSTNode;
	
	newnode -> data = data;
	newnode -> left = NULL;
	newnode -> right = NULL;
	
	return newnode;
}

BSTNode* Insert(BSTNode *root, int data) {
	
	if(root == NULL)
		root = getnode(data);
		
	else if(data < root -> data )
		root -> left = Insert(root -> left, data);
		
	else
		root -> right = Insert(root -> right, data);
	
	return root;
	
}

void PreOrder(BSTNode *root) {
	
	if (root != NULL) {
      Visit(root); 
      PreOrder(root -> left);   
      PreOrder(root -> right);
      
   }

}

void InOrder(BSTNode *root) {
	
	if (root != NULL) {
		
      InOrder(root -> left);   
      Visit(root);
      InOrder( root -> right);
      
   }

}
void Visit(BSTNode *root) {
	cout << " " << root->data;
}


Measured memory_bytes: 18820
#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <limits>

using namespace std;

typedef long long ll;

void add_mod(ll& val, ll add_val) {
	val = (val + add_val) % 100000007;
}

int main (int argc, char* argv[]) {
	int a, b;
	cin >> a >> b;
	cout << (((a * b) & 1) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
using namespace std;

const int sz = 1e5+5;

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

    int n,a[sz][3],dp[sz][3];
    cin >> n;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < 3; j++) {
            cin >> a[i][j];
            dp[i][j] = 0;
        }
    }

    for(int i = 0; i < 3; i++) dp[0][i]=a[0][i];
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < 3; j++) {
            for(int k = 0; k < 3; k++) {
                if(j==k) continue;
                dp[i+1][k]=max(dp[i+1][k],dp[i][j]+a[i+1][k]);
            }
        }
    }
    cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

Measured memory_bytes: 2560
N = int(input())
ab_count = 0
heading_b_count = 0
trailing_a_count = 0
both_sides_count = 0
for _ in range(N):
    s = input()
    ab_count += s.count('AB')
    if s[0] == 'B':
        heading_b_count += 1
    if s[-1] == 'A':
        trailing_a_count += 1
    if s[0] == 'B' and s[-1] == 'A':
        both_sides_count += 1

ans = ab_count + min(heading_b_count, trailing_a_count)
if both_sides_count == trailing_a_count and both_sides_count == heading_b_count and both_sides_count > 0:
    ans -= 1
print(ans)


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

void solve(){
    ll N, K;
    cin >> N >> K;
    vector<ll> H(N);
    REP(i, N) cin >> H[i];

    if(N <= K){
        cout << 0 << endl;
    }
    else{
        sort(H.begin(), H.end());
        ll sum = 0;
        REP(i, N-K) sum += H[i];
        cout << sum << endl;
    }
}

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

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

using namespace std;

int main()
{
    int N, xp=0, yp=0, tp=0, x, t, y;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> t >> x >> y;
        if ((x+y) % 2 != t % 2 || fabs(x-xp) + fabs(y-yp) > t-tp)
        {
            cout << "No";
            return 0;
        }
        xp = x;
        yp = y;
        tp = t;
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<iomanip>
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long ll;
const ll inf=0x3f3f3f3f;
int main()
{
	int a,b;
	cin>>a>>b;
	cout<<a*b;
	return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		int re=0;
		int hi=0;
		Scanner in = new Scanner(System.in);
		while(in.hasNext())
		{
			String st[] = in.next().split(",");
			int a=Integer.valueOf(st[0]);
			int b=Integer.valueOf(st[1]);
			int c=Integer.valueOf(st[2]);

			if(a*a+b*b==c*c)
				re++;
			else if(a==b)
				hi++;
		}
		System.out.println(re);
		System.out.println(hi);
	}
}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long
#define lfl long double

lin n, m;

bool check(lin i)
{
    if(m % i != 0)
        return false;

    if(m / i < n)
        return false;

    return true;
}

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

    lin res = 0;

    lin i = 1;
    for(lin i = 1; i * i <= m; i++)
    {
        if(check(i))
            res = max(i, res);

        lin i2 = m / i;
        if(check(i2))
            res = max(i2, res);
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using pii = pair <int, int>;

#define endl '\n'
#define FIO() ios_base::sync_with_stdio(0);cin.tie(NULL);

int main() {
    FIO();

    int n; cin >> n;
    vector <pii> v;

    for (int i = 0; i < n; i++) {
        int x, y; cin >> x >> y;
        v.emplace_back(x, y);
    }

    bool ok = false;
    for (int i = 0; i + 2 < n; i++) {
        bool x = true;
        for (int j = 0; j < 3; j++) {
            if (v[i + j].first != v[i + j].second) {
                x = false;
                break;
            }
        }

        if (x) {
            ok = true;
            break;
        }
    }

    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3656
import java.util.Scanner;

class Main{
public static void main(String[] args){

    Scanner scanner = new Scanner(System.in);
    
    int input_one = scanner.nextInt();
    int input_two = scanner.nextInt();
    int input_three = scanner.nextInt();
    if(input_one > input_two){
    int kari = input_one;
    input_one = input_two;
    input_two = kari;
    }
    if(input_two > input_three){
    int karxi = input_two;
    input_two = input_three;
    input_three = karxi;
    }
    if(input_one > input_two){
    int kari = input_one;
    input_one = input_two;
    input_two = kari;
    }
    System.out.println(input_one + " " +input_two + " " + input_three);
    }
}


Measured memory_bytes: 26144
#include<stdio.h>
 
int main(){
    int month,day;
    int sum;
    int i;
     
    scanf("%d %d",&month,&day);
    while(month!=0){
        sum=0;
        for(i=1;i<month;i++){
            switch(i){
                case 2:
                    sum=sum+29;
                    break;
                case 4:
                    sum=sum+30;
                    break;
                case 6:
                    sum=sum+30;
                    break;
                case 9:
                    sum=sum+30;
                    break;
                case 11:
                    sum=sum+30;
                    break;
                default:
                    sum=sum+31;
                    break;
            }
        }
        sum=sum+day;
         
        switch(sum%7){
            case 0:
                printf("Wednesday\n");
                break;
            case 1:
                printf("Thursday\n");
                break;
            case 2:
                printf("Friday\n");
                break;
            case 3:
                printf("Saturday\n");
                break;
            case 4:
                printf("Sunday\n");
                break;
            case 5:
                printf("Monday\n");
                break;
            case 6:
                printf("Tuesday\n");
                break;
        }
         
        scanf("%d %d",&month,&day);
    }
     
    return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
struct UnionFind {
private:
    vector<int> par;
    vector<int> count;
    vector<int> rank;
public:
    UnionFind(int N) {
        count.assign(N, 1);
        rank.assign(N, 0);
        par.assign(N, 0);
        rep(i, N) par[i] = i;
    }

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

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

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

    bool issame(int x, int y) {
        return root(x) == root(y);
    }
};
using UF = struct UnionFind;

int main() {
    init();
    ll N, M;
    cin >> N >> M;
    UF uf(M);
    vc<bool> lang(M);
    rep(i,N){
        ll K;
        cin >> K;
        ll f;
        cin >> f;
        lang[f-1] = true;
        rep(i,K-1){
            ll L;
            cin >> L;
            lang[L - 1] = true;
            uf.unite(f-1, L-1);
        }
    }

    ll v;
    rep(i,M)if(lang[i]){
        v = i;
        break;
    }
    cout << (uf.size(v) == accumulate(all(lang),0) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <cstring>
using namespace std;
int main() {
  int n;
  char s[110];
  scanf("%s", s);
  n = strlen(s);
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0 && s[i] == 'L') {
      printf("No\n");
      return 0;
    } else if (i % 2 && s[i] == 'R') {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<numeric>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
ll solve ( string s ) {
    ll cnt = 0, ret = 0;
    rep(i, s.size()) {
        ++cnt;
        if ( i == (int)s.size() - 1 || s[i] != s[i+1]) {
            ret += cnt / 2;
            cnt = 0;
        } 
    }
    return ret;
}
int main(){
    string s;
    cin >> s;
    ll k;
    cin >> k;
    bool flag = true;
    rep(i, s.length()-1 ) {
        if ( s[i] != s[i+1] ) {
            flag = false;
        }
    }
    if ( flag ) {
        ll len = (ll)s.size() * k;
        cout << len / 2LL << endl;
    }
    else {
        string v1 = s;
        string v2 = s + s;
        ll r1 = solve(v1);
        ll r2 = solve(v2);
        cout << r1 + ( r2 - r1 ) * ( k - 1LL ) << endl;
    }
    return 0;
}

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

int main(){
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if(b < a) swap(a, b);
	if(c < b) swap(b, c);
	if(b < a) swap(a, b);
	printf("%d %d %d\n", a, b, c);
}



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

int main()
{
    int N;
    cin >> N;
    map<string, int> words;
    string s;
    for (int i = 0; i < N; i++)
    {
        cin >> s;
        words[s]++;
    }

    int M;
    cin >> M;
    for (int i = 0; i < M; i++)
    {
        cin >> s;
        words[s]--;
    }

    int ans = 0;
    for (auto word = words.begin(); word != words.end(); word++)
    {
        ans = max(ans, word->second);
    }
    cout << ans << endl;
}


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

using namespace std;

int main() {

    int N, K; cin >> N >> K;

    int money = 0;
    
    int p[N];
    for(int i = 0; i < N; i++) cin >> p[i];

    sort(p, p+N);
    
    for(int i = 0; i < K; i++) {
        money += p[i];
    }

        cout << money << endl;


    return 0;
}

Measured memory_bytes: 3640
n=int(input())
s=[]
for i in range(n):
  s.append(input())
m=0
a=0
r=0
c=0
h=0
for i in range(n):
  if s[i][0]=='M':
    m+=1
  if s[i][0]=='A':
    a+=1
  if s[i][0]=='R':
    r+=1
  if s[i][0]=='C':
    c+=1
  if s[i][0]=='H':
    h+=1
li=[m,a,r,c,h]
li.sort(reverse=True)
if li[2]==0:
  print(0)
else:
  ans=m*a*(r+c+h)+m*r*(c+h)+m*c*h+a*r*(c+h)+a*c*h+r*c*h
  print(ans)

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

int h, w;
string maze[31];
int dist[31][31];

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

int main() {
    cin >> h >> w;
    rep(i, h) cin >> maze[i];

    queue<pair<int, int>> que;
    rep(r, h) rep(c, w) {
        if (maze[r][c] == '.') {
            que.push({r, c});
            break;
        }
    }

    bitset<21*21> used;

    int ans = 0;

    rep(r, h) rep(c, w) {
        if (maze[r][c] == '.') {
            queue<pair<int, int>> que;
            que.push({r, c});
            dist[r][c] = 0;
            used.reset();
            used[r*w+c] = 1;
            int ma = 0;
            while (que.size()) {
                pair<int, int> p = que.front(); que.pop();
                rep(d, 4) {
                    int ny = p.first + dy[d], nx = p.second + dx[d];
                    if (0 <= ny and ny < h and 0 <= nx and nx < w and maze[ny][nx] == '.' and !used[ny*w+nx]) {
                        used[ny*w+nx] = 1;
                        que.push({ny, nx});
                        dist[ny][nx] = dist[p.first][p.second] + 1;
                        ma = max(ma, dist[ny][nx]);
                    }
                }
            }

            ans = max(ans, ma);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef  pair<int,int> P;
typedef long long LL;

const LL INF=1<<30;
const LL MOD=1000000007;

LL gcd(LL a,LL b){
    if(b==0)return a;

    return gcd(b,a%b);
}


int main(){
 string s;
 cin>>s;
    if(s[5]-'0'==0&&s[6]-'0'<=4)cout<<"Heisei"<<endl;
    else cout<<"TBD"<<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
 string s ;
 cin >> s ;
 int k=s.size() ;
 int ans=0 ;
 rep(i,k-1) {
   if(s[i]!=s[i+1] ) ans ++ ;
 }

cout <<ans <<endl ;
     return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
  string s;
  cin>>s;
  s=s+'z';
  int n=s.size();
  int ans=0;
  for (int i=0;i<n;i++){
    int a=0;
    for (int j=i;i<n;i++){
      if((s.at(i)=='A' || s.at(i)=='T') || (s.at(i)=='C' || s.at(i)=='G')){
        a++;
      }
      else{
        ans=max(ans,a);
        break;
      }
    }
    
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(n) for (int i = 0; i < n; i++)
#define fo(i, x, n) for (int i = x; i < n; i++)
#define fb(i, x, n) for (int i = n - 1; i >= x; i--)
#define w(t)  \
    int t;    \
    cin >> t; \
    while (t--)

typedef unsigned long long ull;
typedef vector<long long> vi;
#define msi map<string, long long>
#define mii map<long long, long long>
const int MX = 2e5 + 5;
const int INF = 1e18;
#define pb push_back
//#define endl "\n"
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define all(x) x.begin(), x.end()
#define ff first
#define ss second

void print(int a[], int n)
{
    for (int i = 0; i < n; i++)
    {
        cout << a[i] << " ";
    }
    cout << endl;
}

void print(vi &v)
{
    f(v.size())
    {
        cout << v[i] << " ";
    }
    cout << endl;
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin>>n;
    string s="ACL";
    while(n--)
    {
        cout<<s;
    }


    //cerr<< "Time Killed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    ll n;
    cin >> n;
    vector<ll> v(n);
    rep(i, n) {
        cin >> v[i];
    }
    ll mx=v[0];
    ll mn=v[0];
    rep(i, n) {
        if(mn>=v[i]){
        mn=v[i];
        }
        if(mx<=v[i]){
        mx=v[i];
        }
    }
    cout << mx-mn <<endl;
}


Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
q=int(input())
from collections import defaultdict
d=defaultdict(int)
for i in range(n):  
  d[A[i]]+=1

ans=sum(A)

for i in range(q):
  b,c=map(int,input().split())
  l=d[b]
  d[b]=0
  d[c]+=l
  ans+=(c-b)*l 
  print(ans)

Measured memory_bytes: 23836