akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    map<int,int>m,m2;
    int N; cin >> N;
    rep(i,N){
        int x; cin >> x;
        if(i%2==0)  m[x]++;
        else m2[x]++;
    }
    vector<pair<int,int>> L(2),R(2);
    for(auto p:m){
       L.push_back(make_pair(p.second,p.first));   
    }
    for(auto p:m2){
       R.push_back(make_pair(p.second,p.first));
    }
    sort(L.begin(),L.end(),greater<pair<int,int>>()); 
    sort(R.begin(),R.end(),greater<pair<int,int>>());
    if(L[0].second!=R[0].second)cout << N-L[0].first-R[0].first << endl;
    else cout << N-max(L[0].first+R[1].first,L[1].first+R[0].first) << endl;
    return 0;
}

Measured memory_bytes: 8824
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

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

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

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"13 3 1"# => r#"3"#,
r#"12 3 1"# => r#"2"#,
r#"100000 1 1"# => r#"49999"#,
r#"64146 123 456"# => r#"110"#,
r#"64145 123 456"# => r#"109"#,
}


fn solve(src: &str) -> String {
    input! {
        source = src,
        x: usize,
        y: usize,
        z: usize,
    }

    ((x - z) / (y + z)).to_string()
}

Measured memory_bytes: 4352
Tmp = []
Tmp = input().rstrip().split(' ')

nN = int(Tmp[0])
nM = int(Tmp[1])

nData = [[ 0 for i in range(2)] for j in range(nM)]

for i in range(nM):
    nData[i][0]=i+1

for i in range(nN):
	Tmp = input().rstrip().split(' ')
	nK = int(Tmp[0])
	nTmp =[ 0 for j in range(nK)]
	for j in range(nK):
		nTmp[j] = int(Tmp[j+1])
#	print(nTmp)
	for j in range(nM):
		if nData[j][0]  in nTmp:
			nData[j][1] += 1

nAns=0
for i in range(nM):    
    if nData[i][1]==nN:
        nAns += 1

print(nAns)
            
    
    
    

Measured memory_bytes: 3064
n = gets.to_i
s = gets.split('')
minus = 0
for i in 0..n-1
  j=i+1
  k=i+2
  #count=0
  while k<n
    if (s[i]!=s[j] && s[j]!=s[k] && s[i]!=s[k])
      minus += 1
    end
    #count+=1
    j+=1
    k+=2
  end
end


r = s.count('R')
g = s.count('G')
b = s.count('B')


puts r*g*b - minus

Measured memory_bytes: 14396
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k,s,m=0,z;
    cin>>k>>s;
    for(int x=0;x<=k;x++)
    {
        for(int y=0;y<=k;y++)
        {
            z=s-x-y;
            if(z>=0&&z<=k)
            {
            	m++;
			}
        }
    }
    cout<<m<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define ll long long
const int maxi=2000000000;
const int maxq=1000000000;
const ll mod=1000000007LL;
#define f(i,a,b) for(ll  i=(a); i<(b);++i)
/*
unsigned int countSetBits(unsigned int n)
{
    unsigned int count = 0;
    while (n) {
        count += n & 1;
        n >>= 1;
    }
    return count;
}
*/

/*
const int maxx=9000000;
void SieveOfEratosthenes(vector<int> &primes){
    bool IsPrime[maxx+1];
    memset(IsPrime, true, sizeof(IsPrime));
    for(int p=2;p*p<=maxx ;p++){
        if(IsPrime[p]){
            for(int i=p*p;i<maxx ;i+=p) IsPrime[i]=false;
        }
    }
    f(p,2,maxx +1){
        if(IsPrime[p]) primes.push_back(p);
    }
    }
*/
//int b[100];
void func(ll n){
    if(n==0) return;
    n--;
    func(n/26);
    putchar('a'+(n%26));
    }
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*ll n,sum=0;
    cin>>n;
    ll a[n];
    f(i,0,n){
        cin>>a[i];
        sum+=a[i];
    }
    ll x;
    cin>>x;
    while(x--){
        ll c,d;
        cin>>c>>d;
        f(i,0,n){
        if(a[i]==c){
            a[i]=d;
            sum=sum+d-c;
        }

        } cout<<sum<<endl;
    } */

    ll a;
    cin>>a;
    func(a);
    return 0;
}




Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
const int mod = 1000000007;
signed main(){
    int n;cin >> n;
    vector<int> table(11000);
    for(int i = 2;i <= n+5;i++){
        for(int j = i+i;j <= n+5;j += i){
            table[j]++;
        }
    }
    vector<int> res;
    for(int i = 2;i <= n+5;i++){
        if(table[i] == 0)res.push_back(i);
    }
    int ans = 1;
    for(auto p:res){
        //pの倍数が何個
        int ret = 0;
        for(int i = p;i <= n;i *= p){
            ret = (ret + n/i)%mod;
            
        }
        //trace(p,ret);
        ans =(ans*(ret+1))%mod;

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

Measured memory_bytes: 3716
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
cnt = 0
for i in range(n):
    sum = 0
    a = list(map(int,input().split()))
    for j in range(m):
        sum += a[j]*b[j]
    if sum + c > 0:
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include <stdio.h>
using namespace std;

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

  for (int i = 0; i < num; i++) {
    int A, B, C;
    scanf("%d %d %d", &A, &B, &C);

    if (A*A+B*B == C*C || A*A+C*C == B*B || B*B+C*C==A*A) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }

}

Measured memory_bytes: 1008
#include <iostream>
#include <cmath>
using namespace std;
#define NUM 6
int main(void){
    // Your code here!
    int b = 1;
    int *inp = new int[NUM];
    for(int i = 0;i < NUM;i++){
        cin >> inp[i];
    }
    
    for(int i = 0;i < NUM-1;i++){
        for(int k = 0;k < NUM-1;k++){
            if(abs(inp[i] - inp[k]) > inp[NUM-1]){
                b = 0;
                break;
            }
        }
        if(!b){
            break;
        }
        
    }
    if(b){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }
    
}


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

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


 
void solve(void)
{  
  int K;cin>>K;
  int M = 50;
  vector<int> vec (M,0); 
  int U = K/50;
  for (int i = 0; i < M; i++)
  {
    vec[i] = i + U;
  }
  int P = K%50;
  for (int i = 0; i < P; i++)
  {
    for (int j = 0; j < M; j++)
    {
      if(i == j)
      {
        vec[j] += M;
      }
      else
      {
        vec[j]--;
      }
      
    }

  }
  

      cout<<M<<endl;
    for (int i = 0; i < vec.size(); i++)
    {
        if(i != 0)cout<<char(32);
        cout<<vec[i];
    }
    cout<<endl;
    

  



  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return ans.x;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int a , b , c;
cin>>a>>b>>c;
cout<<c<<" "<<a<<" "<<b<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;i++)

int main()
{
	int n;
	string s, t;
	cin >> n >> s >> t;
	rep(i, n)
	{
		cout << s[i] << t[i];
	}
	cout << "\n";
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;
using Graph = vector<set<int>>;

int main()
{
  int n;
  cin>>n;
  Graph g(n);
  REP(i,n-1) {
    int a,b;
    cin>>a>>b;
    --a;--b;
    g[a].insert(b);
    g[b].insert(a);
  }
  vecint c(n);
  REP(i,n)cin>>c[i];
  sort(ALL(c));
  queue<int> q;
  REP(i,n) {
    if (g[i].size() == 1) {
      q.push(i);
    }
  }
  int s = 0;
  vecint res(n);
  REP(i,n-1) {
    int j = q.front();
    s += c[i];
    res[j] = c[i];
    q.pop();
    int k = *g[j].begin();
    g[j].clear();
    g[k].erase(j);
    if (g[k].size() == 1) q.push(k);
  }
  res[q.front()] = c.back();
  cout << s << endl;
  REP(i,n) {
    if(i) cout << ' ';
    cout << res[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 1792
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define fe(vec,lambda) std::for_each(vec.begin(), vec.end(), lambda );
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define printv(val) std::for_each(val.begin(),val.end(),[](auto x){cout<<x<<"\n";});
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T& a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T& b,T a){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template <class T> T gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T lcm(T a, T b){return a * b / gcd(a, b);}
inline bool operator<(const pii &lhs,const pii &rhs){return(lhs.second<rhs.second);}
template<class T> vector<pair<T,T>> duplicator(const vector<T>& input){vector<pair<T,T>> out(input.size()-1);rep(i,input.size()-1){out[i].first =input[i  ];out[i].second=input[i+1];}return(out);}
vector<char> String_to_vector_char(const string& input){vector<char> out(input.size());rep(i,input.size()){out[i]=input[i];}return out;}


ll a,b,c,d,n;
vector<ll>v;
map<ll,ll>m;
string s[3],s2;
void input(){
    cin>>a>>b>>c;
}
void src(){
    cout<<((c>=a and c<=b)? "Yes":"No");
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define f first
#define s second
#define sz(x) int(x.size())
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define SIZE 26     
#define watch(x) cout << (#x) << " is " << (x) << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
 
const ll mod = 1e9 + 7;
const ll inf = 1e18;
const int N = 1e5 + 5;

int h[N],dp[N];

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

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;


int main(){
	
	int n,m;cin >> n >> m;
	set<ll> sa;
	vector<ll> A(n);
	REP(i,n){
		cin >> A[i];
		sa.insert(A[i]);
	}
	set<ll> sb;
	vector<ll> B(m);
	REP(i,m){
		cin >> B[i];
		sb.insert(B[i]);
	}
	
	if(sa.size() != n || sb.size() != m){
		cout << 0 << endl;
		return 0;
	}
	
	sort(ALL(A),greater<ll>());
	sort(ALL(B),greater<ll>());
	
	int placeA = 0;
	int placeB = 0;
	
	ll ans = 1;	
	
	for(ll i = n*m;i > 0;i--){
		int cou = 0;
		if(placeA < n && i == A[placeA])placeA++,cou+=1;
		if(placeB < m && i == B[placeB])placeB++,cou+=2;
		if(cou == 3)continue;
		else if(cou == 2){
			ans *= placeA;
		}
		else if(cou == 1){
			ans *= placeB;
		}
		else {
			ans *= max(0LL, (placeA * placeB - (n*m - i)));
		}
		ans %= MOD;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 384
//
// Created by kuroneko on 2019-09-07.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <queue>

using namespace std;

typedef long long ll;

#define INF 1000000000000009LL
#define MOD 1000000007LL

typedef int Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight):src(src), dst(dst), weight(weight) {}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

int main() {
    int N; cin >> N;
    std::cout << std::fixed;
    std::cout << std::setprecision(10);
    priority_queue<double, vector<double>, greater<double>> v;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        v.push(a);
    }

    for (int i = 0; i < N - 1; i++) {
        double a, b;
        a = v.top(); v.pop();
        b = v.top(); v.pop();
        v.push(1.0 * (a + b)/2);
    }
    cout << v.top() << endl;
    return 0;
}


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

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

double const pi=3.1415926535;

int printint(int n){
	cout<<n<<endl;
	return 0;
}

int prints(string s){
	cout<<s<<endl;
	return 0;
}

int main(){
	int n,a,b;
	cin>>n>>a>>b;
	int ans=0;
	for(int x=0;x<=9;x++){
		for(int y=0;y<=9;y++){
			for(int z=0;z<=9;z++){
				for(int w=0;w<=9;w++){
					if(a<=x+y+z+w&&x+y+z+w<=b&&1000*x+100*y+10*z+w<=n)ans+=1000*x+100*y+10*z+w;
				}
			}
		}
	}
	if(n==10000&&a==1)ans+=10000;
	printint(ans);
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;



int main(){
  int n;
  cin >> n;
  vector<int> a(n+2);
  a[0] = 0;
  a[n+1] = 0;
  for (int i = 1; i <= n; i++) cin >> a[i];

  vector<int> l(n+1), r(n+1);
  l[0] = abs(a[1]);
  r[n] = abs(a[n]);
  for (int i = 1; i <= n; i++){
    l[i] = l[i-1] + abs(a[i+1] - a[i]);
  }
  for (int i = n-1; i >= 0; i--){
    r[i] = r[i+1] + abs(a[i+1] - a[i]);
  }
  for (int i = 1; i <= n; i++){
    if (i == 1) cout << abs(a[2]) + r[2] << endl;
    else if (i == n) cout << l[n-2] + abs(a[n-1]) << endl;
    else cout << l[i-2] + abs(a[i+1] - a[i-1]) + r[i+1] << endl;
  }
}


Measured memory_bytes: 2432
const input = require("fs").readFileSync("/dev/stdin", "utf8")
const lines = input.split('\n')
const N = lines[0] - 0

const u = [
  'pon',
  'pon',
  'hon',
  'bon',
  'hon',
  'hon',
  'pon',
  'hon',
  'pon',
  'hon'
]

console.log(u[N % 10])

Measured memory_bytes: 29508
#include<bits/stdc++.h>
using namespace std;
int cost[6000]; int dp[9000][9000],fun[6000],n;
double t;
int knapsack(int i,int w)
{
    if(i>n)
        return 0;
    if(dp[i][w]!=-1)
        return dp[i][w];
    int p=0,q=0;
    if(w+cost[i]<=t)
        p=fun[i]+knapsack(i+1,w+cost[i]);
    else
        p=fun[i];
    q=knapsack(i+1,w);
    dp[i][w]=max(p,q);
    return dp[i][w];
}
int main()
{
    int i,j;
    cin>>n>>t;
    t-=0.5;
    memset(dp,-1,sizeof(dp));
    for(i=1;i<=n;i++)
        cin>>cost[i]>>fun[i];
    for(i=1;i<n;i++)
    {
        for(j=i+1;j<=n;j++)
        {
            if(cost[i]>cost[j])
            {
                swap(cost[i],cost[j]);
                swap(fun[i],fun[j]);
            }
        }
    }
    cout<<knapsack(1,0)<<endl;
    return 0;
}


Measured memory_bytes: 316928
#include <string>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;

int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<int> vec(n);
  int ans=0;
  for(int i=0;i<n;i++){
    if(s.at(i)=='.'){
      ans++;
    }
  }
  int tmp=ans;
  for(int i=0;i<n;i++){
    if(s.at(i)=='.'){
      tmp--;
      if(tmp<ans){
        ans=tmp;
      }
    }
    else{
      tmp++;
    }
  }
  cout << ans << endl;
}
      

Measured memory_bytes: 1412
#include <cstdio>
bool c[105];
int main(){
	int i, n;
	
	scanf("%d", &n);
	while(n--){
		scanf("%d", &i);
		c[i]=1;
	}
	n=0;
	for(i=1; i<=100; i++)
		n+=c[i];
	printf("%d", n);
	return 0;
}

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

int N;
vector<vector<P>> v;
bool judge(int bit) {
  rep(i,N) {
    if(!(bit&(1<<i))) continue;
    for(auto p: v[i]) {
      int x = p.first;
      int y = p.second;

      if(y==1&&!(bit&(1<<x))) return false;
      if(y==0&&(bit&(1<<x))) return false;
    }
  }
  return true;
}

int main() {
  cin >> N;
  v.resize(N);
  rep(i,N) {
    int A;
    cin >> A;
    v[i].resize(A);
    rep(j,A) {
      cin >> v[i][j].first >> v[i][j].second;
      v[i][j].first--;
    }
  }

  int res = 0;
  for(int bit=0; bit<(1<<N); bit++) {
    if(judge(bit)) {
      int count = 0;
      rep(i,N) {
        if(bit&(1<<i)) count++;
      }
      res = max(res,count);
    }
  }

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

ll C(ll n){
	return(n*(n-1)/2);
}
	
int main()
{
	int n;
	cin >> n;
	string s;
	map<string, ll> m;
	ll ans = 0;
	for (int i = 0; i < n; i++){
		cin >> s;
		sort(ALL(s));
		m[s]++;
	}
	for (auto x : m){
		ans += C(x.second);
	}

	cout << ans << endl;

	
}


Measured memory_bytes: 11136
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();
        double[][] x = new double[n][d];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < d; j++) {
                x[i][j] = sc.nextDouble();
            }
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            for (int i2 = i+1; i2 < n; i2++) {
                double tmp = 0.0;
                for (int j = 0; j < d; j++) {
                    tmp += (x[i][j] - x[i2][j]) * (x[i][j] - x[i2][j]);
                }
                double sq = Math.sqrt(tmp);
                if(sq == (int)sq) ans++;
            }
        }

        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 24532
package main

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

func main() {
	s1 := getString()
	s2 := getString()
	s3 := getString()

	fmt.Println(strings.ToUpper(s1[:1] + s2[:1] + s3[:1]))
}

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

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


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

int main(){
  int a, b;
  cin >> a >> b;
  if(a == 1 && b == 1) cout << "Draw" << endl;
  else if(a == 1) cout << "Alice" << endl;
  else if(b == 1) cout << "Bob" << endl;
  else if(a > b) cout << "Alice" << endl;
  else if(b > a) cout << "Bob" << endl;
  else cout << "Draw" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,j,l,r,d,ans;
    scanf("%d %d %d",&l,&r,&d);
    i=l/d;
    j=r/d;
    if(l%d==0) i=i-1;
    ans=j-i;
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 1724
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
#import numpy as np
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())

N = int(input())

cnt = 0
for i in range(1, N+1) :
  if len(str(i)) % 2 == 1 :
    cnt += 1

print (cnt)

Measured memory_bytes: 3444
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
struct P{
  P(){};
  P(int a,int b){
    x=a,y=b;
  }
  int x,y;
  void move(int,int);
};
struct S{
  S(){};
  S(P a,P b){
    t=a;
    k=b;
  }
  P t,k;
  void move(int);
};

P size;
S f_pos;
vector<vector<int> > f;
bool input(){
  size=P();
  f_pos=S();
  f.clear();
  cin>>size.y>>size.x;
  if(size.x==0&&size.y==0)return false;
  cin>>f_pos.t.y>>f_pos.t.x;
  cin>>f_pos.k.y>>f_pos.k.x;
  vector<int> t;
  for(int i=0;i<size.y+2;i++){
    t.push_back(1);
  }
  f.push_back(t);
  for(int i=0;i<size.x;i++){
    vector<int> tt;
    tt.push_back(1);
    for(int j=0;j<size.y;j++){
      int tmp;
      cin>>tmp;
      tt.push_back(tmp);
    }
    tt.push_back(1);
    f.push_back(tt);
  }
  f.push_back(t);
  return true;
}
int cost[60][60][60][60];
const int vx[]={0,0,1,-1};
const int vy[]={1,-1,0,0};
void S::move(int i){
  t.move(vx[i],vy[i]);
  k.move(-vx[i],-vy[i]);
}
void P::move(int a,int b){
  if(f[x+a][y+b]!=1){
    x+=a;
    y+=b;
  }
}
int solve(){
  for(int i=0;i<60;i++){
    for(int j=0;j<60;j++){
      for(int k=0;k<60;k++){
        for(int l=0;l<60;l++){
          cost[i][j][k][l]=-1;
        }
      }
    }
  }
  queue<S> q;
  q.push(f_pos);
  cost[f_pos.t.x][f_pos.t.y][f_pos.k.x][f_pos.k.y]=0;
  while(!q.empty()){
    S now = q.front();q.pop();
    for(int i=0;i<4;i++){
      S tmp = now;
      tmp.move(i);
      if(cost[tmp.t.x][tmp.t.y][tmp.k.x][tmp.k.y]!=-1)continue;

      cost[tmp.t.x][tmp.t.y][tmp.k.x][tmp.k.y] = cost[now.t.x][now.t.y][now.k.x][now.k.y]+1;
      if(cost[tmp.t.x][tmp.t.y][tmp.k.x][tmp.k.y]>=100){
        return -1;
      }else if( (tmp.t.x==tmp.k.x)&&(tmp.t.y==tmp.k.y) ){
        return cost[tmp.t.x][tmp.t.y][tmp.k.x][tmp.k.y];
      }else{
        q.push(tmp);
      }
    }
  }
  return -1;
}
int main(){
  while(input()){
    /*
    for(int i=0;i<f.size();i++){
      for(int j=0;j<f[i].size();j++){
        cout<<f[i][j];
      }cout<<endl;
    }cout<<endl;
    */
    int ans= solve();
    if(ans==-1||ans>=100){
      cout<<"NA"<<endl;
    }else{
      cout<<ans<<endl;
    }
  }
}

Measured memory_bytes: 52016
#include <iostream>
#include <algorithm>
using namespace std;
#define INF 1000000000
typedef long long ll;
int h,w,dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll a[35][35],dp[35][35][1000],ans=INF;
int main(void){
    cin>>h>>w;
    for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>a[i][j];
    for(int i=0;i<h;i++)for(int j=0;j<w;j++)for(int k=0;k<h*w;k++)dp[i][j][k]=INF;
    dp[0][0][0]=0;
    for(ll k=0;k<h*w;k++){
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(dp[i][j][k]!=INF){
                    for(int p=0;p<4;p++){
                        int x=j+dx[p],y=i+dy[p];
                        if(x>=0&&x<w&&y>=0&&y<h){
                            dp[y][x][k+1]=min(dp[y][x][k+1],dp[i][j][k]+a[y][x]*(k*2+1));
                        }
                    }
                }
            }
        }
    }
    for(int i=0;i<h*w;i++)ans=min(ans,dp[h-1][w-1][i]);
    cout<<ans<<endl;
}



Measured memory_bytes: 10248
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
ll mod=1000000000000000000;
int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n)cin >> a[i];
    rep(i,n){
        if(a[i]==0){
            cout << 0 << endl;
            return 0;
        }
    }
    ssort(a);
    FOR(i,n,1){
        if(a[0]>1000000000000000000){
            cout << -1 << endl;
            return 0;
        }else{
            ll tmp=a[0];
            a[0]*=a[i]%mod;
            
            if(a[0]>1000000000000000000||tmp>a[0]){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << a[0]<< endl;
}

Measured memory_bytes: 3984
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int cnt=0;
void merge(vector<int> &A,int left,int mid,int right){
	int n1=mid-left,n2=right-mid;
	vector<int> L,R;	for(int i=0;i<n1;i++){
		L.push_back(A[left+i]);
	}
	for(int i=0;i<n2;i++){
		R.push_back(A[mid+i]);
	}
	L.push_back(pow(10,9)+1);
	R.push_back(pow(10,9)+1);
	int i=0;
	int j=0;
	for(int k=left;k<right;k++){
		cnt++;
		if(L[i]<=R[j]){
			A[k]=L[i];
			i++;
		}else{
			A[k]=R[j];
			j++;
		}
	}
}

void mergeSort(vector<int> &A,int left,int right){
	if(left+1<right){
		int mid=(left+right)/2;
		mergeSort(A,left,mid);
		mergeSort(A,mid,right);
		merge(A,left,mid,right);
	}
}
int main(){
	int n;
	cin>>n;
	vector<int> S(n);
	for(int i=0;i<n;i++){
		cin>>S[i];
	}
	
	mergeSort(S,0,n);
	for(int i=0;i<n;i++){
		cout<<S[i];
		if(i!=n-1) cout<<' ';
	}
	cout<<'\n';
	cout<<cnt<<'\n';
	return 0;
}


Measured memory_bytes: 7348
#include<algorithm>
#include<cmath>
#include<cstdint>
#include<cstdio>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;

#define loop(i,a,b) for(int i=(a); i<(b); ++i)
#define rep(i,n) for(int i=0; i<n; ++i)
#define all(v) begin(v), end(v)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

const double PI = acos(-1.0);

int main() {
  std::ios::sync_with_stdio(false);

  vector<int> in(3);
  cin >> in[0] >> in[1] >> in[2];
  sort(all(in));
  int a = in[0];
  int b = in[1];
  int c = in[2];

  int ans = (c - a) / 2 + (c - b) / 2;
  int x = (c - a) % 2;
  int y = (c - b) % 2;
  if (x == 0 && y == 0) {
  } else if (x == 0 && y == 1) {
    ans += 2;
  } else if (x == 1 && y == 0) {
    ans += 2;
  } else if (x == 1 && y == 1) {
    ans ++;
  }

  cout << ans << endl;

  return 0;
}


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



#define MOD 1000000007
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  
  int x = 1, tot = 0;
  map<int, ll> cnt;
  ll res = 0;
 for (int i = n - 1; i >= 0; i--){
    cnt[tot]++;
    tot += (s[i]-'0')*x;
    tot %= 2019;
    res += cnt[tot];
    x = x*10%2019;
    
  }
  cout << res << endl;
}


Measured memory_bytes: 3728
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    ll M, D;
    cin >> M >> D;
    ll ans = 0;
    for(ll m = 0; m <= M; m++) {
        for(ll d = 22; d <= D; d++) {
            ll d_1 = d % 10;
            ll d_10 = (d / 10);
            if(!(d_1 >= 2 && d_10 >= 2)) continue;
            ans += (m == d_1 * d_10);
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
using ll = long long;

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

    int a, b;

    cin >> a >> b;

    int ans;

    for(int i = 1; i < 1100; ++i) {
        if(i * 8 / 100 == a && i * 10 / 100 == b) {
            printf("%d\n", i);
            return 0;
        }
    }

    printf("-1\n");

    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
S = [input() for _ in range(H)]

Ans = [[S[h][w] for w in range(W)] for h in range(H)]

for h in range(H):
    for w in range(W):
        if Ans[h][w] == '.':
            x = 0
            for i in [-1, 0, 1]:
                for j in [-1, 0, 1]:
                    if 0 <= h + i and h + i < H and 0 <= w + j and w + j < W and S[h + i][w + j] == '#':
                        x += 1
            Ans[h][w] = x

for h in range(H):
    for w in range(W):
        print(Ans[h][w], end="")
    print("")

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

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

  string S;
  cin >> S;

  vector<int> count(N + 1); // count[i] := the num of "AC" in s[0: i]
  for(int i = 1; i < N; i++){
    count[i + 1] = count[i];
    if(S[i] == 'C' && S[i - 1] == 'A'){
      count[i + 1]++;
    }
  }

  for(int i = 0; i < Q; i++){
    int l, r;
    cin >> l >> r;
    int ans = count[r] - count[l - 1];
    if(l > 1 && S[l - 1] == 'C' && S[l - 2] == 'A'){
      ans--;
    }
    cout << ans << endl;
  }
}


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

int main() {
	int n;
  	cin>>n;
  	int a[n];
  	for(int i=0;i<n;i++) 
      cin>>a[i];
  	int flag = 0;
  	for(int i=0;i<n;i++) 
    {
    	if(a[i]%2 == 0) 
        {
        	if(a[i]%3 != 0 && a[i]%5 != 0) 
            {
            	flag = 1;
              	break;
            }
        }
    }
  	if(flag == 1)
      cout<<"DENIED";
  	else
      cout<<"APPROVED";
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;


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

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<time.h>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include<cassert>
#include<cctype>
#include<iterator>
#include<unordered_map>
#include <cassert>
#include <bit>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
using Edge=pair<int,ll>;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// g++ -o a a.cpp -Wall -lm -std=c++17

int h,w,k;
bool b[8][8];


int main(){
    cin>>h>>w>>k;
    rep(i,h)rep(j,w){
        char s;cin>>s;
        if(s=='.')b[i][j]=0;
        else b[i][j]=1;
    }
    int ans=0;
    for(int i=0;i<(1<<h);i++){
        for(int j=0;j<(1<<w);j++){
            int cnt=0;
            rep(y,h)rep(x,w){
                if((i & 1<<y) ||(j & 1<<x))continue;
                else if(!b[y][x])continue;
                cnt++;
            }
            if(cnt==k)ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3616
import java.util.*

fun main(args: Array<String>) = FastScanner().run {
    val n = int()
    val p = int()
    val a = IntArray(n){int()}
    val existOdd = a.count { it % 2 != 0 } > 0
    val ret = if (existOdd) {
        2L.pow(n-1)
    } else {
        if (p == 0) 2L.pow(n) else 0
    }
    println(ret)
}

fun Long.pow(k: Int) = Math.pow(this.toDouble(), k.toDouble()).toLong()


class FastScanner {
    private val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = System.`in`.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }
    fun readByte(): Byte {
        return if (hasNextByte()) buffer[ptr++] else return -1
    }
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }
    fun string(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }
    fun long(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }
    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }
    fun double(): Double {
        return string().toDouble()
    }
}

Measured memory_bytes: 31140
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cinng(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfng(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
typedef unsigned long long ull;
const int inf=1039074182;
using namespace std;
int n,w;
int a[105],b[105];
ll dp[105][100005];

int main()
{
//	freopen("input.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin>>n>>w;
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
	}
	dp[0][a[0]]=b[0];
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<=w;j++)
		{
			dp[i][j]=max(dp[i][j],dp[i-1][j]);
			if(j-a[i]>=0) dp[i][j]=max(dp[i][j],dp[i-1][j-a[i]]+b[i]);
		}
	}
	ll res=0;
	for(int i=0;i<=w;i++)
	{
		res=max(res,dp[n-1][i]);
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 79360
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>

using ll = long long;

using namespace std;

long long x = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= x;
	if (n % 2 == 1)t *= a;
	return t % x;
}

const int INF = 1001001001;

int main() {
	int n, k;
	cin >> n >> k;
	vector<double>sum(n + 1);
	sum[0] = 0;
	for (int i = 1; i < n + 1; i++) {
		double p;
		cin >> p;
		p = (p + 1) / 2;		
		sum[i] = sum[i - 1] + p;		
	}
	double ans = 0;
	for (int i = k; i < n + 1; i++) {
		double tmp = sum[i] - sum[i - k];
		if (tmp > ans)ans = tmp;
	}
	printf("%.12lf\n", ans);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main()
{
     int x,a[9];
     while(true){cin>>x;
     if(x==0)break;
     for(int i=0;i<9;++i){
        cin>>a[i];
        x-=a[i];

     }
     cout<<x<<endl;}
    return 0;
}



Measured memory_bytes: 3004
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
    System.out.println(2*a*3.14159);
  }
}

Measured memory_bytes: 35836
import sys
rl = sys.stdin.readline


def solve():
    N, M = map(int, rl().split())
    graph = [set() for _ in range(N)]
    for _ in range(M):
        a, b = map(lambda x: int(x) - 1, rl().split())
        graph[a].add(b)
        graph[b].add(a)
    
    for child in graph[0]:
        if N - 1 in graph[child]:
            print('POSSIBLE')
            exit()
    print('IMPOSSIBLE')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 99788
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s; cin >> s;
	int n = s.size();
	if(s[0]!='A'){
		cout << "WA" << endl;
		return 0;
	}
	int Ccnt = 0;
	for(int i=2;i<n-1;i++){
		if(s[i]=='C'){
			Ccnt++;
		}
	}
	if(Ccnt!=1){
		cout << "WA" << endl;
		return 0;
	}
	int scnt = 0;
	for(int i=0;i<n;i++){
		for(char c='a';c<='z';c++){
			if(s[i]==c) scnt++;
		}
	}
	if(scnt!=n-2){
		cout << "WA" << endl;
		return 0; 
	}
	cout << "AC" << endl;
	return 0;
}

Measured memory_bytes: 256
# include <iostream>
using namespace std; 
int main(){
  int n; 
  cin>>n; 
  if(n<=599 && n>=400){
    cout<<"8";
  }
  if(n<=799 && n>=600){
    cout<<"7";
  }
  if(n<=999 && n>=800){
    cout<<"6";
  }
  if(n<=1199 && n>=1000){
    cout<<"5";
  }
  if(n<=1399 && n>=1200){
    cout<<"4";
  }
  if(n<=1599 && n>=1400){
    cout<<"3";
  }
  if(n<=1799 && n>=1600){
    cout<<"2";
  }
  if(n<=1999 && n>=1800){
    cout<<"1";
  }
  return 0;
}

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

int main()
{
	int n, i;
	int count = 0;
	int max = 0;
	int h[100];

	cin >> n;

	for(i = 0; i < n; i++){
		cin >> h[i];
	}

	max = h[0];
	count = 0;
	for(i = 0; i < n; i++){
		if(max <= h[i]){
			max = h[i];
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <numeric>
#include <cstring>
#include <algorithm>
#include <random>
#include <deque>
#include <queue>
#include <ctime>

using namespace std;

using LL = long long;

//void solve() {
//    int x1,y1, x2,y2;
//    cin >> x1 >> y1 >> x2 >> y2;
//
//    int n;
//    cin >> n;
//
//    if(x1 > x2) {
//        swap(x1, x2);
//        swap(y1, y2);
//    }
//
//    bool rev = y1 > y2;
//    if(rev) {
//        y1 *= -1;
//        y2 *= -1;
//    }
//
//    vector<pair<int, int>> a(n);
//    for(auto &it : a) {
//        cin >> it.first >> it.second;
//        if(rev) {
//            it.second *= -1;
//        }
//    }
//
//    sort(a.begin(), a.end());
//
//    vector<int> cl;
//    for(auto it : a)  {
//        if (x1 <= it.first && it.first <= x2 &&
//            y1 <= it.second && it.second <= y2) {
//            cl.push_back(it.second);
//        }
//    }
//
//    vector<int> dp(n + 1, 1000*1000*1000);
//    dp[0] = -1000*1000*1000;
//    for(int i = 0; i < cl.size(); ++i) {
//        int pos = upper_bound(dp.begin(), dp.end(), cl[i]) - dp.begin();
//        if(dp[pos - 1] < cl[i] && cl[i] < dp[pos])
//            dp[pos] = cl[i];
//    }
//
//    int cnt = 0;
//    for(int i = 0; i <= cl.size(); ++i) {
//        if(dp[i] != 1000*1000*1000) {
//            cnt = i;
//        }
//    }
//
//    LL ans = 100*LL(abs(x2 - x1) + abs(y2 - y1)) - 20*cnt;
//
//    if(cnt == abs(y2 - y1) + 1) {
//        cnt++;
//    }
//
//    cout << ans + 5.0*cnt*acos(-1) << endl;
//}
//
//int main() {
//    cout.precision(30);
//    solve();
//}

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

    int n = s.size();
    vector<vector<int>> pr(s.size() + 1, vector<int> (30, 0));

    for(int i = 1; i <= n; ++i) {
        pr[i] = pr[i-1];
        pr[i][s[i - 1] - 'a']++;
    }

    LL ans = 0;

    for(int i = 0; i < n; ++i) {
        ans += n - i;
        ans -= (pr[n][s[i] - 'a'] - pr[i][s[i]- 'a']);
    }

    cout << ans + 1 << endl;
}


Measured memory_bytes: 30084