akhauriyash/Code-Regression huggingface dataset:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

S = s()

for i in S:
    if i == "o":
        cnt += 1

a = len(S)
if cnt + (15-a) >= 8:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 10068
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;


int n;
ll k;
vi a;

vi memo;
ll roop;
int made;

void dfs(int i) {
    if(memo[a[i]] != -1) {
        roop = memo[i] - memo[a[i]] + 1;
        made = a[i];
        return;
    }
    memo[a[i]] = memo[i] + 1;
    dfs(a[i]);

}

int main() {
    cin >> n >> k;
    a.resize(n);
    rep(i, n) {
        int l;
        cin >> l;
        a[i] = l-1;
    }

    memo.assign(n, -1);
    memo[0] = 0;
    dfs(0);

    if(memo[made] >= k) {
        int i=0;
        rep(j, k) {
            i = a[i];
        }
        cout << i+1 << endl;
        return  0;
    }
    k -= memo[made];
    k %= roop;
    //cout << k << endl;
    int i_=made;
    rep(i, k) {
        i_ = a[i_];
    }
    cout << i_+1 << endl;
}

Measured memory_bytes: 4820
from collections import defaultdict
from bisect import bisect_right
N = int(input())
XYU = [None]*N
for i in range(N):
    x, y, u = input().split()
    XYU[i] = (int(x), int(y), u)
U, D = defaultdict(list), defaultdict(list)
R, L = defaultdict(list), defaultdict(list) 
Ru, Rd, Lu, Ld = defaultdict(list), defaultdict(list), defaultdict(list), defaultdict(list)
for x, y, u in XYU:
    if u == 'R':
        Ru[x+y].append(x)
        Rd[y-x].append(x)
        R[y].append(x)
    elif u == 'L':
        Lu[y-x].append(x)
        Ld[x+y].append(x)
        L[y].append(x)
    elif u == 'U':
        U[x].append(y)
    else:
        D[x].append(y)
ans = float('inf')
for x in U:
    if len(D[x]) > 0:
        D[x].sort()
        le = len(D[x])
        for y in U[x]:
            idx = bisect_right(D[x], y)
            if idx < le and ans > (D[x][idx]-y)/2:
                ans = (D[x][idx]-y)/2
for y in R:
    if len(L[y]) > 0:
        L[y].sort()
        le = len(L[y])
        for x in R[y]:
            idx = bisect_right(L[y], x)
            if idx < le and ans > (L[y][idx]-x)/2:
                ans = (L[y][idx]-x)/2
for k in Ru:
    Ru[k].sort()
for k in Lu:
    Lu[k].sort()
for k in Rd:
    Rd[k].sort()
for k in Ld:
    Ld[k].sort()
for x, y, u in XYU:
    if u == 'U':
        if len(Ru[x+y]) > 0:
            idx = bisect_right(Ru[x+y], x)-1
            if 0 <= idx < len(Ru[x+y]):
                ans = min(ans, x-Ru[x+y][idx])
        if len(Lu[y-x]) > 0:
            idx = bisect_right(Lu[y-x], x)
            if idx < len(Lu[y-x]):
                ans = min(ans, Lu[y-x][idx]-x)
    elif u == 'D':
        if len(Rd[y-x]) > 0:
            idx = bisect_right(Rd[y-x], x)-1
            if 0 <= idx < len(Rd[y-x]):
                ans = min(ans, x-Rd[y-x][idx])
        if len(Ld[x+y]) > 0:
            idx = bisect_right(Ld[x+y], x)
            if idx < len(Ld[x+y]):
                ans = min(ans, Ld[x+y][idx]-x)
if ans == float('inf'):
    print('SAFE')
else:
    print(int(ans*10))

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

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n, k; cin >> n >> k;
	if (k == 1)cout << 0 << endl;
	else cout << n - k << endl;
}

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

#define loop(n, i) for(int i=0;i<n;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using vec = vector<T>;

int S[30][300000] = {};
int main() {
    int n; cin >> n;
    vec<int> A(n);
    loop (n, i) cin >> A[i];

    loop (20, i) loop (n, j) {
        S[i][j + 1] = S[i][j] + ((A[j] >> i) & 1);
    }
    ll ans = 0;
    loop (n, i) {
        ll w = 1<<29;
        loop (20, j) {
            ll l = i, r = n;
            while (l + 1 < r) {
                ll m = (l + r) / 2;
                if (S[j][m + 1] - S[j][i] > 1) r = m;
                else l = m;
            }
            w = min(w, l - i + 1);
        }
        ans += w;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 25088
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    long long  a[n+1];
    for(int i=0;i<n+1;i++)
    cin>>a[i];
    long long  b[n];
    long long monster=0;
    for(int i=0;i<n;i++)
    cin>>b[i];
    for(int i=0;i<n;i++)
    {
        if(a[i]<=b[i])
        {
            monster+=a[i];
            b[i]-=a[i];
            if(a[i+1]<=b[i])
            {
                monster+=a[i+1];
                a[i+1]=0;
            }
            else
            {
                monster+=b[i];
                a[i+1]-=b[i];
            }
        }
        else
        {
            monster+=b[i];

            
            
        }
        
        
        
        
    }
    
    
        cout<<monster<<endl;
    
    return 0;
}

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

long long value[51];
long long dp[51][51]; 
int N,A,B;

bool comp(long long a,long long b)
{
    return a>b?true:false;
}
void init()
{
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	for(int i=1;i<=50;i++)
	{
		dp[i][0]=1;
		for(int j=1;j<=i;j++)
			dp[i][j]=dp[i-1][j-1]+dp[i-1][j];
	}
}
int main()
{
	
	init();
	while(cin>>N>>A>>B)
	{
		double ave=0;
		for(int i=0;i<N;i++)
			cin>>value[i];
		sort(value,value+N,comp);
	//	reverse(value,value+N);//大->小
		for(int i=0;i<A;i++) 
			ave+=value[i];
		ave/=A;
		int num=0,k=0;
		for(int i=0;i<N;i++)
		{
			if(value[i]==value[A-1])
			{
				num++;
				if(i<A)
					k++;
			}
		}	
		long long ans=0; 
		if(k==A)//前A个相同,可以增加个数 
		{
			for(int i=A;i<=B;i++)
				ans+=dp[num][i];
		}
		else
			ans+=dp[num][k];

 		printf("%.15f\n",ave);
 		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fbo find_by_order
#define ook order_of_key
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define MOD 998244353
#define MID (l+r)/2
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define mx 200003
#define pc(x) putchar_unlocked(x);
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds;
long long n,a[mx],jaw;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	if(a[1]>0){
		cout<<-1<<endl;
		return 0;
	}
	int now=0;
	for(int i=2;i<=n;i++){
		if(a[i]==now+1){
			jaw++;
		}
		else if(a[i]<=now){
			jaw+=a[i];
		}
		else{
			cout<<-1<<endl;
			return 0;
		}
		now=a[i];
	}
	cout<<jaw<<endl;
}




Measured memory_bytes: 1792
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

signed main(){
	ll K,A,B;
	cin >> K >> A >> B;
	ll DP[3] = {1,2};
	FOR(i,1,K){
		if(DP[0]>=A)DP[2] = max(DP[1]+1,DP[0]+B-A);
		else DP[2] = DP[1]+1;
		DP[0] = DP[1];
		DP[1] = DP[2];
	}
	cout << DP[min(2,K)] << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define all(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x,y)* mod_pow(kai(y,y), mod - 2, mod) % mod;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct UnionFind {
	vector<int> par;

	UnionFind(int n) : par(n, -1) { }

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

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};
int p[20];
bool b[20][20];
signed main() {
	int n, m;
	cin >> n >> m;
	rep(i, m) {
		int s;
		cin >> s;
		rep(j, s) {
			int d;
			cin >> d;
			d--;
			b[i][d] = true;
		}
	}
	rep(i, m) {
		cin >> p[i];
	}
	int ans = 0;
	rep(i, 1 << n) {
		int cnt[20];
		fill(cnt, cnt + m, 0);
		rep(j, n) {
			bool bo = (i >> j) & 1;
			rep(k, m) {
				if (bo&&b[k][j])cnt[k]++;
			}
		}
		rep(j, m) {
			if (cnt[j] % 2 != p[j])goto bed;
		}
		ans++;
	bed:;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
// E - Handshake

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int MOD = 1e9 + 7;

const ll MAX_N = 100000; // 100000だとなぜかWA
const ll MAX_A = 100000;

ll A[MAX_N];
ll A_csum[MAX_N + 1]; // 値が大きい側からの累積和
ll N, M;

// t <= Ax + Ay となる組み合わせの数を求める
// Ax = A[i]ごとに二分探索で数を求めて合計する -> O(NlogN)

ll get_n_comb(ll t) {
	ll result = 0;
	for (int i=0; i<N; i++) {
		ll Ay = t - A[i];
		ll idx = lower_bound(A, A+N, Ay) - A; // t <= Ax + Ay となる最初のインデックス
		result += (N - idx);
	}

	//cout << "t=" << t << " -> comb=" << result << endl;

	return result;
}

// t <= Ax + Ay となる組み合わせの数がk以上となる最大のtを求める
ll get_max_t(ll k) {
	ll ok = 0;
	ll ng = 2 * MAX_A + 1;

	while(ng - ok > 1) {
		ll trying = (ok + ng) / 2;

		if (get_n_comb(trying) >= k) {
			ok = trying;
		} else {
			ng = trying;
		}
	}

	return ok;
}

// t <= Ax + Ay となる組み合わせについて総和を求める
ll get_sum_ge(ll t) {
	ll result = 0;
	for (int i=0; i<N; i++) {
		ll Ay = t - A[i];
		ll idx = lower_bound(A, A+N, Ay) - A; // t <= Ax + Ay となる最初のインデックス
		result += (A[i] * (N - idx)) + A_csum[idx]; // Axの和 + Ayの和
	}

	//cout << "t=" << t << " sum=" << result << endl; // **** debug ****

	return result;
}

int main() {

	cin >> N >> M;

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

	sort(A, A+N);

	// 値が大きい側からの累積和を作成（get_sum_ge()で用いる）
	A_csum[N-1] = A[N-1];
	for (int i=N-2; i>=0; i--) {
		A_csum[i] = A[i] + A_csum[i+1];
	}

	// t <= Ax + Ay となる組み合わせの数がM以上となる最大のtを求める
	ll max_t = get_max_t(M);
	//cout << "max_t = " << max_t << endl; // **** debug ****

	// get_sum_ge(t)では t == Ax + Ay となる握手が複数存在する場合に余分な握手が含まれてしまうので
	// （(t == max_t) の和） + （(t >= max_t + 1) の和）で求める
	ll n_max_t = M - get_n_comb(max_t + 1); // t == max_t となる場合の数
	ll ans = (max_t * n_max_t) + get_sum_ge(max_t + 1);

	cout << ans << endl;

	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef complex<ld> cd;

const ll mod = 1000000007;

int main(){

// #ifndef  ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<setprecision(30);

    int n;
    char ch;
    int f[26] = {0};
    cin>>n;
    for(int i = 0; i < n; i++){
    	cin>>ch;
    	f[ch-'a']++;
    }
    ll ans = 1;
    for(int i = 0; i < 26; i++){
    	(ans *= (f[i] + 1)) %= mod;
    }
    cout<<(ans + mod - 1)%mod<<endl;
}


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

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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  vector <ll> v(n);
  rep(i, n) cin >> v.at(i);
  ll res = 0;
  rep(i, n-1) res += min(abs(v.at(i)-v.at(i+1))*a, b);
  cout << res << endl;
}

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

using namespace std;

int main()
{
    int N,M,C;
    cin >> N >> M >> C;
    vector<int> B(M);
    for (int i = 0;i < M;i++) {
        cin >> B[i];
    }
    vector<vector<int>> A(N);
    for (int i = 0;i < N;i++) {
        vector<int> k(M);
        A[i] = k;
        for(int j = 0;j < M;j++){
            cin >> A[i][j];
        }
   }
    int to = 0;
    int ans = 0;
    for (int i = 0;i < N;i++) {
        to = 0;
        for(int j = 0;j < M;j++){
            to += A[i][j]*B[j];
        }
        if(to + C > 0){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
N, WW = map(int, input().split())
W, V = [], []
for _ in range(N):
    _w, _v = list(map(int, input().split()))
    if _w > WW:
        continue
    W.append(_w)
    V.append(_v)

dp = [[0] * (WW+1) for _ in range(N+1)]
for i in range(1, N+1):
    # i := 1...N
    for j in range(1, WW+1):
        # j := 0...WW
        
        wi = W[i-1]
        vi = V[i-1]
        if j-wi < 0:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-wi] + vi)

print(dp[N][WW])

Measured memory_bytes: 120144
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define REP1(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Int = long long;
 
//INT_MAX = 2147483647;
//LLONG_MAX = 9223372036854775807;
//ULLONG_MAX = 18446744073709551615;
const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;
 
//少数点表示
//cout << std::fixed << std::setprecision(14) << 値
 
int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int n,x=0;
    cin >> n;
    rep(i,10){
        x+=1000;
        if(x>=n) break;
    }
    cout << abs(x-n);
    
    return 0;
}


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

const long long MOD = 1000000007;

long long dp[100010];
long long st[100010];

void add(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void solve(long long N, long long M, std::vector<long long> a){
    for(ll i = 0; i < (ll)100010; ++i){
        dp[i] = 0;
        st[i] = 1;
    }
    for(ll i = 0; i < a.size(); ++i) st[a[i]] = -1;
    dp[0] = 1;
    for(ll i = 0; i <= N; ++i){
        if(i+1 <= N && st[i+1] > 0 && st[i] > 0) add(dp[i+1], dp[i]);
        if(i+2 <= N && st[i+2] > 0 && st[i] > 0) add(dp[i+2], dp[i]); 
    }
    //for(ll i = 0; i < N; ++i) cout << dp[i] << endl;
    cout << dp[N] << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, M, std::move(a));
    return 0;
}


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

long long N, C = 1; vector<long long>R;

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

int main() {
	cin >> N;
	for (int i = 2; i*i <= N; i++) {
		if (N%i == 0) {
			N /= i; R.push_back(i);
			if (N%i == 0) { cout << "-1" << endl; return 0; }
		}
	}
	if (N >= 2) { R.push_back(N); }
	if (R.size() <= 1) { cout << "1" << endl; return 0; }
	if (R.size() >= 3 || R[0] == 2) { cout << "-1" << endl; return 0; }
	long long a = R[0], b = R[1], c = 1, s = -1, t = -1;
	for (int i = 1; i <= b / 2; i++) {
		c *= a; c %= (b - 1);
		if (c == 1) { s = i; break; }
	}
	c = 1;
	for (int i = 1; i <= a / 2; i++) {
		c *= b; c %= (a - 1);
		if (c == 1) { t = i; break; }
	}
	if (s == -1 || t == -1) { cout << "-1" << endl; }
	else { cout << s*t / gcd(s, t) << endl; }
	return 0;
}


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

typedef long long ll;

#define pb push_back
#define MS(x,y) memset((x),(y),sizeof((x)))
#define mn 1000000

using namespace std;

int niza[100001];
int n;
int dp[100001];

int solve (int i) {
    if (dp[i] != -1) return dp[i];
    if (i >= n-1) return 0;

    int pat1 = abs(niza[i]-niza[i+1])+solve(i+1);
    int pat2 = abs(niza[i]-niza[i+2])+solve(i+2);

    if (i == n-2) return dp[i] = pat1;
    else return dp[i] = min(pat1,pat2);
}

int main()
{
    #if LOCAL_DEBUG
        fstream cin("in.txt");
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;

    for (int i = 0; i<n; i++) cin>>niza[i];
    for (int i = 0; i<n; i++) dp[i] = -1;

    cout<<solve(0)<<endl;

    return 0;
}


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

using namespace std;
int main()

{
int r,b,g;
cin>>r>>g>>b;

if((r * 100 + g * 10 + b) % 4 == 0)
  cout<< "YES" <<endl;
else
  cout<< "NO" <<endl;
    
  return 0;
}

Measured memory_bytes: 256
/***************************************************************
	File name: C.cpp
	Author: ljfcnyali
	Create time: 2020年01月12日 星期日 19时58分27秒
***************************************************************/
#include<bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for ( int i = (a), _end_ = (b); i <= _end_; ++ i ) 
#define mem(a) memset ( (a), 0, sizeof ( a ) ) 
#define str(a) strlen ( a ) 
#define pii pair<int, int>
typedef long long LL;

const int maxn = 1e5 + 10;

int n, m, sum1, sum2, p[maxn];
bool flag[maxn];
char s[maxn];

int main()
{
    scanf("%d%d", &n, &m);
    REP(i, 1, m)
    {
        int x; scanf("%d %s", &x, s);
        if ( s[0] == 'A' ) 
        {
            if ( !flag[x] ) ++ sum1;
            flag[x] = true;
        }
        else
        {
            if ( !flag[x] ) ++ p[x];
        }
    }
    REP(i, 1, n) if ( flag[i] ) sum2 += p[i];
    printf("%d %d\n", sum1, sum2);
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pk(x) cout<<(x)<<" ";
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a[100001],b[100001],c[100001],d,n,m,x,y,z,h,w,k,sum,mi=inf,ma=-inf,ans,s,t,l,r,res,tmp,itr,p,q;
bool flag;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dx8[8]={1,1,0,-1,-1,-1,0,1},dy8[8]={0,1,1,1,0,-1,-1,-1};
char cha;
string st;
typedef map<ll, ll> imap;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pair<ll,ll> > VP;
P pa;
int main(){
    cin>>n>>k;
    VL ve;
    rep(i,n){
        cin>>tmp;
        ve.pb(tmp);
    }
    sort(all(ve));
    rep(i,n-k){
        sum+=ve[n-1-(k+i)];
    }
    p(sum);
    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=1e5;

int N;
ll A[MAX_N],B[MAX_N],C[MAX_N];

int main(){
	cin>>N;
	REP(i,N)cin>>A[i];
	REP(i,N)cin>>B[i];
	REP(i,N)cin>>C[i];
	sort(A,A+N);
	sort(B,B+N);
	sort(C,C+N);
	ll ans=0;
	REP(i,N){
		ans+=(ll)(lower_bound(A,A+N,B[i])-A)*(C+N-upper_bound(C,C+N,B[i]));
	}
	cout<<ans<<endl;
	return 0;
}

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

#define fr(i,b,e) for(int i=(b); i!=(e); ++i)
#define rep(i,e) for(int i=0; i!=(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long int ll;
using graph = vector<vector<int>>;
using edgedp = vector<vector<pair<int,ll>>>;
constexpr int INF=1000000;
//constexpr int MOD=998244353;
constexpr int MOD=1e9+7;

int calc_pw(ll n, ll p){
    if(n/p==0){
        return 0;
    }else{
        return calc_pw(n/p,p)+1;
    }
}


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

    int a;
    ll b,n;
    cin >> a >> b >> n;
    if(n>=b-1){
        cout << (a*(b-1))/b << endl;
    }else{
        cout << (a*n)/b << endl;
    }
}   




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

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

int go(int nowx, int nowy, bool mp[92][92])
{
	int mx = 0;
	mp[nowx][nowy] = false;
	for (int i = 0; i < 4; i++){
		int nextx = nowx + dx[i], nexty = nowy + dy[i];
		if (mp[nextx][nexty]) mx = max(mx, go(nextx, nexty, mp));
	}
	mp[nowx][nowy] = true;
	return mx + 1;
}

int main()
{
	while (true){
		int m, n;
		cin >> m >> n;
		if (!m&&!n) break;

		bool mp[92][92];
		memset(mp, 0, sizeof mp);
		int mx = 0;
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= m; j++){
				cin >> mp[i][j];
			}
		}

		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= m; j++){
				if (mp[i][j]) mx = max(mx, go(i, j, mp));
			}
		}
		cout << mx << endl;
	}
	return 0;
}

Measured memory_bytes: 1176
import java.util.Scanner;

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

        int[] dp = new int[100010];
        dp[0] = 0;

        for (int i = 1; i <= 100000; i++) {
            dp[i] = Integer.MAX_VALUE;
            int pow = 1;
            while (pow <= i) {
                dp[i] = Math.min(dp[i], dp[i - pow] + 1);
                pow *= 6;
            }
            pow = 1;
            while (pow <= i) {
                dp[i] = Math.min(dp[i], dp[i - pow] + 1);
                pow *= 9;
            }
        }
        System.out.println(dp[n]);
    }
}

Measured memory_bytes: 21076
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n;
    cin >> n;
    double x[n],dist[4] = {};
    for(int i = 0;i < n;i++)
    {
        cin >> x[i];
    }
    for(int i = 0;i < n;i++)
    {
        double y;
        cin >> y;
        dist[0] += fabs(x[i] - y);
        dist[1] += pow(x[i] - y,2);
        dist[2] += pow(fabs(x[i] - y),3);
        dist[3] = max(dist[3],fabs(x[i] - y));
    }
    dist[1] = sqrt(dist[1]);
    dist[2] = cbrt(dist[2]);
    for(int i = 0;i < 4;i++)
    {
        cout << fixed << setprecision(20) << dist[i] << "\n";
    }

    return 0;
}


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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
typedef long long ll;

int dp[101];
int main() {
  int N; cin >> N;
  dp[0] = 1;
  rep(i, 101) {
    if(i >= 4)dp[i] += dp[i - 4];
    if(i >= 7)dp[i] += dp[i - 7];
  }
  if (dp[N] > 0) dump("Yes");
  else dump("No");
  //rep(i, 101) {
  //  cout << i  << ":::" << dp[i] << endl;
  //}
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.math.BigInteger;

public class Main implements Runnable {
	
	//static int mod = 1000000007;
	
    public static void main(String[] args) {
    	new Thread(null, new Main(), "", 1024 * 1024 * 1024).start();
    }
    
    public void run() {
        PrintWriter out = new PrintWriter(System.out);
        FastScanner sc = new FastScanner();
        
        int r = sc.nextInt();
        
        out.println(3*r*r);
        
        out.flush();
    }

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}
	public int[] nextintArray(int n){
		int[] a = new int[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public long[] nextlongArray(int n){
		long[] a = new long[n];
		for(int i=0;i<n;i++){
			a[i] = nextLong();
		}
		return a;
	}
	public Integer[] nextIntegerArray(int n){
		Integer[] a = new Integer[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public int[][] nextintMatrix(int h, int w){
		int[][] mat = new int[h][w];
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				mat[i][j] = nextInt();
			}
		}
		return mat;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 24788
#include <stdio.h>

int main(void)
{
	int H,W,a,b,c;
	while(1){
	scanf("%d %d",&H,&W);
	if(H==0 && W==0){break;}
	for(b=1;b<=H;b++){
	for(a=1;a<=W;a++){
	c = a+b;
	if(c %2== 0){printf("#");
	}else{printf(".");
	}
	}
	printf("\n");
	}
	printf("\n");
	}
return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

string mp[110];

int main(){
    int n, m, d, ans = 0;
    cin>>n>>m>>d;
    for(int y = 0; y < n; y++){
        cin>>mp[y];
    }
    for(int y = 0; y < n; y++){
        for(int x = 0, cnt = 0; x < m; x++){
            if(mp[y][x] == '#')cnt=0;
            else cnt++;
            if(cnt >= d)ans++;
        }
    }
    for(int x = 0; x < m; x++){
        for(int y = 0, cnt = 0; y < n; y++){
            if(mp[y][x] == '#')cnt=0;
            else cnt++;
            if(cnt >= d)ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

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

    ll i = 0;
    rep(j, s.size()){
        if(s[j] == '+'){
            i++;
        }else{
            i--;
        }
    }

    cout << i << endl;
    return 0;
}


Measured memory_bytes: 256
macro_rules! read_line_to_tuple {
    ( $( $t:ty ),* ) => {{
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).unwrap();
        let mut iter = input.split_whitespace();
        ( $( iter.next().unwrap().parse::<$t>().unwrap() ),* )
    }};
}

use std::collections::HashMap;
use std::cmp::min;

fn main() {
    let (n, x, m) = read_line_to_tuple!(usize, usize, usize);

    let mut map: HashMap<usize, usize> = HashMap::new();
    let mut v = Vec::with_capacity(m);
    let mut a = x;
    for i in 0..(min(n, m)) {
        if map.contains_key(&a) {
            break;
        } else {
            map.insert(a, i);
            v.push(a);
            a = a * a % m;
        }
    }

    let mut ans = 0;
    if n <= v.len() {
        for i in 0..n {
            ans += v[i];
        }
        return println!("{}", ans);
    }
    let left = map[&a];
    let right = v.len();
    for i in 0..left {
        ans += v[i];
    }
    for k in left..(right - 1) {
        v[k + 1] += v[k];
    }
    let q = (n - left) / (right - left);
    let r = (n - left) % (right - left);
    ans += q * v[right - 1] + if r == 0 { 0 } else { v[left + r - 1] };
    println!("{}", ans);
}

Measured memory_bytes: 3972
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort((x).rbegin(),(x).rend())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl
const ll LINF = (1LL << 62) - 1;
const int INF = (1 << 30) - 1;
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;}
// clang-format on

void solve(long long N, std::vector<long long> A) {
  if (find(all(A), 0) != A.end()) {
    ANS(0);
    return;
  }
  ll L = 1e18;
  SORT_DESC(A);
  ll ans = 1;
  rep(i, N) {
    if ((L + 1) / ans < A[i] || A[i] * ans > L) {
      ANS(-1);
      return;
    }
    ans *= A[i];
  }
  ANS(ans);
}

// clang-format off
int main() {
  long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 3968
#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 1000000007
#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 h,w; cin>>h>>w;
    vector<P> a(h+w);
    rep(i,h){
        cin>>a[i].first;
        a[i].second=0;
    }
    rep(i,w){
        cin>>a[i+h].first;
        a[i+h].second=1;
    }
    sort(all(a));

    int ans=0,vert=h+1,side=w+1;
    rep(i,h+w){
        if(a[i].second==0){
            ans+=a[i].first*side;
            vert--;
        }else{
            ans+=a[i].first*vert;
            side--;
        }
    }
    cout<<ans<<endl;
    

}

Measured memory_bytes: 3456
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

public class Main {

	static int MAX = 999 + 51;
	static char TERM = 'Z';

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int n = parseInt(line);
			if (n == 0) break;

			//load and pre proc.
			char[][] board = new char[n][MAX];
			int check = 0;
			for (int i = 0; i < n; i++) {
				line = br.readLine();
				for (int j = 0; j < line.length(); j++) {
					char c = line.charAt(j);
					board[i][j] = c;
					if (c == '.') {
						check++;
						if (line.charAt(j + 1) >= 'a') {
							board[i][j] = '+';
							check--;
						}
					}
				}
				board[i][line.length()] = TERM;
			}

			//write off
			//vertical bar.
			for (int j = 0; j < MAX; j++) {
				for (int i = n - 1; i > 0; i--) {
					char c = board[i][j];
					if (c == '+') {
						for (int k = i - 1; k > 0; k--) {
							if (board[k][j] == '.') {
								board[k][j] = '|';
								check--;
							} else break;
						}
					} else if (c == '.') {
						board[i][j] = ' ';
						check--;
					}
				}
				if (check == 0) break;
			}

			//ans.
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < MAX; j++) {
					char c = board[i][j];
					if (c == TERM) break;
					System.out.print(board[i][j]);
				}
				System.out.println();
			}
		} //end while
	} //end main
}

Measured memory_bytes: 66680
/***************************************** SHORT - TEMPLATE ***************************************************/
#pragma optimization_level 3
#include<bits/stdc++.h>
using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)		
#define  all(x)         (x).begin(),(x).end()
#define  newl           cout<<"\n"
#define  pb             push_back
#define  s              second
#define  f              first
#define  ll             long long
#define  vll            vector<ll>
#define  MOD            1000000007
#define  INF            LLONG_MAX
#define  N              100008

/***************************************** FUNCTIONS / DECLARATIONS ********************************************/
ll t=1;

/***************************************** MAIN FUNCTION - DRIVER *******************************************************/
void MAIN(){
	ll n;
	cin>>n;
	cout<<(n/500)*1000+((n%500)/5)*5;
	
}

int main(){
	fastio;//cin>>t;
	while(t--){
		MAIN();
	}
}

Measured memory_bytes: 256
import heapq

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

a = list(map(int, input().split()))

valueheap = [x * (-1) for x in a]

heapq.heapify(valueheap)

for _ in range(M):

    maxvalue = heapq.heappop(valueheap) * (-1)

    maxvalue //= 2

    maxvalue *= -1

    heapq.heappush(valueheap, maxvalue)

print(sum(valueheap) * (-1))


Measured memory_bytes: 14180
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <queue>
#include <stack>
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1e9 + 7;

int main(void)
{
    int n;
    vector<string> s;
    vector<pair<int, string>> ans;
    vector<string> ans2;
    int i;

    cin >> n;

    s.resize(n);

    rep(i, 0, n)
    {
        cin >> s[i];
    }

    sort(s.begin(), s.end());

    ans.push_back(make_pair(0, s.front()));

    rep(i, 1, n)
    {
        if (ans.back().second == s[i])
        {
            ans.back().first++;
        }
        else
        {
            ans.push_back(make_pair(0, s[i]));
        }
    }

    sort(ans.rbegin(), ans.rend());

    rep(i, 0, ans.size())
    {
        ans2.push_back(ans[i].second);

        if (ans[i].first != ans[i + 1].first)
        {
            break;
        }
    }

    sort(ans2.begin(), ans2.end());

    for (auto &x : ans2)
    {
        cout << x << endl;
    }
}

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

#define M 200005
#define MOD 1000000007
#define PI 3.14159265358979323846
#define ep emplace_back
#define mk make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> PII;
typedef pair<lli,lli> PLL;

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

	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);

	string s;
	cin>>s;

	cout<<s[0]<<s[1]<<s[2]<<"\n";
	

}

Measured memory_bytes: 3612
n=int(input());l=[list(map(int,input().split()))for i in[0]*n];a=[0]*n;d=1;k=n*(n-1)
while sum(a)<k and d<9999:
 L=[0]*n;y=0;d+=1
 for i in range(n):
  if a[i]<n-1:
   x=l[i][a[i]]-1
   if l[x][a[x]]-1==i and L[x]+L[i]<1:
    a[i]+=1;a[x]+=1;L[i]=L[x]=y=1
print([k//2,d*y-1][d*y<9999])

Measured memory_bytes: 53980
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
 
int main() {
 
  int N; cin >> N;
  vector<int> vec(N);
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }

  sort(vec.begin(), vec.end());
  bool find = 0;
  for(int i = 0; i < N-1; i++){
    if(vec.at(i) == vec.at(i+1)){
      find = 1;
      break;
    }
  }
  if(find) cout << "NO" << endl;
  else cout << "YES" << endl;
}

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

public class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader reader =
            new BufferedReader (new InputStreamReader (System.in));
        String[] arr = reader.readLine().split (" ");
        int N;
        N = Integer.parseInt (arr[0]);
        Integer[] arrHon = {2, 4, 5, 7, 9};
        Integer[] arrPon = {0, 1, 6, 8};
        if (Arrays.asList (arrHon).contains (N % 10)) {
            System.out.println ("hon");
            return;
        }
        if (Arrays.asList (arrPon).contains ((int)(N % 10))) {
            System.out.println ("pon");
            return;
        }
        System.out.println ("bon");
        return;
    }
}

Measured memory_bytes: 32320
#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>;

int main() {
  int x, y;
  cin >> x >> y;

  bool ans = false;
  for(int i = 0; i <= x; i++) {
    int a = i * 2 + (x - i) * 4;
    if(a == y) {
      ans = true;
      break;
    }
  }

  if(ans) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3628
package main

import (
	"fmt"
)

func main() {
	var a, b int

	fmt.Scanf("%d%d", &a, &b)

	if b < 10 {
		a = a*10 + b
	} else if b != 100 {
		a = a*100 + b
	} else {
		a = a*1000 + b
	}

	for i := 1; i*i <= a; i++ {
		if i*i == a {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans;
    ll pre=0;
    ll nex=0;
    char a;
    char b;
    cin>>a>>b;
    pre=(a-48)*10+(b-48);
    cin>>a>>b;
    nex=(a-48)*10+(b-48);

    if( (pre>0&&pre<=12)&& (nex>0&&nex<=12))cout <<"AMBIGUOUS"<<endl;
    else if(pre>0&&pre<=12)cout <<"MMYY"<<endl;
    else if(nex>0&&nex<=12)cout <<"YYMM"<<endl;
    else cout <<"NA"<<endl;

    return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		
		Scanner stdIn = new Scanner(System.in);
		
		int iningNum = stdIn.nextInt();
		
		while(0 < iningNum){
			/*
			 * int baseStatus
			 * 
			 * 0=走者なし
			 * 1=1塁走者のみ
			 * 2=2塁走者のみ
			 * 4=3塁走者のみ,
			 * 
			 * 3=1,2塁のみ(1+2)
			 * 5=1,3塁のみ(1+4)
			 * 以下略
			 */
			int outCount = 0;
			int score = 0;
			int baseStatus = 0;
			
			while(outCount < 3){
				String event = stdIn.next();
				if(event.equals("OUT")){
					outCount++;
				}else if(event.equals("HIT")){
					switch(baseStatus){
					case 0:
						baseStatus = 1;
						break;
					case 1:
						baseStatus = 3;
						break;
					case 2:
						baseStatus = 5;
						break;
					case 3:
						baseStatus = 7;
						break;
					case 4:
						baseStatus = 0;
						score++;
						break;
					case 5:
						baseStatus = 3;
						score++;
						break;
					case 6:
						baseStatus = 5;
						score++;
						break;
					case 7:
						score++;
						break;
					}
				}else{
				switch(baseStatus){
					case 0:
						score += 1;
						baseStatus = 0;
						break;
					case 1:
						score += 2;
						baseStatus = 0;
						break;
					case 2:
						score += 2;
						baseStatus = 0;
						break;
					case 3:
						score += 3;
						baseStatus = 0;
						break;
					case 4:
						score += 2;
						baseStatus = 0;
						break;
					case 5:
						score += 3;
						baseStatus = 0;
						break;
					case 6:
						score += 3;
						baseStatus = 0;
						break;
					case 7:
						score += 4;
						baseStatus = 0;
						break;
					}
				}
			}
			System.out.println(score);
			iningNum--;
		}
	}
}

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

const int MOD = 1000000007;
const int INF = 100000000;
typedef pair<int, int> P;
const int MAX_H = 20, MAX_W = 20;
int H, W;
int sy = 0, sx = 0;
int gy = 0, gx = 0;
char maze[MAX_H][MAX_W];

int d[MAX_H][MAX_W];

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

int bfs();

int main()
{
  cin >> H >> W;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      cin >> maze[i][j];
    }
  }
  int ans = 0;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      for (int k = 0; k < H; k++)
      {
        for (int l = 0; l < W; l++)
        {
          if (maze[i][j] == '.')
            sy = i, sx = j;
          if (maze[k][l] == '.')
            gy = k, gx = l;
          if (maze[sy][sx] == '#' or maze[gy][gx] == '#')
            continue;
          if (sy != gy or sx != gx)
          {
            int now = bfs();
            if (now != INF)
              ans = max(ans, now);
          }
        }
      }
    }
  }
  cout << ans << endl;
}

int bfs()
{
  queue<P> que;
  // 全ての点をINFで初期化
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      d[i][j] = INF;
    }
  }
  // スタート地点をキューに入れ，その点の距離を0にする
  que.push(P(sy, sx));
  d[sy][sx] = 0;

  // キューが空になるまでループ
  while (que.size())
  {
    // キューの先頭を取り出す
    P p = que.front();
    que.pop();
    // 取り出してきた状態がゴールなら探索をやめる
    if (p.first == gy && p.second == gx)
    {
      break;
    }
    // 移動4方向をループ
    for (int i = 0; i < 4; i++)
    {
      // 移動した後の点を(nx, ny)とする
      int ny = p.first + dy[i], nx = p.second + dx[i];

      // 移動が可能かの判定と既に訪れたことがあるかの判定(d[nx][ny] != INFなら訪れたことがある)
      if (0 <= ny && ny < H && 0 <= nx && nx < W && maze[ny][nx] != '#' && d[ny][nx] == INF)
      {
        // 移動できるならキューに入れ，その点の距離をpからの距離+1で確定する
        que.push(P(ny, nx));
        d[ny][nx] = d[p.first][p.second] + 1;
      }
    }
  }
  return d[gy][gx];
}


Measured memory_bytes: 384
import fractions as f
for i in range(int(input())):
 a,b,c,d=list(map(int,input().split()))
 g=f.gcd(b,d)
 if a<b or b>d or a-((a-b)//g+1)*g>c:
  print("No")
 else:
  print("Yes")

Measured memory_bytes: 5048
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<string> a(3);
    cin >> a[0] >> a[1] >> a[2];
    int odp = 0 ;
    for (int i = 0; i < n; ++i)
    {
        set<char> S;
        for (int j = 0; j < 3; ++j)
            S.insert(a[j][i]);
        if (S.size() == 2)
            ++odp;
        if (S.size() == 3)
            odp += 2;
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

int main(){
  int n,k; cin >>n >>k;
  vector<int>v(n);
  for(int i=0; i<n; i++) cin >>v[i];
  sort(v.begin(),v.end());
  int sum=0;
  for(int i=0; i<k; i++) sum+=v[i];
  cout <<sum;
return 0;}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <cmath>
#include <math.h>
#include <stdio.h>
using namespace std;
int main(){
    double a,b,c,pi;
    cin>>a>>b>>c;
    pi=acos(-1);
    printf("%.8f\n",a*b*sin(c*pi/180)/2);
    printf("%.8f\n",sqrt(a*a+b*b-2*a*b*cos(c*pi/180))+a+b);
    printf("%.8f\n",b*sin(c*pi/180));
}
    


Measured memory_bytes: 3360