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

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] p = new int[n];
        int[] q = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = Integer.parseInt(sc.next());
        }
        for (int i = 0; i < n; i++) {
            q[i] = Integer.parseInt(sc.next());
        }

        // 主処理
        String target = "";
        String strP = "";
        String strQ = "";
        for (int i = 0; i < n; i++) {
            target += (i + 1);
            strP += p[i];
            strQ += q[i];
        }
        List<String> targetList = permutation(target);

        int a = targetList.indexOf(strP);
        int b = targetList.indexOf(strQ);   
        int result = Math.abs(a - b);

        // 出力
        System.out.println(result);
        sc.close();
    }

    public static List<String> permutation(String q) {
        return permutation(q, "");
    }

    private static List<String> permutation(String q, String ans) {
        List<String> list = new ArrayList<>();
        if (q.length() <= 1) {
            list.add(ans + q);
        } else {
            for (int i = 0; i < q.length(); i++) {
                list.addAll(permutation(q.substring(0, i) + q.substring(i + 1), ans + q.charAt(i)));
            }
        }
        return list;
    }
}

Measured memory_bytes: 49812
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    while True:
        h, w = ZZ()
        if h == 0 and w == 0: break
        for i in range(h):
            for j in range(w):
                if (i+j)%2: print('.', end='')
                else: print('#', end='')
            print('')
        print('')

    return

if __name__ == '__main__':
    main()



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ull> vull;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;


#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORDOWN(i, a, b) for(int i = a; i >= b; --i)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
//mt19937 rnd(150);



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

    //  freopen("goat5.in", "r", stdin);
    //  freopen("goat5.out","w", stdout);

   string s,t;
   cin >> s >> t;

   int ans = t.size();

   for (int i = 0; i <= s.size()- t.size(); ++i) {
       int now = 0;
       for (int j = 0; j < t.size(); ++j) {
           if (s[i + j] != t[j])
               now++;
       }
       ans = min(ans,now);
   }

   cout << ans;



    return 0;
}


Measured memory_bytes: 3604
#include <iostream>

using namespace std;

int main()
{
	int n;
	int abc[100001][3];
	
	cin >> n;
	
	for(int i = 1; i <= n; ++i)
	{
		for(int j = 0; j < 3; ++j)
		{
			cin >> abc[i][j];
		}
	}

	int dp[100001][3] = { 0 };
	for(int i = 1; i <= n; ++i)
	{
		dp[i][0] = max(dp[i - 1][1] + abc[i][0], dp[i - 1][2] + abc[i][0]);
		dp[i][1] = max(dp[i - 1][0] + abc[i][1], dp[i - 1][2] + abc[i][1]);
		dp[i][2] = max(dp[i - 1][0] + abc[i][2], dp[i - 1][1] + abc[i][2]);
	}

	cout << max(max(dp[n][0], dp[n][1]), dp[n][2]) << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
using namespace std;
 
void solve(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max({a*c, a*d, b*c, b*d});
}

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

    solve(); cout<<endl;
    return 0;
}

Measured memory_bytes: 3648
# -*- coding: utf-8 -*-
import math
import copy
#GCD（最大公約数）
def gcd(x, y):
    if x < y:
        x, y = y, x
    while y > 0:
        x, y = y, x % y
    return x

#最小公倍数
def lcm(a, b):
    return (a * b) // gcd(a, b)


n, m = map(int,input().split())
a = [int(i) for i in input().split()] 
b = copy.deepcopy(a)

count = [0 for _ in range(n)]
for i in range(n):
    while b[i] % 2 == 0:
        b[i] //= 2
        count[i] += 1
#print(count)
if len(set(count)) != 1:
    print(0)
    exit()

l = 1
for i in range(n):
    l = lcm(l, a[i])

ans = math.ceil((2 * m // l) / 2) 
print(ans)


Measured memory_bytes: 15572
#include <iostream>
#include <algorithm>
const int MAX_V = 100;
const int INF = 99999999;
using namespace std;

int c[MAX_V][MAX_V];
int t[MAX_V][MAX_V];

int main(void) {
  while (1) {
    int n, m;
    cin >> n >> m;
    if (n == 0 && m == 0) break;
    for (int i = 0; i < MAX_V; i++) {
      for (int j = 0; j < MAX_V; j++) {
        c[i][j] = INF;
        t[i][j] = INF;
      }
    }
    
    for (int i = 0; i < n; i++) {
      int a, b, cost, time;
      cin >> a >> b >> cost >> time;
      a--; b--;
      c[a][b] = c[b][a] = cost;
      t[a][b] = t[b][a] = time;
    }

    for (int k = 0; k < m; k++) {
      for (int i = 0; i < m; i++) {
        for (int j = 0; j < m; j++) {
          c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
          t[i][j] = min(t[i][j], t[i][k] + t[k][j]);
        }
      }
    }

    int k;
    cin >> k;
    for (int i = 0; i < k; i++) {
      int p, q, r;
      cin >> p >> q >> r;
      p--; q--;
      if (r == 0) {
        cout << c[p][q] << endl;
      } else {
        cout << t[p][q] << endl;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 1236
w, h, x, y, r = map(int, input().split())

if x<0 or y<0:
    print('No')

else:
    if w<x+r or x-r<0:
        print('No')

    else:
        if h<y+r or y-r<0:
            print('No')

        else:
            print('Yes')


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

int min(int x,int y){if(x>y)return y; return x;}

int main(){
	int n,k,a,b;
	scanf("%d%d",&n,&k);
	for(int i=0;i<k;i++){
		scanf("%d%d",&a,&b);
		int ans=min(min(a,b),min(n+1-a,n+1-b))%3;
		if(ans==0)ans=3;
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 1172
#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>;
using namespace std;

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

    ll res = n % 1000;
    if (res == 0) {
        cout << 0 << endl;
        return 0;
    }
    cout << 1000 - (n % 1000) << endl;
    return 0;
}


Measured memory_bytes: 3624
/*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/
#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;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=2e5+4;

typedef pair<ll,ll> pll;

ll me(ll a,ll b)
{
	ll res=1;

	while(b)
	{
		if(b&1)
		res=(res*a)%mod;

		b>>=1; a=(a*a)%mod;
	}

	return res;
}

int main()
{
	int n;

	scn(n);

	map<pll,ll> ma;

	ll az=0,xz=0,yz=0;

	rep(i,0,n)
	{
		ll a,b; lscn(a); lscn(b);

		if(a==0 and b==0)
		az++;
		else if(a==0)
		xz++;
		else if(b==0)
		yz++;
		else
		{
			pll p;

			ll d=gcd(abs(a),abs(b));

			a/=d; b/=d;

			int sa=a/abs(a),sb=b/abs(b);

			if(a<0)
			a*=-1;

			if(b<0)
			b*=-1;

			if(sa*sb<0)
			p=mp(-a,b);
			else			
			p=mp(a,b);

			if(ma.find(p)!=ma.end())
			ma[p]++;
			else
			ma[p]=1;
		}
	}

	ll ans=0,other=1;

	for(auto &it:ma)
	{
		pll ph=it.F,preq;

		if(ph.F<0)
		preq=mp(ph.S,-ph.F);
		else
		preq=mp(-ph.S,ph.F);

		ll cnt1=it.S,cnt2=0;

		if(ma.find(preq)!=ma.end())
		cnt2=ma[preq],ma[preq]=0,it.S=0;

		ll contribution=(me(2,cnt1)+me(2,cnt2)-1+mod)%mod;

		other=(other*contribution)%mod;
	}

	ans=(other-1+mod)%mod; //remove the empty set

	ll temp=(me(2,xz)-1+mod)%mod,temp1;

	temp=(temp*other)%mod;

	ans=(ans+temp)%mod;

	temp=(me(2,yz)-1+mod)%mod;

	temp=(temp*other)%mod;

	ans=(ans+temp)%mod;

	ans=(ans+az)%mod; 

	lpri(ans);

	return 0;
}

Measured memory_bytes: 16116
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

vector<ll> p, q, sorted;
ll s[100010];
map<ll, ll> pos;

int main(){
    int n;
    cin >> n;
    rep(i, n) {
        ll a; cin >> a;
        if (i%2==0) p.push_back(a);
        else q.push_back(a);
        sorted.push_back(a);
    }
    sort(p.begin(), p.end());
    sort(q.begin(), q.end());
    sort(sorted.begin(), sorted.end());

    int j = 0, k = 0;
    rep(i, n) {
        if (i%2==0) s[i] = p[j], j++;
        else s[i] = q[k], k++;
    }

    ll cnt = 0;

    rep(i, n){
        pos[sorted[i]] = i;
    }

    rep(i, n){
        cnt += (pos[s[i]]%2 ^ i%2);
    }
    
    cout << cnt / 2 << endl;

    return 0;
}


Measured memory_bytes: 11776
#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<vector>
using namespace std;
int a[3],ans;
int main()
{
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	ans+=a[2]-a[1];a[0]+=a[2]-a[1];a[1]=a[2];
	ans+=(a[2]-a[0])/2;
	a[0]+=(a[2]-a[0])/2*2;
	if (a[0]!=a[2]) ans+=2;
	cout<<ans<<endl;
	return 0;
}

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


int main(){

  ll n;
  cin>>n;
  ll dp[n+1][3];
  rep(i,n+1)rep(j,3)dp[i][j]=0;
  ll v[n][3];
  rep(i,n){
    cin>>v[i][0];
    cin>>v[i][1];
    cin>>v[i][2];
  }
  rep(i,n){
    dp[i+1][0]=max(dp[i+1][0],dp[i][1]+v[i][0]);
    dp[i+1][0]=max(dp[i+1][0],dp[i][2]+v[i][0]);

    dp[i+1][1]=max(dp[i+1][1],dp[i][0]+v[i][1]);
    dp[i+1][1]=max(dp[i+1][1],dp[i][2]+v[i][1]);

    dp[i+1][2]=max(dp[i+1][2],dp[i][1]+v[i][2]);
    dp[i+1][2]=max(dp[i+1][2],dp[i][0]+v[i][2]);

  }

ll ans=0;
rep(i,3){
  ans=max(ans,dp[n][i]);
}
cout<<ans;
}


Measured memory_bytes: 8192
import sys


def find_color(n, ai, bi):
    color = (3, 1, 2)
    if n % 2 != 0:
        if ai > int((n+1)/2):
            ai = int((n+1)/2) - (ai - int((n+1)/2))
        if bi > int((n+1)/2):
            bi = int((n+1)/2) - (bi - int((n+1)/2))
    else:
        if ai > int(n/2):
            ai = int(n/2) - (ai - int(n/2)) + 1
        if bi > int(n/2):
            bi = int(n/2) - (bi - int(n/2)) + 1

    if bi >= ai and bi <= n - ai:
        return color[ai % 3]
    else:
        return color[bi % 3]


n = int(sys.stdin.readline())
k = int(sys.stdin.readline())

for i in range(0, k):
    ai, bi = (int(x) for x in sys.stdin.readline().split())
    print(find_color(n, ai, bi))

Measured memory_bytes: 7776
#include<bits/stdc++.h>
#define N 200005
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>
using namespace std;
inline void in(int &x)
{
	x=0;
	char c=getchar();
	while(c<'0'||c>'9')c=getchar();
	while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
}
int n,a[N],san[N],sanc,ans[N];
inline int ID(int l,int r){return (l+r)|(l!=r);}
inline void chmax(int &x,int y){x=x>y?x:y;}
vector<int> v[N];
int tree[N<<1];
void push_up(int k,int l,int r)
{
	int mid=l+r>>1,ls=ID(l,mid),rs=ID(mid+1,r);
	tree[k]=max(tree[ls],tree[rs]);
}
void update(int k,int l,int r,int x,int val)
{
	if(l==r)
	{
		tree[k]=val;
		return;
	}
	int mid=l+r>>1;
	if(x<=mid)update(ID(l,mid),l,mid,x,val);
	else update(ID(mid+1,r),mid+1,r,x,val);
	push_up(k,l,r);
}
int query(int k,int l,int r,int L,int R)
{
	if(L>R)return 0;
	if(L<=l&&r<=R)
	{
		return tree[k];
	}
	int mid=l+r>>1;
	int ret=0;
	if(L<=mid)chmax(ret,query(ID(l,mid),l,mid,L,R));
	if(mid<R)chmax(ret,query(ID(mid+1,r),mid+1,r,L,R));
	return ret;
}
void dfs(int from,int f)
{
	int res=query(ID(1,sanc-1),1,sanc-1,1,a[from]-1)+1,last=tree[ID(a[from],a[from])];
	update(ID(1,sanc-1),1,sanc-1,a[from],res);
	ans[from]=tree[ID(1,sanc-1)];
	for(int i=0;i<v[from].size();++i)
	{
		int to=v[from][i];
		if(to==f)continue;
		dfs(to,from);
	}
	update(ID(1,sanc-1),1,sanc-1,a[from],last);
}
int main()
{
	in(n);
	for(int i=1;i<=n;++i)in(a[i]),san[i]=a[i];
	sort(san+1,san+n+1);
	sanc=1;
	for(int i=1;i<=n;++i)
	if(san[i]!=san[i+1])san[sanc++]=san[i];
	for(int i=1;i<=n;++i)
	{
		int l=1,r=sanc;
		while(r-l>1)
		{
			int mid=l+r>>1;
			if(san[mid]<=a[i])l=mid;
			else r=mid;
		}
		a[i]=l;
	}
	for(int i=1;i<n;++i)
	{
		int x,y;
		in(x);in(y);
		v[x].pb(y);
		v[y].pb(x);
	}
	dfs(1,0);
	for(int i=1;i<=n;++i)
	printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 31124
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

struct Hashing {
    ull seed, mod;
    vector <ull> hs, pw;

    Hashing(ull seed = 31, ull mod = 1000173169) :
        seed(seed),
        mod(mod) {}

    void build(int n, const string& s) {
        hs.assign(n + 1, 0);
        pw.assign(n + 1, 1);
        pw[0] = 1;

        for (int i = 1; i <= n; ++i)
            pw[i] = pw[i - 1] * seed % mod;
        for (int i = 1; i <= n; ++i)
            hs[i] = (hs[i - 1] * seed + s[i]) % mod;
    }

    ull hash(int l, int r) {
        return (hs[r] - hs[l - 1] * pw[r - l + 1] % mod + mod) % mod;
    }
};


pair<int, int> getFirstLast(int n) {

    pair<int, int> p;

    p.second = n % 10;

    while (n > 0) {
        p.first = n;
        n /= 10;
    }

    return p;
}

int solve()
{
    int N;

    std::cin >> N;

    vector<vector<int>> help(10, vector<int> (N, 0));

    for (int i = 1; i <= N; ++i) {
        auto p = getFirstLast(i);

        help[p.first][p.second]++;
    }

    ll ans = 0;

    for (int i = 1; i <= N; ++i) {
        auto p = getFirstLast(i);

        ans += help[p.second][p.first];
    }

    cout << ans << endl;

    return 0;
}

int main()
{
//    std::cout << solve() << std::endl;
    solve();

    return 0;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000003
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

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

    int n,xors=0; cin>>n;
    vector<int> a(n),bits(30,0);
    rep(i,n){
        cin>>a[i]; xors^=a[i];
        rep(j,30){
            if((1<<j)&a[i]){
                bits[j]++; break;
            }
        }
    }

    int ans=0;
    for(int i=29; i>=0; i--){
        if((1<<i)&xors){
            if(bits[i]==0){
                cout<<-1<<endl; return 0;
            }else{
                xors^=(1<<i);
                xors^=(1<<i)-1;
                ans++;
            }
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
#define ll long long
ll n, k, h[100009], dp[100009];
ll solve(ll ind)
{
	if (ind == n - 1)
		return 0;
	ll jump = 1e18;
	if (dp[ind] != -1)
		return dp[ind];
	for (int i = 1; i <= k; i++)
	{
		if (i + ind < n)
			jump = min(jump, abs(h[ind] - h[ind + i]) + solve(ind + i));
	}
	return dp[ind] = jump;
}
int main()
{
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> h[i];
	memset(dp, -1, sizeof(dp));
	cout << solve(0);
}

Measured memory_bytes: 6528
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iterator>
#include <deque>
#include <string>
#include <queue>
#include <omp.h>
#include <fstream>   // ifstream, ofstream
typedef int64_t ll;
using namespace std;
const ll INF=1e10;
const double EPS=1e-8;
const ll mod = 1000000007;
int main(){
	ll n;
	cin>>n;
	vector<ll> a;
	for(ll i1=0;i1<n;i1++){
		ll temp;
		cin>>temp;
		a.push_back(temp);
	}
	ll max_value=-1;
	ll max_count=0;
	ll second_max_value=-1;
	for(ll i1=0;i1<n;i1++){
		if(a[i1]>max_value){
			second_max_value = max_value;
			max_value=a[i1];
			max_count=1;
		}else if(a[i1]==max_value){
			max_count++;
		}else if(a[i1]>second_max_value){
			second_max_value = a[i1];
		}
	}
	if(max_count >=2){
		for(ll i1=0;i1<n;i1++){
			cout<<max_value<<endl;
		}
	}else{
		for(ll i1=0;i1<n;i1++){
			if(a[i1]==max_value){
				cout<<second_max_value<<endl;
			}else{
				cout<<max_value<<endl;
			}
		}
	}
}


Measured memory_bytes: 3312
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(unsigned x){
  int s=0;
  char f[10];
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(unsigned long long x){
  int s=0;
  char f[21];
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(double x){
  printf("%.15f",x);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
inline void wt_L(string &x){
  int i=0;
  for(i=0;x[i]!='\0';i++){
    putchar_unlocked(x[i]);
  }
}
template<class T> inline T GCD_L(T a,T b){
  T r;
  while(a){
    r=b;
    b=a;
    a=r%a;
  }
  return b;
}
int N;
int M;
char S[100002];
char T[100002];
int main(){
  int i;
  rd(N);
  rd(M);
  rd(S);
  rd(T);
  int g =GCD_L(N, M);
  for(i=(0);i<(g);i++){
    if(S[N/g*i] != T[M/g*i]){
      wt_L(-1);
      wt_L('\n');
      return 0;
    }
  }
  wt_L((long long)N*M/g);
  wt_L('\n');
  return 0;
}
// cLay varsion 20191123-1

// --- original code ---
// int N, M;
// char S[100002], T[100002];
// {
//   rd(N,M,S,T);
//   int g = gcd(N,M);
//   rep(i,g) if(S[N/g*i] != T[M/g*i]) wt(-1), return 0;
//   wt((ll)N*M/g);
// }


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

int main(){
	string S;
	cin >> S;
	for(int i=0; i<S.size()-1; i++){
		if(S[i] == S[i+1]){
			cout << i+1 << " " << i+2 << endl;
			return 0;
		}
		
	}
	for(int i=0; i<S.size()-2; i++){
		if(S[i] == S[i+2]){
			cout << i+1 << " " << i+3 << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
const int N = 3000300;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const int mod =    1e9+7;
ll n,ans;
ll arr[2005];
int main()
{ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

cin>>n;
rep(i,1,n+1)
cin>>arr[i];
sort(arr,arr+n+1);
for(int i=1;i<=n-2;i++)
{
	for(int j=i+1;j<=n-1;j++)
	{
		ll sum=arr[i]+arr[j];

		ll x=lower_bound(arr,arr+n,sum)-arr;

		 while(arr[x]>=sum)
		 x--;
		if(x>j)
		ans+=(x-j);
	//	cout<<i<<" "<<j<<" "<<x<<endl;
	}
}
cout<<ans;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 23;
const int mod = 1e9+7;
typedef long long ll;
int N;
int memo[1 << 21];
int A[maxn][maxn];
int solve(int mask){
    int last = N-__builtin_popcount(mask);
    if (!mask && last == N)return 1;
    if(!mask || last == N)return 0;
    int &ans = memo[mask];
    if (ans != -1)return ans;
    ans = 0;
    for (int i = 0;i < N;i++){
        if (mask & (1 << i)&& A[last+1][i])
            ans =(ans+solve(mask^1 << i))%mod;
    }
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> N;
    for (int i = 1; i <=N;i++){
        for (int j = 0; j < N;j++){
            cin >> A[i][j];
        }
    }
    memset(memo,-1,sizeof memo);
    cout << solve((1 << N)-1);
    return 0;
}


Measured memory_bytes: 8448
import java.util.*;
import java.io.*;

class Main{
	public static void main(String[] args) throws Exception{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String[] _in = reader.readLine().split(" ");
		int v = Integer.parseInt(_in[0]);
		int e = Integer.parseInt(_in[1]);
		Group[] groups = new Group[v];
		for(int i = 0; i < v; i++) groups[i] = new Group();
		List<Branch> branches = new ArrayList<>(e);
		for(int i = 0; i < e; i++) {
			_in = reader.readLine().split(" ");
			branches.add(new Branch(
				Integer.parseInt(_in[0]),
				Integer.parseInt(_in[1]),
				Integer.parseInt(_in[2])
			));
		}
		Collections.sort(branches);
		int result = 0;
		for(Branch _b : branches) {
			Group g1 = groups[_b.s].getGroup();
			Group g2 = groups[_b.t].getGroup();
			if(g1==g2) continue;
			Group newg = new Group();
			g1.parent = newg;
			g2.parent = newg;
			result += _b.v;
		}
		System.out.println(result);
	}
}

class Group{
	Group parent;
	Group(){
	}
	Group getGroup() {
		return (parent==null)?this:parent.getGroup();
	}
}

class Branch implements Comparable<Branch>{
	int s,t;
	int v;
	Branch(int _s, int _t, int _v) {
		s = _s;
		t = _t;
		v = _v;
	}
	@Override
	public int compareTo(Branch _b) {
		return this.v - _b.v;
	}
}

Measured memory_bytes: 67932
import math

def get_sieve_of_eratosthenes(n):
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, 1000000)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
        
x = int(input())
ans = get_sieve_of_eratosthenes(x)
for i in ans:
  if i >= x:
    print(i)
    break

Measured memory_bytes: 50456
XN = input().split()
P = input().split()
X = int(XN[0])
N = int(XN[1])
pi = [int(a) for a in P]
if N == 0:
    print(X)
    exit()
i = 0
while True:
    koho1 = X + i
    koho2 = X - i
    if not koho2 in pi:
        print(koho2)
        break
    elif not koho1 in pi:
        print(koho1)
        break
    else:
        i = i + 1
        continue


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

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef set<int> si;
typedef set<ll> sll;
typedef map<int, int> mii;
typedef map<ll, ll> mll;

const double pi = acos(-1.0);
const long long INF = 2e18;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define in insert
#define endl "\n"

#define sqr(a) ((a) * (a))
#define jor(a) !(a&1)// jor means EVEN number
#define bjor(a) (a&1)// bjor means ODD number

#define all(a)  a.begin(), a.end()
#define mem(arr, b) memset(arr, b, sizeof(arr)) //memset only for -1 and 0
//fill(a, a+n, 5) //fill for any value

#define for0(i,b) for(int i=0;i<(b);i++)
#define for1(i,b) for(int i=1;i<=(b);i++)
#define forab(i,a,b) for(int i=(a);i<=(b);i++)
#define forba(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fileRead freopen("input.txt", "r", stdin);
#define fileWrite freopen("output.txt", "w", stdout);

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

//-------------------------------------------------------------------\\

int main()
{
    int n; cin>>n; int k; cin>>k;
    int a[n]; for0(i,n) cin>>a[i];
    sort(a,a+n);
    int ans=0;
    for0(i,k) ans+=a[i];
    cout<<ans;
}


Measured memory_bytes: 3548
inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
N = inp.shift() * 1
a = 0
b = 0
ab = 0
c = 0
for (i=0; i<N; i++) {
    s = inp[i]
    if (s[0] == 'B' && s[s.length - 1] == 'A') {
        ab += 1
    } else if (s[s.length - 1] == 'A') {
        a += 1
    } else if (s[0] == 'B') {
        b += 1
    }
    for (j=0; j<s.length-1; j++) {
        if (s[j] == 'A' && s[j+1] == 'B') {
            c++
        }
    }
}
if (a>0) {
    a--
    c += ab
    ab = 0
    if (b>0) {
        c++
        b--
    }
}
if (b>0) {
    b--
    c += ab
    ab = 0
    if (a>0) {
        c++
        a--
    }
}
if (ab > 0) {
    c += ab - 1
}
c += Math.min(a,b)
console.log(c)


Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s;
  
  	cin >> s;
  
  	int s_1=s/100;
  	int s_2=(s - s_1*100)/10;
  	int s_3=(s - s_1*100 - s_2*10);
  	
  		cout << s_1 + s_2 + s_3 << endl;
}

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

typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
const double pi = 3.141592653589793238;

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

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


int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;

  long long r = 0, g = 0, b = 0;
  for (auto c : S) {
      if (c == 'R') ++r;
      else if (c == 'G') ++g;
      else ++b;
  }

  long long all = r * g * b;
  long long sub = 0;
  for (int i = 0; i < N; ++i) {
      for (int j = i+1; j < N; ++j) {
          if (S[i] == S[j]) continue;
          int k = j*2-i;
          if (k >= N || S[k] == S[i] || S[k] == S[j]) continue;
          ++sub;
      }
  }
  cout << all - sub << endl;

}


Measured memory_bytes: 3612
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")



#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include <ext/rope>
// using namespace __gnu_pbds;
// using namespace __gnu_cxx;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define Find order_of_key
// #define at find_by_order
#define x first
#define y second
#define ll long long
#define lll __int128
#define ull unsigned long long
#define ulll unsigned __int128
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#define gu getchar_unlocked()
#define pu putchar_unlocked()
#define all(x) x.begin(),x.end()
#define endl '\n'

// for min add -m , -b then return -ans 
#define ll long long
const ll is_query = -(1LL<<62);
struct Line {
    ll m, b;
    mutable function<const Line*()> succ;
    bool operator<(const Line& rhs) const {
        if (rhs.b != is_query) return m < rhs.m;
        const Line* s = succ();
        if (!s) return 0;
        ll x = rhs.m;
        return b - s->b < (s->m - m) * x;
    }
};
struct HullDynamic : public multiset<Line> { 
    bool bad(iterator y) {
        auto z = next(y);
        if (y == begin()) {
            if (z == end()) return 0;
            return y->m == z->m && y->b <= z->b;
        }
        auto x = prev(y);
        if (z == end()) return y->m == x->m && y->b <= x->b;
        return 1.0 * (x->b - y->b)*(z->m - y->m) >= 1.0 * (y->b - z->b)*(y->m - x->m);
    }
    void add(ll m, ll b) {
        auto y = insert({ m, b });
        y->succ = [=] { return next(y) == end() ? 0 : &*next(y); };
        if (bad(y)) { erase(y); return; }
        while (next(y) != end() && bad(next(y))) erase(next(y));
        while (y != begin() && bad(prev(y))) erase(prev(y));
    }
    ll eval(ll x) {
        auto l = *lower_bound((Line) { x, is_query });
        return l.m * x + l.b;
    }
}cht;
ll n,c,h[200010];

int main()
{
	fast;
	cin>>n>>c;
	for(int i=1;i<=n;i++)cin>>h[i];
	cht.add(2LL*h[n],-(h[n]*h[n]+c));
	ll dp;
	for(int i=n-1;i>=1;i--){
		dp=h[i]*h[i]-cht.eval(h[i]);
		cht.add(2LL*h[i],-(h[i]*h[i]+c+dp));
	}cout<<dp<<endl;
	return 0;
}

Measured memory_bytes: 23760
#include<stdio.h>
int main()
{
    long long int a,b,t,gcd,lcm,x,y;
    while(scanf("%lld %lld",&a,&b)!=EOF)
    {
        x=a;
        y=b;
    if(a==0)
    gcd=a;
    else if(b==0)
        gcd=b;
    else
    {
    while(b!=0)
    {
        t=b;
        b=a%b;
        a=t;
    }
    gcd=a;
    }
    lcm=(x*y)/gcd;
    printf("%lld\n",lcm);
    }
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){int n;cin>>n;int p=0;
      for(int i=0;i<n;i++)
      { int w,e;cin>>w>>e;if(w==e)p++;else p=0;
      if(p>2)break;}
if(p>2)cout<<"Yes"<<endl;
      else cout<<"No"<<endl;}

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

int main() {
  int n,m,x;
  cin>>n>>m>>x;
  int table[n][m+1];
  for(int i=0; i<n; i++) {
    for(int j=0; j<m+1; j++) {
      cin>>table[i][j];
    }
  }

  bool already = false;
  int ans = -1;
  for(int bit=0; bit<(1<<n); bit++) {
    int algo[m];
    for(int i=0; i<m; i++) algo[i]=0;
    int price = 0;

    for(int i=0; i<n; i++) {
      if((bit>>i)&1) {
        price += table[i][0];
        for(int j=0; j<m; j++) {
          algo[j] += table[i][j+1];
        }
      }
    }

    bool check = true;
    for(int i=0; i<m; i++) {
      if(algo[i]<x) check = false;
    }

    if(check) {
      if(!already) {
        ans = price;
        already = true;
      }
      else ans = min(price, ans);
    }
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int fact[1100000];
Int revfact[1100000];
Int rev[1100000];

void init(){
    Int m = MOD;
    fact[0] = 1;
    revfact[0] = 1;
    rev[0] = 0;
    rev[1] = 1;
    for(int i = 1;i < 1100000;i++){
        fact[i] = fact[i-1] * i % m;
        if(i>1)rev[i] = MOD / i * (MOD-rev[MOD % i]) % MOD;
        revfact[i] = revfact[i-1] * rev[i] % MOD;
    }
}

Int nCk(Int n, Int k){
    if(n < k)return 0;
    return fact[n] * revfact[n-k] % MOD * revfact[k] % MOD;
}

Int n, a[220000], b[220000];
Int dp_[4400][4400];

Int &dp(int x, int y){
    return dp_[x+2200][y+2200];
}

int main(){
    init();
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> a[i] >> b[i];
        dp(-a[i], -b[i])++;
    }
    for(int i = 0;i < 4400;i++){
        for(int j = 0;j < 4400;j++){
            if(i)dp_[i][j] += dp_[i-1][j];
            if(j)dp_[i][j] += dp_[i][j-1];
            dp_[i][j] %= MOD;
        }
    }
    Int ans = 0;
    for(int i = 0;i < n;i++){
        ans += dp(a[i], b[i]);
        ans -= nCk(2*(a[i] + b[i]), 2*a[i]);
        ans %= MOD;
    }
    if(ans < 0)ans += MOD;
    if(ans % 2 == 1)ans += MOD;
    ans /= 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 180736
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
int main(){
    int n;
    cin>>n;
    double v[51];
    rep(i,0,n)cin>>v[i];
    sort(v,v+n);
    rep(i,1,n+1)v[i]=(v[i]+v[i-1])/2;
    cout<<v[n-1]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define maxn 500000
using namespace std;
int n,k;
int a[maxn];
bool cuts(int t) {
    int ret=0;
    for(int i=0;i<n;i++) {
        int x=a[i]/t;
        ret--;
        ret+=x;
        if(a[i]%t!=0) ret++;
        if(ret>k) return false;
    }
    return true;
}
int main() {
    scanf("%d %d",&n,&k);
    int l=1;
    int r=0;
    for(int i=0;i<n;i++) {
        scanf("%d",&a[i]);
        r=max(r,a[i]);
    }
    while(l<r) {
        int m=(l+r)/2;
        if(cuts(m)) r=m;
        else l=m+1;
    }
    printf("%d",l);
	return 0;
}


Measured memory_bytes: 4528
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int AA=0;
  int BB=0;
  cin>>N;
  vector<long long>vec(N);
  vector<long long>A(0);
  vector<long long>B(0);
  for(int X=0;X<N;X++){
    cin>>vec.at(X);
    if(X%2==0){
      A.push_back(vec.at(X));
    }
    else{
      B.push_back(vec.at(X));
    }
  }
  if(N%2==0){
    for(int X=B.size()-1;X>=0;X--){
      if(X==0){
        cout<<B.at(X)<<" ";
      }
      else{
        cout<<B.at(X)<<" ";
      }
    }
    for(int X=0;X<A.size();X++){
      if(X==N-1){
        cout<<A.at(X)<<endl;
      }
      else{
        cout<<A.at(X)<<" ";
      }
    }
  }
  if(N%2==1){
    for(int X=A.size()-1;X>=0;X--){
      if(X==0){
        cout<<A.at(X)<<" ";
      }
      else{
        cout<<A.at(X)<<" ";
      }
    }
    for(int X=0;X<B.size();X++){
      if(X==N-1){
        cout<<B.at(X)<<endl;
      }
      else{
        cout<<B.at(X)<<" ";
      }
    }
  }
}

Measured memory_bytes: 6660
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;

int n;
int h[100005];

void init() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%d", &h[i]);
	}
}

void solve() {
	int tag = 0;
	for(int i = n; i > 1; i--) {
		if(h[i] < h[i-1]) {
			h[i-1]--;
		}
	}
	for(int i = n; i > 1; i--) {
		if(h[i] < h[i-1]) {
			tag = 1;
			break;
		}
	}
	if(tag == 1) printf("No");
	else printf("Yes");
}

int main() {
	init();
	solve();
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	string s,t;
	int ans=0;
	cin>>s>>t;
	for(int i=0;i<s.size();i++)
		ans+=s[i]!=t[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3800
N=int(input())
A=list(map(int,input().split()))
a=[0]*(10**5+1)
num=0
for i in range(N):
    s=A[i]
    a[s]+=1
    num+=s
Q=int(input())
ans=[]
for i in range(Q):
    B,C=map(int,input().split())
    a[C]+=a[B]
    num+=(C-B)*a[B]
    a[B]=0
    ans.append(num)
for i in ans:
    print(i)

Measured memory_bytes: 21092
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  string t = s;
  reverse(t.begin(),t.end());
  string left,right,left2,right2;
  int n = s.length();
  left = s.substr(0,(n-1)/2);
  left2 = left;
  reverse(left2.begin(),left2.end());
  right = s.substr((n+3)/2-1);
  right2 = right;
  reverse(right2.begin(),right2.end());
  if(s==t && left == left2 && right == right2)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string> 
#include <cstring>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
//#include <boost/multiprecision/cpp_int.hpp>

#define BIT(a) (1 << (a))
#define EPS (1e-10)

using namespace std;
//using namespace boost::multiprecision;

const long long MOD = 1000000007;
const int COUNTER_CLOCKWISE = 1;
const int CLOCKWISE = -1;
const int ONLINE_BACK = 2;
const int ONLINE_FRONT = -2;
const int ON_SEGMENT = 0;

class Point{
    public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {}
    
    Point operator+(Point p){return Point(x + p.x, y + p.y);}
    Point operator-(Point p){return Point(x - p.x, y - p.y);}
    Point operator*(double a){return Point(a * x, a * y);}
    Point operator/(double a){return Point(x / a, y / a);}

    bool operator < (const Point &p) const {
        return y != p.y ? y < p.y : x < p.x;
    }

    double norm(){return x * x + y * y;}
};
typedef Point Vector;
typedef vector<Vector> Polygon;

double cross(Vector a, Vector b){
    return a.x*b.y - a.y*b.x;
}

double dot(Vector a, Vector b){
    return a.x * b.x + a.y * b.y;
}

int ccw(Point p0, Point p1, Point p2){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if (cross(a, b) > EPS)return COUNTER_CLOCKWISE;
    if (cross(a, b) > -EPS)return CLOCKWISE;
    if (dot(a, b) < -EPS)return ONLINE_BACK;
    if (a.norm() < b.norm())return ONLINE_FRONT;

    return ON_SEGMENT;
}

Polygon andrewScan(Polygon s){
    Polygon u, l;
    if (s.size() < 3) return s;
    sort(s.begin(), s.end());
    u.push_back(s[0]);
    u.push_back(s[1]);
    l.push_back(s[s.size()-1]);
    l.push_back(s[s.size()-2]);
    
    for (size_t i = 2; i < s.size(); i++){
        for (size_t n = u.size(); n >= 2 && ccw(u[n-2], u[n-1], s[i]) == COUNTER_CLOCKWISE; n--){
            u.pop_back();
        }
        u.push_back(s[i]);
    }

    for (int i = (int)s.size() - 3; i >= 0; i--){
        for (size_t n = l.size(); n >= 2 && ccw(l[n-2], l[n-1], s[i]) == COUNTER_CLOCKWISE; n--){
            l.pop_back();
        }
        l.push_back(s[i]);
    }

    reverse(l.begin(), l.end());
    for (size_t i = u.size() - 2; i >= 1; i--) l.push_back(u[i]);

    return l;
}

long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

set<string> se;

int main(void){
    int X;
    cin >> X;
    for (int i = X; i >= 1; i--){
        for (int j = i-1; j >= 2; j--){
            int tmp = i;
            while (tmp % j == 0){
                tmp /= j;
            }
            if (tmp == 1){
                cout << i << endl;
                return 0;
            }
        }
    }
    cout << 1 << endl;

}   



Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main () {
  int N, M, ans;
  double sum = 0;
  ans = sum = 0;
  cin >> N >> M;
  int A[N+1];
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    sum += A[i];
  }
  double tmp = sum / (4 * M);
  // printf("%lf\n", tmp);
  sort(A, A+N, greater<int>());
  for (int i = 0; i < N; ++i) {
    if (A[i] >= tmp) {
      ++ans;
    }
  }
  if (ans >= M) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int x, t;
	cin >> x >> t;
	if(x > t)
		cout << x-t << endl;
	else
		cout << 0 << endl;
}

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

using namespace std;
int a[200005];
bool pos(int x,int k,int n){
    if(x<=0) return false;
    int cuts=0;
    for(int i=0;i<n;i++){
        int div=(a[i]-1)/x;
        cuts+=div;
    }
    return (cuts<=k);
}
int main()
{
    int n,k;
    cin>>n>>k;
    int lo=0,high=0,ans=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        high=max(high,a[i]);
    }
    ans=high;
    while(lo<=high){
        int mid=(lo+high)/2;
        //cout<<lo<<" "<<high<<" "<<mid<<"\n";
        if(pos(mid,k,n)){
            ans=mid;
            high=mid-1;
        }
        else lo=mid+1;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 4368
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second

typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const long double inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

long double x[55],y[55];
long double dif(int i,int j){
  return sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
}

long double px,py;

void Circumcenter(int a,int b,int c) {

	//辺
	long double eAB = dif(a,b);
	long double eBC = dif(b,c);
	long double eCA = dif(c,a);

	//角度(余弦定理)
	long double aCAB = acos((eCA*eCA + eAB*eAB - eBC*eBC) / (2 * eCA*eAB));
	long double aABC = acos((eAB*eAB + eBC*eBC - eCA*eCA) / (2 * eAB*eBC));
	long double aBCA = acos((eBC*eBC + eCA*eCA - eAB*eAB) / (2 * eBC*eCA));

	long double A = sin(2 * aCAB);
	long double B = sin(2 * aABC);
	long double C = sin(2 * aBCA);

	//外心の位置ベクトル(ベクトルの面積比の公式)

 if(-eAB+eBC+eCA<1e-8) return;
 if( eAB-eBC+eCA<1e-8) return;
 if( eAB+eBC-eCA<1e-8) return;
	
	px=(A*x[a] + B*x[b] + C*x[c]) / (A + B + C);
  py=(A*y[a] + B*y[b] + C*y[c]) / (A + B + C);

} 


int main(){
  int i,j,k;
  int n;
  cin>>n;
  long double ans=inf;
  for(i=0;i<n;i++){
    cin>>x[i]>>y[i];
  }
  if(n==2){
    cout<<fixed<<setprecision(15)<<dif(0,1)/2.00<<endl;
  }
  else{
    for(i=0;i<n;i++){
      for(j=i+1;j<n;j++){
        for(k=j+1;k<n;k++){
          long double R=0;
          Circumcenter(i,j,k);
          //cout<<px<<" "<<py<<endl;
          for(int l=0;l<n;l++) R=max(R,sqrt((x[l]-px)*(x[l]-px)+(y[l]-py)*(y[l]-py)));
          ans=min(ans,R);
        }
      }
    }
    for(i=0;i<n;i++){
      for(j=i+1;j<n;j++){
        px=(x[i]+x[j])/2.0;
        py=(y[i]+y[j])/2.0;
        long double R=0;
        for(int l=0;l<n;l++) R=max(R,sqrt((x[l]-px)*(x[l]-px)+(y[l]-py)*(y[l]-py)));
        ans=min(ans,R);
      }
    }
    cout<<fixed<<setprecision(15)<<ans<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 512
import java.util.*;

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

		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();

		long [] array = {a*c, a*d, b*c, b*d};
		long intMax = array[0];

        for(int i = 1; i < 4; i++) {
			if(intMax < array[i]) {
				intMax = array[i];
			}
		}
		System.out.println(intMax);
		return;
	}

}


Measured memory_bytes: 35644
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

int main()
{
	int a,b,c,k;cin>>a>>b>>c>>k;
	
	while(a >= b)
	{
		b*=2;
		k--;	
	}
	
	while(b >= c)
	{
		c*=2;
		k--;
	}
	
	if(k >= 0)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
 
int main(int argc, const char *argv[]) {
    int i, j, x, y, tmp;
    std::cin >> i >> j;
    if (i > j) {
        x = i;
        y = j;
    } else {
        x = j;
        y = i;
    }
    while (y > 0) {
        tmp = y;
        y = x % y;
        x = tmp;
    }
    std::cout << x << std::endl;
    return 0;
}

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

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

    int n, m;
    cin >> n >> m;

    vector<bool> AC(n, false);
    vector<int> Pe(n);
    for(int i = 0; i < m; i++){
        int p;
        string s;
        cin >> p >> s;
        if(s == "AC"){
            AC[p - 1] = true;
        }else{
            if(AC[p - 1]);
            else{
                Pe[p - 1]++;
            }
        }
    }

    int ac = 0, pe = 0;
    for(int i = 0; i < n; i++){
        if(AC[i]){
            ac++;
            pe += Pe[i];
        }
    }

    cout << ac << ' ' << pe << endl;

    return 0;
}

Measured memory_bytes: 640