akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0055
{
    class Program
    {
        static void Main(string[] args)
        {
            string temp = "";
            double term1 = 0;
            double[] term = new double[10];

            while ((temp = Console.ReadLine()) != null)
            {
                term1 = double.Parse(temp);
                term[0] = term1;
                double answer = 0;

                for (int i = 1; i < 10; i++)
                {
                    if (i % 2 == 0)
                    {
                        term[i] = term[i - 1] / 3;

                    }
                    else
                    {
                        term[i] = term[i - 1] * 2;
                    }
                }
                foreach (double item in term)
                {
                    answer += item;
                }
                Console.WriteLine(answer);
            }
        }
    }
}



Measured memory_bytes: 17904
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int i,j,n;
	long long m=100000,k,p;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		m=m+(m*5/100);
		if(m%1000!=0)
		{
			m=m/1000;
			m=m*1000+1000;
		}
	}
	cout<<m<<endl;
	return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<string> S(N);
  for(int i = 0; i < N; ++i){
    cin >> S[i];
    sort(S[i].begin(), S[i].end());
  }
  vector<int> id(N,0);
  char c = 'a';
  string ans;
  while(c <= 'z'){
    bool f = true;
    for(int i = 0; i < N; ++i){
      while(id[i] < S[i].length() && S[i][id[i]] < c) ++id[i];
      if(id[i] >= S[i].length() || S[i][id[i]] != c) f = false;
      else ++id[i];
    }
    if(f) ans += c;
    else ++c;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    rep(i,V){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    rep(i,V){
      d[i] = INF/10;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};
int main() {
  string s;
  cin>>s;
  ll ca = 0;
  ll len = s.size();
  ll cd = 0;
  ll cc = 0;
  ll sa,sb;
  ll f = 0;
  ll q = 0;
  ll w = 0;
  ll ans = len;
  for(ll i=0; i<len; i++){
    if(s[i]!=s[i+1]){
      ca = max(len-(i+1),i+1);
    ans = min(ans,ca);}
  }
  cout << ans << endl;}


Measured memory_bytes: 3740
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int count = 1;
    char[] ca = sc.next().toCharArray();
    for (int i = 0; i < n - 1; i++)
      if (ca[i] != ca[i + 1])
        count++;
    System.out.println(count);
  }
}

Measured memory_bytes: 27908
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (int i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PL = pair<long long, long long>;
const int INF = 1001001007;
const int mod = 1000000007;

int main(){
    int n; cin >> n;
    ll ans = 0;
    repp(i,n+1,1){
        if (i % 3 != 0 && i % 5 != 0) ans += i; 
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int x[10][7] = {
	{0,1,1,1,1,1,1},
	{0,0,0,0,1,1,0},
	{1,0,1,1,0,1,1},
	{1,0,0,1,1,1,1},
	{1,1,0,0,1,1,0},
	{1,1,0,1,1,0,1},
	{1,1,1,1,1,0,1},
	{0,1,0,0,1,1,1},
	{1,1,1,1,1,1,1},
	{1,1,0,1,1,1,1}
};
int p[7];
int main() {
	int n, a;
	while (true) {
		cin >> n; if (n == -1) { break; }
		for (int i = 0; i < 7; i++) { p[i] = 0; }
		for (int i = 0; i < n; i++) {
			cin >> a;
			for (int j = 0; j < 7; j++) {
				cout << (p[j] ^ x[a][j]);
				p[j] = x[a][j];
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
    int n,x; cin>>n>>x;
    if(x==1||x==2*n-1){
        Yes(0);
    }else{
        Yes(1);
        if(x==2){
            FOR(i,0,n-1){
                co(n+1+i);
            }
            FOR(i,0,n){
                co(i+1);
            }
        }else{
            int k=0;
            FOR(i,0,n-2){
                if(x-2==k+1){
                    k+=5;
                }else{
                    k++;
                }
                co(k);
            }
            co(x-2); co(x); co(x+1); co(x-1);
            FOR(i,0,n-3){
                if(x-2==k+1){
                    k+=5;
                }else{
                    k++;
                }
                co(k);
            }
        }
    }
}


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

judege=0
for num in a:
    if num%2==0:
        if num%3==0 or num%5==0:
            pass
        else:
            judege+=1

    
        
if judege==0:       
    print("APPROVED")
else:
    print("DENIED")

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    int n;
    ll k; 
    cin >> n >> k;
    vector<int> a(n);
    vector<int> f(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> f[i];
    sort(a.begin(), a.end());
    sort(f.rbegin(), f.rend());
    ll l = -1, r = 1e12;
    while(l+1 < r){
        ll c = (l+r) / 2;
        ll sum = 0;
        rep(i,n)sum += max(0ll, (a[i] - c/f[i]));
        if(sum <= k)r = c;
        else l = c;
    }
    cout << r << endl;
}

Measured memory_bytes: 1792
#include <map>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <tr1/unordered_map>
#define mo 1000000007
#define num(x) (x>='0' && x<='9')
typedef unsigned long long ull;
typedef long long ll;
using namespace std::tr1;
using namespace std;
int read(){
    int p=0, q=1;
    char ch=getchar();
    while (!num(ch))
        (ch=='-'?q=-1:0),
        ch=getchar();
    while (num(ch)) p=p*10+ch-'0', ch=getchar();
    return p*q;
}
int power(ll a, int b){
	ll c=1;
	while (b){
		if (b&1) c=c*a%mo;
		a=a*a%mo;
		b>>=1;
	}
	return c;
}
int main(){
	int x=read();
	if (x>=30) puts("Yes");
	else puts("No"); 
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef vector<int> vi;

int main() {FIN
	
	int k, n, sum = 0, _min = 1000000000, i;
	cin >> k >> n;
	vi hs(n), ds(n);
	for (i = 0; i < n; i++) {
		cin >> hs[i];
		if (i > 0) {
			ds[i - 1] = hs[i] - hs[i - 1] ;
			sum += ds[i - 1];
		}
	}
	ds[n - 1] = abs((hs[0] + k) - hs[n - 1]);
	sum += ds[n - 1];
	
	for (i = 0; i < n; i++)
		_min = min(_min, sum - ds[i]);
	
	cout << _min << "\n";
		
	return 0;	
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b)   (((a)+(b)-1)/(b))
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout << fixed << setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main() {
	int k = in();
	int even = k / 2, odd = k - even;
	cout << even * odd << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
s = list(input())
n = len(s)
res = 10**6

for k in range(n-1):
    if s[k]!=s[k+1]:
        res = min(res, max(k+1, n-k-1))

if res==10**6:
    res = n
print(res)


Measured memory_bytes: 3956
S = [s for s in input()]

S0 = S[0]
S1 = S[1]
S2 = S[2]

if S0 == S1 == S2 == 'R':
    count = 3

elif S0 == S1 == 'R' or S1 == S2 == 'R':
    count = 2

elif S0 == S1 == S2 == 'S':
    count = 0

else:
    count = 1

print(count)


Measured memory_bytes: 9052
#include <iostream>
#include <string>

using namespace std;

bool can_comm(string a, string b, string k) {
  int A = stoi(a);
  int B = stoi(b);
  int K = stoi(k);

  if (abs(A - B) <= K) {
    return true;
  } else {
    return false;
  }
}

int main(int argc, char* argv[]) {
  string a;
  cin >> a;
  string b;
  cin >> b;
  string c;
  cin >> c;
  string d;
  cin >> d;
  string e;
  cin >> e;
  string k;
  cin >> k;

  if (can_comm(a, b, k) &&
      can_comm(a, c, k) &&
      can_comm(a, d, k) &&
      can_comm(a, e, k) &&
      can_comm(b, c, k) &&
      can_comm(b, d, k) &&
      can_comm(b, e, k) &&
      can_comm(c, d, k) &&
      can_comm(c, e, k) &&
      can_comm(d, e, k)
      ) {
    cout << "Yay!"         << "\n";
  } else {
    cout << ":("         << "\n";
  }

  return 0;
}


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

int main(){
  char c;
  int pass=0, sum=0;

  while((c=getchar()) != EOF){
    if('0' <= c  && c <= '9'){
	pass *= 10;
	pass += c - '0';
      }
      else{
      sum += pass;
      pass = 0;
      }
  }
  cout << sum << endl;
  return 0;
}

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

table = {}

for _ in range(N):
	S = input().strip()
	if S in table:
		table[S] += 1
	else:
		table[S] = 1

data = []
for S, count in table.items():
	data.append((-count, S))

data.sort()

i = 0
while True:
	print(data[i][1])
	i += 1
	if i >= len(data) or data[i][0] != data[0][0]:
		break


Measured memory_bytes: 45856
#include<cstdio>
#include<string>
#define min(a,b) ((a)<(b)?(a):(b))
#define MAXN 100005
using namespace std;
inline int read(){
	register int x=0;
	register bool f=1;
	register char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-') f=0;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=(x<<1)+(x<<3)+(ch-'0');
		ch=getchar();
	}
	return f?x:-x;
}
long long A[MAXN],N,ans,sum;
int main(){
	N=read();
	for(int i=1;i<=N;i++) A[i]=read();
	for(int i=1;i<=N;i++){
		sum+=A[i];
		if(!A[i]||sum%2==0){
			ans+=(sum/2);
			sum=0;
		}
	}
	ans+=(sum/2);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 896
S = input()
def check(S): #1 moji
    if S in "ATGC":
        return True
    else:
        return False

ans =0
for i in range(len(S)):
    temp = 0
    while i<len(S) and check(S[i]):
        temp+=1
        i+=1
    ans = max(ans,temp)

print(ans)


Measured memory_bytes: 2940
#include<iostream>
#include<string>
using namespace std;
int main(){
  long long N,M;
  cin >> N >> M;
  if(N==1){
    if(M==1){
    cout<< M;
  }else{
    cout<<M-2;
  }
}else{
  if(M==1){
    cout <<N-2;
  }else{
    cout<<N*M-2*N-2*M+4;
  }
}
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll mod = 1e9+7;
const ll N = 3002;
ll dp[N][N],arr[N]={0};

ll solve(ll l,ll r,ll p)
{
    //cout<<l<<" "<<r<<" "<<p<<endl;
    if(l==r){
        if(p==0){
            dp[l][r] = arr[l];
        }
        else
            dp[l][r] = -1*arr[l];
        return dp[l][r];
    }
    if(dp[l][r]!=-1)
        return dp[l][r];
    ll x = solve(l+1,r,1-p);
    ll y = solve(l,r-1,1-p);
    if(p==0){
        x+=arr[l];
        y+=arr[r];
        dp[l][r] = max(x,y);
        return dp[l][r];
    }
    else{
        x-=arr[l];
        y-=arr[r];
        dp[l][r] = min(x,y);
        return dp[l][r];
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        for(int j=0;j<n;j++)
            dp[i][j]=-1;
    }
    cout<<solve(0,n-1,0)<<endl;
    /*for(int i=0;i<n;i++){
        for(int j=0;j<n;j++)
            cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  double L;
  cin >> L;
  double ans = (L * L * L) / (3 * 3 * 3);
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char* argv[])
{
  int A, B, K; cin >> A >> B >> K;

  vector<int> divide;
  for (int i = 1; i <= min(A, B); i++) {
    if (A%i == 0 && B%i == 0) {
      divide.push_back(i);
    }
  }

  cout << divide[divide.size()-K] << endl;
  return 0;
}


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

int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    transform(s1.begin(), s1.end(), s1.begin(), ::toupper);
    transform(s2.begin(), s2.end(), s2.begin(), ::toupper);
    transform(s3.begin(), s3.end(), s3.begin(), ::toupper);

    cout << s1.at(0) << s2.at(0) << s3.at(0) << endl;
    return 0;
}

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





int main() {
  int x,a,b;
  cin>>x>>a>>b;
  
  if (abs(x-a)<abs(x-b)){
    cout<<'A'<<endl;
  }
  else{
    cout<<'B'<<endl;
  }
}
  













Measured memory_bytes: 256
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
#include <string>
using namespace std;
#define N 100009
#define ll long long

int main(){
    int n;
    cin>>n;
    int data[n];
    for (int i=0; i<n; i++){
        cin>>data[i];
    }
    long sum=0;
    for (int i=0; i<n-1; i++){
        for (int j=i+1; j<n; j++){
            int p=data[i]*data[j];
            sum+=p;
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e12;
using Graph = vector<vector<int>>;

signed main(){
  int N, T;
  cin >> N >> T;
  vector<pair<int, int>> dish(N);
  for( int i = 0; i < N; i++ ){
    int A, B;
    cin >> A >> B;
    dish[i] = {A, B};
  }
  sort(dish.begin(), dish.end());

  vector<int> dp(7000);
  for( int i = 0; i < N; i++ ){
    for( int j = T-1; j >= 0; j-- ){
      int A = dish[i].first;
      int B = dish[i].second;
      dp[j+A] = max(dp[j+A], dp[j]+B);
    }
  }
  int ans = 0;
  for( int i = 0; i < 6200; i++ ){
    ans = max(ans, dp[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
ll mod=1000000007;

int main(){
    std::ios::sync_with_stdio(false);
    double a,b;
    cin>>a>>b;
    double ans=a/b;
    //cout<<ans<<endl;
    std::cout << std::fixed;
    cout<<std::setprecision(6)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,k;
	cin>>n>>k;
	map<ll,ll>a;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		a[x]++;
	}
	vector<ll>b;
	for(auto i=a.begin();i!=a.end();i++){
		ll val=i->second;
		b.push_back(val);
	}
	sort(b.begin(),b.end());
	ll ans=0;
	for(ll i=0;i+k<b.size();i++){
		ans+=b[i];
	}
	cout <<ans;
	// your code goes here
	return 0;
}

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

int main(){
    ll L, R;
    cin >> L >> R;
    ll ans = 20000;
    if(R - L >= 2019){
        cout << 0 << endl;
    }
    else{
        for(ll i = L; i < R; i++){
            for(ll j = i + 1; j <= R; j++){
                ll a;
                a = (i * j) % 2019;
                ans = min(ans, a);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	N := sc.nextInt()
	h := sc.nextIntSlice(N)
	ans := 0
	for {
		done := true
		for i := 0; i < N; i++ {
			if h[i] != 0 {
				done = false
			}
		}
		if done {
			break
		}

		start := false
		for i := 0; i < N; i++ {
			if h[i] > 0 {
				h[i]--
				start = true
			} else if start {
				break
			}
		}
		ans++
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main{
	public static void main(String[] args){
		solve();
	}
	private static void solve() {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		int V = sc.nextInt();
		int E = sc.nextInt();
		int r = sc.nextInt();
		@SuppressWarnings("unchecked")
		List<Edge>[] edges = Stream.generate(ArrayList::new).limit(V).toArray(List[]::new);
		for(int i=0;i<E;i++){
			edges[sc.nextInt()].add(new Edge(sc.nextInt(), sc.nextInt()));
		}
		int[] dist = new int[V];
		int[] pred = new int[V];
		shortestPaths(edges, r, dist, pred);
		for(int i=0;i<V;i++){
			if(dist[i]==Integer.MAX_VALUE){
				System.out.println("INF");
				continue;
			}
			System.out.println(dist[i]);
		}
	}
	public static void shortestPaths(List<Edge>[] edges, int s, int[] prio, int[] pred) {
		Arrays.fill(pred, -1);
		Arrays.fill(prio, Integer.MAX_VALUE);
		prio[s] = 0;
		PriorityQueue<Long> q = new PriorityQueue<>();
		q.add((long) s);
		while (!q.isEmpty()) {
			long cur = q.remove();
			int curu = (int) cur;
			if (cur >>> 32 != prio[curu])
				continue;
			for (Edge e : edges[curu]) {
				int v = e.t;
				int nprio = prio[curu] + e.cost;
				if (prio[v] > nprio) {
					prio[v] = nprio;
					pred[v] = curu;
					q.add(((long) nprio << 32) + v);
				}
			}
		}
	}

	static class Edge {
		int t;
		int cost;

		public Edge(int t, int cost) {
			this.t = t;
			this.cost = cost;
		}
	}

}

Measured memory_bytes: 326824
from collections import Counter

N = int(input())
As = list(map(int,input().split()))
# print(As)
Q = int(input())
Bs = []
Cs = []
for _ in range(Q):
  b,c = map(int,input().split())
  Bs.append(b)
  Cs.append(c)

cnt = Counter(As)
sum0 = sum(As)
for i in range(Q):
  sum0 += cnt[Bs[i]] * (Cs[i] - Bs[i])
  cnt[Cs[i]] += cnt[Bs[i]]
  cnt[Bs[i]] = 0
  print(sum0)

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

#define int long long 
vector<pair<vector<int>,int>> a;
vector<int> ans;
void dfs(int root,int pre,int sum){

    sum += a[root].second;
    ans[root] = sum;

    for(auto x : a[root].first){
        if(x != pre){
            dfs(x,root,sum);
        }
    }
}

signed main(){
    int n,q;
    cin >> n >> q;
    a.resize(n);
    for(int i =0 ; i < n - 1; ++i){
        int x,y;
        cin >> x >> y;
        --x,--y;
        a[x].first.push_back(y);
        a[y].first.push_back(x);
    }
    ans.resize(n);
    while(q--){
        int node,val;
        cin >> node >> val;
        node--;
        a[node].second += val;
    }
    dfs(0,0,0);

    for(auto x : ans) {
        cout << x << " ";
    }
}

Measured memory_bytes: 25856
#include <iostream>
#include <vector>

using namespace std;
using ll = long long int;
using vll = std::vector<ll>;

ll N, K;
vll A;

int main() {
  cin >> N >> K;
  for (ll i = 0; i < N; i++) {
    ll tmp; 
    cin >> tmp;
    A.push_back(tmp);
  }

  vll off_count(64, 0);
  for (ll sht = 0; sht < 60; sht++) {
    ll cnt = 0;
    for (ll a : A) {
      if ((a & (1LL << sht)) == 0LL) {
        cnt++;
      }
    }
    off_count[sht] = cnt;
  }

  ll k = K;
  ll x = 0LL;
  for (ll sht = 60; sht >= 0; sht--) {
    if (off_count[sht] > N / 2) { // we should flip this bit
      if ((1LL << sht) <= k) { // can we do that?
        k -= (1LL << sht);
        x ^= (1LL << sht);
      }
    }
  }

  ll sum = 0LL;
  for (ll a : A) {
    sum += (x ^ a);
  }

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define int long long

int n;
vector <int> v;

void check(int a, int b) {
	if (a*b == n) v.push_back(a+b-2);
}

int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for(int i = 1; i <= sqrt(n); ++i) {
		check(i, n/i);
	}
	cout << *min_element(v.begin(), v.end());
}

Measured memory_bytes: 3700
#include<stdio.h>

int main(void){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  for(int i=1;i<=b;i++){
    if((i*a)%b==c){
      printf("YES\n");
      return 0;
    }
  }
  printf("NO\n");
  return 0;
}

Measured memory_bytes: 128
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    long res=0;
    long[] a=new long[n];
    Map<Long,Long> map=new TreeMap<>();
    for(int i=0;i<n;i++) {
    	a[i]=sc.nextLong();
    	if(map.containsKey(a[i])) {
    		map.put(a[i], map.get(a[i])+1L);
    	}else {
    		map.put(a[i], 1L);
    	}
    }
    for (Long key : map.keySet()){
    	if(map.get(key)-key>=0) {
    		res+=Math.min(map.get(key)-key, map.get(key));
    	}else {
    		res+=map.get(key);
    	}
    }
    System.out.println(res);
  }
}


Measured memory_bytes: 63772
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll ac(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main()
{
	int N, k;
	cin >> N >> k;
	vector<int> A(N);
	rep(i, 0, N) {
		cin >> A[i];
	}
	rep(_i, 0, min(k, 1000)) {
		vector<int> B(N, 0);
		rep(i, 0, N) {
			int l = max(0, i - A[i]);
			int r = min(N - 1, i + A[i]);
			B[l]++;
			if (r + 1 < N)B[r + 1]--;
		}
		rep(i, 0, N - 1)B[i + 1] += B[i];
		rep(i, 0, N)A[i] = B[i];
	}
	rep(i, 0, N) {
		printf(i == N - 1 ? "%d\n" : "%d ", A[i]);
	}
	return 0;
}


Measured memory_bytes: 4972
#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 main() {
    int n;
    cin >> n;
    deque<int> b;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if (i % 2 == 0) b.push_back(a);
        else b.push_front(a);
    }
    
    if (n % 2 == 1) {
        for (int i = n - 1; i >= 0; i--)
        {
            if (i != 0)
                cout << b[i] << " ";
            else
                cout << b[i];
        }
        
    } else {
        for (int i = 0; i < n; i++)
        {
            if (i != n - 1)
                cout << b[i] << " ";
            else
                cout << b[i];
        }
    }
    cout << endl;
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  long long mod=10e8+7;
  long long tmp=1;
  for(int i=1;i<=n;i++){
    tmp=((tmp%mod)*i)%mod;
  }
  cout<<tmp%mod<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n, m, i, sum = 0;
  int a[10000];
  
  scanf("%d %d", &n, &m);
  
  for(i = 0; i < m; i++){
    scanf("%d", &a[i]);
    sum += a[i];
  }
  
  if(sum > n){
    printf("-1");
  }else{
    printf("%d", n-sum);
  }
  
  return 0;
 
}

Measured memory_bytes: 1736
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define int ll
using pint = pair<int,int>;
using Graph = vector<vector<int>>;
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#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 out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 1e10; //10^10
const double PI = acos(-1.0L);
/*mod逆元*/long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}
template< typename T >T mod_pow(T x, T n, T p=MOD) {T ret = 1;while(n > 0) {if(n & 1) (ret *= x) %= p;(x *= x) %= p;n >>= 1;}return ret;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}

//----------------ライブラリとか----------------

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

    int n,t; cin >> n >> t;
    VI tt(n); REP(i,n) cin >> tt[i];
    int ans = t;
    REP(i,n-1){
        if(tt[i]+t>=tt[i+1]) ans+=(tt[i+1]-tt[i]);
        else ans+=t;
    }
    out(ans);

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cctype>
#include <cassert>
#include <cstring>
#include <climits>
 
using namespace std;
 
#define FOR(k,a,b) for(int k=(a); k < (b); k++)
#define FORE(k,a,b) for(int k=(a); k <= (b); k++)
#define REP(k,a) for(int k=0; k < (a); k++)
 
#define ALL(c) (c).begin(), (c).end()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define RANGE(lb, x, ub) ((lb) <= (x) && (x) < (ub))
 
#define dump(x) cerr << #x << ": " << (x) << endl;
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
 
const int INF = 1000000000;
const double EPS = 1e-10;
const double PI = acos(-1.0);
 
int main(void) {
	ll n, m; cin >> n >> m;
	ll sum=0;
	vector<ll> A(n); REP(i, n) {cin >> A[i]; sum+=A[i];}
	
	ll items=0;
	REP(i, n) {
		items += A[i] >= sum/(4.0*m);
	}

	cout << (items >= m ? "Yes" : "No") << endl;

    return 0;
}


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

using namespace std;

#define int long long

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> cnt(n);
    for (int i = 0; i < q; ++i)
    {
        int x;
        cin >> x;
        --x;
        ++cnt[x];
    }
    for (int i = 0; i < n; ++i)
    {
        if (k + cnt[i] - q > 0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1536
ary = []
5.times { ary << gets.to_i }
remainder = 0
wait_times = []
count = 0
ary.each do |i|
  wait_times << 10 - i % 10 unless i % 10 == 0
end
count = 0
ary.each { |i| count += i }
wait_times.each { |i| count += i }
max_time = wait_times.length > 1 ? wait_times.max : 0
puts count - max_time

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

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    cout<<setprecision(10)<<fixed;
    double r;
    cin>>r;
    double pi = acos(-1.0);
    cout<<r*pi*2.0<<endl;
    return 0;
}


Measured memory_bytes: 3820
//In the name of God
 
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair <int , int> pii;
 
const int N = 3e3+10 , mod = 1e9+7;
 
int dp[N][N];
pii par[N][N] , lst;
 
int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   string s , t;
   cin >> s >> t;
   s = "!" + s;
   t = "@" + t;
   int ans = 0;
   for(int i = 1 ; i < s.length() ; i++)
      for(int j = 1 ; j < t.length() ; j++){
         if(s[i] == t[j])
            dp[i][j] = max(dp[i][j] , dp[i - 1][j - 1] + 1) , par[i][j] = {i - 1 , j - 1};
         else{
            if(dp[i - 1][j] > dp[i][j]){
               dp[i][j] = dp[i - 1][j];
               par[i][j] = {i - 1 , j};
            }
            if(dp[i][j - 1] > dp[i][j]){
               dp[i][j] = dp[i][j - 1];
               par[i][j] = {i , j - 1};
            }
         }
         if(dp[i][j] > ans){
            ans = dp[i][j];
            lst = {i , j};
         }
      }
   string ret = "";
   while(lst.first != 0 && lst.second != 0){
      int i = lst.first , j = lst.second;
      if(s[i] == t[j])
         ret = ret + s[i];
      lst = par[i][j];
   }
   reverse(ret.begin() , ret.end());
   cout << ret;
   return 0;
}

Measured memory_bytes: 106368
import java.util.Scanner;
public class Main {
	 public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
	        int a, c = 0;
	        while(true) {
	            a = sc.nextInt();
	            if(a == 0) break;
	            System.out.println("Case " + (++c) + ": " + a);
	        }
	    }
	}


Measured memory_bytes: 42584
import collections
N = int(input())
A = list(map(int, input().split()))


ans = 0
t = collections.defaultdict(int)
t2 = collections.defaultdict(int)
for i, x in enumerate(A):
    t[i-x] += 1
    t2[x+i] += 1
for i, x in enumerate(A):
    ans += t[x+i]
    ans += t2[i-x]

print(ans // 2)


Measured memory_bytes: 90276
#include <stdio.h>
int f[45];

int fib(int n){
  if(n==0 || n==1)return f[n]=1;
  if(f[n]!=0)return f[n];
  return f[n]=fib(n-2)+fib(n-1);
}
int main(){
  int n,i;
  for(i=0;i<45;i++)f[i]=0;
  scanf("%d",&n);
  printf("%d\n",fib(n));
  return 0;
}



Measured memory_bytes: 2104
import sys
from fractions import gcd


def main():
    x1, y1, x2, y2 = map(int, input().split())
    x3 = x2 - (y2 - y1)
    y3 = y2 + (x2 - x1)
    x4 = x1 - (y2 - y1)
    y4 = y1 + (x2 - x1)
    print(x3, y3, x4, y4)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5588
import numpy as np

C = np.zeros((3, 3))
for i in range(3):
    C[i, 0], C[i, 1], C[i, 2] = [int(_) for _ in input().split()]

for i in range(3):
    for j in range(2):
        if not(C[i, 0] - C[j, 0] == C[i, 1] - C[j, 1] == C[i, 2] - C[j, 2])\
                or not\
                (C[0, i] - C[0, j] == C[1, i] - C[1, j] == C[2, i] - C[2, j]):
            print('No')
            quit()
print('Yes')

Measured memory_bytes: 12448
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x) 
{
    return (ll)(log(x) / log(base));
}
ll n,p; string s;
bool pp(string x)
{
	ll y=x.size();
	rep(i,0,y/2)
	if(x[i]!=x[y-i-1])
	return false;
	
	return true;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll m,k,l,g,i,ans;
    	cin>>s;
    	n=s.size();
    	if(pp(s) && pp(s.substr(0,(n-1)/2)) && pp(s.substr(((n+3)/2)-1)))
    	cout<<"Yes";
    	else
    	cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
import copy
import itertools
def main():
    H, W,K = map(int, input().split())
    c = []
    for i in range(H):
        c.append(list(input()))
    alllist = [x for x in range(H+W)]
    ans = 0
    for i in range(H+W):
        numlist = list(itertools.combinations(alllist, i))
        for num in numlist:
            R = []
            C = []
            for n in num:
                if n < H:
                    R.append(n)
                else:
                    C.append(n-H)
            cnt = 0
            for h in range(H):
                for w in range(W):
                    if not h in R and not w in C:
                        if c[h][w] == '#':
                            cnt += 1
            if cnt == K:
                ans += 1
    print(ans)
                    
                
if __name__ == '__main__':
    main()

Measured memory_bytes: 9436
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,t;
	scanf("%d %d",&a,&b);
	t=b;
	while(t!=0)
	{
		t/=10;
		a*=10;
	}
	a+=b;
	if(sqrt(a)==(int)sqrt(a))
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>

#define MAX_SIZE 100000000
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  string S; cin>>S;
  int a_pos = S.find("A");
  int len = S.size();
  reverse(S.begin(), S.end());
  int z_pos = S.find("Z");
  int real_z_pos = len - z_pos;

  cout << real_z_pos - a_pos << endl;
}


Measured memory_bytes: 640
N=int(input())
S=input()
p=10**9+7

from collections import defaultdict
D=defaultdict(int)
num=0
ans=0
dp=[0]*N
dp[0]=2
D[S[0]]+=1
for i in range(1,N):
    s=S[i]
    if D[s]>=1:
        dp[i]=(dp[i-1]+dp[i-1]*pow(D[s]+1,p-2,p))%p
        #print(D[s])
        D[s]+=1
    else:
        dp[i]=dp[i-1]*2%p
        D[s]+=1
#print(dp)
print((dp[-1]-1)%p)

Measured memory_bytes: 69468
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var hwab = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var h = hwab[0];
            var w = hwab[1];
            var a = hwab[2];
            var b = hwab[3];

            var answer = new int[h][].Select(x => new int[w]).ToArray();

            for (var i = 0; i < h; i++)
            {
                for (var j = 0; j < w; j++)
                {
                    answer[i][j] = (i < b) ^ (j < a) ? 1 : 0;
                }
            }

            for (var i = 0; i < answer.Length; i++)
            {
                Console.WriteLine(string.Join("", answer[i]));
            }
        }
    }
}


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

using namespace std;

const int mod = (int) 1e9 + 7;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto& x : a) {
    cin >> x;
  }
  vector<long long> sum(n);
  for (int i = n-1; i >= 0; i--) {
    sum[i] = ((i == n-1 ? 0LL : sum[i+1]) + a[i]);
    if (sum[i] >= mod) {
      sum[i] -= mod;
    }
  }
  long long ans = 0;
  for (int i = 0; i+1 < n; i++) {
    ans = (ans + (a[i] * sum[i+1])) %mod;
  }
  cout << ans << '\n';
  return 0;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) (v.begin(), v.end())
#define dump(v)              \
  cerr << #v ":[ ";          \
  for (auto macro_vi : v) {  \
    cerr << macro_vi << " "; \
  }                          \
  cerr << "]" << endl;
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

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

  if (a >= 1) {
    if (k >= a) {
      k -= a;
      a = 0;

    } else {
      a -= k;
      k = 0;
      cout << a << " " << b << endl;
      return 0;
    }
  }

  if (b >= 1) {
    if (k >= b) {
      k -= b;
      b = 0;

    } else {
      b -= k;
      k = 0;
    }
  }

  cout << a << " " << b << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)




int main(){

ll N;
cin>>N;
vector<string> S(N);

for(ll i=0;i<N;i++){
    cin>>S[i];
}

sort(ALL(S));


string pre = S[0];

ll nnum=1;
vector<pair<ll,string>> v;
for(ll i=1;i<N;i++){
    if(pre==S[i]){
        nnum++;
    }
    else{
        v.push_back(mkpr(nnum,pre));
        nnum=1;
    }
    pre = S[i];
}


    v.push_back(mkpr(nnum,pre));

    sort(ALL(v));
    reverse(ALL(v));

vector<string> ans;
ans.push_back(v[0].second);
ll pp =  v[0].first;
    for(ll i=1;i<v.size();i++){
        if(v[i].first==pp)
       ans.push_back(v[i].second);
        else{
            break;
        }
    }
    
    sort(ALL(ans));

    for(ll i=0;i<ans.size();i++){
    cout<<ans[i]<<endl;
}


}


Measured memory_bytes: 21360
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;
ld pi = acos(-1.0);
const ld dtop = pi / 180.;
const ld ptod = 1. / dtop;

ld rad = 6378.1;
int main() {
	while (1) {
		ld a, b, c, d; cin >> a >> b >> c >> d;
		if (b < -eps)break;
		ld wd= (d-b);
		
		ld ax = rad*(cos(a*dtop));
		ld ay = 0;
		ld az = rad*(sin(a*dtop));
		ld bx = (rad*cos(wd*dtop))*(cos(c*dtop));
		ld by = (rad*sin(wd*dtop))*(cos(c*dtop));
		ld bz = rad*(sin(c*dtop));
		ld dx = ax - bx;
		ld dy = ay - by;
		ld dz = az - bz;
		ld dis = sqrt(dx*dx + dy*dy + dz*dz);
		ld arad = asin( (dis / 2)/rad);
		ld ans = rad*2*arad;
		int ians = int(round(ans));
		cout << ians << endl;
	}
	return 0;
}

Measured memory_bytes: 3308
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
count = 0
for i in range(N):
    ans = 0
    A = list(map(int,input().split()))
    for j in range(M):
        ans += A[j]*B[j]
    ans += C
    if ans > 0:
        count += 1
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <string>
#include <sstream>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

struct Node {
    int num;
    ll c;
};

ll calc(int i, vector<Node> vec, ll count, ll cur, ll G) {
    if (i < 0) {
        return 10000000000;
    }
    for (int j = 0; j < vec[i].num; ++j) {
        // cout << i << " " << j << " " << cur << " " << count << endl;
        cur += 100 * (i + 1);
        ++count;
        
        if (cur >= G) {
            return count;
        }
    }
    cur += vec[i].c;
    if (cur >= G) {
        return count;
    }
    ll ans = 10000000000;
    for (int j = 0; j < i; ++j) {
        ans = min(ans, calc(j, vec, count, cur, G));
    }
    return ans;
}

int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    ll D, G;
    cin >> D >> G;
    vector<Node> vec;
    for (int i = 0; i < D; ++i) {
        ll p, c;
        cin >> p >> c;
        Node n = {
            num: p,
            c: c
        };
        vec.push_back(n);
    }

    ll ans = 10000000000;
    for (int i = 0; i < D; ++i) {
        ans = min(ans, calc(i, vec, 0, 0, G));
    }

    cout << ans << endl;
}

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

int MOD = (int) 1e9+7;
int N;

int solve(vector<vector<int>>& A, int n, int mask, vector<vector<int>>& dp) {

  if(n == 0) { return 1;}

  if(dp[n][mask] != -1) {
    return dp[n][mask];
  }

  int ans = 0;

  for(int j = 0; j < N; j++) {
    if( (mask & (1 << j)) && A[N-n][j]) {
      ans += solve(A, n-1, mask & ( ~ (1 << j)), dp);
      ans %= MOD;
    }
  }

  dp[n][mask] = ans;
  return ans;
  
}
int main() {
  cin >> N;
  vector<vector<int>> A(N, vector<int> (N, 0));
  for(int i = 0; i < N; i++) {
  for(int j = 0; j < N; j++) {
    int in;
    cin >> in;
    A[i][j] = in;
  }}

  vector<vector<int>> dp(N+5, vector<int> ((1<<N)+5, -1));

  cout << solve(A, N, (1 << N) - 1, dp) << endl;
}




Measured memory_bytes: 221568