akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W;
	cin >> H >> W;
	vector<string> A(H);
	for (int i = 0; i < H; i++) {
		cin >> A[i];
	}
	vector<vector<int> > D(H, vector<int>(W, 10000000));
	queue<pair<int, int> > qu;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (A[i][j] == '#') {
				qu.emplace(i, j);
				D[i][j] = 0;
			}
		}
	}
	int dx[4] = { 0,1,-1,0 };
	int dy[4] = { -1,0,0,1 };
	int res = 0;
	while (qu.size() > 0) {
		pair<int, int> p = qu.front(); qu.pop();

		for (int k = 0; k < 4; k++) {
			int xx = p.first + dx[k];
			int yy = p.second + dy[k];
			if (xx >= 0 && xx < H && yy >= 0 && yy < W) {
				if (D[xx][yy] > D[p.first][p.second] + 1) {
					D[xx][yy] = D[p.first][p.second] + 1;
					res = D[xx][yy];
					qu.emplace(xx, yy);
				}
			}
		}

	}


	cout << res << endl;
}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

int main(){

  ll n;cin>>n;
  ll taro=0,hanako=0;
  rep(i,0,n){
    string s,t;cin>>s>>t;
    if(s<t)hanako+=3;
    else if(s>t)taro+=3;
    else {
      taro++;
      hanako++;
    }
  }

  out(taro<<" "<<hanako);


  return 0;
}



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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

bool debug = 1;
#define MAX 800
int V,E;
vector<int> G[MAX];
double dp[MAX], dp2[MAX];

void compute() {
  for(int i=V-2;i>=0;--i) {
    rep(j,(int)G[i].size()) {
      int nex = G[i][j];
      dp[i] += (dp[nex] + 1.0);
    }
    dp[i] /= (double)G[i].size();
  }
  double answer = dp[0];
  for(int i=V-2;i>=0;--i) if( G[i].size() >= 2 ) {
    int pos = -1;
    double sum = 0;
    rep(j,(int)G[i].size()) {
      int nex = G[i][j];
      if( pos == -1 ) pos = nex;
      else if( LT(dp[pos],dp[nex]) ) pos = nex;
      sum += ( dp[nex] + 1.0 );
    }
    assert( pos != -1 );
    sum -= ( dp[pos] + 1.0 );
    dp2[i] = sum / (double)( (int)G[i].size() - 1 );

    for(int j=i-1;j>=0;--j) {
      dp2[j] = 0;
      rep(k,(int)G[j].size()) {
	int nex = G[j][k];
	if( nex <= i ) dp2[j] += ( dp2[nex] + 1.0 );
	else           dp2[j] += ( dp[nex]  + 1.0 );
      }
      dp2[j] /= (double)G[j].size();
    }
    if( LT(dp2[0],answer) ) answer = dp2[0];
  }
  printf("%.10f\n",answer);
}

int main() {
  cin >> V >> E;
  int s,t;
  rep(_,E) {
    cin >> s >> t;
    --s, --t;
    G[s].push_back(t);
  }
  compute();
  return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    // 整数の入力
    int N = sc.nextInt();
    int M = sc.nextInt();

    for (int i = 0; i < M; i++) {
      int ai = sc.nextInt();
      N = N - ai;
    }

    // 出力
    System.out.println(N < 0 ? -1 : N);
  }
}


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

struct mat {
	ll l, c, r;
};

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

	mat a[110][110];
	int N; cin >> N;
	ll l, r;
	for (int i = 0; i < N; i++) {
		cin >> l >> r;
		a[i][i].l = l;
		a[i][i].r = r;
		a[i][i].c = 0;
	}
	for (int l = 1; l < N;l++) {
		for (int i = 0; i+l < N; i++) {
			ll m = 1000010;
			a[i][i + l].l = a[i][i].l;
			a[i][i + l].r = a[i + l][i + l].r;
			for (int j = i; j < i + l; j++) {
				m = min(a[i][j].l * a[i][j].r * a[j + 1][i + l].r + a[i][j].c + a[j + 1][i + l].c, m);
			}
			a[i][i + l].c = m;
		}
	}
	cout << a[0][N-1].c << endl;
}


Measured memory_bytes: 3372
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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; }

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

    int H, W;
    cin >> H >> W;

    vs a(H);
    rep(i, H) cin >> a[i];

    vvll dp(H, vll(W));
    dp[0][0] = 1;

    //配るDP
    rep(h, H)
    {
        rep(w, W)
        {
            if (a[h][w] == '#') continue;
            if (h + 1 < H)
            {
                dp[h + 1][w] += dp[h][w];
                dp[h + 1][w] %= MOD;
            }
            if (w + 1 < W)
            {
                dp[h][w + 1] += dp[h][w];
                dp[h][w + 1] %= MOD;
            }
        }
    }

    cout << dp[H - 1][W - 1];

    return 0;
}

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


int main(){
    int a, b, c, k;
    int p, q, r;
    cin >> a >> b >> c >> k;

    vector<int> v{a, b, c};
    sort(v.begin(), v.end());

    for(int i=0;i<k;i++){
        v[2] *= 2;
    }

    cout << v[0] + v[1] + v[2] << endl;

	
	
	return 0;
}


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

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

  x = 0;
  y = 0;
  a = n / 1000;
  b = (n % 1000) / 100;
  c = (n % 100) / 10;
  d = (n % 10);
  
  if (a == b) {
    x = x + 1;
  } 
  if (b == c) {
    x = x + 1;
    if (x >= 2){
      y = 1;
    }
  } else {
    x = 0;
  }
  if (c == d) {
    x = x + 1;
    if (x >= 2){
      y = 1;
    }
  }
  
  if (y == 1) {
	cout << "Yes" << endl;
   } else {
	cout << "No" << endl;
     
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
vvi E(222222);
vi col(222222);
void dfs(ll now,ll par,ll color){
  col[now] = color;
  for(auto e:E[now]){
    if(e == par)continue;
    dfs(e,now,-color);
  }
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  for(int i=0;i<n-1;i++){
    ll a,b;cin>>a>>b;
    E[--a].pb(--b);
    E[b].pb(a);
  }
  dfs(0,-1,1);
  ll one = 0;
  for(int i=0;i<n;i++){
    one += (col[i] > 0);
  }
  vi ans(n);
  ll ocn = n/3+(n%3 >= 1),tcn = n/3+(n%3 == 2);
  if(one <= n/3 || (n-one) <= n/3){
    if(one <= n/3){
      ll now = 3;
      for(int i=0;i<n;i++){
	if(col[i] == 1){
	  ans[i] = now;
	  now += 3;
	}
      }
      for(int i=0;i<n;i++){
	if(col[i] == -1){
	  if(now > n){
	    now %= 3;now++;
	  }
	  ans[i] = now;
	  now += 3;
	}
      }
    }else{
      ll now = 3;
      for(int i=0;i<n;i++){
	if(col[i] == -1){
	  ans[i] = now;
	  now += 3;
	}
      }
      for(int i=0;i<n;i++){
	if(col[i] == 1){
	  if(now > n){
	    now %= 3;now++;
	  }
	  ans[i] = now;
	  now += 3;
	}
      }
    }
  }else{
    ll cnon = 0,cntw = 0;
    ll on = 1,two = 2,three = 3;
    // cout<<ocn<<" "<<tcn<<endl;
    for(int i=0;i<n;i++){
      if(col[i] == 1 && cnon < ocn){
	ans[i] = on;on+=3;
	cnon++;
      }else if(col[i] == -1 && cntw < tcn){
	ans[i] = two;two += 3;
	cntw++;
      }
    }
    for(int i=0;i<n;i++){
      if(ans[i] == 0){
	ans[i] = three;
	three+=3;
      }
    }
  }
  for(auto aa:ans)cout<<aa<<" ";
  cout<<endl;
  return 0;
}


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

int main() {
    long long n, a[100005], b[100005], ans=0, k, l, m;
    cin >> n;
    for(int i=0; i<=n; i++) cin >> a[i];
    for(int i=0; i<n; i++) cin >> b[i];
    for(int i=0; i<n; i++) {
        k=a[i];
        l=b[i];
        m=a[i+1];
        ans+=min(a[i],b[i]);
        a[i]=max(k-l,0LL);
        b[i]=max(l-k,0LL);
        ans+=min(a[i+1], b[i]);
        a[i+1]=max(m-b[i], 0LL);
    }
    cout << ans;
}

Measured memory_bytes: 1792
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String args[]) {
        FastReader sc = new FastReader();
        PrintWriter pw = new PrintWriter(System.out);
        String a, b;
        a = sc.next();
        b = sc.next();
        int ans = func(a, b);
        if (ans > 0) {
            pw.println("GREATER");
        }
        else if (ans == 0) {
            pw.println("EQUAL");
        }
        else
            pw.println("LESS");
        pw.close();
    }

    private static int func(String a, String b) {
        if (a.length() != b.length()) {
            if (a.length() > b.length()) return 1;
            else return -1;
        }
        else {
            for (int i = 0; i < a.length(); i++) {
                int first = a.charAt(i) - '0';
                int second = b.charAt(i) - '0';
                if (first > second) {
                    return 1;
                }
                if (first < second) {
                    return -1;
                }
            }
        }
        return 0;
    }


    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 21332
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
typedef long long                   ll;
typedef long double                 ld;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<double,double>         pdd;
typedef pair<ld,ld>                 pld;
typedef pair<string , string>       pss;
#define ts(x)                       to_string(x)
#define ti(x)                       stoi(x)
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define tab                         '\t'
#define sep                         ' '
#define mine(v)                     *min_element(all(v))
#define maxe(v)                     *max_element(all(v))
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define endl                        "\n"
inline ll input(){ll n; cin >> n ; return n;}

const int MAXN = 3e3 + 10;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;
const ll INF = 8e18;

ll pw(ll a , ll b)  { return (!b ? 1 : (b & 1 ? (a * pw(a * a % MOD, b / 2)) % MOD : pw(a * a % MOD, b / 2))); }

ld dp[MAXN][MAXN], v[MAXN];

int main(){
    fast_io;
    cout << fixed << setprecision(10);
    //scanf("%d %d %f %lld %s %c", &x);
    //printf("%d %d %f %lld %s %c", x);
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> v[i];
    }
    dp[1][1] = v[1];
    dp[1][0] = (1 - v[1]);
    for(int i = 2; i <= n; i++){
        for(int j = 0; j <= n; j++){
            if(j == 0){
                dp[i][j] = dp[i - 1][j] * (1 - v[i]);
                continue;
            }
            dp[i][j] = (dp[i - 1][j] * (1 - v[i]) + dp[i - 1][j - 1] * v[i]);
        }
    }
    ld ans = 0;
    for(int i = 0; i <= n; i++){
        if(n - i > i){
            ans += dp[n][i];
        }
    }
    cout << (1 - ans);
    return 0;
}




Measured memory_bytes: 141440
#include <stdio.h>

#define MAX 10000
#define NIL -1

struct Node {
    int p, left, right;
};

struct Node T[MAX];
int n, D[MAX], H[MAX];

void depth(int, int);
int height(int);
int sibling(int);
void printree(int);

int main() {
    int i, v, l, r, root = 0;
    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        T[i].p = NIL;
    }

    for (i = 0; i < n; i++) {
        scanf("%d%d%d", &v, &l, &r);
        T[v].left = l;
        T[v].right = r;
        if (l != NIL) T[l].p = v;
        if (r != NIL) T[r].p = v;
    }

    for (i = 0; i < n; i++) {
        if (T[i].p == NIL) root = i;
    }
    depth(root, 0);
    height(root);

    for (i = 0; i < n; i++) printree(i);

    return 0;
}


void depth(int u, int d) {
    if (u == NIL) return;
    D[u] = d;
    depth(T[u].left, d+1);
    depth(T[u].right, d+1);
}


int height(int u) {
    int h1 = 0, h2 = 0;
    if (T[u].left != NIL) h1 = height(T[u].left) + 1;
    if (T[u].right != NIL) h2 = height(T[u].right) +1;
    return H[u] = (h1 > h2 ? h1 : h2);
}


int sibling(int u) {
    if (T[u].p == NIL) return NIL;
    if (T[T[u].p].left != u && T[T[u].p].left != NIL) return T[T[u].p].left;
    if (T[T[u].p].right != u && T[T[u].p].right != NIL) return T[T[u].p].right;
    return NIL;
}


void printree(int u) {
    int deg = 0;

    printf("node %d: ", u);
    printf("parent = %d, ", T[u].p);
    printf("sibling = %d, ", sibling(u));

    if (T[u].left != NIL) deg++;
    if (T[u].right != NIL) deg++;

    printf("degree = %d, ", deg);
    printf("depth = %d, ", D[u]);
    printf("height = %d, ", H[u]);

    if (T[u].p == NIL) printf("root\n");
    else if (T[u].left == NIL && T[u].right == NIL) printf("leaf\n");
    else printf("internal node\n");

}


Measured memory_bytes: 2128
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def ufinit(n):
  global ufsz, ufances
  ufsz = [1] * n
  ufances = [0] * n
  for i in range(n):
    ufances[i] = i

def ufroot(x):
  global ufances
  a = []
  y = x
  while ufances[y] != y:
    a.append(y)
    y = ufances[y]
  for z in a:
    ufances[z] = y
  return y

def ufconn(x,y):
  global ufsz, ufances
  i = ufroot(x)
  j = ufroot(y)
  if i==j:
    return
  #k  = [i,j].min
  k  = j if (ufsz[i]<ufsz[j]) else i
  if k==j:
    ufances[i] = j
  else:
    ufances[j] = i
  ufsz[k] = ufsz[i] + ufsz[j]

n,m = inm()
k = []
l = []
for i in range(n):
    z = inl()
    k.append(z[0])
    l.append(z[1:])
ufinit(n+m)
for i in range(n):
    for j in l[i]:
        ufconn(i,j+n-1)
r = ufroot(0)
for i in range(1,n):
    if ufroot(i)!=r:
        print('NO')
        exit()
print('YES')


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

const int N = 100000+5;

int n;
pair<int, int> v[N];

void readInt(int &x){
	char c = getchar();
	x = 0;
	while(c != ' ' and c != '\n'){
		x = (x<<1) + (x<<3) + c - '0';
		c = getchar();
	}
}

int main(){
	readInt(n);
	for(int i = 1; i <= n; i++){
		readInt(v[i].second);
		readInt(v[i].first);
	}
	sort(v + 1, v + n + 1);
	int ans = 0;
	int lastR = -1;
	for(int i = 1; i <= n; i++){
		if(lastR < v[i].second){
			ans += 1;
			lastR = v[i].first;
		}
	}
	vector<int> v;
	while(ans > 0){
		v.emplace_back(ans % 10);
		ans /= 10;
	}
	if(v.empty()) puts("0");
	else{
		for(int i = v.size() - 1; i >= 0; i--){
			putchar('0' + v[i]);
		}
		putchar('\n');
	}
	return 0;
}


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

void solve(long long N, std::vector<long long> a){
    sort(a.begin(), a.end());
    long long ans = 0;
    for (int i = N; i < N * 3; i += 2)
        ans += a[i];
    cout << ans << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(3*N);
    for(int i = 0 ; i < 3*N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
    int n, k;
    int d[1100];
    int trick[10010] = {};
    int cnt = 0;

    cin >> n >> k;

    for (int i = 0; i < k; i++) {
        cin >> d[i];
        for (int j = 0; j < d[i]; j++) {
            int mem;
            cin >> mem;
            trick[mem]++;
        }
    }

    for (int i = 1; i <= n; i++) {
        if (trick[i] == 0) {
            cnt++;
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 3676
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = Integer.parseInt(sc.next());
		int Y = Integer.parseInt(sc.next());
		sc.close();

		if(4 * X < Y) {
			System.out.println("No");
		}else {
			int turtle = (Y - 2 * X) / 2;
			if((Y - 2 * X) % 2 == 0 && turtle >= 0) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}

	}

}

Measured memory_bytes: 35724
n = int(input())
l = [list(input()) for i in range(2)]

mod = 10**9+7

ans = 1
check = 0
count = 0
while count < n:
    if l[0][count] == l[1][count]:
        if count == 0:
            ans *= 3
            count += 1
            check = 1
        else:
            if check == 1:
                ans *= 2
                ans %= mod
                count += 1
            elif check == 2:
                count += 1
                check = 1
    else:
        if count == 0:
            ans *= 6
            count += 2
            check = 2
        else:
            if check == 1:
                ans *= 2
                ans %= mod
                count += 2
                check = 2
            else:
                ans *= 3
                ans %= mod
                count += 2
print(ans%mod)
                

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

int main(){
  int m,d; cin >> m >> d;
  
  int cnt = 0;
  
  for(int i = 1; i <= m; i++){
    
    int d1,d10;
    
    for(int j = 1; j <= d; j++){
      d10 = j/10;
      d1 = j%10;
    
    
    if( d1 >= 2 && d10 >= 2 && d1*d10 == i){ cnt++; }
    }
  }
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

template<typename T> bool chmax( T &a, const T &b ) { if ( a <= b ) { a = b; return ( true ); } else { return ( false ); } }
template<typename T> bool chmin( T &a, const T &b ) { if ( a >= b ) { a = b; return ( true ); } else { return ( false ); } }

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par.resize( n ); siz.resize( n ); par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


int main()
{
	int N, M;
	cin >> N;
	vector<string> vn( N );
	rep( i, N ) cin >> vn[i];

	cin >> M;
	vector<string> vm( M );
	rep( i, M ) cin >> vm[i];

	map<string, int> m;
	rep( i, N ) m[vn[i]]++;
	rep( i, M ) m[vm[i]]--;

	int total = 0;
	arep( it, m )
	{
		chmax( total, it.second );
	}

	cout << total << endl;

	return ( 0 );
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
int read(){
    char x;
    while((x = getchar()) > '9' || x < '0') ;
    int u = x - '0';
    while((x = getchar()) <= '9' && x >= '0') u = (u << 3) + (u << 1) + x - '0';
    return u;
}
int buf[105];  
inline void write(int i){  
    int p = 0;  
    if(i == 0) p++;  
    else while(i) {  
        buf[p++] = i % 10;  
        i /= 10;  
    }  
    for(int j = p-1; j >= 0; j--) putchar('0' + buf[j]);  
} 
int a[500005],ans[500005],cnt[500005],res=0,n,q,bl;
struct node{
	int l,r,id;
	int block;
}e[500005]; 

inline bool cmp(const node &a,const node &b){
	if(a.block^b.block)return a.l<b.l;
	
	if(a.block&1) return a.r<b.r;
	return a.r>b.r;
	
	
}

inline void del(int x){
	--cnt[a[x]];
	if(!cnt[a[x]])--res;
}
inline void add(int x){
	if(!cnt[a[x]])++res;
	++cnt[a[x]];
}

int main() {
	n=read();
	q=read();
	bl=n/sqrt(q*2/3);
	for(int i=1;i<=n;++i)a[i]=read();
	for(int i=1;i<=q;++i){
		e[i].l=read();
		e[i].r=read();
		e[i].id=i;
		e[i].block=e[i].l/bl;
	}
	sort(e+1,e+1+q,cmp);
	int l=e[1].l,r=e[1].l-1;
	for(int i=1;i<=q;++i){
		int stdl=e[i].l,stdr=e[i].r;
		while(l<stdl)del(l++);
		while(l>stdl)add(--l);
		while(r<stdr)add(++r);
		while(r>stdr)del(r--);
		ans[e[i].id]=res;
	}
	for(int i=1;i<=q;++i)write(ans[i]),printf("\n");
	return 0;
}

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

int main() {
  int h,w,k;cin>>h>>w>>k;
  vector<vector<char>> c(h,vector<char>(w));
  rep(i,h)rep(j,w)cin>>c[i][j];
  int ans=0;
  rep(bit1,1<<h)rep(bit2,1<<w){
    int cnt=0;
    rep(i,h)rep(j,w){
      if(bit1&(1<<i))continue;
      if(bit2&(1<<j))continue;
      if(c[i][j]=='#')cnt++;
    }
    if(cnt==k)ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3624
import java.util.*

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val pq = PriorityQueue<Int>(n) { o1, o2 -> -o1.compareTo(o2) }
    readLine()!!.split(' ')
            .map { it.toInt() }
            .forEach { pq.add(it) }
    repeat(m) {
        val a = pq.poll()
        pq.add(a / 2)
    }
    println(pq.fold(0L) { acc, i -> acc + i })
}


Measured memory_bytes: 74548
/* AtCoder コピペ */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repEq(i, n) for (int i = 0; i <= (int)(n); i++)
#define repVector(i, v) for (auto i = v.begin(); i != v.end(); ++i)

#define ifBetween(n, a, b) if (n > a && n < b)
#define ifBetweenEq(n, a, b) if (n >= a && n <= b)

int main() {
	int x[3];
  
  	rep(i, 3) {
    	cin >> x[i];
    }
 
  	std::vector<int> vec(x, x + sizeof x / sizeof x[0]);
    sort(vec.begin(), vec.end(), greater<>());
  
  	int biggestBag = vec[0];
  	int otherBags = vec[1] + vec[2];

  	cout << (biggestBag == otherBags ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
using vpll = vector<pll>;

#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define RREP(i, n) for(ll i = n-1; i >= 0; i--)
#define FOR(i, a, b) for(ll i = a; i <= (ll)(b); i++)
#define RFOR(i, a, b) for(ll i = a; i >= (ll)(b); i--)

#define SIZE(x) ((ll)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));

#define PB push_back
#define MP make_pair
#define F first
#define S second

#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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; }

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S; cin >> S;
    string n = S.substr(S.length() - 1, S.length());
    if (n == "2" || n == "4" || n == "5" || n == "7" || n == "9") {
        cout << "hon" << endl;
    } else if (n == "0" || n == "1" || n == "6" || n == "8") {
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }
}

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

typedef long long LL;
const int N = 16;
int xsel[1 << 15][N], ysel[1 << 15][N];
int x[N], y[N], p[N];
LL res[N];

void solve() {
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d%d%d", &x[i], &y[i], &p[i]);
    }
    memset(res, 0x3f, sizeof res);

    for(int i = 0; i < 1 << n; i++) {
        for(int j = 1; j <= n; j++) {
            xsel[i][j] = abs(x[j]);
            ysel[i][j] = abs(y[j]);
            for(int k = 0; k < n; k++) {
                if((i >> k) & 1) {
                    xsel[i][j] = min(xsel[i][j], abs(x[j] - x[k + 1]));
                    ysel[i][j] = min(ysel[i][j], abs(y[j] - y[k + 1]));
                }
            }
        }
    }

    for(int i = 0; i < 1 << n; i++) {
        int cnt = 0;
        for(int j = 0; j < n; j++) {
            if((i >> j) & 1) cnt++;
        }
        for(int j = i; j >= 0; j--) {
            j &= i;     // 状态i的情况下，在选择x轴方向的马路状态
            LL sum = 0;
            for(int k = 0; k < n; k++) {
                if(!((i >> k) & 1)) {
                    sum += (LL)min(xsel[j][k + 1], ysel[i - j][k + 1]) * p[k + 1];
                }
            }
            res[cnt] = min(res[cnt], sum);
        }
    }

    for(int i = 0; i <= n; i++) {
        printf("%lld\n", res[i]);
    }
}

int main() {
//    freopen("in.txt", "r", stdin);
    solve();
    return 0;
}


Measured memory_bytes: 7800
#include <iostream>
#include <cstdio>
#define ll long long
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
ll n,a[20];
ll dfs(int l,int r,int xl,int xr)
{
	if(r - l <= 1) return 0;
	ll ans = 1e18;
	for(int i = l + 1;i < r;i ++) ans = min(ans,dfs(l,i,xl,xl + xr) + dfs(i,r,xl + xr,xr) + a[i] * (xl + xr));
	return ans;
}
int main()
{
	cin >> n; for(int i = 1;i <= n;i ++) cin >> a[i];
	cout << a[1] + a[n] + dfs(1,n,1,1);
}

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

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

  sort(vc.begin(), vc.end());
  int cnt = 0;
  for(int i = 0; i < n;i++){
    for (int j = 0; j < i;j++){
      for (int k = 0; k < j;k++){
        if ((vc[i] != vc[j] && vc[i] != vc[k] && vc[j] != vc[k]) && (vc[k] + vc[j] > vc[i]))
        {
          cnt++;
        }
      }
    }
  }

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
//#define mod 998244353

int N;
signed main(){
    scanf("%lld",&N);
    if(N==0)printf("1\n");
    if(N==1)printf("0\n");
}

Measured memory_bytes: 1656
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define MOD 998244353
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
#define ar array
#define ld long double
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
char c[4]={'D' , 'R' , 'U' , 'L'};
const ll maxN=2e5+5;
ll n , k;
ar<ll,3> a[maxN] , dp[maxN];
void solve(){
	cin>> n ;
	for(ll i=0;i<n ; i++){
		cin>>a[i][0]>>a[i][1]>>a[i][2];
		dp[i][0]=a[i][0] , dp[i][1]=a[i][1] , dp[i][2]=a[i][2];
	}
	for(ll i=1;i<n ; i++){
		dp[i][0]=a[i][0]+max(dp[i-1][1] , dp[i-1][2]);
		dp[i][1]=a[i][1]+max(dp[i-1][0] , dp[i-1][2]);
		dp[i][2]=a[i][2]+max(dp[i-1][1] , dp[i-1][0]);
	}
	ll ans= max({dp[n-1][0] , dp[n-1][1] , dp[n-1][2]});
	cout<<ans<<endl;
}
int main(){
	//mahakal();
	fast;
	ll t =1 ;
	//cin>> t ; 
	while(t--)solve();
	//cerr << "\ntime taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
	return 0;
}

Measured memory_bytes: 8284
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int v = 0;
        for(int i=0; i<2;i++){
            if(a>b){
                v += a;
                a--;
            }else{
                v += b;
                b--;
            }
        }
        System.out.println(v);
    }
}


Measured memory_bytes: 23124
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;

const string YES = "Yes";
const string NO = "No";

void solve(long long H, long long N, std::vector<long long> A){
    ll sum=0;
    REP(i, N) sum += A[i];
    if(sum >= H) cout<<YES<<endl;
    else cout<<NO<<endl;
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(H, N, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def input():
    return sys.stdin.readline()


def resolve():
    x, n = map(int, input().split())

    if n == 0:
        print(x)
        exit()

    p_list = list(map(int, input().split()))

    max_p = 100
    not_p_list = []


    flag = False
    for j in range(-max_p-1, max_p):
        j1 = j+1
        if j1 in p_list:
            pass
        else:
            not_p_list.append(j1)
    not_p_list.append(101)
    #print(not_p_list)

    min_num = 999
    ans = 0

    for i in not_p_list:

        m = abs(x - i)
        if min_num >= m:
            if min_num == m:
                continue
            min_num = m
            ans = i

    print(ans)

if __name__ == "__main__":
    resolve()



Measured memory_bytes: 62064
def c_name(a, b):
    x = '0'*(6-len(str(a)))
    y = '0'*(6-len(str(b)))
    return x + str(a) + y + str(b)

N, M = map(int,input().split())

C = []

for i in range(M):
    p, y = map(int,input().split())
    _ = [i, p, y]
    C.append(_)

C.sort(key=lambda x: (x[1],x[2]))

d = {}
tmp = C[0][1]
num = 0
for i in C:
    if i[1] == tmp:
        num += 1
        d[i[0]] = c_name(i[1],num)
    else:
        tmp = i[1]
        num = 1
        d[i[0]] = c_name(i[1],num)

ans = sorted(d.items())

for i in ans:
    print(i[1])


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

using namespace std;

typedef long long ll;

int main(){
	int n;
	cin >> n;
	vector<int> b;
	for(int i = 0; i < n; i++){
		int bb;
		cin >> bb;
		b.push_back(bb);
	}
	vector<int> ans;
	for(int i = (int)b.size()-1; i >= 0; i--){
		if(i+1-b[i] == 0){
			ans.push_back(b[i]);
			b.erase(b.begin()+i);
			i = (int)b.size();
		}
	}
	if((int)b.size() == 0){
		for(int i = n-1; i >= 0; i--)cout << ans[i] << endl;
	}
	else cout << -1 << endl;
    return 0;
}

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

int count(int bits) {
    if (bits == 0) return 0;
    return count(bits >> 1) + (bits & 1);
}
 
int main() {
    int N;
    int A[16];
    int x[16][16];
    int y[16][16];
 
    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
        for (int j = 1; j <= A[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }
 
    int result = 0;
    for (int bits = 1; bits < (1 << N); bits++) {
        bool ok = true;
        for (int i = 1; i <= N; i++) {
            if ( !( bits & ( 1 << (i-1) ) ) ) continue;
            for (int j = 1; j <= A[i]; j++) {
                if ( ( ((bits >> (x[i][j]-1)) & 1) ^ y[i][j] ) ) ok = false;
            }
        }
        if (ok) result = max(result, count(bits));
    }
 
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 888
r, c, n = map(int, input().split())
l = []
for i in range(n):
    x1, y1, x2, y2 = map(int, input().split())
    if (x1 == 0 or x1 == r or y1 == 0 or y1 == c) and (x2 == 0 or x2 == r or y2 == 0 or y2 == c):
        if x1 == 0:
            l.append((y1, i))
        elif y1 == c:
            l.append((c + x1, i))
        elif x1 == r:
            l.append((c * 2 + r - y1, i))
        else:
            l.append((r * 2 + c * 2 - x1, i))
        if x2 == 0:
            l.append((y2, i))
        elif y2 == c:
            l.append((c + x2, i))
        elif x2 == r:
            l.append((c * 2 + r - y2, i))
        else:
            l.append((r * 2 + c * 2 - x2, i))
l.sort()
s = []
d = [False] * n
for x, i in l:
    if d[i]:
        if s[-1] != i:
            print('NO')
            exit(0)
        s.pop()
    else:
        s.append(i)
        d[i] = True
print('YES')


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N){
    cin >> A[i];
  }
  set<int> used{1};
  int iter = 1;
  int count = 0;
  bool judge = 0;
  rep(i, N){
    iter = A[iter-1];
    count++;
    if (iter == 2) {
      judge = 1;
      break;
    }
  }
  if (judge) cout << count << endl;
  else cout << -1 << endl;
  
}


Measured memory_bytes: 640
def read_input():
    n = input()
    return n


def submit():
    n = read_input()
    d = [c for c in n]

    if d[0] == d[1] == d[2]:
        print('Yes')
    elif d[1] == d[2] == d[3]:
        print('Yes')
    else:
        print('No')



if __name__ == '__main__':
    submit()

Measured memory_bytes: 38256
#include <cstdio>
#include <cctype>

int
main(void)
{
  int i;
  char str[1201];
  
  std::fgets(str, sizeof(str), stdin);

  for (i = 0; str[i] != '\0'; i++) {
    if (std::islower(str[i])) {
      str[i] = toupper(str[i]);
    } else if (std::isupper(str[i])) {
      str[i] = tolower(str[i]);
    }
  }

  std::printf("%s", str);

  return 0;
}



Measured memory_bytes: 2696
//
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <array>
#include <numeric>
#include <functional>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <complex>

using namespace std;

#define REP(i,m,n) for(int i=m;i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef pair<int, int> pii;

int main(){

	int n;
	cin >> n;
	cout << (n-2)*180 << endl;
	return 0;
}


Measured memory_bytes: 888
//_nebula_
#include<bits/stdc++.h>
using namespace std;
#define int long  long
#define double long double
int t;
const int M=1e9+7;
int factt(int n)
{
    int ans=1;
    for(int i=1;i<=n;i++)
    {
        ans*=i;
        ans=ans%M;
    }
    return ans;
}
int max(int a,int b,int c)
{
    return max(a,max(b,c));
}
int min(int a,int b,int c)
{
    return min(a,min(b,c));
}
int fspow(int x,int y)
{
    int ans;
    if(y==0) return 1;
    ans=fspow(x, y/2);
    if(y%2==0) return (ans*ans)%M;
    return (x*((ans*ans)%M))%M;;
}
int gcd(int x,int y)
{
    if(x<y) swap(x,y);
    if(y==0) return x;
    return gcd(x%y,y);
}
int p2(int x)
{
    int ans=0;
    while(x>=1)
    {
        ans++;
        x/=2;
    }
    return ans;
}
int v=0;
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    t=1;
    // freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //  cin>>t;
    // int tmp=t;
    while(t--)
    {
        string a,b;
        cin>>a>>b;
        int na=a.size();
        int nb=b.size();
        int mn=1e18;
        for(int i=0;i<=na-nb;i++)
        {
            int cur=0;
            for(int j=i;j<i+nb;j++)
            {
                if(a[j]!=b[j-i]) cur++;
            }
            mn=min(cur,mn);
        }
        cout<<mn<<"\n";
    }
}


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

#define endl "\n"
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main()
{

    optimize();
    int N;
    cin>>N;
    vector<int>vec(N);
    for(int i=0; i<N; i++)
        cin>>vec[i];

    map<int,int >mp;
    for(auto u:vec)
        mp[u]++;
    int ans =0;


    for(auto u:mp)
        if(u.second>u.first)
            ans+=(u.second-u.first);
        else if(u.first>u.second)
            ans+=u.second;

    cout<<ans;

    return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

bool ans[60];

int main(){
  ll N; cin >> N;

  for (int i = 0; i < 60; i++){
    ll now = (ll) 1 << (i + 1);
    if (N % now != 0){
      ans[i] = true;
      if (i % 2 == 0) N -= now / 2;
      else N += now / 2;
    }

    if (N == 0){
      for (int j = i; j >= 0; j--) cout << ans[j];
      cout << endl;
      return 0;
    }
  }


  return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int n,i,j,k;
  vector<int> x(10010,0);
  cin >> n;
  for(i=1;i<=100;i++){
    for(j=1;j<=100;j++){
      for(k=1;k<=100;k++){
        if(i*i+j*j+k*k+i*j+j*k+k*i<=n){
          x[i*i+j*j+k*k+i*j+j*k+k*i]++;
        }
      }
    }
  }
  for(i=1;i<=n;i++){
    cout << x[i] << endl;
  }
  return 0;
}

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

#define mp make_pair
#define pb push_back
#define fill(a) memset(a,0,sizeof(a))

typedef long long ll;
typedef long double ld;




int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n; cin>>n;

    if(n>=30) cout<<"Yes";
    else cout<<"No";
    return 0;
}

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

int cnt_digits(long long n){
    int digits=0;
    while(n>0){
        n /= 10;
        digits++;
    }
    return digits;
}

int main(){
    long long n;
    cin >> n;
    int ans = cnt_digits(n);
    for(long long i=1; i<=sqrt(n); i++)
    {
        if(n%i!=0) continue;
        const long long k = n/i;
        const int cur = max(cnt_digits(i), cnt_digits(k));
        
        if(ans>cur) ans = cur;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int lli;
typedef long double ld;
const int oo = 1e9;
const int mod = 1e9+9;
//===========================================================//
const int nax = 1e5+3;
int n;
int dp[nax];
int a[nax];
int f(int i){
	if (i==n-1) return 0;
	if(dp[i]!=-1) return dp[i];
	int ans = abs(a[i]-a[i+1])+f(i+1);
	if(i!=n-2) ans = min(ans, abs(a[i]-a[i+2])+f(i+2));
	return dp[i]=ans;
}
int main(){
	cin>>n;
	for(int i=0; i<n; i++) cin>>a[i];
	memset(dp, -1, sizeof dp);
	cout<<f(0)<<endl;
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <complex>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;
constexpr double EPS = 1e-10;

using Point = complex<double>;
struct Line {
    Point s, t;
    Line(Point s, Point t) : s(s), t(t){}
};
double dot(Point p, Point q) { return (conj(p) * q).real(); }
double cross(Point p, Point q) { return (conj(p) * q).imag(); }

Point project(Line l, Point p) { // project p onto line (s,t)
    return l.s + (l.t - l.s) * dot(p - l.s, l.t - l.s) / norm(l.t - l.s);
}

Point reflect(Line l, Point p) {
    return l.s + conj((p - l.s) / (l.t - l.s)) * (l.t - l.s);
}

int ccw(Point a, Point b, Point c) {
    b -= a; c -= a;
    if(cross(b, c) >  EPS) return +1; // counter-clockwise
    if(cross(b, c) < -EPS) return -1; // clockwise
    if(  dot(b, c) < -EPS) return +2; // c--a--b
    if(abs(b)+EPS < abs(c))return -2; // a--b--c
    return 0; // a--c--b
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    double a,b,c,d;
    cin >> a >> b >> c >> d;
    Point p1(a, b), p2(c, d);
    cout << fixed << setprecision(10);

    int q;
    cin >> q;
    for(int i=0; i < q; ++i) {
        double x,y;
        cin >> x >> y;
        int ret = ccw(p1, p2, Point(x, y));
        switch(ret) {
            case +1:
                cout << "COUNTER_CLOCKWISE";
                break;
            case -1:
                cout << "CLOCKWISE";
                break;
            case +2:
                cout << "ONLINE_BACK";
                break;
            case -2:
                cout << "ONLINE_FRONT";
                break;
            default:
                cout << "ON_SEGMENT";
        }
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 3332
#include <stdio.h>

int main(void)
{
    int n;
    int i;

    scanf("%d", &n);
    printf("%d:", n);
    for (i = 2; i * i <= n; i++){
        while (n % i == 0){
            printf(" %d", i);
            n /= i;
        }
    }
    if (n > 1){
        printf(" %d", n);
    }
    puts("");

    return 0;
}

Measured memory_bytes: 608
input_ints = input().split()
x = int(input_ints[0])
y = int(input_ints[1])

if y <= 3:
    result_y = (4 - y) * 100000
else:
    result_y = 0
    
if x <= 3:
    result_x = (4 - x) * 100000
else:
    result_x = 0

result = result_y + result_x

if x == 1 and y == 1:
    result = result + 400000

print(result)

Measured memory_bytes: 3064