akhauriyash/Code-Regression huggingface dataset:
-- modules to import --

import qualified Data.ByteString.Char8
import qualified Data.Maybe
import           Prelude

-- functions for this task --

readInteger' = Prelude.fst . Data.Maybe.fromJust . Data.ByteString.Char8.readInteger
getInteger   = readInteger' <$> Data.ByteString.Char8.getLine

task_A :: Integer -> Integer
task_A radius = (3 :: Integer) * radius * radius

-- the main process is as follows --

main :: IO ()
main = do

        -- STEP.01
        -- read out the given data
        radius <- getInteger

        -- STEP.02
        -- calculate & output the answer of this task
        Prelude.print $ task_A $ radius

-- EOF --

Measured memory_bytes: 380
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
    int arr[200005];
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    n-=k;
    long long sum=0;
    for(int i=0;i<n;i++)
    {
        sum+=arr[i];
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 1024
K = int(input())

def main(K):
  cnt = 1
  amari = 0
  while True:
    amari *= 10
    amari += 7
    amari %= K
    if amari == 0:
      return cnt
    else:
      cnt += 1
  

if K % 2 == 0 or K % 5 == 0:
  print(-1)
else:
  print(main(K))

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#include<vector>
using namespace std;
 
int main() {
    int a,b;
    cin>>a>>b;
    int c[a][b];
    for(int i=0;i<a;i++){
        for(int o=0;o<b;o++){
            cin>>c[i][o];
        }
    }
    int d[b];
    for(int i=0;i<b;i++){
        cin>>d[i];
    }
    int e;
        for(int i=0;i<a;i++){
            e=0;
        for(int o=0;o<b;o++){
            e+=c[i][o]*d[o];
        }
        cout<<e<<endl;
    }
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 50;
ll a[maxn];
int main()
{
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i = 0;i < n;i++) cin >> a[i];
    sort(a, a + n);
    reverse(a, a + n);
    ll ans = 0;
    for(int i = 1;i < n;i++){
        ans += a[i / 2];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5160
import math

n = int(input())
a = sorted(list(map(int, input().split())))
aMax, aNum, aMaxSum = 0, 0, 0

for i in range(n):
    aNum, aCnt = a[i], 0
    while aNum % 2 == 0 and aNum / 2 == aNum // 2:
        aCnt += 1
        aNum /= 2
    aMaxSum += aCnt

print(aMaxSum)


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

int main(){
	int N,ans=1;
	string S;
	cin >> N >> S;
	for (int i=1;i<N;i++){
		if(S.at(i-1)!=S.at(i)) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int max = 0;
    int ans = 0;

    for (int i = 0; i < n; i++) {
      int p = sc.nextInt();
      max = Math.max(p, max);
      ans += p;
    }

    System.out.println(ans - (max / 2));

  }
}

Measured memory_bytes: 35760
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        string s;
        cin >> s;
        if (s.size() % 2) {
            cout << "No" << endl;
            return;
        }

        for (int i = 0; i < s.size(); ++i) {
            if (!((i % 2 == 0 && s[i] == 'h') || (i % 2 == 1 && s[i] == 'i'))) {
                cout << "No" << endl;
                return;
            }
        }
        cout << "Yes" << endl;
    }

};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<(int)N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=0;i--)
#define p(s) cout<<(s)<<endl
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf=1e9+7;

int n;
string s;

int main() {

	cin>>n;
	if(n/10==9||n%10==9) p("Yes");
	else	p("No");

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include<complex>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> pr;
typedef complex<double> com;


int main(){
	string s;
	cin >> s;
	int a[26];
	rep(i, 26) {
		a[i] = 0;
	}
	rep(i, s.size()) {
		a[s[i] - 'a']++;
	}
	rep(i, 26) {
		if (a[i] % 2 == 1) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}
//Ctrl+Aを使わない

Measured memory_bytes: 256
N,A = map(int,input().split())
X = [0]+list(map(int,input().split()))

# dp[n][k][s] : n枚目までからk枚選んで合計をsにする場合の数
dp = [[[0 for _ in range(2501)] for _ in range(N+1)] for _ in range(N+1)]
dp[0][0][0] = 1

for n in range(1,N+1):
    for k in range(n+1):
        for s in range(50*k+1):
            if s<X[n]:
                dp[n][k][s] = dp[n-1][k][s]
            elif k>=1 and s>=X[n]:
                dp[n][k][s] = dp[n-1][k][s] + dp[n-1][k-1][s-X[n]]

Ans = 0
for i in range(1,N+1):
    Ans += dp[N][i][i*A]

print(Ans)

Measured memory_bytes: 65520
#pragma GCC optimize "O3"
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define REP_FROM(i,m,n) for (int i = (m); (i) < int(n); ++(i))
#define REP_REV(i,n) for (int i = (n)-1; (i) >= 0; --(i))
#define REP_FROMREV(i,m,n) for (int i = (n)-1; (i) >= int(m); --(i))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#ifndef LOCAL
#define cerr if (false) cerr
#endif
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

template <class T> inline void setmax(T & a, T const & b) { a = max(a, b); }
template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }
template <class T> T sq(T x) { return x * x; }
template <class T> T clamp(T a, T l, T r) { return min(max(a, l), r); } // [l, r]
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main(int argc, char *argv[]) {
	// Something to do
	int n;
	cin >> n;

	LL max = -INFINITY;
	LL input_min = INFINITY;

	int ary[n];
	REP(i, n) {
		cin >> ary[i];
		if(ary[i] - input_min > max)
			max = ary[i] - input_min;
		if(ary[i] < input_min)
			input_min = ary[i];
	}

	cout << max << endl;
	return 0;
}

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

using namespace std;

int minnum(string s)
{
	int n;
	stringstream ss;

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

	ss << s;
	ss >> n;

	return (n);
}

int maxnum(string s)
{
	int n;
	stringstream ss;

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

	ss << s;
	ss >> n;

	return (n);
}

int main()
{
	int n, l;
	string str;

	while (scanf("%d %d", &n, &l), l){
		vector<int> v;

		v.push_back(n);

		for (int i = 0; i < 20; i++){
			stringstream ss;
			ss << setfill('0') << setw(l) << n;

			n = maxnum(ss.str()) - minnum(ss.str());
			v.push_back(n);
		}

		int pos, res, diff;
		bool flag = true;

		for (int i = 0; i < 21; i++){
			for (int j = i + 1; j < 21; j++){
				if (flag && v[i] == v[j]){
					pos = i;
					res = v[i];
					diff = j - i;

					flag = false;
				}
			}
		}

		printf("%d %d %d\n", pos, res, diff);
	}

	return (0);
}

Measured memory_bytes: 1320
A, B = map(int, input().split())

def f(n):
    ans = ((n >> 1) ^ (n & 1)) & 1
    key = 2
    while key <= n:
        ans |= (key & n != 0) * (key ^ (key * (n & 1)))
        key <<= 1
    return ans
print(f(A-1)^f(B))


Measured memory_bytes: 2940
/*
        FFFFFFFFFFFFFFFFFFFFFF
        F::::::::::::::::::::F
        F::::::::::::::::::::F
        FF::::::FFFFFFFFF::::F
          F:::::F       FFFFFF
          F:::::F
          F::::::FFFFFFFFFF
          F:::::::::::::::F
          F:::::::::::::::F
          F::::::FFFFFFFFFF
          F:::::F
          F:::::F
        FF:::::::FF
        F::::::::FF
        F::::::::FF
        FFFFFFFFFFF
*/
#include <bits/stdc++.h>
using namespace std;
#define debug(...) cout<<__FUNCTION__<<":"<<__LINE__<<": ";debugger(#__VA_ARGS__, __VA_ARGS__);
template<typename arg>
void debugger(const char* varname, arg&& var) { cout<<varname<<" = "<<var<<endl; }
template<typename arg, typename... args>
void debugger(const char* varnames, arg&& var, args&&... vars) {
    const char* comma = strchr(varnames + 1, ',');
    cout.write(varnames, comma - varnames)<<" = "<<var<<" | ";
    int sz = 1; if(isspace(comma[sz])) sz++;
    debugger(comma + sz, vars...);
}
#define forr(i, s, n) for(ll i=(ll)(s); i<(ll)(n); ++i)
#define forn(i, n) forr(i, 0, n)
#define eb(n) emplace_back(n)
#define endl '\n'
#define fst first
#define snd second
using ll = long long;
using ii = pair<ll,ll>;
using vi = vector<ll>;
extern const int INF = INT_MAX - 5;
extern const ll LINF = LLONG_MAX - 5;
extern const int MOD = 1e9 + 7;
extern const int N = 2e5 + 200;

int main() {
    int n,m;
    cin>>n>>m;
    if(n >= m) {
        forn(i, n) {
            cout<<m;
        } cout<<endl;
    } else {
        forn(i, m) {
            cout<<n;
        } cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N;
double dp[301][301][301];
double make_dp(int i, int j, int k){
  if (dp[i][j][k] >= 0){
    return dp[i][j][k];
  }
  if (i == 0 && j == 0 && k == 0){
    return 0.0;
  }
  double y = 0.0;
  if (i > 0){
    y += make_dp(i-1, j, k) * i;
  }
  if (j > 0){
    y += make_dp(i+1, j-1, k) * j;
  }
  if (k > 0){
    y += make_dp(i, j+1, k-1) * k;
  }
  y += N;
  y *= 1.0 / (i + j + k);
  dp[i][j][k] = y;
  return dp[i][j][k];
}
int main(){
  cin >> N;
  int SUSY[3] = {0, 0, 0};
  int tmp;
  for (int i=0;i<N;i++){
    cin >> tmp;
    SUSY[tmp-1] += 1;
  }
  for (int i=0;i<=N;i++){
    for (int j=0;j<=N;j++){
      for (int k=0;k<=N;k++){
        dp[i][j][k] = -1.0;
      }
    }
  }
  printf("%.012f", make_dp(SUSY[0], SUSY[1], SUSY[2]));
  return 0;
}

Measured memory_bytes: 213376
#include <string.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <math.h>
#include <set>
#include <vector>
#include <algorithm>
#include <map>


using namespace std;

typedef long long ll;
#define PI 3.1415927
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

int main(){
    ios::sync_with_stdio(false);
    int N, K;
    while(scanf("%d%d", &N, &K) != EOF){
        if(N%K)
            cout << 1 << endl;
        else
            cout << 0 << endl;
    }

    return 0;
}

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

int main() {
    int N;
    int i;
    cin >> N;
    if( N % 2 == 0) {
    cout << N << "\n";
    exit(0);
    }
    for (i = N*2 ; i < 2147483647; i=i+N){
        if( i % 2 == 0 && i % N == 0)
        break;
    }
    cout << i << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#define int long long
using namespace std;

signed main() {
	int N;
	cin >> N;
	vector<string> vec(N);
	for(int i = 0;i < N;i++) {
		cin >> vec.at(i);
	}
	string answer;
	for(int i = 'a';i < 'z' + 1;i++) {
		int A = 1000;
		for(int j = 0;j < N;j++) {
			int B = 0;
			for(int k = 0;k < vec[j].size();k++) {
				if(vec[j].at(k) == i) {
					B++;
				}
			}
			A = min(A,B);
		}
		if(A != 0) {
			for(int j = 0;j < A;j++) {
				answer.push_back(i);
			}
		}
	}
	cout << answer << endl;
}

Measured memory_bytes: 256
A = int(input().strip())
B = int(input().strip())
C = int(input().strip())
X = int(input().strip())

k = 0
for a in range(A + 1):
  for b in range(B + 1):
    for c in range(C + 1):
      if 500 * a + 100 * b + 50 * c == X:
        k += 1

print(k)


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

string s;
int len;

int main() {
    cin >> s; len = s.size();
    if (s[0] == s[len - 1]) {
        if (len % 2) printf("Second\n");
        else printf("First\n");
    }
    else {
        if (len % 2) printf("First\n");
        else printf("Second\n");
    }
    return 0;
}

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

int main() {
    int n,x,t,x1,t1;
    cin>>n>>x>>t;
    x1=x;
    t1=t;
    if(n<=x)
    {
        cout<<t;
    }
    else
    {
        while(n>x)
        {
            t=t+t1;
            x=x+x1;
        }
        cout<<t;
    }
    return 0;
}

Measured memory_bytes: 3616
from sys import stdin,setrecursionlimit
setrecursionlimit(10 ** 7)

h,w = map(int,stdin.readline().rstrip().split())
s = [stdin.readline().rstrip() for _ in range(h)]

li = [[0 for i in range(w)]for j in range(h)]

x = [-1,0,1]
y = [-1,0,1]

for i in range(h):
    for j in range(w):
        count = 0
        for xx in x:
            for yy in y:
                if xx == 0 and yy == 0:
                    continue
                if j+xx < 0 or j+xx > w-1:
                    continue
                if i+yy < 0 or i+yy > h-1:
                    continue
                if s[i+yy][j+xx] == "#":
                    count += 1
        if s[i][j] == "#":
            li[i][j] = "#"
        else:li[i][j] = str(count)

for i in li:
    print("".join(i))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
struct Q{
	int a,b,c,d;
}q[55];
int n,m,Q,ans,a[15];
void update(){
	int w=0;
	for(int i=0;i<Q;i++)
		if(a[q[i].b]-a[q[i].a]==q[i].c)w+=q[i].d;
	ans=max(ans,w);
}
void work(int l,int d){
	if(d==n+1){update();return;}
	for(int i=l;i<=m;i++)a[d]=i,work(i,d+1);
}
int main(){
	scanf("%d%d%d",&n,&m,&Q);
	for(int i=0;i<Q;i++)scanf("%d%d%d%d",&q[i].a,&q[i].b,&q[i].c,&q[i].d);
	work(1,1);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 3784
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int n, k, p;

    n = sc.nextInt();
    for(;n > 0;n--){
      k = sc.nextInt(); p = sc.nextInt();
      k %= p;
      if(k == 0)k = p;
      out.println(k);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 20392
#define ll long long int
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#include <bits/stdc++.h>
using namespace std;

void solve(){
    ll n, d;
    cin >> n >> d;
    ll ans = 0;
    for(ll i=0; i<n; i++){
        ll x, y;
        cin >> x >> y;
        if(sqrt(x*x + y*y) <= d){ans++;}
    }
    cout << ans << "\n";
}

int main()
{
    fast;
        solve();
    return 0;
}


Measured memory_bytes: 3696
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var pl = new List<int[]>();
        for (var i = 0; n > i; i++)
        {
            pl.Add(Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray());
        }

        Func<int, int, double>dist = (i, j) =>
        {
            double dx = pl[i][0] - pl[j][0];
            double dy = pl[i][1] - pl[j][1];
            return Math.Sqrt(dx * dx + dy * dy);
        };

        var sum = 0.0;
        for (var i = 0; n > i; i++)
        {
            for (var j = i + 1; n > j; j++)
            {
                sum += dist(i, j);
            }
        }
        Console.WriteLine(sum * 2 / n);

    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define ld long double
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

//struct node{int t,x,y;};

int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}

ll combination(ll n, ll r) {
  if ( r * 2 > n ) r = n - r;
  ll dividend = 1;
  ll divisor  = 1;
  for ( ll i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

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

    vector<set<string>> p(5);
    int n; cin >> n;
    rep(i,n){
        string s; cin >> s;
        if(s[0]=='M') p[0].insert(s);
        if(s[0]=='A') p[1].insert(s);
        if(s[0]=='R') p[2].insert(s);
        if(s[0]=='C') p[3].insert(s);
        if(s[0]=='H') p[4].insert(s);
    }
    vint a(5);
    rep(i,5){
        a[i]=SZ(p[i]);
    }
    //rep(i,5) cout<<a[i]; cout<<endl;

    int res=0;
    for(int bit=0; bit<(1<<5); bit++){
        if(__builtin_popcount(bit)!=3) continue;
        //cout<<binary(bit)<<endl;
        int tmp=1;
        rep(i,5){
            if(bit&(1<<i)) tmp*=a[i];
        }
        res+=tmp;
    }
    cout<<res<<endl;
    
    






    // int n; cin >> n;
    // vector<node> a(n+1);
    // a[0].t=a[0].x=a[0].y=0;
    // rep(i,n) cin >> a[i+1].t >> a[i+1].x >> a[i+1].y;
    // FOR(i,0,n){
    //     int t=a[i+1].t-a[i].t;
    //     int d=abs(a[i+1].x-a[i].x)+abs(a[i+1].y-a[i].y);
    //     if(t<d || (t%2!=d%2)){
    //         coutn;
    //         return 0;
    //     }
    // }
    // couty;


}

Measured memory_bytes: 9600
from collections import Counter

mod = 998244353

def solve():
    N = int(input())
    Ds = list(map(int, input().split()))
    if Ds[0] != 0:
        print(0)
        return
    
    counter = Counter(Ds)
    ret = 1

    if counter[0] > 1:
        print(0)
        return
    max_key = max(counter.keys())
    for i in range(1, max_key+1):
        if i not in counter:
            # print(i,counter)
            print(0)
            return
        
        ret = (ret*(counter[i-1]**counter[i]))%mod
        # print(ret)
        
    print(ret)
    
solve()

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

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

int main()
{
	int n, k;
	bool ans = 0, ma = 0;
	cin >> n >> k;
	int A[100001];
	for (int i = 0; i < n; ++i)
	{
		cin >> A[i];
		if(A[i] == k)
		{
			ans = 1;
		}
		if(A[i] > k)
		{
			ma = 1;
		}
	}
	sort(A, A+n);
	bool ok = 0;
	int g = gcd(A[1],A[0]);
	for (int i = 1; i < n - 1; ++i)
	{
		g = gcd(g, A[i]);

	}
	ok = (k % g == 0);
	if(ma && ok)
	{
		ans = 1;
	}
	cout << (ans?"POSSIBLE":"IMPOSSIBLE") << endl;

	return 0;
}

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

using namespace std;

int main(int argc, char *argv[])
{
    // input from txt （提出時にこの箇所は削除すること）
    //std::ifstream in("in.txt");
    //std::cin.rdbuf(in.rdbuf());
    
    
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);

    int n;
    cin >> n;
    n = pow(n,3);
    cout << n << endl;
    return 0;
}



Measured memory_bytes: 3296
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

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

const int oo = 1e9 + 7;
const int mod = 1e9 + 7, maxn = 20;
const double PI = acos(-1);

vector<pii> v[20];
bitset<17> b;

bool check(int n){
    for (int i=0; i<n; i++){
        for (auto it: v[i]){
            if(b[i] == 1 and b[it.ff] != it.ss) return false;
            // if(b[i] == 0 and b[it.ff] == it.ss) return false;
        }
    }
    return true;
}


int main (){
    int n, a, x, y;
    cin >> n;

    for (int i=0; i<n; i++){
        cin >> a;
        for (int j=0; j<a; j++){
            cin >> x >> y;
            --x;
            v[i].push_back({x, y});
        }
    }

    int ans = 0;
    for (int i=0; i<(1 << n); i++){
        b = bitset<17>(i);
        if (check(n)) {
            ans = max((int)b.count(), ans);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
using namespace std;

int main(){
	string s1,s2,s3;
	cin >> s1 >> s2 >> s3;
	cout << char(s1[0]-32) << char(s2[0]-32) << char(s3[0]-32) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
using namespace std;
struct Point{int x,y,d,m;};
int main(){
  int r,c;
  cin >> r >> c;
  string st[25];
  int i,j,k;
  for(i=0;i<r;i++) cin >> st[i];
  Point p,b;
  int ax[]={1,0,-1,0};
  int ay[]={0,1,0,-1};
  p.x=0;p.y=0;p.d=0;p.m=0;
  queue <Point> q;
  q.push(p);
  bool f=true;
  int vi[25][25][5][20]={{{{}}}};
 
  while(!q.empty()){
    p=q.front();q.pop();
    if(vi[p.x][p.y][p.d][p.m]==1) continue;
    vi[p.x][p.y][p.d][p.m]=1;
    char x=st[p.y][p.x];
    if(x=='<'){
      p.d=2;
    }else if(x=='>'){
      p.d=0;
    }else if(x=='^'){
      p.d=3;
    }else if(x=='v'){
      p.d=1;
    }else if(x=='_'){
      if(p.m==0) p.d=0;
      else p.d=2;
    }else if(x=='|'){
      if(p.m==0) p.d=1;
      else p.d=3;
    }else if(x=='?'){
      for(i=0;i<4;i++){
        b.d=i;
        b.x=(p.x+c+ax[b.d])%c;
        b.y=(p.y+r+ay[b.d])%r;
        b.m=p.m;
        q.push(b);
      }
      continue;
    }else if(x=='.'){
    }else if(x=='@'){
      f=false;
      break;
    }else if(x>='0'&&x<='9'){
      p.m=x-'0';
    }else if(x=='+'){
      p.m=(p.m+1)%16;
    }else if(x=='-'){
      p.m=(p.m+15)%16;
    }
    b.d=p.d;
    b.x=(p.x+c+ax[b.d])%c;
    b.y=(p.y+r+ay[b.d])%r;
    b.m=p.m;
    q.push(b);
  }
  if(f) cout << "NO" << endl;
  else cout << "YES" << endl;
  return 0;
}

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

using namespace std;

#define MAX 1010
#define MAX_M 101

int dp[MAX_M][MAX];

int main()
{
    int LIMIT, N, M, X;
    string name;
    while (cin >> LIMIT >> N >> M >> X, LIMIT) {
        vector<int> c(N), s(N);
        for (int i = 0; i < N; i++) {
            cin >> name >> c[i] >> s[i];
        }
        int max_s[MAX];
        fill(max_s, max_s + MAX, -1);
        for (int i = 0; i < N; i++) {
            max_s[c[i]] = max(max_s[c[i]], s[i]);
            for (int j = i + 1; j < N; j++) {
                max_s[c[i] + c[j]] = max(max_s[c[i] + c[j]], s[i] + s[j]);
            }
        }
        for (int i = 0; i < LIMIT; i++) {
            max_s[i+1] = max(max_s[i+1], max_s[i]);
        }
        vector<int> sc(M), ss(M);
        for (int i = 0; i < M; i++) {
            cin >> name >> sc[i] >> ss[i];
        }
        for (int i = 0; i <= M; i++) {
            for (int j = 0; j <= LIMIT; j++) {
                dp[i][j] = -1;
            }
        }
        dp[0][0] = 0;
        for (int i = 0; i < M; i++) {
            for (int j = M-1; j >= 0; j--) {
                for (int k = LIMIT-sc[i]; k >= 0; k--) {
                    if (dp[j][k] == -1) continue;
                    int nk = k + sc[i];
                    if (nk <= LIMIT) {
                        dp[j+1][nk] = max(dp[j+1][nk], dp[j][k] + ss[i]);
                    }
                }
            }
        }
        
        int res = 0;
        for (int i = 0; i <= LIMIT; i++) {
            if (max_s[i] == -1) continue;
            for (int j = X; j <= M; j++) {
                if (dp[j][LIMIT-i] == -1) continue;
                res = max(res, max_s[i] + dp[j][LIMIT-i]);                   
            }
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3540
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  string S;
  cin>>S;
  int N=S.size();
  ll mod=1e9+7;
  ll dp[100100][4]={};
  dp[0][0]=1;
  rep(i,N){
    rep(j,4) (dp[i+1][j]+=dp[i][j])%=mod;
    if(S[i]=='A' or S[i]=='?') (dp[i+1][1]+=dp[i][0])%=mod;
    if(S[i]=='B' or S[i]=='?') (dp[i+1][2]+=dp[i][1])%=mod;
    if(S[i]=='C' or S[i]=='?') (dp[i+1][3]+=dp[i][2])%=mod;
    if(S[i]=='?') rep(j,4) (dp[i+1][j]+=dp[i][j]*2)%=mod;
  }
  cout<<dp[N][3]<<endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
/* * * *   * * *   	* * * */
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define ms(a,v) memset(a,v,sizeof a)
/* * * *   * * *   	* * * */
/* *
 *
 * Author: Hamkor
 *
 * */
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int m; cin>>m;
	cout<<24 + (24-m);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define INF 1000000000
#define M 1000000007ll
#define UQ(x) (x).resize(distance((x).begin(),unique(all((x)))))
int n;
ll t,e,x[100005],mem[100005],ml[100005];
multiset<ll> s;
int main() {
	scanf("%d%lld%lld",&n,&e,&t);
	for (int i=0;i<n;i++) scanf("%lld",&x[i]);
	mem[0]=(x[0]+t);
	ml[0]=mem[0]-x[0]-x[1]-x[1];
	int cur=1;
	for (int i=1;i<n;i++) {
		mem[i]=max(t,x[i]-x[0]+x[i]-x[0])+x[i];
		mem[i]=min(mem[i],mem[i-1]+x[i]-x[i-1]+t);
		if (i>1) {
			while(x[i]-x[cur+1]+x[i]-x[cur+1]>t) {
				s.erase(s.find(mem[cur]-x[cur]));
				cur++;
			}
			//printf("i = %d, cur = %d\n", i,cur);
			//for (ll x:s) printf("%lld ", x);
			//printf("\n");
			//printf("%d: %lld\n", i,mem[i]);
			if (cur>1 || x[i]-x[1]+x[i]-x[1]>t) mem[i]=min(mem[i],ml[min(cur,i-1)-1]+3ll*x[i]);
			else mem[i]=min(mem[i],mem[0]+t+x[i]-x[0]);
			//printf("%d: %lld\n", i,mem[i]);
			if (!s.empty()) mem[i]=min(mem[i],(*s.begin())+t+x[i]);
			//printf("%d: %lld\n", i,mem[i]);
		}
		ml[i]=min(ml[i-1],mem[i]-x[i]-x[i+1]-x[i+1]);
		s.insert(mem[i]-x[i]);
		//printf("%d: %lld\n", i,mem[i]);
	}
	printf("%lld\n", mem[n-1]+e-x[n-1]);
}

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

typedef long long ll;
typedef long double ld;

int MOD;

vector <int> graf[100005];
vector <int> pref[100005];
vector <int> suf[100005];
int dole[100005];
int dp[100005];
int dpn[100005];

int add(int a, int b){
    return (a+b)%MOD;
}

int mul(int a, int b){
    return ((ll)a*b)%MOD;
}

void dfs1(int v, int parent){
    dp[v] = 1;
    for(auto c : graf[v]){
        if(c == parent) continue;
        dfs1(c, v);
    }
    int k = graf[v].size();
    for(int i=0; i<k; i++){
        if(graf[v][i] == parent){
            graf[v].erase(graf[v].begin()+i);
            break;
        }
    }
    k = graf[v].size();
    for(int i=0; i<k; i++){
        pref[v].push_back(1+dole[graf[v][i]]);
        if(i) pref[v][i] = mul(pref[v][i], pref[v][i-1]);
    }
    for(int i=k-1; i>=0; i--){
        suf[v].push_back(1+dole[graf[v][i]]);
        if(i < k-1) suf[v][k-1-i] = mul(suf[v][k-1-i], suf[v][k-2-i]);
    }
    reverse(suf[v].begin(), suf[v].end());
    /*cout << v << " za \n";
    for(auto c : pref[v]) cout << c << " ";
    cout << "\n";
    for(auto c : suf[v]) cout << c << " ";
    cout << "\n";*/
    if(k) dole[v] = pref[v][k-1];
    else dole[v] = 1;
}

void dfs2(int v, int parent){
    dp[v] = add(1, dpn[parent]);
    dp[v] = mul(dp[v], dole[v]);
    dpn[v] = dp[v];
    int k = graf[v].size();
    for(int i=0; i<k; i++){
        dpn[v] = add(1, dpn[parent]);
        if(i) dpn[v] = mul(dpn[v], pref[v][i-1]);
        if(i < k-1) dpn[v] = mul(dpn[v], suf[v][i+1]);
        dfs2(graf[v][i], v);
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n;
    cin >> n >> MOD;
    for(int i=1; i<n; i++){
        int a, b;
        cin >> a >> b;
        graf[a].push_back(b);
        graf[b].push_back(a);
    }
    dfs1(1, 0);
    dfs2(1, 0);
    for(int i=1; i<=n; i++){
        cout << dp[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 25856
N, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(1, N):
    dim = (a[i] + a[i-1]) - x
    if dim > 0:
        dif = dim if a[i]-dim > 0 else a[i]
        a[i] -= dif
        ans += dif
ans += max(a[0]-x, 0)
print(ans)

Measured memory_bytes: 14540
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, d;
    cin >> n >> d;
    vector<int> t(n), f(n);
    rep(i, 0, n){
        cin >> t[i] >> f[i]; f[i]--;
    }
    bool g = true;
    int flr = 0, time = 0, ride = 0;
    int ans = 0;
    rep(i, 0, n){
        //?????????
        if(ride == d || t[i] - time >= flr + f[i]){
            ans += flr * ride;
            ride = 0;
            time += flr;
            flr = 0;
        }
        //?????????
        if(t[i] - time < f[i] - flr) g = false;
        ans += (t[i] - time) * ride;
        ride++;
        time = t[i];
        flr = f[i];
        // cout << ans << ' ' << ride << ' ' << time << ' ' << flr << endl;
    }
    ans += flr * ride;
    if(g) cout << ans << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 4384
#include <bits/stdc++.h>
using namespace std;
#define spc " "
#define ll long long
#define ft first
#define sd second
#define pi pair<int,int>
const int N=1100;

int a[N][N];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    queue<pair<pi,int>> f;
    int n,m;
    char ch;
    cin>>n>>m;

    for (int i = 1; i <= n; ++i)
    {
        a[i][0]=1;
        a[i][m+1]=1;
    }

    for (int i = 1; i <= m; ++i)
    {
        a[0][i]=1;
        a[n+1][i]=1;
    }

    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= m; ++j)
        {
            cin>>ch;
            if(ch=='#'){
                a[i][j]=1;
                f.push({{i,j},0});
            }else
                a[i][j]=0;
        }        
    }   
    pi at; 
    int x,mx=0;
    while(!f.empty()){
        at=f.front().ft;
        x=f.front().sd;
        f.pop();
        mx=max(mx,x);
        if(!a[at.ft+1][at.sd]){
            a[at.ft+1][at.sd]=1;
            f.push({{at.ft+1,at.sd},x+1});
        }

        if(!a[at.ft-1][at.sd]){
            a[at.ft-1][at.sd]=1;
            f.push({{at.ft-1,at.sd},x+1});
        }

        if(!a[at.ft][at.sd+1]){
            a[at.ft][at.sd+1]=1;
            f.push({{at.ft,at.sd+1},x+1});
        }

        if(!a[at.ft][at.sd-1]){
            a[at.ft][at.sd-1]=1;
            f.push({{at.ft,at.sd-1},x+1});
        }
    }
    cout<<mx<<"\n";
    return 0;
}

Measured memory_bytes: 16656
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

ate = -3
ans = 0
for i in range(n):
  eat = A[i]-1
  ans  += B[eat]
  if eat == ate +1:
    ans += C[ate]
  ate = eat
print(ans)
  

Measured memory_bytes: 3064
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do(): 
    a,b=INTM()
    print(a*b)
if __name__ == '__main__':
    do()

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

int main(){
    string N;
    cin >> N;
    if ((N.at(0) == N.at(1) && N.at(1) == N.at(2)) || (N.at(1) == N.at(2) && N.at(2) == N.at(3))) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define FOR(i,n) for(int i = 0; i < (n); i++) 
#define sz(c) ((int)c.size())


int main() {
	int n; cin >> n;
	while (n--) {
		int s, d; cin >> s >> d;
		int ans = 0;
		while (s != d) {
			int add = 1;
			while (true) {
				if (s + add * 2 > d) break;
				int x = abs(s);
				if ((x&add)) break;
				add *= 2;
			}
			s += add;
			ans++;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1160
def get_coin_comb(A, B, C, X):
    count = 0
    for i in range(A+1):
        for j in range(B+1):
            for k in range(C+1):
                sumv = 500*i + 100*j + 50*k
                if sumv == X:
                    count += 1
    return count


if __name__ == '__main__':
    a = int(input())
    b = int(input())
    c = int(input())
    x = int(input())

    print(get_coin_comb(a, b, c, x))

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
const int M = 10010;
char str[M];
int ans;
int main()
{
    ans = 0;
    scanf("%s",str);
    for (int i = 0; i < strlen(str); i++)
        if(str[i] == '1')
            ans++;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    
    double A;
    double ans;
    int i,j;
    int flag = 0;
    
    scanf("%lf",&A);
    
    for(i=1;i<=9;i++){
        ans = A/i;
        for(j=1;j<=9;j++){
            if(ans==j){
                flag = 1;
                break;
            }
        }
    }
    
    if(flag == 1){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 128
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import defaultdict

n = ni()
a = list(li())

dic = defaultdict(int)

for ai in a:
    dic[ai] += 1

if len(dic) > 3:
    print("No")

elif len(dic) == 3:
    keys = []
    vals = []
    for k, v in dic.items():
        keys.append(k)
        vals.append(v)

    if vals[0] == vals[1] == vals[2] and keys[0] ^ keys[1] ^ keys[2] == 0:
        print("Yes")

    else:
        print("No")

elif len(dic) == 2:
    if not 0 in dic.keys():
        print("No")

    else:
        zero = dic[0]
        anot = 0
        for k, v in dic.items():
            if k != 0:
                anot = v

        if zero * 2 != anot:
            print("No")

        else:
            print("Yes")

elif len(dic) == 1:
    if not 0 in dic.keys():
        print("No")

    else:
        print("Yes")



Measured memory_bytes: 14468
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    public static void Main(string[] args) {
        int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        List<int> result = new List<int>();
        for (int i = 1; i <= 100; i ++) {
            if (s[0] % i == 0 && s[1] % i == 0) result.Add(i);
        }
        result.Reverse();
        Console.WriteLine(result[s[2]-1]);
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int mypow(int a,int b,int c){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
int x[60];
signed main(){
	int n,a,ans=0;
	cin>>n;
	f(i,n){
		cin>>a;
		int cnt=0;
		while(a){
			x[cnt]+=a%2;
			a/=2;
			cnt++;
		}
	}
	f(i,60){
		ans+=(n-x[i])*x[i]%mod*(int)mypow(2,i,mod);
		ans%=mod;
	}
	cout<<ans<<endl;
}


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

using namespace std;

typedef long long ll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

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

int main(){
    int H,W;
    cin>>H>>W;
    vector<string> S(H);
    rep(i,H)cin>>S[i];
    vector<bool> h(H,false),w(W,false);
    rep(i,H){
        rep(j,W){
            if(S[i][j]=='#'){
                h[i]=true;
                w[j]=true;
            }
        }
    }
    cout<<endl;
    
    rep(i,H){
        if(h[i]){
            rep(j,W){
                if(w[j]){
                    cout<<S[i][j];
                }
            }
            cout<<endl;
        }
    }
    return 0;
}

//a=97,z=122

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

using namespace std;

int main()
{
    while (true)
    {
        string input;

        cin >> input;
        if (input.compare("0") == 0) break;

        int sum = 0;
        for (int i = 0; i < input.length(); i++)
        {
            sum += input[i] - '0';
        }
        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
bool DP[30001][4][1000];

int main() {
  int N; cin >> N; 
  string S; cin >> S;
  DP[0][0][0] = true;
  rep(i,N) rep(j,4) rep(k,1000) {
    if (DP[i][j][k] == false) continue;
    DP[i+1][j][k] = true;
    if (j < 3) {
      DP[i+1][j+1][k*10+(S[i]-'0')] = true;
    }
  }
  int cnt = 0;
  rep(i,1000) {
    if (DP[N][3][i]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 117504
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m, l;
    cin >> n >> m >> l;
    vector<vector<long int> > a(n, vector<long int>(m)), b(m, vector<long int>(l)), c(n, vector<long int>(l));
    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < m ; j++)
            cin >> a[i][j];
    for (int i = 0; i < m; i++)
        for (int j = 0; j < l; j++)
            cin >> b[i][j];
    
    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < l ; j++)
            for(int k = 0 ; k < m ; k++)
                c[i][j] += a[i][k] * b[k][j];

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            cout << c[i][j];
            if(j < l - 1)
                cout << " ";
        }
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 3288
/*|In The Name Of Allah|*/
//This Month Will Be Expert ISA
#include <bits/stdc++.h>

using namespace std;

int n;
int k;
string s;
int mem[111][2][4][2];

int go(int idx , int les , int lft , int smS){
    if(idx == n)
        return lft == 0;
    if(~mem[idx][les][lft][smS])
        return mem[idx][les][lft][smS];
    int cnt = 0;
    for(int i = ((idx == 0) ? 1 : 0); i <= 9; i++){
        if( les && lft - (i != 0) >= 0 && smS ){
            cnt += go(idx + 1 , 1 , lft - (i != 0) , smS);
        } else if( !les && i <= s[idx] - '0' && lft - (i != 0) >= 0 && smS ){
            bool nwles = (i < s[idx]-'0');
            cnt += go(idx + 1 , nwles , lft - (i != 0) , smS);
        } else if(!smS && lft - (i != 0) >= 0) {
            cnt += go(idx + 1 , 1 , lft - (i != 0) , smS);
        }
    }
    return mem[idx][les][lft][smS] = cnt;
}

int main(){
    cin >> s >> k;
    memset(mem , -1 , sizeof mem);
    int ans = 0;
    for(int i = 1; i <= s.size(); i++){
        memset(mem , -1 , sizeof mem);
        n = i;
        ans += go(0 , 0 , k , i == s.size());
    }
    cout << ans << endl;
}


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

using namespace std;

// 0-indexed
template <class T> class SegmentTree {
	int size;
	T def;
	vector<T> data;
	function<T(T, T)> f;

public:
	SegmentTree<T>(int _size, T _def, function<T(T, T)> _f) : f(_f), def(_def), size(1) {
		while (size < _size) size <<= 1;
		data = vector<T>(size * 2, def);
	}
	// bottom-up implementation
	// query for[l, r)
	T query(int l, int r) {
		T L = def, R = def;
		for (l += size, r += size; l < r; l >>= 1, r >>= 1) {
			if (l & 1) L = f(L, data[l++]);
			if (r & 1) R = f(data[--r], R);
		}
		return f(L, R);
	}
	void update(int idx, T val) {
		idx += size;
		data[idx] = val;
		while (idx > 1) {
			idx >>= 1;
			data[idx] = f(data[2 * idx], data[2 * idx + 1]);
		}
	}
	T operator[](int idx) { return data[idx + size]; }
};

class Solution {
public:
	void solve() {
		int n, q;
		cin >> n >> q;
		SegmentTree<long long> st(n, 0, [](long long l, long long r) { return l + r; });
		for (int i = 0; i < n; i++) {
			long long a;
			cin >> a;
			st.update(i, a);
		}
		while (q--) {
			int t;
			cin >> t;
			if (t == 0) {
				int i, x;
				cin >> i >> x;
				st.update(i, st[i] + x);
			} else {
				int l, r;
				cin >> l >> r;
				cout << st.query(l, r) << "\n";
			}
		}
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 12524
// G - Longest Path
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define rep(i,n) for(int i=0;i<(n);++i)
#define chmax(x,y) x=max(x,y)
int in(){int x;cin>>x;return x;}

int N; // number of vertices
int M; // number of edges
vvi dag; // [parent vertex][children vertex]
vi dp; // [vertex]: longest path from this vertex (memo of dfs)

int dfs(int p){
	if(0 <= dp[p]) return dp[p]; // already visited
	dp[p] = 0;
	for(int c:dag[p]) chmax(dp[p], dfs(c)+1);
	return dp[p];
}

int main(){
	cin>>N>>M;
	dag.resize(N);
	while(M--) dag[in()-1].push_back(in()-1);

	int ans = 0;
	dp.resize(N);
	rep(i, N) dp[i] = -1;
	rep(p, N) chmax(ans, dfs(p));
	cout<< ans <<endl;

	// // print ===================
	// cout<<"ans "<<ans<<"\n";//
	// rep(p,N){
	// 	cout<<"["<<dp[p]<<"] "<<p<<":";
	// 	for(int c:dag[p])cout<<" "<<c;
	// 	puts("");
	// }
	// // ===================

}


Measured memory_bytes: 10624
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Mid ((l+r)/2)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define drep(i,a,b) for(int i=(a);i>=(b);--i)
#define file(a) freopen(#a".in","r",stdin),freopen(#a".out","w",stdout);
const int maxn=1e5+5,mod=1e9+7,inf=0x3f3f3f3f;
int n,m,Q,K,T;
int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}char a[maxn],b[maxn];
signed main(){
    //file(a);
    scanf("%s%s",a,b);int ans=0;
    // cout<<strlen(a)<<" "<<strlen(b)<<endl;
    rep(i,0,strlen(a)-1){
        int sum=0;
        if(i+strlen(b)-1>strlen(a)-1)break;
        rep(j,0,strlen(b)-1){
            if(a[i+j]==b[j])++sum;
        }ans=max(ans,sum);
    }printf("%d\n",strlen(b)-ans);

    return 0;
}

Measured memory_bytes: 3808
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;

	int l, r;
	vector<pair<int, int>> tmpvec(M);
	vector<vector<int>> edges(N); // Nは番兵
	for (int i = 0; i < M; i++) {
		cin >> l >> r;
		tmpvec[i] = { r,l };
	}

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

	for (int i = 0; i < M; i++) {
		edges[tmpvec[i].second - 1].emplace_back(tmpvec[i].first - 1);
	}

	int ans = 0, tmp = INF;
	for (int i = 0; i < N; i++) {

		if (!edges[i].empty()) {
			//sort(edges[i].begin(), edges[i].end());
			tmp = min(tmp, edges[i].front());
		}

		if (tmp - 1 <= i) {
			tmp = INF;
			ans++;
		}

	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;
 
int main() {
  int n, x, ans=0, v=0;
  cin >> n >> x;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  sort(all(a));
  x -= accumulate(all(a), 0);
  x /= a.at(0);
  cout << n + x;
}


Measured memory_bytes: 256