akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
ll ans = -999999999999;
int a[20];
int N;
bool F[100][11];
ll P[100][11];
void func(void) {
	ll score = 0;
	bool ok = false;
	REP(i, N) {
		int cnt = 0;
		REP(j, 10) {
			if (a[j] == 1)ok = true;
			if (F[i][j] == 1)if (a[j] == 1)cnt++;
		}
		score += P[i][cnt];
	}
	if(ok)ans = max(ans, score);
}
void dfs(int pos) {
	if (pos == 10) {
		func();
		return;
	}
	a[pos] = 0; dfs(pos + 1);
	a[pos] = 1; dfs(pos + 1);
}
int main() {
	cin >> N;
	REP(i, N)REP(j, 10)cin >> F[i][j];
	REP(i, N)REP(j, 11)cin >> P[i][j];
	dfs(0);
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;


int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b && b == c) cout << "Yes" << endl;
    else cout << "No" << endl;

    

    return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
alist=list(map(int,input().split()))
#print(alist)

def num_cut(x):
  if x==0:
    return float("inf")
  
  ret=0
  for a in alist:
    ret+=-(-(a-x)//x)
  return ret

#for i in range(1,max(alist)):
#  print(i,num_cut(i))

l=1
r=max(alist)+1
while l<=r:
  mid=(l+r)//2
  #print(l,mid,r)
  
  if num_cut(mid-1)>K and num_cut(mid)<=K:
    print(mid)
    break
  elif num_cut(mid)<=K:
    r=mid
  else:
    l=mid

Measured memory_bytes: 94024
A, B = map(int, input().split())
S = list(input())

N = [str(a) for a in range(10)]
ans = 'Yes'
for i, s in enumerate(S):
    if i != A:
        if not s in N:
            ans = 'No'
    else:
        if s != '-':
            ans = 'No'
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
const int md=1000000007;
char c[3333];
int dp[3333][3333],n;
int main(){
	scanf("%d%s",&n,c+1);
	dp[0][1]=1;
	int i,j;
	for(i=1;i<n;++i){
		if(c[i]=='<'){
			ll s(0);
			for(j=1;j<i+2;++j){
				dp[i][j]=s;
                s+=dp[i-1][j];
                if(s>=md) s-=md;
			}
		}else{
			ll s(0);
			for(j=i;j;--j){
				s+=dp[i-1][j];
				if(s>=md) s-=md;
				dp[i][j]=s;
			}
		}
	}
	ll ans(0);
	for(i=1;i<=n;++i) ans+=dp[n-1][i];
	printf("%d\n",ans%md);
	return 0;
}

Measured memory_bytes: 39808
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
//stack<int> st;
// cout << << endl;
// cin >> ;
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
template<typename T>
T gcd(T a, T b){
	return b != 0 ? gcd(b, a % b) : a;
}    
 
int main(){
    ll x=-10,y=-10,d=0,n,m,h,k,max=-100000,min=10000000,ans=0,count=1,sum=0;
    string s;
    cin >> n >> s;
    VI w(n+1);
    VI e(n+1);
    VI c(n);
    w[0] = 0;
    e[n] = 0;
    for(int i=1; i<n+1; i++){
        if(s[i-1]=='W')
            w[i]= w[i-1]+1;
        else w[i] = w[i-1];
    }
    for(int i=n-1; i>=0; i--){
        if(s[i]=='E')
            e[i]=e[i+1]+1;
        else e[i] = e[i+1];
    }
    for(int i=1;i<=n;i++){
        c[i-1]=w[i]+e[i-1];
    }
    
    for(int i=0;i<n;i++){
        if(min > c[i])
            min = c[i];
    }

    cout << min-1 << endl;
    return 0;
}

Measured memory_bytes: 4228
#include<bits/stdc++.h>
using namespace std;
int check(int);
int main()
{
  int n,s;
  cin>>n;
  for(int i=1;i<=n;i++)
  {
    if(check(i))
      s++;
  }
  cout<<s;
  return 0;
}
  
  int check(int n)
  { int p=0;
    while(n!=0)
    {
      n=n/10;
      p++;
    }
   if(p%2==0)
     return 0;
   else return 1;
  }

Measured memory_bytes: 256
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define F first
#define S second
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr> 
#define pr pair<int, int> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define vout(v) for (auto z: v) cout << z << " "; cout << endl;

#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {vector<string>v; stringstream ss(s); string x;
while (getline(ss, x, c))v.emplace_back(x); return move(v);} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {
cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}

const int M = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;
ll vis[N],res[N];

int solve() 
{
	//happy coding

	int n;
	cin>>n;
	string s;
	cin>>s;

	Unique(s);
	cout<<s.size()<<endl;
	
	return 0;
}
int main(){
	int test = 1;
  	//scanf("%d", &test);
  	while (test--)solve();return 0;
}

Measured memory_bytes: 3764
// Best practice

#include<bits/stdc++.h>

#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define in(x) 		scanf("%d", &x)
#define echo(x)		printf("%d", x)
#define inf 		(int)(1e18)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;

#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}

// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };


// Code from Here -------------------------------------------------------------------------------


signed main() {
	tezz


	int n,k;
	cin >> k >> n;
	int p;
	map<int,int> mp;
	for(int i=0; i<n; i++){
		cin >> p;
		mp[p]++;
	}
	for(int i=0; i<100; i++){
		
		if(!mp[k-i]){
			cout << k-i;
			return 0;
		}
		if(!mp[k+i]){
			cout << k+i;
			return 0;
		}
	}

	return 0;
}  


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    int n,k,r=0,l=0,ans=0;
    string s;
    cin >> n >> k >> s;
    rep(i,n-1){
        if(s[i]==s[i+1]) ans++;
    }
    ans = min(n-1,ans+2*k);
    cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
    private static Scanner scanner;
    public static void main(String[] args){
        scanner = new Scanner(System.in);
        LinkedList<String> name = new LinkedList<String>();
        LinkedList<Integer> time = new LinkedList<Integer>();
        int length = scanner.nextInt();
        int q = scanner.nextInt();
        int qTime = 0;
        for(int i = 0;i < length;i++){
            name.add(scanner.next());
            time.add(scanner.nextInt());
        }
        while(!name.isEmpty()){
            if(time.peek() <= q){
                System.out.print(name.poll() + " ");
                qTime = qTime + time.poll();
                System.out.println(qTime);
            }else{
                name.add(name.poll());
                time.add(time.poll() - q);
                qTime = qTime + q;
            }
        }
    }

}

Measured memory_bytes: 76812
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007


template <class T>
void print(vector<T> arr)
{
	cout << "start printing the vector\n";
	for (auto u : arr)
		cout << u << " ";
	cout << "\n";
}

template <class T>
void print_mat(vector<vector<T>> a)
{
	cout << "start printing the matrix\n";
	for (auto v : a)
	{
		for (auto e : v)
		{
			cout << e << " ";
		}
		cout << "\n";
	}
}

/******************************************
* NUMBER THEORY ;) *
******************************************/



ll powermod(ll x, ll y)
{
	ll res = 1;
	x = x % mod;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % mod;
		y = y >> 1;
		x = (x * x) % mod;
	}
	res %= mod;
	return res;
}
ll factmod(ll n)
{
	ll res = 1;
	while (n > 1)
	{
		res = (res * ((n / mod) % 2 ?  mod - 1 : 1)) % mod;
		for (ll i = 2; i <= n % mod; ++i)
			res = (res * i) % mod;
		n /= mod;
	}
	res %= mod;
	return res;
}

bool possible(vll &arr, ll mid, ll k, ll cand, ll maxx)
{
	for (auto u : arr)
	{
		k -= ceil((u * 1.0) / cand) - 1;
	}
	return k >= 0;
}



void solve()
{
	ll n, k;
	cin >> n >> k;
	vll arr(n);
	for (ll i = 0; i < n; i++)
		cin >> arr[i];
	ll maxx = *max_element(arr.begin(), arr.end());
	ll left = 1ll;
	ll right = 1000000000ll;
	while (left < right)
	{
		ll mid = (left + right) / 2;
		if (possible(arr, mid, k, mid, maxx))
			right = mid;
		else
			left = mid + 1;

	}
	cout << left << "\n";
}

int main()
{

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// ll t;
	// cin>>t;
	// while(t--)
	// {
	solve();
	// }

	return 0;
}

Measured memory_bytes: 4752
#include <bits/stdc++.h> 
using namespace std; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define EPS 0.000001
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
void setIO(string s) {
  ios_base::sync_with_stdio(0); cin.tie(0); 
  freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout);
}
ll arr[1000001];
int main()
{
  //flash;
  ll n;
  cin>>n;
  ve hed;
  for (ll i = 0; i < n; ++i)
  {
    ll yo;
    cin>>yo;
    hed.pb(yo);
    arr[yo]++;
  }
  ll ans=0;
  for (ll i = 0; i < n; ++i)
  {
    bool ka=0;
    for (ll j = 1; j <= sqrt(hed[i])+1; ++j)
    {
      if(!(hed[i]%j)){
        if(arr[j]>=1 && j!=hed[i]){
          ka=1;break;
        }
        if(arr[(hed[i]/j)]>=1 && ((hed[i]/j))!=hed[i]){
          ka=1;break;
        }
        if(j==hed[i] && arr[j]>1){
          ka=1;break;
        }
        if((hed[i]/j)==hed[i] && arr[(hed[i]/j)]>1){
          ka=1;break;
        }
      }
    }
    if(!ka)ans++;
  }
  cout<<ans;
  return 0;
}
//code the AC sol !
// BS/queue/map

Measured memory_bytes: 13176
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N + 2);
    A[0] = 0;
    REP(i, N) cin >> A.at(i + 1);
    A[N + 1] = 0;

    int sum = 0;
    REP(i, N + 1) { sum += abs(A[i] - A[i + 1]); }

    REP(i, N) {
        int tmp = sum;
        tmp += abs(A[i] - A[i + 2]) - abs(A[i] - A[i + 1]) - abs(A[i + 1] - A[i + 2]);
        cout << tmp << endl;
    }
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(1e8) + 5;
const int MAX_A = int(15e6);
const double EPS = 1e-8;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
string dir = "RDLU";
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main() {
    ll n, p, cnt[2]{}, ans = 0, conb[55][55]{};

    REP(i, 51) {
        REP(j, i + 1) {
            if (j == 0)
                conb[i][j] = 1;
            else
                conb[i][j] = conb[i - 1][j] + conb[i - 1][j - 1];
        }
    }

    cin >> n >> p;
    REP(i, n) {
        int a;
        cin >> a;
        cnt[a % 2]++;
    }
    for (int i = p; i <= cnt[1]; i += 2) {
        ans += conb[cnt[1]][i];
    }
    ans *= ll(pow(2, cnt[0]));
    cout << ans << endl;
    return 0;
}


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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int N; cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; ++i) cin >> A[i];
    sort(ALL(A));
    ll ans = A.back();
    int M = N-2;
    for(int i = N-2; 0 <= i; --i) {
        ll K = min(2,M);
        ans += A[i]*K;
        M -= K;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4788
#include<bits/stdc++.h>
#define pb           push_back
#define pf           push_front
#define in           insert
#define ff           first
#define ss           second
#define mp           make_pair
#define int          long long
#define uint         unsigned long long
#define rep(i,x,m)   for(int i=x;i<m;i++)
#define repr(i,x,m)  for(int i=x;i>=m;i--)
#define MOD          1000000007
#define endl         "\n"
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define vi           vector<int>
#define vs           vector<string>
#define pi           pair<int,int>
#define di           deque<int>
#define sz(x)       (int)x.size()
#define pq           priority_queue<int>
#define pqs          priority_queue<int,vi,greater<int> >
#define fix(y)       fixed<<setprecision(y)
#define print(v)     for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
#define noob         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int fac[2000005]={0};
void factorial(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=((i%MOD)*(fac[i-1]%MOD))%MOD;}
int power(int n,int m)
{int p=1;if(m==0)return 1;p=(power(n,m/2)%MOD);p=(p%MOD*p%MOD)%MOD;
return(m&1?((p%MOD*n%MOD)%MOD):(p%MOD));}
int ncr(int n,int r){return ((fac[n]*power(fac[r],MOD-2))%MOD*power(fac[n-r],MOD-2))%MOD;}

void ram5564()
{
    int n;
    cin>>n;
    string s;
    
    map<string,int>m1;
    m1["AC"]=0;
    m1["TLE "]=0;
    m1["WA"]=0;
    m1["TLE"]=0;
    while(n--)
    {
       cin>>s;
       m1[s]++;
    }
    cout<<"AC x "<<m1["AC"]<<endl;
    cout<<"WA x "<<m1["WA"]<<endl;
    cout<<"TLE x "<<m1["TLE"]<<endl;
    cout<<"RE x "<<m1["RE"]<<endl;

}

signed main()
{
        noob
        // #ifndef ONLINE_JUDGE
        //  freopen("input.txt","r",stdin);
        //  freopen("output.txt","w",stdout);
        //  #endif   
        
        int t=1;
        //cin>>t;
        while(t--)
        ram5564();
        return 0;
}

Measured memory_bytes: 3668
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>

using namespace std;
#define REP(i,a,n) for(int i = a; i < (int)n; ++i)
#define REPM(i,n,a) for(int i = n - 1; i >= a; --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;

#if 1
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

int N;
LL A[100001];
int main() {
	cin >> N;
	REP(i, 0, N) {
		cin >> A[i];
	}
	sort(A, A + N, greater<LL>());

	LL T = 0, R = 0;
	int s = 0;
	REP(i, 0, N - 1) {
		if (A[i] == A[i + 1]) {
			if (s == 0) {
				T = A[i];
				++s;
				++i;
			} else if(s == 1) {
				R = A[i];
				break;
			}
		}
	}
	
	cout << T * R << endl;
	return 0;
}

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


def main():
    sc = Scan()
    sc.intarr()[0]
    h = sc.intarr()
    maximum = 0
    count = 0
    before = 0
    for i in h:
        if before < i:
            if maximum < count:
                maximum = count
            count = 0
        else:
            count += 1
        before = i
    if maximum < count:
        maximum = count
    print(maximum)


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


main()


Measured memory_bytes: 15272
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000






int main() {
	map<long long, long long>rev;
	map<long long, int>cnt;
	vector<long long>a;
	vector<long long>prm;
	bool p[2500];
	int n, k;
	long long x, y, z, xx;
	long long l, r, m;
	int s, ans, sz;
	f(i, 2500)p[i] = true;
	p[0] = false;
	p[1] = false;
	f(i, 2500) {
		if (p[i]) {
			prm.push_back(i);
			k = 2 * i;
			while (k < 2500) {
				p[k] = false;
				k += i;
			}
		}
	}
	sz = prm.size();
	scanf("%d", &n);
	f(tt, n) {
		scanf("%lld", &x);
		y = 1;
		z = 1;
		f(i, sz) {
			if (x%prm[i] == 0) {
				k = 1;
				x /= prm[i];
				while (x%prm[i] == 0) {
					k++;
					x /= prm[i];
				}
				if (k % 3 == 1)y *= prm[i];
				else if (k % 3 == 2) z *= prm[i];
			}
		}
		l = 2500;
		r = 100000;
		while ((l + 1) < r) {
			m = (l + r) / 2;
			if ((m*m) <= x)l = m;
			else r = m;
		}
		if ((l*l) == x)z *= l;
		else y *= x;
		x = (y * z)*z;
		if (y > 1000000)xx = -1;
		else xx = (y*y)*z;
		k = cnt[x];
		if (k == 0) {
			cnt[x] = 1;
			rev[x] = xx;
			a.push_back(x);
		}
		else cnt[x] = k + 1;
	}
	sort(a.begin(), a.end());
	ans = 0;
	sz = a.size();
	f(i, sz) {
		if (a[i] == 1)ans++;
		else if (rev[a[i]] == -1)ans += cnt[a[i]];
		else {
			ans += max(cnt[a[i]], cnt[rev[a[i]]]);
			cnt[a[i]] = 0;
			cnt[rev[a[i]]] = 0;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 16372
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
 
int main() {
	int n;
	string s;
	int flg = 0;
	cin >> n;

	rep(i, n)
	{
		cin >> s;
		if (s == "Y")
		{
			flg = 1;
			break;
		}
	}
	if (flg == 0)
	{
		cout << "Three" << endl;
	}
	else
	{
		cout << "Four" << endl;
	}
}

Measured memory_bytes: 3548
#include <stdio.h>
#include <math.h>
 
int main() {
  double a, b, h, m, deg, ans;
  scanf("%lf %lf %lf %lf", &a, &b, &h, &m);
    
  //c2=a2+b2−2ab*cos𝐶
  deg = fabs((11*m-60*h)*M_PI/360);
  ans = sqrt(a*a + b*b - 2*a*b*cos(deg));
  
  printf("%.10lf", ans);
  return(0);
}

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

using namespace std;

class Permutation{
public:
  vector<int> data;
  Permutation(int n){
    data.resize(n);
  }

  bool operator < (const Permutation &obj) const{ //ノード同士の比較を行うための演算子定義
    bool result = false;
    int flag = 0;
    for(int i = 0; i < this->data.size(); i++){
      if(this->data.at(i) < obj.data.at(i)){
        result = true;
        break;
      }
      if(this->data.at(i) > obj.data.at(i)){
        break;
      }
    }
    return result;
  }

  bool operator == (const Permutation &obj) const{
    bool result = true;
    for(int i = 0; i < this->data.size(); i++){
      if(this->data.at(i) != obj.data.at(i)){
        result = false;
        break;
      }
    }
    return result;
  }
};

int main(void){
//string S;
int N;
cin >> N;
Permutation P(N), Q(N);
//vector<int> P(N), Q(N);
int result = 0;

for(int i = 0; i < N; i++){
  cin >> P.data[i];
}
for(int i = 0; i < N; i++){
  cin >> Q.data[i];
}

if(P < Q){
  while(next_permutation(P.data.begin(), P.data.end()) != false){
    result++;
    if(P == Q) break;
  }
}else if(Q < P){
  while(next_permutation(Q.data.begin(), Q.data.end()) != false){
    result++;
    if(P == Q) break;
  }
}
cout << result << endl;

return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

double PI = 3.14159265;

int main() {
    double r;
    cin >> r;

    cout << fixed << setprecision(5) << 2.0 * r * PI << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

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

    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans1 = a * c;
    ll ans2 = b * d;
    ll ans3 = b * c;
    ll ans4 = a * d;
    ll ans = max({ans1,ans2,ans3,ans4});
    cout << ans << "\n";


}




















Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    int n; cin >> n;

    int l[2*n];
    for(int i=0; i<2*n; i++){
        cin >> l[i];
    }

    sort(l, l+2*n);

    ll ans = 0;
    for(int i=0; i<2*n; i+=2){
        ans += l[i];
    }

    cout << ans;

    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
            int m = sc.nextInt();
            int nmin = sc.nextInt(), nmax = sc.nextInt();
            if(m==0) break;
            int[] score = new int[m];

            for (int i = 0; i < m; i++) {
                score[i] = sc.nextInt();
            }

            Arrays.sort(score);

            int max = 0, j = 0;
            for (int i = m-nmin; i >= m-nmax; i--) {
                if(max <= score[i] - score[i-1]){
                    max = score[i] - score[i-1];
                    j = m - i;
                }
            }
            System.out.println(j);
        }
    }
}

Measured memory_bytes: 57316
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.StringTokenizer;

class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		String line = null;
		List<Integer> results = new ArrayList<Integer>();
		
		while ((line = br.readLine()) != null) {
			StringTokenizer st = new StringTokenizer(line);
			if (!st.hasMoreTokens()) break;
			
			int a = Integer.parseInt(st.nextToken());
			int b = Integer.parseInt(st.nextToken());
			
			results.add(Integer.toString(a + b).length());
		}
		
		for (int x : results) {
			System.out.println(x);
		}
	}
}

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

ll MAX = 1000000007;
vector< vector<ll> > dp(2010, vector<ll>(2010,-1));

ll combi(int n, int k){
  if(k == 0 || n == k){
    dp[n][k] = 1;
    return 1;
  } 
  if(dp[n][k] != -1) return dp[n][k];
  if(dp[n][k] == -1){
    ll ans = combi(n-1, k) + combi(n-1, k-1);
    ans = ans % MAX;
    dp[n][k] = ans;
    return ans;
  }
}

int main(){
  int N,K;
  cin >> N >> K;
  for(int i = 1; i <= K; ++i){
    ll red, blue;
    if(N-K+1 < i) red = 0;
    else red = combi(N-K+1,i);
    blue = combi(K-1, i-1);
    cout << blue * red % MAX << endl;
  }
}


Measured memory_bytes: 32000
fc=lambda x:1 if x=='A' else 2
s=list(map(fc,list(input())))
t=list(map(fc,list(input())))
q=int(input())
abcd=[list(map(int,input().split())) for _ in range(q)]
cs=[0]
tmp=0
for x in s:
  tmp+=x
  cs.append(tmp)
ct=[0]
tmp=0
for x in t:
  tmp+=x
  ct.append(tmp)
for a,b,c,d in abcd:
  if (cs[b]-cs[a-1])%3==(ct[d]-ct[c-1])%3:
    print('YES')
  else:
    print('NO')


Measured memory_bytes: 111844
#include<iostream>
#include<string>
#include <algorithm>

int main(){
  int a,b;
  std::cin >> a >> b;
  if(a<=8 && b<=8){
    std::cout<< "Yay!" << std::endl;
  }else{
    std::cout<< ":(" << std::endl;
  }
}

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

int main(){
    int N, K, R, S, P;
    cin >> N >> K;
    cin >> R >> S >> P;
    string T;
    cin >> T;
    int ans=0;
    int *point = new int[N];
    for(int i=0;i<K;i++){
        if(T[i]=='r'){
            ans += P;
            point[i] = P; 
        }
        if(T[i]=='s'){
            ans += R;
            point[i] = R; 
        }
        if(T[i]=='p'){
            ans += S;
            point[i] = S; 
        }
    }
    for(int i=K;i<N;i++){
        if(T[i]==T[i-K]&&point[i-K]!=0){
            point[i] = 0;
        }else{
            if(T[i]=='r'){
                ans += P;
                point[i] = P; 
            }   
            if(T[i]=='s'){
                ans += R;
                point[i] = R; 
            }
            if(T[i]=='p'){
                ans += S;
                point[i] = S; 
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647 >> 1); // 10^9 + 5000
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Kunitaka{
    template<
        typename TYPE,
        std::size_t SIZE
    >
    std::size_t array_length(const TYPE (&array)[SIZE])
    {
        return SIZE;
    }
}
using namespace Kunitaka;
namespace Printer{
    void br(){
        cout << endl;
    }

    void loop_cnt(int i){
        cout << "i = " << i << endl;
    }

    void loop_cnt(int i, int j){
        cout << "i = " << i << ", " << "j = " << j << endl;
    }

    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T, class S>
    void print(T x, S y){
        cout << x << "," << y << endl;
    }

    template<class T, class S, class U>
    void print(T x, S y, U z){
        cout << x << "," << y << "," << z << endl;
    }

    template<class T, class S>
    void print(pair<T, S> p){
        cout << p.first << ", " << p.second << endl;
    }

    template<
        typename TYPE,
        std::size_t SIZE
    >
    void print(const TYPE (&array)[SIZE]){
        int lim = array_length(array);
        for(int i=0; i<lim; i++){
            if(i) cout << " ";
            cout << array[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<S> v){
        for(int i=0; i<v.size(); i++){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<vector<S> > vv){
        for(int i=0; i<vv.size(); i++){
            for(int j=0; j<vv[i].size(); j++){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void yesno(bool x){
        if(x) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
};
using namespace Printer;

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//


    // input
    cout << fixed << setprecision(10);
    ll N, K; cin >> N >> K;

    // variable
    ll ans = 0;
    // solve
    while(N != 0){
        N /= K;
        ans++;
    }

    print(ans);
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }
using P = array<ll, 2>;

int main() {
    int n;
    cin >> n;
    vector<P> v(n);
    for (int i = 0; i < n; ++i) {
        ll h, p;
        cin >> h >> p;
        v[i] = {h, p};
    }
    sort(v.begin(), v.end(), [&](P a, P b){ return a[0]+a[1] < b[0]+b[1]; });
    auto dp = make_v(n+1, n+1, INF<ll>);
    dp[0][0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if(dp[i][j] == INF<ll>) continue;
            chmin(dp[i+1][j], dp[i][j]);
            if(dp[i][j] <= v[i][0]) chmin(dp[i+1][j+1], dp[i][j]+v[i][1]);
        }
    }
    int ans = 0;
    for (int i = 0; i <= n; ++i) {
        if(dp[n][i] != INF<ll>) chmax(ans, i);
    }
    cout << ans << "\n";
    return 0;
}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int N, H;

vector<int> a;
vector<int> b;

int main(void) {
    cin >> N >> H;
    a.resize(N);
    b.resize(N);
    rep(i, N) {
        cin >> a[i] >> b[i];
    }

    sort(ALLOF(a), std::greater<int>());
    sort(ALLOF(b), std::greater<int>());

    int count = 0;
    int h = H;
    for (int i = 0; i < N; ++i) {
        if (a[0] > b[i]) break;
        h -= b[i];
        count++;
        if (h <= 0) break;
    }

    if (h > 0) {
        int slash = h / a[0];
        if (h % a[0] != 0) slash++;
        count += slash;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>

using namespace std;

const int MOD = 1000000007;
typedef long long ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,T,A,mi=10000000,ans;
  cin>>N>>T>>A;
  vector<int>H(N);
  for(int i=0;i<N;i++)cin>>H[i];
  for(int i=0;i<N;i++){
    mi=min(mi,abs(1000*A-(T*1000-H[i]*6)));
    if(mi==abs(1000*A-(T*1000-H[i]*6)))ans=i+1;
  }
  cout<<ans<<endl;
}


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

def check(p):
  _N = N
  while _N%p == 0:
    _N //= p
  return (_N-1)%p == 0

n = int(N**0.5) + 1
P0 = set([N])
P1 = set([N-1])
for i in range(2, n+1):
  if (N-1)%i == 0:
    P1.add(i)
    P1.add((N-1)//i)
  if N%i == 0:
    P0.add(i)
    P0.add(N//i)

P0.discard(1)
P1.discard(1)
ans = len(P1)
for p in P0:
  ans += check(p)

print(ans)

Measured memory_bytes: 3828
a = str(input())
b = str(input())
check = 0
for i in range(len(a)):
  if a == b:
    check = 1
    break
  else:
    a = a[len(a)-1] + a[0:len(a)-1]
    
if check == 0:
  print("No")
else:
  print("Yes")
    
  
  

Measured memory_bytes: 3060
N, A, B = map(int, input().split())
h = []
for i in range(N):
    h.append(int(input()))
    
left = 0
right = max(h)

def can_kill(count):
    ness = 0
    for hp in h:
        ness += max(-(-(hp - B * count) // (A - B)), 0)
    if ness <= count:
        return True
    return False
    
while right - left > 1:
    middle = left + (right - left) // 2
    if can_kill(middle):
        right = middle
    else:
        left = middle

print(right)

Measured memory_bytes: 7112
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

bool ok = true;
vector<bool> used(1e+5 + 1, false);
vec a(1e+5 + 1, 0);
mat G(1e+5 + 1, vec(0));//node : 0 ~ N
int p = 0;
ll dfs(int v){
    used[v] = true;
    ll sum = 0, ma = 0;
    for(int to : G[v]){
        if(!used[to]) {
            ll temp = dfs(to);
            sum += temp;
            ma = max(ma, temp);
        }
    }
    if(sum == ma){
        if(sum != 0 && sum != a[v]) ok = false;
        return a[v];
    }else {
        ma = max(ma, (sum + 1) / 2);
        if (a[v] < ma || sum < a[v]) ok = false;
        return a[v] * 2 - sum;
    }
}

int main() {
    cin>>N;
    rep(i,N) cin>>a[i + 1];
    rep(i,N - 1){
        cin>>A>>B;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    reps(i, 1, N + 1) if(G[i].size() == 1) p = i;
    dfs(p);
    cout<<(ok ? "YES" : "NO")<<endl;
}

Measured memory_bytes: 12800
N = gets.to_i
As = gets.split.map(&:to_i)

xs = As.map.with_index(1){|a, i| a - i}.sort
b = N.even? ? (xs[N/2 - 1, 2].inject(:+) / 2.0).round : xs[N/2]
puts xs.inject(0){|s, x| s + (x - b).abs}

Measured memory_bytes: 20608
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

use std::cmp;
use std::num;

fn main() {
    input! {
        n: i32, 
        k: i32,
        x: [i32; n],
    }

    let mut ans = 0;

    for i in x {
        ans += cmp::min(2*(0 - i).abs(),2*(k - i).abs());
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,x,m,mi=100001;
  cin>>n>>x;
  for(int i=0;i<n;i++){
    cin>>m;
    mi=min(mi,m);
    x-=m;
  }
  n+=x/mi;
  cout<<n;
}

Measured memory_bytes: 256
N=int(input())
d={}
flag=True
before=None
for z in range(N):
  s=input()
  if before==None:
    before=s[-1]
  else:
    if before==s[0]:
      before=s[-1]
    else:
      flag=False
  if not(s in d):
    d[s]=True
  else:
    flag=False

if flag:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3060
#include <cstdio>

using namespace std;

char s[123456];
int pre[123456];

int main()
{
  int n, q;
  scanf("%d %d", &n, &q);
  scanf("%s", s);

  for (int i = 1; i < n; ++i)
  {
    pre[i + 1] = pre[i] + (s[i] == 'C' && s[i - 1] == 'A');
  }

  while (q--)
  {
    int l, r;
    scanf("%d %d", &l, &r);

    int res = pre[r] - pre[l - 1];
    if (l > 1 && s[l - 1] == 'C' && s[l - 2] == 'A')
      res--;
    printf("%d\n", res);
  }
  return (0);
}

Measured memory_bytes: 1280
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if (a > b) {
			System.out.println(a-1);
		} else {
			System.out.println(a);
		}
	}
}

Measured memory_bytes: 22996
# coding : utf-8

import math

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

l = []
for i in range(1,int(math.sqrt(M))+1):
    if M % i == 0:
        l.append(i)
        l.append(M//i)

ans = 1
for l_ in l:
    if l_ <= M//N:
        ans = max(ans,l_)

print(ans)

Measured memory_bytes: 3064
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0010
  * Circumscribed Circle of a Triangle
  */
object Main {
  def main(args: Array[String]): Unit = {
    val n = io.StdIn.readInt()
    Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).take(n).map(_.split(" +").map(BigDecimal(_)))
      .map { case Array(x1, y1, x2, y2, x3, y3) => solve(x1, y1, x2, y2, x3, y3) }
      .foreach { case (px, py, r) =>
        println(s"${px.setScale(3, BigDecimal.RoundingMode.HALF_UP)} ${py.setScale(3, BigDecimal.RoundingMode.HALF_UP)} ${r.setScale(3, BigDecimal.RoundingMode.HALF_UP)}")
      }
  }

  def solve(x1: BigDecimal, y1: BigDecimal, x2: BigDecimal, y2: BigDecimal, x3: BigDecimal, y3: BigDecimal): (BigDecimal, BigDecimal, BigDecimal) = {
    val px = ((y1 - y2) * ((x1 + x3) * (x1 - x3) + (y1 + y3) * (y1 - y3)) - (y1 - y3) * ((x1 + x2) * (x1 - x2) + (y1 + y2) * (y1 - y2))) / (2 * ((x1 - x3) * (y1 - y2) - (x1 - x2) * (y1 - y3)))
    val py = ((x1 - x2) * ((y1 + y3) * (y1 - y3) + (x1 + x3) * (x1 - x3)) - (x1 - x3) * ((y1 + y2) * (y1 - y2) + (x1 + x2) * (x1 - x2))) / (2 * ((y1 - y3) * (x1 - x2) - (y1 - y2) * (x1 - x3)))
    val r = BigDecimal(math.sqrt(((x1 - px) * (x1 - px) + (y1 - py) * (y1 - py)).toDouble))
    (px, py, r)
  }
}

Measured memory_bytes: 44652
#include <bits/stdc++.h>
using namespace std;
int a[123456],b[123456],c[123456];
int main(){
	int i,j,n;
	cin>>n;
	for (i=0;i<n;++i){
		cin>>a[i]>>b[i]>>c[i];
	}
	for (i=1;i<n;++i){
		a[i]=max(a[i]+b[i-1],a[i]+c[i-1]);
		b[i]=max(a[i-1]+b[i],b[i]+c[i-1]);
		c[i]=max(c[i]+b[i-1],a[i-1]+c[i]);
	}
	cout <<max(a[n-1],max(b[n-1],c[n-1]));
}

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


num = a[0]*a[2]

if a[0]*a[3] > num:
  num = a[0]*a[3]

if a[1]*a[2] > num:
  num = a[1]*a[2]

if a[1]*a[3] > num:
  num = a[1]*a[3]


print(num)

Measured memory_bytes: 9188
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int X = sc.nextInt();
		for(int i = X - K + 1; i < X + K; i++) {
			if(i != X + K - 1) {
				System.out.print(i + " ");
			} else {
				System.out.println(i);
			}
		}
	}
}


Measured memory_bytes: 21972
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from itertools import product
def resolve():
    m, n, k = map(int, input().split())
    grid = [list(input()) for _ in range(m)]
    ans = 0
    for U, V in product(range(1 << m), range(1 << n)):
        tmp = [a[:] for a in grid]
        for i in range(m):
            if not U >> i & 1:
                continue
            for j in range(n):
                tmp[i][j] = '.'
        for j in range(n):
            if not V >> j & 1:
                continue
            for i in range(m):
                tmp[i][j] = '.'
        ans += sum(tmp[i][j] == '#' for i in range(m) for j in range(n)) == k
    print(ans)
resolve()

Measured memory_bytes: 69076
#include <stdio.h>
#include <stdlib.h>

int main(){
	int N, a, i, ans = 0;
	scanf("%d", &N);
	for(i = 0; i < N; i++){
		scanf("%d", &a);
		ans += a - 1;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n";
#define int long long
#define mod 1000000007

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve() {
	// int t, n, k;
	// cin >> t;
	// while (t--) {
	// 	cin >> n >> k;
	// 	vector<int> arr(2 * n);
	// 	for (int i = 0; i < n; i++) {
	// 		cin >> arr[i];
	// 		arr[i + n] = arr[i];
	// 	}
	// 	for (int i = 1; i < arr.size(); i++)
	// 		arr[i] += arr[i - 1];
	// 	int ans = LLONG_MIN;
	// 	for (int start = 0; start < n; start++) {
	// 		int curr = 0;
	// 		if (start == 0)
	// 			curr = arr[start + k];
	// 		else
	// 			curr = arr[start + k] - arr[start - 1];
	// 		ans = max(ans, curr);
	// 	}
	// 	cout << ans << "\n";
	// }
	int s, w;
	cin >> s >> w;
	cout << (w >= s ? "unsafe" : "safe");
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5+10;
int n, m, dist[maxn];
vector<int> grafo[maxn];
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cin >> n >> m;
    for(int i=1; i<=m; i++){
        int u, v;
        cin >> u >> v;
        grafo[u].push_back(v);
        grafo[v].push_back(u);
    }
    queue<int> fila;
    memset(dist, -1, sizeof dist);
    fila.push(1);
    dist[1] = 0;
    while(!fila.empty()){
        int u = fila.front();
        fila.pop();
        for(auto v : grafo[u]){
            if(dist[v] == -1){
                dist[v] = dist[u] + 1;
                fila.push(v);
            }
        }
    }
    cout << (dist[n] == 2 ? "POSSIBLE\n" : "IMPOSSIBLE\n");
}


Measured memory_bytes: 16048