akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
namespace mp = boost::multiprecision;
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    mp::cpp_dec_float_100 a,b,c;
    cin>>a>>b>>c;
  cout<<((sqrt(a)+sqrt(b)<sqrt(c))?"Yes":"No")<<endl;

    return 0;
}


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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	ll A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    C *= 2;

    ll ans = INF;

    rep(i, 100000){
        ans = min(i*C + max(0ll, X-i)*A + max(0ll, Y-i)*B, ans);
    }

    cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}
 
template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.first <<","<<P.second <<")";
}
 
#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int main() {
 	long long w, h;
 	cin >> w >> h;
 	if(w == 1 || h == 1) {
 		cout << 1 << endl;
 		return 0;
 	}
 	if(w % 2 == 0 || h % 2 == 0) cout << (w * h) / 2 << endl;
 	else cout << (w * h) / 2 + 1<< endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define ll long long
using namespace std;

int main(){
    ll n,k;
    cin>>n>>k;
    ll a[n];

    for (int i=0;i<n;i++) cin>>a[i];
    
    ll ans=1e18;
    for (ll bit=0;bit<(1<<n);bit++){
        ll max_h=a[0];
        ll sum=0;
        ll cnt=1;
        for (int i=1;i<n;i++){
            if (bit&(1<<i)){
                if(a[i]<=max_h){
                    sum+=max_h-a[i]+1;
                    cnt++;
                    max_h++;
                }else max_h=a[i];
            }else if(a[i]>max_h){
                cnt++;
                max_h=max(max_h,a[i]);
            }           
        }
        if (cnt>=k) ans=min(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}

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

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

    vector<long long int> a(n);
    long long int total_xor = 0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        total_xor ^= a[i];
    }
    for(int i=0; i<n; i++){
        a[i] &= ~total_xor;// ~ : NOT, ignoring the bits having no effect
    }

    // Gaussian Elimination (XOR ver.)
    int rank = 0;
    vector<int> msb(n);
    for(int b=60; b>=0; b--){
        bool flag = false;
        for(int i=rank+1; i<n; i++){
            if(a[i] >> b & 1){// if bit set
                swap(a[i], a[rank]);
                flag = true;
                break;
            }
        }
        if(flag == false) continue;// no bit set

        msb[rank] = b;
        for(int i=0; i<n; i++){
            if(i == rank) continue;

            if(a[i] >> b & 1) a[i] ^= a[rank];// eliminate
        }
        rank += 1;
    }
    
    long long int max_and = 0;
    for(int b=60; b>=0; b--){
        long long int test = max_and | (1LL << b);// *...*10...0

        for(int i=0; i<rank; i++){
            if(test >> msb[i] & 1) test ^= a[i];
        }
        
        bool flag = true;
        for(int c=60; c>=b; c--){
            if(test >> c & 1) flag = false;
        }
        if(flag == true) max_and |= (1LL << b);
    }
    cout << total_xor + 2 * max_and << endl;// (a + b) = (a XOR b) + 2 * (a AND b)
    return 0;
}

Measured memory_bytes: 4564
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

int N = 1000000;    // Nまで調べる
bool arr[1000000];  // arr[i] := 整数 i が素数かどうか

void initSieve() {
  // 篩を初期化
  for (int i = 0; i < N; i++) {
    arr[i] = 1;
  }

  // 篩落とす
  for (int i = 2; i < sqrt(N); i++) {
    if (arr[i]) {
      for (int j = 0; i * (j + 2) < N; j++) {
        arr[i * (j + 2)] = 0;
      }
    }
  }
}

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

  int q;
  cin >> q;
  vector<int> l(q), r(q);
  for (int i = 0; i < q; i++) {
    cin >> l[i] >> r[i];
  }

  initSieve();

  vector<int> dp(1000000, 0);
  for (int i = 1; i <= 100000; i++) {
    dp[i] = dp[i - 1];

    if (i % 2 == 0) continue;

    if (arr[i] && arr[(i + 1) / 2]) {
      dp[i]++;
    }
  }

  dp[0] = 1;

  for (int i = 0; i < q; i++) {
    int li = l[i];
    int ri = r[i];

    cout << dp[ri] - dp[li - 1] << ln;
  }

  return 0;
}

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

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

ll win(int i, int j){
    return (S[abs(i - j) - 1] == '0' ? min(i, j) : max(i, j));
}

int main() {
    cin>>N>>S;
    ll sz = 1LL<<N;//Sのサイズー１
    mat dp(N + 1, vec(sz));
    rep(i,sz) {
        cin>>dp[0][i];
        --dp[0][i];
    }
    rep(n,N){
        //cout<<n<<endl;
        rep(i,sz){
            dp[n+1][i] = win(dp[n][i], dp[n][(i + (1<<n))%sz]);
            //cout<<i<<' '<<dp[n][i]<<' '<<dp[n][(i + (1<<n))%sz]<<' '<<dp[n+1][i]<<endl;
        }
    }
    rep(i,sz)cout<<dp[N][i] + 1<<endl;
}


Measured memory_bytes: 44312
#include<bits/stdc++.h>
using namespace std;
#define int long long
int recursion(int n)
{
    if(n == 1)
        return 1;
    return 2*recursion(n/2) + 1;
}
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    //cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        cout << recursion(n) ;
    }
}


Measured memory_bytes: 256
k,s=gets.split.map(&:to_i)
ans=[-1]*3
0.upto([k,s/10000].min) do |i|
    y=i*10000
    0.upto(k-i) do |j|
        h=j*5000
        l=[k-i-j,0].max
        ans=[i,j,l] if y+h+l*1000==s
    end
end
puts ans.join(" ")

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

bool dfs(int, int, int*, int);
int main(){
  int n; cin >> n;
  int a[n];
  for(int i=0; i<n; i++) cin >> a[i];
  int q; cin >> q;
  int m[q];
  for(int i=0; i<q; i++) cin >> m[i];

  for(int i=0; i<q; i++){
    if(dfs(0, m[i], a, n)) cout << "yes" << endl;
    else cout << "no" << endl;
  }
}

bool dfs(int i, int sum, int* a, int n){
  if(sum==0) return true;
  if(i==n) return false;
  return dfs(i+1, sum, a, n)||dfs(i+1, sum-a[i], a, n);
}



Measured memory_bytes: 3080
n = gets.to_i
arr = gets.chomp.split(' ').map(&:to_i).unshift(0).push(0)
lengths = arr.map.with_index {|num,id| (arr[id+1] - arr[id]).abs if id < n + 1}.compact
sum = lengths.sum
lengths.each.with_index do |length,id|
  puts sum - lengths[id-1] - lengths[id] + (arr[id+1] - arr[id-1]).abs if (0 < id && id< n+1)
end


Measured memory_bytes: 23788
using System;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        //入力の受け取り
        char[] input = Console.ReadLine().ToCharArray();

        //配列→list
        List<char> numList = new List<char>();
        for(int jj = 0; jj < input.Length; jj++)
        {
            numList.Add(input[jj]);
        }

        //答え用カウンター
        int answer = 0;

        //隣合う0と1を取り除いてカウントしていく
        for (int ii = 0; ii < numList.Count - 1; ii++)
        {
            if (numList[ii] != numList[ii + 1])
            {
                numList.RemoveAt(ii);
                numList.RemoveAt(ii);
                answer = answer + 2;
                if (ii < 2)
                {
                    ii = -1;
                }
                else
                {
                    ii = ii - 2;
                }
            }
        }

        //回答提出
        Console.WriteLine(answer);

    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int L;
	while(cin >> L , L){
		int sum = 0 , ans = -1;
		rep(i,12){
			int a,b;
			cin >> a >> b;
			sum += a - b;
			if(!~ans && sum >= L) ans = i+1;
		}
		if(~ans)cout << ans << endl;
		else cout << "NA" << endl;
	}
}

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

int main(){
  while(1){
    int n,p;
    cin >> n >> p;
    if(n==0&&p==0)break;
    vector<int> stone(n);
    int pot=p;
    rep(i,n) stone[i]=0;
    rep(i,1000000){
      if(pot){
        pot--;
        stone[i%n]++;
      }
      else if(stone[i%n]){
        pot+=stone[i%n];
        stone[i%n]=0;
      }
      if(pot==0){
        rep(j,n){
          if(stone[j]==p){cout << j << endl;i=1010000;break;}
        }
      }
    }
  }
  return 0;
}



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






int main() {
	vector<int>a;
	vector<int>b;
	vector<int>c;
	vector<int>d;
	vector<pair<int, int> >e;
	vector<pair<int, int> >f;
	bool used[N];
	int g[N];
	int n, k;
	int x, y, z;
	long long s, ans;
	bool v = false;
	ans = 0;
	scanf("%d", &n);
	f(i, n) {
		scanf("%d", &x);
		c.push_back(x);
		e.push_back(make_pair(x, i));
	}
	f(i, n) {
		scanf("%d", &x);
		d.push_back(x);
		f.push_back(make_pair(x, i));
	}
	sort(c.begin(), c.end());
	sort(d.begin(), d.end());
	sort(e.begin(), e.end());
	sort(f.begin(), f.end());
	f(i, n) {
		if (c[i] > d[i]) {
			printf("No\n");
			return 0;
		}
		if (i > 0) {
			if (d[i - 1] >= c[i])v = true;
		}
	}
	if (v) {
		printf("Yes\n");
		return 0;
	}
	f(i, n) {
		g[e[i].second] = f[i].second;
		used[i] = false;
	}
	x = 0;
	v = false;
	f(i, n) {
		if (used[x])v = true;
		used[x] = true;
		x = g[x];
	}
	if (v)printf("Yes\n");
	else printf("No\n");
	return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  string S;
  cin>>S;
  int N=S.size();
  bool ok=true;
  string rS=S;
  reverse(rng(rS));
  if(S!=rS){
    cout<<"No"<<endl;
    return 0;
  }
  string S1=S.substr(0,(N-1)/2);
  string rS1=S1;
  reverse(rng(rS1));
  if(S1!=rS1){
    cout<<"No"<<endl;
    return 0;
  }
  string S2;
  for(int i=(N+3)/2-1;i<N;i++)S2.push_back(S[i]);
  string rS2=S2;
  reverse(rng(rS2));
  if(S2!=rS2){
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;

  return 0;
}


Measured memory_bytes: 256
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)


a = 0
k = int(input())
for i in range(1,k+1):
    for j in range (i,k+1):
        for l in range(j,k+1):
            g = gcd(i,j,l)
            if i==j and j==l:
                a = a+g
            elif i != j and j != l and l != i:
                a = a+ (6*g)
            else:
                a = a + (3*g)
print(a)

Measured memory_bytes: 9632
#include <stdio.h>

int main (){

    int a;
    char s[100];
    char r[] = "red";
    scanf("%d",&a); // numero
    scanf("%s", s ); // string

    if (a > 3200 || a == 3200){
        printf("%s\n",s );
    } else{
        printf("%s\n",r);
    }



return 0;
}


Measured memory_bytes: 128
n=int(input())
A=list(map(int,input().split()))

L=[0]*(max(A)+1)
for i in A:
    L[i]+=1

M=[0]*(len(L))
for i in range(len(L)):
    M[i]=L[i]*(L[i]-1)//2

N=[0]*(len(L))
for i in range(len(L)):
    N[i]=(L[i]-1)*(L[i]-2)//2

S=sum(M)
for i in range(n):
    print(S-M[A[i]]+N[A[i]])
    


Measured memory_bytes: 26140
# coding: utf-8
# Your code here!
import sys

n,k=map(int,input().split())

pos=n%k;
left=int(n/k+1);

ans=0;
p=0;

if k%2==0:
    if k/2<=pos:p=left;
    else: p=left-1;
    ans+= p**3;
if k<=pos:p=left;
else:p=left-1;
ans+= p**3;
print(int(ans));


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> score(N);
  rep(i,N) score[i] = K - Q;
  rep(i,Q) {
    int a;
    cin >> a;
    --a;
    ++score[a];
  }
  rep(i,N) {
    if (score[i] > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3144
def main():
    N, S = open(0).read().split()
    pre = S.count("E")
    cur = pre
    for Si in S:
        if cur < pre:
            pre = cur
        if Si == "E":
            cur -= 1
        else:
            cur += 1
    print(pre if pre < cur else cur)
    return


main()


Measured memory_bytes: 3572
#include <iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  
  int* a = new int[N];
  int totalXor = 0;
  
  for(int i = 0; i < N; i++){
    cin >> a[i];
    totalXor ^= a[i];
  }
  
  cout << (totalXor ^ a[0]);
  for(int i = 1; i < N; i++){
    cout << ' ' << (totalXor ^ a[i]);
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 3976
#include<stdio.h>
#include<string.h>

#define N 3
#define LIM 32
#define HN 362897

struct dep{
  int depth,key;
};

int ans[N][N]={
  {1,2,3},
  {4,5,6},
  {7,8,0}
};

int min = LIM;
struct dep h[HN];

int hash1(int k){
  return k % HN;
}
int hash2(int k){
  return 1 + k%(HN-1);
}
int hash(int k, int i){
  return (hash1(k)+i*hash2(k))%HN;
}


void dfs(int p[N][N], int n){
  int i,j,i0,j0,a=0,b=1;
  int f=0;
  int tmp[N][N];

  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(ans[i][j] != p[i][j]) f++;
      if(p[i][j] == 0){
        i0=i;
        j0=j;
      }
      a+=p[i][j]*b;
      b*=10;
    }
  }

  if(f == 0){
    if(min >= n){
      min = n;
    }
    return;
  }

  if(n > min) return;

  i=0;

  while(1){
    b=hash(a, i);

    if(h[b].key == 0){
      h[b].key=a;
      h[b].depth=n;
      break;
    }
    else if(h[b].key == a){
      if(h[b].depth>n){
        h[b].depth=n;
        break;
      }
      else return;
    }
    i++;
  }

  if(i0 > 0 && i0 < N){
    memcpy(tmp,p,sizeof(int)*N*N);

    f=tmp[i0][j0];
    tmp[i0][j0]=tmp[i0-1][j0];
    tmp[i0-1][j0]=f;
    dfs(tmp, n+1);
  }

  if(j0 > 0 && j0 < N)
  {
    memcpy(tmp,p,sizeof(int)*N*N);

    f=tmp[i0][j0];
    tmp[i0][j0]=tmp[i0][j0-1];
    tmp[i0][j0-1]=f;
    dfs(tmp, n+1);
  }

  if(i0 >= 0 && i0 < N-1){
    memcpy(tmp,p,sizeof(int)*N*N);

    f=tmp[i0][j0];
    tmp[i0][j0]=tmp[i0+1][j0];
    tmp[i0+1][j0]=f;
    dfs(tmp, n+1);
  }
  if(j0 >= 0 && j0 < N-1){
    memcpy(tmp,p,sizeof(int)*N*N);

    f=tmp[i0][j0];
    tmp[i0][j0]=tmp[i0][j0+1];
    tmp[i0][j0+1]=f;
    dfs(tmp, n+1);
  }
}

int main(){
  int i,j;
  int p[N][N];

  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      scanf("%d",&p[i][j]);
    }
  }
  dfs(p,0);

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

  return 0;
}



Measured memory_bytes: 4688
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long power = 1;
    int mod = 1000000007;
    for (int i = 1; i <= n; i++) {
      power = power * i % mod;
    }
    System.out.println(power);
  }
}

Measured memory_bytes: 35692
#include<bits/stdc++.h>
#include <math.h>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)

int ukuri(ll a,ll b){
  if(a<b){
    a += b;
        b = a-b;
        a -= b; //入れ替え
  }
  while(b!=0){
  a=a%b;
  a += b;
  b = a-b;
  a -= b; //入れ替え
  }
  return a;
}

int main() {
    ll a,b,c,d;
	cin >> a>> b>>c>>d;
    a-=1;
    cout << b-(b/c+b/d-b/(c*d/(ukuri(c,d))))-a+(a/c+a/d-a/(c*d/(ukuri(c,d)))) << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ロシアの旗
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
            string[] flag = new string[nm[0]];
            for (int i = 0; i < flag.Length; i++)
            {
                flag[i] = Console.ReadLine();
            }
            int ans = int.MaxValue;
            int count = 0;
            for (int i = 1; i < (nm[0]-1); i++)
            {
                for (int j = i + 1; j < nm[0]; j++)
                {
                    for (int l = 0; l < nm[0]; l++)
                    {
                        for (int k = 0; k < nm[1]; k++)
                        {
                            if (l < i) { if (flag[l][k] != 'W') count++; }
                            else if (l < j) { if (flag[l][k] != 'B') count++; }
                            else { if (flag[l][k] != 'R') count++; }
                        }
                    }
                    ans = Math.Min(ans, count);
                    count = 0;
                }
            }
            Console.WriteLine(ans);
        }
    }
}



Measured memory_bytes: 16324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int n = 105;

ll X, Y;

int main(){
	cin >> X >> Y;
	ll r = 0;
	if(X == 1) r += 300000;
	if(X == 2) r += 200000;
	if(X == 3) r += 100000;
	if(Y == 1) r += 300000;
	if(Y == 2) r += 200000;
	if(Y == 3) r += 100000;
	if(X == 1 && Y == 1) r += 400000;

	cout << r << endl;
}


Measured memory_bytes: 384
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        for(int i = 0; i < 5; i++){
            if(scan.nextInt() == 0){
                System.out.println(i + 1);
                return;
            }
        }
        scan.close();
    }
}

Measured memory_bytes: 27004
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
int inf=1000001000;
ll INF=1e18;
ll MOD=INF;
ll mod=INF;


int main() {
  int h,w,k;
  cin >> h >> w >> k;
  vector<vector<int>> a(w,vector<int>(h));
  rep(i,h){
      rep(j,w) {
          char f;
          cin >> f;
          if (f=='.') a[j][i]=0;
          else a[j][i]=1;
      }
  }
  int ans=0;
  int c=pow(2,w),cc=pow(2,h);
  rep(i,c){
      vector<int> u(w);
      int y=i;
      rep(jj,w){
          u[jj]=y%2;
          y/=2;
      }
      rep(j,cc){
          vector<int> uu(h);
          int yy=j;
          rep(jj,h){
              uu[jj]=yy%2;
              yy/=2;
          }
          int t=0;
          rep(ii,w){
              rep(jj,h){
                  if (u[ii]==0 && uu[jj]==0 && a[ii][jj]==1) t++;
              }
          }
          if (t==k) ans++;
      }
  }
  cout << ans << endl;
}


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007;

int main(){
    
    int N;cin>>N;
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    ll dp[N+5][N+5];
    for(int i=0;i<N+5;i++){
        for(int j=0;j<N+5;j++){
            dp[i][j]=0;
        }
    }
    for(int len=1;len<=N;len++){
        for(int i=0;i+len<=N;i++){
            int j=i+len;
            if((N-len)%2==0){
                dp[i][j]=max(dp[i+1][j]+A[i],dp[i][j-1]+A[j-1]);
            }else{
                dp[i][j]=min(dp[i+1][j]-A[i],dp[i][j-1]-A[j-1]);
            }
        }
    }
    cout<<dp[0][N]<<endl;
}


Measured memory_bytes: 70784
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		int M = GetInt();
		int[,] A = new int[N, M];
		for(int i = 0; i < N; i++)
			for(int j = 0; j < M; j++)
				A[i, j] = GetInt() - 1;

		int ans = int.MaxValue / 2;
		bool[] removed = new bool[M];
		for(int i = 0; i < M; i++)
		{
			int[] cnt = new int[M];
			for(int j = 0; j < N; j++)
			{
				for(int k = 0; k < M; k++)
				{
					if(removed[A[j, k]])
						continue;

					cnt[A[j, k]]++;
					break;
				}
			}

			int max = cnt.Max();
			int iMax = Array.FindIndex(cnt, x => x == max);
			removed[iMax] = true;
			ans = Math.Min(ans, max);
		}

		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


Measured memory_bytes: 17500
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  set<ll> primes;
  cin >> N;
  FOR(i, 2, 55556){
    if(is_prime(i)and i%5==1)primes.insert(i);
  }

  for(auto ip:primes){
    if(N==0)break;
    cout << ip << " ";
    N--;
  }
  return 0;
}


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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    int sum = 0;
    rep(i, 0, n){
        cin >> d[i];
        sum += d[i];
    }
    int ans = 0;
    rep(i, 0, n){
        ans += (sum - d[i]) * d[i];
    }
    cout << ans / 2 << endl;
}


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

using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    int h[n+1];
    for (int i=1; i<=n; i++){
        cin>>h[i];
    }
    int dp[n+1];
    dp[1] = 0;
    dp[2] = abs(h[2]-h[1])+dp[1];
    for (int i=3; i<=n; i++){
        int min_cost = abs(h[i]-h[i-1])+dp[i-1];
        for (int j=2; j<=k; j++){
            if (j<=i-1){
                min_cost = min(min_cost, abs(h[i]-h[i-j])+dp[i-j]);
            }
        }
        dp[i] = min_cost;
    }
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>                                                               
#include <string>
using namespace std;

int main(){
    int dish[5];
    
    for(int i = 0; i < 5; i++){
        cin >> dish[i];
    }
    
    int min = 9;
    int key = 0;
    int val = 0;
    int temp = 0;
    
    for(int h = 0; h < 5; h++){ 
        val = dish[h] % 10;
        if(val == 0){
            continue;
        }else{
            if(val < min){
                min = val;
                key = h;
            }
        }
    }
    temp = dish[4];
    dish[4] = dish[key];
    dish[key] = temp;
    
    
    double now = 0;
    int test = 0;
    
    for(int j = 0; j < 5; j++){
        now += dish[j];
        if(j < 4){
            test = now;
            now = ceil(now / 10)*10;
        }    
    }
    cout << now << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a;
	cin>>a;
	if(a%10==3)
	cout<<"bon"<<endl;
	else if(a%10==0||a%10==1||a%10==6||a%10==8)
	cout<<"pon"<<endl;
	else cout<<"hon"<<endl;
}

Measured memory_bytes: 3076
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n,x,y;cin>>n>>x>>y;
  x--;y--;

  V<int> ans(n,0);
  rep(i,0,n){
    rep(j,i+1,n){
      ll dis=j-i;
      chmin(dis,abs(x-i) +1 +abs(j-y));
      chmin(dis,abs(x-j) +1 +abs(i-y));
      
      ans[dis]++;
    }
  }

  rep(i,1,n){
    cout<<ans[i]<<ENDL;
  }
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 256
h,w,d = map(int,input().split())
a = [[0 for i in range(0,w)] for j in range(0,h)]
x = [0 for i in range(0,h*w)]
y = [0 for i in range(0,h*w)]
for i in range(0,h):
    a[i] = list(map(int,input().split()))
for j in range(0,h):
    for i in range(0,w):
        x[a[j][i]-1] = i
        y[a[j][i]-1] = j
l = []
r = []
q = int(input())
for i in range(0,q):
    L,R = map(int,input().split())
    l.append(L)
    r.append(R)

way = [0 for i in range(0,h*w)]
for i in range(d,h*w):
    way[i] = way[i-d] + abs(x[i] - x[i-d]) + abs(y[i] - y[i-d])
for i in range(0,q):
    print(way[r[i]-1] - way[l[i]-1])


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

int main(){
	int a,b,c;
  	cin>>a>>b>>c;
  	if(a-b==0)cout<<c<<endl;
  	else {
    	if(a-c==0)cout<<b<<endl;
      	else cout<<a<<endl;
    }return 0;
}

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

using namespace std;

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

    string s;
    printf("%d\n", 0); fflush(stdout);
    cin >> s;

    if (s == "Vacant") return 0;

    int l = 0;
    int r = n - 1;

    while (l <= r) {
        int mid = (l + r) / 2;
        printf("%d\n", mid); fflush(stdout);

        string resp; cin >> resp;
        if (resp == "Vacant") return 0;

        if (mid % 2 == 0) {
            if (resp != s) r = mid - 1;
            else l = mid + 1;
        }
        else {
            if (resp == s) r = mid - 1;
            else l = mid + 1;
        }
    }

    printf("%d\n", l); fflush(stdout);
    return 0;
}


Measured memory_bytes: 852
#include<stdio.h>
inline int Min(int a,int b){return a<b?a:b;}
int f[42][42][42][42],n,m,x,y,ans=1e9;
int s[42][42];
char a[52][52];
inline int get(int l,int r,int d,int u){
	return s[r][u]-s[l-1][u]-s[r][d-1]+s[l-1][d-1];
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%s",a[i]+1);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			s[i][j]=(a[i][j]=='#')+s[i-1][j]+s[i][j-1]-s[i-1][j-1];
			if(a[i][j]=='P')x=i,y=j;
		}
	}for(register int l=1;l<=x;l++){
		for(register int r=n;r>=x;r--){
			for(register int d=1;d<=y;d++){
				for(register int u=m;u>=y;u--){
					f[l][r][d][u]=1e9;
					if(l==1&&r==n&&d==1&&u==m)f[l][r][d][u]=0;
					for(int g=1;g<=l;g++){
						for(int h=1;h<=d;h++){
							f[l][r][d][u]=Min(f[l][r][d][u],f[g][r][h][u]+get(g,l-1,d,u)+get(l,r,h,d-1));
						}
					}for(int g=1;g<=l;g++){
						for(int h=u;h<=m;h++){
							f[l][r][d][u]=Min(f[l][r][d][u],f[g][r][d][h]+get(g,l-1,d,u)+get(l,r,u+1,h));
						}
					}for(int g=r;g<=n;g++){
						for(int h=1;h<=d;h++){
							f[l][r][d][u]=Min(f[l][r][d][u],f[l][g][h][u]+get(r+1,g,d,u)+get(l,r,h,d-1));
						}
					}for(int g=r;g<=n;g++){
						for(int h=u;h<=m;h++){
							f[l][r][d][u]=Min(f[l][r][d][u],f[l][g][d][h]+get(r+1,g,d,u)+get(l,r,u+1,h));
						}
					}ans=Min(ans,f[l][r][d][u]+Min(Min(s[x][y]-s[l-1][y]-s[x][d-1]+s[l-1][d-1],s[r][u]-s[x-1][u]-s[r][y-1]+s[x-1][y-1]),Min(s[x][u]-s[l-1][u]-s[x][y-1]+s[l-1][y-1],s[r][y]-s[x-1][y]-s[r][d-1]+s[x-1][d-1])));
				}
			}
		}
	}printf("%d",ans);
}

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

int main()
{
    int money = 0;
    vector<char> a(3);
    for (int i = 0; i < 3;i++){
        cin >> a.at(i);
        if (a.at(i) == 'o'){
            money += 100;
        }
    }
    money += 700;
    cout << money << endl;
}

Measured memory_bytes: 384
n, m = gets.strip.split.map(&:to_i)

lhs = 0
rhs = n

m.times {
    l, r = gets.strip.split.map(&:to_i)
    lhs = [l, lhs].max
    rhs = [r, rhs].min
}

d = rhs - lhs + 1
puts d >= 0 ? d : 0


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

#define LL long long
#define MOD 1000000007
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define print(a, n) for(LL e=0; e<n; e++) cout<<a[e]<<" "; cout<<"\n"
#define prints(a) for(auto i: a) cout<<i<<" "; cout<<"\n"
#define read(a, n) for(LL e=0; e<n; e++) cin>>a[e]

const int maxN = 1e5;
int freq[maxN+1];

int main()
{
	fastio;
	LL n, sum=0;
	cin>>n;
	int a, b;
	memset(freq, 0, sizeof(freq));

	for(int i=0; i<n; i++){
		cin>>a;
		freq[a]++;
		sum += a;
	}

	int q;
	cin>>q;
	while(q--){
		cin>>a>>b;
		sum -= (a-b)*freq[a];
		freq[b] += freq[a];
		freq[a] = 0;
		cout<<sum<<"\n";
	}


	exit(0);
}

Measured memory_bytes: 4044
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define D(x) cerr << #x << " is " << (x) << "\n";

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a){os << '{';for(int i=0;i<sz(a);i++){if(i>0&&i<sz(a))os << ", ";os << a[i];}os<<'}';return os;}
template<class T> ostream& operator<<(ostream& os, const set<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T> ostream& operator<<(ostream& os, const multiset<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T1,class T2> ostream& operator<<(ostream& os, const map<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}

const int N=3001;
int dp[N][N];
int main()
{
	string s,t;
	cin >> s >> t;
	int n=s.size(),m=t.size();
	for(int i=n-1;i>=0;i--)
        for(int j=m-1;j>=0;j--)
            if(s[i]==t[j])
                dp[i][j]=dp[i+1][j+1]+1;
            else
                dp[i][j]=max(dp[i+1][j],dp[i][j+1]);
    string sol;
    int i=0,j=0;
    while(i<n&&j<m)
        if(s[i]==t[j])
            sol+=s[i],i++,j++;
        else
            if(dp[i+1][j]>dp[i][j+1])
                i++;
            else
                j++;
    cout << sol << endl;
    return 0;
}


Measured memory_bytes: 35456
A = [list(map(int,input().split())) for i in range(3)]
n = int(input())
for j in range(n):
  b = int(input())
  for j in range(3):
    for k in range(3): 
    	if b==A[j][k]:
      		A[j][k]=-1

for k in range(3):
  if A[k][:]==[-1,-1,-1]:
    print('Yes')
    exit(0)

ri = [[_[k] for _ in A]for k in range(3)]

for k in range(3):
  if ri[:][k]==[-1,-1,-1]:
    print('Yes')
    exit(0)
    
if (A[0][0]==A[1][1]==A[2][2]==-1)or(A[2][0]==A[1][1]==A[0][2]==-1): 
    print('Yes')
    exit(0)
    
print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    double ans = 0;
    rep(i, n) {
        double a;
        cin >> a;
        ans += 1.0/a;
    }

    ans = 1.0/ans;

    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 764
#include <algorithm>
#include <cmath>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using ll = long long int;
#define int ll

const int MOD = 1e9 + 7;
const int INF = 1e15 + 373;

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

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> init_vector2(size_t n0, size_t n1, T e = T()) {
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> init_vector3(size_t n0, size_t n1, size_t n2, T e = T()) {
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    for (T e : v) {
        os << e << ", ";
    }
    os << "]";
    return os;
}

signed main() {
    int n, p;
    cin >> n >> p;

    vector<int> a(n);
    rep(i, n) { cin >> a[i]; }

    int cnt0 = 0;
    int cnt1 = 0;
    rep(i, n) {
        if (a[i] % 2 == 0) {
            cnt0++;
        }
        if (a[i] % 2 == 1) {
            cnt1++;
        }
    }

    if (p == 0) {
        cout << (1LL << (cnt0 + max(cnt1 - 1, 0LL))) << endl;
    } else {
        cout << (cnt1 == 0 ? 0LL : 1LL << (cnt0 + max(cnt1 - 1, 0LL))) << endl;
    }

    return 0;
}


Measured memory_bytes: 384
s=input()
n=len(s)
for i in range(n-2):
    if s[i]==s[i+2]:
        print(i+1,i+3)
        exit()
    elif s[i]==s[i+1]:
        print(i+1,i+2)
        exit()
if s[-2]==s[-1]:
    print(n-1,n)
    exit()
print(-1,-1)

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

int main() {
    int coins[4] = {25, 10, 5, 1};
    long n, a, x;
    cin >> n;
    x = 0;
    for (int i = 0; i < 4; i++) {
        x += n / coins[i];
        n = n % coins[i];
    }
    cout << x << endl;

    return 0;
}



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

int main() {
    int a, b;
    cin >> a >> b;

    if (a > 0 && b > 0) cout << "Positive" << endl;
    else if (a <= 0 && b >= 0) cout << "Zero" << endl;
    else {
        if ((b - a) % 2 == 0) cout << "Negative" << endl;
        else cout << "Positive" << endl;
    }
    return 0;
}


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

int		main() {
  string str;
  cin >> str;
  
  if ((str.at(2) == str.at(3)) && (str.at(4) == str.at(5)))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i, 3) {
        if(s[i] == t[i]) ans++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
l = []
m = []
for _ in range(N):
    data = input()
    data = list(data)
    data.sort()
    l.append(data)
l.sort()
cnt = 0
for i in range(N-1):
    if l[i] == l[i+1]:
        cnt += 1
    else:
        if cnt == 0:
            pass
        else:
            m.append(cnt+1)
        cnt = 0
if cnt != 0:
    m.append(cnt+1)

ans = 0
for i in m:
    ans += i * (i-1) // 2
print(ans)

Measured memory_bytes: 24652
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
inline ll lin() { ll x; scanf("%lld",&x); return x;}
inline char chin() { char x; scanf("%c",&x); return x;}
inline string stin() { string x; cin >> x; return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  double d = (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);
  d = sqrt(d);
  printf("%.10f\n", d);
  return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int a, b, c; cin >> a >> b >> c;
    int k; cin >> k;
    int mx = max(a, max(b, c));
    int tmp = mx;
    rep(i, k) mx *= 2;
    cout << a+b+c-tmp+mx << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
 
 
for k in range(K):
  B = [0]*N
  for i in range(N): 
    start = max(0, i-A[i])
    end = min(N, i+A[i]+1)
    B[start] += 1
    if end <= N - 1:
      B[end] -= 1
 
  for i in range(1, N):
    B[i] = B[i-1] + B[i] 
  A = B
  if min(A) == N:
    break
 
print(*A)

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";

string vow = "aeiou";

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

void solve ( int test_case )
{
    int a , b ; 
    cin >> a >> b ; 
    
    int ans = max ( { a + b , a-b , a*b } ) ;
    cout << ans ; 
}

int main()
{
    int t = 1;
    //cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define N 100000
using namespace std;
main () {
        int n, a[N];
        cin >> n;
        for (int i=0; i<n; i++) cin >> a[i];
        sort(a,a+n);

        // for (int i=0; i<n; i++) cout << a[i] << " ";
        // cout << endl;
        int sum = 0, i = 0;
        while (i < n) {
                int k = a[i], j = 0;
                // cout << sum << " " << k << " " << j << endl;
                while (k == a[i]) {
                        i++;
                        j++;
                }
                if (j > a[i-1]) sum += j-a[i-1];
                else if(j < a[i-1]) sum += j;
        }
        cout << sum << endl;
}


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,k,dn,nm=0;
  cin >>n>>k;
  rep(i,n){
    int cs=i+1;
    //cout << cs<<' '<<k<<endl;
    while(cs<k){
      cs*=2;
      //cout <<cs<<endl;
    }
    if(i==0)dn=cs;
    nm+=dn/(cs/(i+1));
    //cout << nm;
  }
  cout << fixed << setprecision(13) <<(double)nm/(dn*n);
}

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

typedef long long ll;
typedef pair<int,ll> P;
typedef pair<P,P> P2;
const ll INF=100000000000000001;
int main() {
	int a,b;
	cin>>a>>b;
	if((a%3==0||b%3==0)||(a+b)%3==0){
		cout<<"Possible"<<endl;
	}else{
		cout<<"Impossible"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
n = int(input());
a = input().split(" ");
b = input().split(" ");
c = input().split(" ");

for i in range(n) :
	a[i] = int(a[i]);
	b[i] = int(b[i]);
a.insert(0,0);
b.insert(0,0);

for i in range(n-1) :
	c[i] = int(c[i]);
c.insert(0,0);

ans = b[a[1]]
for i in range(2,n+1) :
 	ans += b[a[i]];
 	if a[i-1] + 1 == a[i] :
 		ans += c[a[i-1]];
 		
print(ans)

Measured memory_bytes: 3064
while True:
    n,x = list(map(int, input().split()))
    if n == 0 and x == 0:
        break
    res = 0
    i = 1
    while n-1 > i:
        j = i+1
        while n > j:
            k = j+1
            if x < i+k:
                break
            while n >= k:
                sum = i+j+k
                if sum == x:
                    res += 1
                elif x < sum:
                    break
                k += 1
            j += 1
        i += 1
    print(res)

Measured memory_bytes: 7672
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string str;
    getline(cin,str);
    for(int I=0;I<str.size();I++)
    {
        if('a'<=str[I] && str[I]<='z'){
            str[I]-=('a'-'A'); }
        else if('A'<=str[I] && str[I]<='Z'){
            str[I]+=('a'-'A'); }
        else if(str[I]=='/n')break;
    }
    cout<<str<<endl;
    return 0;
    
    
}


Measured memory_bytes: 3192