akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int N,A[100],B[100],C[100],ans=0,temp=-1;
  cin>>N;

  for(int i=0;i<N;i++){
    cin>>A[i];
  } 
  for(int i=0;i<N;i++){
    cin>>B[i];
    ans+=B[i];
  } 
  for(int i=1;i<=N-1;i++) cin>>C[i];

  for(int i=0;i<N;i++){
    if(temp+1==A[i]){
      ans+=C[temp];
    }
    temp=A[i];
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 888
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;
int x,y,s;

int func(int a, int x) {
    return a*(100.0+x)/100.0;
}

void solve() {
    int ans = 0;
    rep(i,s) rep(j,s) {
        if(i==0 || j==0) continue;
        if(func(i,x) + func(j,x) == s) {
            ans = max(ans, func(i,y)+func(j,y));
        }
    }
    cout<<ans<<endl;
}

int main() {
    while(cin>>x>>y>>s) {
        if(x+y+s==0) break;
        solve();
    }
    return 0;
}

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

using namespace std;

typedef pair<double,double> P;
 
int main(){
  int N;
 
  cin >> N;
  vector<P> v;
  double ans = 0, x ,y;
  for(int i = 0 ; i < N ; i++){
    cin >> x >> y;
    v.push_back(P(x,y));
  } 
  for(int i = 1; i < N+1 ; i++){
    ans += (v[i%N].first-v[i-1].first)*(v[i%N].second+v[i-1].second);
  }
  ans /= 2.0;
  printf("%.1f\n" ,abs(ans));
  
  return 0;
}

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

int main(void){
    int A, B, C, D, E;
    int t;
    cin >> A >> B >> C >> D >> E;
    
    if(A < 0){
        t = -A * C + D + B * E;
    }else{
        t = (B-A) * E;
        if(A == 0) t += D;
    }
    cout << t << endl;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define pii pair<ll,ll>
#define pi pair<int ,int> 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i,a,n) for(int i=a;i>=n;i-- )
 ll power(ll x,ll y)
 {
     if(y==0){return 1;}
     ll ans=power(x,y/2)%mod;
      ans=(ans%mod*ans%mod)%mod;
      return (y%2==0)?(ans):(ans%mod*x%mod)%mod;
     
 }
  ll gcd(ll x,ll y)
  {
      if(y==0){return x;}
      return gcd(y,x%y);
  }
   ll lcm(ll x,ll y)
   {
       ll temp=(x*y)%mod;
       ll t1=gcd(x,y);
       ll t2=power(t1,mod-2);
       
       return (temp*t2)%mod;
   }
int main() {
  
  
  ll n;
  cin>>n;
   ll A[n];
   map<ll,ll>mp,mop;
  REP(i,0,n)
  {
      cin>>A[i];
      ll x=A[i];
      for(int j=2;j*j<=x;j++)
      {
         while(x%j==0)
         {
             mp[j]++;
             x/=j;
         }
      }
      if(x>1)
      {
          mp[x]++;
      }
      
      for(auto j:mp)
      {
          mop[j.F]=max(mop[j.F],j.S);
      }
      mp.clear();
      
  }
  ll lc=1,ans=0;
  for(auto i:mop)
  {
      lc=((lc%mod)*(power(i.F,i.S)%mod))%mod;
  }
  REP(i,0,n)
  {
      ll temp=power(A[i],mod-2)%mod;
      ll t1=((temp%mod)*(lc%mod))%mod;
      ans=((ans%mod)+(t1%mod))%mod;
  }
  
  
  cout<<ans%mod;
  
  

	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
    using namespace std;
     
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define endl "\n"
    #define int long long
     
    const int N = 505;
     
    int n, k, sum = 0;
    int a[N];
     
    int check(int x)
    {
    	int reqd = 0;
    	vector<int> v;
    	for(int i = 1; i <= n; i++)
    	{
    		int cur = a[i] % x;
    		v.push_back(cur);
    	}
    	sort(v.begin(), v.end());
    	int l = 0, r = v.size() - 1;
    	int rem = 0;
    	while(l <= r)
    	{
    		if(rem <= 0)
    		{
    			rem += v[l];
    			reqd += v[l];
    			l++;
    		}
    		else
    		{
    			rem -= (x - v[r]);
    			reqd += (x - v[r]);
    			r--;
    		}
    	}
    	if(reqd > 2 * k)
    		return 0;
    	if(rem != 0)
    		return 0;
    	return 1;
    }
     
    int32_t main()
    {
    	IOS;
    	cin >> n >> k;
    	for(int i = 1; i <= n; i++)
    	{
    		cin >> a[i];
    		sum += a[i];
    	}
    	int ans = 1;
    	for(int i = 1; i * i <= sum; i++)
    	{
    		if(sum % i == 0)
    		{
    			if(check(i))
    				ans = max(ans, i);
    			if(check(sum / i))
    				ans = max(ans, sum / i);
    		}
    	}
    	cout << ans;
    	return 0;
    }

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
k = 0
a = sorted(a)
maxa = a[int(len(a)/2)]
mina = a[int(len(a)/2)-1]+1
if mina > maxa:
    print(0)
else:
    print(maxa-mina+1)

Measured memory_bytes: 14428
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>

using namespace std;
using ll = long long int; 

void prime(vector<int> &num, int n){
    for(int i=0;i<=n;i++){
        num[i] = 1;
    }
    num[0] = 0;
    num[1] = 0;
    num[2] = 1;

    for(int i=2;i<=sqrt(n);i++){
        if(num[i] == 1){
            for(int j=2;j<=n/i;j++){
                num[i*j] = 0;
            }
        }
    }
}


ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

ll keta(ll a){
  ll ans = 1;
  while(1){
    if(a/10 > 0){
      ans++;
      a = a/10;
    }
    if(a<10) break;
  }
  return ans;
}

const int MAX = 50;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void){

    ll n;
    cin>>n;
    ll ans = 0;

    if(n%2==1){
        cout<<"0"<<endl;
        return 0;
    }else{
        //10の倍数が何個あるか数える
        int piv = 1;
        
        while(1){
            ll val = pow(5, piv);
            ans += n/val/2;
            piv++;
            if(n/val==0)break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
program main

  implicit none

  integer    :: n, k
  integer,allocatable :: p(:)
  real(8)   ,allocatable :: sp(:)
  real(8)   ,allocatable :: h(:)
  real(8)   ,allocatable :: sh(:)
  integer :: i, j 
  real(8) :: rj
  
  read(*,*) n, k
  allocate( p(n) )
  allocate( h(n) )
  read(*,*) p

  allocate( sp(maxval( p )) )
  j = 0
  do i = 1, maxval( p )
    j = j + i
    sp(i) = j
  end do

  do i = 1, n
    h(i) = sp(p(i)) / p(i) 
  end do

  allocate( sh(n-k+1) )
  rj = sum( h(1:k) )
  do i = 1, n-k+1
    sh(i) = rj
    rj = rj + h(i+k) - h(i) 
  end do
  
  call quicksort1( sh, 1, n-k+1 ) 

  print*, sh( n-k+1 )

end program main

recursive subroutine quicksort1(a, first, last)
  implicit none
  real(8),intent(inout)::a(*)
  integer,intent(in)::first,last
  !
  ! Original
  ! https://gist.github.com/t-nissie/479f0f16966925fa29ea
  !
  real(8)::x,t
  integer::i,j

  x = a((first+last)/2)
  i = first
  j = last
  do
     do while (a(i) < x)
        i=i+1
     end do
     do while (x < a(j))
        j=j-1
     end do
     if (i >= j) exit
     t = a(i)
     a(i) = a(j)
     a(j) = t
     i=i+1
     j=j-1
  end do
  if (first < i-1) call quicksort1(a, first, i-1)
  if (j+1 < last)  call quicksort1(a, j+1, last)

  return
end subroutine quicksort1


Measured memory_bytes: 4736
#include<iostream>
#include<vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <limits>
#include <map>
#include <bitset>

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

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

vector< vector<int> > memo;

int gcd(int a, int b, int c) {
	int min_num = (a > b) ? b : a;
	if (min_num > c) min_num = c;
	while (min_num != 1) {
		if (a % min_num == 0 && b % min_num == 0 && c % min_num == 0) break;
		min_num--;
	}
	return min_num;
}

int gcd(int a, int b) {
	int m = (a < b) ? a : b;
	while (m != 1) {
		if (a % m == 0 && b % m == 0)break;
		m--;
	}
	return m;
}



int main() {
	int s,w;
	cin >> s >> w;
	if (s > w)cout << "safe" << endl;
	else cout << "unsafe" << endl;
	
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001; // > 10^9
const int MOD = (int)1e9 + 7;
const ll INFLL = 1001001001001001001;  // > 10^18
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

  int n; cin >>n;
  vector<string> s(n); rep(i,n) cin >> s[i];

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

  vector<int> nums;
  int res = 0;
  for (int i = 0; i < s.size();) {
      int j = i;
      while (j < s.size() && s[i] == s[j]) {
          j++;
      }
      nums.push_back(j-i);
      res = max(res, j - i);
      i = j;
  }

  vector<string> ou;
  for (int i = 0; i < s.size();) {
      int j = i;
      while (j < s.size() && s[i] == s[j]) {
          j++;
      }
      if (j - i == res) {
        ou.push_back(s[i]);
      } 
      i = j;
  }

  sort(ou.begin(), ou.end());
  for (int i = 0; i < ou.size(); i++) {
    cout << ou[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 16756
#include<iostream>
#define n_max 100000
using namespace std;
int find(int);
int com[n_max],x[n_max],y[n_max],par[n_max],rank[n_max];

bool same(int x,int y){
  return find(x) == find(y);
}

void unite(int x,int y){
  
  x= find(x);
  y= find(y);
  

  if(rank[x] > rank[y]){
    par[y] = x;
  }
  else {
    par[x] = y;
    if(rank[x] == rank[y]) rank[y]++;
  }

}


int find(int x){
  if(x != par[x]){
    par[x] = find(par[x]);
  }
  return par[x];
}

int main(){
  
  int n,q;
  cin >>n>>q;
  
  for(int i=0;i<n;i++){
    par[i]=i;
    rank[i]=0;
  }
  
  for(int i=0;i<q;i++){
    cin >>com[i]>>x[i]>>y[i];

    if(com[i]){
      same(x[i],y[i]);
      cout <<same(x[i],y[i])<<endl;
    }
    else{
      unite(x[i],y[i]);
    }
    
    
  }


 
  
}

Measured memory_bytes: 2420
import copy
H,W = map(int,input().split())
S = [['.']*(W+2)]
for i in range(H):
    S.append(list('.'+input()+'.'))
S.append(['.']*(W+2))
T = copy.deepcopy(S)
for i in range(1,H+1):
    for j in range(1,W+1):
        if S[i][j] == '#':
            continue
        s = 0
        for k in [-1,0,1]:
            for l in [-1,0,1]:
                if S[i+k][j+l]=='#':
                    s += 1
        T[i][j] = s
for i in range(1,H+1):
    print(''.join([str(i) for i in T[i][1:W+1]]))


Measured memory_bytes: 41840
#include<iostream>
#include<algorithm>
using namespace std;
constexpr auto maxn = 200005;
long long a[maxn];
long long b[maxn];
int main() {
	int n;
	int temp1;
	int temp2;
	cin >> n;
	long long sum = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		sum += a[i];
		b[i] = sum;
	}
	for (int i = 1; i <= n; i++) {
		if (sum % 2 == 0 && sum / 2 == b[i])
			return cout << 0, 0;
		else if(sum%2==1 && sum/2==b[i])
			return cout << 1, 0;
	}
	for (int i = 1; i <= n; i++) {
		if (b[i] > sum / 2) {
			temp1 = i;
			break;
		}
	}
	for (int i = 1; i <= n; i++) {
		if (b[n] - b[i] < sum / 2)
		{
			temp2 = i;
			break;
		}
	}
	cout << min(b[temp1]-(b[n] - b[temp1]),b[n]-2*b[temp2-1]);
	return 0;
}

Measured memory_bytes: 3328
function Main(input) {
	input = input.trim();
	input = input.split(" ");
	var num = parseInt(input[0] + input[1], 10);

	var ans = Math.sqrt(num);
	ans = String(ans).split(".");

    if (ans.length === 1) {
		console.log("Yes");
	} else {
		console.log("No");
	}
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <numeric>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;
ll  LINF = 1e18;

// int main(){
// 	ll n;
// 	int x,m;cin >> n >> x >> m;
// 	vector<int> res(100005);
// 	ll temp = x;
// 	ll len = 1;
// 	bool flag = false;
// 	while(true){
// 		temp %= m;
// 		cout << temp << endl;
// 		if(temp == 0) flag = true;
// 		if(res[temp]!=0) break;
// 		res[temp]++;
// 		temp *= temp;
// 		len++;
// 	}
// 	len--;
// 	ll ans = 0;
// 	if(flag){
// 		rep(i,m) if(res[i]!=0) ans += i;
// 		cout << ans << endl;
// 		return 0;
// 	}
// 	rep(i,m) if(res[i]!=0) ans += i;
// 	cout << ans << endl;
// 	ans += (n-len)*temp;
// 	//rep(i,20) if(res[i]!=0) cout << len << endl;
// 	// temp = x;
// 	// rep(i,n%len){
// 	// 	temp %= m;
// 	// 	ans += temp;
// 	// 	temp *= temp;
// 	// }
// 	cout << ans << endl;

// }





int main(){
	int mod = 998244353; 
	int n,k;cin >> n >> k;
	vector<P> step(k);
	vector<ll> ans(200050),cum(200050);
	rep(i,k){
		int l,r;cin >> l >> r;
		step[i] = make_pair(l,r);
	}
	cum[1] = 1;
	ans[1] = 1;
	for(int i = 2;i <= n;i++){
		for(P p:step){
			if(i-p.first<0) continue;
			int li = i - p.second;
			int ri = i - p.first;
			li = max(li,1);
			ans[i] += cum[ri] - cum[li-1];
			ans[i] %= mod;
			if(ans[i]<0) ans[i] += mod;
		}
		cum[i] = (cum[i-1]+ans[i])%mod;
	}
	//rep(i,n+1)cout << ans[i] << endl;
	cout << ans[n] << endl;
}


Measured memory_bytes: 6424
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ins insert
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define up_b upper_bound
#define low_b lower_bound
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define rev(i,a,b) for(int i=b;i>=a;i--)
#define boost ios_base::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL)
#define nl '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<pii> vii;

const int N=201;
const int MXN=1000001;
const int inf=1e9;
const ll INF=1e18;

int main(){
  boost;
  int a,b;
  cin>>a>>b;
  if(a<=0&&b>=0)cout<<"Zero";
  else if(a>0)cout<<"Positive";
  else if((b-a+1)%2)cout<<"Negative";
  else cout<<"Positive";
  return 0;
}


Measured memory_bytes: 256
import itertools
 
n,m,r_ = map(int, input().split( ))
 
r = list(map(int, input().split( )))
for i in range(r_):
  	r[i] -= 1
d = [[10**10 for _ in range(n)] for i in range(n)]
 
for i in range(m):
    ai,bi,ci = map(int, input().split( ))
    ai-=1
    bi-=1
    d[ai][bi] = d[bi][ai] = ci

for k in range(n):
    for i in range(n):
        for j in range(n):
            d[i][j] = min(d[i][k]+d[k][j],d[i][j])
ans= 100000000000000
for l in itertools.permutations(r,r_):
    tmp = 0
    for i in range(r_-1):
        tmp += d[l[i]][l[i+1]]
    ans = min(ans, tmp)
 
print(ans)

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

int main() {
    int n;
    cin >> n;
    int x[8], y[8];
    rep(i, n) cin >> x[i] >> y[i];

    int f = 1;
    for(int i = 1; i <= n; i++) {
        f *= i;
    }

    vector<int> ord(n);
    rep(i, n) ord[i] = i;

    double res = 0;
    do {
        rep(i, n) {
            if(i == 0) continue;
            res += sqrt((x[ord[i-1]] - x[ord[i]])*(x[ord[i - 1]] - x[ord[i]]) + (y[ord[i - 1]] - y[ord[i]])*(y[ord[i - 1]] - y[ord[i]]));
        }
    }
    while(next_permutation(ord.begin(), ord.end()));

    printf("%.10f\n", res / f);
    //cout << f << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
INF = 10**9
mod = 10**9+7

N,M = I()
a = l()
num1 = format(a[0],'b')[::-1].find('1')
num2 = 1
for i in range(N):
  num2 = lcm(num2,a[i])
  if num1 != format(a[i],'b')[::-1].find('1'):
    print(0)
    exit()
num2 = num2//2
print(math.ceil(M//num2/2))

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

int main(){
  int N, K;
  cin >> N >> K;
  int cnt, tmp;
  
  for (int i = 0; i < N; i++) {
    cin >> tmp;
    if (tmp >= K) cnt++;
  }

  cout << cnt;
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
int main()
{
	int n;
	char prime[50001];
	for(int i = 0; i <= 50000; i++)
		prime[i] = 1;
	prime[0] = 0; prime[1] = 0;
	for(int i = 2; i <= 50000; i++){
		if(!prime[i]) continue;
		for(int j = i + i; j <= 50000; j += i)
			prime[j] = 0;
	}
	while(scanf("%d\n", &n), n){
		int cnt = 0;
		for(int i = 2; i <= n / 2; i++)
			if(prime[i] && prime[n - i])
				cnt++;
		printf("%d\n", cnt);
	}
	return 0;
}

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

typedef long long ll;

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
int main() {
    ll S, MOD = 1e9 + 7;
    vector<ll> F(4001, 1);
    rep(i, 4000) F[i + 1] = (F[i] * (i + 1)) % MOD;
    cin >> S;
    if (S < 3) {
        cout << "0\n";
        return 0;
    }
    ll ans = 0;
    for (ll i = 1; i <= S / 3; i++) {
        ll x = S - i * 3;
        ll y = (F[x + i - 1] * mod_pow(F[i - 1], MOD - 2, MOD)) % MOD;
        y = (y * mod_pow(F[x], MOD - 2, MOD)) % MOD;
        ans = (ans + y) % MOD;
    }
    cout << ans << "\n";
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  ll MOD = 1e9+7;
  vl a(n),t(n),g(n),c(n);
  REP(i,n){
    if(i==0){
      a[i] = 1;
      t[i] = 1;
      g[i] = 1;
      c[i] = 1;
      continue;
    }
    if(i==1){
      a[i] = 4;
      t[i] = 4;
      g[i] = 4;
      c[i] = 4;
      continue;
    }
    a[i] = a[i-1] + t[i-1] + g[i-1] + c[i-1];
    t[i] = a[i-1] + t[i-1] + g[i-1] + c[i-1];
    g[i] = a[i-1] + t[i-1] + g[i-1] + c[i-1] - a[i-2];
    c[i] = a[i-1] + t[i-1] + g[i-1] + c[i-1] - a[i-2] -g[i-2];
    if(i==2) continue;
    c[i] -= 3*a[i-3];
    g[i] += g[i-3];
    a[i] += MOD;
    t[i] += MOD;
    g[i] += MOD;
    c[i] += MOD;
    a[i] %= MOD;
    t[i] %= MOD;
    g[i] %= MOD;
    c[i] %= MOD;
  }
  ll ans = a[n-1]+t[n-1]+g[n-1]+c[n-1];
  ans %= MOD;
  cout << ans  << endl;
  return 0;
}


Measured memory_bytes: 256
/*input
13
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=200005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;

ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a;
    cin>>a;
    cout<<(a*(a-1))/2;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<cassert>
#include<stack>
#include<fstream>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

int main(){
	int n,p;
	string s;
	cin>>n>>p>>s;
	if(p==2||p==5){
		ll ans=0;
		for(int i=0;i<s.size();i++){
			if((s[i]-'0')%p==0)ans+=i+1;
		}
		cout<<ans<<endl;
		return 0;
	}
	ll cnt[10010];
	rep(i,p)cnt[i]=0;
	ll rui=0,po=1;
	cnt[0]++;
	for(int i=s.size()-1;i>=0;i--){
		rui+=(s[i]-'0')*po;
		rui%=p;
		cnt[rui]++;
		po=po*10%p;
	}
	ll ans=0;
	rep(i,p){
		ans+=cnt[i]*(cnt[i]-1)/2;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

bool e[1000001];

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

    e[s] = true;
    int a = s;
    FOR (i,2,100000) {
        int t;
        if (a % 2 == 1) {
            t = 3 * a + 1;
        } else {
            t = a / 2;
        }

        //cout<<t<<" ";
        if (e[t]) {
            cout<<i<<endl;
            break;
        } else {
            e[t] = true;
            a = t;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll N;
	cin >> N;
	map<string, ll> dic_blue;
	rep(i, 0, N) {
		string str;
		cin >> str;
		dic_blue[str]++;
	}

	ll M;
	cin >> M;
	map<string, ll> dic_red;
	rep(i, 0, M) {
		string str;
		cin >> str;
		dic_red[str]++;
	}

	ll ans = 0;
	for (auto x : dic_blue) {
		auto y = dic_red.find(x.first);
		if (y == dic_red.end()) {
			ans = max(ans,x.second);
		}
		else {
			if (x.second > y->second) {
				ans = max(ans,x.second - y->second);
			}
		}
	}

	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 3636
///cREATED bY BERNARB.01
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef priority_queue<int,vector<int>,greater<int>> pqil;
typedef priority_queue<int> pqig;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef priority_queue<pii> pqiig;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<int, int> mii;
#define mid ((l+r)/2)
#define PB push_back
#define PP pop_back
#define PF push_front
#define DF pop_front
#define F first
#define S second
#define MP make_pair
#define C continue
#define B break
#define R return
#define sz(v) (int)(v).size()
#define len(s) (int)(s).length()
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define clr(arr, x) memset((arr), (x), sizeof (arr))
#define loop(n) for(int i=0; i<(n); i++)
#define lop(a, n) for(int i=(a); i<(n); i++)
#define jloop(n) for(ll j=0; j<(n); j++)
#define kloop(n) for(ll k=0; k<(n); k++)
#define rloop(n) for(ll i=(n)-1; i>=0; i--)
#define sgm(y) (((y)*((y)+1))/2)
const ll INF = 2e17+423;
const ll mod = 1e9+7; //998244353;
const ld pi = acos(-1.0);
const ld cmpf = 1e-9;
//__int128_t
//      -ASCII-
//a -> z | A -> Z | 0 -> 9
//97 122 | 65  90 | 48  57
#define endl '\n'
ll po(ll,ll);















int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int x; cin >> x;
  int siv[2*x];
  clr(siv, 0);
  for(int i=2; i<=2*x; i++){
    if(siv[i]) C;
    for(int u=2*i; u<=2*x; u+=i){
      siv[u]=i;
    }
  }
  while(siv[x]) x++;
  cout << x << endl;
  R 0;
}
/*

*/




























































ll po(ll x, ll n){
  if(n==0) R 1;
  ll y = po(x, n/2);
  y = ((y)*(y));
  if(n%2) y = (y*(x));
  R y;
}


Measured memory_bytes: 1024
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define SZ(a) int(a.size())
#define ALL(x) (x).begin(),(x).end()
#define trav(a,x) for (auto& a: x)
#define LOG(FMT...) fprintf(stderr, FMT)
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; cin>>___T; for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const double PI = acos(-1.0);
constexpr int maxn = 1e6+10;
constexpr int mod = 1e9+7;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr ull base=2333, P_1=19260811, P_2=999998639;
void add(int &a,int b) {a+=b; if(a>=mod) a-=mod;}
void dec(int &a,int b) {a-=b; if(a<0) a+=mod;}
int main()
{
    string s;
    cin >> s;
    cout << (s=="ABC"?"ARC":"ABC");

    
}

Measured memory_bytes: 3108
#include <iostream>
#include <cmath>

using std::cout;
using std::endl;
using std::cin;
using std::abs;

int T[100'010];
int X[100'010];
int Y[100'010];

int main() {
	// Input
	int N;
	cin >> N;
	for(int i = 0; i < N; ++i) {
		cin >> T[i] >> X[i] >> Y[i];
	}
	// Calculation
	bool isPossible = true;
	int curT = 0;
	int curX = 0;
	int curY = 0;
	for(int i = 0; i < N; ++i) {
		int duration = T[i] - curT;
		int distance = abs(X[i] - curX) + abs(Y[i] - curY);
		if(distance > duration || (duration % 2 != distance % 2)) {
			isPossible = false;
			break;
		}
		curT = T[i];
		curX = X[i];
		curY = Y[i];
	}
	// Output
	if(isPossible) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

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

typedef long long lli;
#define MX 1000000
const lli MOD = 1000000007;

lli fact[MX+2];
lli factinvrse[MX+2];
lli invrse[MX+2];

void init()
{
    fact[0] = fact[1] = invrse[1] = factinvrse[0] = factinvrse[1] = 1;
    for (int i = 2; i < MX+3; i++)
    {
        fact[i] = (fact[i - 1] * i) % MOD;
        invrse[i] = MOD - invrse[MOD%i] * (MOD / i) % MOD;
        factinvrse[i] = factinvrse[i - 1] * invrse[i] % MOD;
    }
}

lli solve(lli n, lli k)
{
    if (k < 0 || n < 0)return 0;
    if (n < k)return 0;
    return fact[n] * (factinvrse[k] * factinvrse[n - k] % MOD) % MOD;
}

int main()
{
    init();
    lli x, y;
    cin>>x>>y;
    if((x + y) % 3 != 0)puts("0");
    else
    {
        lli n = (x+y)/3;
        if( x - n < 0 || (2 * n - x) < 0)puts("0");
        else cout<<solve(n, x - n)<<endl;
    }
}


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

int n,m,c[10],d[10];
int dp[10010][10];
int temp[10];

bool compare(int t)
{
    if(temp[0] > dp[t][0])
        return true;

    if(temp[0] < dp[t][0])
        return false;

    for(int i = 9; i >= 1; i--)
    {
        if(temp[i] > dp[t][i])
            return true;

        if(temp[i] < dp[t][i])
            return false;
    }

    return false;
}

int main(void)
{
    c[0] = 99;
    c[1] = 2;
    c[2] = 5;
    c[3] = 5;
    c[4] = 4;
    c[5] = 5;
    c[6] = 6;
    c[7] = 3;
    c[8] = 7;
    c[9] = 6;

    cin >> n >> m;
    rep(i,m)
    {
        int a;
        cin >> a;

        if(d[c[a]] < a)
            d[c[a]] = a;
    }

    rep(i,n)
    {
        dp[i+1][0] = -1;
    }


    rep(i,n)
    {
        temp[0] = dp[i][0] + 1;

        loop(j,2,8)
        {
            if(d[j] == 0)
                continue;

            loop(k,1,10)
            {
                temp[k] = dp[i][k];
            }
            temp[d[j]]++;

            if(compare(i+j))
            {
                rep(k,10)
                {
                    dp[i+j][k] = temp[k];
                }                
            }
        }
    }

    for(int i = 9; i >= 1; i--)
    {
        rep(j,dp[n][i])
        {
            cout << i;
        }
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rrep(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;
using namespace std;

int dp[3050][3050];

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n,m,u,v; cin >> n >> m;
  vector<vector<int>> G(n);
  vector<int> in(n,0),a(n,0);
  queue<int> q;
  rep(i,m){
    cin >> u >> v;
    u--; v--;
    G[u].push_back(v); in[v]++;
  }
  rep(i,n) if(in[i] == 0){ q.push(i); a[i] = 0;}
  
  int ans = 0;
  while(!q.empty()){
    int now = q.front(); q.pop();
    for(auto i : G[now]){
      a[i] = max(a[i],a[now]+1);
      in[i]--;
      if(in[i] == 0) q.push(i);
    }
  }
  rep(i,n) ans = max(ans,a[i]);
  cout << ans << endl;
  return 0;
}

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

struct NODE{
	NODE *from,*to;
	NODE(){ from = to = 0; }
};
NODE student[200010];
int main(){	
	int N,M,Q;
	cin >> N >> M >> Q;
	map<NODE*,int> remain;
	for(int i = 0 ; i < N ; i++){
		student[i].to = &student[(i+1)%N];
		student[i].from = &student[(i-1+N)%N];
	}
	NODE *root = &student[0];
	for(int i = 0 ; i < M ; i++){
		int a; cin >> a;
		if( a & 1 ){
			while( a-- ) root = root->from;
		}else{
			while( a-- ) root = root->to;
		}
		root->from->to = root->to;
		root->to->from = root->from;
		root = root->to;
	}
	while( remain.count(root) == false ){
		remain[root] = true;
		root = root->to;
	}
	
	for(int i = 0 ; i < Q ; i++){
		int q; cin >> q;
		cout << remain[&student[q]] << endl;
	}
	
}

Measured memory_bytes: 4384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  int n; cin >> n;
  pair< pair<string, int>, int> pairs[n];

  for (int i = 0; i < n; i++) {
    string name;
    int score;
    cin >> name >> score;
    pairs[i] = make_pair(make_pair(name, -score), i);
  }
  sort(pairs, pairs + n);

  for (int i = 0; i < n; i++) {
    cout << pairs[i].second + 1 << endl;
  }

  return 0;
}


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

template <class T>
inline void read(T &res)
{
	res = 0; bool bo = 0; char c;
	while (((c = getchar()) < '0' || c > '9') && c != '-');
	if (c == '-') bo = 1; else res = c - 48;
	while ((c = getchar()) >= '0' && c <= '9')
		res = (res << 3) + (res << 1) + (c - 48);
	if (bo) res = ~res + 1;
}

const int N = 1e5 + 5;

int n, a[N], b[N], tot;

int main()
{
	read(n);
	for (int i = 1; i <= n; i++) read(a[i]);
	std::sort(a + 1, a + n + 1);
	if (n % 3) return puts(a[1] == 0 && a[n] == 0 ? "Yes" : "No"), 0;
	for (int i = 1; i <= n / 3; i++)
		b[++tot] = a[i], b[++tot] = a[i + n / 3], b[++tot] = a[i + 2 * n / 3];
	b[n + 1] = b[1]; b[n + 2] = b[2];
	for (int i = 1; i <= n; i++) if (b[i] ^ b[i + 1] ^ b[i + 2])
		return puts("No"), 0;
	return puts("Yes"), 0;
}

Measured memory_bytes: 4284
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string[] str;
            str = Console.ReadLine ().Split (' ');

            int N = int.Parse (str[0]);
            long[] L = new long[N];
            str = Console.ReadLine ().Split (' ');

            for (int i = 0; i < N; i++)
            {
                L[i] = int.Parse (str[i]);
            }
            int ans = 0;
            for (int i = 0; i < N - 2; i++)
            {
                for (int j = i + 1; j < N - 1; j++)
                {
                    for (int k = j + 1; k < N; k++)
                    {
                        if (L[i] != L[j] && L[j] != L[k] && L[k] != L[i] && L[i] + L[j] > L[k] && L[j] + L[k] > L[i] && L[k] + L[i] > L[j]) ans++;
                    }
                }
            }

            Console.Write (ans);
        }
    }

    class MyLibrary
    {
        public static int GCD (int a, int b)
        {
            if (a % b == 0) return b;
            return GCD (b, a % b);
        }
    }
}

Measured memory_bytes: 27564
#include<bits/stdc++.h>
using namespace std;
     
     
typedef long long ll;
typedef vector <int> vi;
typedef pair <int,int> pi;
typedef tuple <int,int,int> ti;

#define forn(i,a,n) for(int i = a; i < n ; i++)
#define mem(str,a) memset(str, a, sizeof(str));
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(nullptr)
const int MOD = 1e9+7, N = 1e7 + 10, E = 1e-9;
/*
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
//vector <int> show;
//for (auto x : show)
//   cout << x << " ";
getline(cin,s);


*/

int main() {
    string w;
    cin >> w;
    int count[26] = {0};
    forn(i,0,w.size()) {
        count[w[i]-'a']++;
    }
    bool even = true;
    forn(i,0,26) {
        if(count[i]%2 != 0) {
            even = false;
            break;
        }
    }
    if(even == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3592
hwm=input("").split(" ")
h=int(hwm[0])
w=int(hwm[1])
m=int(hwm[2])
liw=[]
ww=[]
hh=[]
for i in range(w):
    liw+=[[]]
    ww+=[0]
for i in range(h):
    hh+=[0]
for i in range(m):
    hw=input("").split(" ")
    hh[int(hw[0])-1]+=1
    ww[int(hw[1])-1]+=1
    liw[int(hw[1])-1]+=[int(hw[0])-1]
mw=max(ww)
mh=max(hh)
w0=[]

h0=[]

c=0
for i in ww:
    if(mw==i):
        w0+=[c]
    
    c+=1
c=0
for i in hh:
    if(mh==i):
        h0+=[c]
    
    c+=1
for i in w0:
    if not(set(h0)<=set(liw[i])):
        print(mh+mw)
        break
else:
    print(mh+mw-1)


Measured memory_bytes: 90264
import java.io.*;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader r = new BufferedReader (new InputStreamReader (System.in));
		String s1 = r.readLine();
		
		int c = 0;
		
		if (isMonth(s1.substring(0, 2))) {
			c += 2;
		}
		if (isMonth(s1.substring(2, 4))) {
			c += 1;
		}
		
		if (c == 0) {
			System.out.println("NA");
		}
		if (c == 1) {
			System.out.println("YYMM");
		}
		if (c == 2) {
			System.out.println("MMYY");
		}
		if (c == 3) {
			System.out.println("AMBIGUOUS");
		}
	}
	
	static boolean isMonth(String data) {
		if (data.equals("01")) {
			return true;
		}
		if (data.equals("02")) {
			return true;
		}
		if (data.equals("03")) {
			return true;
		}
		if (data.equals("04")) {
			return true;
		}
		if (data.equals("05")) {
			return true;
		}
		if (data.equals("06")) {
			return true;
		}
		if (data.equals("07")) {
			return true;
		}
		if (data.equals("08")) {
			return true;
		}
		if (data.equals("09")) {
			return true;
		}
		if (data.equals("10")) {
			return true;
		}
		if (data.equals("11")) {
			return true;
		}
		if (data.equals("12")) {
			return true;
		}
		return false;
	}
}

Measured memory_bytes: 22356
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var num = Input.num;
        var ar = Input.ar;
        WriteLine(ar.Count(c => c % 2 == 1) % 2 == 0 ? "YES" : "NO");
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public  static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 20704
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<map>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const int mod=1000000007;
const llint big=1e18+10;
const long double pai=3.141592653589793238462643383279;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
int gcd(int a,int b){if(a%b==0){return b;}else return gcd(b,a%b);}//a>b
llint ans=0;
int solve(vector<llint>&a ){
	llint i,n=a.size();
	while(-1){
		llint now=0;
		for(i=0;i<n;i++){
			now+=max((llint)0,(a[i]+ans+1)/(n+1));
		}
		if(now<=ans){return ans;}//足りる
		ans++;
	}
}
std::random_device seed_gen;
mt19937 engine(seed_gen());
int main(void){
	cout<<50<<endl;
	llint i,k;cin>>k;
	vector<llint> a(50);
	for(i=0;i<50;i++){a[i]=i;}
	for(i=0;i<50;i++){a[i]+=(k+i)/50;}
	for(i=0;i<50;i++){cout<<a[i]<<" ";}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    string s;
    cin>>s;
    int start=-1,end;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='A'&&start==-1){
            start=i;
        }
        if(s[i]=='Z'&&start!=-1){
            end=i;
        }
    }
    cout<<end-start+1;
}

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

int main(){
    int a, b;
    string s;
    cin >> a >> b;
    cin >> s;
    string pattern = "\\d{" + to_string(a) + "}-\\d{" + to_string(b) + "}";
    regex regex(pattern);
    if(regex_match(s, regex)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[][] arr = new int[N+1000][3];
        int[][] memo = new int[N+1000][3];

        for (int i = 0; i < N; i++) {
            arr[i][0] = sc.nextInt();
            arr[i][1] = sc.nextInt();
            arr[i][2] = sc.nextInt();
        }

        for (int i = 0; i < memo.length; i++) {
            memo[i][0]=-1;
            memo[i][1]=-1;
            memo[i][2]=-1;
        }

        //        int[][] dp = new int[N+1000][3];
//        for (int i = 0; i <dp.length ; i++) {
//            dp[i] = Integer.MAX_VALUE;
//        }

//        dp[1][0] = arr[0][0];
//        dp[1][1] = arr[0][1];
//        dp[1][2] = arr[0][2];
//
//        for (int i = 1; i <= N-1 ; i++) {
//            //A
//            dp[i+1][0]=Math.max(dp[i][1],dp[i][2]) + arr[i][0];
//            dp[i+1][1]=Math.max(dp[i][0],dp[i][2]) + arr[i][1];
//            dp[i+1][2]=Math.max(dp[i][0],dp[i][1]) + arr[i][2];
//        }
//
//        System.out.println(Math.max(Math.max(dp[N][0],dp[N][1]),dp[N][2]));

        System.out.println(recur(arr,memo,N));

    }

    static public int recur(int[][] arr,int[][] memo,int N){
        return Math.max(
                    Math.max(
                        recur(arr,memo,N, 0),
                        recur(arr,memo,N, 1)),
                    recur(arr,memo,N, 2)
                );
    }

    static public int recur(int[][] arr,int[][] memo, int idx, int type){
        if(memo[idx][type]!=-1) return memo[idx][type];
        if(idx ==0){
            return arr[0][type];
        }

        int  max = 0;
        for (int i = 0; i < 3; i++) {
            if(i!=type){
                max = Math.max(max,recur(arr,memo,idx-1, i));
            }
        }
        max += arr[idx][type];

        memo[idx][type] =max;
        return max;
    }


}


Measured memory_bytes: 112300
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  ll x, k, d;
  cin >> x >> k >> d;
  // x が正だと仮定
  x = abs(x);
  ll oikoshi_cnt = x / d;         // 0ピッタリに止まれる場合もある
  if (x % d != 0) oikoshi_cnt++;  // 追い越してしまう場合

  ll oikosanai_cnt = oikoshi_cnt - 1;
  ll oikoshi_dist = abs(x - (d * oikoshi_cnt));
  ll oikosanai_dist = abs(x - (d * oikosanai_cnt));

  // kの値によっては限界まで近づくで終わる
  if (k < oikosanai_cnt) {
    cout << oikosanai_dist + d * (oikosanai_cnt - k) << endl;
    return 0;
  }
  //  oikoshi_cnt <= k
  k -= oikosanai_cnt;
  if (k % 2 == 0) {
    cout << oikosanai_dist << endl;
    return 0;
  } else {
    cout << oikoshi_dist << endl;
    return 0;
  }
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<ll> A(N);
  for (auto &it : A)
    cin >> it;
  // 累積和とmap
  vector<ll> S(N + 1, 0LL);
  map<ll, ll> mp;
  for (int i = 0; i < N; i++)
  {
    S[i + 1] = S[i] + A[i];
  }
  for (int i = 0; i < N + 1; i++)
  {
    mp[S[i]]++;
  }

  // 集計処理
  ll ans = 0;
  for (auto &it : mp)
  {
    ll num = it.second;
    ans += num * (num - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 15872
(N,) = [int(x) for x in input().split()]
L = [int(x) for x in input().split()]
count = 0
for i in range(N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            a, b, c = L[i], L[j], L[k]
            if len(set([a, b, c])) == 3 and a + b > c and a + c > b and b + c > a:
                count += 1
print(count)


Measured memory_bytes: 68544
N,K=map(int,input().split())

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

distance_dict=[[x,abs(x)] for x in candls]

for x in range(0,N):
  if candls[x]>=0:
    x-=1
    break

resultlist=[]
minus=x
if K==1:
  print (min(abs(candls[minus]),abs(candls[minus+1])))
  exit()
elif minus==-1:
  print(abs(candls[K-1]))
  exit()
elif minus-K+1>=0:
  resultlist.append(abs(candls[minus-K+1]))
  for i in range(1,2*K):
    try:
      resultlist.append(abs(candls[minus+i])+abs(candls[minus-K+1+i])+min(candls[minus+i],abs(candls[minus-K+1+i])))
    except:
      break
else:
  for i in range(0,minus+2):
    try:
      resultlist.append(abs(candls[K-1+i])+abs(candls[0+i])+min(candls[K-1+i],abs(candls[0+i])))
    except:
      break
try:
  resultlist.append(candls[minus+K])
except:
  pass

print (min(resultlist))

Measured memory_bytes: 20760
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<double> v(n);
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  
  double ans=v[0];
  int i=0;
  for(i=1;i<n;i++){
    ans=(ans+v[i])/2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256