akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BBreakNumber {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n;
	    in >> n;

	    int res = 1;
	    int now = 0;
	    for(int i=1; i<=n; i++){
	        int cnt = 0;
	        int buf = i;
	        while(buf % 2 == 0){
	            cnt++;
	            buf /= 2;
	        }
	        if(now < cnt){
	            res = i;
	            now = cnt;
	        }
	    }
	    out << res << endl;
	}
};


int main() {
	BBreakNumber solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e9;
template<typename T> void cmax(T &a, T b) {a = max(a, b);}
template<typename T> void cmin(T &a, T b) {a = min(a, b);}


signed main(){
  int a,b;cin>>a>>b;
  if(a<=8&&b<=8)cout<<"Yay!"<<endl;
  else cout<<":("<<endl;
  return 0;
}


Measured memory_bytes: 256
def main():

    capa = []
    n = int(raw_input())
    ans = 0

    for i in range(5):
        capa.append(int(raw_input()))
    sorted_capa = sorted(capa)
    if n % sorted_capa[0] == 0:
        ans = 4 + n//sorted_capa[0]
    else:
        ans = 4 + n//sorted_capa[0] + 1
    print(ans)
    """
    people = [n]
    for i in range(5):
        people.append(0)
    print(capa,people)
    while people[-1] < n:
        for i in reversed(range(0,6)):
            if i != 0:
                people[i] += min(people[i-1],capa[i-1])
                people[i-1] -= min(people[i-1],capa[i-1])
        time += 1
        print(people,time)
    print(time)

    """
if __name__ == "__main__":
    main()


Measured memory_bytes: 2568
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int A1 = 0, A2 = 0, A3 = 0;
    int tmp = 0;

    do{
        scanf("%d %d %d", &A1, &A2, &A3);
    }while( A1 < 1 && A1 > 100 && A2 < 1 && A2 > 100 && A3 < 1 && A3 > 100 );

    if( A1 >= A2 && A1 >= A3){
        tmp = A1;
    }
    else if( A2 >= A1 && A2 >= A3){
        tmp = A2;
    }
    else if( A3 >= A1 && A3 >= A2){
        tmp = A3;
    }

    if( A1 <= A2 && A1 <= A3){
        tmp -= A1;
    }
    else if( A2 <= A1 && A2 <= A3){
        tmp -= A2;
    }
    else if( A3 <= A1 && A3 <= A2){
        tmp -= A3;
    }

    printf("%d\n", tmp);
}

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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool prime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

ll addmod(ll a,ll b)
{
    return (a+b)%mod;
}
ll mulmod(ll a,ll b)
{
    a %=mod;
    b%=mod;
    return (a*b)%mod;
}
ll submod(ll a,ll b)
{
    ll x  = a-b;
    if(x<0)x+=mod;
    x%=mod;
    return x;
}
bool comp(pair<pi,ll>a,pair<pi,ll>b)
{
    if(a.fi.fi==b.fi.fi)return a.fi.se<b.fi.se;
    return a.fi.fi<b.fi.fi;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string s; cin>>s;
    reverse(all(s));
    ll n = s.size();
    vi arr(n);

    for(ll i=0;i<n;i++)
    {
        arr[i] = ((s[i]-'0')*modexp(10,i,2019))%2019;
    }
    vi pref(n);
    pref[0] = arr[0];
    rep(i,1,n)pref[i]= (pref[i-1]+arr[i])%2019;
    map<ll,ll>mp;
    ll ans = 0;
    for(ll i=0;i<n;i++)
    {
        if(pref[i]==0)ans++;
        ans+=mp[pref[i]];
        mp[pref[i]]++;
    }
    cout<<ans<<endl;
    return 0;
}
/*
5 10 10
22 23
17 19
13 17
8 12
2 6
*/


Measured memory_bytes: 6804
import numpy as np
N, K = map(int, input().split())
A = [int(c) for c in input().split()]
F = [int(c) for c in input().split()]
A.sort()
F.sort(reverse=True)
A = np.array(A)
F = np.array(F)
Asum = A.sum()
M = np.max(A*F)

l = -1
r = M+1
while l+1<r:
  s = (l+r)//2
  cnt = Asum - np.minimum(A, s//F).sum()
  if cnt>K:
    l = s
  else:
    r = s

print(r)

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

using namespace std;

long long fact(int x) {
		long long res = 1;
		for (int i = 1; i <= x; i++) {
				res *= i;
		}
		return res;
}

long long nPr(int n, int r) {
		if (r > n) {return 0;}
		r = r > (n-r) ? (n-r) : r;
		int _ = n - r;
		long long res = 1;
		while(n > _) {
				res *= n;
				n--;
		}
		return res;
}

long long nCr(int n, int r) {
		if (r > n) {return 0;}
		r = r > (n-r) ? (n-r) : r;
		return nPr(n, r) / fact(r);
}

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

		long long res = nCr(N, 2) + nCr(M, 2);
		cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define BUF 1e5
#define INF 1 << 30
constexpr ll mod = 1e9 + 7;
using namespace std;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;
int intceil(ll a, ll b) {
    return (a + (b - 1)) / b;
}

int main() {
    cin >> N;
    vector<int> a(N), ca(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    map<int, int> mp;
    vector<int> b(a);
    sort(b.rbegin(), b.rend());
    for (int i = 0; i < N; i++) {
        if (a[i] == b[0])
            cout << b[1] << endl;
        else
            cout << b[0] << endl;
    }
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
int main(void){
    int h, a;
    std::cin >> h >> a;
    int ans;
    ans = h/a;
    if(h % a == 0) std::cout << ans << std::endl;
    else std::cout << ans + 1 << std::endl;
}


Measured memory_bytes: 256
n = int(input())
list1 = list(map(int,input().split()))

ans_inv,i = 1,0

while True:
    if i == n:
        break
    if list1[i] == ans_inv:
        ans_inv += 1
    i += 1
if ans_inv == 1:
    print(-1)
else:
    print(n - (ans_inv-1))

Measured memory_bytes: 77516
def evl_score(m,f,r):
    if m == -1 or f == -1:
        ret = 'F'
    elif m + f >= 80:
        ret = 'A' 
    elif m + f >= 65 and m + f < 80:
        ret = 'B' 
    elif m + f >= 50 and m + f < 65: 
        ret = 'C' 
    elif m + f >= 30 and m + f < 50: 
        if r >= 50: 
            ret = 'C' 
        else:
            ret = 'D' 
    else: 
        ret = 'F'
    return ret 
while True:
    m,f,r =[int(i) for i in input().split(' ')] 
    if (m == -1 and f == -1 and r == -1):
        break 
    print(evl_score(m,f,r)) 


Measured memory_bytes: 5600
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

string solve(string str){
  //cout <<"! " <<str <<endl;
  int cnt = 0, l = str.length(), r = -1;
  char tar = ' ';
  stringstream ss;
  for(int i = (int)str.length() - 1; i >= 0; --i){
    if(str[i] == ']') {
      if(tar != ' ') ss << (tar == '?' ? 'A' : tar);
      tar = ' ';
      --cnt; r = max(r, i);
    }
    else if(str[i] == '[') { ++cnt; l = min(l, i); }
    if(cnt == 0 && r == -1){
      if(str[i] == '?' || isalpha(str[i])){
        if(tar != ' ') ss << (tar == '?' ? 'A' : tar);
        tar = str[i];
      }
      if(tar != '?' && str[i] == '+') { ++tar; if(tar > 'Z') tar = 'A'; }
      if(tar != '?' && str[i] == '-') { --tar; if(tar < 'A') tar = 'Z'; }
    }

    if(cnt == 0 && r != -1){
      if(tar != ' ') { ss << (tar == '?' ? 'A' : tar); tar = ' '; }
      string a = solve(str.substr(l + 1, r - l - 1));
      ss << a;
      l = str.length(); r = -1;
    }
  }
  if(tar != ' ') ss << (tar == '?' ? 'A' : tar);
  string res = ss.str();
  REVERSE(res);
  //cout <<"    res " <<res <<endl;
  return res;
}

int main() {
  string s;
  while(cin >>s && s != ".") cout <<solve(s) <<endl;
  return 0;
}

Measured memory_bytes: 1232
N=int(input())
rt=[int(input()) for x in range(N)]
min=rt[0]
# if rt[0]>rt[1]:min=rt[1]
max=rt[1]-rt[0]
for j in range(1,N):
    if max < rt[j] - min: max = rt[j] - min
    if min> rt[j]:min=rt[j]

print(max)


Measured memory_bytes: 13596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n,x) for(int i=(n);i<(x);++i)
#define rem(i,n,x) for(int i=(n);i>=(x);--i)
#define pb push_back
using ll = long long;

int main() {
	int n; cin >> n;
	vector<int> d(n); rep(i, 0, n) cin >> d[i];

	ll ans = 0;
	rep(i, 0, n-1) {
		rep(j, i+1, n) {
			ans += d[i] * d[j];
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
a = [0]
for i in range(n):
    if s[i] == "(":
        a.append(a[-1] + 1)
    else:
        a.append(a[-1] - 1)
left = -min(a)
right = a[-1] + left
print("(" * left + s + ")" * right)

Measured memory_bytes: 38256
#include<stdio.h>
#include<math.h>
inline double SQ(double x){return x*x;}
int main(void)
{
	const int N = 20;
	double x[N],y[N],S=0,a,b,c,s;
	int n = 0;
	while(scanf("%lf,%lf",&x[n],&y[n]) == 2)
		++n;
	int i = 0, j = 1, k = n-1;
	while(i<j && j<k)
	{
		a = sqrt( SQ(x[i]-x[j])+SQ(y[i]-y[j]) );
		b = sqrt( SQ(x[j]-x[k])+SQ(y[j]-y[k]) );
		c = sqrt( SQ(x[k]-x[i])+SQ(y[k]-y[i]) );
		s = (a+b+c)/2;
		S += sqrt( s*(s-a)*(s-b)*(s-c) );
		
		if(j-i==1)
		{
			i = j;
			j = k-1;
		}
		else
		{
			k = j;
			j = i+1;
		}
	}
	printf("%f\n",S);

	return 0;
}

Measured memory_bytes: 0
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<deque>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<tuple>
#include<map>
#include<memory>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<double> VD;
typedef pair<int, int> P1;
typedef long long int ll;

//number
#define INF 1e9
#define NUM 1000000007

//itr
#define all(x) begin(x),end(x)

//repeat
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

//max,min
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

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

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	retur5n a * (b / g);
}*/

int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}

//grid template
int x[] = { -1, 0, 1, 0 };
int y[] = { 0,-1,0,1 };
int xx[] = { -1,-1,1,1 };
int yy[] = { 1,-1,1,-1 };

int main() {
	int r, g, b, n;
	cin >> r >> g >> b >> n;

	int cnt = 0;
	for (int i = 0; i <= 3000; i++) {
		for (int j = 0; j <= 3000; j++) {
			ll ans = i * r + j * g;
			if ((n-ans)%b==0 && n>=ans) cnt++;
		}
	}

	cout << cnt << endl;
}

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

int main(){
    int N; cin >> N;
    int T[N];
    int S=0;
    for (int i=0; i<N; i++){
        cin >> T[i];
        S += T[i];
    }
    int M; cin >> M;
    int p[M], x[M];
    for (int i=0; i<M; i++){
        cin >> p[i] >> x[i];
    }
    for (int i=0; i<M; i++){
        cout << S - T[p[i]-1] + x[i] << endl;
    }
}


Measured memory_bytes: 256
s=list(input())
t=[]
for i in range(0,len(s)):
    if s[i]=='B' and len(t)==0:pass
    elif s[i]=='B' and len(t)!=0:del t[-1]
    elif s[i]=='0':t.append('0')
    else:t.append('1')
print("".join(t))

Measured memory_bytes: 3060
/*
 * jiku_sugoroku.cpp
 *
 *  Created on: 2017/04/24
 *      Author: Nishio
 */
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<(int)N;i++)
#define p(S) cout<<(S)<<endl
#define ck(n,a,b) (a<=(n)&&(n)<b)
typedef long long ll;
using namespace std;
const int inf=1e9;


int main(){
	int n;
	cin>>n;
	int dp[100010];//no-visit inf, NG -inf,
	int effect[100010];
	REP(i,0,n) cin>>effect[i];
	REP(i,0,n) dp[i]=inf;
	queue<int> q;
	dp[0]=0;
	q.push(0);
	//bfs
	while(!q.empty()){
		int now=q.front();q.pop();
		REP(i,1,7){
			int next=now+i;
			if(next>n-1) break;
			if(dp[next]==inf){
				set<int> s;//check
				while(1){
					s.insert(next);
					next+=effect[next];
					if(effect[next]==0){
						s.insert(next);
						for(auto itr=s.begin();itr!=s.end();itr++) {
							dp[*itr]=min(dp[*itr],dp[now]+1);
						}
						q.push(next);
						break;
					}
					if(s.find(next)!=s.end()||dp[next]!=inf){
						for(auto itr=s.begin();itr!=s.end();itr++) dp[*itr]=inf-1;
						break;
					}
				}
			}
		}
		if(dp[n-1]<inf-1){
			break;
		}
	}
	p(dp[n-1]);
	return 0;
}

Measured memory_bytes: 7800
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define DEBUG(x)           cout << '>' << #x << ':' << x << endl;
#define forn(i,n)          for(int i=0;i<(int)n;++i)
#define for1(i,n)          for(int i=1;i<=(int)n;++i)
#define forr(i,n)          for(int i=(int)n-1;i>=0;--i)
#define forre(i,a,b)       for(int i=(int)b;i>=(int)a;--i)
#define fore(i,a,b)        for(int i=(int)a;i<=(int)b;++i)
#define input(arr,n)       for(int i=0;i<n;i++)cin>>arr[i]
#define output(arr,n)      for(int i=0;i<n;i++)cout<<arr[i]<<" "
#define for_each(arr)      for(auto& it:arr)cout<<it<<" "
#define ff                 first
#define ss                 second
#define PI                 acos(-1.0)
#define all(a)             a.begin(),a.end()
#define rall(a)            a.rbegin(),a.rend()
#define Unique(a)          sort(all(a)),a.erase(unique(all(a)),a.end())
#define pb(x)              push_back(x)
#define eb(x)              emplace_back(x) 
#define ppb(x)             pop_back(x)
#define pf(x)              push_front(x)
#define ppf(x)             pop_front(x)
#define in(x,y)            insert({x,y})
#define Sort(a)            sort(a.begin(),a.end())
#define mem(arr,a)         memset(arr,a,sizeof arr)
#define ins(a)             insert(a)
#define max2(a,b)          max(a,b)
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max3(b,c,d))
#define min2(a,b)          min(a,b)
#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min3(b,c,d))
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<char> vc;
typedef vector<double> vd;
/*inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void Set(int & n, int b) { n |= two(b); }
inline void Reset(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }*/
/*int fx1[]={+1,-1,+0,+0};
int fy1[]={+0,+0,+1,-1};
int fx2={+0,+0,+1,-1,-1,+1,-1,+1};
int fy2={-1,+1,+0,+0,+1,+1,-1,-1};
*/

ll a,b,c,n,ans,cn1,cn2,cn3,t;
string s,s1,s2;


int main()
{
    FIO;
   // #ifndef ONLINE_JUDGE
   // freopen("input.txt","r",stdin);
  ////  freopen("output.txt","w",stdout);
  //  #endif
    cin>>a>>b;
    if(a==b){
    	cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    

    
   	
    #ifdef ONLINE_JUDGE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    #endif
   return 0;
}
 


Measured memory_bytes: 256
while True:
	a,b,c = input().split()

	if b == "?":
		break
	elif b == "+":
		s = int(a)+int(c)
	elif b == "-":
		s = int(a)-int(c)
		
	elif b == "*":
		s = int(a)*int(c)
		
	else :
		s = int(a)/int(c)
	print(int(s))

Measured memory_bytes: 7536
#include<stdio.h>
#include<string.h>
#include <stdlib.h>
int main(void){
    int N;
    int P,min=200001,SUM=0;
    scanf("%d",&N);
    for (int i=0; i<N; i++) {
        scanf("%d",&P);
        if (min>P) {
            min=P;
            SUM++;
        }
    }
    printf("%d\n",SUM);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int X = sc.nextInt();
    int A[] = new int [M];
    int left = 0;
    for(int i=0;i<M;i++){
      if(sc.nextInt()<X){
        left++;
      }
    }
    System.out.println(Math.min(left, M-left));
  }
}
    
    
    

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
const ll LINF = 1e11;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }


void solve() {
    int n;
    cin >> n;

    int ans = (n - 2) * 180;

    cout << ans << "\n";
}


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

    solve();
    return 0;
}


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

using namespace std;

int main(void) {
	int N, K;
	cin >> N >> K;
	map<int, int> MA;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		MA[A]++;
	}
	vector<int> C;
	for (auto itr = MA.begin(); itr != MA.end(); itr++) {
		C.push_back(itr->second);
	}
	sort(C.begin(), C.end());

	long long ans = 0;
	for (int i = 0; i < (signed)MA.size() - K; i++) {
		ans += C[i];
	}

	cout << ans << endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 10748
fun main() {
	val n = readLine()!!.toInt()
	val a = LongArray(n+1) {0L}

	var r=0L

	for(i in 1..n) {
		for(j in i..n step i)
			++a[j]
		r+=a[i]*i
	}
	println(r)
}


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

string is_vowel(char);

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	char c;
	cin >> c;
	
	cout << is_vowel(c);
	
	return 0;
}

string is_vowel(char c){
	switch(c){
		case 'a':
		case 'e':
		case 'i':
		case 'o':
		case 'u':
			return "vowel";
		default:
			return "consonant";
	}
}

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

int main()
{
    int n;
    cin >> n;
    int l[n];
    int maxl = 0;
    int suml = 0;
    rep(i, n) {
        cin >> l[i];
        suml += l[i];
        maxl = max(maxl, l[i]);
    }

    if (suml - maxl > maxl) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 764
// g++ -std=gnu++1y -O2 main.cpp

#include <cstdio>
#include <vector>
#include <set>

#include <map>
#include <unordered_map>
#include <string>
#include <utility>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <climits>

using namespace std;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
	int X, Y, Z;
	cin >> X >> Y >> Z;
	cout << Z << ' ' << X << ' ' << Y << endl;
	return 0;
}

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

int main(void)
{
	long long  l1, l2, tmp1, tmp2, tmp;
	while (cin >> l1 >> l2) {
		tmp1 = max(l1, l2);
		tmp2 = min(l1, l2);
		while (tmp1 && tmp2) {
			tmp = tmp1 % tmp2;
			tmp1 = tmp2;
			tmp2 = tmp;
		}
		tmp2 = l1 * l2 / tmp1;

		cout << tmp1 << " " << tmp2 << endl;
	}

	return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int main()
{
    int n;
    cin>>n;
    int a[n][n];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>a[i][j];
        }
    }
    int dp[1<<n]={};
    dp[0]=1;
    for(int i=0;i<1<<n;i++)
    {
        int x=__builtin_popcount(i);
        for(int j=0;j<n;j++)
        {
            if(a[x][j]&&!(i&1<<j))
            {
               
                    dp[i|1<<j]=(dp[i|1<<j]+dp[i])%mod;
                
            }
        }
    }
    cout<<dp[(1<<n)-1]%mod<<endl;
}

Measured memory_bytes: 8448
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            int X = Integer.parseInt(s);

            int e = 1;
            if (X == 1) e = X;
            else {
                for (int i = 2; i <= X; i++) {
                    for (int j = 2; j <= X; j++) {
                        if (X < Math.pow(i, j)) break;
                        if (e < (int)Math.pow(i, j))
                            e = (int)Math.pow(i, j);
                    }
                }
            }

            System.out.println(e);
        }
    }
}


Measured memory_bytes: 20692
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

s = ns()

def go(s):
    return s == s[::-1]

n = len(s)
print("Yes" if go(s) and go(s[0:(n-1)//2]) else "No")


Measured memory_bytes: 38384
/*input
5
2 5 2
2 3 10
1 3 8
3 4 2
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define int long long 
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define FOR(i,n) for(int i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int power(int x, int y, int mod = 2e18)
{int ans = 1;x%=mod;while(y){if(y&1)ans = (x * ans) % mod;x = (x * x) % mod;y >>= 1;}return ans;}

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " : " << arg1 << "  ";
        __f(comma + 1, args...);
    }
#else
#define trace(...)
#endif // ifndef ONLINE_JUDGE

template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) os << v[i] << " "; return os; } 
template <typename T> ostream& operator << (ostream& os, const set<T>& v) { for (auto it : v) os << it << " "; return os; } 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T, S>& v) { os << v.first << " " << v.second; return os; } 
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << "\n"; return os; } 

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
int const MOD = 1e9+7;
int const inf = 2e18;
int const N = 2e5+10;
vector<int> v[N];
int col[N];
void dfs(int i,int p=-1,int c = 0){
  col[i]=c;
  for(auto x : v[i]){
    if(x!=p){
      dfs(x,i,!c);
    }
  }
}
signed main() {
  IOS;
  int n;
  cin>>n;
  int ct = 1e5+1; 
  FOR(i,n-1){
    int x,y,w;
    cin>>x>>y>>w;
    w%=2;
    if(!w){
      v[x].pb(ct);
      v[ct].pb(x);
      v[ct].pb(y);
      v[y].pb(ct);
      ct++;
    }
    else
    {
      v[x].pb(y);
      v[y].pb(x);
    }
  }
  dfs(1);
  FOR(i,n+1){
    if(!i)continue;
    cout << col[i] << endl;
  }
return 0;
}

Measured memory_bytes: 14080
#include<stdio.h>
#include<algorithm>
#include<string>
#include<vector>
#include<string.h>
using namespace std;
int R=10;
string s[2100];
char in[11000];
typedef unsigned long long wolf;
wolf rj[11000];
wolf ks=1000000007;
char rd[2010][10010];
char dp[2010][10010];
char st[2010][10010];
vector<wolf> Hash[2010];
wolf cur[10010];
int lc[10100];
int f[]={114,514,810,1919,893,364364,334,1000000007,31415926,1145141919};
inline bool eq(int a,int b,int c,int d){
	int len=b-a;
//	printf("%d %d %d: %llu %llu %llu %llu\n",a,b,c,cur[b]-cur[a],Hash[c][len],rj[a],Hash[c][len]*rj[a]);
	if(cur[b]-cur[a]!=Hash[c][len]*rj[a])return false;
	for(int i=0;i<R;i++){
		int at=f[i]%len;
		if(st[d][a+at]!=s[c][at]){
		//	printf("%d\n",i);
			return false;
		}
	}
	return true;
}
inline int calc(int a,int b){
	if(eq(a,a+s[b].size(),b,b))return 9999999;
	int left=a-1;
	int right=a+s[b].size();
	while(left+1<right){
		int M=(left+right)/2;
		if(eq(a,M+1,b,b)){
			left=M;
		}else right=M;
	}
	//printf("%d\n",right);
	//if(right==a+s[b].size())return 0;
	//if(s[b][right-a]<st[b][right])return 1;
	//return -1;
	return right;
}
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%s",in);
		s[i]=in;
	}
	rj[0]=1;
	for(int i=1;i<11000;i++)rj[i]=rj[i-1]*ks;
	rd[a][b]=1;
	for(int i=a;i;i--){
		for(int j=0;j<=b;j++){
			if(rd[i][j]&&j>=s[i-1].size()){
				rd[i-1][j-(int)(s[i-1].size())]=1;
			}
			if(rd[i][j])rd[i-1][j]=1;
		}
	}
	for(int i=0;i<a;i++){
		Hash[i]=vector<wolf>(s[i].size()+1);
		wolf now=0;
		wolf tt=1;
		for(int j=0;j<s[i].size();j++){
			now+=tt*s[i][j];
			tt*=ks;
			Hash[i][j+1]=now;
	//		printf("%llu ",now);
		}
	//	printf("\n");
	}
	dp[0][0]=1;
	for(int i=0;i<b;i++)st[0][i]='~';
	for(int i=0;i<a;i++){
		wolf now=0;
		wolf tt=1;
		for(int j=0;j<b;j++){
			now+=tt*st[i][j];
			tt*=ks;
			cur[j+1]=now;
		//	printf("%llu ",now);
		}
		//printf("\n");
		for(int j=0;j<=b;j++)st[i+1][j]=st[i][j];
	//	if(i==1561)printf("%s\n",st[i]);
		int lcp=b;
		int bv=-1;
		for(int j=0;j<=b;j++){
			if(!dp[i][j])continue;
			if(j+s[i].size()<=b&&rd[i+1][j+s[i].size()]){
				int val=calc(j,i);
				lc[j]=val;
				if(bv==-1){
					if(val<b&&s[i][val-j]<st[i][val]){
						bv=j;
						lcp=lc[j];
					}
				}else{
					if((val<lc[bv]&&s[i][val-j]<st[i][val])||(val==lc[bv]&&s[i][val-j]<=s[i][lc[bv]-bv])){
						bv=j;
						lcp=lc[j];
					}
				}
				
			}
		}
	//	if(i==1560)printf("%d %d\n",bv,lcp);
		if(bv!=-1){
			for(int j=bv;j<bv+s[i].size();j++)st[i+1][j]=s[i][j-bv];
			for(int j=bv+s[i].size();j<b;j++)st[i+1][j]='~';
		}
		//printf("%s\n",st[i+1]);
		now=0;
		tt=1;
		for(int j=0;j<b;j++){
			now+=tt*st[i+1][j];
			tt*=ks;
			cur[j+1]=now;
		//	printf("%llu ",now);
		}
		for(int j=0;j<=b;j++){
			if(!dp[i][j])continue;
	//		printf("%d %d\n",i,j);
			if(j+s[i].size()<=b&&lcp>=j&&rd[i+1][j+s[i].size()]){
				if(eq(j,j+s[i].size(),i,i+1))dp[i+1][j+s[i].size()]=1;
			}
			if(rd[i+1][j]&&j<=lcp){
				dp[i+1][j]=1;
		//		if(i>1550)printf("%d %d\n",i,j);
			}
		}
	}
	printf("%s\n",st[a]);
}

Measured memory_bytes: 62592
n = str(input())
a = n[-1]
a = int(a)
if (a == 2) or (a == 4) or (a == 5) or (a == 7) or (a == 9):
    print("hon")
elif (a == 0) or (a == 1) or (a == 6) or (a == 8):
    print("pon") 
else:
    print("bon")

Measured memory_bytes: 9188
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

#define TIMES(i) while(i--)
#define REP(i, n) for ( int i = 0; i < n; i++ )

using namespace std;

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

    TIMES(n) {
        // ??\???
        double ax, ay, ar, bx, by, br;
        cin >> ax >> ay >> ar >> bx >> by >> br;

        // ?????¢????±???????
        double dis_x = abs(ax-bx),
            dis_y = abs(ay-by),
            dist = sqrt(dis_x * dis_x + dis_y * dis_y);

        // cout << dis_x << " " << dis_y << " " << dist << endl;

        // ??¢????????????
        if ( dist > ar + br ) {
            cout << 0;

        // a????????????????????????
        } else if ( dist + ar < br ) {
            cout << -2;

        // b????????????????????????
        } else if ( dist + br < ar ) {
            cout << 2;

        // ????????£?????????
        } else {
            cout << 1;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1232
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool in_range(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool in_range(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//



int main() {
	string S;
	cin >> S;
	int n = S.size();
	cout << S.substr(0,n-8) << endl;
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 764
from subprocess import *
call(('pypy3','-c',"""
import sys
def input(): return sys.stdin.readline().rstrip()
# 単位元とseg_funcを設定する
from fractions import gcd
class seg():
    def __init__(self,init_val):
        self.n=len(init_val)
        self.ide_ele=0 #単位元
        self.num=2**(self.n-1).bit_length() #n以上の最小の2のべき乗
        self.seg=[self.ide_ele]*2*self.num
        for i in range(self.n):
            self.seg[i+self.num-1]=init_val[i]
        for i in range(self.num-2,-1,-1):
            self.seg[i]=self.seg_func(self.seg[2*i+1],self.seg[2*i+2])
    def seg_func(self,a,b):
        #return a+b #0
        #return a*b #1
        return gcd(a,b) #0
        #return max(a,b) #-1か-10**10 (十分小さいもの)
        #return min(a,b) #10**10 (十分大きいもの)
    def update(self,k,x):
        k+=self.num-1
        self.seg[k]=x
        while k:
            k=(k-1)//2
            self.seg[k]=self.seg_func(self.seg[k*2+1],self.seg[k*2+2])
    def query(self,p,q): #O(logN)
        if q<=p:return self.ide_ele
        p+=self.num-1
        q+=self.num-2
        self.res=self.ide_ele
        while q-p>1:
            if p&1==0:
                self.res=self.seg_func(self.res,self.seg[p])
            if q&1==1:
                self.res=self.seg_func(self.res,self.seg[q])
                q-=1
            p=p//2
            q=(q-1)//2
        if p==q:self.res=self.seg_func(self.res,self.seg[p])
        else:self.res=self.seg_func(self.seg_func(self.res,self.seg[p]),self.seg[q])
        return self.res

def main():
    n=int(input())
    A=[int(_) for _ in input().split()]
    ans=0
    seg_a=seg(A)
    for i in range(n):
        ans=max(ans,gcd(seg_a.query(0,i),seg_a.query(i+1,n)))
    print(ans)
if __name__=='__main__':
    main()
"""))

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

int main() {
  double N, d;
  double count = 0;
  cin >> N;
  for (int i = 1; i <= N; i++)
  {
    if (i % 2 == 1)
    {
      count++;
    }
  }
  d = count / N;
  cout << d << endl;
}

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

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

  int n;
  cin>> n;
  while ( n!=0) {
    int y =  n%10;
    if ( y == 7) {
      cout << "Yes" << endl;
      return 0;
    }
    n = n/10;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3600
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int k, n;

ll f(ll x, int cnt = 0) {
    if (cnt > n) return n;
    if (x == 0) return 1;
    x -= x / k + 1;
    if (x < 0) return 1;
    return f(x, cnt + 1) + 1;
}

int main() {
    cin >> n >> k;
    if (n == 1) {
        cout << 0 << endl;
        return 0;
    }
    ll r = 1000000000000000000, l = 0;
    while (r - l > 1) {
        ll mid = l + (r - l) / 2;
        //cout << mid << " " << f(mid) << endl;
        if (f(mid) >= n) {
            r = mid;
        }
        else {
            l = mid;
        }
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()




using namespace std;

int main(){
  ll a,b,c; cin>>a>>b>>c;
  ll k; cin>>k;
  ll K = k;

  ll ans = 0;

  k -= a;

  if(k<=0){ ans +=K; cout<<ans<<endl; return 0;}
  else ans+= a;

  k -= b;

  if(k<=0){cout<<ans<<endl; return 0;}

  ans -= min(k,c);

  cout<<ans<<endl;


  




  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
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;}
const int MOD = 1000000007;

void solve() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<char>> v(h);
  rep(i,h) {
    rep(j,w) {
      char c;
      cin >> c;
      v[i].push_back(c);
    }
  }

  int ans = 0;

  rep(bit1, (1 << h)) {
    rep (bit2, (1 << w)) {
      vector<vector<char>> copy = v;
      rep(i, h) {
        if (!(bit1 & (1 << i))) continue;
        else {
          rep(j,w) copy[i][j] = 'r';
        }
      }
      rep(i, w) {
        if (!(bit2 & (1 << i))) continue;
        else {
          rep(j,h) copy[j][i] = 'r';
        }
      }
      int temp = 0;
      rep(i,h) rep(j,w) {
        if (copy[i][j] == '#') temp++;
      }
      if (temp == k) ans++;
    }
  }

  cout << ans << endl;
}


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

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	if(b>a)return 0;
	if(a==b)return 1;
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n,k,ans;
string s;
signed main(){
	cin>>n>>k>>s;
	rep(i,s.size()-1)if(s[i]==s[i+1])ans++;
	cout<<min(n-1,ans+(2*k))<<endl;
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int N, M, Q, A, a[55], b[55], c[55], d[55], p[11];

void go(int x, int l)
{
	if (x == N){
		int S = 0;
		for (int i = 0; i < Q; i++){
			if (p[b[i]] - p[a[i]] == c[i]) S += d[i];
		}
		if (A < S)
			A = S;
	}
	else{
		for (int i = l; i <= M; i++){
			p[x + 1] = i;
			go(x + 1, i);
		}
	}
}
int main()
{
	scanf ("%d %d %d", &N, &M, &Q);
	for (int i = 0; i < Q; i++) scanf ("%d %d %d %d", &a[i], &b[i], &c[i], &d[i]);

	go(0, 1);
	
	printf ("%d\n", A);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

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

    int h,w;cin>>h>>w;
    vector<string> s(h);
    for(int i=0;i<h;i++) cin>>s[i];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#'){
                cout<<'#';
                continue;
            }
            int cnt=0;
            for(int k=0;k<8;k++){
                int nx=i+dx[k],ny=j+dy[k];
                if(nx<0 || h<=nx || ny<0 || w<=ny) continue;
                if(s[nx][ny]=='#') cnt++;
            }
            cout<<cnt;
        }
        cout<<endl;
    }
}


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

int main () {
  int a , b , x ;
  cin >> a >> b >> x ;
  
  if ( a > x ) {
    cout << "NO" << endl ;
  } else if ( (x-a) <= b ) {
    cout << "YES" << endl ;
  } else {
    cout << "NO" << endl ;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a, a+3);
	cout<<a[2]-a[0]<<endl;
	return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<string>w(n);
  set<string>A;
  for(int i=0;i<n;i++){
    cin>>w.at(i);
    A.insert(w.at(i));
  }
  if(n!=A.size()){
    cout<<"No"<< endl;
    return 0;
  }
  for(int i=1;i<n;i++){
    if(w.at(i-1).at(w.at(i-1).size()-1)!=w.at(i).at(0)){
      cout<<"No"<< endl;
      return 0;
    }
  }
  cout<<"Yes"<< endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,t;
    cin >> a >> b >> t;
    cout << b*(t/a) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
int y[101],r,n;

double mk_dis(int x1,int h,double cy){
  return sqrt(x1*x1+(h-cy)*(h-cy));
}


bool check(double cy){
  cy=(int)(cy*100000)/100000.0;
  double x=fabs(sqrt(r*r-cy*cy));
  if(cy>=0)x=r;
  int L=(-x-0.999999),R=(x+0.999999),hb[101]={};
  for(int i=L+50;i<R+50;i++)
    if(i>=50){
      if(mk_dis(i-50,y[i],cy)>=r)hb[i]++;
    }
    else {
      if(mk_dis(i-49,y[i],cy)>=r)hb[i]++;
    }
  
  for(int i=L+50;i<R+50;i++)if(!hb[i])return false;
  return true;
}

int main(){
  while(1){
    cin>>r>>n;
    if(!r&&!n)break;
    memset(y,0,sizeof(y));
    for(int i=0;i<n;i++){
      int x1,x2,h;
      cin>>x1>>x2>>h;
      for(int j=x1;j<x2;j++) y[j+50]=max(y[j+50],h);
    }
    double ans;
    for(ans=0;ans<41&&check(ans-r);ans+=0.0001);
    printf("%lf\n",ans-0.0001);
  }
  return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pci pair<char,int
#define mii map<int,int>
#define mll map<long long int,long long int>
#define mci map<char,int>
#define umii unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define umci unordered_map<char,int>
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define mod 1000000007
using namespace std;
#define maxval 10003000


int main(){
   IOS;
ll a,b,c,d;cin>>a>>b>>c>>d;
ll x=a*d;
x=max(x,a*c);
x=max(x,b*c);
x=max(x,b*d);
cout<<x<<"\n";  

    
return 0;    
}

Measured memory_bytes: 3652
import sys
sys.setrecursionlimit(10 ** 6)
N, M, Q = map(int, input().split())
a, b, c, d = [], [], [], []
for _ in range(Q):
    ta, tb, tc, td = map(int, input().split())
    ta -= 1
    tb -= 1
    a.append(ta)
    b.append(tb)
    c.append(tc)
    d.append(td)

x = []
def dfs(s):
    if len(s) - s.count("0") == N:
        x.append(s)
        return

    if s[-1] == "0":
        start = 10
    else:
        start = s[-1]
    for i in range(int(start), M+1):
        dfs(s + str(i))
        # x.append(res)

ans = 0
for i in range(1, M+1):
    x = []
    dfs(str(i))
    # print(x)
    for y in x:
        A = []
        for z in y:
            if z == "0":
                A[-1] += z
            else:
                A.append(z)
        A = [int(z) for z in A]
        # print(A)
        score = 0
        for ta, tb, tc, td in zip(a, b, c, d):
            if A[int(tb)] - A[int(ta)] == tc:
                score += td
        ans = max(ans, score)
print(ans)


Measured memory_bytes: 85160
#include<iostream>
#include<map>
#include<string>
using namespace std;
map<char,string> e;
map<string,char> d;
std::string noToCode(int no){
std::string ans="01234";
for(int i=0;i<5;i++){
	ans[4-i]=no%2+'0';
	no=no/2;
}
return ans;
}
void setMap(){
for(int i=0;i<26;i++){
	e['A'+i]=noToCode(i);
}
e[' '] = "11010"; 
e['.'] = "11011";
e[','] = "11100";
e['-'] = "11101";
e['\'']= "11110";
e['?'] = "11111";
 d["101"] = ' ';
 d["000000"] = '\'';
 d["000011"] = ','; 
 d["10010001"] = '-'; 
 d["010001"] = '.';
 d["000001"] = '?'; 
 d["100101"] = 'A'; 
 d["10011010"] = 'B'; 
 d["0101"] = 'C';
 d["0001"] = 'D'; 
 d["110"] = 'E'; 
 d["01001"] = 'F'; 
 d["10011011"] = 'G';
 d["010000"] = 'H'; 
 d["0111"] = 'I'; 
 d["10011000"] = 'J'; 
 d["0110"] = 'K';
 d["00100"] = 'L'; 
 d["10011001"] = 'M'; 
 d["10011110"] = 'N';
 d["00101"] = 'O';
 d["111"] = 'P'; 
 d["10011111"] = 'Q'; 
 d["1000"] = 'R'; 
 d["00110"] = 'S'; 
 d["00111"] = 'T'; 
 d["10011100"] = 'U';  
 d["10011101"] = 'V'; 
 d["000010"] = 'W'; 
 d["10010010"] = 'X'; 
 d["10010011"] = 'Y'; 
 d["10010000"] = 'Z'; 
}
int main(){
setMap();
string line,put1,ans;
int p,k,size;
while(getline(cin,line)){
	put1="";
	for(int i=0;i<line.size();i++){
		put1.append(e[line[i]]);
	}
	ans="";
	p=0;
	size=put1.size();
	while(p<size){
		for(int k=3;k<9;k++){
			if(p+k>size){
				 p=size;
				 break;
			}
			line=put1.substr(p,k);
			if(d.find(line)!=d.end()){
				ans+=d[line];
				p=p+k-1;
				break;
			}
		}
		p++;
	}
	cout<<ans<<"\n";
}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}

const int INF = 1 << 20;
const int MOD = 1e9 + 7;

map<int, int> prime(int n) {
   map<int, int> v;
   for (int i = 2; (ll)i * i <= n; i++) {
      while (n % i == 0) {
         v[i]++;
         n /= i;
      }
   }
   if (n > 1) v[n]++;
   return v;
}
int main() {
   int n;
   cin >> n;
   map<int, int> pr;
   rep(i, 1, n + 1) {
      auto mp = prime(i);
      for (auto s : mp) {
         pr[s.first] += s.second;
      }
   }
   int ans = 0;
   rep(i, 2, n + 1) {
      if (pr[i] >= 74) ans++;
   }
   rep(i, 2, n + 1) {
      rep(j, 2, n + 1) {
         if (i != j && pr[i] >= 4 && pr[j] >= 14) ans++;
      }
   }
   rep(i, 2, n + 1) {
      rep(j, 2, n + 1) {
         if (i != j && pr[i] >= 2 && pr[j] >= 24) ans++;
      }
   }
   rep(i, 2, n + 1) {
      rep(j, 2, n + 1) {
         rep(k, j + 1, n + 1) {
            if (i != j && i != k && pr[i] >= 2 && pr[j] >= 4 &&
                pr[k] >= 4)
               ans++;
         }
      }
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
n,x = gets.split.map(&:to_i)
p,b = 2.times.map{Array.new(51,0)}
p[0] = 1
50.times do |i|
    p[i+1] = p[i]*2+1
    b[i+1] = b[i]*2+2
end

ans = 0
while x > 0
    if x >= p[n]+b[n]
        x -= p[n]+b[n]
        ans += p[n]
        break if x == 0
        x -= 1
        ans += 1
    else
        x -= 1
        n -= 1
    end
end
puts ans

Measured memory_bytes: 1788
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N,Q = inputlist()
S = list(input())
sumac = [0]*N
li = [0]*Q
for i in range(1,N):
    if S[i-1] == 'A' and S[i] == 'C':
        sumac[i] = sumac[i-1]+1
        continue
    sumac[i] = sumac[i-1]
for i in range(Q):
    l,r = inputlist()
    l-=1
    r-=1
    li[i] = sumac[r]-sumac[l]
for i in range(Q):
    print(li[i])

Measured memory_bytes: 10988