akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;

const ll MOD=1000000007;

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b){
  ll p=1;
  for(int i=0;i<b;i++){
    p*=a;
  }
  return p;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p){
  ll n=solveLinear(a,p,1);
  n=n%p;
  if(n<0)return n+p;
  return n;
}

int main(){
  int i,j,cnt=0;
  int h,w;
  cin>>h>>w;
  int n=h*w;
  char a[n];
  for(i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  int b[26];
  for(i=0;i<26;i++)b[i]=0;
  for(i=0;i<n;i++)b[a[i]-'a']++;
  if(h%2==0 && w%2==0){
    for(i=0;i<26;i++){
      if(b[i]%4!=0){
        cout<<"No"<<endl;
        return 0;
      }
    }
    cout<<"Yes"<<endl;
    return 0;
  }
  if(h%2==1 && w%2==0)swap(h,w);
  if(h%2==0 && w%2==1){
    int sum=0;
    for(i=0;i<26;i++){
      if(b[i]%2!=0){
        cout<<"No"<<endl;
        return 0;
      }
      if(b[i]%4==2){
        sum+=2;
      }
    }
    if(sum>h)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
  }
  if(h%2==1 && w%2==1){
    int sum=0;
    for(i=0;i<26;i++){
      if(b[i]%4==3){
        cout<<"No"<<endl;
        return 0;
      }
      if(b[i]%4==1){
        cnt++;
      }
      if(b[i]%4==2){
        sum+=2;
      }
    }
    if(cnt==1 && h+w-1>=sum)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};

bool ispali(string s) {
	int n = s.size();
	bool res = 1;
	rep(i, n / 2) {
		if(s[i] != s[n - i - 1]) res = 0;
	}
	return res;
}

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

	string s;
	int ans = 0;
	while(cin >> s) {
		if(ispali(s)) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3184
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};




ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;


    
    ll n,k;
    cin>>n>>k;
    ll a[100010];
    rep(i,n){
        cin>>a[i];
    }
    sort(a,a+n);
    ll ans=0;
    COMinit();
    rep(i,n){
        ll s=n-(i+1);
        if(s<k-1) continue;
        ans-=COM(s,k-1)*a[i]%MOD;
        ans%=MOD;
    }
    rep(i,n){
        if(i<k-1) continue;
        ans+=COM(i,k-1)*a[i]%MOD;
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 26880
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}


#include <iostream>

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

    if (N <= 999) { cout << "ABC" << endl; }
    else { cout << "ABD" << endl; }
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

ll solve(ll ni, ll nj, ll nl, ll no) {
	ll res = no;
	res += ni / 2 * 2 + nj / 2 * 2 + nl / 2 * 2;
	return res;
}

int main() {
	int ai, ao, at, aj, al, as, az;
	cin >> ai >> ao >> at >> aj >> al >> as >> az;
	if (aj < al) swap(aj, al); // aj ≧ al
	
	ll ans = 0;
	ll cnt = min(ai, min(aj, al));
	chmax(ans, solve(ai - cnt, aj - cnt, al - cnt, ao) + cnt * 3);
	
	if (cnt >= 1) {
		cnt--;
		chmax(ans, solve(ai - cnt, aj - cnt, al - cnt, ao) + cnt * 3);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input!(t0: i64, t1: i64, a0: i64, a1: i64, b0: i64, b1: i64);
    let d0 = t0 * (a0 - b0);
    let d1 = d0 + t1 * (a1 - b1);
    println!(
        "{}",
        if d1 == 0 {
            "infinity".to_string()
        } else if (0 < d0 && 0 < d1) || (d0 < 0 && d1 < 0) {
            0.to_string()
        } else {
            let q: i64 = d0.abs() / d1.abs();
            let r: i64 = d0.abs() % d1.abs();
            if r == 0 {
                assert!(1 <= q);
                2 * (q + 1) - 2
            } else {
                2 * q + 1
            }
            .to_string()
        }
    );
}


Measured memory_bytes: 2184
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    string s,t;
    cin>>s>>t;
    int ls=sz(s),lt=sz(t);
    vector<vector<int>> dp(ls+1,vector<int>(lt+1));
    for(int i=0;i<ls;i++){
        for(int j=0;j<lt;j++){
            chmax(dp[i+1][j+1],max(dp[i][j+1],dp[i+1][j]));
            if(s.at(i)==t.at(j)){
                chmax(dp[i+1][j+1],dp[i][j]+1);
            }
        }
    }

    string ans;
    int ps=ls,pt=lt;
    while(ps + pt){
        if(ps && dp[ps][pt]==dp[ps-1][pt]){
            ps--;
        }
        else if(pt && dp[ps][pt]==dp[ps][pt-1]){pt--;}
        else{
            ps--;pt--;
            ans.pb(s.at(ps));
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}

Measured memory_bytes: 37376
"""
シミュレーション問題
- 数式にこだわりすぎた
- WAになって何が間違っているかはわからなかった
- Nの範囲を確認すればO(N^2)でも十分問題なかったことが分かったので素直に実装すればよかった
"""
n = int(input())
setting = []
for _ in range(n-1):
    setting.append(tuple(map(int, input().split())))

results = []
for i in range(n-1):
    cur = 0
    for c, s, f in setting[i:]:
        if cur < s:
            cur = c + s
        elif 0 == cur % f:
            cur += c
        else:
            cur += c + f - cur % f
    results.append(cur)
results.append(0)
for result in results:
    print(result)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
int main() {
	ll s;
	cin >> s;
	ll rs = sqrt(s) + 1;
	if (rs > 1000000000)
		rs = 1000000000;
	ll diff = rs * rs - s;
	cout << 0 << ' ' << 0 << ' ' << rs << ' ' << diff << ' ' << 1 << ' ' << rs;
}

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

int main() {
    int n;
    cin >> n;
    map<string, int> count;
    for (int i = 0; i < n; i++)  {
        string tmp;
        cin >> tmp;
        count[tmp]++;
    }
    printf("AC x %d\n", count["AC"]);
    printf("WA x %d\n", count["WA"]);
    printf("TLE x %d\n", count["TLE"]);
    printf("RE x %d\n", count["RE"]);
}

Measured memory_bytes: 3660
#include<iostream>
#include<string>
#include<algorithm>
#include<map>

using namespace std;

int main()
{
	int N, M;
	cin >> N;
	map<string, int> s;
	for (int i = 0; i < N; i++)
	{
		string tmp;
		cin >> tmp;
		auto it = s.find(tmp);
		if (it != s.end())
		{
			s[tmp]++;
		}
		else
		{
			s[tmp] = 1;
		}
	}

	cin >> M;
	map<string, int> t;
	for (int i = 0; i < M; i++)
	{
		string tmp;
		cin >> tmp;
		auto it = t.find(tmp);
		if (it != t.end())
		{
			t[tmp]++;
		}
		else
		{
			t[tmp] = 1;
		}
	}

	int ans = 0;
	for (auto i : s)
	{
		int tmp = i.second;
		if (t.find(i.first) != t.end())
		{
			tmp = i.second - t[i.first];
		}
		if (tmp > ans)
			ans = tmp;
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
# 折れ線グラフで考えると
# ( : +1
# ) : -1
# 0で終わる
# 0未満にならない → 各文字列で最下点と和を利用
# 和がマイナスの部分と分けて、マイナス部分は反転して考える

n = int(input())
plus = []
minus = []
for i in range(n):
    min_v = 0
    sum_v = 0
    s = input()
    for j in s:
        sum_v += 1 if j == '(' else -1
        min_v = min(min_v, sum_v)
    if sum_v > 0:
        plus.append((min_v, sum_v))
    else:
        minus.append((min_v-sum_v, -sum_v))

plus.sort(key=lambda x:x[0], reverse=True)
minus.sort(key=lambda x:x[0], reverse=True)

sum_plus = 0
for min_v, sum_v in plus:
    if sum_plus + min_v < 0:
        print("No")
        exit()
    sum_plus += sum_v

sum_minus = 0
for min_v, sum_v in minus:
    if sum_minus + min_v < 0:
        print("No")
        exit()
    sum_minus += sum_v

if sum_plus == sum_minus:
    print("Yes")
else:
    print("No")





Measured memory_bytes: 84244
N = int(input())
p = [int(i) for i in input().split()]
input()
O = [int(i) for i in input().split()]
for x in O:
    if p[x - 1] == 2019:
        continue
    if x < N and p[x - 1] + 1 == p[x]:
        continue
    p[x - 1] += 1

for x in p:
    print(x)
    


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

string s, t1, t2;

signed main() {
  cin >> s;
  int n = s.size();
  rep (i, n) {
    t1 += i % 2 == 0 ? "0" : "1";
    t2 += i % 2 == 1 ? "0" : "1";
  }

  int cnt1 = 0;
  int cnt2 = 0;
  rep (i, n) {
    if (s[i] != t1[i]) cnt1++;
    if (s[i] != t2[i]) cnt2++;
  }

  cout << min(cnt1, cnt2) << endl;

  return 0;
}

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





#define MAX_INT 2147483647
#define MIN_INT -2147483648





/*以下便利なマクロを定義する。*/

#define rep(i, min, max) for(i=min; i<=max; i=i+1)



#define if_exists(i, min, max, prop)\
\
	rep(i, min, max)\
	{\
		if(prop)\
		{\
			break;\
		}\
	}\
\
	if(i<max+1)\



/*以下便利な関数を定義する。*/

void fill_int(int array[], int min, int max, int element)
{
	int i=min;

	rep(i, min, max)
	{
		array[i]=element;
	}

}



void fill_int_array(int size_1, int size_2, int array[size_1][size_2], int i_min, int i_max, int j_min, int j_max, int element)
{
	int i=i_min;

	rep(i, i_min, i_max)
	{
		fill_int(array[i], j_min, j_max, element);
	}
}



int graph_number_of_hamilton_path_sub(int size, int adjacency_matrix[size][size], int start, int target)
{
	int i=0;
	int j=0;
	int k=0;

	int answer=0;

	int copy_matrix[size-1][size-1];

	if(start==target)
	{
		answer=0;
	}
	else
	{
		if(size==2)
		{
			if(adjacency_matrix[start][target]>0)
			{
				answer=adjacency_matrix[start][target];
			}
			else
			{
				answer=0;
			}
		}
		else if(size>2)
		{
			if(adjacency_matrix[start][target]>0)
			{
				for(i=0; i<start; i=i+1)
				{
					for(j=0; j<start; j=j+1)
					{
						copy_matrix[i][j]=adjacency_matrix[i][j];
					}
					for(j=start; j<size-1; j=j+1)
					{
						copy_matrix[i][j]=adjacency_matrix[i][j+1];
					}
				}
				for(i=start; i<size-1; i=i+1)
				{
					for(j=0; j<start; j=j+1)
					{
						copy_matrix[i][j]=adjacency_matrix[i+1][j];
					}
					for(j=start; j<size-1; j=j+1)
					{
						copy_matrix[i][j]=adjacency_matrix[i+1][j+1];
					}
				}
				for(k=0; k<size-1; k=k+1)
				{
					if(start>target)
					{
						answer=answer+adjacency_matrix[start][target]*graph_number_of_hamilton_path_sub(size-1, copy_matrix, target, k);
					}
					else if(start<target)
					{
						answer=answer+adjacency_matrix[start][target]*graph_number_of_hamilton_path_sub(size-1, copy_matrix, target-1, k);
					}
				}
			}
			else if(adjacency_matrix[start][target]==0)
			{
				answer=0;
			}
		}
	}
	return answer;
}











int main(void)
{
	int i=0;

	int answer=0;

	int N;
	int M;
	scanf("%d %d", &N, &M);

	int a[M];
	int b[M];
	rep(i, 0, M-1)
	{
		scanf("%d %d", &a[i], &b[i]);
	}

	int adjacency_matrix[N][N];
	fill_int_array(N, N, adjacency_matrix, 0, N-1, 0, N-1, 0);

	rep(i, 0, M-1)
	{
		adjacency_matrix[a[i]-1][b[i]-1]=adjacency_matrix[a[i]-1][b[i]-1]+1;
		adjacency_matrix[b[i]-1][a[i]-1]=adjacency_matrix[b[i]-1][a[i]-1]+1;
	}

	rep(i, 1, N-1)
	{
		answer=answer+graph_number_of_hamilton_path_sub(N, adjacency_matrix, 0, i);
	}

	printf("%d\n", answer);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  int r,g,b,n;
  cin >> r >> g >> b >> n;
  int answer = 0;
  REP(i,n+1) REP(j,n+1) {
    int left = n-r*i-g*j;
    if(left>=0 && left%b == 0) ++answer;
  }
  cout << answer << endl;
  return 0;
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    
    // source code
  int n;
  cin >> n;
  int d[n];
  inputArray(d,n);
  int ans = 0;
  rep(i,n - 1)
  {
    repd(j,i + 1,n)
    {
      ans += d[i] * d[j];
    }
  }
  cout << ans;
}

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

class rolling_hash {
public:
	using u64 = std::uint_fast64_t;
	using size_type = std::uint_fast32_t;

	static constexpr u64 MOD = (1uL << 61) - 1;
	static constexpr u64 base = 20200213;

	std::string str;
	std::vector<u64> hash_, pow;

private:
	static constexpr u64 mask30 = (1ul << 30) - 1;
	static constexpr u64 mask31 = (1ul << 31) - 1;

	u64 mul(u64 a, u64 b) const {
		u64 au = a >> 31;
		u64 ad = a & mask31;
		u64 bu = b >> 31;
		u64 bd = b & mask31;
		u64 mid = ad * bu + au * bd;
		u64 midu = mid >> 30;
		u64 midd = mid & mask30;
		return apply(au * bu * 2 + midu + (midd << 31) + ad * bd);
	}
	u64 apply(u64 val) const {
		val = (val & MOD) + (val >> 61);
		if(val >= MOD) val -= MOD;
		return val;
	}
	size_type xorshift(size_type x) const {
		x ^= x << 13;
		x ^= x >> 17;
		x ^= x << 5;
		return x;
	}

public:
	rolling_hash(const rolling_hash &) = default;
	rolling_hash(rolling_hash&&) = default;

	rolling_hash() : str() {};
	rolling_hash(const std::string & str) : str(str) {
		hash_.resize(str.size() + 1, 0);
		pow.resize(str.size() + 1, 1);
		for(size_type i = 0; i < str.size(); i++) {
			hash_[i + 1] = mul(hash_[i], base) + xorshift(str[i] + 1);
			pow[i + 1] = mul(pow[i], base);
			if(hash_[i + 1] >= MOD) hash_[i + 1] -= MOD;
		}
	}

	u64 hash() const { return hash_.back(); }
	u64 hash(size_type l, size_type r) const {
		u64 ret = MOD + hash_[r] - mul(hash_[l], pow[r - l]);
		return ret < MOD ? ret : ret - MOD;
	}
	
	size_type size() const { return str.size(); }
};

int main() {
	int n; scanf("%d", &n);
	std::string s; std::cin >> s;
	
	int ans = 0;
	rolling_hash hash(s);
	for(int i = 0; i < s.size(); i++) {
		for(int j = i; j < s.size(); j++) {
			while(i + ans < j and j + ans < n) {
				if(hash.hash(i, i + ans + 1) != hash.hash(j, j + ans + 1)) break;
				ans++;
			}
		}
	}

	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
//const int mod = 1e9 + 7;
const int mod = 998244353;

int main(){
	int n; cin >> n;
	vl a(n); rep(i,n) cin >> a[i];
	map<ll,ll> mp;
	rep(i,n) mp[a[i]]++;
	if(n % 3 != 0){
		if(mp.size() == 1 && mp[0] == n){
			puts("Yes");
		}else{
			puts("No");
		}
	}
	else{
		if(mp.size() == 3){
			ll exor = 0;
			ll num = -1;
			for(auto i : mp){
				exor ^= i.first;
				if(num == -1) num = i.second;
				else{
					if(num != i.second) num = -2;
				}
			}
			if(exor == 0 && num >= 0) puts("Yes");
			else puts("No");
		}else{
			if(mp.find(0) == mp.end()) puts("No");
			else{
				if(mp.size() == 1){
					puts("Yes");
					return 0;
				}
				if(mp.size() == 2){
					if(mp[0] == n/3) puts("Yes");
					else puts("No");
				}
				else puts("No");
			}
		}
	}
}

Measured memory_bytes: 8620
/*
Author : N_o_o_B
Created : May 02 2020 18:22:50 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    ll a,b,n;
    cin >> a >> b >> n;

    ll q = min(b-1,n);

    ll ans = a*q/b;

    cout << ans << endl;



    time_taken();
    return 0;
}

Measured memory_bytes: 3792
#include<stdio.h>

int d[15][10];

int main()
{
    int n,k,i,j,T,cnt=0;
    scanf("%d %d", &n, &k);
    d[1][1]=4;
    for(i=2;i<=5;i++)d[1][i]=(d[1][i-1]+9)%11;
    for(i=2;i<=11;i++){
        for(j=1;j<=5;j++){
            d[i][j]=(d[i-1][j]+63)%11;
        }
    }
    n-=2;
    T=n/11,n%=11;
    for(i=1;i<=n;i++){
        for(j=1;j<=5;j++){
            if(d[i][j]==k)cnt++;
        }
    }
    printf("%d\n", cnt+T*5);
    return 0;
}


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

using namespace std;

struct edge {
    int to, cost;
    edge(int to, int cost) : to(to), cost(cost) {};
};

int d[205][205];

int main()
{
    int N, M, R; cin >> N >> M >> R;
    vector<int> r(R);
    
    for (int i = 0; i < 205; ++i) for (int j = 0; j < 205; ++j) d[i][j] = i != j ? 1e9 : 0;
    
    for (int i = 0; i < R; ++i) cin >> r[i], r[i]--;
    for (int i = 0; i < M; ++i) {
        int A, B, C; cin >> A >> B >> C;
        --A, --B;
        d[A][B] = d[B][A] = C;
    }
    
    for (int k = 0; k < N; ++k)
        for (int i = 0; i < N; ++i)
            for (int j = 0; j < N; ++j)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    
    sort(begin(r), end(r));
    
    int ans = 1e9;
    
    do {
        int sum = 0;
        for (int i = 0; i < R - 1; ++i) {
            sum += d[r[i]][r[i+1]];
        }
        ans = min(ans, sum);
    } while (next_permutation(begin(r), end(r)));
    
    cout << ans << endl;
}









Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<queue>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
using namespace std;
namespace ProjectPermy
{
	struct perm
	{
		vector<int>v;
		int &operator[](int x){return v[x];}
		const int &operator[](int x)const{return v[x];}
		int size()const{return v.size()-1;}
		void resize(int n){v.resize(n+1);}
		void read(int n){v.resize(n+1);for(int i=1;i<=size();i++)scanf("%d",&v[i]);}
		void out()
		{
			for(int i=1;i<=size();i++)
				printf("%d ",v[i]);
			printf("\n");
		}
	};
	perm e(int n)
	{
		perm ans;
		ans.resize(n);
		for(int i=1;i<=n;i++)
			ans[i]=i;
		return ans;
	}
	perm operator*(perm a,perm b)
	{
		perm ans=e(a.size());
		perm rev=e(a.size());
		for(int i=1;i<=a.size();i++)
			ans[i]=a[b[i]];
		return ans;
	}
	perm operator~(perm a)
	{
		perm ans=e(a.size());
		for(int i=1;i<=a.size();i++)
			ans[a[i]]=i;
		return ans;
	}
	vector<int>vis,rem;
	perm operate;
	void find_cycle(int x)
	{
		if(vis[x]) return;
		vis[x]=1;
		rem.push_back(x);
		find_cycle(operate[x]);
	}
	perm Pow(perm a,int x)
	{
		perm ans=e(a.size());
		vector<vector<int> >cycle;
		vis.clear();
		vis.resize(a.size()+1);
		operate=a;
		for(int i=1;i<=a.size();i++)
		{
			if(!vis[i])
			{
				rem.clear();
				find_cycle(i);
				cycle.push_back(rem);
			}
		}
		for(int i=0;i<cycle.size();i++)
		{
			for(int j=0;j<cycle[i].size();j++)
				ans[cycle[i][j]]=cycle[i][(j+x)%cycle[i].size()];
		}
		return ans;
	}
}
using namespace ProjectPermy;
signed main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	perm p,q;
	p.read(n);
	q.read(n);
	perm a[7];
	a[1]=p;
	a[2]=q;
	for(int i=3;i<=6;i++)
		a[i]=a[i-1]*(~a[i-2]);
	if(m<=6)
	{
		a[m].out();
		return 0;
	}
	perm g=q*(~p)*(~q)*p;
	(Pow(g,(m-1)/6)*a[(m-1)%6+1]*Pow(~g,(m-1)/6)).out();
	return 0;
}
/*
5
2 4 3 1 5
2 4 3 1 5
*/

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

int main(){
    ll N;
    cin >> N;
    map<string, ll> count;
    ll c=0;

    rep(i,N){
        string in;
        cin >> in;
        char *chars = new char[in.length() + 1];
        strcpy(chars, in.c_str());
        sort(chars,chars+in.length());
        string tmp=chars;

        if(count.count(tmp) > 0){
            count[tmp] += 1;
        }else{
            count.insert(make_pair(tmp, 1));
        }
    }

    for(auto itr = count.begin(); itr != count.end(); ++itr) {
        ll v = itr->second;
        v = v * (v-1) / 2;
        c += v;
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 14336
N, M = map(int, input().split())
A = list(map(int, input().split()))
F = 0
trigger = 1 / (4 * M)

for i in range(len(A)):
    if A[i]/sum(A) >= trigger:
        F = F + 1
        
if F >= M:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type pair struct {
	first  int
	second int
}

type SortBy []pair

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i].second < a[j].second }

func main() {
	sc.Split(bufio.ScanWords)

	N, M := nextInt(), nextInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = nextInt()
	}

	bc := make([]pair, M)
	for i := 0; i < M; i++ {
		B, C := nextInt(), nextInt()
		bc[i] = pair{first: B, second: C}
	}

	sort.Ints(A)
	sort.Sort(sort.Reverse(SortBy(bc)))

	ans := 0
	k := 0
	for _, bcc := range bc {
		for i := 0; i < bcc.first; i++ {
			if k >= N {
				break
			}
			ans += max(A[k], bcc.second)
			k++
		}
	}

	for i := k; i < N; i++ {
		ans += A[i]
	}
	fmt.Println(ans)
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}


Measured memory_bytes: 4992
// AOJ 2570: Shipura
// 2017.12.1 bal4u@uu

#include <stdio.h>
#include <ctype.h>

#define M  1000000007
#define BASE -1
#define SFT  -2
#define S    -3

char b1[2000002];
int stack[2000002], *top;

int main()
{
	int x, y;
	char *p;

	while (fgets(b1+1, sizeof(b1), stdin) && *(b1+1) != '#') {
		p = b1, *p++ = 0; while (*p >= ' ') *p++; *p-- = 0;
		while (*p) {
			if (*p == '<') { *p-- = ' '; continue; }
			if (!isdigit(*p) && *p != 'S') { p--; continue; }
			if (*p == 'S') p--;
			else while (isdigit(*p)) p--;
			while (*p == ' ') p--;
			if (*p == '>' && *(p-1) == '>') *p = 'R', *(p-1) = ' ', p-=2;
		}

		p++, top = stack, *top++ = BASE;
		while (*p) {
			while (*p == ' ') p++;
			if (*p == 'S') { p++, *top++ = S; continue; }
			if (*p == 'R') { p++, *top++ = SFT; continue; }
			if (isdigit(*p)) {
				x = 0;
				while (isdigit(*p)) x = (x<<3)+(x<<1) + (*p++ & 0xf);
			} else {		//  '>'
				p++;
				x = *--top;
				x = (long long)x * x % M;
				top--;
			}
			if (*(top-1) == SFT) {
				top -= 2;
				y = *top;
				if (x > 31) y = 0; else y >>= x;
				x = y;
			}
			*top++ = x;
		}
		printf("%d\n", x);
	}
	return 0;
}

Measured memory_bytes: 2056
def conv(N):
    ans = []
    while True:
        n = N % 26 if N % 26 != 0 else 26
        alph = chr(96 + n)
        ans.append(alph)
        N = int((N-n)/26)
        if N == 0:
            break
    return "".join(ans[::-1])


if __name__ == "__main__":
    n = int(input())
    print(conv(n))


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

int main(){
  int W, H, N;
  cin >> W >> H >> N;
  
  int x, y, a, w, h;
  w = 0;
  h = 0;
  rep(i, N){
    cin >> x >> y >> a;
    if (a == 1) w = max(w, x);
    else if (a == 2) W = min(W, x);
    else if (a == 3) h = max(h, y);
    else if (a == 4) H = min(H, y);
  }
  
  int ans;
  ans = (W-w) * (H-h);
  if ((W-w)<=0 || (H-h)<=0) cout << 0 << endl;
  else cout << ans << endl;
  
      
}

Measured memory_bytes: 256
n,w=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
dp=[[0 for i in range(w+1)] for j in range(n+1)]
for i in range(1,n+1):
  for j in range(1,w+1):
    if j-l[i-1][0]>=0:
      dp[i][j]=max(dp[i-1][j-l[i-1][0]]+l[i-1][1],dp[i-1][j])
    else:
      dp[i][j]=dp[i-1][j]
print(dp[-1][-1])

Measured memory_bytes: 171656
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N;
    cin >> N;
    vector<int> m;
    long long res = 1;
    int cnt = 1;
    while(N > res*26){
        cnt++;
        res *= 26;
        N -= res;
    }
    string s;
    N--;
    while(cnt > 0){
        if(N < 26){
            if(cnt == 1) m.push_back(N);
            else m.push_back(0);
            cnt--;
        }
        else{
            long long t = N / res;
            N = N % res;
            res /= 26;
            cnt--;
            m.push_back(t);
        }
    }
    for(int i = 0; i < m.size(); i++){
        s += 'a' + m[i];
    }
    cout << s << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;

const int N=1e5+1;
int p[N], q[N], t[N], tmp[N];
bool vis[N];
int main() {
	int n=rd(), k=rd();
	for(int i=1; i<=n; ++i) p[i]=rd();
	for(int i=1; i<=n; ++i) q[i]=rd();
	for(int i=1; i<=n; ++i) t[p[i]]=q[i];
	for(int i=1; i<=n; ++i) tmp[q[i]]=t[i];
	for(int i=1; i<=n; ++i) t[i]=tmp[p[i]];
	for(int i=1; i<=(k-1)%6; ++i) {
		for(int j=1; j<=n; ++j) tmp[p[j]]=q[j];
		for(int j=1; j<=n; ++j) p[j]=q[j], q[j]=tmp[j];
	}
	k=(k-1)/6;
	for(int i=1; i<=n; ++i) if(!vis[i]) {
		int cnt=0;
		vis[tmp[cnt++]=i]=true;
		for(int j=i; (j=t[j])!=i; ) vis[tmp[cnt++]=j]=true;
		for(int j=0; j<cnt; ++j) t[tmp[j]]=tmp[(j+k)%cnt];
	}
	for(int i=1; i<=n; ++i) tmp[i]=t[p[i]];
	for(int i=1; i<=n; ++i) p[t[i]]=tmp[i];
	for(int i=1; i<=n; ++i) printf("%d%c", p[i], " \n"[i==n]);
	return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

string s;

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

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

    priority_queue<int> pq;

    int r = 0;
    queue<int> nextl;
    nextl.push(0);
    int ans = 0;
    while (r < N)
    {
        if ((r > 0 && s[r - 1] == '0' && s[r] == '1'))
        {
            nextl.push(r);
        }

        if (nextl.size() == K + 1 && (r > 1 && s[r - 1] == '1' && s[r] == '0'))
        {
            ans = max(ans, r - nextl.front());
            nextl.pop();;
        }
        ++r;
    }

    cout << max(ans, r - nextl.front()) << "\n";
    return 0;
}



Measured memory_bytes: 512
s=input()

temp=0
templi=[0]
for i in range(len(s)):
  if s[i]=="A" or s[i]=="C" or s[i]=="G" or s[i]=="T":
    temp+=1
  else:
    templi.append(temp)
    temp=0
templi.append(temp)

print(max(templi))

Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	private static final Integer[] primeNumberArray = getPrimeNumberArray(110000);
	private static final int[] ansArray = getAnsArray(50000);

	public static void main(String[] args) throws IOException {
		try (BufferedReader input = new BufferedReader(new InputStreamReader(System.in))) {
			while (input.ready()) {
				final int dataset = Integer.valueOf(input.readLine());
				if (dataset == 0)
					break;
				System.out.println(ansArray[dataset]);
			}
		}
	}

	private static int[] getAnsArray(final int maxNumber) {
		int ansArray[] = new int[maxNumber + 1];
		int tmp = 0;
		for (int i = 0; i < primeNumberArray.length; i++) {
			for (int j = i; j < primeNumberArray.length / 2; j++) {
				tmp = primeNumberArray[i] + primeNumberArray[j];
				if (tmp > maxNumber) {
					break;
				}
				ansArray[tmp]++;
			}
		}
		return ansArray;
	}

	public static Integer[] getPrimeNumberArray(final int maxNumber) {
		ArrayList<Integer> primeNumberList = new ArrayList<>();
		primeNumberList.add(2);
		primeNumberList.add(3);
		primeNumberList.add(5);
		primeNumberList.add(7);

		final int[] oneDigitList = { 1, 3, 7, 9 };

		int tmp;
		int sqrtTmp;
		boolean addFlag;
		for (int i = 10; i <= maxNumber; i += 10) {
			for (int oneDigit : oneDigitList) {
				addFlag = true;
				tmp = i + oneDigit;
				sqrtTmp = (int) Math.sqrt(tmp);
				for (int primeNumber : primeNumberList) {
					if (tmp % primeNumber == 0) {
						addFlag = false;
						break;
					}
					if (sqrtTmp < primeNumber) {
						break;
					}
				}
				if (addFlag) {
					primeNumberList.add(tmp);
				}
			}
		}

		return primeNumberList.toArray(new Integer[0]);
	}
}

Measured memory_bytes: 33712
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
ll fact_[200000];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1;
		for (int i = 1; i < 200000; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
		}
	}
	if (x < y) return 0;
	return mod_pow(fact_[x], mod, mod) *
		mod_pow(fact_[x - y], mod - 2, mod) % mod *
		mod_pow(fact_[y], mod - 2, mod) % mod;
}//xCy
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------

signed main() {
	int a, b;
	cin >> a >> b;
	if (a < 10 && b < 10) cout << a * b << endl;
	else cout << -1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int N = 1e5+5;
char str[N];
int main()
{
	int flag=0;
	scanf("%s",str);
	int l=0,r=strlen(str)-1;
	int sum1=0,sum2=0;
	while(l<r)
	{
		if(str[l]==str[r]) 
		{
			l++;
			r--;
		}
		else if(str[l]=='x'&&str[r]!='x'){
			sum1++;
			l++;
		}
		else if(str[l]!='x'&&str[r]=='x')
		{
			sum2++;
			r--;
		}
		else if(str[l]!=str[r])
		{
			flag=1;break;
		}
	}
	if(flag) cout<<"-1\n";
	else cout<<sum1+sum2<<endl;
	
	
} 

Measured memory_bytes: 384
import java.util.Scanner;
import java.util.Arrays;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
 
        int[] inputs = {a, b, c};
        Arrays.sort(inputs);
 
        int da = inputs[2] - inputs[0];
        int db = inputs[2] - inputs[1];
 
        if (da % 2 == 0 && db % 2 == 0) {  // even & even
            System.out.println((da / 2) + (db / 2));
        }
        else if (da % 2 == 1 && db % 2 == 1) {  // odd & odd
            System.out.println(((da - 1) / 2) + ((db - 1) / 2) + 1);
        }
        else {  // odd & even
            System.out.println((da / 2) + (db / 2) + 2);
        }
    }
}


Measured memory_bytes: 23764
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	int N;
	cin >> N;
	ll ans = 1;
	for (int i = 2; i <= N; i++) {
		bool p = 1;
		for (int j = 2; j*j <= i; j++) {
			if (i%j == 0) {
				p = 0;
				break;
			}
		}
		if (p) {
			int m = N;
			int k = 0;
			while (m) {
				k += m / i;
				m /= i;
			}
			(ans *= k + 1) %= MOD;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define int long long
using namespace std;

int n,a[100010],b[100010];
vector<pair<pair<int,int>,int> > v;
bool vis[100010][2];

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	int sum1=0,sum2=0;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
		sum1+=a[i];
		sum2+=b[i];
		v.push_back(make_pair(make_pair(a[i],i),0));
		v.push_back(make_pair(make_pair(b[i],i),1));
	}
	sort(v.begin(),v.end());
	int sum=0;
	for(int i=0;i<n;i++){vis[v[i].first.second][v[i].second]=1;sum+=v[i].first.first;}
	int cnt1=0,cnt2=0,cnt3=0,cnt4=0;
	for(int i=1;i<=n;i++){
		if(!vis[i][0]&&!vis[i][1]) cnt1++;
		if(vis[i][0]&&!vis[i][1]) cnt3++;
		if(!vis[i][0]&&vis[i][1]) cnt2++;
		if(vis[i][0]&&vis[i][1]) cnt4++;
	}
	if(cnt1>0&&cnt4>0) cout<<sum<<endl;
	else if(cnt2==0||cnt3==0) cout<<sum<<endl;
	else{
		int mn=min(sum1,sum2);
		multiset<int> s;
		for(int i=1;i<=n;i++){
			if(vis[i][0]) s.insert(b[i]);
			else s.insert(a[i]);
		} 
		for(int i=1;i<=n;i++){
			if(vis[i][0]){
				int now=sum-a[i];
				s.erase(b[i]);
				now+=*s.begin();
				mn=min(mn,now);
				s.insert(b[i]);
			}
			else{
				int now=sum-b[i];
				s.erase(a[i]);
				now+=*s.begin();
				mn=min(mn,now);
				s.insert(a[i]);
			}
		}
		cout<<mn<<endl;
	}
	return 0;
}

Measured memory_bytes: 12652
# AOJ 0184 Tsuruga Castle
# Python3 2018.6.19 bal4u

while True:
	n = int(input())
	if n == 0: break
	f = [0]*14
	for i in range(n): f[int(input())//10] += 1
	f[6] = sum(f[6:14])
	print(*f[0:7], sep='\n')


Measured memory_bytes: 5616
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mat vector<vector<int>>
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
#define INF (int)1e18


auto max(auto a){auto ans=a[0];for(auto i:a)if(i>ans)ans=i;return ans;}
auto min(auto a){auto ans=a[0];for(auto i:a)if(i<ans)ans=i;return ans;}
void print(auto a){for(auto i:a)cerr<<i<<' ';cerr<<'\n';}


signed main()
{
	fio
	inp(n)
	bool ans=1;
	string s;
	cin>>s;
	if(n%2)
		ans=0;
	else
		fo(i,n/2)
			if(s[i]!=s[n/2+i])
				ans=0;
	if(ans)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	printclock;
}

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

int main(){
  int n, k;
  long m=20000000000;
  cin >> n >> k;
  vector<long>h(n);
  for(int i=0; i<n; i++){
    cin >> h[i];
  }
  sort(h.begin(), h.end());
  for(int i=0; i<=n-k; i++){
    m=min(m, h[i+k-1]-h[i]);
  }
  cout << m;
  return 0;
}

Measured memory_bytes: 1024
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		int a=scanner.nextInt();
		int b=scanner.nextInt();
		int sam =0;
		int[] ar =new int[1004];
		for(int i=0;i<a;i++) {
			ar[i]=scanner.nextInt();
			sam+=ar[i];
		}
		int k=0;
		if(sam%(4*b)!=0)k++;
		k+=sam/(4*b);
		int t=0;
		for(int i=0;i<a;i++) {
			if(ar[i]>=k)t++;
		}
		if(t>=b)System.out.println("Yes");
		else System.out.println("No");
	}

}

Measured memory_bytes: 23124